2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import {Component, OnInit} from '@angular/core';
20 import {SortedTableComponent} from "@app/modules/shared/sorted-table-component";
21 import {PropertyEntry} from '@app/model/property-entry';
22 import {TranslateService} from "@ngx-translate/core";
23 import {Observable} from "rxjs";
24 import {PagedResult} from "@app/model/paged-result";
25 import {SecurityService} from "@app/services/security.service";
26 import {ToastService} from "@app/services/toast.service";
27 import {ErrorResult} from "@app/model/error-result";
30 selector: 'app-security-properties',
31 templateUrl: './security-properties.component.html',
32 styleUrls: ['./security-properties.component.scss']
34 export class SecurityPropertiesComponent extends SortedTableComponent<PropertyEntry> implements OnInit {
36 editProperty:string='';
37 propertyValue:string='';
39 constructor(translator: TranslateService, private securityService: SecurityService, private toastService: ToastService) {
40 super(translator, function (searchTerm: string, offset: number, limit: number, orderBy: string[], order: string): Observable<PagedResult<PropertyEntry>> {
41 // console.log("Retrieving data " + searchTerm + "," + offset + "," + limit + "," + orderBy + "," + order);
42 return securityService.queryProperties(searchTerm, offset, limit, orderBy, order);
44 super.sortField=['key']
50 isEdit(key:string) : boolean {
51 return this.editProperty == key;
54 updateProperty(key:string, value:string) {
55 console.log("Updating "+key+"="+value)
56 this.securityService.updateProperty(key, value).subscribe(
58 this.toastService.showSuccessByKey('security-properties', 'security.config.properties.edit_success')
60 (error: ErrorResult) => {
61 this.toastService.showErrorByKey('security-properties', 'security.config.properties.edit_failure', {error:error.firstMessageString()})
66 toggleEditProperty(propertyEntry:PropertyEntry) : void {
67 if (this.editProperty==propertyEntry.key) {
68 propertyEntry.value=this.propertyValue
70 this.updateProperty(propertyEntry.key, this.propertyValue);
71 this.propertyValue = '';
73 this.editProperty = propertyEntry.key;
74 this.propertyValue = propertyEntry.value;