Commit 74114de4d3d69a6109d211ba0f577517d48839b8

Authored by Igor Kulikov
1 parent cabdc68a

Rulenode component

@@ -1407,12 +1407,14 @@ @@ -1407,12 +1407,14 @@
1407 "balanced-match": { 1407 "balanced-match": {
1408 "version": "1.0.0", 1408 "version": "1.0.0",
1409 "bundled": true, 1409 "bundled": true,
1410 - "dev": true 1410 + "dev": true,
  1411 + "optional": true
1411 }, 1412 },
1412 "brace-expansion": { 1413 "brace-expansion": {
1413 "version": "1.1.11", 1414 "version": "1.1.11",
1414 "bundled": true, 1415 "bundled": true,
1415 "dev": true, 1416 "dev": true,
  1417 + "optional": true,
1416 "requires": { 1418 "requires": {
1417 "balanced-match": "^1.0.0", 1419 "balanced-match": "^1.0.0",
1418 "concat-map": "0.0.1" 1420 "concat-map": "0.0.1"
@@ -1427,17 +1429,20 @@ @@ -1427,17 +1429,20 @@
1427 "code-point-at": { 1429 "code-point-at": {
1428 "version": "1.1.0", 1430 "version": "1.1.0",
1429 "bundled": true, 1431 "bundled": true,
1430 - "dev": true 1432 + "dev": true,
  1433 + "optional": true
1431 }, 1434 },
1432 "concat-map": { 1435 "concat-map": {
1433 "version": "0.0.1", 1436 "version": "0.0.1",
1434 "bundled": true, 1437 "bundled": true,
1435 - "dev": true 1438 + "dev": true,
  1439 + "optional": true
1436 }, 1440 },
1437 "console-control-strings": { 1441 "console-control-strings": {
1438 "version": "1.1.0", 1442 "version": "1.1.0",
1439 "bundled": true, 1443 "bundled": true,
1440 - "dev": true 1444 + "dev": true,
  1445 + "optional": true
1441 }, 1446 },
1442 "core-util-is": { 1447 "core-util-is": {
1443 "version": "1.0.2", 1448 "version": "1.0.2",
@@ -1554,7 +1559,8 @@ @@ -1554,7 +1559,8 @@
1554 "inherits": { 1559 "inherits": {
1555 "version": "2.0.3", 1560 "version": "2.0.3",
1556 "bundled": true, 1561 "bundled": true,
1557 - "dev": true 1562 + "dev": true,
  1563 + "optional": true
1558 }, 1564 },
1559 "ini": { 1565 "ini": {
1560 "version": "1.3.5", 1566 "version": "1.3.5",
@@ -1566,6 +1572,7 @@ @@ -1566,6 +1572,7 @@
1566 "version": "1.0.0", 1572 "version": "1.0.0",
1567 "bundled": true, 1573 "bundled": true,
1568 "dev": true, 1574 "dev": true,
  1575 + "optional": true,
1569 "requires": { 1576 "requires": {
1570 "number-is-nan": "^1.0.0" 1577 "number-is-nan": "^1.0.0"
1571 } 1578 }
@@ -1580,6 +1587,7 @@ @@ -1580,6 +1587,7 @@
1580 "version": "3.0.4", 1587 "version": "3.0.4",
1581 "bundled": true, 1588 "bundled": true,
1582 "dev": true, 1589 "dev": true,
  1590 + "optional": true,
1583 "requires": { 1591 "requires": {
1584 "brace-expansion": "^1.1.7" 1592 "brace-expansion": "^1.1.7"
1585 } 1593 }
@@ -1691,7 +1699,8 @@ @@ -1691,7 +1699,8 @@
1691 "number-is-nan": { 1699 "number-is-nan": {
1692 "version": "1.0.1", 1700 "version": "1.0.1",
1693 "bundled": true, 1701 "bundled": true,
1694 - "dev": true 1702 + "dev": true,
  1703 + "optional": true
1695 }, 1704 },
1696 "object-assign": { 1705 "object-assign": {
1697 "version": "4.1.1", 1706 "version": "4.1.1",
@@ -1703,6 +1712,7 @@ @@ -1703,6 +1712,7 @@
1703 "version": "1.4.0", 1712 "version": "1.4.0",
1704 "bundled": true, 1713 "bundled": true,
1705 "dev": true, 1714 "dev": true,
  1715 + "optional": true,
1706 "requires": { 1716 "requires": {
1707 "wrappy": "1" 1717 "wrappy": "1"
1708 } 1718 }
@@ -1824,6 +1834,7 @@ @@ -1824,6 +1834,7 @@
1824 "version": "1.0.2", 1834 "version": "1.0.2",
1825 "bundled": true, 1835 "bundled": true,
1826 "dev": true, 1836 "dev": true,
  1837 + "optional": true,
1827 "requires": { 1838 "requires": {
1828 "code-point-at": "^1.0.0", 1839 "code-point-at": "^1.0.0",
1829 "is-fullwidth-code-point": "^1.0.0", 1840 "is-fullwidth-code-point": "^1.0.0",
  1 +/**
  2 + * Copyright © 2016-2019 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +:host ::ng-deep {
  17 + .fc-canvas {
  18 + .fc-node {
  19 + border-radius: 8px;
  20 + &.fc-selected {
  21 + &:not(.fc-edit) {
  22 + margin: -3px;
  23 + border: solid 3px #f00;
  24 + }
  25 + }
  26 + }
  27 +
  28 + .fc-edit {
  29 + .fc-nodeedit,
  30 + .fc-nodedelete {
  31 + border: solid 2px #fff;
  32 + background: #f83e05;
  33 + outline: none;
  34 + }
  35 + }
  36 +
  37 + .fc-arrow-marker {
  38 + polygon {
  39 + fill: #808080;
  40 + stroke: #808080;
  41 + }
  42 + }
  43 +
  44 + .fc-arrow-marker-selected {
  45 + polygon {
  46 + fill: #f00;
  47 + stroke: #f00;
  48 + }
  49 + }
  50 +
  51 + .fc-edge {
  52 + outline: none;
  53 + stroke: #808080;
  54 +
  55 + &.fc-selected {
  56 + stroke: #f00;
  57 + }
  58 +
  59 + &.fc-hover {
  60 + stroke: #808080;
  61 + }
  62 + }
  63 +
  64 + .edge-endpoint {
  65 + fill: #808080;
  66 + }
  67 +
  68 + .fc-edge-label {
  69 + opacity: 1 !important;
  70 + &:focus {
  71 + outline: 0;
  72 + }
  73 +
  74 + &.fc-selected {
  75 + .fc-edge-label-text {
  76 + span {
  77 + color: #fff !important;
  78 + background-color: #f00 !important;
  79 + border: solid #f00 !important;
  80 + }
  81 + }
  82 + }
  83 +
  84 + .fc-edge-label-text {
  85 + font-size: 14px !important;
  86 + font-weight: 600 !important;
  87 +
  88 + span {
  89 + background-color: #fff !important;
  90 + color: #003a79 !important;
  91 + border: solid 2px #003a79 !important;
  92 + }
  93 + }
  94 + }
  95 + }
  96 +}
@@ -39,7 +39,7 @@ import { RuleChainService } from '@core/http/rule-chain.service'; @@ -39,7 +39,7 @@ import { RuleChainService } from '@core/http/rule-chain.service';
39 @Component({ 39 @Component({
40 selector: 'tb-rulechain-page', 40 selector: 'tb-rulechain-page',
41 templateUrl: './rulechain-page.component.html', 41 templateUrl: './rulechain-page.component.html',
42 - styleUrls: [] 42 + styleUrls: ['./rulechain-page.component.scss']
43 }) 43 })
44 export class RuleChainPageComponent extends PageComponent implements OnInit, HasDirtyFlag { 44 export class RuleChainPageComponent extends PageComponent implements OnInit, HasDirtyFlag {
45 45
@@ -22,16 +22,28 @@ import {RuleChainRoutingModule} from '@modules/home/pages/rulechain/rulechain-ro @@ -22,16 +22,28 @@ import {RuleChainRoutingModule} from '@modules/home/pages/rulechain/rulechain-ro
22 import {HomeComponentsModule} from '@modules/home/components/home-components.module'; 22 import {HomeComponentsModule} from '@modules/home/components/home-components.module';
23 import { RuleChainTabsComponent } from '@home/pages/rulechain/rulechain-tabs.component'; 23 import { RuleChainTabsComponent } from '@home/pages/rulechain/rulechain-tabs.component';
24 import { RuleChainPageComponent } from './rulechain-page.component'; 24 import { RuleChainPageComponent } from './rulechain-page.component';
  25 +import { RuleNodeComponent } from '@home/pages/rulechain/rulenode.component';
  26 +import { FC_NODE_COMPONENT_CONFIG } from 'ngx-flowchart/dist/ngx-flowchart';
25 27
26 @NgModule({ 28 @NgModule({
27 entryComponents: [ 29 entryComponents: [
28 RuleChainComponent, 30 RuleChainComponent,
29 - RuleChainTabsComponent 31 + RuleChainTabsComponent,
  32 + RuleNodeComponent
30 ], 33 ],
31 declarations: [ 34 declarations: [
32 RuleChainComponent, 35 RuleChainComponent,
33 RuleChainTabsComponent, 36 RuleChainTabsComponent,
34 - RuleChainPageComponent 37 + RuleChainPageComponent,
  38 + RuleNodeComponent
  39 + ],
  40 + providers: [
  41 + {
  42 + provide: FC_NODE_COMPONENT_CONFIG,
  43 + useValue: {
  44 + nodeComponentType: RuleNodeComponent
  45 + }
  46 + }
35 ], 47 ],
36 imports: [ 48 imports: [
37 CommonModule, 49 CommonModule,
  1 +<!--
  2 +
  3 + Copyright © 2016-2019 The Thingsboard Authors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +
  17 +-->
  18 +<div
  19 + (dblclick)="userNodeCallbacks.doubleClick($event, node)"
  20 + (mousedown)="userNodeCallbacks.mouseDown($event, node)"
  21 + (mouseenter)="userNodeCallbacks.mouseEnter($event, node)"
  22 + (mouseleave)="userNodeCallbacks.mouseLeave($event, node)">
  23 + <div class="{{flowchartConstants.nodeOverlayClass}}"></div>
  24 + <div class="tb-rule-node {{node.nodeClass}}" [ngClass]="{'tb-rule-node-highlighted' : node.highlighted, 'tb-rule-node-invalid': node.error }">
  25 + <mat-icon *ngIf="!node.iconUrl" fxFlex="15">{{node.icon}}</mat-icon>
  26 + <img *ngIf="node.iconUrl" fxFlex="15" src="{{node.iconUrl}}"/>
  27 + <div fxLayout="column" fxFlex="85" fxLayoutAlign="center">
  28 + <span class="tb-node-type">{{ node.component.name }}</span>
  29 + <span class="tb-node-title" *ngIf="node.name">{{ node.name }}</span>
  30 + </div>
  31 + <div class="{{flowchartConstants.leftConnectorClass}}">
  32 + <div fc-magnet [connector]="connector" [callbacks]="callbacks"
  33 + *ngFor="let connector of modelservice.nodes.getConnectorsByType(node, flowchartConstants.leftConnectorType)">
  34 + <div fc-connector [connector]="connector"
  35 + [mouseOverConnector]="mouseOverConnector"
  36 + [callbacks]="callbacks"
  37 + [modelservice]="modelservice"></div>
  38 + </div>
  39 + </div>
  40 + <div class="{{flowchartConstants.rightConnectorClass}}">
  41 + <div fc-magnet [connector]="connector" [callbacks]="callbacks"
  42 + *ngFor="let connector of modelservice.nodes.getConnectorsByType(node, flowchartConstants.rightConnectorType)">
  43 + <div fc-connector [connector]="connector"
  44 + [mouseOverConnector]="mouseOverConnector"
  45 + [callbacks]="callbacks"
  46 + [modelservice]="modelservice"></div>
  47 + </div>
  48 + </div>
  49 + </div>
  50 + <div *ngIf="modelservice.isEditable() && !node.readonly" class="fc-nodeedit" (click)="userNodeCallbacks.nodeEdit($event, node)">
  51 + <i class="fa fa-pencil" aria-hidden="true"></i>
  52 + </div>
  53 + <div *ngIf="modelservice.isEditable() && !node.readonly" class="fc-nodedelete" (click)="modelservice.nodes.delete(node)">
  54 + &times;
  55 + </div>
  56 +</div>
  1 +/**
  2 + * Copyright © 2016-2019 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +:host {
  18 +
  19 + .fc-node-overlay {
  20 + position: absolute;
  21 + pointer-events: none;
  22 + left: 0;
  23 + top: 0;
  24 + right: 0;
  25 + bottom: 0;
  26 + background-color: #000;
  27 + border-radius: 5px;
  28 + opacity: 0;
  29 + }
  30 +
  31 + :host-context(.fc-hover) .fc-node-overlay {
  32 + opacity: 0.25;
  33 + transition: opacity .2s;
  34 + }
  35 +
  36 + :host-context(.fc-selected) .fc-node-overlay {
  37 + opacity: 0.25;
  38 + }
  39 +
  40 + :host-context(.fc-edit) {
  41 + .fc-nodeedit,
  42 + .fc-nodedelete {
  43 + border: solid 2px #fff;
  44 + background: #f83e05;
  45 + outline: none;
  46 + }
  47 + }
  48 +
  49 + .tb-rule-node {
  50 + display: flex;
  51 + flex-direction: row;
  52 + min-width: 150px;
  53 + max-width: 150px;
  54 + height: 32px;
  55 + min-height: 32px;
  56 + max-height: 32px;
  57 + padding: 5px 10px;
  58 + font-size: 12px;
  59 + line-height: 16px;
  60 + color: #333;
  61 + pointer-events: none;
  62 + background-color: #f15b26;
  63 + border: solid 1px #777;
  64 + border-radius: 5px;
  65 +
  66 + &.tb-filter-type {
  67 + background-color: #f1e861;
  68 + }
  69 +
  70 + &.tb-enrichment-type {
  71 + background-color: #cdf14e;
  72 + }
  73 +
  74 + &.tb-transformation-type {
  75 + background-color: #79cef1;
  76 + }
  77 +
  78 + &.tb-action-type {
  79 + background-color: #f1928f;
  80 + }
  81 +
  82 + &.tb-external-type {
  83 + background-color: #fbc766;
  84 + }
  85 +
  86 + &.tb-rule-chain-type {
  87 + background-color: #d6c4f1;
  88 + }
  89 +
  90 + &.tb-unknown-type {
  91 + background-color: #f16c29;
  92 + }
  93 +
  94 + &.tb-rule-node-highlighted:not(.tb-rule-node-invalid) {
  95 + box-shadow: 0 0 10px 6px #51cbee;
  96 +
  97 + .tb-node-title {
  98 + font-weight: 700;
  99 + text-decoration: underline;
  100 + }
  101 + }
  102 +
  103 + &.tb-rule-node-invalid {
  104 + box-shadow: 0 0 10px 6px #ff5c50;
  105 + }
  106 +
  107 + &.tb-input-type {
  108 + user-select: none;
  109 + background-color: #a3eaa9;
  110 + }
  111 +
  112 + mat-icon, img {
  113 + margin: auto;
  114 + width: 20px;
  115 + min-width: 20px;
  116 + height: 20px;
  117 + min-height: 20px;
  118 + padding-right: 4px;
  119 + font-size: 20px;
  120 + }
  121 +
  122 + .tb-node-title {
  123 + font-weight: 500;
  124 + }
  125 +
  126 + .tb-node-type,
  127 + .tb-node-title {
  128 + overflow: hidden;
  129 + text-overflow: ellipsis;
  130 + white-space: nowrap;
  131 + }
  132 + .fc-leftConnectors,
  133 + .fc-rightConnectors {
  134 + position: absolute;
  135 + top: 0;
  136 +
  137 + z-index: 0;
  138 +
  139 + display: flex;
  140 + flex-direction: column;
  141 + height: 100%;
  142 +
  143 + .fc-magnet {
  144 + align-items: center;
  145 + }
  146 + }
  147 +
  148 + .fc-leftConnectors {
  149 + left: -20px;
  150 + }
  151 +
  152 + .fc-rightConnectors {
  153 + right: -20px;
  154 + }
  155 +
  156 + .fc-magnet {
  157 + display: flex;
  158 + flex-grow: 1;
  159 + justify-content: center;
  160 + height: 60px;
  161 + }
  162 +
  163 + .fc-connector {
  164 + width: 14px;
  165 + height: 14px;
  166 + margin: 10px;
  167 + pointer-events: all;
  168 + background-color: #ccc;
  169 + border: 1px solid #333;
  170 + border-radius: 5px;
  171 + }
  172 +
  173 + .fc-connector.fc-hover {
  174 + background-color: #000;
  175 + }
  176 + }
  177 +}
  1 +///
  2 +/// Copyright © 2016-2019 The Thingsboard Authors
  3 +///
  4 +/// Licensed under the Apache License, Version 2.0 (the "License");
  5 +/// you may not use this file except in compliance with the License.
  6 +/// You may obtain a copy of the License at
  7 +///
  8 +/// http://www.apache.org/licenses/LICENSE-2.0
  9 +///
  10 +/// Unless required by applicable law or agreed to in writing, software
  11 +/// distributed under the License is distributed on an "AS IS" BASIS,
  12 +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +/// See the License for the specific language governing permissions and
  14 +/// limitations under the License.
  15 +///
  16 +
  17 +import { Component } from '@angular/core';
  18 +import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
  19 +
  20 +@Component({
  21 + selector: 'rule-node',
  22 + templateUrl: './rulenode.component.html',
  23 + styleUrls: ['./rulenode.component.scss']
  24 +})
  25 +export class RuleNodeComponent extends FcNodeComponent {
  26 +
  27 + constructor() {
  28 + super();
  29 + }
  30 +
  31 +}