Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap 3290 add tab scientific json metadata #1400

Merged
merged 12 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CI/ESS/e2e/config.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"addDatasetEnabled": true,
"archiveWorkflowEnabled": false,
"datasetReduceEnabled": true,
"datasetJsonScientificMetadata": true,
"editDatasetSampleEnabled": true,
"editMetadataEnabled": true,
"editPublishedData": false,
Expand Down Expand Up @@ -107,7 +108,10 @@
"multipleDownloadAction": "https://scicatfileserver.esss.dk/zip",
"multipleDownloadEnabled": true,
"oAuth2Endpoints": [
{ "authURL": "api/v3/auth/oidc", "displayText": "ESS One Identity" }
{
"authURL": "api/v3/auth/oidc",
"displayText": "ESS One Identity"
}
],
"policiesEnabled": true,
"retrieveDestinations": [],
Expand All @@ -123,4 +127,4 @@
"tableSciDataEnabled": true,
"datasetDetailsShowMissingProposalId": false,
"notificationInterceptorEnabled": true
}
}
1 change: 1 addition & 0 deletions src/app/app-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const appConfig: AppConfig = {
addDatasetEnabled: true,
archiveWorkflowEnabled: true,
datasetReduceEnabled: true,
datasetJsonScientificMetadata: true,
editDatasetSampleEnabled: true,
editMetadataEnabled: true,
editPublishedData: true,
Expand Down
1 change: 1 addition & 0 deletions src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface AppConfig {
accessTokenPrefix: string;
addDatasetEnabled: boolean;
archiveWorkflowEnabled: boolean;
datasetJsonScientificMetadata: boolean;
datasetReduceEnabled: boolean;
editDatasetSampleEnabled: boolean;
editMetadataEnabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LeavingPageGuard } from "app-routing/pending-changes.guard";
import { ServiceGuard } from "app-routing/service.guard";
import { AdminTabComponent } from "datasets/admin-tab/admin-tab.component";
import { DatafilesComponent } from "datasets/datafiles/datafiles.component";
import { JsonScientificMetadataComponent } from "datasets/jsonScientificMetadata/jsonScientificMetadata.component";
import { DatasetDetailComponent } from "datasets/dataset-detail/dataset-detail.component";
import { DatasetFileUploaderComponent } from "datasets/dataset-file-uploader/dataset-file-uploader.component";
import { DatasetLifecycleComponent } from "datasets/dataset-lifecycle/dataset-lifecycle.component";
Expand All @@ -18,6 +19,10 @@ const routes: Routes = [
component: DatasetDetailComponent,
canDeactivate: [LeavingPageGuard],
},
{
path: "jsonScientificMetadata",
component: JsonScientificMetadataComponent,
},
{
path: "datafiles",
component: DatafilesComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface FileObject {
}
enum TAB {
details = "Details",
jsonScientificMetadata = "Scientific Metadata (JSON)",
datafiles = "Datafiles",
relatedDatasets = "Related Datasets",
reduce = "Reduce",
Expand Down Expand Up @@ -92,6 +93,7 @@ export class DatasetDetailsDashboardComponent

fetchDataActions: { [tab: string]: { action: any; loaded: boolean } } = {
[TAB.details]: { action: fetchDatasetAction, loaded: false },
[TAB.jsonScientificMetadata]: { action: fetchDatasetAction, loaded: false },
[TAB.relatedDatasets]: {
action: fetchRelatedDatasetsAction,
loaded: false,
Expand Down Expand Up @@ -149,6 +151,13 @@ export class DatasetDetailsDashboardComponent
icon: "menu",
enabled: true,
},
{
location: "./jsonScientificMetadata",
label: TAB.jsonScientificMetadata,
icon: "schema",
enabled:
this.appConfig.datasetJsonScientificMetadata && isLoggedIn,
},
{
location: "./datafiles",
label: TAB.datafiles,
Expand Down
3 changes: 3 additions & 0 deletions src/app/datasets/datasets.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { DatasetDetailsDashboardComponent } from "./dataset-details-dashboard/da
import { DashboardComponent } from "./dashboard/dashboard.component";
import { DatablocksComponent } from "./datablocks-table/datablocks-table.component";
import { DatafilesComponent } from "./datafiles/datafiles.component";
import { JsonScientificMetadataComponent } from "./jsonScientificMetadata/jsonScientificMetadata.component";
import { DatasetDetailComponent } from "./dataset-detail/dataset-detail.component";
import { DatasetTableComponent } from "./dataset-table/dataset-table.component";
import { DatasetsFilterComponent } from "./datasets-filter/datasets-filter.component";
Expand Down Expand Up @@ -140,6 +141,7 @@ import { RelatedDatasetsComponent } from "./related-datasets/related-datasets.co
BatchViewComponent,
DashboardComponent,
DatablocksComponent,
JsonScientificMetadataComponent,
DatafilesComponent,
DatasetDetailComponent,
DatasetTableComponent,
Expand Down Expand Up @@ -174,6 +176,7 @@ import { RelatedDatasetsComponent } from "./related-datasets/related-datasets.co
exports: [
DashboardComponent,
DatablocksComponent,
JsonScientificMetadataComponent,
DatafilesComponent,
DatasetDetailComponent,
DatasetTableComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@use "@angular/material" as mat;

@mixin color($theme) {
$color-config: map-get($theme, "color");
$warn-2: map-get($color-config, "warn-2");

.warning-icon {
color: mat.get-color-from-palette($warn-2, "default");
}
}

@mixin theme($theme) {
$color-config: map-get($theme, "color");
@if $color-config != null {
@include color($theme);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ng-template [ngIf]="dataset$ | async">
<div fxLayout="row" fxLayout.xs="column" *ngIf="dataset$">
<div fxFlex="100%">
<mat-card *ngIf="true && editingAllowed && appConfig.jsonMetadataEnabled">
<mat-card-content>
<ngx-json-viewer [json]="datasetWithout$ | async" [expanded]="false">
</ngx-json-viewer>
</mat-card-content>
</mat-card>
</div>
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
mat-icon {
vertical-align: middle;
}

.selected {
margin-left: 2em;
}

.datafiles-header {
margin-top: 1em;

.nbr-of-files {
font-size: larger;
}

.download-button {
margin: 0 0 1em 1em;
float: right;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, ChangeDetectorRef, AfterViewChecked } from "@angular/core";
import { Store } from "@ngrx/store";
import {
selectCurrentDataset,
selectCurrentDatasetWithOnlyScientificMetadataKey,
} from "state-management/selectors/datasets.selectors";
import { AppConfigService } from "app-config.service";

@Component({
selector: "jsonScientificMetadata",
templateUrl: "./jsonScientificMetadata.component.html",
styleUrls: ["./jsonScientificMetadata.component.scss"],
})
export class JsonScientificMetadataComponent implements AfterViewChecked {
dataset$ = this.store.select(selectCurrentDataset);
datasetWithout$ = this.store.select(
selectCurrentDatasetWithOnlyScientificMetadataKey,
);

editingAllowed = true;
show = false;
appConfig = this.appConfigService.getConfig();

constructor(
public appConfigService: AppConfigService,
private store: Store,
private cdRef: ChangeDetectorRef,
) {
console.log({ dataset: this.dataset$ });
console.log({ datasetWithout: this.datasetWithout$ });
}

ngAfterViewChecked() {
this.cdRef.detectChanges();
}
}
2 changes: 2 additions & 0 deletions src/app/shared/sdk/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface DatasetInterface {
origdatablocks?: OrigDatablock[];
attachments?: Attachment[];
instrument?: Instrument;
scientificMetadata?: any
}

export class Dataset implements DatasetInterface {
Expand Down Expand Up @@ -99,6 +100,7 @@ export class Dataset implements DatasetInterface {
origdatablocks: OrigDatablock[];
attachments: Attachment[];
instrument: Instrument;
scientificMetadata?: any;
constructor(data?: DatasetInterface) {
Object.assign(this, data);
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/state-management/selectors/datasets.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ export const selectCurrentDatasetWithoutFileInfo = createSelector(
},
);

export const selectCurrentDatasetWithOnlyScientificMetadataKey = createSelector(
selectCurrentDataset,
(currentSet) => {
if (currentSet) {
return currentSet?.scientificMetadata;
}
return undefined;
},
);

export const selectCurrentOrigDatablocks = createSelector(
selectCurrentDataset,
(dataset) => (dataset ? dataset.origdatablocks : []),
Expand Down
8 changes: 6 additions & 2 deletions src/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"addDatasetEnabled": true,
"archiveWorkflowEnabled": false,
"datasetReduceEnabled": true,
"datasetJsonScientificMetadata": true,
"editDatasetSampleEnabled": true,
"editMetadataEnabled": true,
"editPublishedData": false,
Expand Down Expand Up @@ -113,7 +114,10 @@
"multipleDownloadAction": "http://localhost:3012/zip",
"multipleDownloadEnabled": true,
"oAuth2Endpoints": [
{ "authURL": "api/v3/auth/oidc", "displayText": "ESS One Identity" }
{
"authURL": "api/v3/auth/oidc",
"displayText": "ESS One Identity"
}
],
"policiesEnabled": true,
"retrieveDestinations": [],
Expand All @@ -128,4 +132,4 @@
"shoppingCartOnHeader": true,
"tableSciDataEnabled": true,
"datasetDetailsShowMissingProposalId": false
}
}
Loading