diff options
Diffstat (limited to 'rulemgt-frontend/src/app/correlation-ruleInfo')
-rw-r--r-- | rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.html | 6 | ||||
-rw-r--r-- | rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts | 507 |
2 files changed, 262 insertions, 251 deletions
diff --git a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.html b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.html index 61535fc..2211a83 100644 --- a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.html +++ b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.html @@ -79,7 +79,7 @@ </div> </div> - <div class="row form-group"> + <!--<div class="row form-group"> <label for="" class="col-xs-2 col-sm-1 col-form-label labelstyle"> <span>{{"common_file"|translate}}</span> </label> @@ -119,7 +119,7 @@ </span> </div> </div> - </div> + </div>--> <div class="row form-group"> <label for="" class="col-xs-2 col-sm-1 col-form-label labelstyle"> @@ -153,4 +153,4 @@ </div> </div> </form> -</div>
\ No newline at end of file +</div> diff --git a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts index 56376df..dfb75b4 100644 --- a/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts +++ b/rulemgt-frontend/src/app/correlation-ruleInfo/ruleInfo.component.ts @@ -13,284 +13,295 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Component, OnInit, Input } from '@angular/core'; -import { RuleModel } from '../correlation-ruleList/alarmRule'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AlarmRuleService } from '../correlation-ruleList/alarmRule.service'; -import { Http, Response, Headers } from '@angular/http'; -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; + @Component({ - selector: 'RuleInfo', - templateUrl: './ruleInfo.component.html' + selector: 'RuleInfo', + templateUrl: './ruleInfo.component.html' }) export class RuleInfo implements OnInit { - formModel: RuleModel; - queryRule: RuleModel; - id: number; - addBottonStatus: boolean; - constructor(private modalService: ModalService, private route: ActivatedRoute, private router: Router, private alarmRuleService: AlarmRuleService, http: Http) { }; - - update() { - this.queryRule.enabled = $('input:radio:checked').val(); - if (!this.queryRule.content.startsWith('package ')) { - let msg = { title: 'exception_content_error', message: 'exception_package_error' }; - this.modalService.getmodalObservable.next(msg); + formModel: RuleModel; + queryRule: RuleModel; + id: number; + addBottonStatus: boolean; + + constructor(private modalService: ModalService, + private route: ActivatedRoute, + private router: Router, + private alarmRuleService: AlarmRuleService) { + }; + + + + ngOnInit() { + this.formModel = { + ruleId: null, + ruleName: null, + description: null, + content: null, + createTime: null, + creator: null, + updateTime: null, + modifier: null, + enabled: null, + loopControlName: null + }; + this.queryRule = { + ruleId: null, + ruleName: null, + description: null, + content: null, + createTime: null, + creator: null, + updateTime: null, + modifier: null, + enabled: 0, + loopControlName: '' + }; + + this.route.params.subscribe((params) => { + + let id = params['id']; + if (typeof (id) == 'string') { + if (id.indexOf('&') == -1) { + $('#ruleNameInput').attr('disabled', true); + $('#saveLabel').hide(); } else { - this.alarmRuleService.checkContent(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' }; - this.modalService.getmodalObservable.next(msg); - this.router.navigate(['alarmRule']); - } else if (res.status == 499) { - let msg = { title: 'modalTitleUpdate', message: 'message_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - } else { - let msg = { title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - } - }).catch( - res => { - let msg = { title: 'modalTitleUpdate', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - } - ); - - } else if (res.status == 499) { - let msg = { 'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error' }; - this.modalService.getmodalObservable.next(msg); - return false; - } else { - let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - return false; - } - }) + this.addBottonStatus = false; + $('#saveLabel').hide(); + $('#checkLabel').hide(); + $('#updateLabel').hide(); } - } - onSubmit(obj: NgModel) { - this.save(); - } + let str = id.split('&'); + this.getRuleInfo(str[0]); + } else if (typeof (id) != 'undefined') { + this.getRuleInfo(id); + } else { + $('#updateLabel').hide(); + } + if (typeof (this.queryRule.enabled) === 'number') { + this.queryRule.enabled = '' + this.queryRule.enabled; + } + }); - save() { - if (!this.queryRule.content.startsWith('package ')) { - let msg = { title: 'exception_content_error', message: 'exception_package_error' }; - this.modalService.getmodalObservable.next(msg); - } else { - this.alarmRuleService.checkContent(this.queryRule.content).then(res => { + this.initImportDiv(this.queryRule); + } + + update() { + this.queryRule.enabled = $('input:radio:checked').val(); + if (!this.queryRule.content.startsWith('package ')) { + 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.updateRule(this.queryRule) + .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' }; - this.modalService.getmodalObservable.next(msg); - this.router.navigate(['alarmRule']); - } else if (res.status == 499) { - let msg = { title: 'modalTitleDefault', message: 'message_rule_name_repeat_error' }; - this.modalService.getmodalObservable.next(msg); - } else { - let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - } - - }).catch(error => { - let msg = { title: 'modalTitleDefault', message: 'message_rule_name_repeat_error' }; - this.modalService.getmodalObservable.next(msg); - }); - return true; + 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': 'modalTitleCheck', message: 'message_rule_content_repeat_error' }; - this.modalService.getmodalObservable.next(msg); - return false; + let msg = {title: 'modalTitleUpdate', message: 'message_exception_rule_fail'}; + this.modalService.announceOpenModal(msg); } else { - let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - return false; + 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'}; + this.modalService.announceOpenModal(msg); + } + ); - getRuleInfo(id: string): void { - this.route.params.switchMap((params: Params) => this.alarmRuleService.search(id)) - .subscribe(rule => { - rule[0].enabled = '' + rule[0].enabled; - this.queryRule = rule[0] - }) + } else if (res.status == 499) { + 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'}; + this.modalService.announceOpenModal(msg); + return false; + } + }) } + } + + onSubmit(obj: NgModel) { + this.save(); + } - checkContent(judge: string): void { - if (!this.queryRule.content.startsWith('package ')) { - let msg = { title: 'exception_content_error', message: 'exception_package_error' }; - this.modalService.getmodalObservable.next(msg); + save() { + if (!this.queryRule.content || !this.queryRule.content.startsWith('package ')) { + 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'}; + this.modalService.announceOpenModal(msg); + this.router.navigate(['alarmRule']); + } else if (res.status == 499) { + 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'}; + this.modalService.announceOpenModal(msg); + } + + }).catch(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'}; + this.modalService.announceOpenModal(msg); + return false; } else { - this.alarmRuleService.checkContent(this.queryRule.content) - .then(res => { - if (res.status == 200) { - let msg = { 'title': 'modalTitleCheck', message: 'message_checkContent_rule_success' }; - this.modalService.getmodalObservable.next(msg); - } else if (res.status == 499) { - let msg = { 'title': 'modalTitleCheck', message: 'message_rule_content_repeat_error' }; - this.modalService.getmodalObservable.next(msg); - return false; - } else { - let msg = { 'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail' }; - this.modalService.getmodalObservable.next(msg); - return false; - } - }); + let msg = {'title': 'modalTitleCheck', message: 'message_other_exception_rule_fail'}; + this.modalService.announceOpenModal(msg); + return false; } + }) } - switch(): void { - // alert(this.queryRule.enabled); - this.queryRule.enabled == '0' ? this.queryRule.enabled = '1' : this.queryRule.enabled = '0'; + } + + getRuleInfo(id: string): void { + this.route.params.switchMap((params: Params) => this.alarmRuleService.search(id)) + .subscribe(rule => { + rule[0].enabled = '' + rule[0].enabled; + this.queryRule = rule[0] + }) + } + + checkContent(judge: string): void { + if (!this.queryRule.content || !this.queryRule.content.startsWith('package ')) { + 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'}; + this.modalService.announceOpenModal(msg); + } else if (res.status == 499) { + 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'}; + this.modalService.announceOpenModal(msg); + return false; + } + }); } + } + switch(): void { + // alert(this.queryRule.enabled); + this.queryRule.enabled == '0' ? this.queryRule.enabled = '1' : this.queryRule.enabled = '0'; + } - initUpload(queryRule: RuleModel): void { - $('#fileName').text(''); - $('#importFailTip').addClass('hide_panel'); - $('#fileupload').fileupload({ - dropZone: $('#dropzone'), - maxNumberOfFiles: 1, - maxChunkSize: 20000000, - autoUpload: false, - add: function (e, data) { - let fileName = data.files[0].name; + initUpload(queryRule: RuleModel): void { + $('#fileName').text(''); + $('#importFailTip').addClass('hide_panel'); + $('#fileupload').fileupload({ - $('#importFailTip').addClass('hide_panel'); - let suffix = fileName.substring(fileName.lastIndexOf('.'), fileName.length) + dropZone: $('#dropzone'), + maxNumberOfFiles: 1, + maxChunkSize: 20000000, + autoUpload: false, + add: function (e, data) { + let fileName = data.files[0].name; - if (suffix != '.txt') { - $('#importFailTip').removeClass('hide_panel'); - return suffix; - } + $('#importFailTip').addClass('hide_panel'); + let suffix = fileName.substring(fileName.lastIndexOf('.'), fileName.length) - $('#bar').css('width', '0%'); - $('#persent').text('0%'); - $('#fileName').text(fileName); - $('#fileremove').attr('disabled', false); - $('#filesubmit').attr('disabled', false); - $('#filesubmit').click(function () { - this.file = data.files[0] - var reader = new FileReader(); - reader.readAsText(this.file); - reader.onload = function (data) { - queryRule.content = this.result; - } - $('#fileremove').click(); - $('#importDiv').hide(); - e.stopPropagation(); - }); - - $('#fileremove').click(function () { - $('#bar').css('width', '0%'); - $('#persent').text('0%'); - $('#fileName').text(''); - $('#filesubmit').attr('disabled', true); - $('#fileremove').attr('disabled', true); - }); - }, - done: function (e, data) { - - }, - fail: function (e, resp) { - }, - always: function (e, data) { - $('.progress').removeClass('active'); - $('#bar').css('width', '100%'); - $('#persent').text('100%'); - }, - progressall: function (e, data) { - } + if (suffix != '.txt') { + $('#importFailTip').removeClass('hide_panel'); + return suffix; + } + + $('#bar').css('width', '0%'); + $('#persent').text('0%'); + $('#fileName').text(fileName); + $('#fileremove').attr('disabled', false); + $('#filesubmit').attr('disabled', false); + $('#filesubmit').click(function () { + this.file = data.files[0] + var reader = new FileReader(); + reader.readAsText(this.file); + reader.onload = function (data) { + queryRule.content = this.result; + } + $('#fileremove').click(); + $('#importDiv').hide(); + e.stopPropagation(); }); - } - initImportDiv(queryRule: RuleModel): void { - this.initUpload(queryRule); - let importDiv = $('#importDiv'); - $(function (arg) { - $('#importBtn').click(function (e) { - e.preventDefault(); - $('[data-toggle="tooltip"]').tooltip(); - $('#importFailTip').addClass('hide_panel'); - showDiv(); - $(document).one('click', function (e) { - $(importDiv).hide(); - }); - e.stopPropagation(); - }); - $(importDiv).click(function (e) { - e.stopPropagation(); - }); - $('#filesubmit').attr('disabled', true); - $('#fileremove').attr('disabled', true); + $('#fileremove').click(function () { + $('#bar').css('width', '0%'); + $('#persent').text('0%'); + $('#fileName').text(''); + $('#filesubmit').attr('disabled', true); + $('#fileremove').attr('disabled', true); }); - function showDiv() { - $('#bar').css('width', '0%'); - $('#persent').text('0%'); - $(importDiv).fadeIn(); - } - } - ngOnInit() { - this.formModel = { - ruleId: null, - ruleName: null, - description: null, - content: null, - createTime: null, - creator: null, - updateTime: null, - modifier: null, - enabled: null, - loopControlName: null - }; - this.queryRule = { - ruleId: null, - ruleName: null, - description: null, - content: null, - createTime: null, - creator: null, - updateTime: null, - modifier: null, - enabled: 0, - loopControlName: '' - }; - - this.route.params.subscribe((params) => { - - let id = params['id']; - if (typeof (id) == 'string') { - if (id.indexOf('&') == -1) { - $('#ruleNameInput').attr('disabled', true); - $('#saveLabel').hide(); - } else { - this.addBottonStatus = false; - $('#saveLabel').hide(); - $('#checkLabel').hide(); - $('#updateLabel').hide(); - } + }, + done: function (e, data) { - let str = id.split('&'); - this.getRuleInfo(str[0]); - } else if (typeof (id) != 'undefined') { - this.getRuleInfo(id); - } else { - $('#updateLabel').hide(); - } - if (typeof (this.queryRule.enabled) === 'number') { - this.queryRule.enabled = '' + this.queryRule.enabled; - } + }, + fail: function (e, resp) { + }, + always: function (e, data) { + $('.progress').removeClass('active'); + $('#bar').css('width', '100%'); + $('#persent').text('100%'); + }, + progressall: function (e, data) { + } + }); + } + + initImportDiv(queryRule: RuleModel): void { + this.initUpload(queryRule); + let importDiv = $('#importDiv'); + $(function (arg) { + $('#importBtn').click(function (e) { + e.preventDefault(); + $('[data-toggle="tooltip"]').tooltip(); + $('#importFailTip').addClass('hide_panel'); + showDiv(); + $(document).one('click', function (e) { + $(importDiv).hide(); }); + e.stopPropagation(); + }); + $(importDiv).click(function (e) { + e.stopPropagation(); + }); + $('#filesubmit').attr('disabled', true); + $('#fileremove').attr('disabled', true); + }); - this.initImportDiv(this.queryRule); + function showDiv() { + $('#bar').css('width', '0%'); + $('#persent').text('0%'); + $(importDiv).fadeIn(); } + } -}
\ No newline at end of file +} |