From 1b7fdfc59cf28a2ce4de601161ad3b4430159403 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 27 Mar 2020 09:10:32 +0100 Subject: [PATCH] removed custom environment files and fixed config build --- package.json | 1 - scripts/set-env.ts | 13 +++++++++++-- .../models/notification-options.model.ts | 4 ++-- src/config/browse-by-type-config.interface.ts | 2 +- src/environments/environment.dev.ts | 5 ----- src/environments/environment.prod.ts | 4 ---- src/environments/environment.ts | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 src/environments/environment.dev.ts delete mode 100644 src/environments/environment.prod.ts diff --git a/package.json b/package.json index 2f821db00e..a8b89095a5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "config:prod": "ts-node --project ./tsconfig.ts-node.json scripts/set-env.ts --prod", "config:test": "ts-node --project ./tsconfig.ts-node.json scripts/set-env.ts --test", "prestart:dev": "yarn run config:dev", - "prestart:prod": "yarn run config:prod", "prebuild": "yarn run config:dev", "pretest": "yarn run config:test", "pretest:headless": "yarn run config:test", diff --git a/scripts/set-env.ts b/scripts/set-env.ts index 523d15702b..e19f2124fe 100644 --- a/scripts/set-env.ts +++ b/scripts/set-env.ts @@ -43,6 +43,7 @@ import(environmentFilePath) .catch(() => generateEnvironmentFile(merge(commonEnv, processEnv))); function generateEnvironmentFile(file: GlobalConfig): void { + console.log(file); buildBaseUrls(file); const contents = `export const environment = ` + JSON.stringify(file); console.log(colors.magenta('The file `environment.ts` will be written with the following content: \n')); @@ -54,12 +55,18 @@ function generateEnvironmentFile(file: GlobalConfig): void { console.log(colors.magenta(`Angular environment.ts file generated correctly at ${targetPath} \n`)); } }); - console.log(file); } // allow to override a few important options by environment variables function createServerConfig(host?: string, port?: string, nameSpace?: string, ssl?: string): ServerConfig { - const result = { host, nameSpace } as any; + const result = {} as any; + if (hasValue(host)) { + result.host = host; + } + + if (hasValue(nameSpace)) { + result.host = nameSpace; + } if (hasValue(port)) { result.port = Number(port); @@ -75,6 +82,8 @@ function createServerConfig(host?: string, port?: string, nameSpace?: string, s function buildBaseUrls(config: GlobalConfig): void { for (const key in config) { if (config.hasOwnProperty(key) && config[key].host) { + console.log(key); + console.log(config[key]); config[key].baseUrl = [ getProtocol(config[key].ssl), getHost(config[key].host), diff --git a/src/app/shared/notifications/models/notification-options.model.ts b/src/app/shared/notifications/models/notification-options.model.ts index 807ca1e963..65011496b3 100644 --- a/src/app/shared/notifications/models/notification-options.model.ts +++ b/src/app/shared/notifications/models/notification-options.model.ts @@ -3,7 +3,7 @@ import { NotificationAnimationsType } from './notification-animations-type'; export interface INotificationOptions { timeOut: number; clickToClose: boolean; - animate: NotificationAnimationsType; + animate: NotificationAnimationsType | string; } export class NotificationOptions implements INotificationOptions { @@ -13,7 +13,7 @@ export class NotificationOptions implements INotificationOptions { constructor(timeOut = 5000, clickToClose = true, - animate = NotificationAnimationsType.Scale) { + animate: NotificationAnimationsType | string = NotificationAnimationsType.Scale) { this.timeOut = timeOut; this.clickToClose = clickToClose; diff --git a/src/config/browse-by-type-config.interface.ts b/src/config/browse-by-type-config.interface.ts index f9d4f18d27..fae7890613 100644 --- a/src/config/browse-by-type-config.interface.ts +++ b/src/config/browse-by-type-config.interface.ts @@ -14,7 +14,7 @@ export interface BrowseByTypeConfig extends Config { /** * The type of Browse-By page to render */ - type: BrowseByType; + type: BrowseByType | string; /** * The metadata field to use for rendering starts-with options (only necessary when type is set to BrowseByType.Date) diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts deleted file mode 100644 index b3de1af50c..0000000000 --- a/src/environments/environment.dev.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { GlobalConfig } from '../config/global-config.interface'; - -export const environment: Partial = { - production: false -}; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts deleted file mode 100644 index 8665b872ee..0000000000 --- a/src/environments/environment.prod.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { GlobalConfig } from '../config/global-config.interface'; - -export const environment: Partial = { -}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 10767ed7d3..112d041b77 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1 +1 @@ -export const environment = {"production":true,"ui":{"ssl":false,"port":4000},"rest":{"ssl":true,"port":443},"cache":{"msToLive":{"default":900000},"control":"max-age=60","autoSync":{"defaultTime":0,"maxBufferSize":100,"timePerMethod":{"PATCH":3}}},"form":{"validatorMap":{"required":"required","regex":"pattern"}},"notifications":{"rtl":false,"position":["top","right"],"maxStack":8,"timeOut":5000,"clickToClose":true,"animate":"scale"},"submission":{"autosave":{"metadata":["dc.title","dc.identifier.doi","dc.identifier.pmid","dc.identifier.arxiv"],"timer":5},"icons":{"metadata":[{"name":"dc.author","style":"fas fa-user"},{"name":"default","style":""}],"authority":{"confidence":[{"value":600,"style":"text-success"},{"value":500,"style":"text-info"},{"value":400,"style":"text-warning"},{"value":"default","style":"text-muted"}]}}},"universal":{"preboot":true,"async":true,"time":false},"gaTrackingId":"","logDirectory":".","debug":false,"defaultLanguage":"en","languages":[{"code":"en","label":"English","active":true},{"code":"de","label":"Deutsch","active":true},{"code":"cs","label":"Čeština","active":true},{"code":"nl","label":"Nederlands","active":true},{"code":"pt","label":"Português","active":true}],"browseBy":{"oneYearLimit":10,"fiveYearLimit":30,"defaultLowerLimit":1900,"types":[{"id":"title","type":"title"},{"id":"dateissued","type":"date","metadataField":"dc.date.issued"},{"id":"author","type":"metadata"},{"id":"subject","type":"metadata"}]},"item":{"edit":{"undoTimeout":10000}},"collection":{"edit":{"undoTimeout":10000}},"theme":{"name":"default"}} \ No newline at end of file +export const environment = {"production":true,"ui":{"ssl":false,"host":"localhost","port":4000,"nameSpace":"/","baseUrl":"http://localhost:4000/"},"rest":{"ssl":true,"host":"dspace7.4science.cloud","port":443,"nameSpace":"/server/api","baseUrl":"https://dspace7.4science.cloud/server/api"},"cache":{"msToLive":{"default":900000},"control":"max-age=60","autoSync":{"defaultTime":0,"maxBufferSize":100,"timePerMethod":{"PATCH":3}}},"form":{"validatorMap":{"required":"required","regex":"pattern"}},"notifications":{"rtl":false,"position":["top","right"],"maxStack":8,"timeOut":5000,"clickToClose":true,"animate":"scale"},"submission":{"autosave":{"metadata":["dc.title","dc.identifier.doi","dc.identifier.pmid","dc.identifier.arxiv"],"timer":5},"icons":{"metadata":[{"name":"dc.author","style":"fas fa-user"},{"name":"default","style":""}],"authority":{"confidence":[{"value":600,"style":"text-success"},{"value":500,"style":"text-info"},{"value":400,"style":"text-warning"},{"value":"default","style":"text-muted"}]}}},"universal":{"preboot":true,"async":true,"time":false},"gaTrackingId":"","logDirectory":".","debug":false,"defaultLanguage":"en","languages":[{"code":"en","label":"English","active":true},{"code":"de","label":"Deutsch","active":true},{"code":"cs","label":"Čeština","active":true},{"code":"nl","label":"Nederlands","active":true},{"code":"pt","label":"Português","active":true}],"browseBy":{"oneYearLimit":10,"fiveYearLimit":30,"defaultLowerLimit":1900,"types":[{"id":"title","type":"title"},{"id":"dateissued","type":"date","metadataField":"dc.date.issued"},{"id":"author","type":"metadata"},{"id":"subject","type":"metadata"}]},"item":{"edit":{"undoTimeout":10000}},"collection":{"edit":{"undoTimeout":10000}},"theme":{"name":"default"}} \ No newline at end of file