diff --git a/angular.json b/angular.json index 3b9543f85..8c9e1dc10 100644 --- a/angular.json +++ b/angular.json @@ -32,7 +32,8 @@ "glob": "**/*", "input": "apps/red-ui/src/assets/", "output": "/assets/" - } + }, + "apps/red-ui/src/manifest.webmanifest" ], "styles": [ "apps/red-ui/src/styles.scss" @@ -68,7 +69,9 @@ "maximumWarning": "6kb", "maximumError": "10kb" } - ] + ], + "serviceWorker": true, + "ngswConfigPath": "apps/red-ui/ngsw-config.json" } } }, @@ -147,7 +150,8 @@ } }, "cli": { - "defaultCollection": "@nrwl/angular" + "defaultCollection": "@nrwl/angular", + "analytics": false }, "schematics": { "@nrwl/angular:application": { @@ -159,4 +163,4 @@ } }, "defaultProject": "red-ui" -} +} \ No newline at end of file diff --git a/apps/red-ui/ngsw-config.json b/apps/red-ui/ngsw-config.json new file mode 100644 index 000000000..ea7898845 --- /dev/null +++ b/apps/red-ui/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/**", + "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" + ] + } + } + ] +} diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index ecfe56c77..facfd3485 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -38,6 +38,9 @@ import {MatSelectModule} from "@angular/material/select"; import {NgxDropzoneModule} from "ngx-dropzone"; import {MatSidenavModule} from "@angular/material/sidenav"; import { FileDetailsDialogComponent } from './screens/file/file-preview-screen/file-details-dialog/file-details-dialog.component'; +import {ToastrModule} from "ngx-toastr"; +import { ServiceWorkerModule } from '@angular/service-worker'; +import { environment } from '../environments/environment'; export function HttpLoaderFactory(httpClient: HttpClient) { return new TranslateHttpLoader(httpClient, '/assets/i18n/', '.json'); @@ -100,9 +103,11 @@ export function HttpLoaderFactory(httpClient: HttpClient) { MatTabsModule, MatButtonToggleModule, MatFormFieldModule, + ToastrModule.forRoot(), MatSelectModule, NgxDropzoneModule, - MatSidenavModule + MatSidenavModule, + ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) ], providers: [{ provide: KeycloakService, diff --git a/apps/red-ui/src/app/i18n/language.service.ts b/apps/red-ui/src/app/i18n/language.service.ts index f806dbbc8..ca1a2205d 100644 --- a/apps/red-ui/src/app/i18n/language.service.ts +++ b/apps/red-ui/src/app/i18n/language.service.ts @@ -33,4 +33,11 @@ export class LanguageService { get currentLanguage() { return this.translateService.currentLang; } + + changeLanguage(language: string) { + localStorage.setItem('redaction.language',language); + document.documentElement.lang = language; + this.translateService.use(language).subscribe(() => { + }); + } } diff --git a/apps/red-ui/src/app/notification/notification.service.ts b/apps/red-ui/src/app/notification/notification.service.ts index d97ff9f80..aca34b4cd 100644 --- a/apps/red-ui/src/app/notification/notification.service.ts +++ b/apps/red-ui/src/app/notification/notification.service.ts @@ -1,18 +1,36 @@ import {Injectable} from "@angular/core"; import {MatSnackBar} from "@angular/material/snack-bar"; +import {ToastrService} from "ngx-toastr"; +export enum NotificationType { + SUCCESS = 'SUCCESS', WARNING = 'WARNING', ERROR = 'ERROR', INFO = 'INFO', +} + @Injectable({ providedIn: 'root' }) export class NotificationService { - constructor(private readonly _snackBar: MatSnackBar) { + + constructor(private readonly _snackBar: MatSnackBar, + private readonly _toastr: ToastrService) { } - showToastNotification(message: string) { - this._snackBar.open(message, null, { - duration: 5000 - }); + showToastNotification(message: string, title?: string, notificationType: NotificationType = NotificationType.INFO) { + switch (notificationType) { + case NotificationType.ERROR: + this._toastr.error(message, title); + break; + case NotificationType.SUCCESS: + this._toastr.success(message, title); + break; + case NotificationType.WARNING: + this._toastr.warning(message, title); + break + case NotificationType.INFO: + this._toastr.info(message, title); + break + } } } diff --git a/apps/red-ui/src/app/screens/base-screen/base-screen.component.html b/apps/red-ui/src/app/screens/base-screen/base-screen.component.html index 5bef5c50b..a3825abab 100644 --- a/apps/red-ui/src/app/screens/base-screen/base-screen.component.html +++ b/apps/red-ui/src/app/screens/base-screen/base-screen.component.html @@ -31,6 +31,12 @@