Skip to content

Commit

Permalink
Merge branch 'feature/asset_details' into 'develop'
Browse files Browse the repository at this point in the history
feature/asset_details

See merge request upm-inesdata/inesdata-connector-interface!32
  • Loading branch information
sasierrassis committed Aug 29, 2024
2 parents bd19999 + a1e6a54 commit 7c9f91d
Show file tree
Hide file tree
Showing 8 changed files with 407 additions and 66 deletions.
3 changes: 3 additions & 0 deletions src/app/pages/assets/asset-viewer/asset-viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

<mat-divider></mat-divider>
<mat-card-actions class="card-actions">
<button (click)="viewAsset(asset)" [disabled]="isBusy()" color="info" mat-stroked-button>
<mat-icon>info</mat-icon> View asset
</button>
<button (click)="onDelete(asset)" [disabled]="isBusy()" color="warn" mat-stroked-button>
<mat-icon>delete_sweep</mat-icon> Delete
</button>
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/assets/asset-viewer/asset-viewer.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ mat-paginator {
align-items: center;
gap: 10px; /* Adjust the gap between elements */
}

.card-actions button{
margin-right: 10px;
}
33 changes: 31 additions & 2 deletions src/app/pages/assets/asset-viewer/asset-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { AssetService } from "../../../shared/services/asset.service";
import { AssetEditorDialog } from "../asset-editor-dialog/asset-editor-dialog.component";
import { ConfirmationDialogComponent, ConfirmDialogModel } from "../../../shared/components/confirmation-dialog/confirmation-dialog.component";
import { NotificationService } from "../../../shared/services/notification.service";
import { DATA_ADDRESS_TYPES } from 'src/app/shared/utils/app.constants';
import { CONTEXTS, DATA_ADDRESS_TYPES } from 'src/app/shared/utils/app.constants';
import { PageEvent } from '@angular/material/paginator';
import { QuerySpec } from '@think-it-labs/edc-connector-client';
import { EDC_CONTEXT, QuerySpec, DataAddress } from '@think-it-labs/edc-connector-client';
import { ContractOffersViewerComponent } from '../../catalog/contract-offers-viewer/contract-offers-viewer.component';
import { compact } from 'jsonld';

@Component({
selector: 'app-asset-viewer',
Expand All @@ -28,6 +30,14 @@ export class AssetViewerComponent implements OnInit {
currentPage = 0;
paginatorLength = 0;

CONTEXT = {
"@vocab": EDC_CONTEXT,
"description": "http://purl.org/dc/terms/description",
"format": "http://purl.org/dc/terms/format",
"byteSize": "http://www.w3.org/ns/dcat#byteSize",
"keywords": "http://www.w3.org/ns/dcat#keyword"
}

constructor(private assetService: AssetService,
private notificationService: NotificationService,
private readonly dialog: MatDialog) {
Expand Down Expand Up @@ -68,6 +78,25 @@ export class AssetViewerComponent implements OnInit {
});
}

viewAsset(asset: Asset) {
compact(asset, this.CONTEXT).then(compactedAsset => {
this.dialog.open(ContractOffersViewerComponent, {
data: {
assetId: compactedAsset['@id'],
properties: compactedAsset.properties,
privateProperties: compactedAsset.privateProperties,
dataAddress: compactedAsset.dataAddress,
isCatalogView: false
},
disableClose: true
});
})
.catch(error => {
this.notificationService.showError("Error compacting JsonLD");
});

}

onCreate() {
const dialogRef = this.dialog.open(AssetEditorDialog, { disableClose: true });
dialogRef.afterClosed().pipe(first()).subscribe((result: { assetInput?: AssetInput }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export class CatalogBrowserComponent implements OnInit {
assetId: assetId,
contractOffers: contractOffers,
endpointUrl: endpointUrl,
properties: properties
properties: properties,
isCatalogView: true
},
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,187 @@
<h2 mat-dialog-title>Contract Offers - {{data.assetId}} </h2>
<mat-dialog-content>
<mat-tab-group>
<mat-tab label="Asset information">
<mat-tab-group>
<mat-tab label="General information">
<mat-card class="dialog-card">
<div fxLayout="row" fxLayoutGap="15px">
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Id</div>
<div class="property-value" matListItemLine>{{data.properties.id}}</div>
</mat-list-item>
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Name</div>
<div class="property-value" matListItemLine>{{data.properties.name}}</div>
</mat-list-item>
</div>
<div fxLayout="row" fxLayoutGap="15px">
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Content-Type</div>
<div class="property-value"
[ngClass]="{'value-not-available': data.properties.contentType === undefined || data.properties.contentType === ''}"
matListItemLine>{{data.properties.contentType ? data.properties.contentType : 'Not available'}}</div>
</mat-list-item>
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Version</div>
<div class="property-value" matListItemLine>{{data.properties.version}}</div>
</mat-list-item>
</div>
<div fxLayout="row">
<mat-list-item class="property">
<div class="property-title" matListItemTitle>Short description</div>
<div class="property-value description" matListItemLine>{{data.properties.shortDescription}}</div>
</mat-list-item>
</div>
<div fxLayout="row">
<mat-list-item class="property">
<div class="property-title" matListItemTitle>Description</div>
<div class="property-value description" [innerHTML]="data.properties.description" matListItemLine></div>
</mat-list-item>
</div>
<div fxLayout="row" fxLayoutGap="15px">
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Asset type</div>
<div class="property-value" matListItemLine>{{data.properties.assetType}}</div>
</mat-list-item>
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Keywords</div>
<div class="property-value" matListItemLine>{{data.properties.keywords}}</div>
</mat-list-item>
</div>
<div fxLayout="row" fxLayoutGap="15px">
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>Byte size</div>
<div class="property-value"
[ngClass]="{'value-not-available': data.properties.byteSize === undefined || data.properties.contentType === ''}"
matListItemLine>{{data.properties.byteSize ? data.properties.byteSize : 'Not available'}}</div>
</mat-list-item>
<mat-list-item class="property" fxFlex="50">
<div class="property-title" matListItemTitle>File format</div>
<div class="property-value"
[ngClass]="{'value-not-available': data.properties.fileFormat === undefined || data.properties.contentType === ''}"
matListItemLine>{{data.properties.fileFormat ? data.properties.fileFormat : 'Not available'}}</div>
</mat-list-item>
</div>
</mat-card>
</mat-tab>
<mat-tab *ngFor="let key of assetDataKeys" [label]="key">
<mat-card class="dialog-card vocabulary">
<div *ngFor="let item of assetDataEntries[key]" class="grey">
<ng-container *ngIf="item.isArray; else objectOrPlainValue">
<ng-container *ngIf="containsOnlyObjects(item.value); else simpleList">
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title class="property-title">{{item.key}}</mat-panel-title>
</mat-expansion-panel-header>
<div class="details">
<ng-container *ngFor="let subItem of item.value">
<div class="detail-item">
<ng-container *ngFor="let subEntry of getEntries(subItem)">
<div>
<span class="property-title">{{ subEntry.key }}: </span> <span class="property-value">{{
subEntry.value }}</span>
</div>
</ng-container>
</div>
</ng-container>
</div>
</mat-expansion-panel>
</ng-container>
<ng-template #simpleList>
<span class="property-title">{{ item.key }}:</span>
<ul>
<li *ngFor="let subItem of item.value">
<ng-container *ngIf="!isObject(subItem)">
<span class="property-value">{{ subItem }}</span>
</ng-container>
</li>
</ul>
</ng-template>
</ng-container>
<ng-template #objectOrPlainValue>
<ng-container *ngIf="item.isObject; else plainValue">
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>
<mat-panel-title class="property-title">{{item.key}}</mat-panel-title>
</mat-expansion-panel-header>
<ng-container *ngFor="let subEntry of item.entries">
<div>
<span class="property-title">{{ subEntry.key }}: </span> <span class="property-value">{{
subEntry.value }}</span>
</div>
</ng-container>
</mat-expansion-panel>
</ng-container>
<ng-template #plainValue>
<div>
<span class="property-title">{{ item.key }}:</span> <span class="property-value"> {{ item.value
}}</span>
</div>
</ng-template>
</ng-template>
</div>
</mat-card>
</mat-tab>
<ng-container *ngIf="!data.isCatalogView">
<mat-tab label="Storage information">
<mat-card class="dialog-card">
<div fxLayout="row">
<mat-list-item class="property">
<div class="property-title" matListItemTitle>Storage type</div>
<div class="property-value" matListItemLine>{{ dataAddressType }}</div>
</mat-list-item>
</div>
<ng-container *ngIf="data.privateProperties; else dataAddressProperties">
<div fxLayout="row">
<mat-list-item class="property">
<div class="property-title" matListItemTitle>File</div>
<div class="property-value" matListItemLine>{{ data.dataAddress.keyName }}</div>
</mat-list-item>
</div>
</ng-container>
<ng-template #dataAddressProperties>
<div fxLayout="row wrap" fxLayoutGap="15px">
<ng-container *ngFor="let property of data.dataAddress | keyvalue">
<div fxFlex="1 1 calc(50% - 15px)" *ngIf="property.key != 'type'">
<mat-list-item class="property">
<div class="property-title" matListItemTitle>{{ property.key }}</div>
<div class="property-value" matListItemLine>{{ property.value }}</div>
</mat-list-item>
</div>
</ng-container>
</div>
</ng-template>
</mat-card>
</mat-tab>
</ng-container>
</mat-tab-group>
</mat-tab>
<ng-container *ngIf="data.isCatalogView">
<mat-tab label="Contract Offers">
<mat-card class="dialog-card contract-offer" *ngFor="let contractOffer of data.contractOffers" >
<mat-card-content>
<pre class="json-policy break-all">{{ getJsonPolicy(contractOffer) | json }}</pre>
</mat-card-content>
<mat-card-actions align="end">
<button mat-stroked-button color="accent" [disabled]="isBusy(contractOffer) || isNegotiated(contractOffer)"
(click)="onNegotiateClicked(contractOffer)">
<mat-icon>drive_file_rename_outline</mat-icon>
Negotiate Contract
</button>
</mat-card-actions>
<mat-card-footer>
<mat-progress-bar diameter="10" mode="indeterminate" color="accent" *ngIf="isBusy(contractOffer)">
</mat-progress-bar>
</mat-card-footer>
</mat-card>
</mat-tab>
</ng-container>
</mat-tab-group>
</mat-dialog-content>

<mat-dialog-content>
<div fxLayout="column" fxLayoutAlign="stretch" fxLayoutGap="15px">
<mat-card class="dialog-card">
<mat-card-title>
Properties
</mat-card-title>
<div fxLayout="row" fxLayoutGap="15px">
<mat-list-item class="property" fxFlex="33" *ngIf="data.properties.version">
<mat-icon class="property-icon" matListItemIcon>numbers</mat-icon>
<div class="property-title" matListItemTitle>Version</div>
<div class="property-value" matListItemLine>{{data.properties.version}}</div>
</mat-list-item>
<mat-list-item class="property" fxFlex="33" *ngIf="data.properties.contentType">
<mat-icon class="property-icon" matListItemIcon>content_paste</mat-icon>
<div class="property-title" matListItemTitle>Content-Type</div>
<div class="property-value" matListItemLine>{{data.properties.contentType}}</div>
</mat-list-item>
</div>
</mat-card>

<mat-card class="dialog-card" *ngFor="let contractOffer of data.contractOffers">
<mat-card-title>
Contract offer
</mat-card-title>
<mat-card-content>
<pre class="json-policy break-all">{{ getJsonPolicy(contractOffer) | json }}</pre>
</mat-card-content>
<mat-card-actions align="end">
<button mat-stroked-button color="accent"
[disabled]="isBusy(contractOffer) || isNegotiated(contractOffer)"
(click)="onNegotiateClicked(contractOffer)">
<mat-icon>drive_file_rename_outline</mat-icon>
Negotiate Contract
</button>
</mat-card-actions>
<mat-card-footer>
<mat-progress-bar diameter="10" mode="indeterminate" color="accent" *ngIf="isBusy(contractOffer)">
</mat-progress-bar>
</mat-card-footer>
</mat-card>
</div>
</mat-dialog-content>

<mat-dialog-actions>
<button color="accent" mat-dialog-close mat-stroked-button>
<mat-icon>cancel</mat-icon>
close
</button>
</mat-dialog-actions>
<mat-dialog-actions>
<button color="accent" mat-dialog-close mat-stroked-button>
<mat-icon>cancel</mat-icon>
close
</button>
</mat-dialog-actions>
Loading

0 comments on commit 7c9f91d

Please sign in to comment.