From 22eda038b6cb646d63bfaf617372fce2b5d98631 Mon Sep 17 00:00:00 2001 From: "Manor, Yanir (ym903w)" Date: Thu, 20 Sep 2018 14:18:38 +0300 Subject: update code to latest update code to latest Change-Id: I6ed427434b0da47e0d33507a0992b09fe48f9c52 Issue-ID: DCAEGEN2-821 Signed-off-by: Manor, Yanir (ym903w) --- .../app/rule-engine/api/rule-engine-api.service.ts | 138 +++++++++++++++++++-- 1 file changed, 128 insertions(+), 10 deletions(-) (limited to 'public/src/app/rule-engine/api/rule-engine-api.service.ts') diff --git a/public/src/app/rule-engine/api/rule-engine-api.service.ts b/public/src/app/rule-engine/api/rule-engine-api.service.ts index 7bf5e18..f19fd15 100644 --- a/public/src/app/rule-engine/api/rule-engine-api.service.ts +++ b/public/src/app/rule-engine/api/rule-engine-api.service.ts @@ -9,7 +9,7 @@ import { import 'rxjs/add/operator/catch'; // Import RxJs required methods import 'rxjs/add/operator/map'; -import { Observable, Subject } from 'rxjs/Rx'; +import { Observable, Subject, BehaviorSubject } from 'rxjs/Rx'; import { v4 as uuid } from 'uuid'; import { environment } from '../../../environments/environment'; @@ -25,7 +25,7 @@ export class RuleEngineApiService { flowType: string; editorData: Subject = new Subject(); updateVersionLock: Subject = new Subject(); - tabIndex: Subject = new Subject(); + tabIndex: Subject = new BehaviorSubject(-1); constructor(private http: Http) { this.baseUrl = `${environment.apiBaseUrl}/rule-editor`; @@ -70,6 +70,20 @@ export class RuleEngineApiService { ); } + getLatestMcUuid(params) { + const { contextType, serviceUuid, vfiName, vfcmtUuid } = params; + const url = `${ + environment.apiBaseUrl + }/${contextType}/${serviceUuid}/${vfiName}/${vfcmtUuid}/getLatestMcUuid`; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .get(url, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + getListOfRules(): Observable { const url = `${this.baseUrl}/rule/${this.vfcmtUuid}/${this.dcaeCompName}/${ this.nid @@ -83,8 +97,99 @@ export class RuleEngineApiService { }); } - modifyRule(newRole) { - const url = `${this.baseUrl}/rule/${this.vfcmtUuid}/${this.dcaeCompName}/${ + getInitialPhases(flowType): Observable { + const url = `${environment.apiBaseUrl}/conf/getPhases/${flowType}`; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .get(url, this.options) + .map(response => response.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + exportRules() { + const url = `${this.baseUrl}/export/${this.vfcmtUuid}/${ + this.dcaeCompName + }/${this.nid}/${this.configParam}`; + console.log(url); + const link = document.createElement('a'); + link.download = 'a'; + link.href = url; + document.body.appendChild(link); + link.click(); + } + + importRules(rule, vfcmtUuid, isGroup) { + const url = `${this.baseUrl}/import/${vfcmtUuid}/${this.dcaeCompName}/${ + this.nid + }/${this.configParam}/${isGroup}`; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .post(url, rule, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json() || 'Server error'); + }); + } + + importPhase(ruleList) { + const url = `${this.baseUrl}/importPhase`; + + Object.assign(ruleList, { + vfcmtUuid: this.vfcmtUuid, + dcaeCompLabel: this.dcaeCompName, + nid: this.nid, + configParam: this.configParam + }); + + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .post(url, ruleList, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + applyFilter(newFilter) { + const url = `${this.baseUrl}/applyFilter`; + + Object.assign(newFilter, { + vfcmtUuid: this.vfcmtUuid, + dcaeCompLabel: this.dcaeCompName, + nid: this.nid, + configParam: this.configParam + }); + + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .post(url, newFilter, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + deleteFilter() { + const deleteFilter = { + vfcmtUuid: this.vfcmtUuid, + dcaeCompLabel: this.dcaeCompName, + nid: this.nid, + configParam: this.configParam + }; + const url = `${this.baseUrl}/deleteFilter`; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .post(url, deleteFilter, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + modifyRule(newRole, vfcmtUuid) { + const url = `${this.baseUrl}/rule/${vfcmtUuid}/${this.dcaeCompName}/${ this.nid }/${this.configParam}`; this.options.headers.set('X-ECOMP-RequestID', uuid()); @@ -96,8 +201,8 @@ export class RuleEngineApiService { }); } - deleteRule(uid) { - const url = `${this.baseUrl}/rule/${this.vfcmtUuid}/${this.dcaeCompName}/${ + deleteRule(uid, vfcmtUuid) { + const url = `${this.baseUrl}/rule/${vfcmtUuid}/${this.dcaeCompName}/${ this.nid }/${this.configParam}/${uid}`; this.options.headers.set('X-ECOMP-RequestID', uuid()); @@ -109,15 +214,28 @@ export class RuleEngineApiService { }); } - translate(nofityId) { + deleteGroup(groupId, vfcmtUuid) { + const url = `${this.baseUrl}/group/${vfcmtUuid}/${this.dcaeCompName}/${ + this.nid + }/${this.configParam}/${groupId}`; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + return this.http + .delete(url, this.options) + .map((res: Response) => res.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + translate(entryPhase, publishPhase, vfcmtUuid) { const url = `${this.baseUrl}/rule/translate`; const params = { - vfcmtUuid: this.vfcmtUuid, + vfcmtUuid: vfcmtUuid, dcaeCompLabel: this.dcaeCompName, nid: this.nid, configParam: this.configParam, - flowType: this.flowType, - notifyId: nofityId + entryPhase: entryPhase, + publishPhase: publishPhase }; this.options.headers.set('X-ECOMP-RequestID', uuid()); // const params = new URLSearchParams(); params.append('flowType', -- cgit 1.2.3-korg