Hide feature flags in server config for non technicians #334

This commit is contained in:
Sven Heidemann 2023-08-16 00:02:04 +02:00
parent f7f3fea7a7
commit 1cd75cd78f
6 changed files with 16 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "kdb-web",
"version": "1.1.dev79_hide_table_columns",
"version": "1.1.dev334_feature_flags_in_wi",
"scripts": {
"ng": "ng",
"update-version": "ts-node-esm update-version.ts",

View File

@ -26,7 +26,12 @@ export class ComponentWithTable {
this.columns = columns.map(column => {
return { key: this.getKey(column), name: column };
});
this._hiddenColumns = JSON.parse(localStorage.getItem("hiddenColumns") ?? "");
let hiddenColumns = localStorage.getItem("hiddenColumns");
if (!hiddenColumns) {
localStorage.setItem("hiddenColumns", JSON.stringify([{}]));
hiddenColumns = localStorage.getItem("hiddenColumns") ?? JSON.stringify([{}]);
}
this._hiddenColumns = JSON.parse(hiddenColumns);
}
private getKey(column: string): string {

View File

@ -2,9 +2,10 @@
<p-multiSelect display="chip" [options]="columns" [(ngModel)]="hiddenColumns" optionLabel="name" placeholder="{{'common.hidden_columns' | translate}}" [filter]=false>
<ng-template let-value pTemplate="selectedItems">
<div *ngFor="let item of hiddenColumns; let i = index;">
<div>
<div *ngIf="item.name">
{{'common.' + item.name | translate}}<span *ngIf="i < columns.length-1">,</span>
</div>
<div *ngIf="!item.name">{{'common.hidden_columns' | translate}}</div>
</div>
<div *ngIf="!hiddenColumns || hiddenColumns.length === 0">{{'common.hidden_columns' | translate}}</div>
</ng-template>

View File

@ -113,7 +113,7 @@
<app-config-list translationKey="view.server.config.bot.afk_channels" [(data)]="config.afkChannelIds"></app-config-list>
<app-config-list translationKey="view.server.config.bot.moderator_roles" [(data)]="config.moderatorRoleIds"></app-config-list>
<app-config-list translationKey="view.server.config.bot.admin_roles" [(data)]="config.adminRoleIds"></app-config-list>
<app-feature-flag-list [(data)]="config.featureFlags"></app-feature-flag-list>
<app-feature-flag-list *ngIf="isTechnician" [(data)]="config.featureFlags"></app-feature-flag-list>
<div class="content-row">
<button pButton icon="pi pi-save" label="{{'common.save' | translate}}" class="btn login-form-submit-btn"

View File

@ -16,6 +16,7 @@ import { AuthService } from "../../../../../../services/auth/auth.service";
import { ServerConfig } from "../../../../../../models/config/server-config.model";
import { Server } from "../../../../../../models/data/server.model";
import { ActivatedRoute } from "@angular/router";
import { UserDTO } from "../../../../../../models/auth/auth-user.dto";
type AFKChannelId = {
id: number;
@ -41,6 +42,7 @@ export class ConfigComponent implements OnInit {
clonedAfkChannelIds: { [s: number]: AFKChannelId } = {};
private server: Server = {};
isTechnician: boolean = false;
constructor(
private data: DataService,
@ -62,6 +64,9 @@ export class ConfigComponent implements OnInit {
this.data.getServerFromRoute(this.route).then(async server => {
this.server = server;
this.loadConfig();
let authUser = await this.authService.getLoggedInUser();
let isUserTechnicianList = authUser?.users?.map(u => u.isTechnician).filter(u => u) ?? [];
this.isTechnician = isUserTechnicianList.length > 0;
});
}

View File

@ -2,6 +2,6 @@
"WebVersion": {
"Major": "1",
"Minor": "1",
"Micro": "dev79_hide_table_columns"
"Micro": "dev334_feature_flags_in_wi"
}
}