diff options
author | minfanyang <yang.minfan@zte.com.cn> | 2018-08-24 09:28:10 +0800 |
---|---|---|
committer | minfanyang <yang.minfan@zte.com.cn> | 2018-08-24 09:28:10 +0800 |
commit | 6e26bf0b71a8b8493fbd1575717a2c5e539f93ee (patch) | |
tree | 122b28e8c4ebf9ab70051ba34cec8e6ca022d27c /rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts | |
parent | 448a62b47b193dd8a658b6d7c0ddf52dbfe2589b (diff) |
Fixed ui error
Change-Id: I2a26998cc093a7aaf6458f28dc752b152f0cf666
Issue-ID: HOLMES-163
Signed-off-by: minfanyang <yang.minfan@zte.com.cn>
Diffstat (limited to 'rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts')
-rw-r--r-- | rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts b/rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts index 1f0ee3e..ebab289 100644 --- a/rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts +++ b/rulemgt-frontend/src/app/correlation-ruleList/alarmRule.service.ts @@ -13,113 +13,113 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Injectable } from '@angular/core'; -import { Http, Response, Headers } from '@angular/http'; +import {Injectable} from '@angular/core'; +import {Headers, Http} from '@angular/http'; -import { RuleModel } from './alarmRule'; -import { RuleRequest } from './ruleRequest'; -import { Router } from '@angular/router'; -import { ModalService } from '../correlation-modal/modal.service'; +import {RuleModel} from './alarmRule'; +import {RuleRequest} from './ruleRequest'; @Injectable() export class AlarmRuleService { - private ruleUrl = "/api/holmes-rule-mgmt/v1/rule"; - private headers = new Headers({ 'Content-Type': 'application/json' }); - constructor(private http: Http, private modalService: ModalService, private router: Router) { } - - getRules(): Promise<any> { - return this.http.get(this.ruleUrl) - .toPromise() - .then(res => res.json()) - .catch(this.handleError); - } + private ruleUrl = "/api/holmes-rule-mgmt/v1/rule"; + private headers = new Headers({'Content-Type': 'application/json'}); - private handleError(error: any): Promise<any> { - console.error('An error occurred', error); - return Promise.reject(error._body || error); - } + constructor(private http: Http) { + } - search(ruleId: string): Promise<RuleModel> { - if (typeof (ruleId) == "string") { - let rule = [{ - ruleId: null, - ruleName: null, - description: null, - content: null, - createtime: null, - creator: null, - updatetime: null, - modifier: null, - enabled: 0, - }] - } - let data = { 'ruleId': ruleId }; - var queryrequest = JSON.stringify(data); - const url = `${this.ruleUrl}?queryrequest=${queryrequest}`; - return this.http.get(url, {headers:this.headers}) - .toPromise() - .then(res => res.json().correlationRules as RuleModel[]) - .catch(this.handleError); - } + getRules(): Promise<any> { + return this.http.get(this.ruleUrl) + .toPromise() + .then(res => res.json()) + .catch(this.handleError); + } - searchrules(rule: RuleRequest): Promise<RuleModel[]> { - let data = { ruleName: rule.ruleName, enabled: rule.enabled } - console.log(JSON.stringify(data)); - const url = `${this.ruleUrl}?queryrequest=${JSON.stringify(data)}` - return this.http.get(url, { body: data, headers: this.headers }) - .toPromise() - .then(res => res.json().correlationRules as RuleModel[]) - .catch(this.handleError); - } + private handleError(error: any): Promise<any> { + console.error('An error occurred', error); + return Promise.reject(error._body || error); + } - checkContent(ruleContent: string): Promise<any> { - const url = "/api/holmes-engine-mgmt/v1/rule"; - let data = { content: ruleContent }; - return this.http - .post(url, JSON.stringify(data), { headers: this.headers }) - .toPromise() - .then(res => res) - .catch(error => error); + search(ruleId: string): Promise<RuleModel> { + if (typeof (ruleId) == "string") { + let rule = [{ + ruleId: null, + ruleName: null, + description: null, + content: null, + createtime: null, + creator: null, + updatetime: null, + modifier: null, + enabled: 0, + }] } + let data = {'ruleId': ruleId}; + var queryrequest = JSON.stringify(data); + const url = `${this.ruleUrl}?queryrequest=${queryrequest}`; + return this.http.get(url, {headers: this.headers}) + .toPromise() + .then(res => res.json().correlationRules as RuleModel[]) + .catch(this.handleError); + } - updateRule(rule: RuleModel): Promise<any> { - let rules = { - "ruleId": rule.ruleId, - "description": rule.description, - "content": rule.content, - "enabled": rule.enabled, - "loopControlName": rule.loopControlName - } - const url = `${this.ruleUrl}` - return this.http - .post(url, JSON.stringify(rules), { headers: this.headers }) - .toPromise() - .then(res => res) - .catch(error => error) - } + searchrules(rule: RuleRequest): Promise<RuleModel[]> { + let data = {ruleName: rule.ruleName, enabled: rule.enabled} + console.log(JSON.stringify(data)); + const url = `${this.ruleUrl}?queryrequest=${JSON.stringify(data)}` + return this.http.get(url, {body: data, headers: this.headers}) + .toPromise() + .then(res => res.json().correlationRules as RuleModel[]) + .catch(this.handleError); + } + + checkContent(ruleContent: string): Promise<any> { + const url = "/api/holmes-engine-mgmt/v1/rule"; + let data = {content: ruleContent}; + return this.http + .post(url, JSON.stringify(data), {headers: this.headers}) + .toPromise() + .then(res => res) + .catch(error => error); + } - save(rule: RuleModel): Promise<any> { - let ruledata = { - "description": rule.description, - "content": rule.content, - "enabled": rule.enabled, - "ruleName": rule.ruleName, - "loopControlName": rule.loopControlName - } - return this.http.put(this.ruleUrl, JSON.stringify(ruledata), { headers: this.headers }) - .toPromise() - .then(res => res) - .catch(error => error); + updateRule(rule: RuleModel): Promise<any> { + let rules = { + "ruleId": rule.ruleId, + "description": rule.description, + "content": rule.content, + "enabled": rule.enabled, + "loopControlName": rule.loopControlName } + const url = `${this.ruleUrl}` + return this.http + .post(url, JSON.stringify(rules), {headers: this.headers}) + .toPromise() + .then(res => res) + .catch(error => error) + } - public delete(ruleId: string): Promise<void> { - const url = `${this.ruleUrl}` + '/' + ruleId; - return this.http.delete(url, { headers: this.headers }) - .toPromise() - .then(res => { - - }) - .catch(this.handleError); + save(rule: RuleModel): Promise<any> { + let ruledata = { + "description": rule.description, + "content": rule.content, + "enabled": rule.enabled, + "ruleName": rule.ruleName, + "loopControlName": rule.loopControlName } -}
\ No newline at end of file + return this.http.put(this.ruleUrl, JSON.stringify(ruledata), {headers: this.headers}) + .toPromise() + .then(res => res) + .catch(error => error); + } + + public delete(ruleId: string): Promise<void> { + const url = `${this.ruleUrl}` + '/' + ruleId; + return this.http.delete(url, {headers: this.headers}) + .toPromise() + .then(res => { + + }) + .catch(this.handleError); + } +} |