From d79d7e91032ecd9ba1cebe0b2b3a9f1020c2bc35 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 4 Feb 2025 14:41:09 +0100 Subject: [PATCH 01/18] Solved conflicts from merging with master --- package.json | 2 +- src/app/app-config.service.ts | 4 +-- .../dataset-detail.component.ts | 2 +- .../proposal-detail.component.ts | 8 +++++- .../shared/loaders/custom-translate.loader.ts | 2 +- src/app/state-management/models/index.ts | 6 +++-- src/assets/config.json | 27 +++++++++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index e7b567fa8..2783c36a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scicat-frontend", - "version": "4.5.0", + "version": "local.dev", "license": "BSD-3-Clause", "scripts": { "ng": "ng", diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index 326b7e474..1724f252d 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -3,9 +3,9 @@ import { Injectable } from "@angular/core"; import { timeout } from "rxjs/operators"; import { DatasetDetailComponentConfig, - DatasetDetailViewLabelOption, DatasetsListSettings, LabelMaps, + LabelsLocalization, TableColumn, } from "state-management/models"; @@ -103,8 +103,8 @@ export interface AppConfig { labelMaps: LabelMaps; thumbnailFetchLimitPerPage: number; maxFileUploadSizeInMb?: string; - datasetDetailViewLabelOption?: DatasetDetailViewLabelOption; datasetDetailComponent?: DatasetDetailComponentConfig; + labelsLocalization?: LabelsLocalization; } @Injectable() diff --git a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts index 815ba282d..c49fda473 100644 --- a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts @@ -98,7 +98,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { private fb: FormBuilder, ) { this.translateService.use( - this.appConfig.datasetDetailViewLabelOption?.currentLabelSet, + this.appConfig.labelsLocalization?.currentLabelSet["dataset-default"], ); } diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.ts b/src/app/proposals/proposal-detail/proposal-detail.component.ts index fdeaa28a8..4b11f4c7c 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.ts +++ b/src/app/proposals/proposal-detail/proposal-detail.component.ts @@ -21,6 +21,7 @@ import { selectProfile, } from "state-management/selectors/user.selectors"; import { clearProposalsStateAction } from "state-management/actions/proposals.actions"; +import { TranslateService } from "@ngx-translate/core"; @Component({ selector: "proposal-detail", @@ -46,9 +47,14 @@ export class ProposalDetailComponent implements OnInit, OnDestroy { constructor( public appConfigService: AppConfigService, + private translateService: TranslateService, private store: Store, private router: Router, - ) {} + ) { + this.translateService.use( + this.appConfig.labelsLocalization?.currentLabelSet["proposal"], + ); + } ngOnInit(): void { // Prevent user from reloading page if there are unsave changes diff --git a/src/app/shared/loaders/custom-translate.loader.ts b/src/app/shared/loaders/custom-translate.loader.ts index 5fb29aa38..07360bdfb 100644 --- a/src/app/shared/loaders/custom-translate.loader.ts +++ b/src/app/shared/loaders/custom-translate.loader.ts @@ -9,7 +9,7 @@ export class CustomTranslateLoader implements TranslateLoader { getTranslation(): Observable { const { currentLabelSet = "", labelSets = {} } = - this.appConfig.datasetDetailViewLabelOption || {}; + this.appConfig?.labelsLocalization || {}; if (currentLabelSet in labelSets) { return of(labelSets[currentLabelSet]); diff --git a/src/app/state-management/models/index.ts b/src/app/state-management/models/index.ts index 234e434a4..aa856dd51 100644 --- a/src/app/state-management/models/index.ts +++ b/src/app/state-management/models/index.ts @@ -21,10 +21,12 @@ export interface LabelMaps { [key: string]: Record; } -export interface DatasetDetailViewLabelOption { +export interface LabelsLocalization { currentLabelSet: string; labelSets: { - [key: string]: Record; + [key: string]: { + [key: string]: Record; + }; }; } diff --git a/src/assets/config.json b/src/assets/config.json index 96518ad9d..eea2cd6c1 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -205,5 +205,32 @@ { "TextFilter": true } ], "conditions": [] + }, + "labelsLocalization": { + "currentLabelSet": "ess", + "labelSets": { + "ess": { + "dataset-default": {}, + "dataset-custom" : { + "pid": "PID", + "description": "Description", + "principalInvestigator": "Principal Investigator", + "keywords": "Keywords", + "creationTime": "Creation Time", + "scientificMetadata": "Scientific Metadata", + "metadataJsonView": "Metadata JsonView" + }, + "proposal" : { + "General Information": "Proposal Information", + "Title" : "Proposal Title", + "Abstract" : "Abstract", + "Identifier" : "Proposal Id", + "Type" : "Proposal Type", + "Creator Information" : "People", + "Main Proposer": "Proposal Submitted By", + "Metadata": "Additional Information" + } + } + } } } From e314d45b3de7e3c7d3753ba163e0a814d206c111 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 4 Feb 2025 14:42:36 +0100 Subject: [PATCH 02/18] more conflicts solved --- .../proposal-detail.component.html | 56 +++++++++---------- src/app/proposals/proposals.module.ts | 2 + src/assets/config.json | 8 ++- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 6c07a0962..7eef34edf 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -4,23 +4,41 @@
description
- General Information + {{ "General Information" | translate }} - + - + - + + + + + + + + + + - + @@ -49,29 +67,11 @@ let-last="last" > - + - - - - - - - - -
Title{{ "Title" | translate }} {{ proposal.title }}
Abstract{{ "Abstract" | translate }} {{ proposal.abstract }}
Identifier{{ "Proposal Id" | translate }} {{ proposal.proposalId }}
{{ "Proposal Type" | translate }}{{ proposal["type"] }}
{{ "Parent proposal" | translate }} + {{ + parentProposal.title + }} +
Start Time{{ "Start Time" | translate }} {{ period.start | date }}
End Time{{ "End Time" | translate }} {{ period.end | date }}
Type{{ proposal["type"] }}
Parent proposal - {{ - parentProposal.title - }} -
@@ -81,13 +81,13 @@
person
- Creator Information + {{ "Creator Information" | translate }} - + - +
Main proposer{{ "Main proposer" | translate }} {{ proposal.firstname }} {{ proposal.lastname }}
Principal investigator{{ "Principal Investigator" | translate }} {{ proposal.pi_firstname }} {{ proposal.pi_lastname }} science - Metadata + {{ "Metadata" | translate }} diff --git a/src/app/proposals/proposals.module.ts b/src/app/proposals/proposals.module.ts index c718b7d2c..71bb4e59a 100644 --- a/src/app/proposals/proposals.module.ts +++ b/src/app/proposals/proposals.module.ts @@ -37,6 +37,7 @@ import { logbooksReducer } from "state-management/reducers/logbooks.reducer"; import { ProposalLogbookComponent } from "./proposal-logbook/proposal-logbook.component"; import { RelatedProposalsComponent } from "./related-proposals/related-proposals.component"; import { ProposalDatasetsComponent } from "./proposal-datasets/proposal-datasets.component"; +import { TranslateModule } from "@ngx-translate/core"; @NgModule({ imports: [ @@ -62,6 +63,7 @@ import { ProposalDatasetsComponent } from "./proposal-datasets/proposal-datasets SharedScicatFrontendModule, StoreModule.forFeature("proposals", proposalsReducer), StoreModule.forFeature("logbooks", logbooksReducer), + TranslateModule, ], declarations: [ ViewProposalPageComponent, diff --git a/src/assets/config.json b/src/assets/config.json index eea2cd6c1..534fecb24 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -224,10 +224,14 @@ "General Information": "Proposal Information", "Title" : "Proposal Title", "Abstract" : "Abstract", - "Identifier" : "Proposal Id", - "Type" : "Proposal Type", + "Proposal Id" : "Proposal Id", + "Proposal Type" : "Proposal Type", + "Parent Proposal" : "Parent Proposal", + "Start Time" : "Start Time", + "End Time" : "End Time", "Creator Information" : "People", "Main Proposer": "Proposal Submitted By", + "Principal Investigator" : "Principal Investigator", "Metadata": "Additional Information" } } From 1dd83b35f7ba304ee352714374621d512c0ddf20 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Fri, 24 Jan 2025 09:09:20 +0100 Subject: [PATCH 03/18] remove metadata edit for proposals --- .../proposal-detail.component.html | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 7eef34edf..60253e4f3 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -146,30 +146,6 @@ - - - edit Edit - -
- - - - -
-
From bcce2a5d7e92356ae370a4673948d8af5dcfaed9 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Fri, 24 Jan 2025 12:31:24 +0100 Subject: [PATCH 04/18] fixed proposal unit test --- .../proposal-detail.component.spec.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.spec.ts b/src/app/proposals/proposal-detail/proposal-detail.component.spec.ts index 890919ca7..dedd01543 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.spec.ts +++ b/src/app/proposals/proposal-detail/proposal-detail.component.spec.ts @@ -7,6 +7,17 @@ import { MatButtonModule } from "@angular/material/button"; import { NgxJsonViewerModule } from "ngx-json-viewer"; import { AppConfigService } from "app-config.service"; import { StoreModule } from "@ngrx/store"; +import { + TranslateLoader, + TranslateModule, + TranslationObject, +} from "@ngx-translate/core"; +import { Observable, of } from "rxjs"; +class MockTranslateLoader implements TranslateLoader { + getTranslation(): Observable { + return of({}); + } +} const getConfig = () => ({ jsonMetadataEnabled: true, @@ -25,12 +36,23 @@ describe("ProposalsDetailComponent", () => { MatIconModule, NgxJsonViewerModule, StoreModule.forRoot({}), + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: MockTranslateLoader, + }, + }), ], declarations: [ProposalDetailComponent], }); TestBed.overrideComponent(ProposalDetailComponent, { set: { - providers: [{ provide: AppConfigService, useValue: { getConfig } }], + providers: [ + { + provide: AppConfigService, + useValue: { getConfig }, + }, + ], }, }); TestBed.compileComponents(); From 6f2313978122fac6f249416073802fc5eb2d790e Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Mon, 3 Feb 2025 11:32:08 +0100 Subject: [PATCH 05/18] added metadata editing --- .../proposal-detail.component.html | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 60253e4f3..7eef34edf 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -146,6 +146,30 @@ + + + edit Edit + +
+ + + + +
+
From 3de080316cf39eef88ac943c5f5480b42f6c74a2 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Mon, 3 Feb 2025 14:06:34 +0100 Subject: [PATCH 06/18] solving test failing --- .../view-proposal-page/view-proposal-page.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts index dd937df6a..e4f3ec969 100644 --- a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts +++ b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts @@ -31,7 +31,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy { private translateService: TranslateService, ) { this.translateService.use( - this.appConfig.datasetDetailViewLabelOption?.currentLabelSet, + this.appConfig.labelsLocalization?.currentLabelSet["proposal"], ); } From 7cd383bd0f52892505832ce5e1b28d23973a1bef Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 4 Feb 2025 14:43:42 +0100 Subject: [PATCH 07/18] more conflicts --- .../proposal-detail.component.html | 24 +++++++++---------- .../view-proposal-page.component.ts | 2 +- .../shared/pipes/component-translate.pipe.ts | 15 ++++++++++++ src/app/shared/pipes/pipes.module.ts | 3 +++ src/assets/config.json | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 src/app/shared/pipes/component-translate.pipe.ts diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 7eef34edf..9aeed9280 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -4,25 +4,25 @@
description
- {{ "General Information" | translate }} + {{ "General Information" | componentTranslate:"proposal" }} - + - + - + - + @@ -32,7 +32,7 @@ | async as parentProposal " > - + - + @@ -67,7 +67,7 @@ let-last="last" > - + @@ -81,13 +81,13 @@
person
- {{ "Creator Information" | translate }} + {{ "Creator Information" | componentTranslate:"proposal" }}
{{ "Title" | translate }}{{ "Title" | componentTranslate:"proposal" }} {{ proposal.title }}
{{ "Abstract" | translate }}{{ "Abstract" | componentTranslate:"proposal" }} {{ proposal.abstract }}
{{ "Proposal Id" | translate }}{{ "Proposal Id" | componentTranslate:"proposal" }} {{ proposal.proposalId }}
{{ "Proposal Type" | translate }}{{ "Proposal Type" | componentTranslate:"proposal" }} {{ proposal["type"] }}
{{ "Parent proposal" | translate }}{{ "Parent proposal" | componentTranslate:"proposal" }} {{ parentProposal.title @@ -53,7 +53,7 @@ let-first="first" >
{{ "Start Time" | translate }}{{ "Start Time" | componentTranslate:"proposal" }} {{ period.start | date }}
{{ "End Time" | translate }}{{ "End Time" | componentTranslate:"proposal" }} {{ period.end | date }}
- + - +
{{ "Main proposer" | translate }}{{ "Main proposer" | componentTranslate:"proposal" }} {{ proposal.firstname }} {{ proposal.lastname }}
{{ "Principal Investigator" | translate }}{{ "Principal Investigator" | componentTranslate:"proposal" }} {{ proposal.pi_firstname }} {{ proposal.pi_lastname }} science - {{ "Metadata" | translate }} + {{ "Metadata" | componentTranslate:"proposal" }} diff --git a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts index e4f3ec969..9ced0317e 100644 --- a/src/app/proposals/view-proposal-page/view-proposal-page.component.ts +++ b/src/app/proposals/view-proposal-page/view-proposal-page.component.ts @@ -31,7 +31,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy { private translateService: TranslateService, ) { this.translateService.use( - this.appConfig.labelsLocalization?.currentLabelSet["proposal"], + this.appConfig.labelsLocalization?.currentLabelSet, ); } diff --git a/src/app/shared/pipes/component-translate.pipe.ts b/src/app/shared/pipes/component-translate.pipe.ts new file mode 100644 index 000000000..72b83cc49 --- /dev/null +++ b/src/app/shared/pipes/component-translate.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from "@angular/core"; +import { TranslateService } from "@ngx-translate/core"; + +@Pipe({ + name: "componentTranslate", +}) +export class ComponentTranslatePipe implements PipeTransform { + constructor(private translateService: TranslateService) {} + + transform(value: any, component = "", ...args: any[]): string { + const valueToBeTranslated = component ? component + "." + value : value; + const translatedValue = this.translateService.instant(valueToBeTranslated); + return translatedValue !== valueToBeTranslated ? translatedValue : value; + } +} diff --git a/src/app/shared/pipes/pipes.module.ts b/src/app/shared/pipes/pipes.module.ts index 21c716bda..08971a6c8 100644 --- a/src/app/shared/pipes/pipes.module.ts +++ b/src/app/shared/pipes/pipes.module.ts @@ -13,6 +13,7 @@ import { DynamicPipe } from "./dynamicPipe.pipe"; import { NewDynamicPipe } from "./newDynamicPipe.pipe"; import { DescriptionTitlePipe } from "./description-title.pipe"; import { FormatNumberPipe } from "./format-number.pipe"; +import { ComponentTranslatePipe } from "./component-translate.pipe"; @NgModule({ declarations: [ FileSizePipe, @@ -28,6 +29,7 @@ import { FormatNumberPipe } from "./format-number.pipe"; DynamicPipe, NewDynamicPipe, DescriptionTitlePipe, + ComponentTranslatePipe, ], imports: [CommonModule], exports: [ @@ -44,6 +46,7 @@ import { FormatNumberPipe } from "./format-number.pipe"; DynamicPipe, NewDynamicPipe, DescriptionTitlePipe, + ComponentTranslatePipe, ], }) export class PipesModule {} diff --git a/src/assets/config.json b/src/assets/config.json index 534fecb24..38eee0ed1 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -222,7 +222,7 @@ }, "proposal" : { "General Information": "Proposal Information", - "Title" : "Proposal Title", + //"Title" : "Proposal Title", "Abstract" : "Abstract", "Proposal Id" : "Proposal Id", "Proposal Type" : "Proposal Type", From c21bc99cf41e54436fbfe132cfe712662aab3838 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 4 Feb 2025 14:35:04 +0100 Subject: [PATCH 08/18] wip before merge with master --- .../proposals/proposal-detail/proposal-detail.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.ts b/src/app/proposals/proposal-detail/proposal-detail.component.ts index 4b11f4c7c..f5d1b17e9 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.ts +++ b/src/app/proposals/proposal-detail/proposal-detail.component.ts @@ -51,9 +51,7 @@ export class ProposalDetailComponent implements OnInit, OnDestroy { private store: Store, private router: Router, ) { - this.translateService.use( - this.appConfig.labelsLocalization?.currentLabelSet["proposal"], - ); + this.translateService.use(this.appConfig.labelsLocalization?.proposal); } ngOnInit(): void { From 1c1b2128a6f064be162997d5937b205f103d24c1 Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Tue, 4 Feb 2025 14:53:54 +0100 Subject: [PATCH 09/18] change translate to use the current config --- .../proposal-detail.component.html | 24 +++++++++---------- .../proposal-detail.component.ts | 2 +- .../shared/loaders/custom-translate.loader.ts | 13 +++++----- src/app/state-management/models/index.ts | 9 +++---- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 9aeed9280..7eef34edf 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -4,25 +4,25 @@
description
- {{ "General Information" | componentTranslate:"proposal" }} + {{ "General Information" | translate }} - + - + - + - + @@ -32,7 +32,7 @@ | async as parentProposal " > - + - + @@ -67,7 +67,7 @@ let-last="last" > - + @@ -81,13 +81,13 @@
person
- {{ "Creator Information" | componentTranslate:"proposal" }} + {{ "Creator Information" | translate }}
{{ "Title" | componentTranslate:"proposal" }}{{ "Title" | translate }} {{ proposal.title }}
{{ "Abstract" | componentTranslate:"proposal" }}{{ "Abstract" | translate }} {{ proposal.abstract }}
{{ "Proposal Id" | componentTranslate:"proposal" }}{{ "Proposal Id" | translate }} {{ proposal.proposalId }}
{{ "Proposal Type" | componentTranslate:"proposal" }}{{ "Proposal Type" | translate }} {{ proposal["type"] }}
{{ "Parent proposal" | componentTranslate:"proposal" }}{{ "Parent proposal" | translate }} {{ parentProposal.title @@ -53,7 +53,7 @@ let-first="first" >
{{ "Start Time" | componentTranslate:"proposal" }}{{ "Start Time" | translate }} {{ period.start | date }}
{{ "End Time" | componentTranslate:"proposal" }}{{ "End Time" | translate }} {{ period.end | date }}
- + - +
{{ "Main proposer" | componentTranslate:"proposal" }}{{ "Main proposer" | translate }} {{ proposal.firstname }} {{ proposal.lastname }}
{{ "Principal Investigator" | componentTranslate:"proposal" }}{{ "Principal Investigator" | translate }} {{ proposal.pi_firstname }} {{ proposal.pi_lastname }} science - {{ "Metadata" | componentTranslate:"proposal" }} + {{ "Metadata" | translate }} diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.ts b/src/app/proposals/proposal-detail/proposal-detail.component.ts index f5d1b17e9..d6d0577fa 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.ts +++ b/src/app/proposals/proposal-detail/proposal-detail.component.ts @@ -51,7 +51,7 @@ export class ProposalDetailComponent implements OnInit, OnDestroy { private store: Store, private router: Router, ) { - this.translateService.use(this.appConfig.labelsLocalization?.proposal); + this.translateService.use("proposalDefault"); } ngOnInit(): void { diff --git a/src/app/shared/loaders/custom-translate.loader.ts b/src/app/shared/loaders/custom-translate.loader.ts index 07360bdfb..3dd3d0632 100644 --- a/src/app/shared/loaders/custom-translate.loader.ts +++ b/src/app/shared/loaders/custom-translate.loader.ts @@ -8,12 +8,13 @@ export class CustomTranslateLoader implements TranslateLoader { constructor(private appConfigService: AppConfigService) {} getTranslation(): Observable { - const { currentLabelSet = "", labelSets = {} } = - this.appConfig?.labelsLocalization || {}; + // const { currentLabelSet = "", labelSets = {} } = + // this.appConfig?.labelsLocalization || {}; - if (currentLabelSet in labelSets) { - return of(labelSets[currentLabelSet]); - } - return of({}); + // if (currentLabelSet in labelSets) { + // return of(labelSets[currentLabelSet]); + // } + //return of({}); + return of(this.appConfig.labelsLocalization || {}); } } diff --git a/src/app/state-management/models/index.ts b/src/app/state-management/models/index.ts index aa856dd51..ccc3d1180 100644 --- a/src/app/state-management/models/index.ts +++ b/src/app/state-management/models/index.ts @@ -22,12 +22,9 @@ export interface LabelMaps { } export interface LabelsLocalization { - currentLabelSet: string; - labelSets: { - [key: string]: { - [key: string]: Record; - }; - }; + datasetDefault: Record; + datasetCustom: Record; + proposalDefault: Record; } export interface DatasetDetailComponentConfig { From e3de60e20c12342a9f4259ebb04d1b97aa1c2dae Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Fri, 24 Jan 2025 09:09:20 +0100 Subject: [PATCH 10/18] remove metadata edit for proposals --- .../proposal-detail.component.html | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 7eef34edf..60253e4f3 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -146,30 +146,6 @@ - - - edit Edit - -
- - - - -
-
From d5e5741795683b2354b8660ac12d2a5a0ac3c29d Mon Sep 17 00:00:00 2001 From: Max Novelli Date: Mon, 3 Feb 2025 11:32:08 +0100 Subject: [PATCH 11/18] added metadata editing --- .../proposal-detail.component.html | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 60253e4f3..7eef34edf 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -146,6 +146,30 @@ + + + edit Edit + +
+ + + + +
+
From 146e2e0d9b081b4404baf16c8a540fe513dbfd57 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 4 Feb 2025 15:46:16 +0100 Subject: [PATCH 12/18] fix unit test --- .../dataset-detail-dynamic.component.spec.ts | 6 +----- .../dataset-detail-dynamic.component.ts | 4 +--- .../dataset-detail/dataset-detail.component.spec.ts | 6 +----- .../dataset-detail/dataset-detail.component.ts | 4 +--- .../proposal-detail/proposal-detail.component.html | 2 +- .../view-proposal-page/view-proposal-page.component.ts | 4 +--- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.spec.ts b/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.spec.ts index 5393e555d..bd0f074f0 100644 --- a/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.spec.ts +++ b/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.spec.ts @@ -30,11 +30,7 @@ describe("DatasetDetailDynamicComponent", () => { navigateByUrl: jasmine.createSpy("navigateByUrl"), }; - const getConfig = () => ({ - datasetDetailViewLabelOption: { - currentLabel: "test", - }, - }); + const getConfig = () => ({}); beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ diff --git a/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.ts b/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.ts index 483550dc1..0af7f2972 100644 --- a/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail-dynamic/dataset-detail-dynamic.component.ts @@ -58,9 +58,7 @@ export class DatasetDetailDynamicComponent implements OnInit { private store: Store, private fb: FormBuilder, ) { - this.translateService.use( - this.appConfig.datasetDetailViewLabelOption?.currentLabelSet, - ); + this.translateService.use("datasetCustom"); } ngOnInit() { diff --git a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.spec.ts b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.spec.ts index cbb9172f1..3e72e032f 100644 --- a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.spec.ts +++ b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.spec.ts @@ -57,11 +57,7 @@ describe("DatasetDetailComponent", () => { navigateByUrl: jasmine.createSpy("navigateByUrl"), }; - const getConfig = () => ({ - datasetDetailViewLabelOption: { - currentLabel: "test", - }, - }); + const getConfig = () => ({}); let store: MockStore; diff --git a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts index c49fda473..84b5e44c1 100644 --- a/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail/dataset-detail.component.ts @@ -97,9 +97,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { private router: Router, private fb: FormBuilder, ) { - this.translateService.use( - this.appConfig.labelsLocalization?.currentLabelSet["dataset-default"], - ); + this.translateService.use("datasetDefault"); } ngOnInit() { diff --git a/src/app/proposals/proposal-detail/proposal-detail.component.html b/src/app/proposals/proposal-detail/proposal-detail.component.html index 7eef34edf..b250619a5 100644 --- a/src/app/proposals/proposal-detail/proposal-detail.component.html +++ b/src/app/proposals/proposal-detail/proposal-detail.component.html @@ -87,7 +87,7 @@ - +
{{ "Main proposer" | translate }}{{ "Main proposer" | translate }} {{ proposal.firstname }} {{ proposal.lastname }} Date: Tue, 4 Feb 2025 16:18:59 +0100 Subject: [PATCH 13/18] fix e2e test --- .../datasets/datasets-detail-dynamic.cy.js | 2 +- cypress/fixtures/testData.js | 48 ++++++++----------- .../shared/loaders/custom-translate.loader.ts | 17 +++---- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/cypress/e2e/datasets/datasets-detail-dynamic.cy.js b/cypress/e2e/datasets/datasets-detail-dynamic.cy.js index 622460df9..8a8491f6c 100644 --- a/cypress/e2e/datasets/datasets-detail-dynamic.cy.js +++ b/cypress/e2e/datasets/datasets-detail-dynamic.cy.js @@ -4,7 +4,7 @@ import { mergeConfig } from "../../support/utils"; describe("Datasets Detail View Dynamic", () => { const dynamicComponentConfig = testConfig.dynamicDetialViewComponent; const customizedLabelSets = - dynamicComponentConfig.datasetDetailViewLabelOption.labelSets.test; + dynamicComponentConfig.labelsLocalization.datasetCustom; const customizedComponents = dynamicComponentConfig.datasetDetailComponent.customization; diff --git a/cypress/fixtures/testData.js b/cypress/fixtures/testData.js index 8903d9ae4..39dadb90e 100644 --- a/cypress/fixtures/testData.js +++ b/cypress/fixtures/testData.js @@ -152,21 +152,18 @@ export const testData = { export const testConfig = { dynamicDetialViewComponent: { - datasetDetailViewLabelOption: { - currentLabelSet: "test", - labelSets: { - test: { - datasetName: "Test String", - description: "Test Copy", - ownerEmail: "Test Linky", - keywords: "Test Tag", - "Section Label Regular": "Test Section Regular", - "Section Label Attachments": "Test Section Attachments", - "Section Label Metadata JSON": "Test Section Metadata JSON", - "Section Label Metadata TABLE": "Test Section Metadata TABLE", - "Section Label Metadata TREE": "Test Section Metadata TREE", - "Section Label Dataset JsonView": "Test Section Dataset JsonView", - }, + labelsLocalization: { + datasetCustom: { + datasetName: "Test String", + description: "Test Copy", + ownerEmail: "Test Linky", + keywords: "Test Tag", + "Section Label Regular": "Test Section Regular", + "Section Label Attachments": "Test Section Attachments", + "Section Label Metadata JSON": "Test Section Metadata JSON", + "Section Label Metadata TABLE": "Test Section Metadata TABLE", + "Section Label Metadata TREE": "Test Section Metadata TREE", + "Section Label Dataset JsonView": "Test Section Dataset JsonView", }, }, datasetDetailComponent: { @@ -235,18 +232,15 @@ export const testConfig = { }, }, defaultDetailViewComponent: { - datasetDetailViewLabelOption: { - currentLabelSet: "test", - labelSets: { - test: { - "Dataset Name": "Test Dataset name", - Description: "Test Description", - "Creation time": "Test Creation time", - Pid: "Test Pid", - Type: "Test Type", - "General Information": "Test General Information", - "Creator Information": "Creator Information", - }, + labelsLocalization: { + datasetDefault: { + "Dataset Name": "Test Dataset name", + Description: "Test Description", + "Creation time": "Test Creation time", + Pid: "Test Pid", + Type: "Test Type", + "General Information": "Test General Information", + "Creator Information": "Creator Information", }, }, datasetDetailComponent: { diff --git a/src/app/shared/loaders/custom-translate.loader.ts b/src/app/shared/loaders/custom-translate.loader.ts index 3dd3d0632..86394b0ce 100644 --- a/src/app/shared/loaders/custom-translate.loader.ts +++ b/src/app/shared/loaders/custom-translate.loader.ts @@ -7,14 +7,15 @@ export class CustomTranslateLoader implements TranslateLoader { constructor(private appConfigService: AppConfigService) {} - getTranslation(): Observable { - // const { currentLabelSet = "", labelSets = {} } = - // this.appConfig?.labelsLocalization || {}; + getTranslation(lang: string): Observable { + if ( + this.appConfig.labelsLocalization && + this.appConfig.labelsLocalization[lang] + ) { + return of(this.appConfig.labelsLocalization[lang]); + } - // if (currentLabelSet in labelSets) { - // return of(labelSets[currentLabelSet]); - // } - //return of({}); - return of(this.appConfig.labelsLocalization || {}); + console.warn(`Translation for "${lang}" not found.`); + return of({}); } } From 2ddfa7d8aaacaf6283ea9102d493701aa0f5c431 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 4 Feb 2025 17:19:09 +0100 Subject: [PATCH 14/18] e2e test for proposal --- cypress/e2e/proposals/proposals-general.cy.js | 58 +++++++++++++++++++ cypress/fixtures/testData.js | 10 ++++ 2 files changed, 68 insertions(+) diff --git a/cypress/e2e/proposals/proposals-general.cy.js b/cypress/e2e/proposals/proposals-general.cy.js index f8cbf6640..f8821feac 100644 --- a/cypress/e2e/proposals/proposals-general.cy.js +++ b/cypress/e2e/proposals/proposals-general.cy.js @@ -1,4 +1,6 @@ import { testData } from "../../fixtures/testData"; +import { testConfig } from "../../fixtures/testData"; +import { mergeConfig } from "../../support/utils"; describe("Proposals general", () => { let proposal; @@ -210,4 +212,60 @@ describe("Proposals general", () => { .click(); }); }); + + describe("Proposal view details labelization", () => { + const proposalLabelsConfig = testConfig.proposalViewCustomLabels; + before(() => { + cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { + const mergedConfig = mergeConfig(baseConfig, proposalLabelsConfig); + cy.intercept("GET", "**/admin/config", mergedConfig).as( + "getFrontendConfig", + ); + }); + }); + it("should load proposal with fallback labels when no custom labels are available", () => { + const fallbackLabelsToCheck = ["Main proposer", "Proposal Type"]; + const customizedLabelsToCheck = [ + "Test Proposal Title", + "Test Abstract", + "Test Proposal Id", + ]; + + proposal = { + ...testData.proposal, + title: "Cypress test parent proposal", + proposalId: Math.floor(100000 + Math.random() * 900000).toString(), + }; + cy.createProposal(proposal); + + cy.visit("/proposals"); + + cy.get("mat-table mat-header-row").should("exist"); + + cy.finishedLoading(); + + cy.get("mat-table mat-row").should("contain", proposal.proposalId); + + cy.get("mat-row") + .contains(proposal.proposalId) + .parent() + .contains(proposal.title) + .click(); + + cy.url().should("include", `/proposals/${proposal.proposalId}`); + + cy.contains(proposal.title); + + cy.wrap([...fallbackLabelsToCheck, ...customizedLabelsToCheck]).each( + (value) => { + cy.get("mat-card").should(($matCards) => { + const matchFound = [...$matCards].some((card) => + card.innerText.includes(value), + ); + expect(matchFound).to.be.true; + }); + }, + ); + }); + }); }); diff --git a/cypress/fixtures/testData.js b/cypress/fixtures/testData.js index 39dadb90e..eab20af1f 100644 --- a/cypress/fixtures/testData.js +++ b/cypress/fixtures/testData.js @@ -248,4 +248,14 @@ export const testConfig = { customization: [], }, }, + proposalViewCustomLabels: { + labelsLocalization: { + proposalDefault: { + "General Information": "Test Proposal Information", + Title: "Test Proposal Title", + Abstract: "Test Abstract", + "Proposal Id": "Test Proposal Id", + }, + }, + }, }; From 53edef63c4282f2c43694921993018e70a88a5e3 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 4 Feb 2025 17:33:58 +0100 Subject: [PATCH 15/18] fix e2e --- cypress/e2e/proposals/proposals-general.cy.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/proposals/proposals-general.cy.js b/cypress/e2e/proposals/proposals-general.cy.js index f8821feac..8a3aceb95 100644 --- a/cypress/e2e/proposals/proposals-general.cy.js +++ b/cypress/e2e/proposals/proposals-general.cy.js @@ -4,7 +4,14 @@ import { mergeConfig } from "../../support/utils"; describe("Proposals general", () => { let proposal; + const proposalLabelsConfig = testConfig.proposalViewCustomLabels; beforeEach(() => { + cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { + const mergedConfig = mergeConfig(baseConfig, proposalLabelsConfig); + cy.intercept("GET", "**/admin/config", mergedConfig).as( + "getFrontendConfig", + ); + }); cy.login(Cypress.env("username"), Cypress.env("password")); }); @@ -77,7 +84,7 @@ describe("Proposals general", () => { cy.get("mat-card").should("not.contain", newProposal.title); }); - it("proposal should have type", () => { + it.only("proposal should have type", () => { const defaultProposalType = "Default Proposal"; const newProposal = { ...testData.proposal, @@ -214,15 +221,6 @@ describe("Proposals general", () => { }); describe("Proposal view details labelization", () => { - const proposalLabelsConfig = testConfig.proposalViewCustomLabels; - before(() => { - cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { - const mergedConfig = mergeConfig(baseConfig, proposalLabelsConfig); - cy.intercept("GET", "**/admin/config", mergedConfig).as( - "getFrontendConfig", - ); - }); - }); it("should load proposal with fallback labels when no custom labels are available", () => { const fallbackLabelsToCheck = ["Main proposer", "Proposal Type"]; const customizedLabelsToCheck = [ From d70575d0977a9b8e2e6aa09af985392988d80fff Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 4 Feb 2025 18:02:09 +0100 Subject: [PATCH 16/18] remove .only from cypress --- cypress/e2e/datasets/datasets-general.cy.js | 2 +- cypress/e2e/proposals/proposals-general.cy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/datasets/datasets-general.cy.js b/cypress/e2e/datasets/datasets-general.cy.js index dc56ea08b..9dcc9764c 100644 --- a/cypress/e2e/datasets/datasets-general.cy.js +++ b/cypress/e2e/datasets/datasets-general.cy.js @@ -94,7 +94,7 @@ describe("Datasets general", () => { }); }); - describe.only("Dataset page filter and scientific condition UI test", () => { + describe("Dataset page filter and scientific condition UI test", () => { it("should not be able to add duplicated conditions ", () => { cy.visit("/datasets"); diff --git a/cypress/e2e/proposals/proposals-general.cy.js b/cypress/e2e/proposals/proposals-general.cy.js index 8a3aceb95..df942cbff 100644 --- a/cypress/e2e/proposals/proposals-general.cy.js +++ b/cypress/e2e/proposals/proposals-general.cy.js @@ -84,7 +84,7 @@ describe("Proposals general", () => { cy.get("mat-card").should("not.contain", newProposal.title); }); - it.only("proposal should have type", () => { + it("proposal should have type", () => { const defaultProposalType = "Default Proposal"; const newProposal = { ...testData.proposal, From ba565bb32bd0ffdce1165bcd9669c5fee4aed570 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Fri, 7 Feb 2025 10:22:16 +0100 Subject: [PATCH 17/18] fix e2e test error on electron browser --- cypress/e2e/datasets/datasets-datafiles.cy.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/datasets/datasets-datafiles.cy.js b/cypress/e2e/datasets/datasets-datafiles.cy.js index baee6c5b6..f74d7cbd6 100644 --- a/cypress/e2e/datasets/datasets-datafiles.cy.js +++ b/cypress/e2e/datasets/datasets-datafiles.cy.js @@ -1,8 +1,14 @@ describe("Dataset datafiles", () => { beforeEach(() => { + cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => { + cy.intercept("GET", "**/admin/config", baseConfig).as( + "getFrontendConfig", + ); + }); cy.login(Cypress.env("username"), Cypress.env("password")); cy.intercept("PATCH", "/api/v3/datasets/**/*").as("change"); cy.intercept("GET", "*").as("fetch"); + cy.visit("/"); }); after(() => { @@ -11,10 +17,10 @@ describe("Dataset datafiles", () => { describe("Datafiles action test", () => { const actionUrl = { - downloadSelected: "https://www.scicat.info/download/selected", - downloadAll: "https://www.scicat.info/download/all", - notebookSelected: "https://www.scicat.info/notebook/selected", - notebookAll: "https://www.scicat.info/notebook/all", + downloadSelected: "http://localhost:4200/download/selected", + downloadAll: "http://localhost:4200/download/all", + notebookSelected: "http://localhost:4200/notebook/selected", + notebookAll: "http://localhost:4200/notebook/all", }; it("Should be able to download/notebook with selected/all", () => { cy.createDataset("raw", undefined, "small"); From 546761438dccbd01d7d59426c958f15fd58589ea Mon Sep 17 00:00:00 2001 From: junjiequan Date: Fri, 7 Feb 2025 10:29:42 +0100 Subject: [PATCH 18/18] e2e test consistant datafiles action url --- CI/e2e/frontend.config.e2e.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CI/e2e/frontend.config.e2e.json b/CI/e2e/frontend.config.e2e.json index 633624b99..e82f4e0dd 100644 --- a/CI/e2e/frontend.config.e2e.json +++ b/CI/e2e/frontend.config.e2e.json @@ -65,7 +65,7 @@ "files": "all", "mat_icon": "download", "type": "form", - "url": "https://www.scicat.info/download/all", + "url": "http://localhost:4200/download/all", "target": "_blank", "enabled": "#SizeLimit", "authorization": ["#datasetAccess", "#datasetPublic"] @@ -77,7 +77,7 @@ "files": "selected", "mat_icon": "download", "type": "form", - "url": "https://www.scicat.info/download/selected", + "url": "http://localhost:4200/download/selected", "target": "_blank", "enabled": "#Selected && #SizeLimit", "authorization": ["#datasetAccess", "#datasetPublic"] @@ -89,7 +89,7 @@ "files": "all", "icon": "/assets/icons/jupyter_logo.png", "type": "form", - "url": "https://www.scicat.info/notebook/all", + "url": "http://localhost:4200/notebook/all", "target": "_blank", "authorization": ["#datasetAccess", "#datasetPublic"] }, @@ -100,7 +100,7 @@ "files": "selected", "icon": "/assets/icons/jupyter_logo.png", "type": "form", - "url": "https://www.scicat.info/notebook/selected", + "url": "http://localhost:4200/notebook/selected", "target": "_blank", "enabled": "#Selected", "authorization": ["#datasetAccess", "#datasetPublic"]