Skip to content

Commit f649cbd

Browse files
committed
feat(admin): instance config
1 parent 0abadb3 commit f649cbd

19 files changed

+317
-10
lines changed

src/api/backend/api/default.service.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { AchievementGrantRequest } from '../model/achievementGrantRequest';
2222
import { AchievementGrantResponse } from '../model/achievementGrantResponse';
2323
import { AchievementResponse } from '../model/achievementResponse';
2424
import { AchievementsResponse } from '../model/achievementsResponse';
25+
import { AdminInstanceConfig } from '../model/adminInstanceConfig';
26+
import { AdminInstanceConfigResponse } from '../model/adminInstanceConfigResponse';
2527
import { AdminTaskCreationRequest } from '../model/adminTaskCreationRequest';
2628
import { AdminTaskDeployResponse } from '../model/adminTaskDeployResponse';
2729
import { AdminTaskMergeResponse } from '../model/adminTaskMergeResponse';
@@ -2969,6 +2971,105 @@ export class DefaultService {
29692971
);
29702972
}
29712973

2974+
/**
2975+
*
2976+
*
2977+
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
2978+
* @param reportProgress flag to report request and response progress.
2979+
*/
2980+
public instanceConfigGetAll(observe?: 'body', reportProgress?: boolean): Observable<AdminInstanceConfigResponse>;
2981+
public instanceConfigGetAll(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<AdminInstanceConfigResponse>>;
2982+
public instanceConfigGetAll(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<AdminInstanceConfigResponse>>;
2983+
public instanceConfigGetAll(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
2984+
2985+
let headers = this.defaultHeaders;
2986+
2987+
// authentication (ksi) required
2988+
if (this.configuration.accessToken) {
2989+
const accessToken = typeof this.configuration.accessToken === 'function'
2990+
? this.configuration.accessToken()
2991+
: this.configuration.accessToken;
2992+
headers = headers.set('Authorization', 'Bearer ' + accessToken);
2993+
}
2994+
2995+
// to determine the Accept header
2996+
let httpHeaderAccepts: string[] = [
2997+
'application/json'
2998+
];
2999+
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
3000+
if (httpHeaderAcceptSelected != undefined) {
3001+
headers = headers.set('Accept', httpHeaderAcceptSelected);
3002+
}
3003+
3004+
// to determine the Content-Type header
3005+
const consumes: string[] = [
3006+
];
3007+
3008+
return this.httpClient.request<AdminInstanceConfigResponse>('get',`${this.basePath}/admin/instanceConfig`,
3009+
{
3010+
withCredentials: this.configuration.withCredentials,
3011+
headers: headers,
3012+
observe: observe,
3013+
reportProgress: reportProgress
3014+
}
3015+
);
3016+
}
3017+
3018+
/**
3019+
*
3020+
*
3021+
* @param body
3022+
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
3023+
* @param reportProgress flag to report request and response progress.
3024+
*/
3025+
public instanceConfigSetSingle(body: AdminInstanceConfig, observe?: 'body', reportProgress?: boolean): Observable<string>;
3026+
public instanceConfigSetSingle(body: AdminInstanceConfig, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<string>>;
3027+
public instanceConfigSetSingle(body: AdminInstanceConfig, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<string>>;
3028+
public instanceConfigSetSingle(body: AdminInstanceConfig, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
3029+
3030+
if (body === null || body === undefined) {
3031+
throw new Error('Required parameter body was null or undefined when calling instanceConfigSetSingle.');
3032+
}
3033+
3034+
let headers = this.defaultHeaders;
3035+
3036+
// authentication (ksi) required
3037+
if (this.configuration.accessToken) {
3038+
const accessToken = typeof this.configuration.accessToken === 'function'
3039+
? this.configuration.accessToken()
3040+
: this.configuration.accessToken;
3041+
headers = headers.set('Authorization', 'Bearer ' + accessToken);
3042+
}
3043+
3044+
// to determine the Accept header
3045+
let httpHeaderAccepts: string[] = [
3046+
'application/json'
3047+
];
3048+
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
3049+
if (httpHeaderAcceptSelected != undefined) {
3050+
headers = headers.set('Accept', httpHeaderAcceptSelected);
3051+
}
3052+
3053+
// to determine the Content-Type header
3054+
const consumes: string[] = [
3055+
'application/json'
3056+
];
3057+
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
3058+
if (httpContentTypeSelected != undefined) {
3059+
headers = headers.set('Content-Type', httpContentTypeSelected);
3060+
}
3061+
3062+
return this.httpClient.request<string>('post',`${this.basePath}/admin/instanceConfig`,
3063+
{
3064+
body: body,
3065+
withCredentials: this.configuration.withCredentials,
3066+
headers: headers,
3067+
observe: observe,
3068+
reportProgress: reportProgress
3069+
}
3070+
);
3071+
}
3072+
29723073
/**
29733074
*
29743075
*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* web-backend-swagger
3+
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
4+
*
5+
* OpenAPI spec version: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
export interface AdminInstanceConfig {
14+
key: string;
15+
value: string;
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* web-backend-swagger
3+
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
4+
*
5+
* OpenAPI spec version: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
import { AdminInstanceConfig } from './adminInstanceConfig';
13+
14+
export interface AdminInstanceConfigResponse {
15+
config: Array<AdminInstanceConfig>;
16+
}

src/api/backend/model/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export * from './achievementGrantRequest';
66
export * from './achievementGrantResponse';
77
export * from './achievementResponse';
88
export * from './achievementsResponse';
9+
export * from './adminInstanceConfig';
10+
export * from './adminInstanceConfigResponse';
911
export * from './adminTask';
1012
export * from './adminTaskCreation';
1113
export * from './adminTaskCreationRequest';

src/app/components/admin/admin-routing.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PageAdminMonitorComponent } from './page-admin-monitor/page-admin-monit
77
import { PageAdminEmailComponent } from './page-admin-email/page-admin-email.component';
88
import {PageAdminDiscussionComponent} from './page-admin-discussion/page-admin-discussion.component';
99
import {PageAdminAchievementsComponent} from './page-admin-achievements/page-admin-achievements.component';
10+
import {PageAdminInstanceConfigComponent} from './page-admin-instance-config/page-admin-instance-config.component';
1011

1112
const routes: Routes = [
1213
{path: '', component: PageAdminRootComponent},
@@ -15,6 +16,7 @@ const routes: Routes = [
1516
{path: ROUTES.admin.email, component: PageAdminEmailComponent},
1617
{path: ROUTES.admin.discussion, component: PageAdminDiscussionComponent},
1718
{path: ROUTES.admin.achievements, component: PageAdminAchievementsComponent},
19+
{path: ROUTES.admin.instanceConfig, component: PageAdminInstanceConfigComponent},
1820
];
1921

2022
@NgModule({

src/app/components/admin/admin-sidebar/admin-sidebar.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<a class="nav-btn" [routerLink]="['/', routes.routes.admin._, routes.routes.admin.achievements]" routerLinkActive="active" (click)="hideFullMenu($event)">
1919
{{'admin.navbar.achievement' | translate}}
2020
</a>
21+
<a *ngIf="userService.isAdmin$ | async" class="nav-btn" [routerLink]="['/', routes.routes.admin._, routes.routes.admin.instanceConfig]" routerLinkActive="active" (click)="hideFullMenu($event)">
22+
{{'admin.navbar.instance-config' | translate}}
23+
</a>
2124
<ng-container *ngIf="oldFrontendUrl">
2225
<a *ngFor="let oldLink of oldFrontendButtons"
2326
class="nav-btn"

src/app/components/admin/admin-sidebar/admin-sidebar.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class AdminSidebarComponent implements OnInit, OnDestroy {
3030

3131
constructor(
3232
public routes: RoutesService,
33-
private userService: UserService,
33+
public userService: UserService,
3434
private router: Router,
3535
public window: WindowService,
3636
public icon: IconService

src/app/components/admin/admin.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import { SharedModule } from '../shared/shared.module';
1212
import { TooltipModule } from 'ngx-bootstrap/tooltip';
1313
import { PageAdminEmailComponent } from './page-admin-email/page-admin-email.component';
1414
import { QuillModule } from 'ngx-quill';
15-
import { ReactiveFormsModule } from '@angular/forms';
15+
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
1616
import { AccordionModule } from 'ngx-bootstrap/accordion';
1717
import { PageAdminDiscussionComponent } from './page-admin-discussion/page-admin-discussion.component';
1818
import { AdminWaveSelectorComponent } from './shared/admin-wave-selector/admin-wave-selector.component';
1919
import { PageAdminAchievementsComponent } from './page-admin-achievements/page-admin-achievements.component';
20+
import { PageAdminInstanceConfigComponent } from './page-admin-instance-config/page-admin-instance-config.component';
2021

2122

2223
@NgModule({
@@ -29,7 +30,8 @@ import { PageAdminAchievementsComponent } from './page-admin-achievements/page-a
2930
PageAdminEmailComponent,
3031
PageAdminDiscussionComponent,
3132
AdminWaveSelectorComponent,
32-
PageAdminAchievementsComponent
33+
PageAdminAchievementsComponent,
34+
PageAdminInstanceConfigComponent
3335
],
3436
imports: [
3537
CommonModule,
@@ -39,7 +41,8 @@ import { PageAdminAchievementsComponent } from './page-admin-achievements/page-a
3941
TooltipModule,
4042
QuillModule,
4143
ReactiveFormsModule,
42-
AccordionModule
44+
AccordionModule,
45+
FormsModule
4346
]
4447
})
4548
export class AdminModule { }
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<ksi-admin-sidebar></ksi-admin-sidebar>
2+
<div class="content-container">
3+
<div class="content">
4+
<h2 class="title">{{'admin.instance-config.title'|translate}}</h2>
5+
6+
<table class="table table-striped table-responsive-md tasks-table" ksiTheme>
7+
<thead>
8+
<tr class="table-head-row">
9+
<th scope="col">{{'admin.instance-config.key' | translate}}</th>
10+
<th scope="col">{{'admin.instance-config.value' | translate}}</th>
11+
<th scope="col">{{'admin.instance-config.actions' | translate}}</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
<tr *ngFor="let config of (config$ | async)">
16+
<td>{{config.key}}</td>
17+
<td>
18+
<span *ngIf="config.value">
19+
{{config.value}}
20+
</span>
21+
<span *ngIf="!config.value">
22+
<i>{{'admin.instance-config.null-value' | translate}}</i>
23+
</span>
24+
</td>
25+
<td>
26+
<button class="btn btn-outline-primary" (click)="editConfig(config)">{{'admin.instance-config.edit' | translate}}</button>
27+
</td>
28+
</tbody>
29+
</table>
30+
</div>
31+
</div>
32+
33+
<ng-template #modalEditConfig>
34+
<form class="form" *ngIf="editedConfig">
35+
<div class="form-group">
36+
<label for="key">{{'admin.instance-config.key' | translate}}</label>
37+
<input type="text" class="form-control" id="key" name="key" [(ngModel)]="editedConfig.key" disabled>
38+
</div>
39+
<div class="form-group">
40+
<label for="value">{{'admin.instance-config.value' | translate}}</label>
41+
<input type="text" class="form-control" id="value" name="value" [(ngModel)]="editedConfig.value">
42+
</div>
43+
<button [disabled]="!editedConfig" type="submit" class="btn btn-primary" (click)="saveConfig(editedConfig)">{{'admin.instance-config.save' | translate}}</button>
44+
</form>
45+
</ng-template>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import "src/app/styles/vars";
2+
@import "src/app/styles/mixins";
3+
4+
@include page-admin;
5+
6+
:host {
7+
.content {
8+
justify-self: center;
9+
10+
> .title {
11+
margin: $ksi-margin;
12+
text-align: center;
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)