diff --git a/angular.json b/angular.json index e18be14..b46e64d 100644 --- a/angular.json +++ b/angular.json @@ -35,7 +35,8 @@ "inlineStyleLanguage": "scss", "assets": [ "src/favicon.ico", - "src/assets" + "src/assets", + "src/manifest.webmanifest" ], "styles": [ "@angular/material/prebuilt-themes/deeppurple-amber.css", @@ -51,7 +52,9 @@ "base64-js", "js-sha256" ], - "localize": true + "localize": true, + "serviceWorker": true, + "ngswConfigPath": "ngsw-config.json" }, "configurations": { "production": { @@ -148,7 +151,8 @@ "inlineStyleLanguage": "scss", "assets": [ "src/favicon.ico", - "src/assets" + "src/assets", + "src/manifest.webmanifest" ], "styles": [ "@angular/material/prebuilt-themes/deeppurple-amber.css", diff --git a/ngsw-config.json b/ngsw-config.json new file mode 100644 index 0000000..f8bf210 --- /dev/null +++ b/ngsw-config.json @@ -0,0 +1,30 @@ +{ + "$schema": "./node_modules/@angular/service-worker/config/schema.json", + "index": "/index.html", + "assetGroups": [ + { + "name": "app", + "installMode": "prefetch", + "resources": { + "files": [ + "/favicon.ico", + "/index.html", + "/manifest.webmanifest", + "/*.css", + "/*.js" + ] + } + }, + { + "name": "assets", + "installMode": "lazy", + "updateMode": "prefetch", + "resources": { + "files": [ + "/assets/**", + "/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)" + ] + } + } + ] +} diff --git a/package.json b/package.json index 3a97ed9..9823b43 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@angular/platform-browser": "^16.1.0", "@angular/platform-browser-dynamic": "^16.1.0", "@angular/router": "^16.1.0", + "@angular/service-worker": "^16.1.0", "@ngrx/effects": "^16.1.0", "@ngrx/store": "^16.1.0", "keycloak-angular": "^14.0.0", diff --git a/src/assets/icons/icon-128x128.png b/src/assets/icons/icon-128x128.png new file mode 100644 index 0000000..d215b87 Binary files /dev/null and b/src/assets/icons/icon-128x128.png differ diff --git a/src/assets/icons/icon-144x144.png b/src/assets/icons/icon-144x144.png new file mode 100644 index 0000000..1393a36 Binary files /dev/null and b/src/assets/icons/icon-144x144.png differ diff --git a/src/assets/icons/icon-152x152.png b/src/assets/icons/icon-152x152.png new file mode 100644 index 0000000..2fe7697 Binary files /dev/null and b/src/assets/icons/icon-152x152.png differ diff --git a/src/assets/icons/icon-192x192.png b/src/assets/icons/icon-192x192.png new file mode 100644 index 0000000..df9a5a8 Binary files /dev/null and b/src/assets/icons/icon-192x192.png differ diff --git a/src/assets/icons/icon-384x384.png b/src/assets/icons/icon-384x384.png new file mode 100644 index 0000000..e54e8d3 Binary files /dev/null and b/src/assets/icons/icon-384x384.png differ diff --git a/src/assets/icons/icon-512x512.png b/src/assets/icons/icon-512x512.png new file mode 100644 index 0000000..51ee297 Binary files /dev/null and b/src/assets/icons/icon-512x512.png differ diff --git a/src/assets/icons/icon-72x72.png b/src/assets/icons/icon-72x72.png new file mode 100644 index 0000000..c568de8 Binary files /dev/null and b/src/assets/icons/icon-72x72.png differ diff --git a/src/assets/icons/icon-96x96.png b/src/assets/icons/icon-96x96.png new file mode 100644 index 0000000..7a71dbc Binary files /dev/null and b/src/assets/icons/icon-96x96.png differ diff --git a/src/index.html b/src/index.html index a4ae104..1560e76 100644 --- a/src/index.html +++ b/src/index.html @@ -7,10 +7,13 @@ - + + + + diff --git a/src/main.ts b/src/main.ts index 50eac33..427a38e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import {bootstrapApplication} from "@angular/platform-browser"; import {AppComponent} from "./app/app.component"; -import {APP_INITIALIZER} from "@angular/core"; +import {APP_INITIALIZER, isDevMode} from "@angular/core"; import {KeycloakBearerInterceptor, KeycloakService} from "keycloak-angular"; import {environment} from "./environments/environment"; import {provideRouter, withComponentInputBinding} from "@angular/router"; @@ -13,6 +13,7 @@ import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from "@ang import {ROOT_ROUTES} from "./app/app.routes"; import "@angular/localize/init"; import {Location} from "@angular/common"; +import {provideServiceWorker} from '@angular/service-worker'; function initializeKeycloak(keycloak: KeycloakService, locationService: Location) { return () => @@ -24,7 +25,7 @@ function initializeKeycloak(keycloak: KeycloakService, locationService: Location }, initOptions: { onLoad: 'check-sso', - silentCheckSsoRedirectUri:`${window.location.origin}${locationService.prepareExternalUrl('/assets/silent-check-sso.html')}`, + silentCheckSsoRedirectUri: `${window.location.origin}${locationService.prepareExternalUrl('/assets/silent-check-sso.html')}`, flow: "standard" }, shouldAddToken: (request) => { @@ -43,19 +44,20 @@ bootstrapApplication(AppComponent, { multi: true, deps: [KeycloakService, Location], }, - provideRouter(ROOT_ROUTES, - withComponentInputBinding()), + provideRouter(ROOT_ROUTES, withComponentInputBinding()), provideStore(), provideEffects(), provideAnimations(), - provideHttpClient( - withInterceptorsFromDi() - ), + provideHttpClient(withInterceptorsFromDi()), KeycloakService, { provide: HTTP_INTERCEPTORS, useClass: KeycloakBearerInterceptor, multi: true - } + }, + provideServiceWorker('ngsw-worker.js', { + enabled: !isDevMode(), + registrationStrategy: 'registerWhenStable:30000' + }) ] }).catch(err => console.error(err)); diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest new file mode 100644 index 0000000..53a220a --- /dev/null +++ b/src/manifest.webmanifest @@ -0,0 +1,59 @@ +{ + "name": "wahlrecht-frontend", + "short_name": "wahlrecht-frontend", + "theme_color": "#1976d2", + "background_color": "#fafafa", + "display": "standalone", + "scope": "./", + "start_url": "./", + "icons": [ + { + "src": "assets/icons/icon-72x72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-96x96.png", + "sizes": "96x96", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-128x128.png", + "sizes": "128x128", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-144x144.png", + "sizes": "144x144", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-152x152.png", + "sizes": "152x152", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-384x384.png", + "sizes": "384x384", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable any" + } + ] +}