- ruleModel: RuleModel;
- rules: RuleModel[];
- queryRule: RuleModel;
- activeText: string;
- ruleName: string;
- enable_on = "enabled";
- enable_off = "disabled"
- totalcount: number = 0;
- model: any;
- ruleRequest: RuleRequest;
- solution = 'ANGULAR';
- selection = 'A';
- activeStatus = ["option_all", "common_enabled", "common_disabled"];
-
- constructor(public _alarmRuleService: AlarmRuleService, private modalService: ModalService,
- private router: Router) { }
-
- switch(select: string): void {
- console.log(select);
- if (select == "common_enabled") {
- this.ruleModel.enabled = 1;
- } else if (select == "common_disabled") {
- this.ruleModel.enabled = 0;
- } else {
-
- this.ruleModel.enabled = null;
- }
- this.setActiveText();
- }
-
- setActiveText(): void {
- if (this.ruleModel.enabled == 1) {
- this.activeText = "common_enabled";
- this.ruleRequest.enabled = 1;
- }
- else if (this.ruleModel.enabled == 0) {
- this.activeText = "common_disabled";
- this.ruleRequest.enabled = 0;
- } else {
- this.activeText = "option_all";
- this.ruleRequest.enabled = null;
- }
- }
-
- getRules(): Promise<any> {
- return this._alarmRuleService
- .getRules()
- .then(rules => {
- this.rules = rules.correlationRules;
- this.totalcount = rules.totalCount;
- });
- }
-
- public searchRules(): void {
- if (this.ruleModel.enabled == null) {
- this.ruleRequest.enabled = null;
- }
- this.ruleRequest.ruleName = this.ruleModel.ruleName;
- console.log(this.ruleRequest.enabled, this.ruleRequest.ruleName);
-
- this._alarmRuleService
- .searchrules(this.ruleRequest)
- .then(rules => {
- this.rules = rules;
- this.totalcount = rules.length;
- });
- }
- public updateRule(rule: RuleModel): void {
- this.router.navigate(['ruleInfo/', rule.ruleId]);
- }
-
- public delete(rule: RuleModel): void {
- rule.enabled == 1 ? this.deleteActiveRule(rule) : this.deleteModel(rule.ruleId, this._alarmRuleService, this);
- }
-
- public on_off(rule: RuleModel) {
- rule.enabled == 0 ? rule.enabled = 1 : rule.enabled = 0;
- this._alarmRuleService
- .updateRule(rule)
- .then(res => {
- rule = res;
- });
- }
-
- public reset(): void {
- this.ruleModel.ruleName = null;
- this.activeText = 'option_all';
- this.ruleModel.enabled = null;
- this.getRules();
+ ruleModel: RuleModel;
+ rules: any[];
+ queryRule: RuleModel;
+ activeText: string;
+ ruleName: string;
+ enable_on = "enabled";
+ enable_off = "disabled"
+ totalcount: number = 0;
+ model: any;
+ ruleRequest: RuleRequest;
+ solution = 'ANGULAR';
+ selection = 'A';
+ activeStatus = ["option_all", "common_enabled", "common_disabled"];
+
+ constructor(public _alarmRuleService: AlarmRuleService, private modalService: ModalService,
+ private router: Router) {
+ }
+
+ switch(select: string): void {
+ console.log(select);
+ if (select == "common_enabled") {
+ this.ruleModel.enabled = 1;
+ } else if (select == "common_disabled") {
+ this.ruleModel.enabled = 0;
+ } else {
+
+ this.ruleModel.enabled = null;