From f4c43201cc7a46af8e3c5a85c7d76886020cf448 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 23 Jan 2023 15:03:20 +0100 Subject: [PATCH 1/8] fix: updated manifest file --- src/index.html | 2 +- src/{manifest.json => manifest.webmanifest} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/{manifest.json => manifest.webmanifest} (96%) diff --git a/src/index.html b/src/index.html index 7944acdacb..e8dc6545df 100644 --- a/src/index.html +++ b/src/index.html @@ -25,7 +25,7 @@ content="width=device-width, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover"> - + diff --git a/src/manifest.json b/src/manifest.webmanifest similarity index 96% rename from src/manifest.json rename to src/manifest.webmanifest index b56e030c96..fadac50631 100644 --- a/src/manifest.json +++ b/src/manifest.webmanifest @@ -4,8 +4,8 @@ "theme_color": "#1976d2", "background_color": "#fafafa", "display": "standalone", - "scope": ".", - "start_url": ".", + "scope": "./", + "start_url": "./", "icons": [ { "src": "assets/icons/icon-72x72.png", From 174d1f98354e2ed066b911bb5749e415870c7101 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 23 Jan 2023 15:48:57 +0100 Subject: [PATCH 2/8] updated manifest in angular.json --- angular.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index 675e180ba3..12a8e12798 100644 --- a/angular.json +++ b/angular.json @@ -23,7 +23,7 @@ "assets": [ "src/assets", "src/favicon.ico", - "src/manifest.json", + "src/manifest.webmanifest", { "glob": "**/*", "input": "node_modules/leaflet/dist/images/", @@ -104,7 +104,7 @@ "assets": [ "src/assets", "src/favicon.ico", - "src/manifest.json" + "src/manifest.webmanifest" ] } }, From 0e93a5ffe9dcd92b7b157b9bf8df98cfe42b3220 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 23 Jan 2023 16:07:37 +0100 Subject: [PATCH 3/8] updated service worker registration --- angular.json | 3 ++- src/app/app.module.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index 12a8e12798..5d84bca906 100644 --- a/angular.json +++ b/angular.json @@ -63,7 +63,8 @@ "with": "src/environments/environment.prod.ts" } ], - "serviceWorker": true + "serviceWorker": true, + "ngswConfigPath": "ngsw-config.json" }, "development": {} }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 94e111edf7..5e8062bdcf 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -82,8 +82,11 @@ import { TodosModule } from "./features/todos/todos.module"; declarations: [AppComponent], imports: [ // Global Angular modules - ServiceWorkerModule.register("/ngsw-worker.js", { + ServiceWorkerModule.register("ngsw-worker.js", { enabled: environment.production, + // Register the ServiceWorker as soon as the application is stable + // or after 30 seconds (whichever comes first). + registrationStrategy: "registerWhenStable:30000", }), Angulartics2Module.forRoot({ developerMode: !environment.production, From e44902a9de8152f6b7b5e713852cb2149425d220 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 23 Jan 2023 21:28:33 +0100 Subject: [PATCH 4/8] removed i18n in main.ts --- build/Dockerfile | 3 +- src/main.ts | 78 +++++----------------------------------- src/manifest.webmanifest | 4 +-- 3 files changed, 11 insertions(+), 74 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 82cb08f2fa..604777e366 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -59,8 +59,7 @@ ARG SENTRY_ORG ARG SENTRY_PROJECT RUN if [ "$SENTRY_AUTH_TOKEN" != "" ] ; then \ npm install -g @sentry/cli &&\ - sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases --org=$SENTRY_ORG --project=$SENTRY_PROJECT files ndb-core@$APP_VERSION upload-sourcemaps dist && \ - rm dist/*.map ; fi + sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases --org=$SENTRY_ORG --project=$SENTRY_PROJECT files ndb-core@$APP_VERSION upload-sourcemaps dist ; fi ### PROD image diff --git a/src/main.ts b/src/main.ts index 55fca96eec..f5c929220e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,81 +1,19 @@ -/* - * This file is part of ndb-core. - * - * ndb-core 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 3 of the License, or - * (at your option) any later version. - * - * ndb-core 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 ndb-core. If not, see . - */ - -import { loadTranslations } from "@angular/localize"; -import { registerLocaleData } from "@angular/common"; -import { - DEFAULT_LANGUAGE, - LANGUAGE_LOCAL_STORAGE_KEY, -} from "./app/core/language/language-statics"; -import { environment } from "./environments/environment"; import { enableProdMode } from "@angular/core"; -import * as parseXliffToJson from "./app/utils/parse-xliff-to-js"; import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; -import { AppSettings } from "./app/core/app-config/app-settings"; -import { LoggingService } from "./app/core/logging/logging.service"; -import { PwaInstallService } from "./app/core/pwa-install/pwa-install.service"; +import { LoggingService } from "app/core/logging/logging.service"; +import { PwaInstallService } from "app/core/pwa-install/pwa-install.service"; + +import { AppModule } from "./app/app.module"; +import { environment } from "./environments/environment"; if (environment.production) { enableProdMode(); } - -// Listening to event as soon as possible PwaInstallService.registerPWAInstallListener(); - // Initialize remote logging LoggingService.initRemoteLogging({ dsn: environment.remoteLoggingDsn, }); -const logger = new LoggingService(); - -const appLang = - localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) ?? DEFAULT_LANGUAGE; -if (appLang === DEFAULT_LANGUAGE) { - bootstrap(); -} else { - initLanguage(appLang).finally(() => bootstrap()); -} - -function bootstrap(): Promise { - // Dynamically load the main module after the language has been initialized - return AppSettings.initRuntimeSettings() - .catch((err) => logger.error(err)) - .then(() => import("./app/app.module")) - .then((m) => platformBrowserDynamic().bootstrapModule(m.AppModule)) - .catch((err) => logger.error(err)); -} - -async function initLanguage(locale: string): Promise { - const json = await fetch("/assets/locale/messages." + locale + ".json") - .then((r) => r.json()) - .catch(() => - // parse translation at runtime if JSON file is not available - fetch("/assets/locale/messages." + locale + ".xlf") - .then((r) => r.text()) - .then((t) => parseXliffToJson(t)) - ); - - loadTranslations(json); - $localize.locale = locale; - // This is needed for locale-aware components & pipes to work. - // Add the required locales to `webpackInclude` to keep the bundle size small - const localeModule = await import( - /* webpackInclude: /(fr|de|it)\.mjs/ */ - `../node_modules/@angular/common/locales/${locale}` - ); - registerLocaleData(localeModule.default); -} +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err)); diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest index fadac50631..6864de245c 100644 --- a/src/manifest.webmanifest +++ b/src/manifest.webmanifest @@ -33,7 +33,7 @@ "type": "image/png" }, { - "src": "manifest-icon-192.png", + "src": "manifest-icon-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable any" @@ -44,7 +44,7 @@ "type": "image/png" }, { - "src": "manifest-icon-512.png", + "src": "manifest-icon-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable any" From c7f7d0c3f9e4d949eea825ee9ec1b770665ff98e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 25 Jan 2023 09:33:03 +0100 Subject: [PATCH 5/8] fixed icon file names --- src/manifest.webmanifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest index 6864de245c..9af934f6da 100644 --- a/src/manifest.webmanifest +++ b/src/manifest.webmanifest @@ -33,7 +33,7 @@ "type": "image/png" }, { - "src": "manifest-icon-192x192.png", + "src": "assets/icons/manifest-icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable any" @@ -44,7 +44,7 @@ "type": "image/png" }, { - "src": "manifest-icon-512x512.png", + "src": "assets/icons/manifest-icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable any" From 30ef1446fcb2d51e4c7034ccb8c0656657b9c6b0 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 25 Jan 2023 10:10:00 +0100 Subject: [PATCH 6/8] using different icons for maskable and any --- src/manifest.webmanifest | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest index 9af934f6da..dd9d389825 100644 --- a/src/manifest.webmanifest +++ b/src/manifest.webmanifest @@ -32,22 +32,32 @@ "sizes": "152x152", "type": "image/png" }, + { + "src": "assets/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, { "src": "assets/icons/manifest-icon-192.png", "sizes": "192x192", "type": "image/png", - "purpose": "maskable any" + "purpose": "maskable" }, { "src": "assets/icons/icon-384x384.png", "sizes": "384x384", "type": "image/png" }, + { + "src": "assets/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + }, { "src": "assets/icons/manifest-icon-512.png", "sizes": "512x512", "type": "image/png", - "purpose": "maskable any" + "purpose": "maskable" } ] } From b8e3f4b9ab77cdce5a1b9f73ef79f2c59358d525 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 25 Jan 2023 14:44:03 +0100 Subject: [PATCH 7/8] undone changes to main.ts --- src/main.ts | 78 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index f5c929220e..55fca96eec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,19 +1,81 @@ -import { enableProdMode } from "@angular/core"; -import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; -import { LoggingService } from "app/core/logging/logging.service"; -import { PwaInstallService } from "app/core/pwa-install/pwa-install.service"; +/* + * This file is part of ndb-core. + * + * ndb-core 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 3 of the License, or + * (at your option) any later version. + * + * ndb-core 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 ndb-core. If not, see . + */ -import { AppModule } from "./app/app.module"; +import { loadTranslations } from "@angular/localize"; +import { registerLocaleData } from "@angular/common"; +import { + DEFAULT_LANGUAGE, + LANGUAGE_LOCAL_STORAGE_KEY, +} from "./app/core/language/language-statics"; import { environment } from "./environments/environment"; +import { enableProdMode } from "@angular/core"; +import * as parseXliffToJson from "./app/utils/parse-xliff-to-js"; +import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; +import { AppSettings } from "./app/core/app-config/app-settings"; +import { LoggingService } from "./app/core/logging/logging.service"; +import { PwaInstallService } from "./app/core/pwa-install/pwa-install.service"; if (environment.production) { enableProdMode(); } + +// Listening to event as soon as possible PwaInstallService.registerPWAInstallListener(); + // Initialize remote logging LoggingService.initRemoteLogging({ dsn: environment.remoteLoggingDsn, }); -platformBrowserDynamic() - .bootstrapModule(AppModule) - .catch((err) => console.error(err)); +const logger = new LoggingService(); + +const appLang = + localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) ?? DEFAULT_LANGUAGE; +if (appLang === DEFAULT_LANGUAGE) { + bootstrap(); +} else { + initLanguage(appLang).finally(() => bootstrap()); +} + +function bootstrap(): Promise { + // Dynamically load the main module after the language has been initialized + return AppSettings.initRuntimeSettings() + .catch((err) => logger.error(err)) + .then(() => import("./app/app.module")) + .then((m) => platformBrowserDynamic().bootstrapModule(m.AppModule)) + .catch((err) => logger.error(err)); +} + +async function initLanguage(locale: string): Promise { + const json = await fetch("/assets/locale/messages." + locale + ".json") + .then((r) => r.json()) + .catch(() => + // parse translation at runtime if JSON file is not available + fetch("/assets/locale/messages." + locale + ".xlf") + .then((r) => r.text()) + .then((t) => parseXliffToJson(t)) + ); + + loadTranslations(json); + $localize.locale = locale; + // This is needed for locale-aware components & pipes to work. + // Add the required locales to `webpackInclude` to keep the bundle size small + const localeModule = await import( + /* webpackInclude: /(fr|de|it)\.mjs/ */ + `../node_modules/@angular/common/locales/${locale}` + ); + registerLocaleData(localeModule.default); +} From 89aadfbbc0f434095b3f9f6973c92c948cc5bed0 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 25 Jan 2023 15:06:02 +0100 Subject: [PATCH 8/8] undone some changes --- build/Dockerfile | 3 ++- src/app/app.module.ts | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 604777e366..82cb08f2fa 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -59,7 +59,8 @@ ARG SENTRY_ORG ARG SENTRY_PROJECT RUN if [ "$SENTRY_AUTH_TOKEN" != "" ] ; then \ npm install -g @sentry/cli &&\ - sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases --org=$SENTRY_ORG --project=$SENTRY_PROJECT files ndb-core@$APP_VERSION upload-sourcemaps dist ; fi + sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases --org=$SENTRY_ORG --project=$SENTRY_PROJECT files ndb-core@$APP_VERSION upload-sourcemaps dist && \ + rm dist/*.map ; fi ### PROD image diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5e8062bdcf..7f5305c374 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -84,9 +84,6 @@ import { TodosModule } from "./features/todos/todos.module"; // Global Angular modules ServiceWorkerModule.register("ngsw-worker.js", { enabled: environment.production, - // Register the ServiceWorker as soon as the application is stable - // or after 30 seconds (whichever comes first). - registrationStrategy: "registerWhenStable:30000", }), Angulartics2Module.forRoot({ developerMode: !environment.production,