|
|
@@ -1,8 +1,5 @@
|
|
|
-import { Component, OnInit, QueryList, ViewChild } from '@angular/core';
|
|
|
-import { faAngleRight, faPlus, faSave, faServer } from '@fortawesome/free-solid-svg-icons';
|
|
|
-import { ServiceApiService } from '../../services/service-api.service';
|
|
|
-import { ServerApiService } from '../../services/server-api.service';
|
|
|
-import { ServiceCheckFormComponent } from '../../components/service-check-form/service-check-form.component';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { Router } from '@angular/router';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-admin-panel',
|
|
|
@@ -11,38 +8,9 @@ import { ServiceCheckFormComponent } from '../../components/service-check-form/s
|
|
|
host: { class: 'd-flex flex-column h-100' }
|
|
|
})
|
|
|
export class AdminPanelComponent implements OnInit {
|
|
|
- @ViewChild(ServiceCheckFormComponent) formRef!: ServiceCheckFormComponent;
|
|
|
- public serverConfigs: ServerConfig[] = [];
|
|
|
- public serviceChecks: HttpCheckConfig[] = [];
|
|
|
- public fa = { save: faSave, server: faServer, angleRight: faAngleRight, plus: faPlus };
|
|
|
+ constructor(private router: Router) {}
|
|
|
|
|
|
- public activeId = 0;
|
|
|
-
|
|
|
- constructor(private serviceApi: ServiceApiService, apiService: ServerApiService) {
|
|
|
- apiService.serverConfigs$.subscribe(data => {
|
|
|
- this.serverConfigs = data;
|
|
|
- if (data.length > 0) {
|
|
|
- this.fetchServiceChecks(data[this.activeId].id);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- ngOnInit(): void {}
|
|
|
-
|
|
|
- async fetchServiceChecks(serverId: number) {
|
|
|
- try {
|
|
|
- this.serviceChecks = await this.serviceApi.loadServiceChecks(serverId);
|
|
|
- } catch (error: any) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- saveServiceCheck(event: Event) {
|
|
|
- event.stopPropagation();
|
|
|
- this.formRef?.save();
|
|
|
- }
|
|
|
-
|
|
|
- addServiceCheck(serverId: number) {
|
|
|
- this.serviceChecks.unshift({ serverId, checks: [] as string[] } as HttpCheckConfig);
|
|
|
+ ngOnInit(): void {
|
|
|
+ this.router.navigateByUrl('/admin/svc');
|
|
|
}
|
|
|
}
|