2023-03-23 15:05:39 +01:00
|
|
|
import { Component, OnInit, SecurityContext } from '@angular/core';
|
2023-03-23 12:24:56 +01:00
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
2023-03-23 15:05:39 +01:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
import { KeyValue, WfConf, WfSection } from '../common/is.model';
|
2023-03-23 12:24:56 +01:00
|
|
|
import { ISService } from '../common/is.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-wf-confs',
|
|
|
|
templateUrl: './wf-confs.component.html',
|
|
|
|
styleUrls: ['./wf-confs.component.css']
|
|
|
|
})
|
|
|
|
export class WfConfsComponent implements OnInit {
|
|
|
|
|
|
|
|
section?: WfSection;
|
|
|
|
confs: KeyValue[] = [];
|
2023-03-23 15:05:39 +01:00
|
|
|
conf?: WfConf;
|
2023-03-23 12:24:56 +01:00
|
|
|
|
2023-03-23 15:05:39 +01:00
|
|
|
constructor(public service: ISService, public route: ActivatedRoute, public router: Router, public dialog: MatDialog) {
|
2023-03-23 12:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.route.params.subscribe(params => {
|
|
|
|
let sectionId = params['section'];
|
2023-03-23 15:05:39 +01:00
|
|
|
let confId = params['conf'];
|
2023-03-23 12:24:56 +01:00
|
|
|
|
2023-03-23 15:05:39 +01:00
|
|
|
if (confId) {
|
|
|
|
this.service.loadWfConfiguration(confId, (conf: WfConf) => {
|
|
|
|
this.conf = conf;
|
|
|
|
if (conf.section) {
|
|
|
|
this.service.loadWfSections((data: WfSection[]) => this.section = data.find(s => s.id == conf?.section));
|
|
|
|
this.service.loadWfConfigurations(conf.section, (data: KeyValue[]) => this.confs = data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (sectionId) {
|
|
|
|
this.service.loadWfSections((data: WfSection[]) => this.section = data.find(s => s.id == sectionId));
|
|
|
|
this.service.loadWfConfigurations(sectionId, (data: KeyValue[]) => {
|
|
|
|
this.confs = data;
|
|
|
|
if (data.length > 0) {
|
|
|
|
this.router.navigate(['/wfs/conf', data[0].k]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
console.log("One of the following parameters is missing: sectionId or confId");
|
|
|
|
}
|
|
|
|
});
|
2023-03-23 12:24:56 +01:00
|
|
|
}
|
|
|
|
}
|