From 1491e8a5d2078662a434ef239dbd275900952ca6 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 7 Feb 2023 15:08:37 +0100 Subject: [PATCH] mdstore ui - partial implementation --- .../src/app/app-routing.module.ts | 26 +++++----- .../src/app/common/is.model.ts | 2 +- .../src/app/common/is.service.ts | 31 ++++++++++++ .../src/app/dsm/dsm.component.css | 4 -- .../mdstores/mdstores-versions-dialog.html | 49 ++++++++++++++++++- .../src/app/mdstores/mdstores.component.css | 24 ++++++--- .../src/app/mdstores/mdstores.component.html | 8 +-- .../app/mdstores/mdstores.component.spec.ts | 23 --------- .../src/app/mdstores/mdstores.component.ts | 45 +++++++++++++++-- 9 files changed, 153 insertions(+), 59 deletions(-) delete mode 100644 frontends/dnet-is-application/src/app/mdstores/mdstores.component.spec.ts diff --git a/frontends/dnet-is-application/src/app/app-routing.module.ts b/frontends/dnet-is-application/src/app/app-routing.module.ts index 1647793e..04f02978 100644 --- a/frontends/dnet-is-application/src/app/app-routing.module.ts +++ b/frontends/dnet-is-application/src/app/app-routing.module.ts @@ -10,19 +10,19 @@ import { DsmSearchComponent, DsmResultsComponent, DsmApiComponent } from './dsm/ import { MdstoreInspectorComponent, MdstoresComponent } from './mdstores/mdstores.component'; const routes: Routes = [ - { path:"" , redirectTo:'info', pathMatch: 'full' }, - { path:"info" , component:InfoComponent }, - { path:"resources/:type" , component:ResourcesComponent }, - { path:"adv_resources/context" , component:ContextsComponent }, - { path:"adv_resources/vocabulary", component:VocabulariesComponent }, - { path:"adv_resources/protocol" , component:ProtocolsComponent }, - { path:"wf_history" , component:WfHistoryComponent }, - { path:"ctx_viewer" , component:ContextViewerComponent }, - { path:"voc_editor" , component:VocabularyEditorComponent }, - { path:"dsm/search" , component:DsmSearchComponent }, - { path:"dsm/results/:page/:size" , component:DsmResultsComponent }, - { path:"mdstores" , component:MdstoresComponent }, - { path:"mdstore/:id/:limit" , component:MdstoreInspectorComponent } + { path:"" , redirectTo:'info', pathMatch: 'full' }, + { path:"info" , component:InfoComponent }, + { path:"resources/:type" , component:ResourcesComponent }, + { path:"adv_resources/context" , component:ContextsComponent }, + { path:"adv_resources/vocabulary" , component:VocabulariesComponent }, + { path:"adv_resources/protocol" , component:ProtocolsComponent }, + { path:"wf_history" , component:WfHistoryComponent }, + { path:"ctx_viewer" , component:ContextViewerComponent }, + { path:"voc_editor" , component:VocabularyEditorComponent }, + { path:"dsm/search" , component:DsmSearchComponent }, + { path:"dsm/results/:page/:size" , component:DsmResultsComponent }, + { path:"mdstores" , component:MdstoresComponent }, + { path:"mdrecords/:versionId/:limit" , component:MdstoreInspectorComponent } ]; @NgModule({ diff --git a/frontends/dnet-is-application/src/app/common/is.model.ts b/frontends/dnet-is-application/src/app/common/is.model.ts index 24b7f8a8..ae34c6da 100644 --- a/frontends/dnet-is-application/src/app/common/is.model.ts +++ b/frontends/dnet-is-application/src/app/common/is.model.ts @@ -185,6 +185,6 @@ export interface MDStoreVersion { writing: boolean, readCount:number, lastUpdate:string, - siz: number, + size: number, hdfsPath: string; } diff --git a/frontends/dnet-is-application/src/app/common/is.service.ts b/frontends/dnet-is-application/src/app/common/is.service.ts index d3c692d2..16ef6a51 100644 --- a/frontends/dnet-is-application/src/app/common/is.service.ts +++ b/frontends/dnet-is-application/src/app/common/is.service.ts @@ -261,6 +261,37 @@ export class ISService { }); } + commitMDStoreVersion(versionId:string, size:number, onSuccess: Function) { + this.client.get('./ajax/mdstores/version/' + encodeURIComponent(versionId) + '/commit/' + size).subscribe({ + next: data => onSuccess(data), + error: error => this.showError(error) + }); + } + + abortMDStoreVersion(versionId:string, onSuccess: Function) { + this.client.get('./ajax/mdstores/version/' + encodeURIComponent(versionId) + '/abort').subscribe({ + next: data => onSuccess(data), + error: error => this.showError(error) + }); + } + + deleteMDStoreVersion(versionId:string, force:boolean, onSuccess: Function) { + let params = new HttpParams(); + if (force) { params = params.append('force', true); } + + this.client.delete('./ajax/mdstores/version/' + encodeURIComponent(versionId), {params: params}).subscribe({ + next: data => onSuccess(data), + error: error => this.showError(error) + }); + } + + loadMDStoreVersions(mdId:string, onSuccess: Function): void { + this.client.get('./ajax/mdstores/mdstore/' + encodeURIComponent(mdId) + '/versions').subscribe({ + next: data => onSuccess(data), + error: error => this.showError(error) + }); + } + private showError(error: any, form?: FormGroup) { const msg = this.errorMessage(error); if (form) { diff --git a/frontends/dnet-is-application/src/app/dsm/dsm.component.css b/frontends/dnet-is-application/src/app/dsm/dsm.component.css index 29425153..5b48ec7e 100644 --- a/frontends/dnet-is-application/src/app/dsm/dsm.component.css +++ b/frontends/dnet-is-application/src/app/dsm/dsm.component.css @@ -13,10 +13,6 @@ vertical-align: top; } -.dsm-result-table th { - width: 20em; -} - .dsm-result-table td button { font-size: 0.8em !important; padding: 0 !important; diff --git a/frontends/dnet-is-application/src/app/mdstores/mdstores-versions-dialog.html b/frontends/dnet-is-application/src/app/mdstores/mdstores-versions-dialog.html index a6e70c9f..2397a96e 100644 --- a/frontends/dnet-is-application/src/app/mdstores/mdstores-versions-dialog.html +++ b/frontends/dnet-is-application/src/app/mdstores/mdstores-versions-dialog.html @@ -1 +1,48 @@ -VERSIONS \ No newline at end of file +

MDStore Versions

+ +
+

+ + force delete +

+ + + + + + + + + + + + + + + + + + +
IDRead CountLast UpdateSize
+ + {{v.id}} +
+ Path: {{v.hdfsPath}}
+ + + + +
+ {{v.readCount}} + + {{v.lastUpdate | date:"MMM dd, yyyy 'at' HH:mm"}}{{v.size}}
+ +
+ +
+ +
\ No newline at end of file diff --git a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.css b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.css index b03a1413..c548b3a6 100644 --- a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.css +++ b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.css @@ -1,25 +1,33 @@ -.mdstore-info-table { +.mdstore-table { margin-top: 1em; margin-bottom: 1em; border-collapse: collapse; } -.mdstore-info-table tr:not(:last-child) { +.mdstore-table tr:not(:last-child) { border-bottom: 1pt solid lightgrey; } -.mdstore-info-table th { - width: 30%; -} - -.mdstore-info-table th, .mdstore-info-table td{ +.mdstore-table th, .mdstore-table td{ text-align: left; font-size: 0.9em; vertical-align: top; + padding-left: 1em; + padding-right: 1em; } -.mdstore-info-table td button { +.mdstore-table td button, .mdstore-table td a.mdc-button { font-size: 0.8em !important; padding: 0 !important; height: 2.5em !important; } + +.mdstore-table tr.active-row { + background-color: #daffda; +} + +.mdstore-table mat-icon { + width: 1em; + height: 1em; + font-size: 1em; +} \ No newline at end of file diff --git a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.html b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.html index 4445342e..4ea33b3d 100644 --- a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.html +++ b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.html @@ -13,10 +13,10 @@ {{md.datasourceName}} - +
- - + + @@ -53,7 +53,7 @@
Format / Layout / Interpretation{{md.format}} / {{md.layout}} / {{md.interpretation}}Format / Layout / Interpretation{{md.format}} / {{md.layout}} / {{md.interpretation}}
Datasource
- inspect + inspect diff --git a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.spec.ts b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.spec.ts deleted file mode 100644 index 96e6e962..00000000 --- a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MdstoresComponent } from './mdstores.component'; - -describe('MdstoresComponent', () => { - let component: MdstoresComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ MdstoresComponent ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(MdstoresComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.ts b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.ts index 55533938..b0f3686d 100644 --- a/frontends/dnet-is-application/src/app/mdstores/mdstores.component.ts +++ b/frontends/dnet-is-application/src/app/mdstores/mdstores.component.ts @@ -1,6 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { ISService } from '../common/is.service'; -import { ActivatedRoute } from '@angular/router'; +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'; @@ -71,11 +71,46 @@ export class MdstoreInspectorComponent { styleUrls: ['./mdstores.component.css'] }) export class MDStoreVersionsDialog { - - constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) { - + forceDelete:boolean = false; + versions:MDStoreVersion[] = []; + + constructor(public dialogRef: MatDialogRef, @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(); }