Skip to content

Commit

Permalink
Story #11854: Clean code - Migrate service workers
Browse files Browse the repository at this point in the history
  • Loading branch information
ebernard committed Jul 2, 2024
1 parent 6603e97 commit 9adccdb
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 28 deletions.
56 changes: 40 additions & 16 deletions ui/ui-frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"assets": [
"projects/identity/src/assets",
"projects/identity/src/favicon.ico",
"projects/identity/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand Down Expand Up @@ -70,7 +71,8 @@
"input": "projects/vitamui-library/src/assets",
"output": "/assets"
}
]
],
"serviceWorker": "projects/identity/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -116,7 +118,8 @@
},
"assets": [
"projects/identity/src/assets",
"projects/identity/src/favicon.ico"
"projects/identity/src/favicon.ico",
"projects/identity/src/manifest.webmanifest"
]
}
},
Expand Down Expand Up @@ -160,6 +163,7 @@
"assets": [
"projects/portal/src/assets",
"projects/portal/src/favicon.ico",
"projects/portal/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand Down Expand Up @@ -200,7 +204,8 @@
"input": "projects/vitamui-library/src/assets",
"output": "/assets"
}
]
],
"serviceWorker": "projects/portal/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -240,7 +245,8 @@
},
"assets": [
"projects/portal/src/assets",
"projects/portal/src/favicon.ico"
"projects/portal/src/favicon.ico",
"projects/portal/src/manifest.webmanifest"
]
}
},
Expand Down Expand Up @@ -284,6 +290,7 @@
"assets": [
"projects/referential/src/assets",
"projects/referential/src/favicon.ico",
"projects/referential/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand Down Expand Up @@ -324,7 +331,8 @@
"input": "projects/vitamui-library/src/assets",
"output": "/assets"
}
]
],
"serviceWorker": "projects/referential/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -361,7 +369,8 @@
"karmaConfig": "karma.conf.ci.js",
"assets": [
"projects/referential/src/favicon.ico",
"projects/referential/src/assets"
"projects/referential/src/assets",
"projects/referential/src/manifest.webmanifest"
],
"styles": [
"projects/referential/src/sass/styles.scss"
Expand Down Expand Up @@ -456,6 +465,7 @@
"assets": [
"projects/design-system/src/assets",
"projects/design-system/src/favicon.ico",
"projects/design-system/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand All @@ -480,7 +490,8 @@
"replace": "projects/design-system/src/environments/environment.ts",
"with": "projects/design-system/src/environments/environment.prod.ts"
}
]
],
"serviceWorker": "projects/design-system/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -521,7 +532,8 @@
},
"assets": [
"projects/design-system/src/assets",
"projects/design-system/src/favicon.ico"
"projects/design-system/src/favicon.ico",
"projects/design-system/src/manifest.webmanifest"
]
}
},
Expand Down Expand Up @@ -565,6 +577,7 @@
"assets": [
"projects/ingest/src/favicon.ico",
"projects/ingest/src/assets",
"projects/ingest/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand All @@ -589,7 +602,8 @@
"replace": "projects/ingest/src/environments/environment.ts",
"with": "projects/ingest/src/environments/environment.prod.ts"
}
]
],
"serviceWorker": "projects/ingest/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -626,7 +640,8 @@
"karmaConfig": "karma.conf.ci.js",
"assets": [
"projects/ingest/src/favicon.ico",
"projects/ingest/src/assets"
"projects/ingest/src/assets",
"projects/ingest/src/manifest.webmanifest"
],
"styles": [
"projects/ingest/src/sass/styles.scss"
Expand Down Expand Up @@ -679,6 +694,7 @@
"assets": [
"projects/archive-search/src/assets",
"projects/archive-search/src/favicon.ico",
"projects/archive-search/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand All @@ -704,7 +720,8 @@
"replace": "projects/archive-search/src/environments/environment.ts",
"with": "projects/archive-search/src/environments/environment.prod.ts"
}
]
],
"serviceWorker": "projects/archive-search/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -750,7 +767,8 @@
},
"assets": [
"projects/archive-search/src/assets",
"projects/archive-search/src/favicon.ico"
"projects/archive-search/src/favicon.ico",
"projects/archive-search/src/manifest.webmanifest"
]
}
},
Expand Down Expand Up @@ -794,6 +812,7 @@
"assets": [
"projects/collect/src/assets",
"projects/collect/src/favicon.ico",
"projects/collect/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand All @@ -818,7 +837,8 @@
"replace": "projects/collect/src/environments/environment.ts",
"with": "projects/collect/src/environments/environment.prod.ts"
}
]
],
"serviceWorker": "projects/collect/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -864,7 +884,8 @@
},
"assets": [
"projects/collect/src/assets",
"projects/collect/src/favicon.ico"
"projects/collect/src/favicon.ico",
"projects/collect/src/manifest.webmanifest"
]
}
},
Expand Down Expand Up @@ -913,6 +934,7 @@
"assets": [
"projects/pastis/src/assets",
"projects/pastis/src/favicon.ico",
"projects/pastis/src/manifest.webmanifest",
{
"glob": "**/*",
"input": "projects/vitamui-library/src/assets",
Expand All @@ -937,7 +959,8 @@
"replace": "projects/pastis/src/environments/environment.ts",
"with": "projects/pastis/src/environments/environment.prod.ts"
}
]
],
"serviceWorker": "projects/pastis/ngsw-config.json"
},
"development": {
"optimization": false,
Expand Down Expand Up @@ -987,7 +1010,8 @@
"karmaConfig": "karma.conf.ci.js",
"assets": [
"projects/pastis/src/favicon.ico",
"projects/pastis/src/assets"
"projects/pastis/src/assets",
"projects/pastis/src/manifest.webmanifest"
],
"styles": [
"projects/pastis/src/sass/styles.scss"
Expand Down
7 changes: 6 additions & 1 deletion ui/ui-frontend/projects/archive-search/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ registerLocaleData(localeFr, 'fr');
deps: [HttpBackend],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
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',
}),
],
providers: [
Title,
Expand Down
3 changes: 3 additions & 0 deletions ui/ui-frontend/projects/archive-search/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
<title>Vitam-UI</title>
<base href="/" />

<meta name="Description" content="Portail des applications de l'archivage." />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="manifest" href="manifest.webmanifest" />
<meta name="theme-color" content="#702382" />
</head>
<body>
<app-root>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "VitamUI Archive Search",
"short_name": "Archive Search",
"theme_color": "#702382",
"background_color": "#f5f7fc",
"display": "browser"
}
7 changes: 6 additions & 1 deletion ui/ui-frontend/projects/collect/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ registerLocaleData(localeFr, 'fr');
deps: [HttpBackend],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
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',
}),
],
providers: [Title, { provide: LOCALE_ID, useValue: 'fr' }, { provide: WINDOW_LOCATION, useValue: window.location }, DatePipe],
bootstrap: [AppComponent],
Expand Down
3 changes: 3 additions & 0 deletions ui/ui-frontend/projects/collect/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
<title>Vitam-UI</title>
<base href="/" />

<meta name="Description" content="Portail des applications de l'archivage." />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<link rel="manifest" href="manifest.webmanifest" />
<meta name="theme-color" content="#702382" />
</head>
<body>
<app-root>
Expand Down
7 changes: 7 additions & 0 deletions ui/ui-frontend/projects/collect/src/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "VitamUI Collect",
"short_name": "Collect",
"theme_color": "#702382",
"background_color": "#f5f7fc",
"display": "browser"
}
9 changes: 8 additions & 1 deletion ui/ui-frontend/projects/design-system/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import { registerLocaleData } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { default as localeFr } from '@angular/common/locales/fr';
import { LOCALE_ID, NgModule } from '@angular/core';
import { LOCALE_ID, NgModule, isDevMode } from '@angular/core';
import { MatLegacyListModule as MatListModule } from '@angular/material/legacy-list';
import { MatSidenavModule } from '@angular/material/sidenav';
import { BrowserModule, Title } from '@angular/platform-browser';
Expand Down Expand Up @@ -73,6 +73,7 @@ import { TooltipModule } from './components/tooltip/tooltip.module';
import { TranslationModule } from './components/translation/translation.module';
import { TypographyModule } from './components/typography/typography.module';
import { DesignSystemModule } from './design-system/design-system.module';
import { ServiceWorkerModule } from '@angular/service-worker';

registerLocaleData(localeFr, 'fr');

Expand Down Expand Up @@ -115,6 +116,12 @@ export function httpLoaderFactory(httpClient: HttpClient): MultiTranslateHttpLoa
deps: [HttpClient],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: !isDevMode(),
// Register the ServiceWorker as soon as the application is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000',
}),
],
providers: [
Title,
Expand Down
3 changes: 2 additions & 1 deletion ui/ui-frontend/projects/design-system/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<meta name="Description" content="Portail des applications de l'archivage." />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta name="theme-color" content="#1976d2" />
<link rel="manifest" href="manifest.webmanifest" />
<meta name="theme-color" content="#702382" />
</head>
<body>
<design-system-root>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "VitamUI Design System",
"short_name": "Design System",
"theme_color": "#702382",
"background_color": "#f5f7fc",
"display": "browser"
}
7 changes: 6 additions & 1 deletion ui/ui-frontend/projects/identity/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export function httpLoaderFactory(httpBackend: HttpBackend): MultiTranslateHttpL
deps: [HttpBackend],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
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',
}),
],
providers: [Title, { provide: LOCALE_ID, useValue: 'fr' }, { provide: WINDOW_LOCATION, useValue: window.location }, DatePipe],
bootstrap: [AppComponent],
Expand Down
3 changes: 2 additions & 1 deletion ui/ui-frontend/projects/identity/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta name="theme-color" content="#1976d2" />
<link rel="manifest" href="manifest.webmanifest" />
<meta name="theme-color" content="#702382" />
</head>
<body>
<app-root>
Expand Down
7 changes: 7 additions & 0 deletions ui/ui-frontend/projects/identity/src/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "VitamUI Identity",
"short_name": "Identity",
"theme_color": "#702382",
"background_color": "#f5f7fc",
"display": "browser"
}
7 changes: 6 additions & 1 deletion ui/ui-frontend/projects/ingest/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ registerLocaleData(localeFr, 'fr');
deps: [HttpBackend],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
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',
}),
],
providers: [Title, { provide: LOCALE_ID, useValue: 'fr' }, { provide: WINDOW_LOCATION, useValue: window.location }, DatePipe],
bootstrap: [AppComponent],
Expand Down
2 changes: 2 additions & 0 deletions ui/ui-frontend/projects/ingest/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="manifest" href="manifest.webmanifest" />
<meta name="theme-color" content="#702382" />
</head>
<body>
<app-root>
Expand Down
Loading

0 comments on commit 9adccdb

Please sign in to comment.