diff --git a/.gitignore b/.gitignore index 85565177e63bd2d1b2e626c73fafe9648a52c71d..a72e318cdb0572f1eef856542f814d09d13f8f73 100644 --- a/.gitignore +++ b/.gitignore @@ -54,8 +54,10 @@ src/app/generated-api/ src/environments/version.ts src/environments/versions.ts src/environments/environment.local.ts +src/assets/app-version.json src/assets/configurations/environment.runtime.json -cypress/integration/environments/cypress-environment.local.ts src/assets/i18n/translate.csv +scripts/extract-git-version.script.ts +cypress/integration/environments/cypress-environment.local.ts proxy.conf.local.js /report.* diff --git a/ngsw-config.json b/ngsw-config.json index a1133b99a5aa4d154939650792e0c8a1868573f6..dcca5de4adfcbc68a5af9dddb22e6ecbc31927a0 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -25,17 +25,6 @@ "maxSize": 50, "maxAge": "10m" } - }, - { - "name": "configOverride", - "urls": [ - "**/assets/configurations/environment.runtime.json" - ], - "cacheConfig": { - "strategy": "freshness", - "maxSize": 50, - "maxAge": "10m" - } } ], "assetGroups": [ @@ -67,6 +56,7 @@ "/assets/**", "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)", "!/assets/configurations/environment.runtime.json", + "!/assets/app-version.json", "!/assets/i18n/*.json" ] } diff --git a/package-lock.json b/package-lock.json index 52a27433e653bead2f1f88133f1b3e9532ed1107..63d00029c9a17f1764ce80a732181e51efe1a758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,7 @@ "normalize.css": "8.0.1", "patch-package": "6.4.7", "rxjs": "7.5.2", - "solidify-frontend": "3.0.15", + "solidify-frontend": "3.0.16", "tiff.js": "1.0.0", "tslib": "2.3.1", "videojs-wavesurfer": "3.8.0", @@ -19674,9 +19674,9 @@ } }, "node_modules/solidify-frontend": { - "version": "3.0.15", - "resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-3.0.15.tgz", - "integrity": "sha512-pSK4NYD2TpAIQquBSCq76ogiR3TuAsNhODfBec0pw0VMqGM5Y97Jbi+vqw/E9KYtGsTRVMpZCSkrTe24Q4d3wQ==", + "version": "3.0.16", + "resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-3.0.16.tgz", + "integrity": "sha512-9ob8mTqYouDbJICBmn/bw+XzjAd/j+pcfNyL6wIit0Qi+0MLw65L/BTHqhf23+cFALZrkUfp9koQeVV3+ubBxA==", "license": "GPL-2.0-or-later", "dependencies": { "tslib": "^2.3.0" @@ -35891,9 +35891,9 @@ } }, "solidify-frontend": { - "version": "3.0.15", - "resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-3.0.15.tgz", - "integrity": "sha512-pSK4NYD2TpAIQquBSCq76ogiR3TuAsNhODfBec0pw0VMqGM5Y97Jbi+vqw/E9KYtGsTRVMpZCSkrTe24Q4d3wQ==", + "version": "3.0.16", + "resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-3.0.16.tgz", + "integrity": "sha512-9ob8mTqYouDbJICBmn/bw+XzjAd/j+pcfNyL6wIit0Qi+0MLw65L/BTHqhf23+cFALZrkUfp9koQeVV3+ubBxA==", "requires": { "tslib": "^2.3.0" } diff --git a/package.json b/package.json index e7956cf37962a1285f55d0b66e9d3dd31094ff9a..0ce313407c71b7ae140ad0ba8efd1a720b40a64d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "scripts": { "ng": "ng", - "postinstall": "patch-package", + "postinstall": "patch-package && npm run copy-scripts-solidify", "serve": "node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng serve --port 4200", "start": "npm run prepare && npm run generate-models && npm run serve", "start:solidify": "npm run prepare && npm run generate-models && npm run serve -- -c solidify", @@ -41,14 +41,15 @@ "extract-translations:json-to-csv": "ngx-translate-extract-csv -l fr,en,de -i ./src/assets/i18n -o ./src/assets/i18n/translate.csv -s ;", "generate-version": "ts-node --project tsconfig-ts-node.json scripts/extract-git-version.script.ts", "generate-models": "(rm src/app/generated-api -fr || echo generated-api directory is absent) && set env JAVA_OPTS='-Dmodels -DsupportingFiles' && openapi-generator-cli generate -i src/assets/openapi/DLCM-APIs.json -g typescript-angular -o src/app/generated-api --additional-properties=\"ngVersion=7.2.0,providedInRoot=true,modelSuffix=,modelFileSuffix=.partial.model,fileNaming=kebab-case,prependFormOrBodyParameters=true,modelPropertyNaming=original,enumPropertyNaming=UPPERCASE\" --skip-validate-spec && npm run clean-after-models-generation", + "copy-scripts-solidify": "cp -r node_modules/solidify-frontend/scripts/* scripts", "clean-after-models-generation": "cd src/app/generated-api && rm -fr .openapi-generator .gitignore .openapi-generator-ignore git_push.sh api api.module.ts configuration.ts encoder.ts index.ts variables.ts README.md && cp ../../assets/files-to-copy/README-open-api-txt-to-copy.txt README.txt", "build:sourcemaps": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --source-map --base-href /", "build:sourcemaps-prod": "npm run build:sourcemaps -- --configuration production", "build:sourcemaps-prod-local": "npm run build:sourcemaps -- -c production-local", "serve:prod": "cd dist/dlcm-portal && ws --spa index.html --rewrite \"/api/rss -> https://www.unige.ch/feed/rss\" -p 4200", - "simulate-prod-local": "rm -fr dist && cd ../solidify-frontend/ && npm run build && cp -fr dist/solidify-frontend ../dlcm-portal/node_modules && cd ../dlcm-portal/ && npm run build:sourcemaps-prod-local && npm run serve:prod", + "simulate-prod-local": "rm -fr dist && npm run build-solidify && npm run build:sourcemaps-prod-local && npm run serve:prod", "refresh-ngsw-config": "ngsw-config dist/dlcm-portal ngsw-config.json", - "build-solidify": "rm -rf node_modules/@unige && cd ../solidify-frontend && npm run build && cp -fr dist/solidify-frontend ../dlcm-portal/node_modules && cd ../dlcm-portal && npm run solidify-generate-timestamped-version", + "build-solidify": "rm -rf node_modules/solidify-frontend && cd ../solidify-frontend && npm run build && cp -fr dist/solidify-frontend ../dlcm-portal/node_modules && cd ../dlcm-portal && npm run solidify-generate-timestamped-version && npm run copy-scripts-solidify", "solidify-generate-timestamped-version": "ts-node --project tsconfig-ts-node.json scripts/solidify-generate-timestamped-version.script.ts", "update-project-version": "ts-node --project tsconfig-ts-node.json scripts/dlcm-update-version.script.ts", "extract-licenses": "license-checker-rseidelsohn --csv --out ./dist/dlcm-portal/third-party-licenses.csv" @@ -97,7 +98,7 @@ "normalize.css": "8.0.1", "patch-package": "6.4.7", "rxjs": "7.5.2", - "solidify-frontend": "3.0.15", + "solidify-frontend": "3.0.16", "tiff.js": "1.0.0", "tslib": "2.3.1", "videojs-wavesurfer": "3.8.0", diff --git a/scripts/extract-git-version.script.ts b/scripts/extract-git-version.script.ts deleted file mode 100644 index 12c8b17c6d3c09cf2eaabeda4b331f121cad5ab3..0000000000000000000000000000000000000000 --- a/scripts/extract-git-version.script.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * %%---------------------------------------------------------------------------------------------- - * DLCM Technology - DLCM Portal - extract-git-version.script.ts - * SPDX-License-Identifier: GPL-2.0-or-later - * %----------------------------------------------------------------------------------------------% - * Copyright (C) 2017 - 2022 University of Geneva - * %----------------------------------------------------------------------------------------------% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-2.0.html>. - * ----------------------------------------------------------------------------------------------%% - */ - -/* eslint-disable no-console */ -import { - promises as fsPromises, - writeFileSync, -} from "fs"; -import {parseString} from "xml2js"; - -const util = require("util"); -const exec = util.promisify(require("child_process").exec); - -const createVersionsFile = async (filename: string): Promise<void> => { - let version = undefined; - fsPromises.readFile("./pom.xml", "utf-8") - .then((xml) => { - parseString(xml, (err, result) => { - if (err) { - console.log("There was an error when parsing the file pom.xml to json: " + err); - } else { - version = result.project.version; - } - }); - }) - .catch((reason) => { - console.log("There was some problem reading the file pom.xml: " + reason); - }); - - const revision = (await exec("git rev-parse --short HEAD")).stdout.toString().trim(); - const branch = (await exec("git rev-parse --abbrev-ref HEAD")).stdout.toString().trim(); - - console.log(`version: '${version}', revision: '${revision}', branch: '${branch}'`); - - const content = ` -/* eslint-disable solidify/copyright-header */ -// this file is automatically generated by git.version.ts script -export const versions: Versions = { - version: "${version}", - revision: "${revision}", - branch: "${branch}", -}; - -export interface Versions { - version: string; - revision: string; - branch: string; -} -`; - - writeFileSync(filename, content, {encoding: "utf8"}); -}; - -createVersionsFile("src/environments/versions.ts"); diff --git a/src/app/app.component.html b/src/app/app.component.html index c25ffd933a537d9f07ef0df2f2cc6fd7d71e9245..478235b29722a285a0e3322541511007092f6615 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -34,6 +34,7 @@ [isHomePage]="isHomePage" [logged]="isLoggedObs | async" [logo]="logo" + [appVersion]="appVersionObs | async" [numberArchiveInCart]="numberArchiveInCartObs | async" [numberMyOrderReadyNew]="localStorageHelper.getListItem(localStorageEnum.newOrderAvailable).length" [numberPendingRequestNotificationInbox]="numberPendingRequestNotificationInboxObs | async" @@ -77,8 +78,9 @@ <dlcm-footer-container *ngIf="isApplicationInitializedObs | async" class="footer" - (updateChange)="appStatusService.reloadApp()" + [appVersion]="appVersionObs | async" [updateVersion]="appStatusService.updateAvailable | async" + (updateChange)="appStatusService.reloadApp()" ></dlcm-footer-container> </div> diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 70b057eeb0f15765bc398857991dc35297c8ccda..ce2a59ad61e9a46fbfdcc6cc4e7d1c2a4938db78 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -63,6 +63,7 @@ import { import { AbstractAppComponent, AppStatusService, + AppVersion, BreakpointService, CookieConsentService, DialogUtil, @@ -96,6 +97,8 @@ export class AppComponent extends AbstractAppComponent { numberPendingRequestNotificationInboxObs: Observable<number> = MemoizedUtil.total(this._store, AppNotificationInboxState); numberArchiveInCartObs: Observable<number> = MemoizedUtil.total(this._store, AppCartArchiveState); + appVersionObs: Observable<AppVersion> = MemoizedUtil.select(this._store, AppState, state => state.appVersion); + get localStorageEnum(): typeof LocalStorageEnum { return LocalStorageEnum; } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6f4451a2987f2e83a5617a0d423efd72eb2e686e..8f1a2b88b10541f7ea80d6db00e2a6b1fcc83417 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -80,7 +80,6 @@ import {AppSystemPropertyState} from "@app/stores/system-property/app-system-pro import {AppTocState} from "@app/stores/toc/app-toc.state"; import {AppUserState} from "@app/stores/user/app-user.state"; import {environment} from "@environments/environment"; -import {versions} from "@environments/versions"; import {FormlyModule} from "@ngx-formly/core"; import {FormlyMaterialModule} from "@ngx-formly/material"; import { @@ -106,6 +105,7 @@ import { } from "ngx-ui-tour-md-menu"; import { AppConfigService, + CacheBustingUtil, COOKIE_CONSENT_PREFERENCES, CustomMatPaginatorIntlService, DATA_TABLE_COMPONENT, @@ -182,7 +182,7 @@ export const createDefaultStorage: () => Storage | null = () => environment.toke // required for AOT compilation export const HttpLoaderFactory: (http: HttpClient) => HttpTranslateLoaderExtra = http => new HttpTranslateLoaderExtra(http, { - suffix: `.json?cacheBuster=${versions.version}${versions.branch}${versions.revision}`, + suffix: `.json` + CacheBustingUtil.generateCacheBustingQueryParam(), }, environment); @NgModule({ diff --git a/src/app/components/container/footer/footer.container.html b/src/app/components/container/footer/footer.container.html index 77ce5234fb8420ec7398c60973019b6609e3905d..d64f233b633ae638b9806e85772a257c467d754d 100644 --- a/src/app/components/container/footer/footer.container.html +++ b/src/app/components/container/footer/footer.container.html @@ -42,7 +42,7 @@ <div class="version"> <solidify-icon [iconName]="iconNameEnum.appVersion" [matTooltipPosition]="'left'" - [matTooltip]="appUtil.getVersions()" + [matTooltip]="appUtil.getVersions(appVersion)" ></solidify-icon> </div> </div> diff --git a/src/app/components/container/footer/footer.container.ts b/src/app/components/container/footer/footer.container.ts index fa7fe4db53101a57be7e2a7201196e3d6154bda2..4f195353b3064c2795035850465a52aaed7de255 100644 --- a/src/app/components/container/footer/footer.container.ts +++ b/src/app/components/container/footer/footer.container.ts @@ -38,6 +38,7 @@ import { Observable, } from "rxjs"; import { + AppVersion, CookieConsentService, MemoizedUtil, ObservableUtil, @@ -57,6 +58,9 @@ export class FooterContainer extends SharedAbstractContainer { userDocumentationObs: Observable<string> = MemoizedUtil.select(this._store, AppTocState, state => state.userDocumentation); darkModeObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.darkMode); + @Input() + appVersion: AppVersion; + @Input() updateVersion: string | undefined; diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html index 8ad04978f878c43463983c936784e76ef7c3d9fc..41cb81761f704d474afdf9194882b89cdff735f7 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html +++ b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html @@ -72,7 +72,7 @@ </li> <li class="version no-clickable"> - {{appUtil.getVersions()}} + {{appUtil.getVersions(appVersion)}} </li> </ul> </div> diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.ts b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.ts index 09b1aa1faf8e60d5b2153de1e7f4c98910152d43..ca9f833e3692cf494ee5e6811cc45ed15b27b9f2 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.ts +++ b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.ts @@ -31,9 +31,11 @@ import { import { ChangeDetectionStrategy, Component, + Input, } from "@angular/core"; import {AbstractMainToolbarPresentational} from "@app/components/presentationals/main-toolbar/abstract-main-toolbar/abstract-main-toolbar.presentational"; import {AppUtil} from "@app/shared/utils/app.util"; +import {AppVersion} from "solidify-frontend"; @Component({ selector: "dlcm-main-toolbar-mobile", @@ -49,6 +51,9 @@ import {AppUtil} from "@app/shared/utils/app.util"; ], }) export class MainToolbarMobilePresentational extends AbstractMainToolbarPresentational { + @Input() + appVersion: AppVersion; + get appUtil(): typeof AppUtil { return AppUtil; } diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.html b/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.html index 026692a648e158e4f5fa3f81fdc8296f5eda147c..3fade172bda27b0cdccb2e59c024f313f20cd76f 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.html +++ b/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.html @@ -39,6 +39,7 @@ [theme]="theme" [darkMode]="darkMode" [userRoles]="userRoles" + [appVersion]="appVersion" class="mobile-toolbar" > </dlcm-main-toolbar-mobile> diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.ts b/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.ts index 374f2184671ea2f4bcdd2245c493258839a375f0..7da5dc3589180f70678e39aae568a093242d6a1c 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.ts +++ b/src/app/components/presentationals/main-toolbar/main-toolbar/main-toolbar.presentational.ts @@ -35,7 +35,10 @@ import { BehaviorSubject, Observable, } from "rxjs"; -import {ObservableUtil} from "solidify-frontend"; +import { + AppVersion, + ObservableUtil, +} from "solidify-frontend"; @Component({ selector: "dlcm-main-toolbar", @@ -47,6 +50,9 @@ export class MainToolbarPresentational extends SharedAbstractPresentational { @Input() logged: boolean = false; + @Input() + appVersion: AppVersion; + @Input() currentPath: string; diff --git a/src/app/shared/utils/app.util.ts b/src/app/shared/utils/app.util.ts index ab58e489209eb8d8143b631a5431dd1719d5ce18..ca13e3290c700eab621f6e9c2ad02ddb2695b062 100644 --- a/src/app/shared/utils/app.util.ts +++ b/src/app/shared/utils/app.util.ts @@ -22,17 +22,19 @@ */ import {environment} from "@environments/environment"; -import {versions} from "@environments/versions"; -import {isNullOrUndefined} from "solidify-frontend"; +import { + AppVersion, + isNullOrUndefined, +} from "solidify-frontend"; export class AppUtil { - static getVersions(): string { - if (isNullOrUndefined(versions)) { + static getVersions(appVersion: AppVersion): string { + if (isNullOrUndefined(appVersion)) { return "not defined"; } if (environment.isDemoMode || !environment.production) { - return `${versions.version} - ${versions.branch} - ${versions.revision}`; + return `${appVersion.version} - ${appVersion.revision} - ${appVersion.date} - ${appVersion.branch}`; } - return `${versions.version} - ${versions.revision}`; + return `${appVersion.version} - ${appVersion.revision} - ${appVersion.date}`; } } diff --git a/src/environments/environment.prod-local.ts b/src/environments/environment.prod-local.ts index d679942987c715e1e4b2f333403e597d3297b3de..cfa9dc72ef04278e6b27d3dce1afd7aef12aeb26 100644 --- a/src/environments/environment.prod-local.ts +++ b/src/environments/environment.prod-local.ts @@ -21,10 +21,12 @@ * ----------------------------------------------------------------------------------------------%% */ +import {defaultEnvironment} from "@environments/environment.defaults"; import {environmentLocal} from "@environments/environment.local"; import {DlcmEnvironment} from "./environment.defaults.model"; export const environment: DlcmEnvironment = { + ...defaultEnvironment, ...environmentLocal, production: true, forceRuntimeOverrideSetting: true,