diff options
author | Eran (ev672n), Vosk <ev672n@att.com> | 2018-10-29 19:33:00 +0200 |
---|---|---|
committer | Eran (ev672n), Vosk <ev672n@att.com> | 2018-10-29 19:33:00 +0200 |
commit | 2dbff5ec1853f5f48354e0bbdecfae2d7489fbbb (patch) | |
tree | 932b4549f366400753354b7e5937f7ecae40511f /public/src/app/rule-engine/action | |
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/action')
-rw-r--r-- | public/src/app/rule-engine/action/action.component.html | 16 | ||||
-rw-r--r-- | public/src/app/rule-engine/action/action.component.ts | 65 |
2 files changed, 46 insertions, 35 deletions
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); - } - }); + }); + } } } |