소스 검색

✨ re-introduce metadata window

jmacura 3 년 전
부모
커밋
9ae2bfd4f9

+ 3 - 0
src/adjuster/adjuster-presets.service.ts

@@ -137,6 +137,9 @@ export class AdjusterPresetsService {
   }
 
   getLabelInCurrentLang(labels: Label[]) {
+    if (!labels?.length) {
+      return;
+    }
     return this.getLabelInLang(
       labels,
       this.hsLanguageService.getCurrentLanguageCode('default')

+ 3 - 3
src/adjuster/dataset-item/dataset-item.component.html

@@ -2,12 +2,12 @@
   [ngClass]="dataset.included ? 'hs-checkmark' : 'hs-uncheckmark'"
   (click)="dataset.included = !dataset.included;$event.stopPropagation()"></button>
 <!--span class="glyphicon cursor-pointer text-secondary"
-[ngClass]="descriptionVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
-(click)="descriptionVisible = !descriptionVisible"></span-->
+  [ngClass]="descriptionVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
+  (click)="descriptionVisible = !descriptionVisible"></span-->
 <label class="ps-2 text-secondary"><a class="text-decoration-none"
     (click)="dataset.included = !dataset.included;$event.stopPropagation()">{{getLabelInCurrentLang(dataset.labels)}}</a></label>
 &nbsp;
 <i class="icon-opennewwindow cursor-pointer text-info" (click)="showMetadataWindow(dataset)"></i>
 <!--div class="p-2 mb-2 text-info" [hidden]="!descriptionVisible">
-{{dataset.desc}}
+  {{dataset.desc}}
 </div-->

+ 4 - 4
src/adjuster/dataset-list/dataset-list.component.html

@@ -1,15 +1,15 @@
 <div class="d-flex flex-row">
   <div class="p-2 flex-grow-1">
     <span class="glyphicon cursor-pointer"
-      [ngClass]="datasetlistVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
-      (click)="datasetlistVisible = !datasetlistVisible"></span>
-    <label class="ps-2 cursor-pointer" (click)="datasetlistVisible = !datasetlistVisible">{{getLabelInCurrentLang(factor.labels)}}</label>
+      [ngClass]="datasetListVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
+      (click)="datasetListVisible = !datasetListVisible"></span>
+    <label class="ps-2 cursor-pointer" (click)="datasetListVisible = !datasetListVisible">{{getLabelInCurrentLang(factor.labels)}}</label>
   </div>
   <div class="p-2">{{(factor.weight * 100).toFixed(0)}}&nbsp;%</div>
 </div>
 <input type="range" class="form-range" [(ngModel)]="factor.weight" min="0"
   max="1.0" step="0.05">
-<div [hidden]="!datasetlistVisible">
+<div [hidden]="!datasetListVisible">
   <div *ngFor="let dataset of factor.datasets">
     <pra-dataset-item [dataset]="dataset"></pra-dataset-item>
   </div>

+ 3 - 3
src/adjuster/dataset-list/dataset-list.component.ts

@@ -2,7 +2,7 @@ import {Component, Input} from '@angular/core';
 
 import {HsDialogContainerService} from 'hslayers-ng';
 
-import {AdjusterPresetsService} from '../adjuster-presets.service';
+import {AdjusterPresetsService, Factor} from '../adjuster-presets.service';
 
 @Component({
   selector: 'pra-dataset-list',
@@ -10,8 +10,8 @@ import {AdjusterPresetsService} from '../adjuster-presets.service';
   styleUrls: ['./dataset-list.component.scss'],
 })
 export class DatasetListComponent {
-  @Input() factor;
-  datasetlistVisible = false;
+  @Input() factor: Factor;
+  datasetListVisible = false;
   constructor(
     public adjusterPresetsService: AdjusterPresetsService,
     public hsDialogContainerService: HsDialogContainerService

+ 16 - 12
src/adjuster/metadata-dialog/metadata-dialog.component.ts

@@ -4,11 +4,21 @@ import {HsDialogComponent, HsDialogContainerService} from 'hslayers-ng';
 
 import {MetadataDialogService} from './metadata-dialog.service';
 
+export type DatasetDescriptor = {
+  id: string;
+  coverage?: string;
+  desc?: string;
+  link?: string;
+  lod?: string;
+  source?: string;
+  title?: string;
+  update?: string;
+};
+
 @Component({
   selector: 'pra-metadata-dialog',
   templateUrl: './metadata-dialog.component.html' 
 })
-
 export class MetadataDialogComponent implements HsDialogComponent, OnInit {
   viewRef: ViewRef;
   data: DatasetDescriptor;
@@ -16,22 +26,16 @@ export class MetadataDialogComponent implements HsDialogComponent, OnInit {
   constructor(
     public hsDialogContainerService: HsDialogContainerService,
     public metadataDialogService: MetadataDialogService
-    ) {}
+  ) {}
 
   ngOnInit() {
-    this.data = this.metadataDialogService.loadDatasetMetadata(this.data.title);
+    const newData = this.metadataDialogService.loadDatasetMetadata(
+      this.data.id
+    );
+    this.data = {...this.data, ...newData};
   }
 
   close(): void {
     this.hsDialogContainerService.destroy(this);
   }
 }
-
-export type DatasetDescriptor = {
-  title: string;
-  coverage?: string;
-  link?: string;
-  lod?: string;
-  source?: string;
-  update?: string;
-};

+ 29 - 11
src/adjuster/metadata-dialog/metadata-dialog.service.ts

@@ -11,19 +11,37 @@ export class MetadataDialogService {
   constructor(public adjusterPresetsService: AdjusterPresetsService) {
     this.ontology = this.adjusterPresetsService.ontology;
   }
-  
-  loadDatasetMetadata(datasetName: string): DatasetDescriptor {
-    console.log(this.ontology);
-    const ontoInfo = this.ontology.find((subject) => subject['http://www.w3.org/2000/01/rdf-schema#label']?.find((label) => label['@value']?.includes(datasetName)))
-    console.log(ontoInfo);
+
+  loadDatasetMetadata(datasetId: string): DatasetDescriptor {
+    const ontoInfo = this.ontology.find(
+      (subject) => subject['@id'] === datasetId
+    );
     //TODO: the returned values must reflect possibility of multi-values (e.g. coverage CZ + EU)
     return {
-      title: datasetName,
-      coverage: ontoInfo['http://www.semanticweb.org/attractiveness/hasCoverage'][0]['@id'] ?? null,
-      link: ontoInfo['http://www.semanticweb.org/attractiveness/link'][0]['@value'] ?? null,
-      lod: ontoInfo['http://www.semanticweb.org/attractiveness/hasLoD'][0]['@id'] ?? null,
-      source: ontoInfo['http://www.semanticweb.org/attractiveness/hasSource'][0]['@id'] ?? null,
-      update: ontoInfo['http://www.semanticweb.org/attractiveness/update'][0]['@value'] ?? null
+      id: datasetId,
+      title: this.adjusterPresetsService.getLabelInCurrentLang(
+        ontoInfo['http://www.w3.org/2000/01/rdf-schema#label'] ?? null
+      ),
+      coverage:
+        ontoInfo['http://www.semanticweb.org/attractiveness/hasCoverage']?.[0][
+          '@id'
+        ] ?? null,
+      link:
+        ontoInfo['http://www.semanticweb.org/attractiveness/link']?.[0][
+          '@value'
+        ] ?? null,
+      lod:
+        ontoInfo['http://www.semanticweb.org/attractiveness/hasLoD']?.[0][
+          '@id'
+        ] ?? null,
+      source:
+        ontoInfo['http://www.semanticweb.org/attractiveness/hasSource']?.[0][
+          '@id'
+        ] ?? null,
+      update:
+        ontoInfo['http://www.semanticweb.org/attractiveness/update']?.[0][
+          '@value'
+        ] ?? null,
     };
   }
 }