{#if x !== 0 || y !== 0} {/if}
{#if linkSource} {/if} {#each links as _, i} {@const sourceN = links[i].sourceNode} {@const targetN = links[i].targetNode} {/each} {#if mouseAction === 'create'} {#if Math.abs(startMX - curPosX) / grid_size <= 8 || Math.abs(startMY - curPosY) / grid_size <= 4}
{:else}
{/if}
{/if} {#each nodes as _, i} { try { await deleteR(`user/status/node/${nodes[i].id}`); links = links.filter(link => link.sourceNode.node.id !== nodes[i].id && link.targetNode.node.id !== nodes[i].id) nodes.splice(i, 1); nodes = nodes; } catch (e) { console.log("TODO inform the user", e) } }} onNodePointClick={async (inNodeX, inNodeY) => { if (mouseAction === undefined) { linkSource = { node: nodes[i], x: inNodeX, y: inNodeY }; mouseAction = 'link'; } else if (mouseAction === 'link' && linkSource) { if (nodes[i] === linkSource.node) { linkSource = undefined; return; } try { await put('user/status/link', { id: '', user_id: '', source_node: linkSource.node.id, target_node: nodes[i].id, bi: false, source_x: linkSource.x, source_y: linkSource.y, target_x: inNodeX, target_y: inNodeY } as FullLinkApi); // if mouse action is link then we can assume that linkSource is set links.push({ sourceNode: { ...linkSource }, targetNode: { node: nodes[i], x: inNodeX, y: inNodeY }, bi: false }); // Tell svelte that the links changed links = links; linkSource = undefined; mouseAction = undefined; } catch (e) { console.log('inform the user', e); } } }} /> {/each}