From aaa9c51bbc41fd5ba2a06239e5c553f06efed555 Mon Sep 17 00:00:00 2001 From: Timo Date: Tue, 20 Jul 2021 12:07:04 +0300 Subject: [PATCH] removed loading indicator --- .../user-profile-screen.component.html | 17 ++----- .../user-profile-screen.component.ts | 10 ++-- .../dictionary-overview-screen.component.html | 18 +------ .../dictionary-overview-screen.component.ts | 13 +++-- .../general-config-screen.component.html | 2 - .../general-config-screen.component.ts | 47 +++++++++---------- .../screens/rules/rules-screen.component.html | 16 +------ .../screens/rules/rules-screen.component.ts | 14 +++--- .../watermark/watermark-screen.component.html | 2 - .../watermark/watermark-screen.component.ts | 8 ++-- .../file-preview-screen.component.html | 9 ++-- .../file-preview-screen.component.ts | 9 ++-- 12 files changed, 62 insertions(+), 103 deletions(-) diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html index 180ec0c3f..9fd1090b8 100644 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html +++ b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html @@ -23,15 +23,10 @@
- + - {{ - 'top-bar.navigation-items.my-account.children.language.' + - language | translate - }} + {{ 'top-bar.navigation-items.my-account.children.language.' + language | translate }}
@@ -47,15 +42,9 @@ > {{ 'user-profile.actions.save' | translate }} - - {{ 'user-profile.actions.change-password' | translate }} + {{ 'user-profile.actions.change-password' | translate }} - - diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts index 359cf01de..7fa32dbe9 100644 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts +++ b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts @@ -7,6 +7,7 @@ import { TranslateService } from '@ngx-translate/core'; import { UserControllerService } from '@redaction/red-ui-http'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import { DomSanitizer } from '@angular/platform-browser'; +import { LoadingService } from '@services/loading.service'; @Component({ selector: 'redaction-user-profile-screen', @@ -14,7 +15,6 @@ import { DomSanitizer } from '@angular/platform-browser'; styleUrls: ['./user-profile-screen.component.scss'] }) export class UserProfileScreenComponent implements OnInit { - viewReady = false; formGroup: FormGroup; changePasswordUrl: any; @@ -28,8 +28,10 @@ export class UserProfileScreenComponent implements OnInit { private readonly _userControllerService: UserControllerService, private readonly _languageService: LanguageService, private readonly _domSanitizer: DomSanitizer, - private readonly _translateService: TranslateService + private readonly _translateService: TranslateService, + private readonly _loadingService: LoadingService ) { + this._loadingService.start(); this.formGroup = this._formBuilder.group({ email: [undefined, [Validators.required, Validators.email]], firstName: [undefined], @@ -68,7 +70,7 @@ export class UserProfileScreenComponent implements OnInit { } async save(): Promise { - this.viewReady = false; + this._loadingService.start(); if (this.languageChanged) { await this._languageService.changeLanguage(this.formGroup.get('language').value); @@ -106,7 +108,7 @@ export class UserProfileScreenComponent implements OnInit { this.formGroup.patchValue(this._profileModel, { emitEvent: false }); } catch (e) { } finally { - this.viewReady = true; + this._loadingService.stop(); } } } diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.html index e59658806..761e5a76f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.html @@ -36,14 +36,7 @@ tooltipPosition="below" > - +
-
+
{{ dictionary.description }}
- - diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.ts index 46558b69b..3d0d9cce9 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-overview/dictionary-overview-screen.component.ts @@ -18,7 +18,6 @@ import { LoadingService } from '@services/loading.service'; styleUrls: ['./dictionary-overview-screen.component.scss'] }) export class DictionaryOverviewScreenComponent extends ComponentHasChanges implements OnInit { - processing = false; entries: string[] = []; @ViewChild('dictionaryManager', { static: false }) @@ -109,29 +108,29 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple } saveEntries(entries: string[]) { - this.processing = true; + this._loadingService.start(); this._dictionarySaveService .saveEntries(entries, this.entries, this.dictionary.dossierTemplateId, this.dictionary.type, null) .subscribe( () => { - this.processing = false; + this._loadingService.stop(); this._loadEntries(); }, () => { - this.processing = false; + this._loadingService.stop(); } ); } private _loadEntries() { - this.processing = true; + this._loadingService.start(); this._dictionaryControllerService.getDictionaryForType(this.dictionary.dossierTemplateId, this.dictionary.type).subscribe( data => { - this.processing = false; + this._loadingService.stop(); this.entries = data.entries.sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' })); }, () => { - this.processing = false; + this._loadingService.stop(); this.entries = []; } ); diff --git a/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.html index 1ec084dda..6e8724884 100644 --- a/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.html @@ -177,5 +177,3 @@ - - diff --git a/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts index 56c2a2c70..f56f11a31 100644 --- a/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/general-config/general-config-screen.component.ts @@ -1,16 +1,17 @@ -import {Component, OnInit} from '@angular/core'; -import {PermissionsService} from '@services/permissions.service'; -import {FormBuilder, FormGroup, Validators} from '@angular/forms'; -import {AdminDialogService} from '../../services/admin-dialog.service'; +import { Component, OnInit } from '@angular/core'; +import { PermissionsService } from '@services/permissions.service'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { AdminDialogService } from '../../services/admin-dialog.service'; import { GeneralConfigurationModel, GeneralSettingsControllerService, SmtpConfigurationControllerService, SMTPConfigurationModel } from '@redaction/red-ui-http'; -import {AppConfigService} from '../../../app-config/app-config.service'; -import {AutoUnsubscribeComponent} from "../../../shared/base/auto-unsubscribe.component"; -import {Toaster} from "../../../../services/toaster.service"; +import { AppConfigService } from '../../../app-config/app-config.service'; +import { AutoUnsubscribeComponent } from '../../../shared/base/auto-unsubscribe.component'; +import { Toaster } from '../../../../services/toaster.service'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-general-config-screen', @@ -18,7 +19,6 @@ import {Toaster} from "../../../../services/toaster.service"; styleUrls: ['./general-config-screen.component.scss'] }) export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent implements OnInit { - viewReady = false; configForm: FormGroup; smtpForm: FormGroup; @@ -32,7 +32,8 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent imple private readonly _formBuilder: FormBuilder, private readonly _toaster: Toaster, private readonly _dialogService: AdminDialogService, - private readonly _generalSettingsControllerService: GeneralSettingsControllerService + private readonly _generalSettingsControllerService: GeneralSettingsControllerService, + private readonly _loadingService: LoadingService ) { super(); @@ -56,7 +57,6 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent imple password: [undefined] }); - this.addSubscription = this.configForm.controls.auth.valueChanges.subscribe(auth => { if (auth) { this.openAuthConfigDialog(); @@ -93,21 +93,21 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent imple } async save() { - this.viewReady = false; + this._loadingService.start(); await this._smtpConfigService.updateSMTPConfiguration(this.smtpForm.getRawValue()).toPromise(); this._initialSMTPConfiguration = this.smtpForm.getRawValue(); - this.viewReady = true; + this._loadingService.stop(); } async saveGeneralConfig() { - this.viewReady = false; + this._loadingService.start(); const configFormValues = this.configForm.getRawValue(); configFormValues.displayName = configFormValues.displayName || 'RedactManager'; await this._generalSettingsControllerService.updateGeneralConfigurations(configFormValues).toPromise(); this._appConfigService.updateDisplayName(configFormValues.displayName); - this.viewReady = true; + this._loadingService.stop(); } openAuthConfigDialog(skipDisableOnCancel?: boolean) { @@ -115,36 +115,35 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribeComponent imple if (authConfig) { this.smtpForm.patchValue(authConfig); } else if (!skipDisableOnCancel) { - this.smtpForm.patchValue({auth: false}, {emitEvent: false}); + this.smtpForm.patchValue({ auth: false }, { emitEvent: false }); } }); } async testConnection() { - this.viewReady = false; + this._loadingService.start(); try { await this._smtpConfigService.testSMTPConfiguration(this.smtpForm.getRawValue()).toPromise(); this._toaster.success('smtp-config-screen.test.success'); } catch (e) { this._toaster.error('smtp-config-screen.test.error'); } finally { - this.viewReady = true; + this._loadingService.stop(); } } private async _loadData() { + this._loadingService.start(); try { this._initialGeneralConfiguration = await this._generalSettingsControllerService.getGeneralConfigurations().toPromise(); - this.configForm.patchValue(this._initialGeneralConfiguration, {emitEvent: false}); - } catch (e) { - } + this.configForm.patchValue(this._initialGeneralConfiguration, { emitEvent: false }); + } catch (e) {} try { this._initialSMTPConfiguration = await this._smtpConfigService.getCurrentSMTPConfiguration().toPromise(); - this.smtpForm.patchValue(this._initialSMTPConfiguration, {emitEvent: false}); - } catch (e) { - } + this.smtpForm.patchValue(this._initialSMTPConfiguration, { emitEvent: false }); + } catch (e) {} - this.viewReady = true; + this._loadingService.stop(); } } diff --git a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html index cef6a100c..9c295de22 100644 --- a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.html @@ -20,11 +20,7 @@
- +
-
+
- - diff --git a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.ts index d8a6552a7..f51ad33c5 100644 --- a/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/rules/rules-screen.component.ts @@ -8,6 +8,7 @@ import { ComponentHasChanges } from '@guards/can-deactivate.guard'; import { ActivatedRoute } from '@angular/router'; import { AppStateService } from '@state/app-state.service'; import { debounce } from '../../../../utils/debounce'; +import { LoadingService } from '../../../../services/loading.service'; import ICodeEditor = monaco.editor.ICodeEditor; import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration; import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions; @@ -24,7 +25,6 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit automaticLayout: true, readOnly: !this.permissionsService.isAdmin() }; - processing = true; initialLines: string[] = []; currentLines: string[] = []; @@ -41,7 +41,8 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit private readonly _appStateService: AppStateService, private readonly _toaster: Toaster, protected readonly _translateService: TranslateService, - private readonly _activatedRoute: ActivatedRoute + private readonly _activatedRoute: ActivatedRoute, + private readonly _loadingService: LoadingService ) { super(_translateService); _appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); @@ -85,7 +86,7 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit } async save(): Promise { - this.processing = true; + this._loadingService.start(); await this._rulesControllerService .uploadRules({ rules: this._codeEditor.getModel().getValue(), @@ -98,7 +99,7 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit this._toaster.success('rules-screen.success.generic'); }, () => { - this.processing = false; + this._loadingService.stop(); this._toaster.error('rules-screen.error.generic'); } ); @@ -107,7 +108,7 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit revert(): void { this.currentLines = this.initialLines; this._decorations = this._codeEditor?.deltaDecorations(this._decorations, []) || []; - this.processing = false; + this._loadingService.stop(); } download(): void { @@ -145,6 +146,7 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit } private async _initialize() { + this._loadingService.start(); await this._rulesControllerService .downloadRules(this._appStateService.activeDossierTemplateId) .toPromise() @@ -153,7 +155,7 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit this.currentLines = this.initialLines = rules.rules.split('\n'); this.revert(); }, - () => (this.processing = false) + () => this._loadingService.stop() ); } } diff --git a/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.html index d87d01af3..eddd49d16 100644 --- a/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.html @@ -125,5 +125,3 @@ - - diff --git a/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.ts index 627166a6e..f4dbdff7f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/watermark/watermark-screen.component.ts @@ -11,6 +11,7 @@ import { Toaster } from '../../../../services/toaster.service'; import { ActivatedRoute } from '@angular/router'; import { BASE_HREF } from '../../../../tokens'; import { stampPDFPage } from '../../../../utils/page-stamper'; +import { LoadingService } from '../../../../services/loading.service'; export const DEFAULT_WATERMARK: WatermarkModelRes = { text: null, @@ -27,7 +28,6 @@ export const DEFAULT_WATERMARK: WatermarkModelRes = { styleUrls: ['./watermark-screen.component.scss'] }) export class WatermarkScreenComponent implements OnInit { - viewReady = false; configForm: FormGroup; private _instance: WebViewerInstance; private _watermark: WatermarkModelRes = {}; @@ -43,9 +43,11 @@ export class WatermarkScreenComponent implements OnInit { private readonly _http: HttpClient, private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _formBuilder: FormBuilder, - private readonly _activatedRoute: ActivatedRoute + private readonly _activatedRoute: ActivatedRoute, + private readonly _loadingService: LoadingService ) { appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); + this._loadingService.start(); this._initForm(); } @@ -133,7 +135,7 @@ export class WatermarkScreenComponent implements OnInit { this._instance = instance; instance.docViewer.on('documentLoaded', async () => { - this.viewReady = true; + this._loadingService.stop(); await this._drawWatermark(); }); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index f00f3a050..7a64b785a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -29,7 +29,7 @@ -
+
@@ -89,7 +89,6 @@ @@ -149,7 +148,7 @@
@@ -187,8 +186,6 @@
- - { if (!document.fullscreenElement) { this.fullScreen = false; @@ -220,7 +220,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme ngOnDetach() { this.displayPDFViewer = false; - this.viewReady = false; super.ngOnDestroy(); } @@ -246,7 +245,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme } this._subscribeToFileUpdates(); - this.viewReady = true; + this._loadingService.stop(); } rebuildFilters(deletePreviousAnnotations: boolean = false) { @@ -394,7 +393,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme await this._stampExcludedPages(); this._cleanupAndRedrawManualAnnotations(); this._updateCanPerformActions(); - this.viewReady = true; + this._loadingService.stop(); // Go to initial page from query params const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page; if (pageNumber) { @@ -540,7 +539,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme if (fileStatus.fileId === this.fileId) { await this._loadFileData(!this._reloadFileOnReanalysis); this._reloadFileOnReanalysis = false; - this.viewReady = true; + this._loadingService.stop(); this._updateCanPerformActions(); this._cleanupAndRedrawManualAnnotations(); }