summaryrefslogtreecommitdiffstats
path: root/public/src/app/rule-engine/api/rule-engine-api.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'public/src/app/rule-engine/api/rule-engine-api.service.ts')
-rw-r--r--public/src/app/rule-engine/api/rule-engine-api.service.ts138
1 files changed, 128 insertions, 10 deletions
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<any> = new Subject();
updateVersionLock: Subject<any> = new Subject();
- tabIndex: Subject<any> = new Subject();
+ tabIndex: Subject<any> = 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<any> {
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<any> {
+ 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',