src/app/streams/components/flo/node/node.component.ts
Component for displaying application properties and capturing their values.
encapsulation | ViewEncapsulation.None |
selector | app-flo-node |
styleUrls | node.component.scss |
templateUrl | node.component.html |
Properties |
Methods |
Accessors |
constructor()
|
getPropertyValue | ||||||||
getPropertyValue(property: string)
|
||||||||
Parameters :
Returns :
any
|
isCanvas |
isCanvas()
|
Returns :
boolean
|
isCode | ||||||||
isCode(property: string)
|
||||||||
Parameters :
Returns :
boolean
|
keys | ||||||||
keys(o: any)
|
||||||||
Parameters :
Returns :
Array<string>
|
_description |
_description:
|
Type : string
|
paper |
getpaper()
|
Returns :
dia.Paper
|
metadata |
getmetadata()
|
Returns :
Flo.ElementMetadata
|
metaName |
getmetaName()
|
Returns :
string
|
metaGroup |
getmetaGroup()
|
Returns :
string
|
allProperties |
getallProperties()
|
Returns :
any
|
isPropertiesShown |
getisPropertiesShown()
|
Returns :
boolean
|
description |
getdescription()
|
Returns :
string
|
isDisabled |
getisDisabled()
|
Returns :
boolean
|
import { Component, ViewEncapsulation } from '@angular/core';
import { dia } from 'jointjs';
import { Flo, Constants } from 'spring-flo';
import { ElementComponent } from '../../../../shared/flo/support/shape-component';
import { Utils } from '../../../../shared/flo/support/utils';
/**
* Component for displaying application properties and capturing their values.
*
* @author Alex Boyko
* @author Andy Clement
*/
@Component({
selector: 'app-flo-node',
templateUrl: 'node.component.html',
styleUrls: [ './node.component.scss' ],
encapsulation: ViewEncapsulation.None
})
export class NodeComponent extends ElementComponent {
_description: string;
constructor() {
super();
}
getPropertyValue(property: string): any {
if (this.view) {
const value = this.view.model.attr(`props/${property}`);
if (this.isCode(property)) {
return Utils.decodeTextFromDSL(value);
}
return value;
}
return '';
}
isCanvas(): boolean {
return this.paper.model.get('type') === Constants.CANVAS_CONTEXT;
}
get paper(): dia.Paper {
return this.view ? (<any>this.view).paper : undefined;
}
get metadata(): Flo.ElementMetadata {
return this.view ? this.view.model.attr('metadata') : undefined;
}
get metaName(): string {
return this.metadata ? this.metadata.name : 'Unknown';
}
get metaGroup(): string {
return this.metadata ? this.metadata.group : 'Unknown';
}
get allProperties(): any {
return this.view ? this.view.model.attr('props') : {};
}
get isPropertiesShown(): boolean {
return this.view ? !this.view.model.attr('metadata/metadata/hide-tooltip-options') : false;
}
get description(): string {
if (this._description === undefined) {
if (this.metadata && this.metadata.description) {
this.metadata.description().then(d => this._description = d);
}
}
return this._description;
}
get isDisabled(): boolean {
return !this.metadata || this.metadata.unresolved || this.cannotShowToolTip;
}
isCode(property: string): boolean {
return Utils.isCodeTypeProperty(this.metadata, property);
}
keys(o: any): Array<string> {
return Object.keys(o);
}
}
<svg:g [ngSwitch]="metaName">
<svg:g *ngSwitchCase="'destination'" class="destination">
<svg:g class="shape" [tooltip]="canvasNodeTooltip" container="body" placement="bottom" containerClass="app-tooltip" [isDisabled]="isDisabled">
<svg:path d="m6,10 a12,12 0 0,0 0,20 l108,0 a12,12 0 0,0 0,-20 l0,0 z" class="box"/>
<svg:text class="label1"/>
<svg:text class="label2"/>
</svg:g>
<svg:text class="stream-label"/>
<svg:circle class="input-port" tooltip="Input Port" container="body" [isDisabled]="!isCanvas() && canvasNodeTooltip"/>
<svg:circle class="output-port" tooltip="Output Port" container="body" [isDisabled]="!isCanvas() && canvasNodeTooltip"/>
</svg:g>
<svg:g *ngSwitchDefault class="stream-module">
<svg:g class="shape" [tooltip]="canvasNodeTooltip" container="body" placement="bottom" containerClass="app-tooltip" [isDisabled]="isDisabled">
<svg:rect class="box"/>
<svg:text class="label1"/>
<svg:text class="label2"/>
</svg:g>
<svg:text class="stream-label"/>
<svg:rect class="input-port" tooltip="Input Port" container="body" [isDisabled]="!isCanvas() && canvasNodeTooltip"/>
<svg:rect class="output-port" tooltip="Output Port" container="body" [isDisabled]="!isCanvas() && canvasNodeTooltip"/>
</svg:g>
</svg:g>
<ng-template #canvasNodeTooltip>
<div ng-if="cell.attr('metadata/name')">
<span><strong>{{ metaName | uppercase }}</strong></span>
<span><strong>{{ '(' + (metaGroup | capitalize) + ')' }}</strong></span>
</div>
<div *ngIf="description">
<span>{{ description }}</span>
</div>
<table class="table-condensed" *ngIf="allProperties && isPropertiesShown">
<tbody>
<tr *ngFor="let property of keys(allProperties).sort()">
<td class="tooltip-property-key"><strong>{{ property }}</strong></td>
<td class="tooltip-property-value" [ngClass]="{'tooltip-property-value-code': isCode(property)}">{{ getPropertyValue(property) }}</td>
</tr>
</tbody>
</table>
</ng-template>