Connected nodes
This commit is contained in:
parent
2b8472bcd1
commit
ca0659a368
9 changed files with 581 additions and 89 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { Editor } from '@editor'
|
||||
import { MessageBus } from '@mbus'
|
||||
import { SelectType, SelectNode } from '@select_node'
|
||||
import { SelectType, SelectNodeDialog, ConnectionDataDialog } from '@select_node'
|
||||
|
||||
export class App {
|
||||
constructor() {// {{{
|
||||
|
|
@ -41,9 +41,9 @@ export class App {
|
|||
break
|
||||
|
||||
case 'NODE_CONNECT':
|
||||
const selectnode = new SelectNode(selectedNode => {
|
||||
const selectnode = new SelectNodeDialog(selectedNode => {
|
||||
this.nodeConnect(this.currentNode, selectedNode)
|
||||
.then(() => this.edit(this.currentNode))
|
||||
.then(() => this.edit(this.currentNode.ID))
|
||||
})
|
||||
selectnode.render()
|
||||
break
|
||||
|
|
@ -202,23 +202,11 @@ export class App {
|
|||
// The editor-node div is hidden from the start as a lot of the elements
|
||||
// doesn't make any sense before a node is selected.
|
||||
document.getElementById('editor-node').style.display = 'grid'
|
||||
})
|
||||
.catch(err => showError(err))
|
||||
|
||||
fetch(`/nodes/connections/${nodeID}`)
|
||||
.then(data => data.json())
|
||||
.then(json => {
|
||||
if (!json.OK) {
|
||||
showError(err)
|
||||
return
|
||||
}
|
||||
|
||||
const connectedNodes = new ConnectedNodes(json.Nodes)
|
||||
const connectedNodes = new ConnectedNodes(json.Node.ConnectedNodes)
|
||||
document.getElementById('connected-nodes').replaceChildren(connectedNodes.render())
|
||||
|
||||
})
|
||||
.catch(err => showError(err))
|
||||
|
||||
}// }}}
|
||||
async nodeRename(nodeID, name) {// {{{
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -318,12 +306,28 @@ export class App {
|
|||
})
|
||||
.catch(err => showError(err))
|
||||
}// }}}
|
||||
async nodeConnect(parentNode, nodeToConnect) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
// XXX - here
|
||||
//fetch('/nodes/)
|
||||
async nodeConnect(parentNode, nodeToConnect) {// {{{
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = {
|
||||
ParentNodeID: parentNode.ID,
|
||||
ChildNodeID: nodeToConnect.ID,
|
||||
}
|
||||
|
||||
fetch(`/nodes/connect`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(req),
|
||||
})
|
||||
.then(data => data.json())
|
||||
.then(json => {
|
||||
if (!json.OK) {
|
||||
showError(json.Error)
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
.catch(err => reject(err))
|
||||
})
|
||||
}
|
||||
}// }}}
|
||||
typeSort(a, b) {// {{{
|
||||
if (a.Schema['x-group'] === undefined)
|
||||
a.Schema['x-group'] = 'No group'
|
||||
|
|
@ -763,6 +767,12 @@ class ConnectedNode {
|
|||
<div class="type-icon"><img src="/images/${_VERSION}/node_modules/@mdi/svg/svg/${this.node.TypeIcon}.svg" /></div>
|
||||
<div class="node-name">${this.node.Name}</div>
|
||||
`
|
||||
|
||||
for (const el of tmpl.content.children) {
|
||||
el.addEventListener('click', () => {
|
||||
new ConnectionDataDialog(this.node, () => _app.edit(_app.currentNode.ID)).render()
|
||||
})
|
||||
}
|
||||
return tmpl.content
|
||||
}// }}}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue