diff options
author | 2018-10-29 19:33:00 +0200 | |
---|---|---|
committer | 2018-10-29 19:33:00 +0200 | |
commit | 2dbff5ec1853f5f48354e0bbdecfae2d7489fbbb (patch) | |
tree | 932b4549f366400753354b7e5937f7ecae40511f /public/src/app/rule-engine/rule-list | |
parent | e0cf0c1c4a425816704a1e5b325fe7c8b9d2759a (diff) |
Sync code3.0.0-ONAP1.3.0casablanca
Sync the code between repositories
Change-Id: Ib7ee4d0e0f53b58a9bf97dadb15e094789b4f915
Issue-ID: SDC-1874
Signed-off-by: Eran (ev672n), Vosk <ev672n@att.com>
Diffstat (limited to 'public/src/app/rule-engine/rule-list')
-rw-r--r-- | public/src/app/rule-engine/rule-list/rule-list.component.html | 19 | ||||
-rw-r--r-- | public/src/app/rule-engine/rule-list/rule-list.component.ts | 160 |
2 files changed, 109 insertions, 70 deletions
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); + } }); } } |