├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── browserslist ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── example.png ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ ├── icons-provider.module.ts │ └── pages │ │ └── welcome │ │ ├── node-editor │ │ ├── link.model.ts │ │ ├── node-editor.component.html │ │ ├── node-editor.component.scss │ │ ├── node-editor.component.ts │ │ ├── node-slot │ │ │ ├── node-slot.component.html │ │ │ ├── node-slot.component.scss │ │ │ ├── node-slot.component.ts │ │ │ └── slot-type.enum.ts │ │ ├── node.model.ts │ │ └── node │ │ │ ├── node.component.html │ │ │ ├── node.component.scss │ │ │ └── node.component.ts │ │ ├── welcome-routing.module.ts │ │ ├── welcome.component.html │ │ ├── welcome.component.scss │ │ ├── welcome.component.ts │ │ └── welcome.module.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss └── test.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NgNodez ✨ 2 | 3 | Visual editor for adding, organizing and connecting nodes. 4 | 5 | ![example](example.png) 6 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ng-nodez": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss", 11 | "skipTests": true 12 | }, 13 | "@schematics/angular:class": { 14 | "skipTests": true 15 | }, 16 | "@schematics/angular:directive": { 17 | "skipTests": true 18 | }, 19 | "@schematics/angular:guard": { 20 | "skipTests": true 21 | }, 22 | "@schematics/angular:module": { 23 | "skipTests": true 24 | }, 25 | "@schematics/angular:pipe": { 26 | "skipTests": true 27 | }, 28 | "@schematics/angular:service": { 29 | "skipTests": true 30 | } 31 | }, 32 | "root": "", 33 | "sourceRoot": "src", 34 | "prefix": "app", 35 | "architect": { 36 | "build": { 37 | "builder": "@angular-devkit/build-angular:browser", 38 | "options": { 39 | "outputPath": "dist/ng-nodez", 40 | "index": "src/index.html", 41 | "main": "src/main.ts", 42 | "polyfills": "src/polyfills.ts", 43 | "tsConfig": "tsconfig.app.json", 44 | "aot": false, 45 | "assets": [ 46 | "src/favicon.ico", 47 | "src/assets", 48 | { 49 | "glob": "**/*", 50 | "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/", 51 | "output": "/assets/" 52 | } 53 | ], 54 | "styles": [ 55 | "./node_modules/ng-zorro-antd/ng-zorro-antd.min.css", 56 | "src/styles.scss" 57 | ], 58 | "scripts": [ 59 | "./node_modules/leader-line/leader-line.min.js" 60 | ] 61 | }, 62 | "configurations": { 63 | "production": { 64 | "fileReplacements": [ 65 | { 66 | "replace": "src/environments/environment.ts", 67 | "with": "src/environments/environment.prod.ts" 68 | } 69 | ], 70 | "optimization": true, 71 | "outputHashing": "all", 72 | "sourceMap": false, 73 | "extractCss": true, 74 | "namedChunks": false, 75 | "aot": true, 76 | "extractLicenses": true, 77 | "vendorChunk": false, 78 | "buildOptimizer": true, 79 | "budgets": [ 80 | { 81 | "type": "initial", 82 | "maximumWarning": "2mb", 83 | "maximumError": "5mb" 84 | }, 85 | { 86 | "type": "anyComponentStyle", 87 | "maximumWarning": "6kb", 88 | "maximumError": "10kb" 89 | } 90 | ] 91 | } 92 | } 93 | }, 94 | "serve": { 95 | "builder": "@angular-devkit/build-angular:dev-server", 96 | "options": { 97 | "browserTarget": "ng-nodez:build" 98 | }, 99 | "configurations": { 100 | "production": { 101 | "browserTarget": "ng-nodez:build:production" 102 | } 103 | } 104 | }, 105 | "extract-i18n": { 106 | "builder": "@angular-devkit/build-angular:extract-i18n", 107 | "options": { 108 | "browserTarget": "ng-nodez:build" 109 | } 110 | }, 111 | "test": { 112 | "builder": "@angular-devkit/build-angular:karma", 113 | "options": { 114 | "main": "src/test.ts", 115 | "polyfills": "src/polyfills.ts", 116 | "tsConfig": "tsconfig.spec.json", 117 | "karmaConfig": "karma.conf.js", 118 | "assets": [ 119 | "src/favicon.ico", 120 | "src/assets" 121 | ], 122 | "styles": [ 123 | "./node_modules/ng-zorro-antd/ng-zorro-antd.min.css", 124 | "src/styles.scss" 125 | ], 126 | "scripts": [] 127 | } 128 | }, 129 | "lint": { 130 | "builder": "@angular-devkit/build-angular:tslint", 131 | "options": { 132 | "tsConfig": [ 133 | "tsconfig.app.json", 134 | "tsconfig.spec.json", 135 | "e2e/tsconfig.json" 136 | ], 137 | "exclude": [ 138 | "**/node_modules/**" 139 | ] 140 | } 141 | }, 142 | "e2e": { 143 | "builder": "@angular-devkit/build-angular:protractor", 144 | "options": { 145 | "protractorConfig": "e2e/protractor.conf.js", 146 | "devServerTarget": "ng-nodez:serve" 147 | }, 148 | "configurations": { 149 | "production": { 150 | "devServerTarget": "ng-nodez:serve:production" 151 | } 152 | } 153 | } 154 | } 155 | } 156 | }, 157 | "defaultProject": "ng-nodez" 158 | } -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | 'browserName': 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 31 | } 32 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to ng-nodez!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinnormark/ng-nodez/681e3b6eb366c1bed0fca222907e5c09008e0823/example.png -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/ng-nodez'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-nodez", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~8.2.0", 15 | "@angular/cdk": "^8.1.2", 16 | "@angular/common": "~8.2.0", 17 | "@angular/compiler": "~8.2.0", 18 | "@angular/core": "~8.2.0", 19 | "@angular/forms": "~8.2.0", 20 | "@angular/platform-browser": "~8.2.0", 21 | "@angular/platform-browser-dynamic": "~8.2.0", 22 | "@angular/router": "~8.2.0", 23 | "leader-line": "^1.0.5", 24 | "ng-zorro-antd": "^8.1.2", 25 | "rxjs": "~6.4.0", 26 | "tslib": "^1.10.0", 27 | "zone.js": "~0.9.1" 28 | }, 29 | "devDependencies": { 30 | "@angular-devkit/build-angular": "~0.802.1", 31 | "@angular/cli": "~8.2.1", 32 | "@angular/compiler-cli": "~8.2.0", 33 | "@angular/language-service": "~8.2.0", 34 | "@types/node": "~8.9.4", 35 | "@types/jasmine": "~3.3.8", 36 | "@types/jasminewd2": "~2.0.3", 37 | "codelyzer": "^5.0.0", 38 | "jasmine-core": "~3.4.0", 39 | "jasmine-spec-reporter": "~4.2.1", 40 | "karma": "~6.3.14", 41 | "karma-chrome-launcher": "~2.2.0", 42 | "karma-coverage-istanbul-reporter": "~2.0.1", 43 | "karma-jasmine": "~2.0.1", 44 | "karma-jasmine-html-reporter": "^1.4.0", 45 | "protractor": "~5.4.0", 46 | "ts-node": "~7.0.0", 47 | "tslint": "~5.15.0", 48 | "typescript": "~3.5.3" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', pathMatch: 'full', redirectTo: '/welcome' }, 6 | { path: 'welcome', loadChildren: () => import('./pages/welcome/welcome.module').then(m => m.WelcomeModule) } 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [RouterModule.forRoot(routes)], 11 | exports: [RouterModule] 12 | }) 13 | export class AppRoutingModule { } 14 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 15 | 37 | 38 | 39 | 40 |
41 | 42 | 46 | 47 |
48 |
49 | 50 |
51 | 52 |
53 |
54 |
55 |
56 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | :host { 2 | display: flex; 3 | text-rendering: optimizeLegibility; 4 | -webkit-font-smoothing: antialiased; 5 | -moz-osx-font-smoothing: grayscale; 6 | } 7 | 8 | .app-layout { 9 | height: 100vh; 10 | } 11 | 12 | .menu-sidebar { 13 | position: relative; 14 | z-index: 10; 15 | min-height: 100vh; 16 | box-shadow: 2px 0 6px rgba(0,21,41,.35); 17 | } 18 | 19 | .header-trigger { 20 | height: 64px; 21 | padding: 20px 24px; 22 | font-size: 20px; 23 | cursor: pointer; 24 | transition: all .3s,padding 0s; 25 | } 26 | 27 | .trigger:hover { 28 | color: #1890ff; 29 | } 30 | 31 | .sidebar-logo { 32 | position: relative; 33 | height: 64px; 34 | padding-left: 24px; 35 | overflow: hidden; 36 | line-height: 64px; 37 | transition: all .3s; 38 | } 39 | 40 | .sidebar-logo img { 41 | display: inline-block; 42 | height: 32px; 43 | width: 32px; 44 | vertical-align: middle; 45 | } 46 | 47 | .sidebar-logo h1 { 48 | display: inline-block; 49 | margin: 0 0 0 20px; 50 | color: #001529; 51 | font-weight: 600; 52 | font-size: 14px; 53 | font-family: Avenir,Helvetica Neue,Arial,Helvetica,sans-serif; 54 | vertical-align: middle; 55 | } 56 | 57 | nz-header { 58 | padding: 0; 59 | width: 100%; 60 | z-index: 2; 61 | } 62 | 63 | .app-header { 64 | position: relative; 65 | height: 64px; 66 | padding: 0; 67 | background: #fff; 68 | box-shadow: 0 1px 4px rgba(0,21,41,.08); 69 | } 70 | 71 | nz-content { 72 | margin: 24px; 73 | } 74 | 75 | .inner-content { 76 | height: 100%; 77 | } 78 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | isCollapsed = false; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { IconsProviderModule } from './icons-provider.module'; 7 | import { NgZorroAntdModule, NZ_I18N, en_US } from 'ng-zorro-antd'; 8 | import { FormsModule } from '@angular/forms'; 9 | import { HttpClientModule } from '@angular/common/http'; 10 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 11 | import { registerLocaleData } from '@angular/common'; 12 | import en from '@angular/common/locales/en'; 13 | 14 | registerLocaleData(en); 15 | 16 | @NgModule({ 17 | declarations: [ 18 | AppComponent 19 | ], 20 | imports: [ 21 | BrowserModule, 22 | AppRoutingModule, 23 | IconsProviderModule, 24 | NgZorroAntdModule, 25 | FormsModule, 26 | HttpClientModule, 27 | BrowserAnimationsModule 28 | ], 29 | providers: [{ provide: NZ_I18N, useValue: en_US }], 30 | bootstrap: [AppComponent] 31 | }) 32 | export class AppModule { } 33 | -------------------------------------------------------------------------------- /src/app/icons-provider.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { NZ_ICONS } from 'ng-zorro-antd'; 3 | 4 | import { 5 | MenuFoldOutline, 6 | MenuUnfoldOutline, 7 | FormOutline, 8 | DashboardOutline 9 | } from '@ant-design/icons-angular/icons'; 10 | 11 | const icons = [MenuFoldOutline, MenuUnfoldOutline, DashboardOutline, FormOutline]; 12 | 13 | @NgModule({ 14 | providers: [ 15 | { provide: NZ_ICONS, useValue: icons } 16 | ] 17 | }) 18 | export class IconsProviderModule { 19 | } 20 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/link.model.ts: -------------------------------------------------------------------------------- 1 | export class Link { 2 | constructor ( 3 | public fromNodeId: string, 4 | public toNodeId: string 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-editor.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |
6 | 7 |
8 | 9 |
10 |
11 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-editor.component.scss: -------------------------------------------------------------------------------- 1 | .node-editor-wrapper { 2 | height: 100%; 3 | background-size: 20px 20px; 4 | background-color: #fff; 5 | background-image: radial-gradient(circle, #e5e5e5 1px, rgba(0, 0, 0, 0) 1px); 6 | box-shadow: 0px 2px 4px rgb(0, 0, 0, 0.25); 7 | 8 | .tools { 9 | padding: 12px; 10 | display: flex; 11 | flex-flow: row wrap; 12 | justify-content: flex-end; 13 | align-items: center; 14 | 15 | >* { 16 | margin-left: 24px; 17 | } 18 | } 19 | 20 | .nodes-container { 21 | position: relative; 22 | height: calc(100% - 64px); 23 | 24 | svg { 25 | position: absolute; 26 | width: 100%; 27 | height: 100%; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-editor.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, AfterViewInit, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, ViewChild, NgZone, ViewChildren, QueryList } from '@angular/core'; 2 | import { CdkDragMove } from '@angular/cdk/drag-drop'; 3 | import { NodeComponent } from './node/node.component'; 4 | import { Link } from './link.model'; 5 | import { Node } from './node.model'; 6 | 7 | declare var LeaderLine: any; 8 | 9 | @Component({ 10 | selector: 'app-node-editor', 11 | templateUrl: './node-editor.component.html', 12 | styleUrls: ['./node-editor.component.scss'], 13 | encapsulation: ViewEncapsulation.None, 14 | changeDetection: ChangeDetectionStrategy.OnPush 15 | }) 16 | export class NodeEditorComponent implements OnInit, AfterViewInit { 17 | 18 | nodes: Node[] = [new Node("nodeId_1", "💎 Workflow start", "⚡ Start being awesome ✨", false, true)]; 19 | 20 | links: Link[] = []; 21 | linkLines: any[] = []; 22 | 23 | @ViewChild('nodesContainer', null) nodesContainer: ElementRef; 24 | nodesContainerRect: DOMRect; 25 | 26 | @ViewChildren(NodeComponent) nodeComponents: QueryList; 27 | 28 | constructor(private zone: NgZone) { } 29 | 30 | ngOnInit() { 31 | } 32 | 33 | ngAfterViewInit() { 34 | this.nodesContainerRect = this.nodesContainer.nativeElement.getBoundingClientRect(); 35 | 36 | console.log(this.nodesContainerRect); 37 | } 38 | 39 | onAddNodeClick(event: Event) { 40 | this.nodes.push(new Node(`nodeId_${this.nodes.length + 1}`, "⚡✨⚡", `nodeId: ${this.nodes.length}`, this.nodes.length > 0, true)); 41 | 42 | setTimeout(() => this.connectNodes()); 43 | } 44 | 45 | connectNodes() { 46 | if (this.nodes.length > 1) { 47 | const nodesToConnect = this.nodeComponents.filter((item, idx) => idx >= this.nodes.length - 2); 48 | 49 | const el1 = nodesToConnect[0]; 50 | const el2 = nodesToConnect[1]; 51 | 52 | let link = new Link(el1.config.id, el2.config.id); 53 | 54 | this.links.push(link); 55 | 56 | this.linkLines.push( 57 | new LeaderLine(el1.outputSlot.port.nativeElement, el2.inputSlot.port.nativeElement, { 58 | startPlug: 'behind', 59 | endPlug: 'behind', 60 | startSocket: 'bottom', 61 | endSocket: 'top', 62 | color: '#959da5', 63 | startSocketGravity: 150, 64 | endSocketGravity: 150 65 | }) 66 | ); 67 | } 68 | } 69 | 70 | onResetClick (event: Event) { 71 | this.nodes = []; 72 | this.links = []; 73 | this.linkLines = []; 74 | 75 | this.zone.runOutsideAngular(() => { 76 | document.querySelectorAll(".leader-line").forEach((ll) => ll.parentNode.removeChild(ll)); 77 | }); 78 | } 79 | 80 | onDragMove(moved: CdkDragMove) { 81 | const { x, y, width, height } = moved.source.element.nativeElement.getBoundingClientRect() as DOMRect; 82 | const relX = x - this.nodesContainerRect.x + width / 2; 83 | const relY = y - this.nodesContainerRect.y + height; 84 | 85 | requestAnimationFrame(() => this.repositionLinksForNode(moved.source.data)); 86 | } 87 | 88 | repositionLinksForNode(nodeId: string) { 89 | this.links 90 | .forEach((link, idx) => { 91 | if (link.fromNodeId === nodeId || link.toNodeId === nodeId) { 92 | this.linkLines[idx].position(); 93 | } 94 | }); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-slot/node-slot.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
-------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-slot/node-slot.component.scss: -------------------------------------------------------------------------------- 1 | .connect-port { 2 | width: 20px; 3 | height: 20px; 4 | margin-left: -10px; 5 | 6 | &.slot-type-input { 7 | top: -10px; 8 | background-image: linear-gradient( #24292e 0%, #24292e 50%, #444d56 50%, #444d56 100% ); 9 | } 10 | 11 | &.slot-type-output { 12 | bottom: -10px; 13 | background-image: linear-gradient( #444d56 0%, #444d56 50%, #24292e 50%, #24292e 100% ); 14 | } 15 | } 16 | 17 | .connect-port::before { 18 | background-color: #444d55; 19 | content: ''; 20 | position: absolute; 21 | left: 0px; 22 | top: 0px; 23 | width: 18px; 24 | height: 18px; 25 | border-radius: 50%; 26 | } 27 | 28 | .port-inset { 29 | background-color: #1585ff; 30 | width: 10px; 31 | height: 10px; 32 | top: -2px; 33 | z-index: 100; 34 | margin-left: 5px; 35 | margin-top: 7px; 36 | } -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-slot/node-slot.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core'; 2 | import { SlotType } from './slot-type.enum'; 3 | 4 | @Component({ 5 | selector: 'app-node-slot', 6 | templateUrl: './node-slot.component.html', 7 | styleUrls: ['./node-slot.component.scss'] 8 | }) 9 | export class NodeSlotComponent implements OnInit { 10 | 11 | @Input() 12 | slotType: SlotType; 13 | 14 | @ViewChild("connectPort", null) port: ElementRef; 15 | 16 | get isInput(): boolean { 17 | return this.slotType == SlotType.Input; 18 | } 19 | 20 | constructor() { } 21 | 22 | ngOnInit() { 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node-slot/slot-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum SlotType { 2 | Input, Output 3 | } 4 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node.model.ts: -------------------------------------------------------------------------------- 1 | export class Node { 2 | constructor ( 3 | public id: string, 4 | public name: string, 5 | public description: string, 6 | public takesInput: boolean, 7 | public hasOutput: boolean) { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node/node.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 | {{ config?.description || "⛔ No config" }} 7 |

{{ config?.name || "⚠ Config missing" }}

8 |
9 |
10 | 11 |
12 |
13 | -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node/node.component.scss: -------------------------------------------------------------------------------- 1 | :host { 2 | position: absolute; 3 | z-index: 1; 4 | } 5 | 6 | .node { 7 | width: 300px; 8 | min-height: 60px; 9 | transition: none; 10 | color: #fff; 11 | border-radius: 6px; 12 | border: solid 1px #23292e; 13 | box-shadow: 0 1px 15px rgba(27, 31, 35, 0.4); 14 | background-color: #444d55; 15 | 16 | .slots-container { 17 | display: flex; 18 | flex-wrap: nowrap; 19 | justify-content: space-evenly; 20 | } 21 | } -------------------------------------------------------------------------------- /src/app/pages/welcome/node-editor/node/node.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input, HostListener, ElementRef, NgZone, ChangeDetectorRef, QueryList, ViewChildren } from '@angular/core'; 2 | import { Node } from '../node.model'; 3 | import { SlotType } from '../node-slot/slot-type.enum'; 4 | import { NodeSlotComponent } from '../node-slot/node-slot.component'; 5 | 6 | @Component({ 7 | selector: 'app-node', 8 | templateUrl: './node.component.html', 9 | styleUrls: ['./node.component.scss'] 10 | }) 11 | export class NodeComponent implements OnInit { 12 | 13 | SlotTypeEnum = SlotType; 14 | 15 | @Input() 16 | config: Node; 17 | 18 | @ViewChildren(NodeSlotComponent) slots: QueryList; 19 | 20 | get inputSlot(): NodeSlotComponent { 21 | return this.slots.find((s) => s.slotType == SlotType.Input); 22 | } 23 | 24 | get outputSlot(): NodeSlotComponent { 25 | return this.slots.find((s) => s.slotType == SlotType.Output); 26 | } 27 | 28 | mouseDown: boolean = false; 29 | 30 | constructor(private el: ElementRef, private zone: NgZone, private cdRef: ChangeDetectorRef) { } 31 | 32 | ngOnInit() { 33 | // this.zone.runOutsideAngular(() => { 34 | // this.el.nativeElement.addEventListener('mousedown', this.onMouseDown.bind(this)); 35 | // this.el.nativeElement.addEventListener('mouseup', this.onMouseUp.bind(this)); 36 | // }); 37 | } 38 | 39 | onMouseDown (event) { 40 | this.el.nativeElement.style.cursor = 'grabbing'; 41 | this.cdRef.markForCheck(); 42 | } 43 | 44 | onMouseUp (event) { 45 | this.el.nativeElement.style.cursor = 'grab'; 46 | this.cdRef.markForCheck(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { WelcomeComponent } from './welcome.component'; 4 | 5 | const routes: Routes = [ 6 | { path: '', component: WelcomeComponent }, 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [RouterModule.forChild(routes)], 11 | exports: [RouterModule] 12 | }) 13 | export class WelcomeRoutingModule { } 14 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
-------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.scss: -------------------------------------------------------------------------------- 1 | .h-100 { 2 | height: 100%; 3 | } -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-welcome', 5 | templateUrl: './welcome.component.html', 6 | styleUrls: ['./welcome.component.scss'] 7 | }) 8 | export class WelcomeComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 5 | import { DragDropModule } from '@angular/cdk/drag-drop'; 6 | 7 | import { WelcomeRoutingModule } from './welcome-routing.module'; 8 | 9 | import { WelcomeComponent } from './welcome.component'; 10 | 11 | import { NodeEditorComponent } from './node-editor/node-editor.component'; 12 | import { NodeComponent } from './node-editor/node/node.component'; 13 | import { NodeSlotComponent } from './node-editor/node-slot/node-slot.component'; 14 | 15 | @NgModule({ 16 | imports: [CommonModule, DragDropModule, WelcomeRoutingModule, NgZorroAntdModule], 17 | declarations: [WelcomeComponent, NodeEditorComponent, NodeComponent, NodeSlotComponent], 18 | exports: [WelcomeComponent, NodeEditorComponent, NodeComponent] 19 | }) 20 | export class WelcomeModule { } 21 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinnormark/ng-nodez/681e3b6eb366c1bed0fca222907e5c09008e0823/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinnormark/ng-nodez/681e3b6eb366c1bed0fca222907e5c09008e0823/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NgNodez 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | .d-inline-block { 3 | display: inline-block !important; 4 | } 5 | 6 | .circle { 7 | border-radius: 50% !important; 8 | } 9 | 10 | .position-absolute { 11 | position: absolute !important; 12 | } 13 | 14 | .position-relative { 15 | position: relative !important; 16 | } 17 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.ts" 13 | ], 14 | "exclude": [ 15 | "src/test.ts", 16 | "src/**/*.spec.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | }, 22 | "angularCompilerOptions": { 23 | "fullTemplateTypeCheck": true, 24 | "strictInjectionParameters": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "array-type": false, 5 | "arrow-parens": false, 6 | "deprecation": { 7 | "severity": "warning" 8 | }, 9 | "component-class-suffix": true, 10 | "contextual-lifecycle": true, 11 | "directive-class-suffix": true, 12 | "directive-selector": [ 13 | true, 14 | "attribute", 15 | "app", 16 | "camelCase" 17 | ], 18 | "component-selector": [ 19 | true, 20 | "element", 21 | "app", 22 | "kebab-case" 23 | ], 24 | "import-blacklist": [ 25 | true, 26 | "rxjs/Rx" 27 | ], 28 | "interface-name": false, 29 | "max-classes-per-file": false, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-consecutive-blank-lines": false, 47 | "no-console": [ 48 | true, 49 | "debug", 50 | "info", 51 | "time", 52 | "timeEnd", 53 | "trace" 54 | ], 55 | "no-empty": false, 56 | "no-inferrable-types": [ 57 | true, 58 | "ignore-params" 59 | ], 60 | "no-non-null-assertion": true, 61 | "no-redundant-jsdoc": true, 62 | "no-switch-case-fall-through": true, 63 | "no-use-before-declare": true, 64 | "no-var-requires": false, 65 | "object-literal-key-quotes": [ 66 | true, 67 | "as-needed" 68 | ], 69 | "object-literal-sort-keys": false, 70 | "ordered-imports": false, 71 | "quotemark": [ 72 | true, 73 | "single" 74 | ], 75 | "trailing-comma": false, 76 | "no-conflicting-lifecycle": true, 77 | "no-host-metadata-property": true, 78 | "no-input-rename": true, 79 | "no-inputs-metadata-property": true, 80 | "no-output-native": true, 81 | "no-output-on-prefix": true, 82 | "no-output-rename": true, 83 | "no-outputs-metadata-property": true, 84 | "template-banana-in-box": true, 85 | "template-no-negated-async": true, 86 | "use-lifecycle-interface": true, 87 | "use-pipe-transform-interface": true 88 | }, 89 | "rulesDirectory": [ 90 | "codelyzer" 91 | ] 92 | } --------------------------------------------------------------------------------