2023-01-27 11:44:30 +01:00
|
|
|
import { Component, Inject,AfterViewInit, OnInit, ViewChild } from '@angular/core';
|
|
|
|
import { ISService } from '../is.service';
|
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
2023-02-01 09:58:36 +01:00
|
|
|
import { MatSort } from '@angular/material/sort';
|
|
|
|
import { Context, ContextNode } from '../is.model';
|
2023-01-27 11:44:30 +01:00
|
|
|
import { ActivatedRoute, Params } from '@angular/router';
|
|
|
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
2023-02-01 09:58:36 +01:00
|
|
|
import { ContextParam } from '../is.model';
|
2023-01-27 11:44:30 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-contexts',
|
|
|
|
templateUrl: './contexts.component.html',
|
|
|
|
styleUrls: ['./contexts.component.css']
|
|
|
|
})
|
|
|
|
export class ContextsComponent implements AfterViewInit ,OnInit {
|
|
|
|
contextsDatasource: MatTableDataSource<Context> = new MatTableDataSource<Context>([]);
|
|
|
|
|
|
|
|
colums: string[] = ['id', 'label', 'type', 'buttons'];
|
|
|
|
|
|
|
|
@ViewChild(MatSort) sort: MatSort | undefined
|
|
|
|
|
2023-01-27 15:00:41 +01:00
|
|
|
constructor(public service: ISService, public route: ActivatedRoute, public dialog: MatDialog) {
|
2023-01-27 11:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
|
if(this.sort) this.contextsDatasource.sort = this.sort;
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
this.service.loadContexts((data: Context[]) => this.contextsDatasource.data = data);
|
|
|
|
}
|
|
|
|
|
|
|
|
applyFilter(event: Event) {
|
|
|
|
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
|
|
|
|
this.contextsDatasource.filter = filterValue;
|
|
|
|
}
|
2023-01-27 12:43:15 +01:00
|
|
|
|
2023-01-27 15:00:41 +01:00
|
|
|
showParamsDialog(context: Context): void {
|
|
|
|
const dialogRef = this.dialog.open(ContextParamsDialog, {
|
2023-01-27 12:43:15 +01:00
|
|
|
data: context.parameters,
|
2023-01-27 11:44:30 +01:00
|
|
|
width: '80%'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'context-dialog',
|
2023-01-30 10:58:34 +01:00
|
|
|
templateUrl: 'context-params-dialog.html',
|
2023-01-27 11:44:30 +01:00
|
|
|
styleUrls: ['./contexts.component.css']
|
|
|
|
})
|
2023-01-27 12:43:15 +01:00
|
|
|
export class ContextParamsDialog {
|
|
|
|
|
|
|
|
constructor(public dialogRef: MatDialogRef<ContextParamsDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) {
|
2023-01-27 11:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onNoClick(): void {
|
|
|
|
this.dialogRef.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-context-editor',
|
2023-01-27 12:43:15 +01:00
|
|
|
templateUrl: './context-viewer.component.html',
|
2023-01-27 11:44:30 +01:00
|
|
|
styleUrls: ['./contexts.component.css']
|
|
|
|
})
|
2023-01-27 15:00:41 +01:00
|
|
|
export class ContextViewerComponent implements OnInit {
|
|
|
|
|
|
|
|
context?:Context
|
|
|
|
categories:ContextNode[] = [];
|
|
|
|
|
|
|
|
constructor(public service: ISService, public route: ActivatedRoute, public dialog: MatDialog) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.route.queryParams.subscribe((params) => {
|
|
|
|
this.service.loadContext(params['id'], (data: Context) => this.context = data);
|
|
|
|
this.service.loadContextCategories(params['id'], (data:ContextNode[]) => this.categories = data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
populateNode(level:number, node:ContextNode): void {
|
|
|
|
this.service.loadContextConcepts(level, node.id, (data:ContextNode[]) => {
|
|
|
|
node.populated = true;
|
|
|
|
node.childs = data
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
showParamsDialog(params:ContextParam[] | undefined): void {
|
|
|
|
if (params) {
|
|
|
|
this.dialog.open(ContextParamsDialog, {
|
|
|
|
data: params,
|
|
|
|
width: '80%'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-01-27 11:44:30 +01:00
|
|
|
|
|
|
|
}
|