summaryrefslogtreecommitdiffstats
path: root/rulemgt-frontend
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2018-09-21 17:28:34 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2018-09-21 17:28:34 +0800
commitaffcda23b190b7f3f20e27bf375cd3cc79216914 (patch)
tree23bc4b76309921ad016b0c8cf297b90b45a4b1c6 /rulemgt-frontend
parent19a11640b3ed8d770fd1cb6f296c4c0e793cdb2a (diff)
Fix the Rule Updating Issue
Change-Id: I0b8a1554869f7e3638e1f25288c75efd83922877 Issue-ID: HOLMES-170 Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt-frontend')
-rw-r--r--rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts69
1 files changed, 39 insertions, 30 deletions
diff --git a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts
index 4610a63..e75de3c 100644
--- a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts
+++ b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts
@@ -13,12 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-import {Component, OnInit} from '@angular/core';
-import {RuleModel} from '../correlation-ruleList/alarmRule';
-import {ActivatedRoute, Params, Router} from '@angular/router';
-import {AlarmRuleService} from '../correlation-ruleList/alarmRule.service';
-import {ModalService} from '../correlation-modal/modal.service';
-import {NgModel} from '@angular/forms';
+import { Component, OnInit } from '@angular/core';
+import { RuleModel } from '../correlation-ruleList/alarmRule';
+import { ActivatedRoute, Params, Router } from '@angular/router';
+import { AlarmRuleService } from '../correlation-ruleList/alarmRule.service';
+import { ModalService } from '../correlation-modal/modal.service';
+import { NgModel } from '@angular/forms';
declare var $: any;
@@ -33,9 +33,9 @@ export class RuleInfo implements OnInit {
addBottonStatus: boolean;
constructor(private modalService: ModalService,
- private route: ActivatedRoute,
- private router: Router,
- private alarmRuleService: AlarmRuleService) {
+ private route: ActivatedRoute,
+ private router: Router,
+ private alarmRuleService: AlarmRuleService) {
};
@@ -98,38 +98,37 @@ export class RuleInfo implements OnInit {
update() {
this.queryRule.enabled = $('input:radio:checked').val();
if (!this.queryRule.content.startsWith('package ')) {
- let msg = {title: 'exception_content_error', message: 'exception_package_error'};
+ let msg = { title: 'exception_content_error', message: 'exception_package_error' };
this.modalService.announceOpenModal(msg);
} else {
- this.alarmRuleService.checkContent(this.queryRule.content)
+ this.alarmRuleService.checkContent(this.replacePkgName(this.queryRule.content))
.then(res => {
if (res.status == 200) {
this.alarmRuleService.updateRule(this.queryRule)
.then(res => {
if (res.status == 200) {
- let msg = {title: 'modalTitleUpdate', message: 'message_update_rule_success'};
+ let msg = { title: 'modalTitleUpdate', message: 'message_update_rule_success' };
this.modalService.announceOpenModal(msg);
this.router.navigate(['alarmRule']);
} else if (res.status == 499) {
- let msg = {title: 'modalTitleUpdate', message: 'message_exception_rule_fail'};
+ let msg = { title: 'modalTitleUpdate', message: 'message_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
} else {
- let msg = {title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail'};
+ let msg = { title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
}
}).catch(
res => {
- let msg = {title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail'};
+ let msg = { title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
}
- );
-
+ );
} else if (res.status == 499) {
- let msg = {'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error' };
this.modalService.announceOpenModal(msg);
return false;
} else {
- let msg = {'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
return false;
}
@@ -143,35 +142,35 @@ export class RuleInfo implements OnInit {
save() {
if (!this.queryRule.content || !this.queryRule.content.startsWith('package ')) {
- let msg = {title: 'exception_content_error', message: 'exception_package_error'};
+ let msg = { title: 'exception_content_error', message: 'exception_package_error' };
this.modalService.announceOpenModal(msg);
} else {
this.alarmRuleService.checkContent(this.queryRule.content).then(res => {
if (res.status == 200) {
this.alarmRuleService.save(this.queryRule).then(res => {
if (res.status == 200) {
- let msg = {title: 'modalTitleDefault', message: 'message_add_rule_success'};
+ let msg = { title: 'modalTitleDefault', message: 'message_add_rule_success' };
this.modalService.announceOpenModal(msg);
this.router.navigate(['alarmRule']);
} else if (res.status == 499) {
- let msg = {title: 'modalTitleDefault', message: 'message_rule_name_repeat_error'};
+ let msg = { title: 'modalTitleDefault', message: 'message_rule_name_repeat_error' };
this.modalService.announceOpenModal(msg);
} else {
- let msg = {'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
}
}).catch(error => {
- let msg = {title: 'modalTitleDefault', message: 'message_rule_name_repeat_error'};
+ let msg = { title: 'modalTitleDefault', message: 'message_rule_name_repeat_error' };
this.modalService.announceOpenModal(msg);
});
return true;
} else if (res.status == 499) {
- let msg = {'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error' };
this.modalService.announceOpenModal(msg);
return false;
} else {
- let msg = {'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
return false;
}
@@ -189,20 +188,20 @@ export class RuleInfo implements OnInit {
checkContent(judge: string): void {
if (!this.queryRule.content || !this.queryRule.content.startsWith('package ')) {
- let msg = {title: 'exception_content_error', message: 'exception_package_error'};
+ let msg = { title: 'exception_content_error', message: 'exception_package_error' };
this.modalService.announceOpenModal(msg);
} else {
this.alarmRuleService.checkContent(this.queryRule.content)
.then(res => {
if (res.status == 200) {
- let msg = {'title': 'modalTitleCheck', message: 'message_checkContent_rule_success'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_checkContent_rule_success' };
this.modalService.announceOpenModal(msg);
} else if (res.status == 499) {
- let msg = {'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error' };
this.modalService.announceOpenModal(msg);
return false;
} else {
- let msg = {'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail'};
+ let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' };
this.modalService.announceOpenModal(msg);
return false;
}
@@ -304,4 +303,14 @@ export class RuleInfo implements OnInit {
}
}
+ replacePkgName (content: string): string {
+ let reg = /(package\s+[\w\d\.]+)(\s+|;).*/;
+ let groups = reg.exec(content);
+ let pkgName = groups[1];
+ if (pkgName == null) {
+ return content;
+ }
+ return content.replace(pkgName, pkgName + new Date().getTime());
+ }
+
}