<tbody>
<tr *ngFor="let propertyEntry of propertyItem.data" >
<td>{{propertyEntry.key}}</td>
- <td>{{propertyEntry.value}}</td>
+ <td *ngIf="isEdit(propertyEntry.key)"><input class="form-control" type="text" [(ngModel)]="propertyValue"></td>
+ <td *ngIf="!isEdit(propertyEntry.key)">{{propertyEntry.value}}</td>
<td>
- <a [routerLink]="['..','edit', propertyEntry.key]"
+ <a [routerLink]="" (click)="toggleEditProperty(propertyEntry)"
[attr.title]="'security.config.properties.edit' |translate"><span class="fas fa-edit"></span></a>
- <a class="ml-2" [routerLink]="['..','delete', propertyEntry.key]"
- [attr.title]="'security.config.properties.delete' |translate"><span class="fas fa-trash-alt"></span></a>
</td>
</tr>
</tbody>
import {Observable} from "rxjs";
import {PagedResult} from "@app/model/paged-result";
import {SecurityService} from "@app/services/security.service";
+import {ToastService} from "@app/services/toast.service";
+import {ErrorResult} from "@app/model/error-result";
@Component({
selector: 'app-security-properties',
})
export class SecurityPropertiesComponent extends SortedTableComponent<PropertyEntry> implements OnInit {
- constructor(translator: TranslateService, securityService: SecurityService) {
+ editProperty:string='';
+ propertyValue:string='';
+
+ constructor(translator: TranslateService, private securityService: SecurityService, private toastService: ToastService) {
super(translator, function (searchTerm: string, offset: number, limit: number, orderBy: string[], order: string): Observable<PagedResult<PropertyEntry>> {
// console.log("Retrieving data " + searchTerm + "," + offset + "," + limit + "," + orderBy + "," + order);
return securityService.queryProperties(searchTerm, offset, limit, orderBy, order);
ngOnInit(): void {
}
+ isEdit(key:string) : boolean {
+ return this.editProperty == key;
+ }
+
+ updateProperty(key:string, value:string) {
+ console.log("Updating "+key+"="+value)
+ this.securityService.updateProperty(key, value).subscribe(
+ ()=>{
+ this.toastService.showSuccessByKey('security-properties', 'security.config.properties.edit_success')
+ },
+ (error: ErrorResult) => {
+ this.toastService.showErrorByKey('security-properties', 'security.config.properties.edit_failure', {error:error.firstMessageString()})
+ }
+ );
+ }
+
+ toggleEditProperty(propertyEntry:PropertyEntry) : void {
+ if (this.editProperty==propertyEntry.key) {
+ propertyEntry.value=this.propertyValue
+ this.editProperty='';
+ this.updateProperty(propertyEntry.key, this.propertyValue);
+ this.propertyValue = '';
+ } else {
+ this.editProperty = propertyEntry.key;
+ this.propertyValue = propertyEntry.value;
+ }
+ }
}