Scenarios edit from admin
This commit is contained in:
2
dist/qmi-cloud/index.html
vendored
2
dist/qmi-cloud/index.html
vendored
@@ -9,5 +9,5 @@
|
||||
<link rel="stylesheet" href="styles.529f751cbb5308365172.css"></head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.53542aa41b8c5dbc12b3.js" defer></script></body>
|
||||
<script src="runtime.689ba4fd6cadb82c1ac2.js" defer></script><script src="polyfills-es5.f752a17531a45fe93c1f.js" nomodule defer></script><script src="polyfills.06ba8d1a3d9dd3a8e8b9.js" defer></script><script src="scripts.6866cf66954a0b739d41.js" defer></script><script src="main.b7d3a2d901b927013a9e.js" defer></script></body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ProvisionsService } from '../services/provisions.service';
|
||||
import { Subscription, timer } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { ScenariosService } from '../services/scenarios.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Title</th>
|
||||
<th style="width: 500px;">Description</th>
|
||||
<th style="width: 400px;">Description</th>
|
||||
<th style="width: 400px;">AvailableProductVersions</th>
|
||||
<th>IsAdminOnly</th>
|
||||
<th>IsExternal</th>
|
||||
<th>IsWafPolicyAppGw</th>
|
||||
@@ -22,6 +23,7 @@
|
||||
scope="row">{{item.name}}</th>
|
||||
<td contenteditable="true" (keyup)="changeValue(item._id, 'title', $event)" (blur)="updateList(item, 'title', $event)" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{item.title}}</td>
|
||||
<td contenteditable="true" (keyup)="changeValue(item._id, 'description', $event)" (blur)="updateList(item, 'description', $event)" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex">{{item.description}}</td>
|
||||
<td contenteditable="true" (keyup)="changeValue(item._id, 'availableProductVersions', $event)" (blur)="updateJson(item, 'availableProductVersions', $event)" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><pre>{{item.availableProductVersions | json}}</pre></td>
|
||||
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isAdminOnly" [default]="false" (change)="FieldsChange(item, 'isAdminOnly', $event)"></mdb-checkbox></td>
|
||||
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isExternal" [default]="false" (change)="FieldsChange(item, 'isExternal', $event)"></mdb-checkbox></td>
|
||||
<td style="text-align: center;" *ngIf="i+1 >= mdbTablePagination.firstItemIndex && i < mdbTablePagination.lastItemIndex"><mdb-checkbox [checked]="item.isWafPolicyAppGw" [default]="false" (change)="FieldsChange(item, 'isWafPolicyAppGw', $event)"></mdb-checkbox></td>
|
||||
@@ -31,7 +33,7 @@
|
||||
</tbody>
|
||||
<tfoot class="grey lighten-5 w-100">
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<td colspan="8">
|
||||
<mdb-table-pagination [tableEl]="tableEl" [searchDataSource]="elements"></mdb-table-pagination>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
.table td, .table th {
|
||||
vertical-align: middle;
|
||||
max-height: 100px;
|
||||
}
|
||||
|
||||
pre {
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
max-width: 400px;
|
||||
max-height: 100px;
|
||||
}
|
||||
@@ -36,8 +36,7 @@ export class TableScenariosComponent implements OnInit, AfterViewInit {
|
||||
this.previous = this.mdbTable.getDataSource();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
private _refresh() {
|
||||
var scenariosSub = this._scenariosService.getScenariosAll().subscribe( res => {
|
||||
scenariosSub.unsubscribe();
|
||||
this.scenarios = res.results;
|
||||
@@ -45,8 +44,10 @@ export class TableScenariosComponent implements OnInit, AfterViewInit {
|
||||
this._initElements();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@@ -84,23 +85,53 @@ export class TableScenariosComponent implements OnInit, AfterViewInit {
|
||||
//console.log("changeValue editField", id, this.editField);
|
||||
}
|
||||
|
||||
|
||||
updateList(scenario: any, property: string, event: any) {
|
||||
this.editField = event.target.textContent;
|
||||
console.log("editField", scenario, this.editField);
|
||||
let patch = {};
|
||||
patch[property] = this.editField;
|
||||
patch[property] = this.editField.trim();
|
||||
|
||||
if (!patch[property] || patch[property] === "" || patch[property] === scenario[property] ) {
|
||||
return;
|
||||
}
|
||||
this._scenariosService.updateScenario(scenario._id.toString(), patch).subscribe( res=> {
|
||||
console.log("done", res);
|
||||
})
|
||||
this._refresh();
|
||||
});
|
||||
}
|
||||
|
||||
updateJson(scenario: any, property: string, event: any) {
|
||||
this.editField = event.target.textContent.trim();
|
||||
|
||||
try {
|
||||
var patch = {};
|
||||
var value = JSON.parse(this.editField);
|
||||
|
||||
if ( JSON.stringify(value) === JSON.stringify(scenario[property]) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
patch[property] = value;
|
||||
console.log("editField", patch);
|
||||
|
||||
this._scenariosService.updateScenario(scenario._id.toString(), patch).subscribe( res=> {
|
||||
console.log("done", res);
|
||||
this._refresh();
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("error json", e);
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FieldsChange(scenario: any,property: string, value:any){
|
||||
console.log(value.checked);
|
||||
let patch = {};
|
||||
patch[property] = value.checked;
|
||||
this._scenariosService.updateScenario(scenario._id.toString(), patch).subscribe( res=> {
|
||||
console.log("done", res);
|
||||
})
|
||||
this._refresh();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user