-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
demo.web: initial version of the root node viewer
- Loading branch information
Showing
12 changed files
with
115 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { SRootNode } from '../../../../../mps-cli-ts/src/model/snode'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class EditorService { | ||
|
||
private rootNodeSource = new BehaviorSubject<SRootNode | undefined>(undefined); | ||
currentRootNode = this.rootNodeSource.asObservable(); | ||
|
||
changeRootNode(rootNode : SRootNode) { | ||
this.rootNodeSource.next(rootNode) | ||
} | ||
} |
Empty file.
22 changes: 22 additions & 0 deletions
22
demos/web/angular-model-browser/src/app/node-viewer/node-viewer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<section *ngIf="node != undefined"> | ||
<p>node: {{ node!.getProperty("name") === undefined ? "" : node!.getProperty("name") }} ({{ node!.myConcept.name }})</p> | ||
<ul class="px-2 list-disc list-inside"> | ||
<li>properties:</li> | ||
<ul class="px-4 list-disc list-inside" *ngFor="let prop of propertiesKeys()"> | ||
<li> {{ prop[0].name }} :: {{ prop[1] }} </li> | ||
</ul> | ||
</ul> | ||
<ul class="px-2 list-disc list-inside"> | ||
<li>references:</li> | ||
<ul class="px-4 list-disc list-inside" *ngFor="let ref of referencesKeys()"> | ||
<li> {{ ref[0].name }} :: {{ ref[1] }} </li> | ||
</ul> | ||
</ul> | ||
<ul class="px-2 list-disc list-inside"> | ||
<li>children: {{childrenKeys().length}}</li> | ||
<ul class="px-4 list-disc list-inside" *ngFor="let ref of childrenKeys()"> | ||
<li> {{ ref.name }} : </li> | ||
<app-node-viewer *ngFor="let child of children(ref)" [node]="child"></app-node-viewer> | ||
</ul> | ||
</ul> | ||
</section> |
35 changes: 35 additions & 0 deletions
35
demos/web/angular-model-browser/src/app/node-viewer/node-viewer.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { SNode } from '../../../../../../mps-cli-ts/src/model/snode'; | ||
import { NgFor, NgIf } from '@angular/common'; | ||
import { SChildLink, SProperty, SReferenceLink } from '../../../../../../mps-cli-ts/src/model/sconcept'; | ||
|
||
@Component({ | ||
selector: 'app-node-viewer', | ||
standalone: true, | ||
imports: [ NgFor, NgIf ], | ||
templateUrl: './node-viewer.component.html', | ||
styleUrl: './node-viewer.component.css' | ||
}) | ||
export class NodeViewerComponent { | ||
@Input() node : SNode | undefined; | ||
|
||
propertiesKeys() { | ||
return Array.from(this.node!.properties) | ||
} | ||
|
||
referencesKeys() { | ||
return Array.from(this.node!.links).filter(it => it instanceof SReferenceLink) | ||
} | ||
|
||
childrenKeys() { | ||
return Array.from(this.node!.links.keys()).filter(it => it instanceof SChildLink) | ||
} | ||
|
||
children(link : SChildLink) : SNode[] { | ||
let myChildren = this.node?.links.get(link)!; | ||
return myChildren.filter(it => it instanceof SNode) as SNode[] | ||
} | ||
|
||
//key! : SProperty; | ||
//value! : string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
2 changes: 2 additions & 0 deletions
2
demos/web/angular-model-browser/src/app/root-node-editor/root-node-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p>Root: {{ viewedRootNode === undefined ? "No Node Selected" : viewedRootNode.getProperty("name") }}</p> | ||
<app-node-viewer [node]="this.viewedRootNode"></app-node-viewer> |
29 changes: 29 additions & 0 deletions
29
demos/web/angular-model-browser/src/app/root-node-editor/root-node-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | ||
import { SNode, SRootNode } from '../../../../../../mps-cli-ts/src/model/snode'; | ||
import { EditorService } from '../editor.service'; | ||
import { Subscription } from 'rxjs'; | ||
import { NodeViewerComponent } from '../node-viewer/node-viewer.component'; | ||
|
||
@Component({ | ||
selector: 'app-root-node-editor', | ||
standalone: true, | ||
imports: [ NodeViewerComponent ], | ||
templateUrl: './root-node-editor.component.html', | ||
styleUrl: './root-node-editor.component.css' | ||
}) | ||
export class RootNodeEditorComponent implements OnInit, OnDestroy { | ||
|
||
viewedRootNode : SRootNode | undefined; | ||
subscription! : Subscription; | ||
|
||
constructor(public editorService : EditorService) {} | ||
|
||
ngOnInit() { | ||
this.subscription = this.editorService.currentRootNode.subscribe(rootNode => this.viewedRootNode = rootNode) | ||
} | ||
|
||
ngOnDestroy() { | ||
this.subscription.unsubscribe(); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
demos/web/angular-model-browser/src/app/root-node/root-node.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
<li>root: {{ rootNode.getProperty("name") }}</li> | ||
<li>root: {{ rootNode.getProperty("name") }} <button class="btn" (click)="openRootNode()">Open</button></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.