diff --git a/apps/red-ui/src/app/modules/admin/admin.module.ts b/apps/red-ui/src/app/modules/admin/admin.module.ts index 47817f819..7151ac307 100644 --- a/apps/red-ui/src/app/modules/admin/admin.module.ts +++ b/apps/red-ui/src/app/modules/admin/admin.module.ts @@ -34,6 +34,7 @@ import { ActiveFieldsListingComponent } from './dialogs/file-attributes-csv-impo import { AdminSideNavComponent } from './admin-side-nav/admin-side-nav.component'; import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor'; import { ReportsScreenComponent } from './screens/reports/reports-screen.component'; +import { ResetPasswordDialogComponent } from './dialogs/reset-password-dialog/reset-password-dialog.component'; const dialogs = [ AddEditDossierTemplateDialogComponent, @@ -45,7 +46,7 @@ const dialogs = [ AddEditUserDialogComponent, ConfirmDeleteUsersDialogComponent, FileAttributesCsvImportDialogComponent, - AdminSideNavComponent + ResetPasswordDialogComponent ]; const screens = [ @@ -60,7 +61,8 @@ const screens = [ LicenseInformationScreenComponent, UserListingScreenComponent, WatermarkScreenComponent, - SmtpConfigScreenComponent + SmtpConfigScreenComponent, + ReportsScreenComponent ]; const components = [ @@ -70,13 +72,14 @@ const components = [ ComboSeriesVerticalComponent, UsersStatsComponent, ActiveFieldsListingComponent, + AdminSideNavComponent, ...dialogs, ...screens ]; @NgModule({ - declarations: [...components, ReportsScreenComponent], + declarations: [...components], providers: [AdminDialogService], imports: [ CommonModule, diff --git a/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.ts b/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.ts index 9d2710da0..4a041fd9c 100644 --- a/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.ts +++ b/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.ts @@ -3,6 +3,8 @@ import { PermissionsService } from '@services/permissions.service'; import { AppStateService } from '@state/app-state.service'; import { Router } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; +import { DossierTemplateControllerService } from '@redaction/red-ui-http'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-dossier-template-actions', @@ -16,6 +18,8 @@ export class DossierTemplateActionsComponent { constructor( private readonly _dialogService: AdminDialogService, private readonly _appStateService: AppStateService, + private readonly _dossierTemplateControllerService: DossierTemplateControllerService, + private readonly _loadingService: LoadingService, private readonly _router: Router, readonly permissionsService: PermissionsService ) { @@ -29,21 +33,22 @@ export class DossierTemplateActionsComponent { } openEditDossierTemplateDialog($event: any) { - $event.stopPropagation(); - this._dialogService.openAddEditDossierTemplateDialog( + this._dialogService.openDialog( + 'addEditDossierTemplate', + $event, this.dossierTemplate, - async newDossierTemplate => { - if (newDossierTemplate && this.loadDossierTemplatesData) { - this.loadDossierTemplatesData.emit(); - } + () => { + this.loadDossierTemplatesData?.emit(); } ); } openDeleteDossierTemplateDialog($event?: MouseEvent) { - $event?.stopPropagation(); - - this._dialogService.openDeleteDossierTemplateDialog(this.dossierTemplate, async () => { + this._dialogService.openDialog('confirm', $event, null, async () => { + this._loadingService.start(); + await this._dossierTemplateControllerService + .deleteDossierTemplates([this.dossierTemplateId]) + .toPromise(); await this._appStateService.loadAllDossierTemplates(); await this._appStateService.loadDictionaryData(); await this._router.navigate(['main', 'admin']); diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts index 9f3c732e1..e02083765 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts @@ -90,7 +90,7 @@ export class AddEditDictionaryDialogComponent { } observable.subscribe( - () => this._dialogRef.close(this.dictionary ? null : typeValue), + () => this._dialogRef.close(true), error => { if (error.status === 409) { this._notifyError('add-edit-dictionary.error.dictionary-already-exists'); diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.html b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.html index 2e0b381a6..e7dbc94a4 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.html +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.html @@ -37,6 +37,13 @@ + +
diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts index 90a57469f..d75a2ee74 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts @@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { User } from '@redaction/red-ui-http'; import { UserService } from '@services/user.service'; +import { AdminDialogService } from '../../services/admin-dialog.service'; @Component({ selector: 'redaction-add-edit-user-dialog', @@ -17,6 +18,7 @@ export class AddEditUserDialogComponent { constructor( private readonly _formBuilder: FormBuilder, private readonly _userService: UserService, + private readonly _dialogService: AdminDialogService, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public user: User ) { @@ -85,6 +87,13 @@ export class AddEditUserDialogComponent { this.dialogRef.close('DELETE'); } + resetPassword() { + // this._dialogService.openre; + this._dialogService.openDialog('resetPassword', null, { user: this.user }, (res: any) => { + console.log(res); + }); + } + private _setRolesRequirements() { for (const key of Object.keys(this._ROLE_REQUIREMENTS)) { this.userForm.controls[key].valueChanges.subscribe(checked => { diff --git a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component.ts index 85faf8830..19bf85133 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component.ts @@ -1,5 +1,4 @@ import { Component, Inject } from '@angular/core'; -import { AppStateService } from '@state/app-state.service'; import { FileAttributeConfig } from '@redaction/red-ui-http'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @@ -17,7 +16,6 @@ export class ConfirmDeleteFileAttributeDialogComponent { showToast = false; constructor( - private readonly _appStateService: AppStateService, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: FileAttributeConfig ) { diff --git a/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.html b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.html new file mode 100644 index 000000000..05a0c1e57 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.html @@ -0,0 +1 @@ +

reset-password-dialog works!

diff --git a/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.scss b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.spec.ts b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.spec.ts new file mode 100644 index 000000000..00f5eaa74 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ResetPasswordDialogComponent } from './reset-password-dialog.component'; + +describe('ResetPasswordDialogComponent', () => { + let component: ResetPasswordDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ResetPasswordDialogComponent] + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ResetPasswordDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.ts new file mode 100644 index 000000000..b2451638a --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/dialogs/reset-password-dialog/reset-password-dialog.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'redaction-reset-password-dialog', + templateUrl: './reset-password-dialog.component.html', + styleUrls: ['./reset-password-dialog.component.scss'] +}) +export class ResetPasswordDialogComponent implements OnInit { + constructor() {} + + ngOnInit(): void { + console.log('do sth'); + } +} diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html index fe270e457..65e70fe5a 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html @@ -87,7 +87,3 @@
- - diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts index 02b4f2aee..8c68ef20e 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts @@ -1,21 +1,24 @@ -import { Component, Injector } from '@angular/core'; +import { Component, Injector, OnInit } from '@angular/core'; import { AppStateService } from '@state/app-state.service'; import { Colors, DictionaryControllerService } from '@redaction/red-ui-http'; import { ActivatedRoute } from '@angular/router'; import { PermissionsService } from '@services/permissions.service'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-default-colors-screen', templateUrl: './default-colors-screen.component.html', styleUrls: ['./default-colors-screen.component.scss'] }) -export class DefaultColorsScreenComponent extends BaseListingComponent<{ - key: string; - value: string; -}> { - viewReady = false; +export class DefaultColorsScreenComponent + extends BaseListingComponent<{ + key: string; + value: string; + }> + implements OnInit +{ protected readonly _sortKey = 'default-colors'; private _colorsObj: Colors; @@ -24,35 +27,43 @@ export class DefaultColorsScreenComponent extends BaseListingComponent<{ private readonly _activatedRoute: ActivatedRoute, private readonly _dictionaryControllerService: DictionaryControllerService, private readonly _dialogService: AdminDialogService, + private readonly _loadingService: LoadingService, readonly permissionsService: PermissionsService, protected readonly _injector: Injector ) { super(_injector); _appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); - this._loadColors(); + } + + async ngOnInit() { + await this._loadColors(); } openEditColorDialog($event: any, color: { key: string; value: string }) { - $event.stopPropagation(); - this._dialogService.openEditColorsDialog( - this._colorsObj, - color.key, - this._appStateService.activeDossierTemplateId, - async () => this._loadColors() + this._dialogService.openDialog( + 'editColor', + $event, + { + colors: this._colorsObj, + colorKey: color.key, + dossierTemplateId: this._appStateService.activeDossierTemplateId + }, + async () => { + await this._loadColors(); + } ); } - private _loadColors() { - this._dictionaryControllerService + private async _loadColors() { + this._loadingService.start(); + const data = await this._dictionaryControllerService .getColors(this._appStateService.activeDossierTemplateId) - .toPromise() - .then(data => { - this._colorsObj = data; - this.allEntities = Object.keys(data).map(key => ({ - key, - value: data[key] - })); - this.viewReady = true; - }); + .toPromise(); + this._colorsObj = data; + this.allEntities = Object.keys(data).map(key => ({ + key, + value: data[key] + })); + this._loadingService.stop(); } } diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts index d3952653f..cc716fbf1 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts @@ -59,12 +59,28 @@ export class DictionaryListingScreenComponent } openDeleteDictionariesDialog($event?: MouseEvent, types = this.selectedEntitiesIds) { - $event?.stopPropagation(); - this._dialogService.openDeleteDictionariesDialog( - types, - this._appStateService.activeDossierTemplateId, + this._dialogService.openDialog('confirm', $event, null, async () => { + this._loadingService.start(); + await this._dictionaryControllerService + .deleteTypes(types, this._appStateService.activeDossierTemplateId) + .toPromise(); + this.selectedEntitiesIds = []; + await this._appStateService.loadDictionaryData(); + this._loadDictionaryData(false); + this._calculateData(); + this._loadingService.stop(); + }); + } + + openAddEditDictionaryDialog($event?: MouseEvent, dictionary?: TypeValueWrapper) { + this._dialogService.openDialog( + 'addEditDictionary', + $event, + { + dictionary, + dossierTemplateId: this._appStateService.activeDossierTemplateId + }, async () => { - this.selectedEntitiesIds = []; this._loadingService.start(); await this._appStateService.loadDictionaryData(); this._loadDictionaryData(false); @@ -74,23 +90,6 @@ export class DictionaryListingScreenComponent ); } - openAddEditDictionaryDialog($event?: MouseEvent, dict?: TypeValueWrapper) { - $event?.stopPropagation(); - this._dialogService.openAddEditDictionaryDialog( - dict, - this._appStateService.activeDossierTemplateId, - async newDictionary => { - if (newDictionary) { - this._loadingService.start(); - await this._appStateService.loadDictionaryData(); - this._loadDictionaryData(false); - this._calculateData(); - this._loadingService.stop(); - } - } - ); - } - private _loadDictionaryData(loadEntries = true): void { const appStateDictionaryData = this._appStateService.dictionaryData[this._appStateService.activeDossierTemplateId]; 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 e4e1805c6..52f400c26 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 @@ -10,6 +10,7 @@ import { AdminDialogService } from '../../services/admin-dialog.service'; import { DictionaryManagerComponent } from '@shared/components/dictionary-manager/dictionary-manager.component'; import { DictionarySaveService } from '@shared/services/dictionary-save.service'; import { TypeValueWrapper } from '../../../../models/file/type-value.wrapper'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-dictionary-overview-screen', @@ -32,7 +33,8 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple private readonly _dialogService: AdminDialogService, private readonly _router: Router, private readonly _activatedRoute: ActivatedRoute, - private readonly _appStateService: AppStateService + private readonly _appStateService: AppStateService, + private readonly _loadingService: LoadingService ) { super(_translateService); this._appStateService.activateDictionary( @@ -54,12 +56,17 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple } openEditDictionaryDialog($event: any) { - $event.stopPropagation(); - this._dialogService.openAddEditDictionaryDialog( - this.dictionary, - this.dictionary.dossierTemplateId, + this._dialogService.openDialog( + 'addEditDictionary', + $event, + { + dictionary: this.dictionary, + dossierTemplateId: this.dictionary.dossierTemplateId + }, async () => { + this._loadingService.start(); await this._appStateService.loadDictionaryData(); + this._loadingService.stop(); } ); } @@ -67,20 +74,19 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple openDeleteDictionaryDialog($event?: MouseEvent) { $event?.stopPropagation(); - this._dialogService.openDeleteDictionariesDialog( - [this.dictionary.type], - this.dictionary.dossierTemplateId, - async () => { - await this._appStateService.loadDictionaryData(); - await this._router.navigate([ - '/main', - 'admin', - 'dossier-templates', - this._appStateService.activeDossierTemplateId, - 'dictionaries' - ]); - } - ); + this._dialogService.openDialog('confirm', $event, null, async () => { + await this._dictionaryControllerService + .deleteTypes([this.dictionary.type], this.dictionary.dossierTemplateId) + .toPromise(); + await this._appStateService.loadDictionaryData(); + await this._router.navigate([ + '/main', + 'admin', + 'dossier-templates', + this._appStateService.activeDossierTemplateId, + 'dictionaries' + ]); + }); } download(): void { diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html index 9f058830a..829c271b5 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html @@ -34,7 +34,7 @@ }} - + - -
implements OnInit { - loading = false; protected readonly _searchKey = 'name'; protected readonly _selectionKey = 'dossierTemplateId'; protected readonly _sortKey = 'dossier-templates-listing'; @@ -23,9 +24,11 @@ export class DossierTemplatesListingScreenComponent constructor( private readonly _dialogService: AdminDialogService, private readonly _appStateService: AppStateService, + private readonly _loadingService: LoadingService, + private readonly _dossierTemplateControllerService: DossierTemplateControllerService, + protected readonly _injector: Injector, readonly permissionsService: PermissionsService, - readonly userPreferenceService: UserPreferenceService, - protected readonly _injector: Injector + readonly userPreferenceService: UserPreferenceService ) { super(_injector); } @@ -35,34 +38,38 @@ export class DossierTemplatesListingScreenComponent } openDeleteTemplatesDialog($event?: MouseEvent) { - $event?.stopPropagation(); - - this._dialogService.openBulkDeleteDossierTemplatesDialog( - this.selectedEntitiesIds, - async () => { - this.selectedEntitiesIds = []; - this.loading = true; - await this._appStateService.loadAllDossierTemplates(); - await this._appStateService.loadDictionaryData(); - this.loadDossierTemplatesData(); - this.loading = false; - } - ); + return this._dialogService.openDialog('confirm', $event, null, async () => { + this._loadingService.start(); + await this._dossierTemplateControllerService + .deleteDossierTemplates(this.selectedEntitiesIds) + .toPromise(); + this.selectedEntitiesIds = []; + await this._appStateService.loadAllDossierTemplates(); + await this._appStateService.loadDictionaryData(); + this.loadDossierTemplatesData(); + }); } loadDossierTemplatesData() { + this._loadingService.start(); this._appStateService.reset(); this.allEntities = this._appStateService.dossierTemplates; this._executeSearchImmediately(); this._loadDossierTemplateStats(); + this._loadingService.stop(); } openAddDossierTemplateDialog() { - this._dialogService.openAddEditDossierTemplateDialog(null, async newDossierTemplate => { - if (newDossierTemplate) { - this.loadDossierTemplatesData(); + this._dialogService.openDialog( + 'addEditDossierTemplate', + null, + null, + async newDossierTemplate => { + if (newDossierTemplate) { + this.loadDossierTemplatesData(); + } } - }); + ); } private _loadDossierTemplateStats() { diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html index 3b1e5e96d..2965fd2b1 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html @@ -43,8 +43,6 @@ > - -
- - diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts index d4d0d131e..524b9c806 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts @@ -9,6 +9,7 @@ import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-file-attributes-listing-screen', @@ -19,8 +20,6 @@ export class FileAttributesListingScreenComponent extends BaseListingComponent implements OnInit { - viewReady = false; - loading = false; protected readonly _searchKey = 'label'; protected readonly _selectionKey = 'id'; protected readonly _sortKey = 'file-attributes-listing'; @@ -34,6 +33,7 @@ export class FileAttributesListingScreenComponent private readonly _appStateService: AppStateService, private readonly _activatedRoute: ActivatedRoute, private readonly _dialogService: AdminDialogService, + private readonly _loadingService: LoadingService, protected readonly _injector: Injector ) { super(_injector); @@ -47,12 +47,12 @@ export class FileAttributesListingScreenComponent } openAddEditAttributeDialog($event: MouseEvent, fileAttribute?: FileAttributeConfig) { - $event.stopPropagation(); - this._dialogService.openAddEditFileAttributeDialog( - fileAttribute, - this._appStateService.activeDossierTemplateId, - async (newValue: FileAttributeConfig) => { - this.loading = true; + this._dialogService.openDialog( + 'addEditFileAttribute', + $event, + { fileAttribute, dossierTemplateId: this._appStateService.activeDossierTemplateId }, + async newValue => { + this._loadingService.start(); await this._fileAttributesService .setFileAttributesConfiguration( newValue, @@ -65,40 +65,39 @@ export class FileAttributesListingScreenComponent } openConfirmDeleteAttributeDialog($event: MouseEvent, fileAttribute?: FileAttributeConfig) { - $event.stopPropagation(); - this._dialogService.openConfirmDeleteFileAttributeDialog( - fileAttribute, - this._appStateService.activeDossierTemplateId, - async () => { - this.loading = true; - if (fileAttribute) { - await this._fileAttributesService - .deleteFileAttribute( - this._appStateService.activeDossierTemplateId, - fileAttribute.id - ) - .toPromise(); - } else { - await this._fileAttributesService - .deleteFileAttributes( - this.selectedEntitiesIds, - this._appStateService.activeDossierTemplateId - ) - .toPromise(); - } - await this._loadData(); + this._dialogService.openDialog('deleteFileAttribute', $event, fileAttribute, async () => { + this._loadingService.start(); + if (fileAttribute) { + await this._fileAttributesService + .deleteFileAttribute( + this._appStateService.activeDossierTemplateId, + fileAttribute.id + ) + .toPromise(); + } else { + await this._fileAttributesService + .deleteFileAttributes( + this.selectedEntitiesIds, + this._appStateService.activeDossierTemplateId + ) + .toPromise(); } - ); + await this._loadData(); + }); } importCSV(files: FileList | File[]) { - const csvFile = files[0]; + const csv = files[0]; this._fileInput.nativeElement.value = null; - this._dialogService.openImportFileAttributeCSVDialog( - csvFile, - this._appStateService.activeDossierTemplateId, - this._existingConfiguration, + this._dialogService.openDialog( + 'importFileAttributes', + null, + { + csv, + dossierTemplateId: this._appStateService.activeDossierTemplateId, + existingConfiguration: this._existingConfiguration + }, async () => { await this._loadData(); } @@ -107,6 +106,7 @@ export class FileAttributesListingScreenComponent private async _loadData() { try { + this._loadingService.start(); const response = await this._fileAttributesService .getFileAttributesConfiguration(this._appStateService.activeDossierTemplateId) .toPromise(); @@ -115,8 +115,7 @@ export class FileAttributesListingScreenComponent } catch (e) { } finally { this._executeSearchImmediately(); - this.viewReady = true; - this.loading = false; + this._loadingService.stop(); } } } diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.html index 31ff344e5..2f256fdcf 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.html @@ -79,8 +79,4 @@ - - diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts index 459673a86..78759fe62 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts @@ -4,6 +4,7 @@ import { AppStateService } from '../../../../state/app-state.service'; import { ReportTemplate, ReportTemplateControllerService } from '@redaction/red-ui-http'; import { download } from '../../../../utils/file-download-utils'; import { AdminDialogService } from '../../services/admin-dialog.service'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-reports-screen', @@ -11,7 +12,6 @@ import { AdminDialogService } from '../../services/admin-dialog.service'; styleUrls: ['./reports-screen.component.scss'] }) export class ReportsScreenComponent implements OnInit { - viewReady = false; placeholders: string[] = [ 'report', 'predefined placeholder 1', @@ -26,7 +26,8 @@ export class ReportsScreenComponent implements OnInit { private readonly _activatedRoute: ActivatedRoute, private readonly _appStateService: AppStateService, private readonly _reportTemplateService: ReportTemplateControllerService, - private readonly _dialogService: AdminDialogService + private readonly _dialogService: AdminDialogService, + private readonly _loadingService: LoadingService ) { this._appStateService.activateDossierTemplate( _activatedRoute.snapshot.params.dossierTemplateId @@ -39,11 +40,11 @@ export class ReportsScreenComponent implements OnInit { async ngOnInit() { await this._loadReportTemplates(); - this.viewReady = true; + this._loadingService.stop(); } async uploadFile($event) { - this.viewReady = false; + this._loadingService.start(); const file = $event.target.files[0]; await this._reportTemplateService @@ -52,7 +53,6 @@ export class ReportsScreenComponent implements OnInit { this._fileInput.nativeElement.value = null; await this._loadReportTemplates(); - this.viewReady = true; } async download(template: ReportTemplate) { @@ -63,18 +63,20 @@ export class ReportsScreenComponent implements OnInit { } deleteTemplate(template: ReportTemplate) { - this._dialogService.openDeleteReportTemplateDialog( - template.templateId, - template.dossierTemplateId, - async () => { - await this._loadReportTemplates(); - } - ); + this._dialogService.openDialog('confirm', null, null, async () => { + this._loadingService.start(); + await this._reportTemplateService + .deleteTemplate(template.dossierTemplateId, template.templateId) + .toPromise(); + await this._loadReportTemplates(); + }); } private async _loadReportTemplates() { + this._loadingService.start(); this.availableTemplates = await this._reportTemplateService .getAvailableReportTemplates(this._appStateService.activeDossierTemplateId) .toPromise(); + this._loadingService.stop(); } } diff --git a/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.ts index c4048d972..14ecb9845 100644 --- a/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/smtp-config/smtp-config-screen.component.ts @@ -4,8 +4,8 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { GeneralConfigurationModel, - SmtpConfigurationControllerService, GeneralSettingsControllerService, + SmtpConfigurationControllerService, SMTPConfigurationModel } from '@redaction/red-ui-http'; import { NotificationService, NotificationType } from '@services/notification.service'; @@ -103,13 +103,19 @@ export class SmtpConfigScreenComponent implements OnInit { } openAuthConfigDialog(skipDisableOnCancel?: boolean) { - this._dialogService.openSMTPAuthConfigDialog(this.configForm.getRawValue(), authConfig => { - if (authConfig) { - this.configForm.patchValue(authConfig); - } else if (!skipDisableOnCancel) { - this.configForm.patchValue({ auth: false }, { emitEvent: false }); - } - }); + this._dialogService.openDialog( + 'smtpAuthConfig', + null, + this.configForm.getRawValue(), + authConfig => { + if (authConfig) { + this.configForm.patchValue(authConfig); + } else if (!skipDisableOnCancel) { + this.configForm.patchValue({ auth: false }, { emitEvent: false }); + } + }, + false + ); } async testConnection() { diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts index 3f533aa1d..40426f8ce 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts @@ -25,7 +25,7 @@ export class UserListingScreenComponent extends BaseListingComponent imple readonly permissionsService: PermissionsService, readonly userService: UserService, private readonly _translateService: TranslateService, - private readonly _adminDialogService: AdminDialogService, + private readonly _dialogService: AdminDialogService, private readonly _userControllerService: UserControllerService, private readonly _translateChartService: TranslateChartService, private readonly _loadingService: LoadingService, @@ -43,8 +43,7 @@ export class UserListingScreenComponent extends BaseListingComponent imple } openAddEditUserDialog($event: MouseEvent, user?: User) { - $event.stopPropagation(); - this._adminDialogService.openAddEditUserDialog(user, async result => { + this._dialogService.openDialog('addEditUser', $event, user, async result => { if (result === 'DELETE') { return this.openDeleteUserDialog([user]); } @@ -64,8 +63,7 @@ export class UserListingScreenComponent extends BaseListingComponent imple } openDeleteUserDialog(users: User[], $event?: MouseEvent) { - $event?.stopPropagation(); - this._adminDialogService.openConfirmDeleteUsersDialog(users, async () => { + this._dialogService.openDialog('deleteUsers', $event, users, async () => { this._loadingService.start(); await this._userControllerService.deleteUsers(users.map(u => u.userId)).toPromise(); await this._loadData(); diff --git a/apps/red-ui/src/app/modules/admin/services/admin-dialog.service.ts b/apps/red-ui/src/app/modules/admin/services/admin-dialog.service.ts index 4b7e51e44..465c15ceb 100644 --- a/apps/red-ui/src/app/modules/admin/services/admin-dialog.service.ts +++ b/apps/red-ui/src/app/modules/admin/services/admin-dialog.service.ts @@ -1,17 +1,5 @@ import { Injectable } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { - Colors, - DictionaryControllerService, - DossierTemplateControllerService, - DossierTemplateModel, - FileAttributeConfig, - FileAttributesConfig, - ReportTemplateControllerService, - SMTPConfigurationModel, - TypeValue, - User -} from '@redaction/red-ui-http'; import { AddEditFileAttributeDialogComponent } from '../dialogs/add-edit-file-attribute-dialog/add-edit-file-attribute-dialog.component'; import { AddEditDictionaryDialogComponent } from '../dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component'; import { AddEditDossierTemplateDialogComponent } from '../dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component'; @@ -22,7 +10,21 @@ import { SmtpAuthDialogComponent } from '../dialogs/smtp-auth-dialog/smtp-auth-d import { AddEditUserDialogComponent } from '../dialogs/add-edit-user-dialog/add-edit-user-dialog.component'; import { ConfirmDeleteUsersDialogComponent } from '../dialogs/confirm-delete-users-dialog/confirm-delete-users-dialog.component'; import { FileAttributesCsvImportDialogComponent } from '../dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component'; -import { TypeValueWrapper } from '../../../models/file/type-value.wrapper'; +import { ResetPasswordDialogComponent } from '../dialogs/reset-password-dialog/reset-password-dialog.component'; +import { ComponentType } from '@angular/cdk/portal'; + +type DialogType = + | 'confirm' + | 'resetPassword' + | 'addEditDictionary' + | 'editColor' + | 'addEditFileAttribute' + | 'deleteFileAttribute' + | 'importFileAttributes' + | 'addEditUser' + | 'deleteUsers' + | 'smtpAuthConfig' + | 'addEditDossierTemplate'; const largeDialogConfig = { width: '90vw', @@ -39,244 +41,78 @@ const dialogConfig = { @Injectable() export class AdminDialogService { - constructor( - private readonly _dialog: MatDialog, - private readonly _dossierTemplateControllerService: DossierTemplateControllerService, - private readonly _reportTemplateService: ReportTemplateControllerService, - private readonly _dictionaryControllerService: DictionaryControllerService - ) {} + private readonly _config: { + [key in DialogType]: { + component: ComponentType; + dialogConfig?: object; + }; + } = { + confirm: { + component: ConfirmationDialogComponent + }, + resetPassword: { + component: ResetPasswordDialogComponent, + dialogConfig: { autoFocus: true } + }, + addEditDictionary: { + component: AddEditDictionaryDialogComponent, + dialogConfig: { autoFocus: true } + }, + editColor: { + component: EditColorDialogComponent, + dialogConfig: { autoFocus: true } + }, + addEditFileAttribute: { + component: AddEditFileAttributeDialogComponent, + dialogConfig: { autoFocus: true } + }, + deleteFileAttribute: { + component: ConfirmDeleteFileAttributeDialogComponent + }, + importFileAttributes: { + component: FileAttributesCsvImportDialogComponent, + dialogConfig: largeDialogConfig + }, + deleteUsers: { + component: ConfirmDeleteUsersDialogComponent, + dialogConfig: { autoFocus: true } + }, + addEditUser: { + component: AddEditUserDialogComponent, + dialogConfig: { autoFocus: true } + }, + smtpAuthConfig: { + component: SmtpAuthDialogComponent, + dialogConfig: { autoFocus: true } + }, + addEditDossierTemplate: { + component: AddEditDossierTemplateDialogComponent, + dialogConfig: { width: '900px', autoFocus: true } + } + }; - openDeleteDictionariesDialog( - dictionaryTypes: string[], - dossierTemplateId: string, - cb?: () => void - ): MatDialogRef { - const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); + constructor(private readonly _dialog: MatDialog) {} + + openDialog( + type: DialogType, + $event: MouseEvent, + data: any, + cb?: Function, + checkForResult = true + ): MatDialogRef { + const config = this._config[type]; + + $event?.stopPropagation(); + const ref = this._dialog.open(config.component, { + ...dialogConfig, + ...(config.dialogConfig || {}), + data + }); ref.afterClosed().subscribe(async result => { - if (result) { - await this._dictionaryControllerService - .deleteTypes(dictionaryTypes, dossierTemplateId) - .toPromise(); - if (cb) cb(); + if ((result || !checkForResult) && cb) { + await cb(result); } }); return ref; } - - openDeleteReportTemplateDialog( - templateId: string, - dossierTemplateId: string, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); - ref.afterClosed().subscribe(async result => { - if (result) { - await this._reportTemplateService - .deleteTemplate(dossierTemplateId, templateId) - .toPromise(); - if (cb) cb(); - } - }); - return ref; - } - - openDeleteDossierTemplateDialog( - dossierTemplate: DossierTemplateModel, - cb?: () => void - ): MatDialogRef { - const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); - ref.afterClosed().subscribe(async result => { - if (result) { - if (cb) await cb(); - } - }); - return ref; - } - - openBulkDeleteDossierTemplatesDialog( - dossierTemplateIds: string[], - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); - ref.afterClosed().subscribe(async result => { - if (result) { - if (cb) await cb(); - } - }); - return ref; - } - - openAddEditDictionaryDialog( - dictionary: TypeValueWrapper, - dossierTemplateId: string, - cb?: (newDictionary: TypeValue | null) => void - ): MatDialogRef { - const ref = this._dialog.open(AddEditDictionaryDialogComponent, { - ...dialogConfig, - data: { dictionary, dossierTemplateId }, - autoFocus: true - }); - - ref.afterClosed().subscribe((newDictionary: TypeValue) => { - if (newDictionary && cb) cb(newDictionary); - else if (cb) cb(null); - }); - - return ref; - } - - openEditColorsDialog( - colors: Colors, - colorKey: string, - dossierTemplateId: string, - cb?: (result: boolean) => void - ): MatDialogRef { - const ref = this._dialog.open(EditColorDialogComponent, { - ...dialogConfig, - data: { colors, colorKey, dossierTemplateId }, - autoFocus: true - }); - - ref.afterClosed().subscribe((result: boolean) => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openAddEditDossierTemplateDialog( - dossierTemplate: DossierTemplateModel, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(AddEditDossierTemplateDialogComponent, { - ...dialogConfig, - width: '900px', - data: dossierTemplate, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openImportFileAttributeCSVDialog( - csv: File, - dossierTemplateId: string, - existingConfiguration: FileAttributesConfig, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(FileAttributesCsvImportDialogComponent, { - ...largeDialogConfig, - data: { csv, dossierTemplateId, existingConfiguration } - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openAddEditFileAttributeDialog( - fileAttribute: FileAttributeConfig, - dossierTemplateId: string, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(AddEditFileAttributeDialogComponent, { - ...dialogConfig, - data: { fileAttribute, dossierTemplateId }, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openConfirmDeleteFileAttributeDialog( - fileAttribute: FileAttributeConfig, - dossierTemplateId: string, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(ConfirmDeleteFileAttributeDialogComponent, { - ...dialogConfig, - data: fileAttribute, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openSMTPAuthConfigDialog( - smtpConfig: SMTPConfigurationModel, - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(SmtpAuthDialogComponent, { - ...dialogConfig, - data: smtpConfig, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (cb) { - cb(result); - } - }); - - return ref; - } - - openAddEditUserDialog(user?: User, cb?: Function): MatDialogRef { - const ref = this._dialog.open(AddEditUserDialogComponent, { - ...dialogConfig, - data: user, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } - - openConfirmDeleteUsersDialog( - users: User[], - cb?: Function - ): MatDialogRef { - const ref = this._dialog.open(ConfirmDeleteUsersDialogComponent, { - ...dialogConfig, - data: users, - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) { - cb(result); - } - }); - - return ref; - } } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 1a7b16d64..f8490173d 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -97,7 +97,8 @@ "email": "Email", "first-name": "First Name", "last-name": "Last Name", - "role": "Role" + "role": "Role", + "reset-password": "Reset Password" }, "title": { "edit": "Edit User",