153 lines
4.6 KiB
TypeScript
153 lines
4.6 KiB
TypeScript
import { Component, Inject, OnInit } from '@angular/core';
|
|
import { ISService } from '../common/is.service';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
import { MDStore, MDStoreVersion } from '../common/is.model';
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|
|
|
@Component({
|
|
selector: 'app-mdstores',
|
|
templateUrl: './mdstores.component.html',
|
|
styleUrls: ['./mdstores.component.css']
|
|
})
|
|
export class MdstoresComponent implements OnInit {
|
|
|
|
mdstores:MDStore[] = [];
|
|
searchText:string = '';
|
|
|
|
constructor(public service: ISService, public route: ActivatedRoute, public dialog: MatDialog) {}
|
|
|
|
ngOnInit() { this.reload() }
|
|
reload() { this.service.loadMDStores((data: MDStore[]) => this.mdstores = data); }
|
|
|
|
openVersionsDialog(md:MDStore): void {
|
|
const dialogRef = this.dialog.open(MDStoreVersionsDialog, {
|
|
data: md,
|
|
width: '80%'
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(result => {
|
|
if (result) this.reload();
|
|
});
|
|
}
|
|
|
|
openAddMdstoreDialog(): void {
|
|
const dialogRef = this.dialog.open(AddMDStoreDialog, {
|
|
data: {},
|
|
width: '80%'
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(result => {
|
|
if (result) this.reload();
|
|
});
|
|
}
|
|
|
|
createNewVersion(md:MDStore): void {
|
|
this.service.prepareNewMDStoreVersion(md.id, (data:MDStoreVersion) => {
|
|
md.numberOfVersions = md.numberOfVersions + 1;
|
|
this.openVersionsDialog(md);
|
|
});
|
|
}
|
|
|
|
deleteMdstore(md:MDStore) {
|
|
if (confirm('Are you sure?')) {
|
|
this.service.deleteMDStore(md.id, (data: void) => this.reload());
|
|
}
|
|
}
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-mdstore-inspector',
|
|
templateUrl: './mdstore-inspector.component.html',
|
|
styleUrls: ['./mdstores.component.css']
|
|
})
|
|
export class MdstoreInspectorComponent {
|
|
|
|
}
|
|
|
|
@Component({
|
|
selector: 'mdstores-versions-dialog',
|
|
templateUrl: './mdstores-versions-dialog.html',
|
|
styleUrls: ['./mdstores.component.css']
|
|
})
|
|
export class MDStoreVersionsDialog {
|
|
forceDelete:boolean = false;
|
|
versions:MDStoreVersion[] = [];
|
|
|
|
constructor(public dialogRef: MatDialogRef<MDStoreVersionsDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService, public router: Router) {
|
|
this.reload();
|
|
}
|
|
|
|
reload() {
|
|
this.service.loadMDStoreVersions(this.data.id, (res:MDStoreVersion[]) => this.versions = res);
|
|
}
|
|
|
|
openInspectorPage(version:MDStoreVersion):void {
|
|
const url = this.router.serializeUrl(
|
|
this.router.createUrlTree(['/mdrecords/' + encodeURIComponent(version.id) + '/50'])
|
|
);
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
resetReading(version:MDStoreVersion):void {
|
|
//TODO
|
|
}
|
|
|
|
commitVersion(version:MDStoreVersion):void {
|
|
let size:number = parseInt(prompt("New Size", "0") || "0");
|
|
if (size >= 0) {
|
|
this.service.commitMDStoreVersion(version.id, size, (data:void) => {
|
|
this.reload();
|
|
//TODO this version should be promoved as current
|
|
});
|
|
}
|
|
}
|
|
|
|
abortVersion(version:MDStoreVersion):void {
|
|
this.service.abortMDStoreVersion(version.id, (data:void) => this.reload());
|
|
}
|
|
|
|
deleteVersion(version:MDStoreVersion):void {
|
|
this.service.deleteMDStoreVersion(version.id, this.forceDelete, (data:void) => this.reload());
|
|
}
|
|
|
|
onNoClick(): void {
|
|
this.dialogRef.close();
|
|
}
|
|
}
|
|
|
|
@Component({
|
|
selector: 'add-mdstore-dialog',
|
|
templateUrl: './add-mdstore-dialog.html',
|
|
styleUrls: ['./mdstores.component.css']
|
|
})
|
|
export class AddMDStoreDialog {
|
|
|
|
newMdstoreForm = new FormGroup({
|
|
format: new FormControl('', [Validators.required]),
|
|
layout : new FormControl('', [Validators.required]),
|
|
interpretation : new FormControl('', [Validators.required]),
|
|
dsName : new FormControl(''),
|
|
dsId : new FormControl(''),
|
|
apiId : new FormControl(''),
|
|
});
|
|
|
|
constructor(public dialogRef: MatDialogRef<MDStoreVersionsDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) {
|
|
|
|
}
|
|
|
|
onSubmit():void {
|
|
let format:string = this.newMdstoreForm.get('format')?.value!;
|
|
let layout:string = this.newMdstoreForm.get('layout')?.value!;
|
|
let interpretation:string = this.newMdstoreForm.get('interpretation')?.value!;
|
|
let dsName:string = this.newMdstoreForm.get('dsName')?.value!;
|
|
let dsId:string = this.newMdstoreForm.get('dsId')?.value!;
|
|
let apiId:string = this.newMdstoreForm.get('apiId')?.value!;
|
|
|
|
this.service.addMDStore(format, layout, interpretation, dsName, dsId, apiId, (data: void) => this.dialogRef.close(1), this.newMdstoreForm);
|
|
}
|
|
|
|
onNoClick(): void {
|
|
this.dialogRef.close();
|
|
}
|
|
} |