From f18bc80d729dda6c2f42d04a348257b366d9f9e4 Mon Sep 17 00:00:00 2001 From: Martin Trajanovski Date: Wed, 10 May 2023 15:10:33 +0200 Subject: [PATCH 1/2] feat: use json instead of ts files for frontend configuration and theme --- src/admin/admin.service.spec.ts | 2 +- src/admin/admin.service.ts | 4 +- src/auth/strategies/ldap.strategy.ts | 2 +- src/config/frontend.config.json | 136 ++++++++++++++++++ src/config/frontend.config.ts | 135 ----------------- ...{frontend.theme.ts => frontend.theme.json} | 12 +- src/main.ts | 2 +- tsconfig.json | 44 +++--- 8 files changed, 170 insertions(+), 167 deletions(-) create mode 100644 src/config/frontend.config.json delete mode 100644 src/config/frontend.config.ts rename src/config/{frontend.theme.ts => frontend.theme.json} (95%) diff --git a/src/admin/admin.service.spec.ts b/src/admin/admin.service.spec.ts index b49c76116..5b6c3c628 100644 --- a/src/admin/admin.service.spec.ts +++ b/src/admin/admin.service.spec.ts @@ -1,7 +1,7 @@ import { getModelToken } from "@nestjs/mongoose"; import { Test, TestingModule } from "@nestjs/testing"; import { AdminService } from "./admin.service"; -import config from "../config/frontend.config"; +import config from "../config/frontend.config.json"; const mockConfig: Record = config; diff --git a/src/admin/admin.service.ts b/src/admin/admin.service.ts index a0306ea7c..970ad4b3d 100644 --- a/src/admin/admin.service.ts +++ b/src/admin/admin.service.ts @@ -1,6 +1,6 @@ import { Injectable } from "@nestjs/common"; -import config from "../config/frontend.config"; -import theme from "../config/frontend.theme"; +import config from "../config/frontend.config.json"; +import theme from "../config/frontend.theme.json"; @Injectable() export class AdminService { diff --git a/src/auth/strategies/ldap.strategy.ts b/src/auth/strategies/ldap.strategy.ts index 8e2e1be8e..04026feb0 100644 --- a/src/auth/strategies/ldap.strategy.ts +++ b/src/auth/strategies/ldap.strategy.ts @@ -1,4 +1,4 @@ -import * as Strategy from "passport-ldapauth"; +import Strategy from "passport-ldapauth"; import { Injectable, InternalServerErrorException } from "@nestjs/common"; import { PassportStrategy } from "@nestjs/passport"; import { ConfigService } from "@nestjs/config"; diff --git a/src/config/frontend.config.json b/src/config/frontend.config.json new file mode 100644 index 000000000..7e312c5a9 --- /dev/null +++ b/src/config/frontend.config.json @@ -0,0 +1,136 @@ +{ + "accessTokenPrefix": "Bearer ", + "addDatasetEnabled": true, + "archiveWorkflowEnabled": false, + "datasetReduceEnabled": true, + "editDatasetSampleEnabled": true, + "editMetadataEnabled": true, + "editPublishedData": false, + "editSampleEnabled": true, + "externalAuthEndpoint": "/api/v3/auth/msad", + "facility": "ESS", + "loginFacilityLabel": "ESS", + "loginLdapLabel": "Ldap", + "loginLocalLabel": "Local", + "loginFacilityEnabled": true, + "loginLdapEnabled": true, + "loginLocalEnabled": true, + "facilityLoginLabel": "ESS", + "localLoginLabel": "Local", + "fileColorEnabled": true, + "fileDownloadEnabled": true, + "gettingStarted": null, + "ingestManual": null, + "jobsEnabled": true, + "jsonMetadataEnabled": true, + "jupyterHubUrl": "https://jupyterhub.esss.lu.se/", + "landingPage": "doi.ess.eu/detail/", + "lbBaseURL": "", + "localColumns": [ + { + "name": "select", + "order": 0, + "type": "standard", + "enabled": true + }, + { + "name": "pid", + "order": 1, + "type": "standard", + "enabled": true + }, + { + "name": "datasetName", + "order": 2, + "type": "standard", + "enabled": true + }, + { + "name": "runNumber", + "order": 3, + "type": "standard", + "enabled": true + }, + { + "name": "sourceFolder", + "order": 4, + "type": "standard", + "enabled": true + }, + { + "name": "size", + "order": 5, + "type": "standard", + "enabled": true + }, + { + "name": "creationTime", + "order": 6, + "type": "standard", + "enabled": true + }, + { + "name": "type", + "order": 7, + "type": "standard", + "enabled": true + }, + { + "name": "image", + "order": 8, + "type": "standard", + "enabled": true + }, + { + "name": "metadata", + "order": 9, + "type": "standard", + "enabled": false + }, + { + "name": "proposalId", + "order": 10, + "type": "standard", + "enabled": true + }, + { + "name": "ownerGroup", + "order": 11, + "type": "standard", + "enabled": false + }, + { + "name": "dataStatus", + "order": 12, + "type": "standard", + "enabled": false + } + ], + "logbookEnabled": true, + "loginFormEnabled": true, + "maxDirectDownloadSize": 5000000000, + "metadataPreviewEnabled": true, + "metadataStructure": "", + "multipleDownloadAction": "https://scicatfileserver.esss.dk/zip", + "multipleDownloadEnabled": true, + "oAuth2Endpoints": [ + { + "authURL": "api/v3/auth/oidc", + "displayText": "ESS One Identity" + } + ], + "policiesEnabled": true, + "retrieveDestinations": [], + "riotBaseUrl": "http://scichat.esss.lu.se", + "scienceSearchEnabled": true, + "scienceSearchUnitsEnabled": true, + "searchPublicDataEnabled": true, + "searchSamples": true, + "sftpHost": "login.esss.dk", + "shareEnabled": true, + "shoppingCartEnabled": true, + "shoppingCartOnHeader": true, + "tableSciDataEnabled": true, + "datasetDetailsShowMissingProposalId": false, + "notificationInterceptorEnabled": true +} diff --git a/src/config/frontend.config.ts b/src/config/frontend.config.ts deleted file mode 100644 index 8c450f437..000000000 --- a/src/config/frontend.config.ts +++ /dev/null @@ -1,135 +0,0 @@ -export default { - accessTokenPrefix: "Bearer ", - addDatasetEnabled: true, - archiveWorkflowEnabled: false, - datasetReduceEnabled: true, - editDatasetSampleEnabled: true, - editMetadataEnabled: true, - editPublishedData: false, - editSampleEnabled: true, - externalAuthEndpoint: "/api/v3/auth/msad", - facility: "ESS", - loginFacilityLabel: "ESS", - loginLdapLabel: "Ldap", - loginLocalLabel: "Local", - loginFacilityEnabled: true, - loginLdapEnabled: true, - loginLocalEnabled: true, - facilityLoginLabel: "ESS", - localLoginLabel: "Local", - fileColorEnabled: true, - fileDownloadEnabled: true, - gettingStarted: null, - ingestManual: null, - jobsEnabled: true, - jsonMetadataEnabled: true, - jupyterHubUrl: "https://jupyterhub.esss.lu.se/", - landingPage: "doi.ess.eu/detail/", - lbBaseURL: "", - localColumns: [ - { - name: "select", - order: 0, - type: "standard", - enabled: true, - }, - { - name: "pid", - order: 1, - type: "standard", - enabled: true, - }, - { - name: "datasetName", - order: 2, - type: "standard", - enabled: true, - }, - { - name: "runNumber", - order: 3, - type: "standard", - enabled: true, - }, - { - name: "sourceFolder", - order: 4, - type: "standard", - enabled: true, - }, - { - name: "size", - order: 5, - type: "standard", - enabled: true, - }, - { - name: "creationTime", - order: 6, - type: "standard", - enabled: true, - }, - { - name: "type", - order: 7, - type: "standard", - enabled: true, - }, - { - name: "image", - order: 8, - type: "standard", - enabled: true, - }, - { - name: "metadata", - order: 9, - type: "standard", - enabled: false, - }, - { - name: "proposalId", - order: 10, - type: "standard", - enabled: true, - }, - { - name: "ownerGroup", - order: 11, - type: "standard", - enabled: false, - }, - { - name: "dataStatus", - order: 12, - type: "standard", - enabled: false, - }, - ], - logbookEnabled: true, - loginFormEnabled: true, - maxDirectDownloadSize: 5000000000, - metadataPreviewEnabled: true, - metadataStructure: "", - multipleDownloadAction: "https://scicatfileserver.esss.dk/zip", - multipleDownloadEnabled: true, - oAuth2Endpoints: [ - { - authURL: "api/v3/auth/oidc", - displayText: "ESS One Identity", - }, - ], - policiesEnabled: true, - retrieveDestinations: [], - riotBaseUrl: "http://scichat.esss.lu.se", - scienceSearchEnabled: true, - scienceSearchUnitsEnabled: true, - searchPublicDataEnabled: true, - searchSamples: true, - sftpHost: "login.esss.dk", - shareEnabled: true, - shoppingCartEnabled: true, - shoppingCartOnHeader: true, - tableSciDataEnabled: true, - datasetDetailsShowMissingProposalId: false, -}; diff --git a/src/config/frontend.theme.ts b/src/config/frontend.theme.json similarity index 95% rename from src/config/frontend.theme.ts rename to src/config/frontend.theme.json index 64d5f0b15..10108e747 100644 --- a/src/config/frontend.theme.ts +++ b/src/config/frontend.theme.json @@ -1,6 +1,6 @@ -export default { - name: "light", - properties: { +{ + "name": "light", + "properties": { "--theme-primary-default": "#0099c8", "--theme-primary-default-contrast": "#ffffff", "--theme-primary-lighter": "#99d5e9", @@ -54,6 +54,6 @@ export default { "--theme-hover-lighter": "#e5e5e5", "--theme-hover-lighter-contrast": "#000000", "--theme-hover-darker": "#b2b2b2", - "--theme-hover-darker-contrast": "#000000", - }, -}; + "--theme-hover-darker-contrast": "#000000" + } +} diff --git a/src/main.ts b/src/main.ts index f03210807..0b7c1033c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import * as session from "express-session"; +import session from "express-session"; import { json } from "body-parser"; import { NestFactory } from "@nestjs/core"; import { diff --git a/tsconfig.json b/tsconfig.json index 11f79151b..3235a2ac8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,23 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "strictPropertyInitialization": false, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "target": "es2017", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true - } -} +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "strictPropertyInitialization": false, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "target": "es2017", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "esModuleInterop": true + } +} From aa10972c76cd4a42107a3ef3c7ddca78c51f90d7 Mon Sep 17 00:00:00 2001 From: Martin Trajanovski Date: Thu, 11 May 2023 11:06:54 +0200 Subject: [PATCH 2/2] fix api tests --- test/jest-e2e-tests/accessGroups.e2e-spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jest-e2e-tests/accessGroups.e2e-spec.ts b/test/jest-e2e-tests/accessGroups.e2e-spec.ts index 55f15c93b..6aedb7ffd 100644 --- a/test/jest-e2e-tests/accessGroups.e2e-spec.ts +++ b/test/jest-e2e-tests/accessGroups.e2e-spec.ts @@ -1,4 +1,4 @@ -import * as request from "supertest"; +import request from "supertest"; import { Test } from "@nestjs/testing"; import { INestApplication } from "@nestjs/common"; import { AppModule } from "src/app.module";