From 27f77ba8ae3915e3d394f5310000805b9b6dde7d Mon Sep 17 00:00:00 2001 From: Michal Szczepanski Date: Sun, 21 Jul 2024 22:27:35 +0200 Subject: [PATCH] feat: remove backend for now --- .gitignore | 1 + backend/lib/__init__.py | 2 - backend/lib/graph.py | 64 ----------- backend/main.py | 9 -- frontend/package-lock.json | 170 ++++++++++++++++++++++++++++ frontend/package.json | 3 +- frontend/src/app/app.component.html | 15 +++ frontend/src/app/app.component.ts | 26 ++++- 8 files changed, 211 insertions(+), 79 deletions(-) delete mode 100644 backend/lib/__init__.py delete mode 100644 backend/lib/graph.py delete mode 100644 backend/main.py diff --git a/.gitignore b/.gitignore index fab8772..180fd98 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ tmp old data +.venv \ No newline at end of file diff --git a/backend/lib/__init__.py b/backend/lib/__init__.py deleted file mode 100644 index faa18be..0000000 --- a/backend/lib/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- diff --git a/backend/lib/graph.py b/backend/lib/graph.py deleted file mode 100644 index a7aa8ea..0000000 --- a/backend/lib/graph.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import logging -from enum import IntEnum - - -log = logging.getLogger(__name__) - - -class NodeStatus(IntEnum): - ERROR_PREPARING = -201 - ERROR_STARTING = -202 - ERROR_BUSY = -301 - ERROR_STOPPING = -401 - STALE = 101 - PREPARING = 201 - PREPARED = 202 - STARTING = 203 - READY = 204 - BUSY = 301 - STOPPING = 401 - -class Task: - data: any - error: any - result: any - - -class Queue: - def __init__(self, path: str, nodes: list[Node]): - self.path = path - - def add(self, task): - - -class Node: - def __init__(self, name): - self.name = name - self._state: NodeStatus = NodeStatus.STALE - - async def prepare(self, data): - if self._state != NodeStatus.STALE: - return - try: - self._state = NodeStatus.PREPARING - log.debug("preparing") - self._state = NodeStatus.READY - except: - self._state = NodeStatus.ERROR_PREPARING - - async def run(self, task: Task): - try: - self._state = NodeStatus.BUSY - log.debug("running") - except: - self._state = NodeStatus.ERROR_BUSY - - async def stop(self): - try: - self._state = NodeStatus.STOPPING - log.debug("stopping") - self._state = NodeStatus.STALE - except: - self._state = NodeStatus.ERROR_STOPPING diff --git a/backend/main.py b/backend/main.py deleted file mode 100644 index 2aeecd2..0000000 --- a/backend/main.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import logging - -log = logging.getLogger(__name__) - -if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) - log.debug('start') \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index ad9496c..96b0b43 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -20,6 +20,7 @@ "@angular/platform-browser-dynamic": "^18.1.0", "@angular/router": "^18.1.0", "@codemirror/lang-python": "^6.1.6", + "@xyflow/system": "^0.0.37", "codemirror": "^6.0.1", "codemirror-extension-inline-suggestion": "^0.0.3", "rxjs": "~7.8.0", @@ -6057,6 +6058,55 @@ "@types/node": "*" } }, + "node_modules/@types/d3-color": { + "version": "3.1.3", + "resolved": "https://npm.fnexe.com/@types/d3-color/-/d3-color-3.1.3.tgz", + "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", + "license": "MIT" + }, + "node_modules/@types/d3-drag": { + "version": "3.0.7", + "resolved": "https://npm.fnexe.com/@types/d3-drag/-/d3-drag-3.0.7.tgz", + "integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-interpolate": { + "version": "3.0.4", + "resolved": "https://npm.fnexe.com/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", + "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", + "license": "MIT", + "dependencies": { + "@types/d3-color": "*" + } + }, + "node_modules/@types/d3-selection": { + "version": "3.0.10", + "resolved": "https://npm.fnexe.com/@types/d3-selection/-/d3-selection-3.0.10.tgz", + "integrity": "sha512-cuHoUgS/V3hLdjJOLTT691+G2QoqAjCVLmr4kJXR4ha56w1Zdu8UUQ5TxLRqudgNjwXeQxKMq4j+lyf9sWuslg==", + "license": "MIT" + }, + "node_modules/@types/d3-transition": { + "version": "3.0.8", + "resolved": "https://npm.fnexe.com/@types/d3-transition/-/d3-transition-3.0.8.tgz", + "integrity": "sha512-ew63aJfQ/ms7QQ4X7pk5NxQ9fZH/z+i24ZfJ6tJSfqxJMrYLiK01EAs2/Rtw/JreGUsS3pLPNV644qXFGnoZNQ==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-zoom": { + "version": "3.0.8", + "resolved": "https://npm.fnexe.com/@types/d3-zoom/-/d3-zoom-3.0.8.tgz", + "integrity": "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==", + "license": "MIT", + "dependencies": { + "@types/d3-interpolate": "*", + "@types/d3-selection": "*" + } + }, "node_modules/@types/eslint": { "version": "8.56.10", "resolved": "https://npm.fnexe.com/@types/eslint/-/eslint-8.56.10.tgz", @@ -6696,6 +6746,21 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/@xyflow/system": { + "version": "0.0.37", + "resolved": "https://npm.fnexe.com/@xyflow/system/-/system-0.0.37.tgz", + "integrity": "sha512-hSIhezhxgftPUpC+xiQVIorcRILZUOWlLjpYPTyGWRu8s4RJvM4GqvrsFmD5OnMKXLgpU7/PqqUibDVO67oWQQ==", + "license": "MIT", + "dependencies": { + "@types/d3-drag": "^3.0.7", + "@types/d3-selection": "^3.0.10", + "@types/d3-transition": "^3.0.8", + "@types/d3-zoom": "^3.0.8", + "d3-drag": "^3.0.0", + "d3-selection": "^3.0.0", + "d3-zoom": "^3.0.0" + } + }, "node_modules/@yarnpkg/lockfile": { "version": "1.1.0", "resolved": "https://npm.fnexe.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", @@ -8417,6 +8482,111 @@ "dev": true, "license": "MIT" }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://npm.fnexe.com/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://npm.fnexe.com/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://npm.fnexe.com/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://npm.fnexe.com/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://npm.fnexe.com/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://npm.fnexe.com/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://npm.fnexe.com/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://npm.fnexe.com/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://npm.fnexe.com/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/date-format": { "version": "4.0.14", "resolved": "https://npm.fnexe.com/date-format/-/date-format-4.0.14.tgz", diff --git a/frontend/package.json b/frontend/package.json index ac23458..1c7e45c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -32,6 +32,7 @@ "@angular/platform-browser-dynamic": "^18.1.0", "@angular/router": "^18.1.0", "@codemirror/lang-python": "^6.1.6", + "@xyflow/system": "^0.0.37", "codemirror": "^6.0.1", "codemirror-extension-inline-suggestion": "^0.0.3", "rxjs": "~7.8.0", @@ -56,4 +57,4 @@ "typescript": "~5.5.2", "typescript-eslint": "8.0.0-alpha.38" } -} \ No newline at end of file +} diff --git a/frontend/src/app/app.component.html b/frontend/src/app/app.component.html index bb7c638..aba8a3f 100644 --- a/frontend/src/app/app.component.html +++ b/frontend/src/app/app.component.html @@ -1,6 +1,21 @@

Slow things

+ + + + + I'm a div inside a SVG. + + + I'm a second div inside a SVG. + + + + + + +
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index a8a8d6f..fccd2be 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,6 +1,7 @@ -import { Component } from '@angular/core'; +import {AfterViewInit, Component, ViewChild} from '@angular/core'; import { RouterOutlet } from '@angular/router'; import {GraphModule} from "./view/graph/graph.module"; +import { getBezierPath } from '@xyflow/system'; @Component({ selector: 'app-root', @@ -9,6 +10,25 @@ import {GraphModule} from "./view/graph/graph.module"; templateUrl: './app.component.html', styleUrl: './app.component.scss' }) -export class AppComponent { - title = 'slow-shit'; +export class AppComponent implements AfterViewInit { + @ViewChild('source') source: any + @ViewChild('target') target: any + @ViewChild('path') path: any + + ngAfterViewInit() { + const source = this.source.nativeElement; + const target = this.target.nativeElement; + console.log(source, source.offsetLeft, source.offsetTop, source.width) + console.log(target, target.offsetLeft) + const sourceRect = source.getBoundingClientRect() + const targetRect = target.getBoundingClientRect() + const path = getBezierPath({ + sourceX: source.offsetLeft + (sourceRect.width / 2), + sourceY: source.offsetTop + sourceRect.height, + targetX: target.offsetLeft + (targetRect.width / 2), + targetY: target.offsetTop + }) + console.log('path', path) + this.path.nativeElement.setAttribute('d', path[0]) + } }