Skip to content
Snippets Groups Projects
Commit 0c512c28 authored by ncastejon's avatar ncastejon
Browse files

Add 'Others' resource category in the resources tab (dataset data section)

parent b7eb2936
Branches
Tags
No related merge requests found
Pipeline #
...@@ -75,6 +75,29 @@ ...@@ -75,6 +75,29 @@
</ng-container> </ng-container>
</div> </div>
<div class="columns is-multiline" *ngIf="otherResources.length > 0">
<div class="column is-12 title-resource" (click)="otherPanelOpen = !otherPanelOpen">
<span class="icon">
<i class="far fa-arrow-alt-circle-down fa-lg"></i>
</span>
Other Resources
<div class="open-close">
<span class="icon" *ngIf="otherPanelOpen">
<i class="fas fa-minus fa-lg"></i>
</span>
<span class="icon" *ngIf="!otherPanelOpen">
<i class="fas fa-plus fa-lg"></i>
</span>
</div>
</div>
<ng-container *ngIf="otherPanelOpen">
<div class="column is-12 resource" *ngFor="let metadataLink of otherResources">
<div><strong>{{ metadataLink.name }}</strong></div>
<div>{{ metadataLink.url }}</div>
</div>
</ng-container>
</div>
<app-license-modal (close)="toggleLicenseModal()" [isOpen]="displayLicenseModal"></app-license-modal> <app-license-modal (close)="toggleLicenseModal()" [isOpen]="displayLicenseModal"></app-license-modal>
</ng-container> </ng-container>
...@@ -20,10 +20,12 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy { ...@@ -20,10 +20,12 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy {
// To display in the template // To display in the template
queryableResources: Resource[]; queryableResources: Resource[];
downloadableResources: Resource[]; downloadableResources: Resource[];
otherResources: IMetadataLink[];
// Variables for open/use resources panels // Variables for open/use resources panels
queryablePanelOpen = true; queryablePanelOpen = true;
downloadablePanelOpen = true; downloadablePanelOpen = true;
otherPanelOpen = true;
constructor( constructor(
private _datasetDetailService: DatasetDetailService, private _datasetDetailService: DatasetDetailService,
...@@ -33,8 +35,8 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy { ...@@ -33,8 +35,8 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.queryableResources = []; this.queryableResources = [];
this.downloadableResources = []; this.downloadableResources = [];
this.otherResources = [];
console.log('ng on inits');
this.initialize(); this.initialize();
this._resourcesService.getResources().subscribe((resources) => { this._resourcesService.getResources().subscribe((resources) => {
this.resources = resources; this.resources = resources;
...@@ -49,22 +51,33 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy { ...@@ -49,22 +51,33 @@ export class DatasetResourcesComponent implements OnInit, OnDestroy {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
// Resources are organized in 3 categories:
// - queryable
// - downloadable
// - other
// How to organize: we compare the type of one resource from our resource service
// and the ES metadata link property. If there is a match, the service will let us know if the resource
// is queryable or downloadable. If there is no match and the ES resource cannot be found in the service,
// we put it in "others" resources catagory.
initialize() { initialize() {
//
console.log(this.resources);
this.metadata = this._datasetDetailService.datasetMetadata; this.metadata = this._datasetDetailService.datasetMetadata;
if (this.metadata !== undefined && this.resources !== undefined) { if (this.metadata !== undefined && this.resources !== undefined) {
this.metadata.link.forEach((link) => { this.metadata.link.forEach((link) => {
let metadataLinkFound = false;
this.resources.forEach((resource) => { this.resources.forEach((resource) => {
if (link.protocol === resource.type) { if (link.protocol === resource.type) {
metadataLinkFound = true;
resource.metadataLink = link; resource.metadataLink = link;
if (resource.queryable) { if (resource.queryable) {
this.queryableResources.push(resource); this.queryableResources.push(resource);
} else { } else if (resource.downloadable) {
this.downloadableResources.push(resource); this.downloadableResources.push(resource);
} }
} }
}); });
if (! metadataLinkFound) {
this.otherResources.push(link);
}
}); });
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment