Commit aa1a43fcea729d81fc962fd636da806028fe1d77

Authored by Igor Kulikov
1 parent 3d6b058b

Rule chain page

@@ -5140,9 +5140,9 @@ @@ -5140,9 +5140,9 @@
5140 "dev": true 5140 "dev": true
5141 }, 5141 },
5142 "handlebars": { 5142 "handlebars": {
5143 - "version": "4.5.1",  
5144 - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz",  
5145 - "integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", 5143 + "version": "4.5.2",
  5144 + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.2.tgz",
  5145 + "integrity": "sha512-29Zxv/cynYB7mkT1rVWQnV7mGX6v7H/miQ6dbEpYTKq5eJBN7PsRB+ViYJlcT6JINTSu4dVB9kOqEun78h6Exg==",
5146 "dev": true, 5146 "dev": true,
5147 "requires": { 5147 "requires": {
5148 "neo-async": "^2.6.0", 5148 "neo-async": "^2.6.0",
@@ -7411,6 +7411,97 @@ @@ -7411,6 +7411,97 @@
7411 "resolved": "https://registry.npmjs.org/ngx-color-picker/-/ngx-color-picker-8.2.0.tgz", 7411 "resolved": "https://registry.npmjs.org/ngx-color-picker/-/ngx-color-picker-8.2.0.tgz",
7412 "integrity": "sha512-rzR+cByjNG9M/UskU5vNoH7cUc6oM8STTDFKOZmnlX4ALOuM1+61CBjsNTGETWfo9a/h5mbGX02oh5/iNAa7vA==" 7412 "integrity": "sha512-rzR+cByjNG9M/UskU5vNoH7cUc6oM8STTDFKOZmnlX4ALOuM1+61CBjsNTGETWfo9a/h5mbGX02oh5/iNAa7vA=="
7413 }, 7413 },
  7414 + "ngx-flowchart": {
  7415 + "version": "git://github.com/thingsboard/ngx-flowchart.git#d26ee52089a6d9cf8147c5f162144825fceb3009",
  7416 + "from": "git://github.com/thingsboard/ngx-flowchart.git#master",
  7417 + "requires": {
  7418 + "@angular/animations": "~8.0.0",
  7419 + "@angular/common": "~8.0.0",
  7420 + "@angular/compiler": "~8.0.0",
  7421 + "@angular/core": "~8.0.0",
  7422 + "@angular/forms": "~8.0.0",
  7423 + "@angular/platform-browser": "~8.0.0",
  7424 + "@angular/platform-browser-dynamic": "~8.0.0",
  7425 + "@angular/router": "~8.0.0",
  7426 + "rxjs": "~6.4.0",
  7427 + "tslib": "^1.9.0",
  7428 + "zone.js": "~0.9.1"
  7429 + },
  7430 + "dependencies": {
  7431 + "@angular/animations": {
  7432 + "version": "8.0.3",
  7433 + "resolved": "https://registry.npmjs.org/@angular/animations/-/animations-8.0.3.tgz",
  7434 + "integrity": "sha512-9zciJ4YRR0bodFSYgsgXdYMz8wKKyVjch7XZADGkWubXT8mGuwlpdPMlQ6n9Cwj8Ebu0u52WxMeQsX76K9RlYA==",
  7435 + "requires": {
  7436 + "tslib": "^1.9.0"
  7437 + }
  7438 + },
  7439 + "@angular/common": {
  7440 + "version": "8.0.3",
  7441 + "resolved": "https://registry.npmjs.org/@angular/common/-/common-8.0.3.tgz",
  7442 + "integrity": "sha512-2YLYGVUf9eJZcocRmD3/9UHj4qFHt2t4ftDWJmrFM9zo2PZF+G5O9fASO7qoBbwpx3KFZtQO4dprKl2dFugRjg==",
  7443 + "requires": {
  7444 + "tslib": "^1.9.0"
  7445 + }
  7446 + },
  7447 + "@angular/compiler": {
  7448 + "version": "8.0.3",
  7449 + "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-8.0.3.tgz",
  7450 + "integrity": "sha512-1/vF8D6l1O6IfWiDtaj6nC+B8CtkVtFgXgooDzLBO6XAkaCuJCnhKT1HnpWG5GtVsGaY9MGoTl1vE9ZMDbRQjg==",
  7451 + "requires": {
  7452 + "tslib": "^1.9.0"
  7453 + }
  7454 + },
  7455 + "@angular/core": {
  7456 + "version": "8.0.3",
  7457 + "resolved": "https://registry.npmjs.org/@angular/core/-/core-8.0.3.tgz",
  7458 + "integrity": "sha512-IIxrtIPNuv2+HudER9J1nmPGiGJ4aRpeiFM9V4lSiSFv50RzuaoG60XqYIpUyuBdgvyKigcrfSbu9+x1vyN0hw==",
  7459 + "requires": {
  7460 + "tslib": "^1.9.0"
  7461 + }
  7462 + },
  7463 + "@angular/forms": {
  7464 + "version": "8.0.3",
  7465 + "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-8.0.3.tgz",
  7466 + "integrity": "sha512-22s82QDRQ72K4vMYuNh3NAN+da9uanwoydnfKlp2rb9dZAb2QVX9NN6gSoMrkSSr2O9KTP6pWiw6A3/MW8sGRA==",
  7467 + "requires": {
  7468 + "tslib": "^1.9.0"
  7469 + }
  7470 + },
  7471 + "@angular/platform-browser": {
  7472 + "version": "8.0.3",
  7473 + "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-8.0.3.tgz",
  7474 + "integrity": "sha512-ceAPP2Ijmk2sZ1rnOU/WNlE3DtT6K6ljpjO9oUfXKMoSMdWirJKAraT3m/BAzmYwMSXpPBxA7c3paZjiLL6t5A==",
  7475 + "requires": {
  7476 + "tslib": "^1.9.0"
  7477 + }
  7478 + },
  7479 + "@angular/platform-browser-dynamic": {
  7480 + "version": "8.0.3",
  7481 + "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-8.0.3.tgz",
  7482 + "integrity": "sha512-ZjQjSYslSQAKzM4llvyMFxnSjFpbhT1U9FOdKwscPe475zAKX0087qsHrP2CRwkJRfwtdcmj9wMUQIPlzMpHLA==",
  7483 + "requires": {
  7484 + "tslib": "^1.9.0"
  7485 + }
  7486 + },
  7487 + "@angular/router": {
  7488 + "version": "8.0.3",
  7489 + "resolved": "https://registry.npmjs.org/@angular/router/-/router-8.0.3.tgz",
  7490 + "integrity": "sha512-CU5pLTfQVUnTN93mdIKJrVjXiNldUkk30DPz4lpdxpZjYOqFGXeeSeQWmToHSofLPodNcAB4kkZ41VyXvlBu7w==",
  7491 + "requires": {
  7492 + "tslib": "^1.9.0"
  7493 + }
  7494 + },
  7495 + "rxjs": {
  7496 + "version": "6.4.0",
  7497 + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
  7498 + "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
  7499 + "requires": {
  7500 + "tslib": "^1.9.0"
  7501 + }
  7502 + }
  7503 + }
  7504 + },
7414 "ngx-hm-carousel": { 7505 "ngx-hm-carousel": {
7415 "version": "1.7.2", 7506 "version": "1.7.2",
7416 "resolved": "https://registry.npmjs.org/ngx-hm-carousel/-/ngx-hm-carousel-1.7.2.tgz", 7507 "resolved": "https://registry.npmjs.org/ngx-hm-carousel/-/ngx-hm-carousel-1.7.2.tgz",
@@ -10796,9 +10887,9 @@ @@ -10796,9 +10887,9 @@
10796 "dev": true 10887 "dev": true
10797 }, 10888 },
10798 "uglify-js": { 10889 "uglify-js": {
10799 - "version": "3.6.8",  
10800 - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.8.tgz",  
10801 - "integrity": "sha512-XhHJ3S3ZyMwP8kY1Gkugqx3CJh2C3O0y8NPiSxtm1tyD/pktLAkFZsFGpuNfTZddKDQ/bbDBLAd2YyA1pbi8HQ==", 10890 + "version": "3.6.9",
  10891 + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.9.tgz",
  10892 + "integrity": "sha512-pcnnhaoG6RtrvHJ1dFncAe8Od6Nuy30oaJ82ts6//sGSXOP5UjBMEthiProjXmMNHOfd93sqlkztifFMcb+4yw==",
10802 "dev": true, 10893 "dev": true,
10803 "optional": true, 10894 "optional": true,
10804 "requires": { 10895 "requires": {
@@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
59 "moment": "^2.24.0", 59 "moment": "^2.24.0",
60 "ngx-clipboard": "^12.2.0", 60 "ngx-clipboard": "^12.2.0",
61 "ngx-color-picker": "^8.2.0", 61 "ngx-color-picker": "^8.2.0",
  62 + "ngx-flowchart": "git://github.com/thingsboard/ngx-flowchart.git#master",
62 "ngx-hm-carousel": "^1.7.2", 63 "ngx-hm-carousel": "^1.7.2",
63 "ngx-translate-messageformat-compiler": "^4.5.0", 64 "ngx-translate-messageformat-compiler": "^4.5.0",
64 "objectpath": "^1.2.2", 65 "objectpath": "^1.2.2",
  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>Rule chain</div>
  19 +<fc-canvas></fc-canvas>
  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, OnInit} from '@angular/core';
  18 +import {UserService} from '@core/http/user.service';
  19 +import {User} from '@shared/models/user.model';
  20 +import {Authority} from '@shared/models/authority.enum';
  21 +import {PageComponent} from '@shared/components/page.component';
  22 +import {Store} from '@ngrx/store';
  23 +import {AppState} from '@core/core.state';
  24 +import {FormBuilder, FormGroup, Validators} from '@angular/forms';
  25 +import {HasConfirmForm} from '@core/guards/confirm-on-exit.guard';
  26 +import {ActionAuthUpdateUserDetails} from '@core/auth/auth.actions';
  27 +import {environment as env} from '@env/environment';
  28 +import {TranslateService} from '@ngx-translate/core';
  29 +import {ActionSettingsChangeLanguage} from '@core/settings/settings.actions';
  30 +import {ChangePasswordDialogComponent} from '@modules/home/pages/profile/change-password-dialog.component';
  31 +import {MatDialog} from '@angular/material';
  32 +import {DialogService} from '@core/services/dialog.service';
  33 +import {AuthService} from '@core/auth/auth.service';
  34 +import {ActivatedRoute} from '@angular/router';
  35 +import { Dashboard } from '@shared/models/dashboard.models';
  36 +import { RuleChain } from '@shared/models/rule-chain.models';
  37 +
  38 +@Component({
  39 + selector: 'tb-rulechain-page',
  40 + templateUrl: './rulechain-page.component.html',
  41 + styleUrls: []
  42 +})
  43 +export class RuleChainPageComponent extends PageComponent implements OnInit {
  44 +
  45 + ruleChain: RuleChain;
  46 +
  47 + constructor(protected store: Store<AppState>,
  48 + private route: ActivatedRoute,
  49 + private userService: UserService,
  50 + private authService: AuthService,
  51 + private translate: TranslateService,
  52 + public dialog: MatDialog,
  53 + public dialogService: DialogService,
  54 + public fb: FormBuilder) {
  55 + super(store);
  56 + }
  57 +
  58 + ngOnInit() {
  59 + this.ruleChain = this.route.snapshot.data.ruleChain;
  60 + }
  61 +
  62 +}
@@ -14,12 +14,44 @@ @@ -14,12 +14,44 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import {NgModule} from '@angular/core';  
18 -import {RouterModule, Routes} from '@angular/router'; 17 +import { Injectable, NgModule } from '@angular/core';
  18 +import { ActivatedRouteSnapshot, Resolve, RouterModule, Routes } from '@angular/router';
19 19
20 import {EntitiesTableComponent} from '../../components/entity/entities-table.component'; 20 import {EntitiesTableComponent} from '../../components/entity/entities-table.component';
21 import {Authority} from '@shared/models/authority.enum'; 21 import {Authority} from '@shared/models/authority.enum';
22 import {RuleChainsTableConfigResolver} from '@modules/home/pages/rulechain/rulechains-table-config.resolver'; 22 import {RuleChainsTableConfigResolver} from '@modules/home/pages/rulechain/rulechains-table-config.resolver';
  23 +import { Dashboard } from '@shared/models/dashboard.models';
  24 +import { DashboardService } from '@core/http/dashboard.service';
  25 +import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
  26 +import { Observable } from 'rxjs';
  27 +import { map } from 'rxjs/operators';
  28 +import { BreadCrumbConfig, BreadCrumbLabelFunction } from '@shared/components/breadcrumb';
  29 +import { RuleChain } from '@shared/models/rule-chain.models';
  30 +import { RuleChainService } from '@core/http/rule-chain.service';
  31 +import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component';
  32 +import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/dashboard/dashboard-routing.module';
  33 +import { RuleChainPageComponent } from '@home/pages/rulechain/rulechain-page.component';
  34 +
  35 +
  36 +@Injectable()
  37 +export class RuleChainResolver implements Resolve<RuleChain> {
  38 +
  39 + constructor(private ruleChainService: RuleChainService) {
  40 + }
  41 +
  42 + resolve(route: ActivatedRouteSnapshot): Observable<RuleChain> {
  43 + const ruleChainId = route.params.ruleChainId;
  44 + return this.ruleChainService.getRuleChain(ruleChainId);
  45 + }
  46 +}
  47 +
  48 +export const ruleChainBreadcumbLabelFunction: BreadCrumbLabelFunction = ((route, translate, component) => {
  49 + let label: string = component.ruleChain.name;
  50 + if (component.ruleChain.root) {
  51 + label += ` (${translate.instant('rulechain.root')})`;
  52 + }
  53 + return label;
  54 +});
23 55
24 const routes: Routes = [ 56 const routes: Routes = [
25 { 57 {
@@ -41,6 +73,22 @@ const routes: Routes = [ @@ -41,6 +73,22 @@ const routes: Routes = [
41 resolve: { 73 resolve: {
42 entitiesTableConfig: RuleChainsTableConfigResolver 74 entitiesTableConfig: RuleChainsTableConfigResolver
43 } 75 }
  76 + },
  77 + {
  78 + path: ':ruleChainId',
  79 + component: RuleChainPageComponent,
  80 + data: {
  81 + breadcrumb: {
  82 + labelFunction: ruleChainBreadcumbLabelFunction,
  83 + icon: 'settings_ethernet'
  84 + } as BreadCrumbConfig,
  85 + auth: [Authority.TENANT_ADMIN],
  86 + title: 'rulechain.rulechain',
  87 + widgetEditMode: false
  88 + },
  89 + resolve: {
  90 + ruleChain: RuleChainResolver
  91 + }
44 } 92 }
45 ] 93 ]
46 } 94 }
@@ -50,7 +98,8 @@ const routes: Routes = [ @@ -50,7 +98,8 @@ const routes: Routes = [
50 imports: [RouterModule.forChild(routes)], 98 imports: [RouterModule.forChild(routes)],
51 exports: [RouterModule], 99 exports: [RouterModule],
52 providers: [ 100 providers: [
53 - RuleChainsTableConfigResolver 101 + RuleChainsTableConfigResolver,
  102 + RuleChainResolver
54 ] 103 ]
55 }) 104 })
56 export class RuleChainRoutingModule { } 105 export class RuleChainRoutingModule { }
@@ -21,6 +21,7 @@ import {RuleChainComponent} from '@modules/home/pages/rulechain/rulechain.compon @@ -21,6 +21,7 @@ import {RuleChainComponent} from '@modules/home/pages/rulechain/rulechain.compon
21 import {RuleChainRoutingModule} from '@modules/home/pages/rulechain/rulechain-routing.module'; 21 import {RuleChainRoutingModule} from '@modules/home/pages/rulechain/rulechain-routing.module';
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 25
25 @NgModule({ 26 @NgModule({
26 entryComponents: [ 27 entryComponents: [
@@ -29,7 +30,8 @@ import { RuleChainTabsComponent } from '@home/pages/rulechain/rulechain-tabs.com @@ -29,7 +30,8 @@ import { RuleChainTabsComponent } from '@home/pages/rulechain/rulechain-tabs.com
29 ], 30 ],
30 declarations: [ 31 declarations: [
31 RuleChainComponent, 32 RuleChainComponent,
32 - RuleChainTabsComponent 33 + RuleChainTabsComponent,
  34 + RuleChainPageComponent
33 ], 35 ],
34 imports: [ 36 imports: [
35 CommonModule, 37 CommonModule,
@@ -128,9 +128,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -128,9 +128,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
128 if ($event) { 128 if ($event) {
129 $event.stopPropagation(); 129 $event.stopPropagation();
130 } 130 }
131 - // TODO:  
132 - // this.router.navigateByUrl(`customers/${customer.id.id}/users`);  
133 - this.dialogService.todo(); 131 + this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`);
134 } 132 }
135 133
136 exportRuleChain($event: Event, ruleChain: RuleChain) { 134 exportRuleChain($event: Event, ruleChain: RuleChain) {
@@ -21,6 +21,7 @@ import { LogoComponent } from './components/logo.component'; @@ -21,6 +21,7 @@ import { LogoComponent } from './components/logo.component';
21 import { TbSnackBarComponent, ToastDirective } from './components/toast.directive'; 21 import { TbSnackBarComponent, ToastDirective } from './components/toast.directive';
22 import { BreadcrumbComponent } from '@app/shared/components/breadcrumb.component'; 22 import { BreadcrumbComponent } from '@app/shared/components/breadcrumb.component';
23 import { NgxFlowModule, FlowInjectionToken } from '@flowjs/ngx-flow'; 23 import { NgxFlowModule, FlowInjectionToken } from '@flowjs/ngx-flow';
  24 +import { NgxFlowchartModule } from 'ngx-flowchart/dist/ngx-flowchart';
24 import Flow from '@flowjs/flow.js'; 25 import Flow from '@flowjs/flow.js';
25 26
26 import { 27 import {
@@ -235,7 +236,8 @@ import { FileInputComponent } from './components/file-input.component'; @@ -235,7 +236,8 @@ import { FileInputComponent } from './components/file-input.component';
235 HotkeyModule, 236 HotkeyModule,
236 ColorPickerModule, 237 ColorPickerModule,
237 NgxHmCarouselModule, 238 NgxHmCarouselModule,
238 - NgxFlowModule 239 + NgxFlowModule,
  240 + NgxFlowchartModule
239 ], 241 ],
240 exports: [ 242 exports: [
241 FooterComponent, 243 FooterComponent,
@@ -317,6 +319,7 @@ import { FileInputComponent } from './components/file-input.component'; @@ -317,6 +319,7 @@ import { FileInputComponent } from './components/file-input.component';
317 HotkeyModule, 319 HotkeyModule,
318 ColorPickerModule, 320 ColorPickerModule,
319 NgxHmCarouselModule, 321 NgxHmCarouselModule,
  322 + NgxFlowchartModule,
320 ColorPickerDialogComponent, 323 ColorPickerDialogComponent,
321 MaterialIconsDialogComponent, 324 MaterialIconsDialogComponent,
322 ColorInputComponent, 325 ColorInputComponent,