dnet-applications/frontends/dnet-is-application/src/app/wf-confs/wf-confs.component.ts

48 lines
1.5 KiB
TypeScript

import { Component, OnInit, SecurityContext } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { KeyValue, WfConf, WfSection } from '../common/is.model';
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[] = [];
conf?: WfConf;
constructor(public service: ISService, public route: ActivatedRoute, public router: Router, public dialog: MatDialog) {
}
ngOnInit() {
this.route.params.subscribe(params => {
let sectionId = params['section'];
let confId = params['conf'];
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");
}
});
}
}