108 lines
3.0 KiB
TypeScript
108 lines
3.0 KiB
TypeScript
import { Component, Inject, AfterViewInit, OnInit, ViewChild } from '@angular/core';
|
|
import { BrowseTerm, KeyValue } from '../model/controller.model';
|
|
import { ISService } from '../is.service';
|
|
import { ActivatedRoute, Params } from '@angular/router';
|
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
|
import { MatSort, Sort } from '@angular/material/sort';
|
|
import { Vocabulary, VocabularyTermSynonym } from '../model/controller.model';
|
|
import { Observable, combineLatest } from 'rxjs';
|
|
import { map } from 'rxjs/operators';
|
|
import { VocabularyTerm } from '../model/controller.model';
|
|
import { FormControl, FormGroup, FormGroupDirective, NgForm, Validators } from '@angular/forms';
|
|
import { EmitterVisitorContext } from '@angular/compiler';
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-dsm-search',
|
|
templateUrl: './dsm-search.component.html',
|
|
styleUrls: ['./dsm.component.css']
|
|
})
|
|
export class DsmSearchComponent implements OnInit {
|
|
searchText:string = '';
|
|
browsableFields:KeyValue[] = [];
|
|
|
|
constructor(public service: ISService, public route: ActivatedRoute, public router: Router, public dialog: MatDialog) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.service.dsmBrowsableFields((data: KeyValue[]) => this.browsableFields = data);
|
|
}
|
|
|
|
search() {
|
|
this.router.navigate(['/dsm/results/0/100'], {
|
|
queryParams: { value: this.searchText }
|
|
});
|
|
}
|
|
|
|
browseField(field:string, label:string) {
|
|
const dialogRef = this.dialog.open(DsmBrowseDialog, {
|
|
data: { field: field, label: label },
|
|
width: '80%'
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-dsm-results',
|
|
templateUrl: './dsm-results.component.html',
|
|
styleUrls: ['./dsm.component.css']
|
|
})
|
|
export class DsmResultsComponent {
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-dsm-api',
|
|
templateUrl: './dsm-api.component.html',
|
|
styleUrls: ['./dsm.component.css']
|
|
})
|
|
export class DsmApiComponent {
|
|
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-dsm-add-api',
|
|
templateUrl: './dsm-add-api.component.html',
|
|
styleUrls: ['./dsm.component.css']
|
|
})
|
|
export class DsmAddApiComponent {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
selector: 'dsm-browse-dialog',
|
|
templateUrl: 'dsm-browse-dialog.html',
|
|
styleUrls: ['./dsm.component.css']
|
|
})
|
|
export class DsmBrowseDialog implements OnInit{
|
|
|
|
datasource: MatTableDataSource<BrowseTerm> = new MatTableDataSource<BrowseTerm>([]);
|
|
colums: string[] = ['name', 'total'];
|
|
|
|
@ViewChild(MatSort) sort: MatSort | undefined
|
|
|
|
constructor(public dialogRef: MatDialogRef<DsmBrowseDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.service.dsmBrowse(this.data.field, (res:BrowseTerm[]) => this.datasource.data = res);
|
|
}
|
|
|
|
ngAfterViewInit() {
|
|
if (this.sort) this.datasource.sort = this.sort;
|
|
}
|
|
|
|
applyFilter(event: Event) {
|
|
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
|
|
this.datasource.filter = filterValue;
|
|
}
|
|
|
|
onNoClick(): void {
|
|
this.dialogRef.close();
|
|
}
|
|
} |