|
@@ -1,9 +1,10 @@
|
|
|
import { Component, ViewChild } from '@angular/core';
|
|
import { Component, ViewChild } from '@angular/core';
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
-import { faAngleRight, faPlus, faSave, faServer } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
|
+import { faAngleRight, faPlus, faSave, faServer, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
import { NgbAccordion, NgbPanelChangeEvent } from '@ng-bootstrap/ng-bootstrap';
|
|
import { NgbAccordion, NgbPanelChangeEvent } from '@ng-bootstrap/ng-bootstrap';
|
|
|
|
|
|
|
|
import { ServiceCheckFormComponent } from 'src/app/components/service-check-form/service-check-form.component';
|
|
import { ServiceCheckFormComponent } from 'src/app/components/service-check-form/service-check-form.component';
|
|
|
|
|
+import { ComponentService } from 'src/app/services/component.service';
|
|
|
import { ServiceApiService } from 'src/app/services/service-api.service';
|
|
import { ServiceApiService } from 'src/app/services/service-api.service';
|
|
|
import { ServerApiService } from 'src/app/services/server-api.service';
|
|
import { ServerApiService } from 'src/app/services/server-api.service';
|
|
|
|
|
|
|
@@ -21,12 +22,18 @@ export class AdminServiceChecksPageComponent {
|
|
|
@ViewChild('acc') accordeonRef!: NgbAccordion;
|
|
@ViewChild('acc') accordeonRef!: NgbAccordion;
|
|
|
public serverConfigs?: ServerConfig[];
|
|
public serverConfigs?: ServerConfig[];
|
|
|
public serviceChecks: HttpCheckConfig[] = [];
|
|
public serviceChecks: HttpCheckConfig[] = [];
|
|
|
- public fa = { save: faSave, server: faServer, angleRight: faAngleRight, plus: faPlus };
|
|
|
|
|
|
|
+ public fa = { save: faSave, server: faServer, angleRight: faAngleRight, plus: faPlus, trash: faTrashAlt };
|
|
|
|
|
|
|
|
public activeId = 0;
|
|
public activeId = 0;
|
|
|
public params?: { serverID?: number; checkID?: number; activeIds?: string[] };
|
|
public params?: { serverID?: number; checkID?: number; activeIds?: string[] };
|
|
|
|
|
|
|
|
- constructor(apiService: ServerApiService, route: ActivatedRoute, private router: Router, private serviceApi: ServiceApiService) {
|
|
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ apiService: ServerApiService,
|
|
|
|
|
+ private cmpService: ComponentService,
|
|
|
|
|
+ route: ActivatedRoute,
|
|
|
|
|
+ private router: Router,
|
|
|
|
|
+ private serviceApi: ServiceApiService
|
|
|
|
|
+ ) {
|
|
|
apiService.serverConfigs$.subscribe(data => {
|
|
apiService.serverConfigs$.subscribe(data => {
|
|
|
this.serverConfigs = data;
|
|
this.serverConfigs = data;
|
|
|
this.syncInit();
|
|
this.syncInit();
|
|
@@ -129,4 +136,34 @@ export class AdminServiceChecksPageComponent {
|
|
|
}
|
|
}
|
|
|
this.onAccordeonChange({ nextState: true, panelId, preventDefault: () => {} });
|
|
this.onAccordeonChange({ nextState: true, panelId, preventDefault: () => {} });
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ async removeServiceCheck(event: Event, checkId: number) {
|
|
|
|
|
+ event.stopPropagation();
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!this.params?.serverID) return;
|
|
|
|
|
+
|
|
|
|
|
+ if (checkId === -1) {
|
|
|
|
|
+ const decision = await this.cmpService.openConfirmModal({
|
|
|
|
|
+ modalContent: { message: `Really delete unsaved service check?` }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (decision) this.serviceChecks.shift();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const decision = await this.cmpService.openConfirmModal({
|
|
|
|
|
+ modalContent: { message: `Really delete service check #${checkId}?` }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (!decision) return;
|
|
|
|
|
+
|
|
|
|
|
+ await this.serviceApi.deleteServiceCheck(this.params.serverID, checkId);
|
|
|
|
|
+
|
|
|
|
|
+ const idx = this.serviceChecks.findIndex(c => c.id === checkId);
|
|
|
|
|
+ if (idx >= 0) this.serviceChecks.splice(idx, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.params.activeIds = [];
|
|
|
|
|
+ this.onAccordeonChange({ nextState: false, panelId: '', preventDefault: () => {} });
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error(error);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|