-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
317 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* web-backend-swagger | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* OpenAPI spec version: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
export interface AdminInstanceConfig { | ||
key: string; | ||
value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* web-backend-swagger | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* OpenAPI spec version: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
import { AdminInstanceConfig } from './adminInstanceConfig'; | ||
|
||
export interface AdminInstanceConfigResponse { | ||
config: Array<AdminInstanceConfig>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...app/components/admin/page-admin-instance-config/page-admin-instance-config.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<ksi-admin-sidebar></ksi-admin-sidebar> | ||
<div class="content-container"> | ||
<div class="content"> | ||
<h2 class="title">{{'admin.instance-config.title'|translate}}</h2> | ||
|
||
<table class="table table-striped table-responsive-md tasks-table" ksiTheme> | ||
<thead> | ||
<tr class="table-head-row"> | ||
<th scope="col">{{'admin.instance-config.key' | translate}}</th> | ||
<th scope="col">{{'admin.instance-config.value' | translate}}</th> | ||
<th scope="col">{{'admin.instance-config.actions' | translate}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let config of (config$ | async)"> | ||
<td>{{config.key}}</td> | ||
<td> | ||
<span *ngIf="config.value"> | ||
{{config.value}} | ||
</span> | ||
<span *ngIf="!config.value"> | ||
<i>{{'admin.instance-config.null-value' | translate}}</i> | ||
</span> | ||
</td> | ||
<td> | ||
<button class="btn btn-outline-primary" (click)="editConfig(config)">{{'admin.instance-config.edit' | translate}}</button> | ||
</td> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
|
||
<ng-template #modalEditConfig> | ||
<form class="form" *ngIf="editedConfig"> | ||
<div class="form-group"> | ||
<label for="key">{{'admin.instance-config.key' | translate}}</label> | ||
<input type="text" class="form-control" id="key" name="key" [(ngModel)]="editedConfig.key" disabled> | ||
</div> | ||
<div class="form-group"> | ||
<label for="value">{{'admin.instance-config.value' | translate}}</label> | ||
<input type="text" class="form-control" id="value" name="value" [(ngModel)]="editedConfig.value"> | ||
</div> | ||
<button [disabled]="!editedConfig" type="submit" class="btn btn-primary" (click)="saveConfig(editedConfig)">{{'admin.instance-config.save' | translate}}</button> | ||
</form> | ||
</ng-template> |
15 changes: 15 additions & 0 deletions
15
...app/components/admin/page-admin-instance-config/page-admin-instance-config.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import "src/app/styles/vars"; | ||
@import "src/app/styles/mixins"; | ||
|
||
@include page-admin; | ||
|
||
:host { | ||
.content { | ||
justify-self: center; | ||
|
||
> .title { | ||
margin: $ksi-margin; | ||
text-align: center; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.../components/admin/page-admin-instance-config/page-admin-instance-config.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PageAdminInstanceConfigComponent } from './page-admin-instance-config.component'; | ||
|
||
describe('PageAdminInstanceConfigComponent', () => { | ||
let component: PageAdminInstanceConfigComponent; | ||
let fixture: ComponentFixture<PageAdminInstanceConfigComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PageAdminInstanceConfigComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PageAdminInstanceConfigComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
src/app/components/admin/page-admin-instance-config/page-admin-instance-config.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {Component, OnInit, ChangeDetectionStrategy, ViewChild, TemplateRef} from '@angular/core'; | ||
import {BackendService, KsiTitleService, ModalService} from '../../../services'; | ||
import {BehaviorSubject, Subject} from 'rxjs'; | ||
import {AdminInstanceConfig} from '../../../../api/backend'; | ||
import {OpenedTemplate} from '../../../models'; | ||
|
||
@Component({ | ||
selector: 'ksi-page-admin-instance-config', | ||
templateUrl: './page-admin-instance-config.component.html', | ||
styleUrls: ['./page-admin-instance-config.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class PageAdminInstanceConfigComponent implements OnInit { | ||
private configSubject: Subject<AdminInstanceConfig[]> = new BehaviorSubject(([] as AdminInstanceConfig[])); | ||
config$ = this.configSubject.asObservable(); | ||
|
||
editedConfig: AdminInstanceConfig | null = null; | ||
@ViewChild('modalEditConfig', {static: true}) | ||
modalEditConfig: TemplateRef<unknown>; | ||
modalEditConfigInstance: OpenedTemplate | null = null; | ||
|
||
constructor( | ||
private title: KsiTitleService, | ||
private backend: BackendService, | ||
private modal: ModalService | ||
) { } | ||
|
||
ngOnInit(): void { | ||
this.title.subtitle = 'admin.root.instance-config.title'; | ||
this.refreshConfig(); | ||
} | ||
|
||
private refreshConfig(): void { | ||
this.backend.http.instanceConfigGetAll().subscribe((response) => { | ||
this.configSubject.next(response.config); | ||
}); | ||
} | ||
|
||
editConfig(config: AdminInstanceConfig): void { | ||
this.editedConfig = config; | ||
this.modalEditConfigInstance = this.modal.showModalTemplate(this.modalEditConfig, 'admin.root.instance-config.edit-config'); | ||
} | ||
|
||
saveConfig(editedConfig: AdminInstanceConfig | null): void { | ||
if (editedConfig) { | ||
this.editedConfig = null; | ||
this.backend.http.instanceConfigSetSingle(editedConfig).subscribe(() => { | ||
this.refreshConfig(); | ||
this.modalEditConfigInstance?.template.instance.close(); | ||
this.modalEditConfigInstance = null; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.