55 lines
1.7 KiB
TypeScript
Raw Normal View History

2019-12-09 20:14:50 +02:00
///
2020-02-20 10:26:43 +02:00
/// Copyright © 2016-2020 The Thingsboard Authors
2019-12-09 20:14:50 +02:00
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
2019-12-12 19:55:17 +02:00
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { Component, OnInit } from '@angular/core';
2019-12-09 20:14:50 +02:00
import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
2020-07-31 16:18:49 +03:00
import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
import { Router } from '@angular/router';
2019-12-09 20:14:50 +02:00
@Component({
// tslint:disable-next-line:component-selector
2019-12-09 20:14:50 +02:00
selector: 'rule-node',
templateUrl: './rulenode.component.html',
styleUrls: ['./rulenode.component.scss']
})
2019-12-12 19:55:17 +02:00
export class RuleNodeComponent extends FcNodeComponent implements OnInit {
2019-12-09 20:14:50 +02:00
2019-12-12 19:55:17 +02:00
iconUrl: SafeResourceUrl;
2020-07-31 16:18:49 +03:00
RuleNodeType = RuleNodeType;
2019-12-12 19:55:17 +02:00
2020-07-31 16:18:49 +03:00
constructor(private sanitizer: DomSanitizer,
private router: Router) {
2019-12-09 20:14:50 +02:00
super();
}
2019-12-12 19:55:17 +02:00
ngOnInit(): void {
super.ngOnInit();
if (this.node.iconUrl) {
this.iconUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.node.iconUrl);
}
}
2020-07-31 16:18:49 +03:00
openRuleChain($event: Event, node: FcRuleNode) {
if ($event) {
$event.stopPropagation();
}
if (node.targetRuleChainId) {
this.router.navigateByUrl(`/ruleChains/${node.targetRuleChainId}`);
}
}
2019-12-09 20:14:50 +02:00
}