Pull request #336: FirstValueFrom

Merge in RED/ui from firstValueFrom to master

* commit '880318f352daf831a5e7efd6e9dbb5fa2a39c9fe':
  fixed removed imports from rebase
  added dossier-template-listing ts file
  update common
  firstValueFrom instead of  toPromise() in red-ui
  wip shared module
  firstValueFrom instead of toPromise() in dossier module
  firstValueFrom instead of toPromise() in account module
  firstValueFrom instead of toPromise() in admin module
This commit is contained in:
Eduard Cziszter 2022-01-25 16:07:57 +01:00
commit 0abd8e9e49
68 changed files with 479 additions and 455 deletions

View File

@ -11,7 +11,7 @@ import {
} from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { RouterHistoryService } from '@services/router-history.service';
import { interval } from 'rxjs';
import { firstValueFrom, interval } from 'rxjs';
import { switchMap } from 'rxjs/operators';
@Component({
@ -60,11 +60,11 @@ export class DownloadsListScreenComponent extends ListingComponent<DownloadStatu
private async _deleteItems(downloads?: DownloadStatus[]) {
const storageIds = (downloads || this.listingService.selected).map(d => d.storageId);
await this.fileDownloadService.delete({ storageIds }).toPromise();
await firstValueFrom(this.fileDownloadService.delete({ storageIds }));
await this._loadData();
}
private async _loadData() {
await this.fileDownloadService.loadAll().toPromise();
await firstValueFrom(this.fileDownloadService.loadAll());
}
}

View File

@ -6,7 +6,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
import { NotificationsService } from '@services/notifications.service';
import { Notification } from '@red/domain';
import { distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators';
import { BehaviorSubject, Observable, timer } from 'rxjs';
import { BehaviorSubject, firstValueFrom, Observable, timer } from 'rxjs';
import { AutoUnsubscribe, List, shareLast } from '@iqser/common-ui';
import { CHANGED_CHECK_INTERVAL } from '@utils/constants';
@ -63,12 +63,12 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
async markRead($event, notifications: List<string> = this._notifications$.getValue().map(n => n.id), isRead = true): Promise<void> {
$event.stopPropagation();
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
await firstValueFrom(this._notificationsService.toggleNotificationRead(notifications, isRead));
await this._loadData();
}
private async _loadData(): Promise<void> {
const notifications = await this._notificationsService.getNotifications(INCLUDE_SEEN).toPromise();
const notifications = await firstValueFrom(this._notificationsService.getNotifications(INCLUDE_SEEN));
this._notifications$.next(notifications);
}

View File

@ -3,6 +3,7 @@ import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { FilesMapService } from '@services/entity-services/files-map.service';
import { FilesService } from '@services/entity-services/files.service';
import { firstValueFrom } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class DossierFilesGuard implements CanActivate {
@ -22,7 +23,7 @@ export class DossierFilesGuard implements CanActivate {
}
if (!this._filesMapService.has(dossierId)) {
await this._filesService.loadAll(dossierId).toPromise();
await firstValueFrom(this._filesService.loadAll(dossierId));
}
return true;
}

View File

@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class DossiersGuard implements CanActivate {
@ -12,7 +13,7 @@ export class DossiersGuard implements CanActivate {
) {}
async canActivate(): Promise<boolean> {
await this._dossiersService.loadAll().toPromise();
await firstValueFrom(this._dossiersService.loadAll());
return true;
}
}

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { UserPreferenceService } from '@services/user-preference.service';
import { firstValueFrom } from 'rxjs';
@Injectable({
providedIn: 'root',
@ -27,12 +28,12 @@ export class LanguageService {
}
document.documentElement.lang = defaultLang;
this._translateService.setDefaultLang(defaultLang);
this._translateService.use(defaultLang).toPromise().then();
firstValueFrom(this._translateService.use(defaultLang)).then();
}
async changeLanguage(language: string) {
await this._userPreferenceService.saveLanguage(language);
document.documentElement.lang = language;
await this._translateService.use(language).toPromise();
await firstValueFrom(this._translateService.use(language));
}
}

View File

@ -10,6 +10,7 @@ import {
NotificationGroupsKeys,
NotificationGroupsValues,
} from '@red/domain';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-notifications-screen',
@ -67,7 +68,7 @@ export class NotificationsScreenComponent implements OnInit {
async save() {
this._loadingService.start();
try {
await this._notificationPreferencesService.update(this.formGroup.value).toPromise();
await firstValueFrom(this._notificationPreferencesService.update(this.formGroup.value));
} catch (e) {
this._toaster.error(_('notifications-screen.error.generic'));
}
@ -87,7 +88,7 @@ export class NotificationsScreenComponent implements OnInit {
private async _initializeForm() {
this._loadingService.start();
const notificationPreferences = await this._notificationPreferencesService.get().toPromise();
const notificationPreferences = await firstValueFrom(this._notificationPreferencesService.get());
this.formGroup.patchValue(notificationPreferences);
this._loadingService.stop();

View File

@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service';
import { UserService } from '@services/user.service';
import { ConfigService } from '../../../../../services/config.service';
import { LanguageService } from '../../../../../i18n/language.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-user-profile-screen',
@ -76,14 +77,14 @@ export class UserProfileScreenComponent implements OnInit {
const value = this.form.getRawValue() as IProfile;
delete value.language;
await this._userService
.updateMyProfile({
await firstValueFrom(
this._userService.updateMyProfile({
...value,
})
.toPromise();
}),
);
await this._userService.loadCurrentUser();
await this._userService.loadAll().toPromise();
await firstValueFrom(this._userService.loadAll());
}
this._initializeForm();

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, Inject, Injector } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { BaseDialogComponent, shareDistinctLast, Toaster } from '@iqser/common-ui';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -77,8 +77,7 @@ export class AddEditDictionaryDialogComponent extends BaseDialogComponent {
observable = this._dictionaryService.addDictionary({ ...dictionary, dossierTemplateId });
}
return observable
.toPromise()
return firstValueFrom(observable)
.then(() => this._dialogRef.close(true))
.catch(error => {
if (error.status === HttpStatusCode.Conflict) {

View File

@ -11,6 +11,7 @@ import { BaseDialogComponent, LoadingService, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DownloadFileType, IDossierTemplate } from '@red/domain';
import { HttpStatusCode } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './add-edit-dossier-template-dialog.component.html',

View File

@ -4,6 +4,7 @@ import { UserService } from '@services/user.service';
import { LoadingService, Toaster } from '@iqser/common-ui';
import { User } from '@red/domain';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-reset-password',
@ -25,15 +26,15 @@ export class ResetPasswordComponent {
async save() {
this._loadingService.start();
try {
await this._userService
.resetPassword(
await firstValueFrom(
this._userService.resetPassword(
{
password: this.form.get('temporaryPassword').value,
temporary: true,
},
this.user.id,
)
.toPromise();
),
);
this.toggleResetPassword.emit();
} catch (error) {
this._toaster.error(_('reset-password-dialog.error.password-policy'));

View File

@ -7,6 +7,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { User } from '@red/domain';
import { UserService } from '@services/user.service';
import { HttpStatusCode } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-user-details',
@ -107,9 +108,7 @@ export class UserDetailsComponent extends AutoUnsubscribe implements OnChanges,
const userData = { ...this.form.getRawValue(), roles: this.activeRoles };
if (!this.user) {
await this.userService
.create(userData)
.toPromise()
await firstValueFrom(this.userService.create(userData))
.then(() => {
this.closeDialog.emit(true);
})
@ -122,7 +121,7 @@ export class UserDetailsComponent extends AutoUnsubscribe implements OnChanges,
this._loadingService.stop();
});
} else {
await this.userService.updateProfile(userData, this.user.id).toPromise();
await firstValueFrom(this.userService.updateProfile(userData, this.user.id));
this.closeDialog.emit(true);
}
}

View File

@ -4,6 +4,7 @@ import { List, LoadingService } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { UserService } from '@services/user.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-confirm-delete-users-dialog',
@ -40,7 +41,7 @@ export class ConfirmDeleteUsersDialogComponent {
async deleteUser() {
if (this.valid) {
this._loadingService.start();
await this._userService.delete(this.userIds).toPromise();
await firstValueFrom(this._userService.delete(this.userIds));
this.dialogRef.close(true);
} else {
this.showToast = true;

View File

@ -7,6 +7,7 @@ import { TranslateService } from '@ngx-translate/core';
import { defaultColorsTranslations } from '../../translations/default-colors-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DictionaryService } from '@shared/services/dictionary.service';
import { firstValueFrom } from 'rxjs';
interface IEditColorData {
colors: IColors;
@ -46,7 +47,7 @@ export class EditColorDialogComponent extends BaseDialogComponent {
};
try {
await this._dictionaryService.setColors(colors, this._dossierTemplateId).toPromise();
await firstValueFrom(this._dictionaryService.setColors(colors, this._dossierTemplateId));
this._dialogRef.close(true);
const color = this._translateService.instant(defaultColorsTranslations[this.data.colorKey]);
this._toaster.info(_('edit-color-dialog.success'), { params: { color: color } });

View File

@ -2,9 +2,9 @@ import { ChangeDetectionStrategy, Component, Inject, Injector } from '@angular/c
import { AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import * as Papa from 'papaparse';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { DefaultListingServices, ListingComponent, TableColumnConfig, Toaster, trackBy } from '@iqser/common-ui';
import { DefaultListingServices, ListingComponent, TableColumnConfig, Toaster, trackByFactory } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FileAttributeConfig, FileAttributeConfigTypes, IField, IFileAttributesConfig } from '@red/domain';
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
@ -34,7 +34,7 @@ export class FileAttributesCsvImportDialogComponent extends ListingComponent<IFi
columnSample = [];
initialParseConfig: { delimiter?: string; encoding?: string } = {};
readonly tableHeaderLabel = '';
readonly trackBy = trackBy();
readonly trackBy = trackByFactory();
constructor(
private readonly _toaster: Toaster,
@ -56,14 +56,6 @@ export class FileAttributesCsvImportDialogComponent extends ListingComponent<IFi
);
}
private _getForm(): FormGroup {
return this._formBuilder.group({
filenameMappingColumnHeaderName: ['', [Validators.required, this._autocompleteStringValidator()]],
delimiter: [undefined, Validators.required],
encoding: ['UTF-8', Validators.required],
});
}
readFile() {
const reader = new FileReader();
reader.addEventListener('load', event => {
@ -183,7 +175,7 @@ export class FileAttributesCsvImportDialogComponent extends ListingComponent<IFi
};
try {
await this._fileAttributesService.setFileAttributeConfig(fileAttributes, this.data.dossierTemplateId).toPromise();
await firstValueFrom(this._fileAttributesService.setFileAttributeConfig(fileAttributes, this.data.dossierTemplateId));
this._toaster.success(_('file-attributes-csv-import.save.success'), { params: { count: this.activeFields.length } });
} catch (e) {
this._toaster.error(_('file-attributes-csv-import.save.error'));
@ -207,6 +199,14 @@ export class FileAttributesCsvImportDialogComponent extends ListingComponent<IFi
}, 0);
}
private _getForm(): FormGroup {
return this._formBuilder.group({
filenameMappingColumnHeaderName: ['', [Validators.required, this._autocompleteStringValidator()]],
delimiter: [undefined, Validators.required],
encoding: ['UTF-8', Validators.required],
});
}
private _autocompleteStringValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
if ((this.parseResult?.meta?.fields || []).indexOf(control.value) !== -1) {

View File

@ -8,6 +8,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { Audit, IAudit, IAuditResponse, IAuditSearchRequest } from '@red/domain';
import { AuditService } from '../../services/audit.service';
import { firstValueFrom } from 'rxjs';
const PAGE_SIZE = 50;
@ -52,15 +53,6 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
});
}
private _getForm(): FormGroup {
return this._formBuilder.group({
category: [this.ALL_CATEGORIES],
userId: [this.ALL_USERS],
from: [],
to: [],
});
}
get totalPages(): number {
if (!this.logs) {
return 0;
@ -76,6 +68,15 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
await this._fetchData();
}
private _getForm(): FormGroup {
return this._formBuilder.group({
category: [this.ALL_CATEGORIES],
userId: [this.ALL_USERS],
from: [],
to: [],
});
}
private _updateDateFilters(value): boolean {
if (applyIntervalConstraints(value, this._previousFrom, this._previousTo, this.form, 'from', 'to')) {
return true;
@ -105,8 +106,8 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
to,
};
promises.push(this._auditService.getCategories().toPromise());
promises.push(this._auditService.searchAuditLog(logsRequestBody).toPromise());
promises.push(firstValueFrom(this._auditService.getCategories()));
promises.push(firstValueFrom(this._auditService.searchAuditLog(logsRequestBody)));
const data = await Promise.all(promises);
this.categories = data[0].map(c => c.category);

View File

@ -15,6 +15,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { DictionaryService } from '@shared/services/dictionary.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { firstValueFrom } from 'rxjs';
interface ListItem extends IListable {
readonly key: string;
@ -72,7 +73,7 @@ export class DefaultColorsScreenComponent extends ListingComponent<ListItem> imp
private async _loadColors() {
this._loadingService.start();
const data = await this._appStateService.loadColors(this._dossierTemplatesService.activeDossierTemplateId).toPromise();
const data = await firstValueFrom(this._appStateService.loadColors(this._dossierTemplatesService.activeDossierTemplateId));
this._colorsObj = data;
const entities = Object.keys(data)
.map(key => ({

View File

@ -16,7 +16,7 @@ import { UserService } from '@services/user.service';
import { DictionaryService } from '@shared/services/dictionary.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { Dictionary, DossierTemplateStats } from '@red/domain';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { DossierTemplateStatsService } from '@services/entity-services/dossier-template-stats.service';
import { ActivatedRoute } from '@angular/router';
import { tap } from 'rxjs/operators';
@ -66,12 +66,12 @@ export class DictionaryListingScreenComponent extends ListingComponent<Dictionar
openDeleteDictionariesDialog($event?: MouseEvent, types = this.listingService.selected) {
this._dialogService.openDialog('confirm', $event, null, async () => {
this._loadingService.start();
await this._dictionaryService
.deleteDictionaries(
await firstValueFrom(
this._dictionaryService.deleteDictionaries(
types.map(t => t.type),
this._dossierTemplatesService.activeDossierTemplateId,
)
.toPromise();
),
);
await this._loadDictionaryData();
this._loadingService.stop();
});

View File

@ -11,6 +11,7 @@ import { CircleButtonTypes, LoadingService } from '@iqser/common-ui';
import { UserService } from '@services/user.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { Dictionary } from '@red/domain';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './dictionary-overview-screen.component.html',
@ -72,7 +73,7 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
$event?.stopPropagation();
this._dialogService.openDialog('confirm', $event, null, async () => {
await this._dictionaryService.deleteDictionaries([this.dictionary.type], this.dictionary.dossierTemplateId).toPromise();
await firstValueFrom(this._dictionaryService.deleteDictionaries([this.dictionary.type], this.dictionary.dossierTemplateId));
await this._appStateService.loadDictionaryData();
await this._router.navigate([
'/main',
@ -149,9 +150,7 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
private async _loadEntries() {
this._loadingService.start();
await this._dictionaryService
.getForType(this.dictionary.dossierTemplateId, this.dictionary.type)
.toPromise()
await firstValueFrom(this._dictionaryService.getForType(this.dictionary.dossierTemplateId, this.dictionary.type))
.then(
data => {
this._loadingService.stop();

View File

@ -15,6 +15,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { DossierAttributeConfig, IDossierAttributeConfig } from '@red/domain';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './dossier-attributes-listing-screen.component.html',
@ -56,7 +57,7 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
this._dialogService.openDialog('confirm', $event, null, async () => {
this._loadingService.start();
const ids = dossierAttribute ? [dossierAttribute.id] : this.listingService.selected.map(item => item.id);
await this._dossierAttributesService.delete(ids).toPromise();
await firstValueFrom(this._dossierAttributesService.delete(ids));
await this._loadData();
});
}
@ -71,7 +72,7 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
private async _loadData() {
this._loadingService.start();
await this._dossierAttributesService.loadAll().toPromise();
await firstValueFrom(this._dossierAttributesService.loadAll());
this._loadingService.stop();
}
}

View File

@ -18,6 +18,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { RouterHistoryService } from '@services/router-history.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { HttpStatusCode } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './dossier-templates-listing-screen.component.html',
@ -66,16 +67,13 @@ export class DossierTemplatesListingScreenComponent extends ListingComponent<Dos
}
private async _deleteTemplates(templateIds = this.listingService.selected.map(d => d.dossierTemplateId)) {
await this._dossierTemplatesService
.delete(templateIds)
.toPromise()
.catch(error => {
if (error.status === HttpStatusCode.Conflict) {
this._toaster.error(_('dossier-templates-listing.error.conflict'));
} else {
this._toaster.error(_('dossier-templates-listing.error.generic'));
}
});
await firstValueFrom(this._dossierTemplatesService.delete(templateIds)).catch(error => {
if (error.status === HttpStatusCode.Conflict) {
this._toaster.error(_('dossier-templates-listing.error.conflict'));
} else {
this._toaster.error(_('dossier-templates-listing.error.generic'));
}
});
await this._appStateService.loadDictionaryData();
}
}

View File

@ -17,6 +17,7 @@ import { FileAttributeConfig, IFileAttributeConfig, IFileAttributesConfig } from
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { HttpStatusCode } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './file-attributes-listing-screen.component.html',
@ -92,14 +93,14 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
this._loadingService.start();
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
if (fileAttribute) {
await this._fileAttributesService.deleteFileAttributes([fileAttribute.id], dossierTemplateId).toPromise();
await firstValueFrom(this._fileAttributesService.deleteFileAttributes([fileAttribute.id], dossierTemplateId));
} else {
await this._fileAttributesService
.deleteFileAttributes(
await firstValueFrom(
this._fileAttributesService.deleteFileAttributes(
this.listingService.selected.map(f => f.id),
dossierTemplateId,
)
.toPromise();
),
);
}
await this._appStateService.refreshDossierTemplate(dossierTemplateId);
await this._loadData();
@ -123,17 +124,16 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
}
private async _createNewFileAttributeAndRefreshView(newValue: IFileAttributeConfig): Promise<void> {
await this._fileAttributesService
.setFileAttributesConfig(newValue, this._dossierTemplatesService.activeDossierTemplateId)
.toPromise()
.catch(error => {
if (error.status === HttpStatusCode.Conflict) {
this._toaster.error(_('file-attributes-listing.error.conflict'));
} else {
this._toaster.error(_('file-attributes-listing.error.generic'));
}
this._loadingService.stop();
});
await firstValueFrom(
this._fileAttributesService.setFileAttributesConfig(newValue, this._dossierTemplatesService.activeDossierTemplateId),
).catch(error => {
if (error.status === HttpStatusCode.Conflict) {
this._toaster.error(_('file-attributes-listing.error.conflict'));
} else {
this._toaster.error(_('file-attributes-listing.error.generic'));
}
this._loadingService.stop();
});
await this._appStateService.refreshDossierTemplate(this._dossierTemplatesService.activeDossierTemplateId);
await this._loadData();
}
@ -142,9 +142,9 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
this._loadingService.start();
try {
const response = await this._fileAttributesService
.getFileAttributesConfig(this._dossierTemplatesService.activeDossierTemplateId)
.toPromise();
const response = await firstValueFrom(
this._fileAttributesService.getFileAttributesConfig(this._dossierTemplatesService.activeDossierTemplateId),
);
this._existingConfiguration = response;
const fileAttributeConfig = response?.fileAttributeConfigs.map(item => new FileAttributeConfig(item)) || [];
this.entitiesService.setEntities(fileAttributeConfig);

View File

@ -4,6 +4,7 @@ import { GeneralSettingsService } from '@services/general-settings.service';
import { IGeneralConfiguration } from '@red/domain';
import { ConfigService } from '@services/config.service';
import { FormBuilder, FormGroup } from '@angular/forms';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-general-config-form',
@ -11,8 +12,8 @@ import { FormBuilder, FormGroup } from '@angular/forms';
styleUrls: ['./general-config-form.component.scss'],
})
export class GeneralConfigFormComponent extends AutoUnsubscribe implements OnInit, OnDestroy {
private _initialConfiguration: IGeneralConfiguration;
readonly form: FormGroup = this._getForm();
private _initialConfiguration: IGeneralConfiguration;
constructor(
private readonly _loadingService: LoadingService,
@ -23,28 +24,6 @@ export class GeneralConfigFormComponent extends AutoUnsubscribe implements OnIni
super();
}
private _getForm(): FormGroup {
return this._formBuilder.group({
forgotPasswordFunctionEnabled: [false],
auxiliaryName: [undefined],
});
}
async ngOnInit(): Promise<void> {
await this._loadData();
}
async saveGeneralConfig() {
this._loadingService.start();
const configFormValues = this.form.getRawValue();
await this._generalSettingsService.updateGeneralConfigurations(configFormValues).toPromise();
this._initialConfiguration = await this._generalSettingsService.getGeneralConfigurations().toPromise();
this._configService.updateDisplayName(this._initialConfiguration.displayName);
this._loadingService.stop();
}
get generalConfigurationChanged(): boolean {
if (!this._initialConfiguration) {
return true;
@ -59,10 +38,32 @@ export class GeneralConfigFormComponent extends AutoUnsubscribe implements OnIni
return false;
}
async ngOnInit(): Promise<void> {
await this._loadData();
}
async saveGeneralConfig() {
this._loadingService.start();
const configFormValues = this.form.getRawValue();
await firstValueFrom(this._generalSettingsService.updateGeneralConfigurations(configFormValues));
this._initialConfiguration = await firstValueFrom(this._generalSettingsService.getGeneralConfigurations());
this._configService.updateDisplayName(this._initialConfiguration.displayName);
this._loadingService.stop();
}
private _getForm(): FormGroup {
return this._formBuilder.group({
forgotPasswordFunctionEnabled: [false],
auxiliaryName: [undefined],
});
}
private async _loadData() {
this._loadingService.start();
try {
this._initialConfiguration = await this._generalSettingsService.getGeneralConfigurations().toPromise();
this._initialConfiguration = await firstValueFrom(this._generalSettingsService.getGeneralConfigurations());
this.form.patchValue(this._initialConfiguration, { emitEvent: false });
} catch (e) {}

View File

@ -5,6 +5,7 @@ import { AutoUnsubscribe, IconButtonTypes, LoadingService, Toaster } from '@iqse
import { AdminDialogService } from '../../../services/admin-dialog.service';
import { SmtpConfigService } from '../../../services/smtp-config.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-smtp-form',
@ -13,8 +14,8 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
})
export class SmtpFormComponent extends AutoUnsubscribe implements OnInit, OnDestroy {
readonly iconButtonTypes = IconButtonTypes;
private _initialConfiguration: ISmtpConfiguration;
readonly form: FormGroup = this._getForm();
private _initialConfiguration: ISmtpConfiguration;
constructor(
private readonly _formBuilder: FormBuilder,
@ -31,10 +32,53 @@ export class SmtpFormComponent extends AutoUnsubscribe implements OnInit, OnDest
});
}
get smtpConfigurationChanged(): boolean {
if (!this._initialConfiguration) {
return true;
}
for (const key of Object.keys(this.form.getRawValue())) {
if (this._initialConfiguration[key] !== this.form.get(key).value) {
return true;
}
}
return false;
}
async ngOnInit(): Promise<void> {
await this._loadData();
}
openAuthConfigDialog(skipDisableOnCancel?: boolean) {
this._dialogService.openDialog('smtpAuthConfig', null, this.form.getRawValue(), null, authConfig => {
if (authConfig) {
this.form.patchValue(authConfig);
} else if (!skipDisableOnCancel) {
this.form.patchValue({ auth: false }, { emitEvent: false });
}
});
}
async save() {
this._loadingService.start();
await firstValueFrom(this._smtpConfigService.updateSMTPConfiguration(this.form.getRawValue()));
this._initialConfiguration = this.form.getRawValue();
this._loadingService.stop();
}
async testConnection() {
this._loadingService.start();
try {
await firstValueFrom(this._smtpConfigService.testSMTPConfiguration(this.form.getRawValue()));
this._toaster.success(_('general-config-screen.test.success'));
} catch (e) {
this._toaster.error(_('general-config-screen.test.error'));
} finally {
this._loadingService.stop();
}
}
private _getForm(): FormGroup {
return this._formBuilder.group({
host: [undefined, Validators.required],
@ -52,54 +96,11 @@ export class SmtpFormComponent extends AutoUnsubscribe implements OnInit, OnDest
});
}
openAuthConfigDialog(skipDisableOnCancel?: boolean) {
this._dialogService.openDialog('smtpAuthConfig', null, this.form.getRawValue(), null, authConfig => {
if (authConfig) {
this.form.patchValue(authConfig);
} else if (!skipDisableOnCancel) {
this.form.patchValue({ auth: false }, { emitEvent: false });
}
});
}
async save() {
this._loadingService.start();
await this._smtpConfigService.updateSMTPConfiguration(this.form.getRawValue()).toPromise();
this._initialConfiguration = this.form.getRawValue();
this._loadingService.stop();
}
get smtpConfigurationChanged(): boolean {
if (!this._initialConfiguration) {
return true;
}
for (const key of Object.keys(this.form.getRawValue())) {
if (this._initialConfiguration[key] !== this.form.get(key).value) {
return true;
}
}
return false;
}
async testConnection() {
this._loadingService.start();
try {
await this._smtpConfigService.testSMTPConfiguration(this.form.getRawValue()).toPromise();
this._toaster.success(_('general-config-screen.test.success'));
} catch (e) {
this._toaster.error(_('general-config-screen.test.error'));
} finally {
this._loadingService.stop();
}
}
private async _loadData() {
this._loadingService.start();
try {
this._initialConfiguration = await this._smtpConfigService.getCurrentSMTPConfiguration().toPromise();
this._initialConfiguration = await firstValueFrom(this._smtpConfigService.getCurrentSMTPConfiguration());
this.form.patchValue(this._initialConfiguration, { emitEvent: false });
} catch (e) {}

View File

@ -5,6 +5,7 @@ import { Justification } from '@red/domain';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { LoadingService } from '@iqser/common-ui';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-add-edit-justification-dialog',
@ -35,8 +36,8 @@ export class AddEditJustificationDialogComponent {
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
this._loadingService.start();
await this._justificationService.createOrUpdate(this.form.getRawValue(), dossierTemplateId).toPromise();
await this._justificationService.loadAll(dossierTemplateId).toPromise();
await firstValueFrom(this._justificationService.createOrUpdate(this.form.getRawValue(), dossierTemplateId));
await firstValueFrom(this._justificationService.loadAll(dossierTemplateId));
this._loadingService.stop();
this.dialogRef.close(true);
}

View File

@ -13,6 +13,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Justification } from '@red/domain';
import { firstValueFrom } from 'rxjs';
type DialogType = 'confirm' | 'addEditJustification';
@ -51,8 +52,8 @@ export class JustificationsDialogService extends DialogService<DialogType> {
this._loadingService.start();
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
const justificationIds = justifications.map(j => j.id);
await this._justificationService.delete(justificationIds, dossierTemplateId).toPromise();
await this._justificationService.loadAll(dossierTemplateId).toPromise();
await firstValueFrom(this._justificationService.delete(justificationIds, dossierTemplateId));
await firstValueFrom(this._justificationService.loadAll(dossierTemplateId));
this._loadingService.stop();
});
}

View File

@ -15,6 +15,7 @@ import { DossierTemplatesService } from '@services/entity-services/dossier-templ
import { JustificationsDialogService } from '../justifications-dialog.service';
import { UserService } from '@services/user.service';
import { UserPreferenceService } from '@services/user-preference.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-justifications-screen',
@ -52,7 +53,7 @@ export class JustificationsScreenComponent extends ListingComponent<Justificatio
async ngOnInit(): Promise<void> {
this._loadingService.start();
await this._justificationService.loadAll(this._dossierTemplatesService.activeDossierTemplateId).toPromise();
await firstValueFrom(this._justificationService.loadAll(this._dossierTemplatesService.activeDossierTemplateId));
this._loadingService.stop();
}

View File

@ -9,6 +9,7 @@ import { RouterHistoryService } from '@services/router-history.service';
import { LicenseReportService } from '../../services/licence-report.service';
import { ILicenseReport } from '@red/domain';
import { Color, ScaleType } from '@swimlane/ngx-charts';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-license-information-screen',
@ -72,15 +73,15 @@ export class LicenseInformationScreenComponent implements OnInit {
endDate: endDate.toDate(),
};
const promises = [
this._licenseReportService.licenseReport(currentConfig).toPromise(),
this._licenseReportService.licenseReport({}).toPromise(),
firstValueFrom(this._licenseReportService.licenseReport(currentConfig)),
firstValueFrom(this._licenseReportService.licenseReport({})),
];
if (endDate.isBefore(moment())) {
const unlicensedConfig = {
startDate: endDate.toDate(),
};
promises.push(this._licenseReportService.licenseReport(unlicensedConfig).toPromise());
promises.push(firstValueFrom(this._licenseReportService.licenseReport(unlicensedConfig)));
}
Promise.all(promises).then(reports => {
@ -135,12 +136,12 @@ export class LicenseInformationScreenComponent implements OnInit {
}
promises.push(
this._licenseReportService
.licenseReport({
firstValueFrom(
this._licenseReportService.licenseReport({
startDate: moment(`01-${m + 1}-${y}`, 'DD-MM-YYYY').toDate(),
endDate: moment(`01-${nm + 1}-${ny}`, 'DD-MM-YYYY').toDate(),
})
.toPromise(),
}),
),
);
y = ny;

View File

@ -12,6 +12,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { AdminDialogService } from '../../services/admin-dialog.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { ReportTemplateService } from '@services/report-template.service';
import { firstValueFrom } from 'rxjs';
interface Placeholder {
placeholder: string;
@ -56,9 +57,9 @@ export class ReportsScreenComponent implements OnInit {
async download(template: IReportTemplate) {
this._loadingService.start();
try {
const data = await this._reportTemplateService
.downloadReportTemplate(template.dossierTemplateId, template.templateId, 'response')
.toPromise();
const data = await firstValueFrom(
this._reportTemplateService.downloadReportTemplate(template.dossierTemplateId, template.templateId, 'response'),
);
this._loadingService.stop();
download(data, template.fileName);
} catch (e) {
@ -130,31 +131,31 @@ export class ReportsScreenComponent implements OnInit {
});
this._dialogService.openDialog('confirm', null, data, null, async result => {
if (result) {
await this._reportTemplateService.uploadTemplateForm(dossierTemplateId, result > 1, file).toPromise();
await firstValueFrom(this._reportTemplateService.uploadTemplateForm(dossierTemplateId, result > 1, file));
await this._loadReportTemplates();
}
});
} else {
await this._reportTemplateService.uploadTemplateForm(dossierTemplateId, false, file).toPromise();
await firstValueFrom(this._reportTemplateService.uploadTemplateForm(dossierTemplateId, false, file));
await this._loadReportTemplates();
}
}
private async _deleteTemplate(template: IReportTemplate) {
await this._reportTemplateService.delete(template.dossierTemplateId, template.templateId).toPromise();
await firstValueFrom(this._reportTemplateService.delete(template.dossierTemplateId, template.templateId));
await this._loadReportTemplates();
}
private async _loadReportTemplates() {
this.availableTemplates = await this._reportTemplateService
.getAvailableReportTemplates(this._dossierTemplatesService.activeDossierTemplateId)
.toPromise();
this.availableTemplates = await firstValueFrom(
this._reportTemplateService.getAvailableReportTemplates(this._dossierTemplatesService.activeDossierTemplateId),
);
}
private async _loadPlaceholders() {
const placeholdersResponse: IPlaceholdersResponse = await this._reportTemplateService
.getAvailablePlaceholders(this._dossierTemplatesService.activeDossierTemplateId)
.toPromise();
const placeholdersResponse: IPlaceholdersResponse = await firstValueFrom(
this._reportTemplateService.getAvailablePlaceholders(this._dossierTemplatesService.activeDossierTemplateId),
);
this.placeholders = placeholderTypes.flatMap(type =>
placeholdersResponse[type].map(placeholder => ({
placeholder,

View File

@ -7,6 +7,7 @@ import { ComponentHasChanges } from '@guards/can-deactivate.guard';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { RulesService } from '../../services/rules.service';
import { firstValueFrom } from 'rxjs';
import ICodeEditor = monaco.editor.ICodeEditor;
import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration;
import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions;
@ -87,22 +88,21 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit
async save(): Promise<void> {
this._loadingService.start();
await this._rulesService
.uploadRules({
await firstValueFrom(
this._rulesService.uploadRules({
rules: this._codeEditor.getModel().getValue(),
dossierTemplateId: this._dossierTemplatesService.activeDossierTemplateId,
})
.toPromise()
.then(
async () => {
await this._initialize();
this._toaster.success(_('rules-screen.success.generic'));
},
() => {
this._loadingService.stop();
this._toaster.error(_('rules-screen.error.generic'));
},
);
}),
).then(
async () => {
await this._initialize();
this._toaster.success(_('rules-screen.success.generic'));
},
() => {
this._loadingService.stop();
this._toaster.error(_('rules-screen.error.generic'));
},
);
}
revert(): void {
@ -148,15 +148,12 @@ export class RulesScreenComponent extends ComponentHasChanges implements OnInit
private async _initialize() {
this._loadingService.start();
await this._rulesService
.download(this._dossierTemplatesService.activeDossierTemplateId)
.toPromise()
.then(
rules => {
this.currentLines = this.initialLines = rules.rules.split('\n');
this.revert();
},
() => this._loadingService.stop(),
);
await firstValueFrom(this._rulesService.download(this._dossierTemplatesService.activeDossierTemplateId)).then(
rules => {
this.currentLines = this.initialLines = rules.rules.split('\n');
this.revert();
},
() => this._loadingService.stop(),
);
}
}

View File

@ -14,7 +14,7 @@ import {
NestedFilter,
TableColumnConfig,
} from '@iqser/common-ui';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { rolesTranslations } from '../../../../translations/roles-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -96,7 +96,7 @@ export class UserListingScreenComponent extends ListingComponent<User> implement
async toggleActive(user: User) {
this._loadingService.start();
const requestBody = { ...user, roles: user.isActive ? [] : ['RED_USER'] };
await this.userService.updateProfile(requestBody, user.id).toPromise();
await firstValueFrom(this.userService.updateProfile(requestBody, user.id));
await this._loadData();
}
@ -105,7 +105,7 @@ export class UserListingScreenComponent extends ListingComponent<User> implement
}
private async _loadData() {
await this.userService.loadAll().toPromise();
await firstValueFrom(this.userService.loadAll());
this._computeStats();
this._loadingService.stop();
}

View File

@ -11,6 +11,7 @@ import { stampPDFPage } from '@utils/page-stamper';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { WatermarkService } from '@shared/services/watermark.service';
import { firstValueFrom } from 'rxjs';
export const DEFAULT_WATERMARK: IWatermark = {
text: null,
@ -80,7 +81,7 @@ export class WatermarkScreenComponent implements OnInit {
? this._watermarkService.saveWatermark(watermark, dossierTemplateId)
: this._watermarkService.deleteWatermark(dossierTemplateId);
observable.toPromise().then(
firstValueFrom(observable).then(
() => {
this._loadWatermark();
this._toaster.success(

View File

@ -7,6 +7,7 @@ import { UserService } from '@services/user.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { HttpStatusCode } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-dossier-template-actions',
@ -45,11 +46,9 @@ export class DossierTemplateActionsComponent implements OnInit {
this._dialogService.openDialog('confirm', $event, null, async () => {
this._loadingService.start();
await this._dossierTemplatesService
.delete([this.dossierTemplateId])
.toPromise()
await firstValueFrom(this._dossierTemplatesService.delete([this.dossierTemplateId]))
.then(async () => {
await this._dossierTemplatesService.loadAll().toPromise();
await firstValueFrom(this._dossierTemplatesService.loadAll());
await this._appStateService.loadDictionaryData();
await this._router.navigate(['main', 'admin']);
})

View File

@ -5,6 +5,7 @@ import { HttpClientModule } from '@angular/common/http';
import { KeycloakAngularModule, KeycloakOptions, KeycloakService } from 'keycloak-angular';
import { ConfigService } from '@services/config.service';
import { BASE_HREF } from '../../tokens';
import { firstValueFrom } from 'rxjs';
function getKeycloakOptions(configService: ConfigService, baseUrl: string) {
let url: string = configService.values.OAUTH_URL;
@ -36,14 +37,11 @@ function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakServic
export function keycloakInitializer(keycloakService: KeycloakService, configService: ConfigService, baseUrl: string): () => Promise<void> {
return () =>
configService
.loadAppConfig()
.toPromise()
.then(() =>
keycloakService
.init(getKeycloakOptions(configService, baseUrl))
.then(() => configureAutomaticRedirectToLoginScreen(keycloakService)),
);
firstValueFrom(configService.loadAppConfig()).then(() =>
keycloakService
.init(getKeycloakOptions(configService, baseUrl))
.then(() => configureAutomaticRedirectToLoginScreen(keycloakService)),
);
}
@NgModule({

View File

@ -8,6 +8,7 @@ import { BaseDialogComponent, IconButtonTypes, SaveOptions } from '@iqser/common
import { DossiersService } from '@services/entity-services/dossiers.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { ReportTemplateService } from '@services/report-template.service';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './add-dossier-dialog.component.html',
@ -38,27 +39,6 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
this.initialFormValue = this.form.getRawValue();
}
private _getForm(): FormGroup {
return this._formBuilder.group(
{
dossierName: [null, Validators.required],
dossierTemplateId: [null, Validators.required],
downloadFileTypes: [null],
reportTemplateIds: [null],
description: [null],
dueDate: [null],
watermarkEnabled: [true],
watermarkPreviewEnabled: [false],
},
{
validators: control =>
control.value.reportTemplateIds?.length > 0 || control.value.downloadFileTypes?.length > 0
? null
: { downloadPackage: true },
},
);
}
get reportTemplateIdsLength() {
return this.form.controls['reportTemplateIds']?.value?.length || 0;
}
@ -78,7 +58,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId;
async save(options?: SaveOptions) {
const savedDossier = await this._dossiersService.createOrUpdate(this._formToObject()).toPromise();
const savedDossier = await firstValueFrom(this._dossiersService.createOrUpdate(this._formToObject()));
if (savedDossier) {
this._dialogRef.close({ dossier: savedDossier, addMembers: options?.addMembers });
}
@ -90,7 +70,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
if (dossierTemplate) {
this.availableReportTypes =
(await this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId).toPromise()) || [];
(await firstValueFrom(this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId))) || [];
// update dropdown values
this.form.patchValue(
{
@ -111,6 +91,27 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
}
}
private _getForm(): FormGroup {
return this._formBuilder.group(
{
dossierName: [null, Validators.required],
dossierTemplateId: [null, Validators.required],
downloadFileTypes: [null],
reportTemplateIds: [null],
description: [null],
dueDate: [null],
watermarkEnabled: [true],
watermarkPreviewEnabled: [false],
},
{
validators: control =>
control.value.reportTemplateIds?.length > 0 || control.value.downloadFileTypes?.length > 0
? null
: { downloadPackage: true },
},
);
}
private _getDossierTemplates() {
this.dossierTemplates = this._dossierTemplatesService.all
.filter(r => {

View File

@ -8,6 +8,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FilesService } from '@services/entity-services/files.service';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { PermissionsService } from '@services/permissions.service';
import { firstValueFrom } from 'rxjs';
class DialogData {
mode: 'approver' | 'reviewer';
@ -101,28 +102,28 @@ export class AssignReviewerApproverDialogComponent {
this._loadingService.start();
try {
if (!this.selectedUser) {
await this._filesService
.setUnassigned(
await firstValueFrom(
this._filesService.setUnassigned(
this.data.files.map(f => f.fileId),
this.dossier.id,
)
.toPromise();
),
);
} else if (this.data.mode === 'reviewer') {
await this._filesService
.setReviewerFor(
await firstValueFrom(
this._filesService.setReviewerFor(
this.data.files.map(f => f.fileId),
this.dossier.id,
this.selectedUser,
)
.toPromise();
),
);
} else {
await this._filesService
.setUnderApprovalFor(
await firstValueFrom(
this._filesService.setUnderApprovalFor(
this.data.files.map(f => f.fileId),
this.dossier.id,
this.selectedUser,
)
.toPromise();
),
);
}
} catch (error) {
this._toaster.error(_('error.http.generic'), { params: error });

View File

@ -7,6 +7,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dossier } from '@red/domain';
import { BaseDialogComponent } from '@iqser/common-ui';
import { firstValueFrom } from 'rxjs';
export interface LegalBasisOption {
label?: string;
@ -40,7 +41,7 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
async ngOnInit() {
super.ngOnInit();
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
this.legalOptions = data
.map<LegalBasisOption>(lbm => ({
@ -56,6 +57,15 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
this.initialFormValue = this.form.getRawValue();
}
save() {
this._dialogRef.close({
legalBasis: this.form.get('reason').value.legalBasis,
section: this.form.get('section').value,
comment: this.form.get('comment').value,
value: this.form.get('classification').value,
});
}
private _getForm(): FormGroup {
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
return this._formBuilder.group({
@ -65,13 +75,4 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
section: [this._data.annotations[0].section],
});
}
save() {
this._dialogRef.close({
legalBasis: this.form.get('reason').value.legalBasis,
section: this.form.get('section').value,
comment: this.form.get('comment').value,
value: this.form.get('classification').value,
});
}
}

View File

@ -6,6 +6,7 @@ import { FileAttributesService } from '@services/entity-services/file-attributes
import { DossiersService } from '@services/entity-services/dossiers.service';
import { FilesService } from '@services/entity-services/files.service';
import { BaseDialogComponent } from '@iqser/common-ui';
import { firstValueFrom } from 'rxjs';
@Component({
templateUrl: './document-info-dialog.component.html',
@ -33,7 +34,7 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
async ngOnInit() {
super.ngOnInit();
this.attributes = (
await this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId).toPromise()
await firstValueFrom(this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId))
).fileAttributeConfigs.filter(attr => attr.editable);
this.form = this._getForm();
this.initialFormValue = this.form.getRawValue();
@ -44,7 +45,7 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
...this.data.fileAttributes?.attributeIdToValue,
...this.form.getRawValue(),
};
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId).toPromise();
await firstValueFrom(this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId));
this._filesService.reload(this.data.dossierId, this.data.fileId);
this._dialogRef.close(true);
}

View File

@ -7,6 +7,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import * as moment from 'moment';
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-edit-dossier-attributes',
@ -72,7 +73,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
: this.currentAttrValue(attr),
}));
try {
await this._dossierAttributesService.setAttributes(this.dossier, dossierAttributeList).toPromise();
await firstValueFrom(this._dossierAttributesService.setAttributes(this.dossier, dossierAttributeList));
await this._loadAttributes();
return { success: true };
} catch (error) {

View File

@ -16,7 +16,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';
import { ConfigService } from '@services/config.service';
import { getLeftDateTime } from '@utils/functions';
import { Observable, of } from 'rxjs';
import { firstValueFrom, Observable, of } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';
import { FilesService } from '@services/entity-services/files.service';
@ -107,7 +107,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
async ngOnInit() {
this._loadingService.start();
const files = await this._filesService.getDeletedFilesFor(this.dossier.id).toPromise();
const files = await firstValueFrom(this._filesService.getDeletedFilesFor(this.dossier.id));
this.entitiesService.setEntities(this._toListItems(files));
this.sortingService.setSortingOption({
column: 'softDeleted',
@ -119,7 +119,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
revert() {}
save(): EditDossierSaveResult {
return of({ success: true }).toPromise();
return firstValueFrom(of({ success: true }));
}
restore(files = this.listingService.selected) {
@ -130,14 +130,14 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
private async _restore(files: FileListItem[]): Promise<void> {
const fileIds = files.map(f => f.fileId);
await this._fileManagementService.restore(fileIds, this.dossier.id).toPromise();
await firstValueFrom(this._fileManagementService.restore(fileIds, this.dossier.id));
this._removeFromList(fileIds);
await this._filesService.loadAll(files[0].dossierId).toPromise();
await firstValueFrom(this._filesService.loadAll(files[0].dossierId));
}
private async _hardDelete(files: FileListItem[]) {
const fileIds = files.map(f => f.fileId);
await this._fileManagementService.hardDelete(this.dossier.id, fileIds).toPromise();
await firstValueFrom(this._fileManagementService.hardDelete(this.dossier.id, fileIds));
this._removeFromList(fileIds);
}

View File

@ -7,7 +7,8 @@ import { DictionaryService } from '@shared/services/dictionary.service';
import { CircleButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FormBuilder, FormGroup } from '@angular/forms';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-edit-dossier-dictionary',
@ -67,9 +68,9 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
this._loadingService.start();
// TODO: Setting the type manually shouldn't be necessary, but for now it fails with status code 500...
const dictionary: IDictionary = { ...this.dossierDictionary, type: 'dossier_redaction', label };
await this._dictionaryService
.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id)
.toPromise();
await firstValueFrom(
this._dictionaryService.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id),
);
await this._updateDossierDictionary();
this._toaster.success(_('edit-dossier-dialog.dictionary.display-name.success'));
} catch (error) {
@ -85,20 +86,20 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
type: 'dossier_redaction',
addToDictionaryAction: this.form.get('addToDictionaryAction').value,
};
await this._dictionaryService
.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id)
.toPromise();
await firstValueFrom(
this._dictionaryService.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id),
);
await this._dictionaryService
.saveEntries(
await firstValueFrom(
this._dictionaryService.saveEntries(
this._dictionaryManager.editor.currentEntries,
this._dictionaryManager.initialEntries,
this.dossier.dossierTemplateId,
'dossier_redaction',
this.dossier.id,
false,
)
.toPromise();
),
);
await this._updateDossierDictionary();
return { success: true };
@ -127,6 +128,8 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
private async _updateDossierDictionary() {
const { dossierId, dossierTemplateId } = this.dossier;
this.dossierDictionary = await this._dictionaryService.getForType(dossierTemplateId, 'dossier_redaction', dossierId).toPromise();
this.dossierDictionary = await firstValueFrom(
this._dictionaryService.getForType(dossierTemplateId, 'dossier_redaction', dossierId),
);
}
}

View File

@ -6,6 +6,7 @@ import { downloadTypesTranslations } from '../../../../../translations/download-
import { DossiersService } from '@services/entity-services/dossiers.service';
import { ReportTemplateService } from '@services/report-template.service';
import { PermissionsService } from '@services/permissions.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-edit-dossier-download-package',
@ -70,7 +71,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
async ngOnInit() {
this.availableReportTypes =
(await this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId).toPromise()) || [];
(await firstValueFrom(this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId))) || [];
this.form = this._getForm();
if (!this._permissionsService.canEditDossier()) {
@ -85,7 +86,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
reportTemplateIds: this.form.get('reportTemplateIds').value,
};
try {
await this._dossiersService.createOrUpdate(dossier).toPromise();
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
return { success: true };
} catch (error) {
return { success: false };

View File

@ -5,7 +5,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
import { Dossier, IDossierRequest } from '@red/domain';
import { AutoUnsubscribe } from '@iqser/common-ui';
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-edit-dossier-team',
@ -77,7 +77,7 @@ export class EditDossierTeamComponent extends AutoUnsubscribe implements EditDos
} as IDossierRequest;
try {
await this._dossiersService.createOrUpdate(dossier).toPromise();
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
return { success: true };
} catch (error) {
return { success: false };

View File

@ -13,6 +13,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-edit-dossier-general-info',
@ -96,7 +97,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
dossierTemplateId: this.form.get('dossierTemplateId').value,
} as IDossierRequest;
try {
await this._dossiersService.createOrUpdate(dossier).toPromise();
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
return { success: true };
} catch (error) {
return { success: false };
@ -118,7 +119,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
},
});
this._dialogService.openDialog('confirm', null, data, async () => {
await this._dossiersService.delete(this.dossier).toPromise();
await firstValueFrom(this._dossiersService.delete(this.dossier));
this._editDossierDialogRef.close();
this._router.navigate(['main', 'dossiers']).then(() => this._notifyDossierDeleted());
});

View File

@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dossier, ILegalBasisChangeRequest } from '@red/domain';
import { firstValueFrom } from 'rxjs';
export interface LegalBasisOption {
label?: string;
@ -47,18 +48,9 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
return this._data.hint;
}
private _getForm(): FormGroup {
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
return this._formBuilder.group({
reason: this._data.hint ? ['Forced Hint'] : [null, Validators.required],
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
});
}
async ngOnInit() {
super.ngOnInit();
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
legalBasis: lbm.reason,
@ -73,6 +65,15 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
this._dialogRef.close(this._createForceRedactionRequest());
}
private _getForm(): FormGroup {
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
return this._formBuilder.group({
reason: this._data.hint ? ['Forced Hint'] : [null, Validators.required],
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
});
}
private _createForceRedactionRequest(): ILegalBasisChangeRequest {
const request: ILegalBasisChangeRequest = {};

View File

@ -11,6 +11,7 @@ import { Dictionary, Dossier, File, IAddRedactionRequest } from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { BaseDialogComponent } from '@iqser/common-ui';
import { DictionaryService } from '@shared/services/dictionary.service';
import { firstValueFrom } from 'rxjs';
export interface LegalBasisOption {
label?: string;
@ -69,36 +70,15 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
return null;
}
private async _getPossibleDictionaries(): Promise<Dictionary[]> {
const possibleDictionaries: Dictionary[] = [];
const dossier = this._dossier;
const dossierDictionary = await this._dictionaryService
.getForType(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId)
.toPromise();
for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) {
const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId);
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
possibleDictionaries.push(dictionaryData);
}
}
if (dossierDictionary.addToDictionaryAction) {
// TODO fix this in the backend
possibleDictionaries.push(new Dictionary({ ...dossierDictionary, type: 'dossier_redaction' }));
}
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
return possibleDictionaries;
get disabled() {
return this.form.invalid;
}
async ngOnInit() {
super.ngOnInit();
this.possibleDictionaries = await this._getPossibleDictionaries();
const data = await this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId).toPromise();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
legalBasis: lbm.reason,
description: lbm.description,
@ -124,6 +104,31 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
);
}
private async _getPossibleDictionaries(): Promise<Dictionary[]> {
const possibleDictionaries: Dictionary[] = [];
const dossier = this._dossier;
const dossierDictionary = await firstValueFrom(
this._dictionaryService.getForType(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId),
);
for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) {
const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId);
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
possibleDictionaries.push(dictionaryData);
}
}
if (dossierDictionary.addToDictionaryAction) {
// TODO fix this in the backend
possibleDictionaries.push(new Dictionary({ ...dossierDictionary, type: 'dossier_redaction' }));
}
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
return possibleDictionaries;
}
private _getForm(): FormGroup {
return this._formBuilder.group({
section: [null],
@ -155,8 +160,4 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
addRedactionRequest.section = this.form.get('section').value;
addRedactionRequest.value = addRedactionRequest.rectangle ? this.form.get('classification').value : addRedactionRequest.value;
}
get disabled() {
return this.form.invalid;
}
}

View File

@ -3,7 +3,7 @@ import { Dossier, DossierAttributeWithValue, DossierStats } from '@red/domain';
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { FilesService } from '@services/entity-services/files.service';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
import { FilesMapService } from '@services/entity-services/files-map.service';
@ -43,7 +43,7 @@ export class DossierDetailsStatsComponent implements OnInit {
openEditDossierDialog(section: string): void {
const data = { dossierId: this.dossier.dossierId, section };
this._dialogService.openDialog('editDossier', null, data, async () => {
await this._filesService.loadAll(this.dossier.dossierId).toPromise();
await firstValueFrom(this._filesService.loadAll(this.dossier.dossierId));
});
}
}

View File

@ -9,7 +9,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { Dossier, DossierAttributeWithValue, DossierStats, IDossierRequest, StatusSorter, User } from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
import { pluck, switchMap } from 'rxjs/operators';
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
@ -73,7 +73,7 @@ export class DossierDetailsComponent {
async assignOwner(user: User | string, dossier: Dossier) {
const owner = typeof user === 'string' ? this._userService.find(user) : user;
const dossierRequest: IDossierRequest = { ...dossier, ownerId: owner.id };
await this.dossiersService.createOrUpdate(dossierRequest).toPromise();
await firstValueFrom(this.dossiersService.createOrUpdate(dossierRequest));
const ownerName = this._userService.getNameForId(owner.id);
const dossierName = dossier.dossierName;

View File

@ -19,6 +19,7 @@ import { map, take } from 'rxjs/operators';
import { saveAsCSV } from '@utils/csv-utils';
import { UserService } from '@services/user.service';
import { ConfigService } from '../../config.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-screen-header',
@ -53,7 +54,7 @@ export class ScreenHeaderComponent implements OnInit {
async reanalyseDossier() {
this._loadingService.start();
try {
await this._reanalysisService.reanalyzeDossier(this.dossier.dossierId, true).toPromise();
await firstValueFrom(this._reanalysisService.reanalyzeDossier(this.dossier.dossierId, true));
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));
} catch (e) {
this._toaster.error(_('dossier-overview.reanalyse-dossier.error'));

View File

@ -8,6 +8,7 @@ import { FileAssignService } from '../../../shared/services/file-assign.service'
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ReanalysisService } from '../../../../../services/reanalysis.service';
import { FileManagementService } from '@services/entity-services/file-management.service';
import { firstValueFrom } from 'rxjs';
@Injectable()
export class BulkActionsService {
@ -28,13 +29,13 @@ export class BulkActionsService {
this._assignFiles(files, 'approver', true);
} else {
this._loadingService.start();
await this._filesService
.setUnderApprovalFor(
await firstValueFrom(
this._filesService.setUnderApprovalFor(
files.map(f => f.id),
dossier.id,
dossier.approverIds[0],
)
.toPromise();
),
);
this._loadingService.stop();
}
}
@ -45,12 +46,12 @@ export class BulkActionsService {
async ocr(files: File[]) {
this._loadingService.start();
await this._reanalysisService
.ocrFiles(
await firstValueFrom(
this._reanalysisService.ocrFiles(
files.map(f => f.fileId),
files[0].dossierId,
)
.toPromise();
),
);
this._loadingService.stop();
}
@ -64,12 +65,12 @@ export class BulkActionsService {
}),
async () => {
this._loadingService.start();
await this._fileManagementService
.delete(
await firstValueFrom(
this._fileManagementService.delete(
files.map(item => item.fileId),
files[0].dossierId,
)
.toPromise();
),
);
this._loadingService.stop();
},
);
@ -78,18 +79,18 @@ export class BulkActionsService {
async reanalyse(files: File[]) {
this._loadingService.start();
const fileIds = files.filter(file => file.analysisRequired).map(file => file.fileId);
await this._reanalysisService.reanalyzeFilesForDossier(fileIds, files[0].dossierId).toPromise();
await firstValueFrom(this._reanalysisService.reanalyzeFilesForDossier(fileIds, files[0].dossierId));
this._loadingService.stop();
}
async backToUnderReview(files: File[]): Promise<void> {
this._loadingService.start();
await this._filesService
.setUnderReviewFor(
await firstValueFrom(
this._filesService.setUnderReviewFor(
files.map(f => f.id),
files[0].dossierId,
)
.toPromise();
),
);
this._loadingService.stop();
}
@ -105,23 +106,23 @@ export class BulkActionsService {
}),
async () => {
this._loadingService.start();
await this._filesService
.setApprovedFor(
await firstValueFrom(
this._filesService.setApprovedFor(
files.map(f => f.id),
files[0].dossierId,
)
.toPromise();
),
);
this._loadingService.stop();
},
);
} else {
this._loadingService.start();
await this._filesService
.setApprovedFor(
await firstValueFrom(
this._filesService.setApprovedFor(
files.map(f => f.id),
files[0].dossierId,
)
.toPromise();
),
);
this._loadingService.stop();
}
}

View File

@ -9,6 +9,7 @@ import { UserPreferenceService } from '@services/user-preference.service';
import { FilesMapService } from '@services/entity-services/files-map.service';
import { ReanalysisService } from '@services/reanalysis.service';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-dossiers-listing-actions',
@ -60,6 +61,6 @@ export class DossiersListingActionsComponent implements OnChanges {
async reanalyseDossier($event: MouseEvent, id: string): Promise<void> {
$event.stopPropagation();
await this._reanalysisService.reanalyzeDossier(id).toPromise();
await firstValueFrom(this._reanalysisService.reanalyzeDossier(id));
}
}

View File

@ -4,10 +4,10 @@ import { ManualAnnotationService } from '../../../../services/manual-annotation.
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { UserService } from '@services/user.service';
import { PermissionsService } from '@services/permissions.service';
import { AutoUnsubscribe, InputWithActionComponent, LoadingService, trackBy } from '@iqser/common-ui';
import { AutoUnsubscribe, InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui';
import { FilesMapService } from '@services/entity-services/files-map.service';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { CommentingService } from '../../services/commenting.service';
import { tap } from 'rxjs/operators';
@ -19,7 +19,7 @@ import { tap } from 'rxjs/operators';
})
export class CommentsComponent extends AutoUnsubscribe implements OnChanges {
@Input() annotation: AnnotationWrapper;
readonly trackBy = trackBy();
readonly trackBy = trackByFactory();
readonly file$: Observable<File>;
@HostBinding('class.hidden') _hidden = true;
@ViewChild(InputWithActionComponent) private readonly _input: InputWithActionComponent;
@ -58,9 +58,9 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges {
return;
}
this._loadingService.start();
const commentId = await this._manualAnnotationService
.addComment(value, this.annotation.id, this._dossierId, this._fileId)
.toPromise();
const commentId = await firstValueFrom(
this._manualAnnotationService.addComment(value, this.annotation.id, this._dossierId, this._fileId),
);
this.annotation.comments.push({
text: value,
id: commentId,
@ -80,7 +80,7 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges {
async deleteComment($event: MouseEvent, comment: IComment): Promise<void> {
$event.stopPropagation();
this._loadingService.start();
await this._manualAnnotationService.deleteComment(comment.id, this.annotation.id, this._dossierId, this._fileId).toPromise();
await firstValueFrom(this._manualAnnotationService.deleteComment(comment.id, this.annotation.id, this._dossierId, this._fileId));
this.annotation.comments.splice(this.annotation.comments.indexOf(comment), 1);
this._changeRef.markForCheck();
this._loadingService.stop();

View File

@ -5,6 +5,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { File, IPageRange } from '@red/domain';
import { ReanalysisService } from '@services/reanalysis.service';
import { ExcludedPagesService } from '../../services/excluded-pages.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-page-exclusion',
@ -57,15 +58,15 @@ export class PageExclusionComponent implements OnChanges {
endPage,
};
});
await this._reanalysisService
.excludePages(
await firstValueFrom(
this._reanalysisService.excludePages(
{
pageRanges: pageRanges,
},
this.file.dossierId,
this.file.fileId,
)
.toPromise();
),
);
this._inputComponent.reset();
} catch (e) {
this._toaster.error(_('file-preview.tabs.exclude-pages.error'));
@ -75,15 +76,15 @@ export class PageExclusionComponent implements OnChanges {
async includePagesRange(range: IPageRange): Promise<void> {
this._loadingService.start();
await this._reanalysisService
.includePages(
await firstValueFrom(
this._reanalysisService.includePages(
{
pageRanges: [range],
},
this.file.dossierId,
this.file.fileId,
)
.toPromise();
),
);
this._inputComponent.reset();
this._loadingService.stop();
}

View File

@ -7,6 +7,7 @@ import { File, IViewedPage } from '@red/domain';
import { AutoUnsubscribe } from '@iqser/common-ui';
import { FilesMapService } from '@services/entity-services/files-map.service';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-page-indicator',
@ -93,7 +94,7 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy
}
private async _markPageRead() {
await this._viewedPagesService.addPage({ page: this.number }, this.file.dossierId, this.file.fileId).toPromise();
await firstValueFrom(this._viewedPagesService.addPage({ page: this.number }, this.file.dossierId, this.file.fileId));
if (this.activePage) {
this.activePage.showAsUnseen = false;
} else {

View File

@ -8,6 +8,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { FilesService } from '@services/entity-services/files.service';
import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-user-management',
@ -88,11 +89,11 @@ export class UserManagementComponent implements OnChanges {
this.loadingService.start();
if (!assigneeId) {
await this.filesService.setUnassigned([fileId], dossierId).toPromise();
await firstValueFrom(this.filesService.setUnassigned([fileId], dossierId));
} else if (file.isNew || file.isUnderReview) {
await this.filesService.setReviewerFor([fileId], dossierId, assigneeId).toPromise();
await firstValueFrom(this.filesService.setReviewerFor([fileId], dossierId, assigneeId));
} else if (file.isUnderApproval) {
await this.filesService.setUnderApprovalFor([fileId], dossierId, assigneeId).toPromise();
await firstValueFrom(this.filesService.setUnderApprovalFor([fileId], dossierId, assigneeId));
}
this.loadingService.stop();

View File

@ -10,6 +10,7 @@ import { environment } from '@environments/environment';
import { IRectangle, ISectionGrid, ISectionRectangle } from '@red/domain';
import { SkippedService } from './skipped.service';
import { firstValueFrom } from 'rxjs';
import Annotation = Core.Annotations.Annotation;
@Injectable()
@ -91,10 +92,9 @@ export class AnnotationDrawService {
await annotationManager.drawAnnotationsFromList(annotations);
if (this._userPreferenceService.areDevFeaturesEnabled) {
const sectionsGrid = await this._redactionLogService
.getSectionGrid(dossierId, fileId)
.toPromise()
.catch(() => ({ rectanglesPerPage: {} }));
const sectionsGrid = await firstValueFrom(this._redactionLogService.getSectionGrid(dossierId, fileId)).catch(() => ({
rectanglesPerPage: {},
}));
await this._drawSections(activeViewer, sectionsGrid, dossierId);
}
}

View File

@ -2,14 +2,12 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
HostBinding,
Input,
OnChanges,
OnDestroy,
OnInit,
Optional,
Output,
ViewChild,
} from '@angular/core';
import { PermissionsService } from '@services/permissions.service';
@ -38,6 +36,7 @@ import { ExcludedPagesService } from '../../../screens/file-preview-screen/servi
import { tap } from 'rxjs/operators';
import { DocumentInfoService } from '../../../screens/file-preview-screen/services/document-info.service';
import { ExpandableFileActionsComponent } from '@shared/components/expandable-file-actions/expandable-file-actions.component';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-file-actions [file] [type]',
@ -273,7 +272,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
this._loadingService.start();
try {
const dossier = this._dossiersService.find(this.file.dossierId);
await this._fileManagementService.delete([this.file.fileId], this.file.dossierId).toPromise();
await firstValueFrom(this._fileManagementService.delete([this.file.fileId], this.file.dossierId));
await this._router.navigate([dossier.routerLink]);
} catch (error) {
this._toaster.error(_('error.http.generic'), { params: error });
@ -300,7 +299,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
if ($event) {
$event.stopPropagation();
}
await this._reanalysisService.reanalyzeFilesForDossier([this.file.fileId], this.file.dossierId, true).toPromise();
await firstValueFrom(this._reanalysisService.reanalyzeFilesForDossier([this.file.fileId], this.file.dossierId, true));
}
private async _setFileUnderApproval($event: MouseEvent) {
@ -311,7 +310,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
private async _ocrFile($event: MouseEvent) {
$event.stopPropagation();
this._loadingService.start();
await this._reanalysisService.ocrFiles([this.file.fileId], this.file.dossierId).toPromise();
await firstValueFrom(this._reanalysisService.ocrFiles([this.file.fileId], this.file.dossierId));
this._loadingService.stop();
}
@ -321,7 +320,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
private async _toggleAnalysis() {
this._loadingService.start();
await this._reanalysisService.toggleAnalysis(this.file.dossierId, this.file.fileId, !this.file.excluded).toPromise();
await firstValueFrom(this._reanalysisService.toggleAnalysis(this.file.dossierId, this.file.fileId, !this.file.excluded));
this._loadingService.stop();
}
@ -364,7 +363,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
private async _setFileApproved() {
this._loadingService.start();
await this._filesService.setApprovedFor([this.file.id], this.file.dossierId).toPromise();
await firstValueFrom(this._filesService.setApprovedFor([this.file.id], this.file.dossierId));
this._loadingService.stop();
}
}

View File

@ -6,7 +6,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FilesService } from '@services/entity-services/files.service';
import { ConfirmationDialogInput, LoadingService, Toaster } from '@iqser/common-ui';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
@Injectable()
@ -29,14 +29,12 @@ export class FileAssignService {
question: _('confirmation-dialog.assign-file-to-me.question'),
});
this._dialogService.openDialog('confirm', null, data, () => {
this._assignReviewerToCurrentUser(files)
.toPromise()
firstValueFrom(this._assignReviewerToCurrentUser(files))
.then(() => resolve())
.catch(() => reject());
});
} else {
this._assignReviewerToCurrentUser(files)
.toPromise()
firstValueFrom(this._assignReviewerToCurrentUser(files))
.then(() => resolve())
.catch(() => reject());
}
@ -83,28 +81,28 @@ export class FileAssignService {
this._loadingService.start();
try {
if (!userId) {
await this._filesService
.setUnassigned(
await firstValueFrom(
this._filesService.setUnassigned(
files.map(f => f.fileId),
files[0].dossierId,
)
.toPromise();
),
);
} else if (mode === 'reviewer') {
await this._filesService
.setReviewerFor(
await firstValueFrom(
this._filesService.setReviewerFor(
files.map(f => f.fileId),
files[0].dossierId,
userId,
)
.toPromise();
),
);
} else {
await this._filesService
.setUnderApprovalFor(
await firstValueFrom(
this._filesService.setUnderApprovalFor(
files.map(f => f.fileId),
files[0].dossierId,
userId,
)
.toPromise();
),
);
}
} catch (error) {
this._toaster.error(_('error.http.generic'), { params: error });

View File

@ -4,6 +4,7 @@ import { File } from '@red/domain';
import { FileDownloadService } from '@upload-download/services/file-download.service';
import { CircleButtonType, CircleButtonTypes, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { firstValueFrom } from 'rxjs';
export type MenuState = 'OPEN' | 'CLOSED';
@ -38,7 +39,7 @@ export class FileDownloadBtnComponent implements OnChanges {
$event.stopPropagation();
const dossierId = this.files[0].dossierId;
const filesIds = this.files.map(f => f.fileId);
await this._fileDownloadService.downloadFiles(filesIds, dossierId).toPromise();
await firstValueFrom(this._fileDownloadService.downloadFiles(filesIds, dossierId));
this._toaster.info(_('download-status.queued'));
}
}

View File

@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core';
import { Debounce, IconButtonTypes, List } from '@iqser/common-ui';
import { Observable, of } from 'rxjs';
import { firstValueFrom, Observable, of } from 'rxjs';
import { catchError, map, take, tap } from 'rxjs/operators';
import { Dictionary, Dossier, DossierTemplate } from '@red/domain';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -110,20 +110,18 @@ export class DictionaryManagerComponent implements OnChanges {
return;
}
this._dictionaryService
.getForType(this._dictionary.dossierTemplateId, this._dictionary.type)
.pipe(
firstValueFrom(
this._dictionaryService.getForType(this._dictionary.dossierTemplateId, this._dictionary.type).pipe(
tap(values => (this._dictionary.entries = [...values.entries] ?? [])),
catchError(() => {
this._dictionary.entries = [];
return of({});
}),
)
.toPromise()
.then(() => {
this.diffEditorText = this._toString([...this._dictionary.entries]);
this.showDiffEditor = true;
});
),
).then(() => {
this.diffEditorText = this._toString([...this._dictionary.entries]);
this.showDiffEditor = true;
});
}
get _dictionaries() {

View File

@ -4,6 +4,7 @@ import { CircleButtonType, IqserTooltipPosition, Toaster } from '@iqser/common-u
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FileDownloadService } from '@upload-download/services/file-download.service';
import { PermissionsService } from '@services/permissions.service';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-expandable-file-actions',
@ -58,7 +59,7 @@ export class ExpandableFileActionsComponent implements OnChanges {
$event.stopPropagation();
const dossierId = files[0].dossierId;
const filesIds = files.map(f => f.fileId);
await this._fileDownloadService.downloadFiles(filesIds, dossierId).toPromise();
await firstValueFrom(this._fileDownloadService.downloadFiles(filesIds, dossierId));
this._toaster.info(_('download-status.queued'));
}
}

View File

@ -1,6 +1,6 @@
import { Injectable, Injector } from '@angular/core';
import { Dossier, DossierAttributeConfig, DossierAttributeWithValue, IDossierAttribute, IDossierAttributeConfig } from '@red/domain';
import { Observable } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { EntitiesService, List, mapEach, RequiredParam, Validate } from '@iqser/common-ui';
import { map, tap } from 'rxjs/operators';
@ -14,8 +14,8 @@ export class DossierAttributesService extends EntitiesService<DossierAttributeCo
}
async getWithValues(dossier: Dossier): Promise<DossierAttributeWithValue[]> {
const attributes = await this.getAttributes(dossier.id).toPromise();
const attributesConfig = await this.getConfig(dossier.dossierTemplateId).toPromise();
const attributes = await firstValueFrom(this.getAttributes(dossier.id));
const attributesConfig = await firstValueFrom(this.getConfig(dossier.dossierTemplateId));
return attributesConfig.map(config => ({
...config,

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { OverwriteFilesDialogComponent } from '../dialogs/overwrite-files-dialog/overwrite-files-dialog.component';
import { firstValueFrom } from 'rxjs';
const dialogConfig = {
width: '662px',
@ -18,9 +19,6 @@ export class UploadDownloadDialogService {
data: filename,
});
return ref
.afterClosed()
.toPromise()
.then(res => res || { cancel: true });
return firstValueFrom(ref.afterClosed()).then(res => res || { cancel: true });
}
}

View File

@ -2,7 +2,7 @@ import { Injectable, Injector } from '@angular/core';
import { EntitiesService, List, mapEach, QueryParam, RequiredParam, shareLast, Toaster, Validate } from '@iqser/common-ui';
import { Dossier, IDossier, IDossierRequest } from '@red/domain';
import { catchError, filter, map, mapTo, switchMap, tap } from 'rxjs/operators';
import { combineLatest, Observable, of, Subject, throwError, timer } from 'rxjs';
import { combineLatest, firstValueFrom, Observable, of, Subject, throwError, timer } from 'rxjs';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
@ -83,7 +83,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
}
getDeleted(): Promise<IDossier[]> {
return this.getAll('deleted-dossiers').toPromise();
return firstValueFrom(this.getAll('deleted-dossiers'));
}
delete(dossier: Dossier): Observable<unknown> {
@ -99,13 +99,13 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
@Validate()
restore(@RequiredParam() dossierIds: List): Promise<unknown> {
return this._post(dossierIds, 'deleted-dossiers/restore').toPromise();
return firstValueFrom(this._post(dossierIds, 'deleted-dossiers/restore'));
}
@Validate()
hardDelete(@RequiredParam() dossierIds: List): Promise<unknown> {
const body = dossierIds.map<QueryParam>(id => ({ key: 'dossierId', value: id }));
return super.delete(body, 'deleted-dossiers/hard-delete', body).toPromise();
return firstValueFrom(super.delete(body, 'deleted-dossiers/hard-delete', body));
}
private _emitFileChanges(changes: ChangesDetails): void {

View File

@ -1,5 +1,6 @@
import { Injectable, Injector } from '@angular/core';
import { GenericService, List, RequiredParam, Validate } from '@iqser/common-ui';
import { firstValueFrom } from 'rxjs';
type UserAttributes = Record<string, List>;
@ -36,7 +37,7 @@ export class UserPreferenceService extends GenericService<UserAttributes> {
async saveLastOpenedFileForDossier(dossierId: string, fileId: string): Promise<void> {
const key = `${KEYS.dossierRecent}-${dossierId}`;
this.userAttributes[key] = [fileId];
await this.savePreferences([fileId], key).toPromise();
await firstValueFrom(this.savePreferences([fileId], key));
}
getLanguage(): string {
@ -47,7 +48,7 @@ export class UserPreferenceService extends GenericService<UserAttributes> {
async saveLanguage(language: string): Promise<void> {
const key = KEYS.language;
this.userAttributes[key] = [language];
await this.savePreferences([language], key).toPromise();
await firstValueFrom(this.savePreferences([language], key));
}
getFilePreviewTooltipsPreference(): boolean {
@ -60,7 +61,7 @@ export class UserPreferenceService extends GenericService<UserAttributes> {
const currentValue = this.getFilePreviewTooltipsPreference();
const nextValue = [(!currentValue).toString()];
this.userAttributes[key] = nextValue;
await this.savePreferences(nextValue, key).toPromise();
await firstValueFrom(this.savePreferences(nextValue, key));
}
toggleDevFeatures(): void {
@ -69,7 +70,7 @@ export class UserPreferenceService extends GenericService<UserAttributes> {
}
async reload(): Promise<void> {
const attributes = await this.getAll<UserAttributes>().toPromise();
const attributes = await firstValueFrom(this.getAll<UserAttributes>());
this._userAttributes = attributes ?? {};
}

View File

@ -3,6 +3,7 @@ import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
import { AppStateService } from './app-state.service';
import { UserService } from '@services/user.service';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { firstValueFrom } from 'rxjs';
@Injectable({
providedIn: 'root',
@ -17,11 +18,11 @@ export class AppStateGuard implements CanActivate {
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
if (this._userService.currentUser.isUserAdmin) {
await this._userService.loadAll().toPromise();
await firstValueFrom(this._userService.loadAll());
}
if (this._userService.currentUser.isUser || this._userService.currentUser.isAdmin) {
await this._userService.loadAll().toPromise();
await firstValueFrom(this._userService.loadAll());
await this._dossierTemplatesService.loadAllIfEmpty();
await this._appStateService.loadDictionaryDataIfNecessary();
}

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Dictionary, DossierTemplate, IColors } from '@red/domain';
import { Router } from '@angular/router';
import { forkJoin, Observable, of } from 'rxjs';
import { firstValueFrom, forkJoin, Observable, of } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { FALLBACK_COLOR, hexToRgb } from '@utils/functions';
import { DictionaryService } from '@shared/services/dictionary.service';
@ -79,9 +79,9 @@ export class AppStateService {
}
async refreshDossierTemplate(dossierTemplateId: string) {
const dossierTemplate = await this._dossierTemplatesService.get(dossierTemplateId).toPromise();
const dossierTemplate = await firstValueFrom(this._dossierTemplatesService.get(dossierTemplateId));
await this._fileAttributesService.getFileAttributesConfig(dossierTemplateId).toPromise();
await firstValueFrom(this._fileAttributesService.getFileAttributesConfig(dossierTemplateId));
const newDossierTemplate = new DossierTemplate(dossierTemplate);
this._dossierTemplatesService.replace(newDossierTemplate);
@ -102,7 +102,7 @@ export class AppStateService {
for (const dossierTemplate of this.dossierTemplates) {
observables.push(this._getDictionaryDataForDossierTemplate$(dossierTemplate.dossierTemplateId));
}
const result = await forkJoin(observables).toPromise();
const result = await firstValueFrom(forkJoin(observables));
const dictionaryData = {};
for (let i = 0; i < this.dossierTemplates.length; i++) {
@ -113,7 +113,7 @@ export class AppStateService {
}
async refreshDossierTemplateDictionaryData(dossierTemplateId: string) {
this._dictionaryData[dossierTemplateId] = await this._getDictionaryDataForDossierTemplate$(dossierTemplateId).toPromise();
this._dictionaryData[dossierTemplateId] = await firstValueFrom(this._getDictionaryDataForDossierTemplate$(dossierTemplateId));
}
loadColors(dossierTemplateId: string) {

View File

@ -1,7 +1,7 @@
import { catchError, filter, mergeMap, switchMap, take, tap } from 'rxjs/operators';
import { ConfigService } from '@services/config.service';
import { Title } from '@angular/platform-browser';
import { from, of, throwError } from 'rxjs';
import { firstValueFrom, from, of, throwError } from 'rxjs';
import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
import { GeneralSettingsService } from '@services/general-settings.service';
import { LanguageService } from '@i18n/language.service';
@ -18,8 +18,8 @@ export function configurationInitializer(
userPreferenceService: UserPreferenceService,
) {
return () =>
keycloakService.keycloakEvents$
.pipe(
firstValueFrom(
keycloakService.keycloakEvents$.pipe(
filter(event => event.type === KeycloakEventType.OnReady),
switchMap(() => from(keycloakService.isLoggedIn())),
switchMap(loggedIn => (!loggedIn ? throwError('Not Logged In') : of({}))),
@ -34,6 +34,6 @@ export function configurationInitializer(
}),
tap(() => languageService.chooseAndSetInitialLanguage()),
take(1),
)
.toPromise();
),
);
}

@ -1 +1 @@
Subproject commit 650c16b80387943f1de0efa876215559f56d123b
Subproject commit df28e3578b9e8aa2daae87dd9ddb9e851ba8cf34