diff options
Diffstat (limited to 'public/src/app/rule-engine')
11 files changed, 209 insertions, 142 deletions
diff --git a/public/src/app/rule-engine/action-list/action-list.component.html b/public/src/app/rule-engine/action-list/action-list.component.html index c7eac9f..201dba0 100644 --- a/public/src/app/rule-engine/action-list/action-list.component.html +++ b/public/src/app/rule-engine/action-list/action-list.component.html @@ -107,10 +107,11 @@ </button> <button mat-icon-button class='button-remove' [disabled]="store.viewOnly" (click)="removeAction(action)" data-tests-id="deleteAction"> - <mat-icon>delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> - </div> + </div> </li> </ul> </div> diff --git a/public/src/app/rule-engine/action-list/action-list.component.ts b/public/src/app/rule-engine/action-list/action-list.component.ts index f8fd6dd..466b6a9 100644 --- a/public/src/app/rule-engine/action-list/action-list.component.ts +++ b/public/src/app/rule-engine/action-list/action-list.component.ts @@ -407,6 +407,7 @@ export class ActionListComponent implements AfterViewInit { // clear temp copy rule. this.clearCopyRuleFromList(); // then update the rule list and sync with server + this.updateTaregtListExisiting(); this.store.updateRuleInList(response); this._ruleApi.callUpdateVersionLock(); this.store.loader = false; @@ -424,6 +425,25 @@ export class ActionListComponent implements AfterViewInit { } } + updateTaregtListExisiting() { + this._ruleApi + .generateMappingRulesFileName( + this.store.ruleListExistParams.nodeName, + this.store.ruleListExistParams.nodeId, + this.store.ruleListExistParams.vfcmtUuid + ) + .subscribe(response => { + console.log('generateMappingRulesFileName response: ', response); + this.store.advancedSetting.forEach(element => { + if (response.includes(element.name)) { + element.isExist = true; + } else { + element.isExist = false; + } + }); + }); + } + private clearCopyRuleFromList() { this.store.ruleList = this.store.ruleList.filter(item => item.uid !== ''); } @@ -452,6 +472,7 @@ export class ActionListComponent implements AfterViewInit { // clear temp copy rule. this.clearCopyRuleFromList(); // then update the rule list and sync with server + this.updateTaregtListExisiting(); this.store.updateRuleInList(response); this._ruleApi.callUpdateVersionLock(); this.uid = response.uid; diff --git a/public/src/app/rule-engine/action/action.component.html b/public/src/app/rule-engine/action/action.component.html index f439c5c..21f03b1 100644 --- a/public/src/app/rule-engine/action/action.component.html +++ b/public/src/app/rule-engine/action/action.component.html @@ -17,7 +17,7 @@ <span class="label" style="padding: 0 5px; width: 100px;"> Start Value </span> - <input required class="input-text" [readonly]="store.viewOnly" data-tests-id="startValue" name="title" + <input required class="input-text" [readonly]="store.viewOnly" data-tests-id="startValue" name="startValue" [(ngModel)]="action.stringTransform.startValue" type="text" placeholder="Select start value"> </div> </div> @@ -34,7 +34,7 @@ <span class="label" style="padding: 0 5px; width: 100px;"> Target case </span> - <input required class="input-text" [readonly]="store.viewOnly" data-tests-id="targetCase" name="title" + <input required class="input-text" [readonly]="store.viewOnly" data-tests-id="targetCase" name="targetCase" [(ngModel)]="action.stringTransform.targetCase" type="text" placeholder="Select target case"> </div> </div> @@ -162,7 +162,8 @@ <button mat-icon-button class="button-remove" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" (click)="removeSearchField(index)" *ngIf="action.search.enrich.fields.length > 1" style="box-shadow: none; height: 24px; width: 24px; display:flex" data-tests-id="btnDelete" [disabled]="store.viewOnly"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> @@ -217,7 +218,8 @@ <button mat-icon-button data-tests-id="btn-remove-row" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" class="button-remove" (click)="removeSearchUpdatesRow(index)" *ngIf="action.search.updates.length > 1" [disabled]="store.viewOnly" style="height: 24px; width: 24px; display:flex; box-shadow: none;"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </th> </tr> @@ -421,7 +423,8 @@ <th style="height: 30px; display: flex; align-items: baseline;"> <button mat-icon-button data-tests-id="btn-remove-row" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" class="button-remove" (click)="removeMapRow(index)" *ngIf="action.map.values.length > 1" style="height: 24px; width: 24px; display:flex; box-shadow: none;" [disabled]="store.viewOnly"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </th> </tr> @@ -433,7 +436,6 @@ <div style="display: flex; align-items: center;"> <button mat-mini-fab color="primary" (click)="addMapRow()" data-tests-id="btn-add-row" style="height: 16px; width: 16px; display:flex; box-shadow: none;" [disabled]="store.viewOnly"> <span style="padding-left: 2px; display: flex; justify-content: center; align-items: center" [innerHTML]="'plus' | feather:12"></span> - <!-- <mat-icon>add</mat-icon> --> </button> <span style="color: #009FDB; display: flex; justify-content: center; padding-left: 6px">Add Row</span> </div> @@ -447,7 +449,7 @@ align-items: center;" [innerHTML]="'download' | feather:20"></span> </div> - <input type="file" id="file" accept=".csv" (change)="handleFileInput($event.target.files)"> + <input type="file" id="file" #csvInput [disabled]="store.viewOnly" accept=".csv" (change)="handleFileInput($event.target.files)"> </div> </div> </div> diff --git a/public/src/app/rule-engine/action/action.component.ts b/public/src/app/rule-engine/action/action.component.ts index dfdb83f..380ff43 100644 --- a/public/src/app/rule-engine/action/action.component.ts +++ b/public/src/app/rule-engine/action/action.component.ts @@ -4,7 +4,8 @@ import { Input, OnInit, ViewChild, - AfterViewInit + AfterViewInit, + ElementRef } from '@angular/core'; // import { Copy } from "../model"; import { Http, Response, Headers, RequestOptions } from '@angular/http'; @@ -17,6 +18,7 @@ import * as Papa from 'papaparse'; import { metricData } from './metric.data'; import { Store } from '../../store/store'; import { ToastrService } from 'ngx-toastr'; +import { toJS } from 'mobx'; @Component({ selector: 'app-action', @@ -28,6 +30,7 @@ export class ActionComponent implements OnInit, AfterViewInit { @ViewChild('from') fromInstance; @ViewChild('target') targetInstance; @ViewChild('actionFrm') actionFrm: NgForm; + @ViewChild('csvInput') fileInput: ElementRef; highlight = 'black'; hoveredIndex; fileToUpload: File = null; @@ -42,12 +45,12 @@ export class ActionComponent implements OnInit, AfterViewInit { ngAfterViewInit(): void { console.log(this.action.id); if (this.action.from !== undefined && this.action.from !== '') { - console.log('Action %o', this.action); this.fromInstance.updateMode(this.action.from); } if (this.action.target !== undefined && this.action.target !== '') { this.targetInstance.updateMode(this.action); } + console.log('Action %o', this.action); } updateFrom(data) { @@ -93,34 +96,40 @@ export class ActionComponent implements OnInit, AfterViewInit { this.action.search.updates.splice(index, 1); } - handleFileInput(files: FileList) { - this.fileToUpload = files.item(0); - console.log('file to load:', this.fileToUpload); - this.fileName = this.fileToUpload !== null ? this.fileToUpload.name : ''; + clearFile() { + this.fileInput.nativeElement.value = ''; + this.fileName = ''; + } - this.store.loader = true; - Papa.parse(this.fileToUpload, { - complete: result => { - if (result.data) { - const mapConvert = result.data - .slice(0, 300) - .filter(item => item[0] !== undefined && item[1] !== undefined) - .map(item => { - console.log(`item 0: ${item[0]} item 1: ${item[1]}`); - return { - key: item[0].trim(), - value: item[1].trim() - }; - }); + handleFileInput(files: FileList) { + if (files && files.length > 0) { + this.fileToUpload = files.item(0); + console.log('file to load:', this.fileToUpload); + this.fileName = this.fileToUpload !== null ? this.fileToUpload.name : ''; + this.store.loader = true; + Papa.parse(this.fileToUpload, { + complete: result => { + if (result.data) { + const mapConvert = result.data + .slice(0, 300) + .filter(item => item[0] !== undefined && item[1] !== undefined) + .map(item => { + console.log(`item 0: ${item[0]} item 1: ${item[1]}`); + return { + key: item[0].trim(), + value: item[1].trim() + }; + }); + this.store.loader = false; + this.action.map.values = mapConvert; + } + }, + error: (err, file) => { this.store.loader = false; - this.action.map.values = mapConvert; + console.log(`error: ${err}, in file ${file}`); + this.toastr.error('', err); } - }, - error: (err, file) => { - this.store.loader = false; - console.log(`error: ${err}, in file ${file}`); - this.toastr.error('', err); - } - }); + }); + } } } 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 f19fd15..ed0d25c 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 @@ -25,7 +25,8 @@ export class RuleEngineApiService { flowType: string; editorData: Subject<any> = new Subject(); updateVersionLock: Subject<any> = new Subject(); - tabIndex: Subject<any> = new BehaviorSubject(-1); + currentTab: Subject<any> = new BehaviorSubject(-1); + tabIndex = this.currentTab.asObservable(); constructor(private http: Http) { this.baseUrl = `${environment.apiBaseUrl}/rule-editor`; @@ -171,9 +172,9 @@ export class RuleEngineApiService { }); } - deleteFilter() { + deleteFilter(vfcmtUuid) { const deleteFilter = { - vfcmtUuid: this.vfcmtUuid, + vfcmtUuid: vfcmtUuid, dcaeCompLabel: this.dcaeCompName, nid: this.nid, configParam: this.configParam @@ -271,6 +272,6 @@ export class RuleEngineApiService { } callUpdateTabIndex(index) { - this.tabIndex.next(index); + this.currentTab.next(index); } } diff --git a/public/src/app/rule-engine/condition/condition.component.html b/public/src/app/rule-engine/condition/condition.component.html index 3a26823..e4a8775 100644 --- a/public/src/app/rule-engine/condition/condition.component.html +++ b/public/src/app/rule-engine/condition/condition.component.html @@ -59,8 +59,13 @@ <div *ngIf="!isFilter" style="display: flex; margin-left: auto;"> <div style="display: flex; align-items: center; padding: 0 25px;"> - <button mat-mini-fab color="primary" data-tests-id="addCondition" (click)="addConditional(tree, node)" style="height: 24px; width: 24px; display:flex; box-shadow: none;" [disabled]="store.viewOnly"> - <mat-icon class="material-icons md-18">add</mat-icon> + <button mat-mini-fab color="primary" data-tests-id="addCondition" (click)="addConditional(tree, node)" style="height: 16px; width: 16px; display:flex; box-shadow: none;align-items: center;justify-content: center;" [disabled]="store.viewOnly"> + <span style="width: 100%; + color:white; + height: 100%; + display: flex; + justify-content: center; + align-items: center;" [innerHTML]="'plus' | feather:12"></span> </button> <span class="btn-label">Add Condition </span> @@ -68,8 +73,13 @@ <div style="display: flex; align-items: center; padding: 0 25px;"> <button mat-mini-fab color="primary" data-tests-id="addConditionGroup" [disabled]="node.data.level === 2 || store.viewOnly" (click)="addConditionalGroup(tree, node)" - style="height: 24px; width: 24px; display:flex; box-shadow: none;"> - <mat-icon class="material-icons md-18">add</mat-icon> + style="height: 16px; width: 16px; display:flex; box-shadow: none;align-items: center;justify-content: center;"> + <span style="width: 100%; + color:white; + height: 100%; + display: flex; + justify-content: center; + align-items: center;" [innerHTML]="'plus' | feather:12"></span> </button> <span [style.color]="node.data.level === 2 ? '#a7a7a7' : '#009fdb' " [style.cursor]="node.data.level === 2 ? 'default' : 'pointer' " class="btn-label">Add Condition Group diff --git a/public/src/app/rule-engine/from/from.component.html b/public/src/app/rule-engine/from/from.component.html index 0da7173..835946a 100644 --- a/public/src/app/rule-engine/from/from.component.html +++ b/public/src/app/rule-engine/from/from.component.html @@ -52,7 +52,8 @@ <button mat-icon-button class="button-remove" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" (click)="removeFromInput(index)" *ngIf="from.values.length > 1" style="box-shadow: none; height: 24px; width: 24px; display:flex" data-tests-id="btnDelete"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> @@ -81,7 +82,8 @@ <button mat-icon-button class="button-remove" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" (click)="removeFromInput(index)" *ngIf="from.values.length > 1" style="box-shadow: none; height: 24px; width: 24px; display:flex" data-tests-id="btnDelete"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> @@ -112,7 +114,8 @@ <button mat-icon-button class="button-remove" [ngStyle]="hoveredIndex === index ? {'opacity':'1'} : {'opacity':'0'}" (click)="removeFromInput(index)" *ngIf="from.values.length > 2" style="box-shadow: none; height: 24px; width: 24px; display:flex" data-tests-id="btnDelete"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> @@ -122,7 +125,6 @@ <button mat-mini-fab color="primary" (click)="addFromInput()" style="box-shadow: none; height: 16px; width: 16px; display:flex" data-tests-id="btnAddInput"> <span style="padding-left: 2px; display: flex; justify-content: center; align-items: center" [innerHTML]="'plus' | feather:12"></span> - <!-- <mat-icon>add</mat-icon> --> </button> <span style="color: #009FDB; display: flex; justify-content: center; padding-top: 1px; padding-left: 6px;">Add input</span> </div> diff --git a/public/src/app/rule-engine/rule-list/rule-list.component.html b/public/src/app/rule-engine/rule-list/rule-list.component.html index 5085563..b0d3d9b 100644 --- a/public/src/app/rule-engine/rule-list/rule-list.component.html +++ b/public/src/app/rule-engine/rule-list/rule-list.component.html @@ -26,7 +26,7 @@ <div class="field-label required" style="padding-right: 10px;"> Entry Phase </div> - <input name="entryPhase" [readonly]="store.viewOnly" required [(ngModel)]="entryPhase" class="field-text" style="width:250px;" + <input name="entryPhase" [readonly]="store.viewOnly" [(ngModel)]="entryPhase" class="field-text" style="width:250px;" data-tests-id="entryPhase" /> </div> @@ -53,7 +53,7 @@ </div> </div> <div *ngIf="ifStatement"> - <button mat-raised-button (click)="applyFilter()" color="primary" style="width: 113px;height: 36px;" + <button mat-raised-button (click)="applyFilter()" color="primary" style="width: 113px;height: 36px;" [disabled]="store.viewOnly" data-tests-id="applyFilter"> Apply Filter </button> @@ -66,7 +66,7 @@ </div> </div> - <div *ngIf="targetSource && (tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp'))"> + <div *ngIf="targetSource && versionType.selectedEvent && (tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp'))"> <div style="display: flex; align-items: baseline; width: 170px; height:35px; position:relative;" (mouseenter)="showBtnList = true" (mouseleave)="showBtnList = false" data-tests-id="addGroup"> <div style="display: flex; align-items: center;"> @@ -111,8 +111,7 @@ </div> <input type="text" name="phase" [(ngModel)]="item.phase" class="field-text" data-tests-id="phase" /> - <button mat-icon-button (click)="deleteGroup(item.groupId)" [disabled]="disableDeleteGroup(item.groupId)" [disabled]="store.viewOnly" - class="gray" data-tests-id="deleteGroup"> + <button mat-icon-button (click)="deleteGroup(item.groupId)" [disabled]="disableDeleteGroup(item.groupId) || store.viewOnly" class="gray" data-tests-id="deleteGroup"> <span style="width: 100%; height: 100%; display: flex; @@ -144,7 +143,8 @@ </button> <button (click)="removeItem(rule.uid, item.groupId)" data-tests-id="deleteRule" class="btn-list" mat-icon-button [disabled]="disableDeleteGroup(item.groupId) && item.list.length === 1 || store.viewOnly"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> </div> @@ -176,7 +176,7 @@ align-items: center;" [innerHTML]="'download' | feather:18"></span> </button> - <input type="file" id="file" accept=".json" (change)="handleImportCDAP($event.target.files, item.groupId, item.phase)"> + <input type="file" id="file" accept=".json" [disabled]="store.viewOnly" #groupUpload (change)="handleImportCDAP($event.target.files, item.groupId, item.phase)"> <span style="color: #009FDB; display: flex; justify-content: center; ">Import phase</span> </div> </div> @@ -188,7 +188,7 @@ <div *ngIf="targetSource && !(tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp'))"> - <div *ngIf="targetSource && store.ruleList.length === 0 && !(tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp'))" + <div *ngIf="targetSource && store.ruleList.length === 0 && versionType.selectedEvent && !(tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp'))" style="margin: 30px 0; display: flex; align-items: center; justify-content: center; flex-direction: column;"> <div style="margin: 3em 0 2em 0;"> @@ -244,7 +244,8 @@ [innerHTML]="'copy' | feather:20"></span> </button> <button (click)="removeItem(item.uid, null)" data-tests-id="deleteRule" class="btn-list" mat-icon-button *ngIf="!store.viewOnly"> - <mat-icon class="md-24">delete</mat-icon> + <span style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;" + [innerHTML]="'trash-2' | feather:20"></span> </button> </div> </div> diff --git a/public/src/app/rule-engine/rule-list/rule-list.component.ts b/public/src/app/rule-engine/rule-list/rule-list.component.ts index 6e3c877..1bbed87 100644 --- a/public/src/app/rule-engine/rule-list/rule-list.component.ts +++ b/public/src/app/rule-engine/rule-list/rule-list.component.ts @@ -1,4 +1,9 @@ -import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; +import { + Component, + ViewChild, + ViewEncapsulation, + ElementRef +} from '@angular/core'; import { MatDialog } from '@angular/material'; import { isEmpty } from 'lodash'; import { ToastrService } from 'ngx-toastr'; @@ -21,6 +26,7 @@ const primaryColor = '#009fdb'; }) export class RuleListComponent { @ViewChild('versionEventType') versionType; + @ViewChild('groupUpload') fileInput: ElementRef; error: Array<string>; // list = new Array(); schema; @@ -43,6 +49,7 @@ export class RuleListComponent { // filter ifStatement = false; condition: any; + filterSave = false; private errorHandler(error: any) { this.store.loader = false; @@ -82,14 +89,18 @@ export class RuleListComponent { filterCheckbox() { this.ifStatement = !this.ifStatement; - if (!this.ifStatement && this.condition !== undefined) { - this.deleteFilter(); + if (!this.ifStatement) { + if (this.filterSave) { + this.deleteFilter(); + } else { + this.condition = null; + } } } removeConditionCheck(flag) { this.ifStatement = flag; - if (this.condition !== undefined) { + if (this.filterSave) { this.deleteFilter(); } } @@ -107,10 +118,14 @@ export class RuleListComponent { .subscribe( res => { this.store.mcUuid = res.uuid; - this._ruleApi.deleteFilter().subscribe( + this._ruleApi.deleteFilter(res.uuid).subscribe( response => { - console.log('success import', response); + if (this.store.ruleList.length === 0) { + this.versionType.updateVersionTypeFlag(false); + } this.condition = null; + this.filterSave = false; + this.ifStatement = false; this.store.loader = false; }, error => { @@ -174,63 +189,76 @@ export class RuleListComponent { } } + clearFile() { + this.fileInput.nativeElement.value = ''; + this.fileName = ''; + } + handleImportCDAP(files: FileList, groupId, phaseName) { this.error = null; - this.store.loader = true; - this.fileToUpload = files.item(0); - console.log('file to load:', this.fileToUpload); - this.fileName = this.fileToUpload !== null ? this.fileToUpload.name : ''; const reader = new FileReader(); - reader.readAsText(this.fileToUpload, 'UTF-8'); - reader.onload = () => { - console.log(reader.result); - this._ruleApi - .getLatestMcUuid({ - contextType: this.store.sdcParmas.contextType, - serviceUuid: this.store.sdcParmas.uuid, - vfiName: this.store.vfiName, - vfcmtUuid: this.store.mcUuid - }) - .subscribe( - res => { - this.store.mcUuid = res.uuid; - let data = ''; - try { - data = JSON.parse(reader.result as any); - const input = { - version: this.versionType.selectedVersion, - eventType: this.versionType.selectedEvent, - groupId: groupId, - phase: phaseName, - payload: data - }; - this._ruleApi.importPhase(input).subscribe( - response => { - console.log('success import', response); - this.store.loader = false; - this.store.updateRuleList(Object.values(response.rules)); - }, - error => { - this.notifyError(error); - } - ); - } catch (e) { - console.log(e); - this.errorHandler({ - policyException: { - messageId: 'Invalid JSON', - text: 'Invalid JSON', - variables: [], - formattedErrorMessage: 'Invalid JSON' - } - }); + if (files && files.length > 0) { + this.store.loader = true; + this.fileToUpload = files.item(0); + console.log('file to load:', this.fileToUpload); + this.fileName = this.fileToUpload !== null ? this.fileToUpload.name : ''; + reader.readAsText(this.fileToUpload, 'UTF-8'); + reader.onload = () => { + console.log(reader.result); + this._ruleApi + .getLatestMcUuid({ + contextType: this.store.sdcParmas.contextType, + serviceUuid: this.store.sdcParmas.uuid, + vfiName: this.store.vfiName, + vfcmtUuid: this.store.mcUuid + }) + .subscribe( + res => { + this.store.mcUuid = res.uuid; + let data = ''; + try { + data = JSON.parse(reader.result as any); + const input = { + version: this.versionType.selectedVersion, + eventType: this.versionType.selectedEvent, + groupId: groupId, + phase: phaseName, + payload: data + }; + this._ruleApi.importPhase(input).subscribe( + response => { + console.log('success import', response); + this.clearFile(); + this.store.loader = false; + this.store.updateRuleList(Object.values(response.rules)); + }, + error => { + this.clearFile(); + this.notifyError(error); + } + ); + } catch (e) { + console.log(e); + this.clearFile(); + this.errorHandler({ + policyException: { + messageId: 'Invalid JSON', + text: 'Invalid JSON', + variables: [], + formattedErrorMessage: 'Invalid JSON' + } + }); + } + }, + error => { + this.clearFile(); + this.errorHandler(error); } - }, - error => { - this.errorHandler(error); - } - ); - }; + ); + }; + } else { + this.clearFile(); + } } addGroup(type) { @@ -306,10 +334,12 @@ export class RuleListComponent { this.entryPhase = response.entryPhase; this.publishPhase = response.publishPhase; this.condition = response.filter; + this.filterSave = response.filter !== undefined ? true : false; this.ifStatement = this.condition == null ? false : true; } else { this.store.resetRuleList(); this.condition = null; + this.filterSave = false; this.ifStatement = false; this.versionType.updateVersionTypeFlag(false); this.targetSource = null; @@ -412,6 +442,7 @@ export class RuleListComponent { .subscribe( res => { this.store.mcUuid = res.uuid; + this.filterSave = true; let conditionData2server = null; conditionData2server = this.convertConditionToServer(this.condition); const newFilter = { @@ -423,6 +454,9 @@ export class RuleListComponent { }; this._ruleApi.applyFilter(newFilter).subscribe( success => { + if (this.store.ruleList.length === 0) { + this.versionType.updateVersionTypeFlag(true); + } this.store.loader = false; }, error => { @@ -549,7 +583,9 @@ export class RuleListComponent { console.log(data); this.versions = data.map(x => x.version); this.metaData = data; - this.versionType.updateVersionTypeFlag(false); + if (this.filterSave === false) { + this.versionType.updateVersionTypeFlag(false); + } this.targetSource = null; }); } @@ -597,7 +633,9 @@ export class RuleListComponent { this.store.isLeftVisible = false; this._ruleApi.updateVersionLock.subscribe(() => { - this.versionType.updateVersionTypeFlag(true); + if (this.filterSave === true) { + this.versionType.updateVersionTypeFlag(true); + } }); } } diff --git a/public/src/app/rule-engine/version-type-select/version-type-select.component.html b/public/src/app/rule-engine/version-type-select/version-type-select.component.html index fd3cfab..1539c49 100644 --- a/public/src/app/rule-engine/version-type-select/version-type-select.component.html +++ b/public/src/app/rule-engine/version-type-select/version-type-select.component.html @@ -10,10 +10,10 @@ style="height: 35px; padding: 0.3rem; border: 1px solid #d2d2d2; width:250px;" class="field-select"> <option [ngValue]="null" disabled>Select Mapping</option> <optgroup label="Rules Configured"> - <option *ngFor="let target of advancedSetting" [hidden]="!target.isExist" [value]="target.name" data-tests-id="templateOptionsExist">{{target.name}}</option> + <option *ngFor="let target of store.advancedSetting" [hidden]="!target.isExist" [value]="target.name" data-tests-id="templateOptionsExist">{{target.name}}</option> </optgroup> <optgroup label="No Mapping Configuration"> - <option *ngFor="let target of advancedSetting" [hidden]="target.isExist" [value]="target.name" data-tests-id="templateOptionsNotExist">{{target.name}}</option> + <option *ngFor="let target of store.advancedSetting" [hidden]="target.isExist" [value]="target.name" data-tests-id="templateOptionsNotExist">{{target.name}}</option> </optgroup> </select> </div> @@ -45,23 +45,6 @@ | slice:0:selectedEvent.length-6}}</span> </div> - <!-- <div class="notifyId" style="display: flex; flex-direction:column; margin-right:10px;"> - <div class="pretty p-svg space-down"> - <input type="checkbox" name="notifyIdCheckbox" data-tests-id="notifyIdCheckbox" [checked]="notifyIdCheckbox" (change)="changeNotifyId()" - /> - <div class="state"> - <svg class="svg svg-icon" viewBox="0 0 20 20"> - <path d="M7.629,14.566c0.125,0.125,0.291,0.188,0.456,0.188c0.164,0,0.329-0.062,0.456-0.188l8.219-8.221c0.252-0.252,0.252-0.659,0-0.911c-0.252-0.252-0.659-0.252-0.911,0l-7.764,7.763L4.152,9.267c-0.252-0.251-0.66-0.251-0.911,0c-0.252,0.252-0.252,0.66,0,0.911L7.629,14.566z" - style="stroke: #009fdb; fill:#009fdb;"></path> - </svg> - <label style="margin-left: 5px;">Notify OID</label> - </div> - </div> - <div *ngIf="notifyIdCheckbox" class="input-wrapper"> - <input type="text" ngModel required name="defaultInput" data-tests-id="defaultInput" [(ngModel)]="store.notifyIdValue" class="input"> - </div> - </div> --> - </div> </div> diff --git a/public/src/app/rule-engine/version-type-select/version-type-select.component.ts b/public/src/app/rule-engine/version-type-select/version-type-select.component.ts index 6869260..791919c 100644 --- a/public/src/app/rule-engine/version-type-select/version-type-select.component.ts +++ b/public/src/app/rule-engine/version-type-select/version-type-select.component.ts @@ -19,7 +19,6 @@ export class VersionTypeSelectComponent { @Input() metaData; @Output() nodesUpdated = new EventEmitter(); @Output() refrashRuleList = new EventEmitter(); - advancedSetting: Array<any>; notifyIdCheckbox = false; constructor(private _ruleApi: RuleEngineApiService, public store: Store) { @@ -36,7 +35,7 @@ export class VersionTypeSelectComponent { tabName.toLowerCase().includes('highlandpark') || tabName.toLowerCase().includes('hp') ) { - this.advancedSetting = this.store.tabsProperties[index].filter( + this.store.advancedSetting = this.store.tabsProperties[index].filter( item => { if ( !( @@ -49,7 +48,7 @@ export class VersionTypeSelectComponent { } } ); - this.mappingTarget = this.advancedSetting[0].name; + this.mappingTarget = this.store.advancedSetting[0].name; this._ruleApi .generateMappingRulesFileName( @@ -59,7 +58,7 @@ export class VersionTypeSelectComponent { ) .subscribe(response => { console.log('generateMappingRulesFileName response: ', response); - this.advancedSetting.forEach(element => { + this.store.advancedSetting.forEach(element => { if (response.includes(element.name)) { element.isExist = true; } else { |