diff --git a/CI/e2e/frontend.config.e2e.json b/CI/e2e/frontend.config.e2e.json index afb6fc3f1..7bdad6c8d 100644 --- a/CI/e2e/frontend.config.e2e.json +++ b/CI/e2e/frontend.config.e2e.json @@ -209,7 +209,6 @@ ], "conditions": [] }, - "labelsLocalization": { "datasetDefault": {}, "datasetCustom": { @@ -237,5 +236,217 @@ "Metadata": "Additional Information" } }, - "dateFormat": "yyyy-MM-dd HH:mm" + "dateFormat": "yyyy-MM-dd HH:mm", + "datasetDetailComponent": { + "enableCustomizedComponent": false, + "customization": [ + { + "type": "regular", + "label": "General Information", + "order": 0, + "row": 1, + "col": 8, + "fields": [ + { + "element": "text", + "source": "scientificMetadata.start_time", + "order": 0 + }, + { + "element": "copy", + "source": "scientificMetadata.run_number.value", + "order": 1 + }, + { + "element": "text", + "source": "creationTime", + "order": 2 + }, + { + "element": "text", + "source": "type", + "order": 3 + }, + { + "element": "text", + "source": "datasetName", + "order": 4 + }, + { + "element": "tag", + "source": "keywords", + "order": 5 + } + ] + }, + { + "type": "attachments", + "label": "Gallery", + "order": 1, + "col": 2, + "row": 2, + "options": { + "limit": 5, + "size": "medium" + } + }, + { + "type": "regular", + "label": "Contact Information", + "order": 2, + "col": 2, + "row": 1, + "fields": [ + { + "element": "text", + "source": "principalInvestigator", + "order": 0 + }, + { + "element": "linky", + "source": "contactEmail", + "order": 1 + } + ] + }, + { + "type": "regular", + "label": "Files Information", + "order": 3, + "col": 2, + "row": 1, + "fields": [ + { + "element": "text", + "source": "scientificMetadata.runnumber", + "order": 0 + }, + { + "element": "text", + "source": "sourceFolderHost", + "order": 1 + }, + { + "element": "text", + "source": "numberOfFiles", + "order": 2 + }, + { + "element": "text", + "source": "size", + "order": 3 + }, + { + "element": "text", + "source": "numberOfFilesArchived", + "order": 4 + }, + { + "element": "text", + "source": "packedSize", + "order": 5 + } + ] + }, + { + "type": "regular", + "label": "Related Documents", + "order": 4, + "col": 4, + "row": 1, + "fields": [ + { + "element": "internalLink", + "source": "proposalIds", + "order": 0 + }, + { + "element": "internalLink", + "source": "instrumentIds", + "order": 1 + }, + { + "element": "tag", + "source": "sampleIds", + "order": 2 + }, + { + "element": "tag", + "source": "inputDatasets", + "order": 3 + }, + { + "element": "internalLink", + "source": "creationLocation", + "order": 4 + } + ] + }, + { + "type": "attachments", + "label": "Gallery", + "order": 5, + "col": 1, + "row": 1, + "options": { + "limit": 2, + "size": "small" + } + }, + { + "type": "scientificMetadata", + "label": "Scientific Metadata Table", + "viewMode": "table", + "order": 6, + "col": 9, + "row": 1 + }, + { + "type": "scientificMetadata", + "label": "Scientific Metadata JSON", + "viewMode": "json", + "order": 6 + }, + { + "type": "scientificMetadata", + "label": "Scientific Metadata Tree", + "viewMode": "tree", + "order": 6 + }, + { + "type": "datasetJsonView", + "label": "Dataset Json View", + "order": 7, + "col": 10, + "row": 2 + } + ] + }, + "defaultMainPage": { + "nonAuthenticatedUser": "DATASETS", + "authenticatedUser": "PROPOSALS" + }, + "siteHeaderLogoUrl": "https://my.facility.site", + "mainMenu": { + "nonAuthenticatedUser": { + "datasets": true, + "files": false, + "instruments": true, + "jobs": false, + "policies": false, + "proposals": true, + "publishedData": true, + "samples": false + }, + "authenticatedUser": { + "datasets": true, + "files": true, + "instruments": true, + "jobs": true, + "policies": false, + "proposals": true, + "publishedData": true, + "samples": true + } + } } diff --git a/cypress/e2e/mainPage/main-page.cy.js b/cypress/e2e/mainPage/main-page.cy.js new file mode 100644 index 000000000..ee8705c52 --- /dev/null +++ b/cypress/e2e/mainPage/main-page.cy.js @@ -0,0 +1,98 @@ +import { testData } from "../../fixtures/testData"; + +describe("Main Page", () => { + beforeEach(() => { + cy.login(Cypress.env("username"), Cypress.env("password")); + cy.createDataset( + "raw", + "Main Page Dataset Public", + "20150729", + "small", + true, + ); + cy.createDataset( + "raw", + "Main Page Dataset Non Public", + "20150729", + "small", + false, + ); + }); + + after(() => { + cy.removeDatasets(); + }); + + describe("Main page configuration as non authenticated user", () => { + it("should visit main page correctly configured", () => { + const username = Cypress.env("username"); + + cy.visit("/"); + cy.finishedLoading(); + + cy.get(".user-button").should("contain.text", username).click(); + + cy.get("[data-cy=logout-button]").click(); + + cy.finishedLoading(); + cy.visit("/"); + + cy.finishedLoading(); + + cy.get("breadcrumb > div > span > a").should('contain', "Datasets"); + + cy.get("div.header mat-toolbar.mat-toolbar.mat-elevation-z1.mat-primary.mat-toolbar-single-row a").eq(0).should('have.attr','href','/datasets'); + cy.get("div.header mat-toolbar.mat-toolbar.mat-elevation-z1.mat-primary.mat-toolbar-single-row a").eq(1).should('have.attr','href','https://my.facility.site'); + + cy.get("div.main-menu").click() + + cy.get('button.mat-mdc-menu-item:nth-child(1) > span:nth-child(2) > span:nth-child(1)').should('contain','Datasets') + cy.get('button.mat-mdc-menu-item:nth-child(4) > span:nth-child(2) > span:nth-child(1)').should('contain','Published Data') + + cy.get('[data-cy="login-button"]').should('exist'); + + //cy.get("mat-row").contains("Main Page Dataset Public").click(); + }); + }); + + describe("Main page configuration as authenticated user", () => { + it("should visit main page correctly configured", () => { + const username = Cypress.env("username"); + const password = Cypress.env("password"); + + // cy.visit("/login"); + + // cy.finishedLoading(); + + // cy.url().should("include", "/login"); + + // cy.get('mat-tab-group [role="tab"]').contains("Local").click(); + + // cy.get("#usernameInput").type(username).should("have.value", username); + // cy.get("#passwordInput").type(password).should("have.value", password); + + // cy.get("button[type=submit]").click(); + + cy.visit("/"); + cy.finishedLoading(); + + cy.url().should("include", "/proposals"); + + cy.get("breadcrumb > div > span > a").should('contain', "Proposals"); + + cy.get("div.header mat-toolbar.mat-toolbar.mat-elevation-z1.mat-primary.mat-toolbar-single-row a").eq(0).should('have.attr','href','/proposals'); + cy.get("div.header mat-toolbar.mat-toolbar.mat-elevation-z1.mat-primary.mat-toolbar-single-row a").eq(1).should('have.attr','href','https://my.facility.site'); + + cy.get("div.main-menu").click() + + cy.get('button.mat-mdc-menu-item:nth-child(2) > span:nth-child(2) > span:nth-child(1)').should('contain','Files') + + cy.get("div.main-menu").click() + + cy.get('[data-cy="login-button"]').should('not.exist'); + cy.get('.user-button').should('exist'); + + }); + }); + +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 3c4da2539..46a9ce813 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -113,13 +113,19 @@ Cypress.Commands.add( datasetName = testData.rawDataset.datasetName, proposalId = "20170266", dataFileSize = "small", + isPublished = false, ) => { cy.getCookie("user").then((userCookie) => { const user = JSON.parse(decodeURIComponent(userCookie.value)); cy.getToken().then((token) => { if (type === "raw") { - const dataset = { ...testData.rawDataset, datasetName, proposalId }; + const dataset = { + ...testData.rawDataset, + datasetName, + proposalId, + isPublished, + }; cy.log("Raw Dataset 1: " + JSON.stringify(dataset, null, 2)); cy.log("User: " + JSON.stringify(user, null, 2)); diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md new file mode 100644 index 000000000..6b8b9bee9 --- /dev/null +++ b/docs/configuration/configuration.md @@ -0,0 +1,307 @@ +# SciCat Frontend Configuration +SciCat frontend can be configured using a json object containing the entries listed below. +The json configuration object can be provided together with the app or through a URL. +Most of the time it is provided upon request directly from SciCat BE through the endpoint `/admin/config` + +## Configuration Options +- skipSciCatLoginPageEnabled: + - Type: boolean; + - Description: +- accessTokenPrefix: + - Type: string; + - Description: +- addDatasetEnabled: + - Type: boolean; + - Description: +- archiveWorkflowEnabled: + - Type: boolean; + - Description: +- datasetJsonScientificMetadata: + - Type: boolean; + - Description: +- datasetReduceEnabled: + - Type: boolean; + - Description: +- datasetDetailsShowMissingProposalId: + - Type: boolean; + - Description: +- datafilesActionsEnabled: + - Type: boolean; + - Description: +- datafilesActions: + - Type: any[]; + - Description: +- editDatasetEnabled: + - Type: boolean; + - Description: +- editDatasetSampleEnabled: + - Type: boolean; + - Description: +- editMetadataEnabled: + - Type: boolean; + - Description: +- editPublishedData: + - Type: boolean; + - Description: +- addSampleEnabled: + - Type: boolean; + - Description: +- externalAuthEndpoint: + - Type: string | null; + - Description: +- facility: + - Type: string | null; + - Description: +- loginFacilityLabel: + - Type: string | null; + - Description: +- loginLdapLabel: + - Type: string | null; + - Description: +- loginLocalLabel: + - Type: string | null; + - Description: +- loginFacilityEnabled: + - Type: boolean; + - Description: +- loginLdapEnabled: + - Type: boolean; + - Description: +- loginLocalEnabled: + - Type: boolean; + - Description: +- fileColorEnabled: + - Type: boolean; + - Description: +- fileDownloadEnabled: + - Type: boolean; + - Description: +- gettingStarted: + - Type: string | null; + - Description: +- ingestManual: + - Type: string | null; + - Description: +- jobsEnabled: + - Type: boolean; + - Description: +- jsonMetadataEnabled: + - Type: boolean; + - Description: +- jupyterHubUrl: + - Type: string | null; + - Description: +- landingPage: + - Type: string | null; + - Description: +- lbBaseURL: + - Type: string; + - Description: +- localColumns?: + - Type: TableColumn[]; // localColumns is deprecated and should be removed in the future + - Description: +- logbookEnabled: + - Type: boolean; + - Description: +- loginFormEnabled: + - Type: boolean; + - Description: +- maxDirectDownloadSize: + - Type: number | null; + - Description: +- metadataPreviewEnabled: + - Type: boolean; + - Description: +- metadataStructure: + - Type: string; + - Description: +- multipleDownloadAction: + - Type: string | null; + - Description: +- multipleDownloadEnabled: + - Type: boolean; + - Description: +- multipleDownloadUseAuthToken: + - Type: boolean; + - Description: +- oAuth2Endpoints: + - Type: OAuth2Endpoint[]; + - Description: +- policiesEnabled: + - Type: boolean; + - Description: +- retrieveDestinations?: + - Type: RetrieveDestinations[]; + - Description: +- riotBaseUrl: + - Type: string | null; + - Description: +- scienceSearchEnabled: + - Type: boolean; + - Description: +- scienceSearchUnitsEnabled: + - Type: boolean; + - Description: +- searchPublicDataEnabled: + - Type: boolean; + - Description: +- searchSamples: + - Type: boolean; + - Description: +- sftpHost: + - Type: string | null; + - Description: +- sourceFolder?: + - Type: string; + - Description: +- maxFileSizeWarning?: + - Type: string; + - Description: +- shareEnabled: + - Type: boolean; + - Description: +- shoppingCartEnabled: + - Type: boolean; + - Description: +- shoppingCartOnHeader: + - Type: boolean; + - Description: +### siteTitle: + - Type: string | null; + - Description: String shown at the center of the header. If left empty, no string is presented. + - Default: None +### siteSciCatLogo: + - Type: string | null; + - Options: icon, full + - Description: Type of SciCat logo shown in the app header. + If `icon` is selected, the compact logo of SciCat is shown, which is contained in the file `src/assets/images/scicat-header-logo-icon.png`. + If `full` is selected, the full SciCat logo is shown. The full logo is saved in the file `src/assets/images/scicat-header-logo-full.png`. + - Required +### siteHeaderLogo: + - Type: string | null; + - Description: Name of the file with that contains the logo of the facility/lab/company/legal entity that runs the instance of scicat. This shuld be only the name of the file. The path is relative to _`src/assets/images`_. + If SciCat FE is run in a container using the official release image, the file should be mounted in the container under the path just mentioned. + - Example: assets/images/ess-logo-small.png + - Default: None + - Required +### siteHeaderLogoLink: + - Type: string; + - Description: This string will tell which url should be shown when th euser click on the side logo in the header. It can be an in-app path or a full URL. + - Examples: + If we want to show the datasets list when the user click on the site logo, the value should be set to _`/datasets`_. + If we want to link to the main facility web site, the value should be set to the public facing website of the facility: _`https://my.facility.site`_ + - Optional +- siteLoginBackground: + - Type: string | null; + - Description: +- siteLoginLogo: + - Type: string | null; + - Description: +- tableSciDataEnabled: + - Type: boolean; + - Description: +- fileserverBaseURL: + - Type: string; + - Description: +- fileserverButtonLabel: + - Type: string | undefined; + - Description: +- helpMessages?: + - Type: HelpMessages; + - Description: +- notificationInterceptorEnabled: + - Type: boolean; + - Description: +- pidSearchMethod?: + - Type: string; + - Description: +- metadataEditingUnitListDisabled?: + - Type: boolean; + - Description: +- defaultDatasetsListSettings: + - Type: DatasetsListSettings; + - Description: +- labelMaps: + - Type: LabelMaps; + - Description: +- thumbnailFetchLimitPerPage: + - Type: number; + - Description: +- maxFileUploadSizeInMb?: + - Type: string; + - Description: +- datasetDetailComponent?: + - Type: DatasetDetailComponentConfig; + - Description: +- labelsLocalization?: + - Type: LabelsLocalization; + - Description: +- dateFormat?: + - Type: string; + - Description: +### defaultMainPage: + - Type: MainPageConfiguration; + - Definition: + ``` + { + nonAuthenticatedUser: keyof typeof MainPageOptions; + authenticatedUser: keyof typeof MainPageOptions; + } + ``` + - Description: esplicitly configure which is the in-app page that the users are redirected to when visiting the main FE url. As you can see from the structure, sites can define different main pages for authenticated and non-authenticated users. + - Options: DATASETS, PROPOSALS, INSTRUMENTS, SAMPLES (as defined in enum `MainPagesOptions`) + - Default: DATASETS + - Optional +### mainMenu: + - Type: MainMenuConfiguration; + - Definitions: + ``` + MainMenuConfiguration { + nonAuthenticatedUser: MainMenuOptions; + authenticatedUser: MainMenuOptions; + } + + MainMenuOptions { + datasets: boolean; + files: boolean; + instruments: boolean; + jobs: boolean; + policies: boolean; + proposals: boolean; + publishedData: boolean; + samples: boolean; + } + ``` + - Description: + Main menu configuration which controls which menu items are active. There are two configurations, one for authenticated and one for non-auhtenticated users. If not configured, the FE will show a `No menu items configured` element. Each menu item might have additional conditions to be visible. + - Example: + The following example will instruct the FE to show a menu with items datasets, instruments, proposals, and samples to non authenticated users. While for authenticated users, the menu will have all the items enabled, except for policies. + ``` + "mainMenu": { + "nonAuthenticatedUser": { + "datasets": true, + "files": false, + "instruments": true, + "jobs": false, + "policies": false, + "proposals": true, + "publishedData": true, + "samples": false + }, + "authenticatedUser": { + "datasets": true, + "files": true, + "instruments": true, + "jobs": true, + "policies": false, + "proposals": true, + "publishedData": true, + "samples": true + } + } + ``` + - Optional +### supportEmail: + - Type: string; + - Description: + - Optional \ No newline at end of file diff --git a/src/app/_layout/app-header/_app-header-theme.scss b/src/app/_layout/app-header/_app-header-theme.scss index 046d393f3..604d21c03 100644 --- a/src/app/_layout/app-header/_app-header-theme.scss +++ b/src/app/_layout/app-header/_app-header-theme.scss @@ -7,10 +7,11 @@ .header { mat-toolbar { - background-color: mat.m2-get-color-from-palette($primary, "darker"); + background-color: mat.m2-get-color-from-palette($primary, "default-contrast"); + border-bottom: 2px solid mat.m2-get-color-from-palette($primary, "default"); } - a { - color: mat.m2-get-color-from-palette($primary, "default-contrast"); + a, h3, div { + color: mat.m2-get-color-from-palette($primary, "default"); } } } diff --git a/src/app/_layout/app-header/app-header.component.html b/src/app/_layout/app-header/app-header.component.html index c19064f56..57402c029 100644 --- a/src/app/_layout/app-header/app-header.component.html +++ b/src/app/_layout/app-header/app-header.component.html @@ -1,49 +1,73 @@