From e061992b848f5458a0e49c290fbc4305282bfa05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Wed, 14 Jul 2021 14:03:50 +0300 Subject: [PATCH] Manage dossier attributes --- .prettierrc | 2 +- README.md | 2 +- .../app/modules/admin/admin-routing.module.ts | 9 + .../admin-side-nav.component.ts | 1 + .../src/app/modules/admin/admin.module.ts | 17 +- ...it-dossier-attribute-dialog.component.html | 48 +++ ...it-dossier-attribute-dialog.component.scss | 0 ...edit-dossier-attribute-dialog.component.ts | 85 ++++++ ...r-attributes-listing-screen.component.html | 139 +++++++++ ...r-attributes-listing-screen.component.scss | 50 ++++ ...ier-attributes-listing-screen.component.ts | 66 +++++ ...e-attributes-listing-screen.component.html | 45 +-- ...ile-attributes-listing-screen.component.ts | 30 +- .../reports/reports-screen.component.html | 5 +- .../reports/reports-screen.component.ts | 19 +- .../watermark/watermark-screen.component.html | 52 +--- .../watermark/watermark-screen.component.ts | 83 ++---- .../admin/services/admin-dialog.service.ts | 8 +- .../services/file-upload.service.ts | 42 +-- .../src/app/services/error-message.service.ts | 18 ++ .../src/app/services/sorting.service.ts | 6 +- .../app/utils/global-error-handler.service.ts | 2 +- apps/red-ui/src/assets/config/config.json | 4 +- apps/red-ui/src/assets/i18n/en.json | 50 ++++ libs/red-ui-http/src/lib/api/api.ts | 6 +- .../dossierAttributesController.service.ts | 274 +++++++----------- 26 files changed, 672 insertions(+), 391 deletions(-) create mode 100644 apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.html create mode 100644 apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.scss create mode 100644 apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.ts create mode 100644 apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html create mode 100644 apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss create mode 100644 apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts create mode 100644 apps/red-ui/src/app/services/error-message.service.ts diff --git a/.prettierrc b/.prettierrc index b79d43aad..6b065a3b8 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "useTabs": false, - "printWidth": 100, + "printWidth": 140, "tabWidth": 4, "singleQuote": true, "trailingComma": "none", diff --git a/README.md b/README.md index 49fa5d365..28ce2da2a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ To re-generate http rune swagger YOu need swagger-codegen installed `brew install swagger-codegen` ``` -BASE=https://dev-06.iqser.cloud/ +BASE=https://red-staging.iqser.cloud/ URL="$BASE"redaction-gateway-v1/v2/api-docs?group=redaction-gateway-v1 rm -Rf /tmp/swagger mkdir -p /tmp/swagger diff --git a/apps/red-ui/src/app/modules/admin/admin-routing.module.ts b/apps/red-ui/src/app/modules/admin/admin-routing.module.ts index 4162dac19..44dccebc6 100644 --- a/apps/red-ui/src/app/modules/admin/admin-routing.module.ts +++ b/apps/red-ui/src/app/modules/admin/admin-routing.module.ts @@ -18,6 +18,7 @@ import { AuditScreenComponent } from './screens/audit/audit-screen.component'; import { RouterModule } from '@angular/router'; import { SmtpConfigScreenComponent } from './screens/smtp-config/smtp-config-screen.component'; import { ReportsScreenComponent } from './screens/reports/reports-screen.component'; +import { DossierAttributesListingScreenComponent } from './screens/dossier-attributes-listing/dossier-attributes-listing-screen.component'; const routes = [ { path: '', redirectTo: 'dossier-templates', pathMatch: 'full' }, @@ -90,6 +91,14 @@ const routes = [ routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] } }, + { + path: 'dossier-attributes', + component: DossierAttributesListingScreenComponent, + canActivate: [CompositeRouteGuard], + data: { + routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] + } + }, { path: 'default-colors', component: DefaultColorsScreenComponent, diff --git a/apps/red-ui/src/app/modules/admin/admin-side-nav/admin-side-nav.component.ts b/apps/red-ui/src/app/modules/admin/admin-side-nav/admin-side-nav.component.ts index 0c84c8ac6..70ca19201 100644 --- a/apps/red-ui/src/app/modules/admin/admin-side-nav/admin-side-nav.component.ts +++ b/apps/red-ui/src/app/modules/admin/admin-side-nav/admin-side-nav.component.ts @@ -34,6 +34,7 @@ export class AdminSideNavComponent { { screen: 'default-colors' }, { screen: 'watermark' }, { screen: 'file-attributes', onlyAdmin: true }, + { screen: 'dossier-attributes', onlyAdmin: true }, { screen: 'reports', onlyAdmin: true, onlyDevMode: true } ] }; 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 5e628823c..8c1eedd87 100644 --- a/apps/red-ui/src/app/modules/admin/admin.module.ts +++ b/apps/red-ui/src/app/modules/admin/admin.module.ts @@ -36,6 +36,8 @@ import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor'; import { ReportsScreenComponent } from './screens/reports/reports-screen.component'; import { ResetPasswordComponent } from './dialogs/add-edit-user-dialog/reset-password/reset-password.component'; import { UserDetailsComponent } from './dialogs/add-edit-user-dialog/user-details/user-details.component'; +import { AddEditDossierAttributeDialogComponent } from './dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component'; +import { DossierAttributesListingScreenComponent } from './screens/dossier-attributes-listing/dossier-attributes-listing-screen.component'; const dialogs = [ AddEditDossierTemplateDialogComponent, @@ -46,7 +48,8 @@ const dialogs = [ SmtpAuthDialogComponent, AddEditUserDialogComponent, ConfirmDeleteUsersDialogComponent, - FileAttributesCsvImportDialogComponent + FileAttributesCsvImportDialogComponent, + AddEditDossierAttributeDialogComponent ]; const screens = [ @@ -62,7 +65,8 @@ const screens = [ UserListingScreenComponent, WatermarkScreenComponent, SmtpConfigScreenComponent, - ReportsScreenComponent + ReportsScreenComponent, + DossierAttributesListingScreenComponent ]; const components = [ @@ -83,13 +87,6 @@ const components = [ @NgModule({ declarations: [...components], providers: [AdminDialogService], - imports: [ - CommonModule, - SharedModule, - AdminRoutingModule, - NgxChartsModule, - ColorPickerModule, - MonacoEditorModule - ] + imports: [CommonModule, SharedModule, AdminRoutingModule, NgxChartsModule, ColorPickerModule, MonacoEditorModule] }) export class AdminModule {} diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.html b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.html new file mode 100644 index 000000000..6e2853018 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.html @@ -0,0 +1,48 @@ +
+
+ {{ + (dossierAttribute ? 'add-edit-dossier-attribute.title.edit' : 'add-edit-dossier-attribute.title.new') + | translate: { name: dossierAttribute?.label } + }} +
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + + + {{ 'dossier-attribute-types.' + type | translate }} + + +
+
+
+ +
+
+ + +
diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.scss b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.ts new file mode 100644 index 000000000..c8d88ef23 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component.ts @@ -0,0 +1,85 @@ +import { Component, Inject } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { DossierAttributeConfig, DossierAttributesControllerService, FileAttributeConfig } from '@redaction/red-ui-http'; +import { AppStateService } from '../../../../state/app-state.service'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { LoadingService } from '../../../../services/loading.service'; +import { ErrorMessageService } from '../../../../services/error-message.service'; +import { NotificationService, NotificationType } from '../../../../services/notification.service'; +import { HttpErrorResponse } from '@angular/common/http'; + +@Component({ + selector: 'redaction-add-edit-dossier-attribute-dialog', + templateUrl: './add-edit-dossier-attribute-dialog.component.html', + styleUrls: ['./add-edit-dossier-attribute-dialog.component.scss'] +}) +export class AddEditDossierAttributeDialogComponent { + dossierAttributeForm: FormGroup; + dossierAttribute: DossierAttributeConfig; + dossierTemplateId: string; + readonly typeOptions = [ + DossierAttributeConfig.TypeEnum.TEXT, + DossierAttributeConfig.TypeEnum.NUMBER, + DossierAttributeConfig.TypeEnum.DATE, + DossierAttributeConfig.TypeEnum.IMAGE + ]; + + constructor( + private readonly _appStateService: AppStateService, + private readonly _formBuilder: FormBuilder, + private readonly _loadingService: LoadingService, + private readonly _dossierAttributesService: DossierAttributesControllerService, + private readonly _errorMessageService: ErrorMessageService, + private readonly _notificationService: NotificationService, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) + public data: { dossierAttribute: DossierAttributeConfig; dossierTemplateId: string } + ) { + this.dossierAttribute = data.dossierAttribute; + this.dossierTemplateId = data.dossierTemplateId; + + this.dossierAttributeForm = this._formBuilder.group({ + label: [this.dossierAttribute?.label, Validators.required], + placeholder: [this.dossierAttribute?.placeholder, Validators.required], + type: [this.dossierAttribute?.type || FileAttributeConfig.TypeEnum.TEXT, Validators.required] + }); + } + + get changed(): boolean { + if (!this.dossierAttribute) return true; + + for (const key of Object.keys(this.dossierAttributeForm.getRawValue())) { + if (this.dossierAttribute[key] !== this.dossierAttributeForm.get(key).value) { + return true; + } + } + + return false; + } + + saveFileAttribute() { + this._loadingService.start(); + + const attribute: DossierAttributeConfig = { + id: this.dossierAttribute?.id, + editable: true, + ...this.dossierAttributeForm.getRawValue() + }; + + this._dossierAttributesService + .addOrUpdateDossierAttributesConfig(attribute, this._appStateService.activeDossierTemplateId) + .subscribe( + () => { + this.dialogRef.close(true); + }, + (err: HttpErrorResponse) => { + this._loadingService.stop(); + this._notificationService.showToastNotification( + this._errorMessageService.getMessage(err, 'add-edit-dossier-attribute.error.generic'), + null, + NotificationType.ERROR + ); + } + ); + } +} diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html new file mode 100644 index 000000000..1e2f4d616 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html @@ -0,0 +1,139 @@ +
+ + +
+
+ + + +
+
+
+ +
+ + + {{ 'dossier-attributes-listing.table-header.title' | translate: { length: displayedEntities.length } }} + + + + +
+ + + +
+
+ +
+
+ + + + +
+
+
+ + + + + + +
+
+ +
+ +
+ {{ attribute.label }} +
+ +
+ {{ attribute.placeholder }} +
+ +
+ {{ 'dossier-attribute-types.' + attribute.type | translate }} +
+
+
+ + + + +
+
+
+
+
+
+
+
diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss new file mode 100644 index 000000000..2dcca5af9 --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss @@ -0,0 +1,50 @@ +@import '../../../../../assets/styles/red-mixins'; + +.page-header .actions { + display: flex; + justify-content: flex-end; +} + +.header-item { + padding: 0 24px 0 10px; +} + +redaction-table-col-name::ng-deep { + > div { + padding-left: 10px !important; + } +} + +.content-container { + .header-item { + .attributes-actions-container { + display: flex; + flex: 1; + justify-content: flex-end; + + > *:not(:last-child) { + margin-right: 10px; + } + } + } + + cdk-virtual-scroll-viewport { + ::ng-deep.cdk-virtual-scroll-content-wrapper { + grid-template-columns: auto 2fr 2fr 1fr 1fr 11px; + + .table-item > div { + height: 50px; + + &:not(.scrollbar-placeholder) { + padding-left: 10px; + } + } + } + + &.has-scrollbar:hover { + ::ng-deep.cdk-virtual-scroll-content-wrapper { + grid-template-columns: auto 2fr 2fr 1fr 1fr; + } + } + } +} diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts new file mode 100644 index 000000000..b907dbb2d --- /dev/null +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts @@ -0,0 +1,66 @@ +import { Component, Injector, OnInit } from '@angular/core'; +import { BaseListingComponent } from '../../../shared/base/base-listing.component'; +import { DossierAttributeConfig, DossierAttributesControllerService } from '@redaction/red-ui-http'; +import { AppStateService } from '../../../../state/app-state.service'; +import { ActivatedRoute } from '@angular/router'; +import { AdminDialogService } from '../../services/admin-dialog.service'; +import { LoadingService } from '../../../../services/loading.service'; + +@Component({ + selector: 'redaction-dossier-attributes', + templateUrl: './dossier-attributes-listing-screen.component.html', + styleUrls: ['./dossier-attributes-listing-screen.component.scss'] +}) +export class DossierAttributesListingScreenComponent extends BaseListingComponent implements OnInit { + protected readonly _searchKey = 'label'; + protected readonly _selectionKey = 'id'; + protected readonly _sortKey = 'dossier-attributes-listing'; + + constructor( + protected readonly _injector: Injector, + private readonly _appStateService: AppStateService, + private readonly _activatedRoute: ActivatedRoute, + private readonly _dialogService: AdminDialogService, + private readonly _loadingService: LoadingService, + private readonly _dossierAttributesService: DossierAttributesControllerService + ) { + super(_injector); + this._appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); + } + + async ngOnInit() { + await this._loadData(); + } + + openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) { + this._dialogService.openDialog('confirm', $event, null, async () => { + this._loadingService.start(); + const ids = dossierAttribute ? [dossierAttribute.id] : this.selectedEntitiesIds; + await this._dossierAttributesService + .deleteDossierAttributesConfig(ids, this._appStateService.activeDossierTemplateId) + .toPromise(); + await this._loadData(); + }); + } + + openAddEditAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) { + const dossierTemplateId = this._appStateService.activeDossierTemplateId; + + this._dialogService.openDialog( + 'addEditDossierAttribute', + $event, + { dossierAttribute, dossierTemplateId }, + async () => await this._loadData() + ); + } + + private async _loadData() { + this._loadingService.start(); + const response = await this._dossierAttributesService + .getDossierAttributesConfig(this._appStateService.activeDossierTemplateId) + .toPromise(); + this.allEntities = response?.dossierAttributeConfigs || []; + this._executeSearchImmediately(); + this._loadingService.stop(); + } +} 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 2965fd2b1..f81bc3c38 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 @@ -3,6 +3,8 @@
+ + - {{ - 'file-attributes-listing.table-header.title' - | translate: { length: displayedEntities.length } - }} + {{ 'file-attributes-listing.table-header.title' | translate: { length: displayedEntities.length } }} - +
-
+
- +
- +
{{ attribute.label }}
-
+
- +
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 524b9c806..f946643b6 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 @@ -1,10 +1,6 @@ import { Component, ElementRef, Injector, OnInit, ViewChild } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { - FileAttributeConfig, - FileAttributesConfig, - FileAttributesControllerService -} from '@redaction/red-ui-http'; +import { FileAttributeConfig, FileAttributesConfig, FileAttributesControllerService } from '@redaction/red-ui-http'; import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; @@ -16,10 +12,7 @@ import { LoadingService } from '../../../../services/loading.service'; templateUrl: './file-attributes-listing-screen.component.html', styleUrls: ['./file-attributes-listing-screen.component.scss'] }) -export class FileAttributesListingScreenComponent - extends BaseListingComponent - implements OnInit -{ +export class FileAttributesListingScreenComponent extends BaseListingComponent implements OnInit { protected readonly _searchKey = 'label'; protected readonly _selectionKey = 'id'; protected readonly _sortKey = 'file-attributes-listing'; @@ -37,9 +30,7 @@ export class FileAttributesListingScreenComponent protected readonly _injector: Injector ) { super(_injector); - this._appStateService.activateDossierTemplate( - _activatedRoute.snapshot.params.dossierTemplateId - ); + this._appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); } async ngOnInit() { @@ -54,10 +45,7 @@ export class FileAttributesListingScreenComponent async newValue => { this._loadingService.start(); await this._fileAttributesService - .setFileAttributesConfiguration( - newValue, - this._appStateService.activeDossierTemplateId - ) + .setFileAttributesConfiguration(newValue, this._appStateService.activeDossierTemplateId) .toPromise(); await this._loadData(); } @@ -69,17 +57,11 @@ export class FileAttributesListingScreenComponent this._loadingService.start(); if (fileAttribute) { await this._fileAttributesService - .deleteFileAttribute( - this._appStateService.activeDossierTemplateId, - fileAttribute.id - ) + .deleteFileAttribute(this._appStateService.activeDossierTemplateId, fileAttribute.id) .toPromise(); } else { await this._fileAttributesService - .deleteFileAttributes( - this.selectedEntitiesIds, - this._appStateService.activeDossierTemplateId - ) + .deleteFileAttributes(this.selectedEntitiesIds, this._appStateService.activeDossierTemplateId) .toPromise(); } await this._loadData(); 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 2f256fdcf..20173c810 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 @@ -3,6 +3,8 @@
+ +
{{ getPlaceholderDisplayValue(placeholder) }}
- What is and how to use it in your document. The readable content of a page - when looking at its layout must be nice. + What is and how to use it in your document. The readable content of a page when looking at its layout must be nice.
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 78759fe62..a1a408950 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 @@ -12,12 +12,7 @@ import { LoadingService } from '../../../../services/loading.service'; styleUrls: ['./reports-screen.component.scss'] }) export class ReportsScreenComponent implements OnInit { - placeholders: string[] = [ - 'report', - 'predefined placeholder 1', - 'signature 01', - 'new attribute' - ]; + placeholders: string[] = ['report', 'predefined placeholder 1', 'signature 01', 'new attribute']; availableTemplates: ReportTemplate[]; @ViewChild('fileInput') private _fileInput: ElementRef; @@ -29,9 +24,7 @@ export class ReportsScreenComponent implements OnInit { private readonly _dialogService: AdminDialogService, private readonly _loadingService: LoadingService ) { - this._appStateService.activateDossierTemplate( - _activatedRoute.snapshot.params.dossierTemplateId - ); + this._appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); } getPlaceholderDisplayValue(placeholder: string): string { @@ -47,9 +40,7 @@ export class ReportsScreenComponent implements OnInit { this._loadingService.start(); const file = $event.target.files[0]; - await this._reportTemplateService - .uploadTemplateForm(this._appStateService.activeDossierTemplateId, file) - .toPromise(); + await this._reportTemplateService.uploadTemplateForm(this._appStateService.activeDossierTemplateId, file).toPromise(); this._fileInput.nativeElement.value = null; await this._loadReportTemplates(); @@ -65,9 +56,7 @@ export class ReportsScreenComponent implements OnInit { deleteTemplate(template: ReportTemplate) { this._dialogService.openDialog('confirm', null, null, async () => { this._loadingService.start(); - await this._reportTemplateService - .deleteTemplate(template.dossierTemplateId, template.templateId) - .toPromise(); + await this._reportTemplateService.deleteTemplate(template.dossierTemplateId, template.templateId).toPromise(); await this._loadReportTemplates(); }); } 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 67a85559d..d87d01af3 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 @@ -3,6 +3,8 @@
+ + -
+
@@ -52,10 +50,7 @@
- +
- - + +
- +
- +
- +
- + 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 78b5ad95e..3bc64a4da 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 @@ -47,9 +47,7 @@ export class WatermarkScreenComponent implements OnInit { private readonly _formBuilder: FormBuilder, private readonly _activatedRoute: ActivatedRoute ) { - this.appStateService.activateDossierTemplate( - _activatedRoute.snapshot.params.dossierTemplateId - ); + this.appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); this._initForm(); } @@ -80,22 +78,15 @@ export class WatermarkScreenComponent implements OnInit { }; const observable = watermark.text - ? this._watermarkControllerService.saveWatermark( - watermark, - this.appStateService.activeDossierTemplateId - ) - : this._watermarkControllerService.deleteWatermark( - this.appStateService.activeDossierTemplateId - ); + ? this._watermarkControllerService.saveWatermark(watermark, this.appStateService.activeDossierTemplateId) + : this._watermarkControllerService.deleteWatermark(this.appStateService.activeDossierTemplateId); observable.subscribe( () => { this._loadWatermark(); this._notificationService.showToastNotification( this._translateService.instant( - watermark.text - ? 'watermark-screen.action.change-success' - : 'watermark-screen.action.delete-success' + watermark.text ? 'watermark-screen.action.change-success' : 'watermark-screen.action.delete-success' ), null, NotificationType.SUCCESS @@ -126,20 +117,18 @@ export class WatermarkScreenComponent implements OnInit { } private _loadWatermark() { - this._watermarkControllerService - .getWatermark(this.appStateService.activeDossierTemplateId) - .subscribe( - watermark => { - this._watermark = watermark; - this.configForm.setValue({ ...this._watermark }); - this._loadViewer(); - }, - () => { - this._watermark = DEFAULT_WATERMARK; - this.configForm.setValue({ ...this._watermark }); - this._loadViewer(); - } - ); + this._watermarkControllerService.getWatermark(this.appStateService.activeDossierTemplateId).subscribe( + watermark => { + this._watermark = watermark; + this.configForm.setValue({ ...this._watermark }); + this._loadViewer(); + }, + () => { + this._watermark = DEFAULT_WATERMARK; + this.configForm.setValue({ ...this._watermark }); + this._loadViewer(); + } + ); } private _loadViewer() { @@ -186,22 +175,11 @@ export class WatermarkScreenComponent implements OnInit { const text = this.configForm.get('text').value || ''; const fontSize = this.configForm.get('fontSize').value; const fontType = this.configForm.get('fontType').value; - const orientation: WatermarkModelRes.OrientationEnum = - this.configForm.get('orientation').value; + const orientation: WatermarkModelRes.OrientationEnum = this.configForm.get('orientation').value; const opacity = this.configForm.get('opacity').value; const color = this.configForm.get('hexColor').value; - await stampPDFPage( - document, - pdfNet, - text, - fontSize, - fontType, - orientation, - opacity, - color, - 1 - ); + await stampPDFPage(document, pdfNet, text, fontSize, fontType, orientation, opacity, color, 1); this._instance.docViewer.refreshAll(); this._instance.docViewer.updateView([0], 0); this._changeDetectorRef.detectChanges(); @@ -210,26 +188,11 @@ export class WatermarkScreenComponent implements OnInit { private _initForm() { this.configForm = this._formBuilder.group({ text: [{ value: null, disabled: !this.permissionsService.isAdmin() }], - hexColor: [ - { value: null, disabled: !this.permissionsService.isAdmin() }, - Validators.required - ], - opacity: [ - { value: null, disabled: !this.permissionsService.isAdmin() }, - Validators.required - ], - fontSize: [ - { value: null, disabled: !this.permissionsService.isAdmin() }, - Validators.required - ], - fontType: [ - { value: null, disabled: !this.permissionsService.isAdmin() }, - Validators.required - ], - orientation: [ - { value: null, disabled: !this.permissionsService.isAdmin() }, - Validators.required - ] + hexColor: [{ value: null, disabled: !this.permissionsService.isAdmin() }, Validators.required], + opacity: [{ value: null, disabled: !this.permissionsService.isAdmin() }, Validators.required], + fontSize: [{ value: null, disabled: !this.permissionsService.isAdmin() }, Validators.required], + fontType: [{ value: null, disabled: !this.permissionsService.isAdmin() }, Validators.required], + orientation: [{ value: null, disabled: !this.permissionsService.isAdmin() }, Validators.required] }); } } 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 953c7afc9..3e4092fa3 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 @@ -12,6 +12,7 @@ import { ConfirmDeleteUsersDialogComponent } from '../dialogs/confirm-delete-use import { FileAttributesCsvImportDialogComponent } from '../dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component'; import { ComponentType } from '@angular/cdk/portal'; import { DialogService } from '../../shared/services/dialog.service'; +import { AddEditDossierAttributeDialogComponent } from '../dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component'; type DialogType = | 'confirm' @@ -23,7 +24,8 @@ type DialogType = | 'addEditUser' | 'deleteUsers' | 'smtpAuthConfig' - | 'addEditDossierTemplate'; + | 'addEditDossierTemplate' + | 'addEditDossierAttribute'; type AdminDialogConfig = { [key in DialogType]: { @@ -72,6 +74,10 @@ export class AdminDialogService extends DialogService { addEditDossierTemplate: { component: AddEditDossierTemplateDialogComponent, dialogConfig: { width: '900px', autoFocus: true } + }, + addEditDossierAttribute: { + component: AddEditDossierAttributeDialogComponent, + dialogConfig: { autoFocus: true } } }; diff --git a/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts index 0252f86ce..58aa957b6 100644 --- a/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts +++ b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts @@ -1,7 +1,7 @@ import { ApplicationRef, Injectable } from '@angular/core'; import { FileUploadModel } from '../model/file-upload.model'; import { AppStateService } from '@state/app-state.service'; -import { HttpEventType } from '@angular/common/http'; +import { HttpErrorResponse, HttpEventType } from '@angular/common/http'; import { interval, Subscription } from 'rxjs'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import { TranslateService } from '@ngx-translate/core'; @@ -9,6 +9,7 @@ import { UploadDownloadDialogService } from './upload-download-dialog.service'; import { toNumber } from '@utils/functions'; import { UploadControllerService } from '@redaction/red-ui-http'; import { isCsv } from '@utils/file-drop-utils'; +import { ErrorMessageService } from '@services/error-message.service'; export interface ActiveUpload { subscription: Subscription; @@ -31,19 +32,17 @@ export class FileUploadService { private readonly _translateService: TranslateService, private readonly _appConfigService: AppConfigService, private readonly _uploadControllerService: UploadControllerService, - private readonly _dialogService: UploadDownloadDialogService + private readonly _dialogService: UploadDownloadDialogService, + private readonly _errorMessageService: ErrorMessageService ) { - this._uploadControllerService.defaultHeaders = - this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true'); + this._uploadControllerService.defaultHeaders = this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true'); interval(2500).subscribe(() => { this._handleUploads(); }); } get activeDossierKeys() { - return Object.keys(this.groupedFiles).filter( - dossierId => this.groupedFiles[dossierId].length > 0 - ); + return Object.keys(this.groupedFiles).filter(dossierId => this.groupedFiles[dossierId].length > 0); } scheduleUpload(item: FileUploadModel) { @@ -133,18 +132,12 @@ export class FileUploadService { } private _handleUploads() { - if ( - this._activeUploads.length < FileUploadService.MAX_PARALLEL_UPLOADS && - this._pendingUploads.length > 0 - ) { + if (this._activeUploads.length < FileUploadService.MAX_PARALLEL_UPLOADS && this._pendingUploads.length > 0) { let cnt = FileUploadService.MAX_PARALLEL_UPLOADS - this._activeUploads.length; while (cnt > 0 && this._pendingUploads.length > 0) { // Only schedule CSVs when no other file types in queue. // CSVs are sorted at the end of `_pendingUploads`. - if ( - isCsv(this._pendingUploads[0]) && - this._activeUploads.filter(upload => !isCsv(upload.fileUploadModel)).length > 0 - ) { + if (isCsv(this._pendingUploads[0]) && this._activeUploads.filter(upload => !isCsv(upload.fileUploadModel)).length > 0) { return; } @@ -161,18 +154,11 @@ export class FileUploadService { private _createSubscription(uploadFile: FileUploadModel) { this.activeUploads++; - const obs = this._uploadControllerService.uploadFileForm( - uploadFile.dossierId, - uploadFile.file, - 'events', - true - ); + const obs = this._uploadControllerService.uploadFileForm(uploadFile.dossierId, uploadFile.file, 'events', true); return obs.subscribe( async event => { if (event.type === HttpEventType.UploadProgress) { - uploadFile.progress = Math.round( - (event.loaded / (event.total || event.loaded)) * 100 - ); + uploadFile.progress = Math.round((event.loaded / (event.total || event.loaded)) * 100); this._applicationRef.tick(); } if (event.type === HttpEventType.Response) { @@ -189,15 +175,11 @@ export class FileUploadService { await this._appStateService.reloadActiveDossierFiles(); } }, - err => { + (err: HttpErrorResponse) => { uploadFile.completed = true; uploadFile.error = { // Extract error message - message: - this._translateService.instant('upload-status.error.generic') + - (err?.error?.message?.includes('message') - ? ` ${err.error.message.match('"message":"(.*?)\\"')[1]}` - : '') + message: this._errorMessageService.getMessage(err, 'upload-status.error.generic') }; this._removeUpload(uploadFile); if (uploadFile.retryCount < 5 && err.status !== 400) { diff --git a/apps/red-ui/src/app/services/error-message.service.ts b/apps/red-ui/src/app/services/error-message.service.ts new file mode 100644 index 000000000..d8d311fb1 --- /dev/null +++ b/apps/red-ui/src/app/services/error-message.service.ts @@ -0,0 +1,18 @@ +import { Injectable } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { HttpErrorResponse } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class ErrorMessageService { + constructor(private readonly _translateService: TranslateService) {} + + _parseErrorResponse(err: HttpErrorResponse) { + return err?.error?.message?.includes('message') ? ` ${err.error.message.match('"message":"(.*?)\\"')[1]}` : ''; + } + + getMessage(err: HttpErrorResponse, defaultMessage: string) { + return this._translateService.instant(defaultMessage) + this._parseErrorResponse(err); + } +} diff --git a/apps/red-ui/src/app/services/sorting.service.ts b/apps/red-ui/src/app/services/sorting.service.ts index 8b4495971..8e093155f 100644 --- a/apps/red-ui/src/app/services/sorting.service.ts +++ b/apps/red-ui/src/app/services/sorting.service.ts @@ -11,7 +11,8 @@ export type ScreenName = | 'dictionary-listing' | 'dossier-templates-listing' | 'default-colors' - | 'file-attributes-listing'; + | 'file-attributes-listing' + | 'dossier-attributes-listing'; @Injectable({ providedIn: 'root' @@ -23,7 +24,8 @@ export class SortingService { 'dictionary-listing': { column: 'label', order: 'asc' }, 'dossier-templates-listing': { column: 'name', order: 'asc' }, 'default-colors': { column: 'key', order: 'asc' }, - 'file-attributes-listing': { column: 'label', order: 'asc' } + 'file-attributes-listing': { column: 'label', order: 'asc' }, + 'dossier-attributes-listing': { column: 'label', order: 'asc' } }; toggleSort(screen: ScreenName, column: string) { diff --git a/apps/red-ui/src/app/utils/global-error-handler.service.ts b/apps/red-ui/src/app/utils/global-error-handler.service.ts index 6f55b3a0e..08d1c33b4 100644 --- a/apps/red-ui/src/app/utils/global-error-handler.service.ts +++ b/apps/red-ui/src/app/utils/global-error-handler.service.ts @@ -5,7 +5,7 @@ export class GlobalErrorHandler extends ErrorHandler { handleError(error: Error): void { const chunkFailedMessage = /Loading chunk [\d]+ failed/; - if (chunkFailedMessage.test(error.message)) { + if (chunkFailedMessage.test(error?.message)) { window.location.reload(); } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 6cfc820ed..4b001a0b1 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,6 +1,6 @@ { - "OAUTH_URL": "https://dev-06.iqser.cloud/auth/realms/redaction", - "API_URL": "https://dev-06.iqser.cloud/redaction-gateway-v1", + "OAUTH_URL": "https://red-staging.iqser.cloud/auth/realms/redaction", + "API_URL": "https://red-staging.iqser.cloud/redaction-gateway-v1", "OAUTH_CLIENT_ID": "redaction", "BACKEND_APP_VERSION": "4.4.40", "FRONTEND_APP_VERSION": "1.1", diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index c8308f232..fb30e0b9d 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -86,6 +86,23 @@ "new": "Add New File Attribute" } }, + "add-edit-dossier-attribute": { + "form": { + "label": "Attribute Name", + "label-placeholder": "Enter Name", + "placeholder": "Attribute Placeholder", + "placeholder-placeholder": "Enter Placeholder", + "type": "Attribute Type" + }, + "save": "Save Attribute", + "title": { + "edit": "Edit {{name}} Dossier Attribute", + "new": "Add New Dossier Attribute" + }, + "error": { + "generic": "Failed to save attribute!" + } + }, "add-edit-user": { "actions": { "cancel": "Cancel", @@ -827,6 +844,12 @@ "NUMBER": "Number", "TEXT": "Free Text" }, + "dossier-attribute-types": { + "DATE": "Date", + "NUMBER": "Number", + "TEXT": "Free Text", + "IMAGE": "Image" + }, "file-attributes": "File Attributes", "file-attributes-csv-import": { "action": { @@ -914,6 +937,33 @@ }, "upload-csv": "Upload File Attributes Configuration" }, + "dossier-attributes": "Dossier Attributes", + "dossier-attributes-listing": { + "action": { + "delete": "Delete Attribute", + "edit": "Edit Attribute" + }, + "add-new": "New Attribute", + "bulk": { + "delete": "Delete Selected Attributes" + }, + "no-match": { + "title": "No attributes match your current filters." + }, + "no-data": { + "action": "New Attribute", + "title": "There are no dossier attributes." + }, + "search": "Search...", + "table-col-names": { + "label": "Label", + "placeholder": "Placeholder", + "type": "Type" + }, + "table-header": { + "title": "{{length}} dossier attributes" + } + }, "file-preview": { "assign-me": "Assign to me", "assign-reviewer": "Assign Reviewer", diff --git a/libs/red-ui-http/src/lib/api/api.ts b/libs/red-ui-http/src/lib/api/api.ts index a72d3672b..f693a3c29 100644 --- a/libs/red-ui-http/src/lib/api/api.ts +++ b/libs/red-ui-http/src/lib/api/api.ts @@ -24,6 +24,7 @@ import { SmtpConfigurationControllerService } from './smtpConfigurationControlle import { ReportTemplateControllerService } from './reportTemplateController.service'; import { UploadControllerService } from './uploadController.service'; import { GeneralSettingsControllerService } from './generalSettingsController.service'; +import { DossierAttributesControllerService } from './dossierAttributesController.service'; export * from './auditController.service'; @@ -77,6 +78,8 @@ export * from './uploadController.service'; export * from './generalSettingsController.service'; +export * from './dossierAttributesController.service'; + export const APIS = [ AuditControllerService, DebugControllerService, @@ -103,5 +106,6 @@ export const APIS = [ SmtpConfigurationControllerService, ReportTemplateControllerService, UploadControllerService, - GeneralSettingsControllerService + GeneralSettingsControllerService, + DossierAttributesControllerService ]; diff --git a/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts b/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts index c50d8f8eb..cfa08f4b4 100644 --- a/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts +++ b/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts @@ -11,7 +11,7 @@ */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; @@ -23,12 +23,13 @@ import { DossierAttributesRes } from '../model/dossierAttributesRes'; import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; +import { CustomHttpUrlEncodingCodec } from '../encoder'; @Injectable() export class DossierAttributesControllerService { - protected basePath = ''; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); + protected basePath = ''; constructor( protected httpClient: HttpClient, @@ -44,20 +45,6 @@ export class DossierAttributesControllerService { } } - /** - * @param consumes string[] mime-types - * @return true: consumes contains 'multipart/form-data', false: otherwise - */ - private canConsumeForm(consumes: string[]): boolean { - const form = 'multipart/form-data'; - for (const consume of consumes) { - if (form === consume) { - return true; - } - } - return false; - } - /** * Add or update a dossier attribute in existing dossier. * None @@ -72,18 +59,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public addOrUpdateDossierAttributes( body: DossierAttributeReq, dossierId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public addOrUpdateDossierAttributes( body: DossierAttributeReq, dossierId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public addOrUpdateDossierAttributes( body: DossierAttributeReq, dossierId: string, @@ -91,15 +81,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling addOrUpdateDossierAttributes.' - ); + throw new Error('Required parameter body was null or undefined when calling addOrUpdateDossierAttributes.'); } if (dossierId === null || dossierId === undefined) { - throw new Error( - 'Required parameter dossierId was null or undefined when calling addOrUpdateDossierAttributes.' - ); + throw new Error('Required parameter dossierId was null or undefined when calling addOrUpdateDossierAttributes.'); } let headers = this.defaultHeaders; @@ -107,24 +93,20 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = - this.configuration.selectHeaderContentType(consumes); + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } @@ -156,18 +138,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public addOrUpdateDossierAttributesConfig( body: DossierAttributeConfig, dossierTemplateId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public addOrUpdateDossierAttributesConfig( body: DossierAttributeConfig, dossierTemplateId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public addOrUpdateDossierAttributesConfig( body: DossierAttributeConfig, dossierTemplateId: string, @@ -175,15 +160,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling addOrUpdateDossierAttributesConfig.' - ); + throw new Error('Required parameter body was null or undefined when calling addOrUpdateDossierAttributesConfig.'); } if (dossierTemplateId === null || dossierTemplateId === undefined) { - throw new Error( - 'Required parameter dossierTemplateId was null or undefined when calling addOrUpdateDossierAttributesConfig.' - ); + throw new Error('Required parameter dossierTemplateId was null or undefined when calling addOrUpdateDossierAttributesConfig.'); } let headers = this.defaultHeaders; @@ -191,33 +172,27 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = - this.configuration.selectHeaderContentType(consumes); + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } return this.httpClient.request( 'post', - `${this.basePath}/dossier-attributes/config/${encodeURIComponent( - String(dossierTemplateId) - )}`, + `${this.basePath}/dossier-attributes/config/${encodeURIComponent(String(dossierTemplateId))}`, { body: body, withCredentials: this.configuration.withCredentials, @@ -242,18 +217,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public deleteDossierAttribute( dossierAttributeId: string, dossierId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public deleteDossierAttribute( dossierAttributeId: string, dossierId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public deleteDossierAttribute( dossierAttributeId: string, dossierId: string, @@ -261,15 +239,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (dossierAttributeId === null || dossierAttributeId === undefined) { - throw new Error( - 'Required parameter dossierAttributeId was null or undefined when calling deleteDossierAttribute.' - ); + throw new Error('Required parameter dossierAttributeId was null or undefined when calling deleteDossierAttribute.'); } if (dossierId === null || dossierId === undefined) { - throw new Error( - 'Required parameter dossierId was null or undefined when calling deleteDossierAttribute.' - ); + throw new Error('Required parameter dossierId was null or undefined when calling deleteDossierAttribute.'); } let headers = this.defaultHeaders; @@ -277,25 +251,22 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = []; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.request( 'delete', - `${this.basePath}/dossier-attributes/set/${encodeURIComponent( - String(dossierId) - )}/${encodeURIComponent(String(dossierAttributeId))}`, + `${this.basePath}/dossier-attributes/set/${encodeURIComponent(String(dossierId))}/${encodeURIComponent( + String(dossierAttributeId) + )}`, { withCredentials: this.configuration.withCredentials, headers: headers, @@ -319,18 +290,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public deleteDossierAttributeConfig( dossierAttributeId: string, dossierTemplateId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public deleteDossierAttributeConfig( dossierAttributeId: string, dossierTemplateId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public deleteDossierAttributeConfig( dossierAttributeId: string, dossierTemplateId: string, @@ -338,15 +312,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (dossierAttributeId === null || dossierAttributeId === undefined) { - throw new Error( - 'Required parameter dossierAttributeId was null or undefined when calling deleteDossierAttributeConfig.' - ); + throw new Error('Required parameter dossierAttributeId was null or undefined when calling deleteDossierAttributeConfig.'); } if (dossierTemplateId === null || dossierTemplateId === undefined) { - throw new Error( - 'Required parameter dossierTemplateId was null or undefined when calling deleteDossierAttributeConfig.' - ); + throw new Error('Required parameter dossierTemplateId was null or undefined when calling deleteDossierAttributeConfig.'); } let headers = this.defaultHeaders; @@ -354,25 +324,22 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = []; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.request( 'delete', - `${this.basePath}/dossier-attributes/config/${encodeURIComponent( - String(dossierTemplateId) - )}/${encodeURIComponent(String(dossierAttributeId))}`, + `${this.basePath}/dossier-attributes/config/${encodeURIComponent(String(dossierTemplateId))}/${encodeURIComponent( + String(dossierAttributeId) + )}`, { withCredentials: this.configuration.withCredentials, headers: headers, @@ -385,45 +352,51 @@ export class DossierAttributesControllerService { /** * Bulk delete dossier attributes. * None - * @param body dossierId + * @param dossierAttributeIds dossierAttributeIds * @param dossierTemplateId dossierTemplateId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public deleteDossierAttributesConfig( - body: Array, + dossierAttributeIds: Array, dossierTemplateId: string, observe?: 'body', reportProgress?: boolean ): Observable; + public deleteDossierAttributesConfig( - body: Array, + dossierAttributeIds: Array, dossierTemplateId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public deleteDossierAttributesConfig( - body: Array, + dossierAttributeIds: Array, dossierTemplateId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public deleteDossierAttributesConfig( - body: Array, + dossierAttributeIds: Array, dossierTemplateId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { - if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling deleteDossierAttributesConfig.' - ); + if (dossierAttributeIds === null || dossierAttributeIds === undefined) { + throw new Error('Required parameter dossierAttributeIds was null or undefined when calling deleteDossierAttributesConfig.'); } if (dossierTemplateId === null || dossierTemplateId === undefined) { - throw new Error( - 'Required parameter dossierTemplateId was null or undefined when calling deleteDossierAttributesConfig.' - ); + throw new Error('Required parameter dossierTemplateId was null or undefined when calling deleteDossierAttributesConfig.'); + } + + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (dossierAttributeIds) { + dossierAttributeIds.forEach(element => { + queryParameters = queryParameters.append('dossierAttributeIds', element); + }); } let headers = this.defaultHeaders; @@ -431,35 +404,22 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = []; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } - // to determine the Content-Type header - const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = - this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - headers = headers.set('Content-Type', httpContentTypeSelected); - } - return this.httpClient.request( 'post', - `${this.basePath}/dossier-attributes/config/delete/${encodeURIComponent( - String(dossierTemplateId) - )}`, + `${this.basePath}/dossier-attributes/config/delete/${encodeURIComponent(String(dossierTemplateId))}`, { - body: body, + params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, @@ -475,30 +435,23 @@ export class DossierAttributesControllerService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getDossierAttributes( - dossierId: string, - observe?: 'body', - reportProgress?: boolean - ): Observable; + public getDossierAttributes(dossierId: string, observe?: 'body', reportProgress?: boolean): Observable; + public getDossierAttributes( dossierId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public getDossierAttributes( dossierId: string, observe?: 'events', reportProgress?: boolean ): Observable>; - public getDossierAttributes( - dossierId: string, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + + public getDossierAttributes(dossierId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (dossierId === null || dossierId === undefined) { - throw new Error( - 'Required parameter dossierId was null or undefined when calling getDossierAttributes.' - ); + throw new Error('Required parameter dossierId was null or undefined when calling getDossierAttributes.'); } let headers = this.defaultHeaders; @@ -506,16 +459,13 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } @@ -544,25 +494,22 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public getDossierAttributesConfig( dossierTemplateId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public getDossierAttributesConfig( dossierTemplateId: string, observe?: 'events', reportProgress?: boolean ): Observable>; - public getDossierAttributesConfig( - dossierTemplateId: string, - observe: any = 'body', - reportProgress: boolean = false - ): Observable { + + public getDossierAttributesConfig(dossierTemplateId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (dossierTemplateId === null || dossierTemplateId === undefined) { - throw new Error( - 'Required parameter dossierTemplateId was null or undefined when calling getDossierAttributesConfig.' - ); + throw new Error('Required parameter dossierTemplateId was null or undefined when calling getDossierAttributesConfig.'); } let headers = this.defaultHeaders; @@ -570,25 +517,20 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.request( 'get', - `${this.basePath}/dossier-attributes/config/${encodeURIComponent( - String(dossierTemplateId) - )}`, + `${this.basePath}/dossier-attributes/config/${encodeURIComponent(String(dossierTemplateId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, @@ -612,18 +554,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public setDossierAttributes( body: DossierAttributesReq, dossierId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public setDossierAttributes( body: DossierAttributesReq, dossierId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public setDossierAttributes( body: DossierAttributesReq, dossierId: string, @@ -631,15 +576,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling setDossierAttributes.' - ); + throw new Error('Required parameter body was null or undefined when calling setDossierAttributes.'); } if (dossierId === null || dossierId === undefined) { - throw new Error( - 'Required parameter dossierId was null or undefined when calling setDossierAttributes.' - ); + throw new Error('Required parameter dossierId was null or undefined when calling setDossierAttributes.'); } let headers = this.defaultHeaders; @@ -647,24 +588,20 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = - this.configuration.selectHeaderContentType(consumes); + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } @@ -696,18 +633,21 @@ export class DossierAttributesControllerService { observe?: 'body', reportProgress?: boolean ): Observable; + public setDossierAttributesConfig( body: DossierAttributesConfig, dossierTemplateId: string, observe?: 'response', reportProgress?: boolean ): Observable>; + public setDossierAttributesConfig( body: DossierAttributesConfig, dossierTemplateId: string, observe?: 'events', reportProgress?: boolean ): Observable>; + public setDossierAttributesConfig( body: DossierAttributesConfig, dossierTemplateId: string, @@ -715,15 +655,11 @@ export class DossierAttributesControllerService { reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { - throw new Error( - 'Required parameter body was null or undefined when calling setDossierAttributesConfig.' - ); + throw new Error('Required parameter body was null or undefined when calling setDossierAttributesConfig.'); } if (dossierTemplateId === null || dossierTemplateId === undefined) { - throw new Error( - 'Required parameter dossierTemplateId was null or undefined when calling setDossierAttributesConfig.' - ); + throw new Error('Required parameter dossierTemplateId was null or undefined when calling setDossierAttributesConfig.'); } let headers = this.defaultHeaders; @@ -731,33 +667,27 @@ export class DossierAttributesControllerService { // authentication (RED-OAUTH) required if (this.configuration.accessToken) { const accessToken = - typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header const httpHeaderAccepts: string[] = ['application/json']; - const httpHeaderAcceptSelected: string | undefined = - this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = ['application/json']; - const httpContentTypeSelected: string | undefined = - this.configuration.selectHeaderContentType(consumes); + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } return this.httpClient.request( 'put', - `${this.basePath}/dossier-attributes/config/${encodeURIComponent( - String(dossierTemplateId) - )}`, + `${this.basePath}/dossier-attributes/config/${encodeURIComponent(String(dossierTemplateId))}`, { body: body, withCredentials: this.configuration.withCredentials, @@ -767,4 +697,18 @@ export class DossierAttributesControllerService { } ); } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (const consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } }