From c87bcb4db3b648365874b671667997c50d52a65e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Thu, 5 Aug 2021 21:26:42 +0300 Subject: [PATCH 1/8] mode sorting to common-lib --- .../downloads-list-screen.component.ts | 4 +- .../active-fields-listing.component.ts | 4 +- ...-attributes-csv-import-dialog.component.ts | 3 +- .../default-colors-screen.component.ts | 4 +- .../dictionary-listing-screen.component.ts | 4 +- ...ier-attributes-listing-screen.component.ts | 4 +- ...sier-templates-listing-screen.component.ts | 4 +- ...ile-attributes-listing-screen.component.ts | 4 +- .../screens/trash/trash-screen.component.ts | 6 +- .../user-listing-screen.component.ts | 4 +- .../dossier-listing-screen.component.ts | 3 +- .../dossier-overview-screen.component.ts | 4 +- .../search-screen/search-screen.component.ts | 4 +- .../shared/base/base-listing.component.ts | 4 +- .../table-col-name.component.ts | 2 +- .../app/modules/shared/pipes/sort-by.pipe.ts | 4 +- .../src/app/services/sorting.service.ts | 63 ------------------- libs/common-ui | 2 +- package.json | 1 + yarn.lock | 5 ++ 20 files changed, 25 insertions(+), 108 deletions(-) delete mode 100644 apps/red-ui/src/app/services/sorting.service.ts diff --git a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts index 673c7d0fa..ec5d9f628 100644 --- a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts +++ b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts @@ -3,13 +3,11 @@ import { FileDownloadService } from '@upload-download/services/file-download.ser import { DownloadStatusWrapper } from '@upload-download/model/download-status.wrapper'; import { DownloadControllerService } from '@redaction/red-ui-http'; import { BaseListingComponent } from '@shared/base/base-listing.component'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; -import { CircleButtonTypes } from '@iqser/common-ui'; @Component({ selector: 'redaction-downloads-list-screen', diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts index f45e4cf77..36951f4b0 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts @@ -1,13 +1,11 @@ import { Component, EventEmitter, Injector, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { Field } from '../file-attributes-csv-import-dialog.component'; import { FileAttributeConfig } from '@redaction/red-ui-http'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { fileAttributeTypesTranslations } from '../../../translations/file-attribute-types-translations'; -import { CircleButtonTypes } from '@iqser/common-ui'; @Component({ selector: 'redaction-active-fields-listing', diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts index ae2aa660f..1c1001219 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts @@ -8,10 +8,9 @@ import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; import { Toaster } from '@services/toaster.service'; import { TranslateService } from '@ngx-translate/core'; -import { FilterService } from '@iqser/common-ui'; +import { FilterService, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts index c6dc1bd5f..c9a043270 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts @@ -5,14 +5,12 @@ import { ActivatedRoute } from '@angular/router'; import { PermissionsService } from '@services/permissions.service'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { DefaultColorType } from '@models/default-color-key.model'; -import { SortingService } from '@services/sorting.service'; import { defaultColorsTranslations } from '../../translations/default-colors-translations'; -import { CircleButtonTypes } from '@iqser/common-ui'; @Component({ templateUrl: './default-colors-screen.component.html', diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts index 6d7059a0e..9de2315c1 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts @@ -9,13 +9,11 @@ import { ActivatedRoute } from '@angular/router'; import { TypeValueWrapper } from '@models/file/type-value.wrapper'; import { TranslateService } from '@ngx-translate/core'; import { LoadingService } from '@services/loading.service'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { AdminDialogService } from '../../services/admin-dialog.service'; -import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; const toChartConfig = (dict: TypeValueWrapper): DoughnutChartConfig => ({ value: dict.entries?.length ?? 0, diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts index 84b0a775b..deadcb650 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts @@ -5,14 +5,12 @@ import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { SortingService } from '@services/sorting.service'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; import { PermissionsService } from '@services/permissions.service'; import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service'; import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations'; -import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; @Component({ templateUrl: './dossier-attributes-listing-screen.component.html', diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts index 81159eb85..e96584882 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts @@ -6,12 +6,10 @@ import { AdminDialogService } from '../../services/admin-dialog.service'; import { DossierTemplateModelWrapper } from '@models/file/dossier-template-model.wrapper'; import { LoadingService } from '@services/loading.service'; import { DossierTemplateControllerService } from '@redaction/red-ui-http'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; -import { SortingService } from '@services/sorting.service'; -import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; @Component({ templateUrl: './dossier-templates-listing-screen.component.html', diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts index 94ccfe2dd..9b28c5299 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts @@ -5,13 +5,11 @@ import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { fileAttributeTypesTranslations } from '../../translations/file-attribute-types-translations'; -import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; @Component({ templateUrl: './file-attributes-listing-screen.component.html', diff --git a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts index 0231d0d66..11d8cb85f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts @@ -4,15 +4,13 @@ import { Dossier } from '@redaction/red-ui-http'; import { LoadingService } from '@services/loading.service'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import * as moment from 'moment'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { DossiersService } from '../../../dossier/services/dossiers.service'; -import { CircleButtonTypes } from '@iqser/common-ui'; import { AdminDialogService } from '../../services/admin-dialog.service'; -import { ConfirmationDialogInput, TitleColors } from '../../../shared/dialogs/confirmation-dialog/confirmation-dialog.component'; +import { ConfirmationDialogInput, TitleColors } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; const HOURS_IN_A_DAY = 24; diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts index 366af994d..488ab50d6 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts @@ -8,15 +8,13 @@ import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/si import { TranslateChartService } from '@services/translate-chart.service'; import { LoadingService } from '@services/loading.service'; import { InitialsAvatarComponent } from '@shared/components/initials-avatar/initials-avatar.component'; -import { FilterService } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { rolesTranslations } from '../../../../translations/roles-translations'; -import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; @Component({ templateUrl: './user-listing-screen.component.html', diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts index 7d0c6e637..1c02d2f98 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts @@ -16,11 +16,10 @@ import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { UserPreferenceService } from '@services/user-preference.service'; import { ButtonConfig } from '@shared/components/page-header/models/button-config.model'; -import { FilterService, NestedFilter } from '@iqser/common-ui'; +import { FilterService, NestedFilter, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; -import { SortingService } from '@services/sorting.service'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; import { workloadTranslations } from '../../translations/workload-translations'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index ceafa3721..e358ba1de 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -21,10 +21,9 @@ import { DossierWrapper } from '@state/model/dossier.wrapper'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import { ActionConfig } from '@shared/components/page-header/models/action-config.model'; -import { NestedFilter, FilterService, keyChecker } from '@iqser/common-ui'; +import { CircleButtonTypes, FilterService, keyChecker, NestedFilter, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { LoadingService } from '@services/loading.service'; import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service'; @@ -33,7 +32,6 @@ import { UserPreferenceService } from '@services/user-preference.service'; import { workloadTranslations } from '../../translations/workload-translations'; import { fileStatusTranslations } from '../../translations/file-status-translations'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { CircleButtonTypes } from '@iqser/common-ui'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; import { annotationFilterChecker } from '@shared/components/filters/popup-filter/utils/filter-utils'; diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts index d9564d3a3..20e835538 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts @@ -5,17 +5,15 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { debounceTime, map, skip, switchMap, tap } from 'rxjs/operators'; import { ActivatedRoute, Router } from '@angular/router'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; -import { FilterService } from '@iqser/common-ui'; +import { FilterService, keyChecker, SortingService } from '@iqser/common-ui'; import { SearchService } from '@shared/services/search.service'; import { ScreenStateService } from '@shared/services/screen-state.service'; -import { SortingService } from '@services/sorting.service'; import { AppStateService } from '@state/app-state.service'; import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { LoadingService } from '@services/loading.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { fileStatusTranslations } from '../../translations/file-status-translations'; import { SearchPositions } from '@shared/components/page-header/models/search-positions.type'; -import { keyChecker } from '@iqser/common-ui'; import { DossierWrapper } from '@state/model/dossier.wrapper'; import { TranslateService } from '@ngx-translate/core'; diff --git a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts index 411655ed7..c667365b1 100644 --- a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts +++ b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts @@ -1,13 +1,11 @@ import { Component, Injector, OnDestroy, ViewChild } from '@angular/core'; -import { SortingOrders, SortingService } from '@services/sorting.service'; +import { AutoUnsubscribeComponent, FilterService, SortingOrders, SortingService } from '@iqser/common-ui'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { SearchService } from '../services/search.service'; import { ScreenStateService } from '../services/screen-state.service'; import { combineLatest, Observable } from 'rxjs'; -import { AutoUnsubscribeComponent } from '@iqser/common-ui'; import { distinctUntilChanged, map, switchMap } from 'rxjs/operators'; import { PermissionsService } from '@services/permissions.service'; -import { FilterService } from '@iqser/common-ui'; @Component({ template: '' }) export abstract class BaseListingComponent extends AutoUnsubscribeComponent implements OnDestroy { diff --git a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts index f3dd88176..2dbe2d863 100644 --- a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts @@ -1,5 +1,5 @@ import { Component, Input, Optional } from '@angular/core'; -import { SortingService } from '@services/sorting.service'; +import { SortingService } from '@iqser/common-ui'; export interface TableColConfig { readonly column?: string; diff --git a/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts b/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts index bb2ade371..974299f02 100644 --- a/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts +++ b/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts @@ -1,11 +1,11 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { SortingService } from '@services/sorting.service'; +import { SortingOrder, SortingService } from '@iqser/common-ui'; @Pipe({ name: 'sortBy' }) export class SortByPipe implements PipeTransform { constructor(private readonly _sortingService: SortingService) {} - transform(value: T[], order = '', column: string = ''): T[] { + transform(value: T[], order: SortingOrder, column: string): T[] { return this._sortingService.sort(value, order, column); } } diff --git a/apps/red-ui/src/app/services/sorting.service.ts b/apps/red-ui/src/app/services/sorting.service.ts deleted file mode 100644 index 4b5fa976e..000000000 --- a/apps/red-ui/src/app/services/sorting.service.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Injectable } from '@angular/core'; -import { orderBy } from 'lodash'; -import { BehaviorSubject } from 'rxjs'; - -export const SortingOrders = { - asc: 'asc', - desc: 'desc' -} as const; - -export type SortingOrder = keyof typeof SortingOrders; - -export interface SortingOption { - readonly order: SortingOrder; - readonly column: string; -} - -@Injectable({ - providedIn: 'root' -}) -export class SortingService { - private readonly _sortingOption$ = new BehaviorSubject(null); - readonly sortingOption$ = this._sortingOption$.asObservable(); - - get sortingOption(): SortingOption { - return this._sortingOption$.getValue(); - } - - setSortingOption(value: SortingOption): void { - this._sortingOption$.next(value); - } - - sort(values: T[], order?: string, column?: string): T[] { - if (!values || !order) { - return values; - } // no array - if (!column) { - if (order === SortingOrders.asc) { - return values.sort(); - } else { - return values.sort().reverse(); - } - } // sort 1d array - if (values.length <= 1) { - return values; - } // array with only one item - return orderBy(values, [column], [order]); - } - - defaultSort(values: T[]) { - return this.sort(values, this.sortingOption?.order, this.sortingOption?.column); - } - - toggleSort(column: string) { - if (this.sortingOption.column === column) { - this._sortingOption$.next({ - column, - order: this.sortingOption.order === SortingOrders.asc ? SortingOrders.desc : SortingOrders.asc - }); - } else { - this._sortingOption$.next({ column, order: SortingOrders.asc }); - } - } -} diff --git a/libs/common-ui b/libs/common-ui index 3f9915434..98ae1d569 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 3f9915434d96fc93a41b7b448826e1ba6ea85839 +Subproject commit 98ae1d5698a838ed1e3febf0b30dfa81f44b2c16 diff --git a/package.json b/package.json index 3e44ad9dd..b6809138a 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "@nrwl/workspace": "12.3.6", "@types/cypress": "^1.1.3", "@types/jest": "26.0.23", + "@types/lodash": "^4.14.172", "@types/node": "15.12.2", "@typescript-eslint/eslint-plugin": "4.26.1", "@typescript-eslint/parser": "4.26.1", diff --git a/yarn.lock b/yarn.lock index e71c35272..fde77360b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3178,6 +3178,11 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/lodash@^4.14.172": + version "4.14.172" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.172.tgz#aad774c28e7bfd7a67de25408e03ee5a8c3d028a" + integrity sha512-/BHF5HAx3em7/KkzVKm3LrsD6HZAXuXO1AJZQ3cRRBZj4oHZDviWPYu0aEplAqDFNHZPW6d3G7KN+ONcCCC7pw== + "@types/minimatch@*", "@types/minimatch@^3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" From 2cb86ab702a5dbe1e17550dda013bf17bb7d2f3e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 6 Aug 2021 03:43:49 +0300 Subject: [PATCH 2/8] move sort and humanize pipe --- .../add-edit-dictionary-dialog.component.ts | 2 +- .../remove-annotations-dialog.component.ts | 4 +-- .../app/modules/shared/pipes/humanize.pipe.ts | 11 ------- .../app/modules/shared/pipes/sort-by.pipe.ts | 11 ------- .../src/app/modules/shared/shared.module.ts | 7 ++-- .../red-ui/src/app/state/app-state.service.ts | 3 +- apps/red-ui/src/app/utils/functions.ts | 33 +------------------ package.json | 2 +- 8 files changed, 9 insertions(+), 64 deletions(-) delete mode 100644 apps/red-ui/src/app/modules/shared/pipes/humanize.pipe.ts delete mode 100644 apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts index 75577153c..88ce6e0e5 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts @@ -6,8 +6,8 @@ import { Observable } from 'rxjs'; import { Toaster } from '@services/toaster.service'; import { TranslateService } from '@ngx-translate/core'; import { TypeValueWrapper } from '@models/file/type-value.wrapper'; -import { humanize } from '../../../../utils/functions'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { humanize } from '@iqser/common-ui'; @Component({ selector: 'redaction-add-edit-dictionary-dialog', diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.ts index 2c7039e83..2a9966164 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.ts @@ -2,9 +2,9 @@ import { Component, Inject } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { TranslateService } from '@ngx-translate/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { humanize } from '../../../../utils/functions'; -import { PermissionsService } from '../../../../services/permissions.service'; +import { PermissionsService } from '@services/permissions.service'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { humanize } from '@iqser/common-ui'; export interface RemoveAnnotationsDialogInput { annotationsToRemove: AnnotationWrapper[]; diff --git a/apps/red-ui/src/app/modules/shared/pipes/humanize.pipe.ts b/apps/red-ui/src/app/modules/shared/pipes/humanize.pipe.ts deleted file mode 100644 index 1d9b329bf..000000000 --- a/apps/red-ui/src/app/modules/shared/pipes/humanize.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { humanize } from '@utils/functions'; - -@Pipe({ - name: 'humanize' -}) -export class HumanizePipe implements PipeTransform { - transform(item: string, lowercase: boolean = false): any { - return humanize(item, lowercase); - } -} diff --git a/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts b/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts deleted file mode 100644 index 974299f02..000000000 --- a/apps/red-ui/src/app/modules/shared/pipes/sort-by.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { SortingOrder, SortingService } from '@iqser/common-ui'; - -@Pipe({ name: 'sortBy' }) -export class SortByPipe implements PipeTransform { - constructor(private readonly _sortingService: SortingService) {} - - transform(value: T[], order: SortingOrder, column: string): T[] { - return this._sortingService.sort(value, order, column); - } -} diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts index 4062c0c0f..ff6820f6c 100644 --- a/apps/red-ui/src/app/modules/shared/shared.module.ts +++ b/apps/red-ui/src/app/modules/shared/shared.module.ts @@ -14,14 +14,13 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AnnotationIconComponent } from './components/annotation-icon/annotation-icon.component'; import { SimpleDoughnutChartComponent } from './components/simple-doughnut-chart/simple-doughnut-chart.component'; import { StatusBarComponent } from './components/status-bar/status-bar.component'; -import { HumanizePipe } from './pipes/humanize.pipe'; import { SyncWidthDirective } from './directives/sync-width.directive'; import { HasScrollbarDirective } from './directives/has-scrollbar.directive'; import { DictionaryAnnotationIconComponent } from './components/dictionary-annotation-icon/dictionary-annotation-icon.component'; import { HiddenActionComponent } from './components/hidden-action/hidden-action.component'; import { ConfirmationDialogComponent } from './dialogs/confirmation-dialog/confirmation-dialog.component'; import { EmptyStateComponent } from './components/empty-state/empty-state.component'; -import { SortByPipe } from './pipes/sort-by.pipe'; +import { CommonUiModule } from '@iqser/common-ui'; import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core'; import { MomentDateAdapter } from '@angular/material-moment-adapter'; import { SelectComponent } from './components/select/select.component'; @@ -36,7 +35,6 @@ import { InputWithActionComponent } from '@shared/components/input-with-action/i import { PageHeaderComponent } from './components/page-header/page-header.component'; import { DatePipe } from '@shared/pipes/date.pipe'; import { TableHeaderComponent } from './components/table-header/table-header.component'; -import { CommonUiModule } from '@iqser/common-ui'; const buttons = [FileDownloadBtnComponent, UserButtonComponent]; @@ -54,7 +52,6 @@ const components = [ PopupFilterComponent, ConfirmationDialogComponent, EmptyStateComponent, - SortByPipe, SelectComponent, SideNavComponent, DictionaryManagerComponent, @@ -65,7 +62,7 @@ const components = [ ...buttons ]; -const utils = [HumanizePipe, DatePipe, SyncWidthDirective, HasScrollbarDirective, NavigateLastDossiersScreenDirective]; +const utils = [DatePipe, SyncWidthDirective, HasScrollbarDirective, NavigateLastDossiersScreenDirective]; const modules = [MatConfigModule, TranslateModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, CommonUiModule]; diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 537dd0a0a..f2b6befb1 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -15,13 +15,14 @@ import { Event, NavigationEnd, ResolveStart, Router } from '@angular/router'; import { UserService } from '@services/user.service'; import { forkJoin, Observable, of } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; -import { FALLBACK_COLOR, hexToRgb, humanize } from '@utils/functions'; +import { FALLBACK_COLOR, hexToRgb } from '@utils/functions'; import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { DossierWrapper } from './model/dossier.wrapper'; import { TypeValueWrapper } from '@models/file/type-value.wrapper'; import { DossierTemplateModelWrapper } from '@models/file/dossier-template-model.wrapper'; import { DossiersService } from '../modules/dossier/services/dossiers.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { humanize } from '@iqser/common-ui'; export interface AppState { dossiers: DossierWrapper[]; diff --git a/apps/red-ui/src/app/utils/functions.ts b/apps/red-ui/src/app/utils/functions.ts index 83f1a5ed5..183aae547 100644 --- a/apps/red-ui/src/app/utils/functions.ts +++ b/apps/red-ui/src/app/utils/functions.ts @@ -7,25 +7,6 @@ export function groupBy(xs: any[], key: string) { }, {}); } -export function computerize(str: string) { - if (!str) { - return undefined; - } - const frags = str.toLowerCase().split(/[ \-_]+/); - return frags.join('_'); -} - -export function humanize(str: string, lowercase: boolean = true) { - if (!str) { - return undefined; - } - const frags = (lowercase ? str.toLowerCase() : str).split(/[ \-_]+/); - for (let i = 0; i < frags.length; i++) { - frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1); - } - return frags.join(' '); -} - export function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result @@ -37,14 +18,6 @@ export function hexToRgb(hex) { : null; } -export function keypress(key: string) { - document.dispatchEvent(new KeyboardEvent('keypress', { key: key })); -} - -export function reference(x: any) { - return x; -} - export function getFirstRelevantTextPart(text, direction: 'FORWARD' | 'BACKWARD') { let spaceCount = 0; let accumulator = ''; @@ -58,11 +31,7 @@ export function getFirstRelevantTextPart(text, direction: 'FORWARD' | 'BACKWARD' accumulator += char; - if (spaceCount >= 2) { - return true; - } else { - return false; - } + return spaceCount >= 2; }; if (direction === 'FORWARD') { diff --git a/package.json b/package.json index b6809138a..a2630e3fd 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "husky": { "hooks": { - "pre-commit": "pretty-quick --staged && ng lint --project=red-ui-http && ng lint --project=red-ui --fix" + "pre-commit": "pretty-quick --staged && ng lint --project=red-ui-http && ng lint --project=red-ui --fix && ng lint --project=common-ui --fix" } }, "dependencies": { From 9d7c343d5f76f12a15313b0b210e5b10161d22a2 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 6 Aug 2021 14:34:44 +0300 Subject: [PATCH 3/8] move search service, update user wrapper and service --- .../base-screen/base-screen.component.ts | 2 +- .../downloads-list-screen.component.ts | 8 +- .../user-profile-screen.component.ts | 8 +- .../add-edit-user-dialog.component.ts | 4 +- .../reset-password.component.ts | 22 ++-- .../user-details/user-details.component.ts | 7 +- .../confirm-delete-users-dialog.component.ts | 13 ++- .../active-fields-listing.component.ts | 8 +- ...-attributes-csv-import-dialog.component.ts | 7 +- .../smtp-auth-dialog.component.ts | 2 +- .../default-colors-screen.component.ts | 8 +- .../dictionary-listing-screen.component.ts | 8 +- ...ier-attributes-listing-screen.component.ts | 8 +- ...sier-templates-listing-screen.component.ts | 8 +- ...ile-attributes-listing-screen.component.ts | 8 +- .../screens/trash/trash-screen.component.ts | 8 +- .../user-listing-screen.component.html | 8 +- .../user-listing-screen.component.ts | 38 +++--- .../src/app/modules/auth/red-role.guard.ts | 6 +- .../annotation-actions.component.ts | 10 +- .../components/comments/comments.component.ts | 2 +- .../dossier-details.component.html | 2 +- .../dossier-details.component.ts | 11 +- .../team-members-manager.component.ts | 8 +- ...sign-reviewer-approver-dialog.component.ts | 2 +- .../dossier-listing-screen.component.ts | 16 ++- .../dossier-overview-screen.component.ts | 12 +- .../file-preview-screen.component.ts | 13 +-- .../search-screen/search-screen.component.ts | 10 +- .../services/annotation-actions.service.ts | 12 +- .../dossier/services/file-action.service.ts | 2 +- .../shared/base/base-listing.component.ts | 13 ++- .../assign-user-dropdown.component.ts | 19 ++- .../user-button/user-button.component.html | 2 +- .../initials-avatar.component.ts | 22 ++-- .../page-header/page-header.component.ts | 7 +- .../table-col-name.component.ts | 8 +- .../table-header/table-header.component.ts | 2 +- .../shared/services/screen-state.service.ts | 8 +- .../modules/shared/services/search.service.ts | 41 ------- .../src/app/services/permissions.service.ts | 28 ++--- apps/red-ui/src/app/services/user.service.ts | 110 +++++------------- apps/red-ui/src/app/state/app-state.guard.ts | 4 +- 43 files changed, 207 insertions(+), 338 deletions(-) delete mode 100644 apps/red-ui/src/app/modules/shared/services/search.service.ts diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts index 070deabe8..1f597b032 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts @@ -78,7 +78,7 @@ export class BaseScreenComponent { } get user() { - return this._userService.user; + return this._userService.currentUser; } get showPendingDownloadsDot() { diff --git a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts index ec5d9f628..c9b53783d 100644 --- a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts +++ b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts @@ -2,10 +2,8 @@ import { Component, Injector, OnInit } from '@angular/core'; import { FileDownloadService } from '@upload-download/services/file-download.service'; import { DownloadStatusWrapper } from '@upload-download/model/download-status.wrapper'; import { DownloadControllerService } from '@redaction/red-ui-http'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; -import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; +import { CircleButtonTypes } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; @@ -13,7 +11,7 @@ import { TableColConfig } from '@shared/components/table-col-name/table-col-name selector: 'redaction-downloads-list-screen', templateUrl: './downloads-list-screen.component.html', styleUrls: ['./downloads-list-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DownloadsListScreenComponent extends BaseListingComponent implements OnInit { readonly circleButtonTypes = CircleButtonTypes; diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts index 6816cf6c2..e1dcc7b0e 100644 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts +++ b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts @@ -98,12 +98,12 @@ export class UserProfileScreenComponent implements OnInit { private _initializeForm(): void { try { this._profileModel = { - email: this._userService.user.email, - firstName: this._userService.user.firstName, - lastName: this._userService.user.lastName, + email: this._userService.currentUser.email, + firstName: this._userService.currentUser.firstName, + lastName: this._userService.currentUser.lastName, language: this._languageService.currentLanguage }; - if (this._userService.user.email) { + if (this._userService.currentUser.email) { // disable email if it's already set this.formGroup.get('email').disable(); } diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts index e79719568..8753a57bc 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/add-edit-user-dialog.component.ts @@ -1,6 +1,6 @@ import { Component, Inject } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { User } from '@redaction/red-ui-http'; +import { UserWrapper } from '@services/user.service'; @Component({ selector: 'redaction-add-edit-user-dialog', @@ -10,7 +10,7 @@ import { User } from '@redaction/red-ui-http'; export class AddEditUserDialogComponent { resettingPassword = false; - constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public user: User) {} + constructor(readonly dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) readonly user: UserWrapper) {} toggleResetPassword() { this.resettingPassword = !this.resettingPassword; diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts index d65dbbe76..71e219ca7 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/reset-password/reset-password.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { User, UserControllerService } from '@redaction/red-ui-http'; -import { UserService } from '@services/user.service'; +import { FormBuilder, Validators } from '@angular/forms'; +import { UserControllerService } from '@redaction/red-ui-http'; +import { UserService, UserWrapper } from '@services/user.service'; import { LoadingService } from '@services/loading.service'; @Component({ @@ -10,8 +10,10 @@ import { LoadingService } from '@services/loading.service'; styleUrls: ['./reset-password.component.scss'] }) export class ResetPasswordComponent { - passwordForm: FormGroup; - @Input() user: User; + readonly passwordForm = this._formBuilder.group({ + temporaryPassword: [null, Validators.required] + }); + @Input() user: UserWrapper; @Output() toggleResetPassword = new EventEmitter(); constructor( @@ -19,14 +21,10 @@ export class ResetPasswordComponent { private readonly _userControllerService: UserControllerService, private readonly _userService: UserService, private readonly _loadingService: LoadingService - ) { - this.passwordForm = this._formBuilder.group({ - temporaryPassword: [null, Validators.required] - }); - } + ) {} get userName() { - return this._userService.getNameForId(this.user.userId); + return this._userService.getNameForId(this.user.id); } async save() { @@ -37,7 +35,7 @@ export class ResetPasswordComponent { password: this.passwordForm.get('temporaryPassword').value, temporary: true }, - this.user.userId + this.user.id ) .toPromise(); this._loadingService.stop(); diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/user-details/user-details.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/user-details/user-details.component.ts index 617d32a01..d9a6aa7e1 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/user-details/user-details.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-user-dialog/user-details/user-details.component.ts @@ -1,10 +1,11 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { User, UserControllerService } from '@redaction/red-ui-http'; +import { UserControllerService } from '@redaction/red-ui-http'; import { AdminDialogService } from '../../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; import { rolesTranslations } from '../../../../../translations/roles-translations'; import { IconButtonTypes } from '@iqser/common-ui'; +import { UserWrapper } from '@services/user.service'; @Component({ selector: 'redaction-user-details', @@ -14,7 +15,7 @@ import { IconButtonTypes } from '@iqser/common-ui'; export class UserDetailsComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; - @Input() user: User; + @Input() user: UserWrapper; @Output() toggleResetPassword = new EventEmitter(); @Output() closeDialog = new EventEmitter(); userForm: FormGroup; @@ -99,7 +100,7 @@ export class UserDetailsComponent implements OnInit { if (!this.user) { await this._userControllerService.createUser(userData).toPromise(); } else { - await this._userControllerService.updateProfile(userData, this.user.userId).toPromise(); + await this._userControllerService.updateProfile(userData, this.user.id).toPromise(); } this.closeDialog.emit(true); diff --git a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-users-dialog/confirm-delete-users-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-users-dialog/confirm-delete-users-dialog.component.ts index f6ed8044d..3c0ffa4eb 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-users-dialog/confirm-delete-users-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-users-dialog/confirm-delete-users-dialog.component.ts @@ -1,9 +1,10 @@ import { Component, Inject } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { User, UserControllerService } from '@redaction/red-ui-http'; +import { UserControllerService } from '@redaction/red-ui-http'; import { AppStateService } from '@state/app-state.service'; import { LoadingService } from '@services/loading.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { UserWrapper } from '@services/user.service'; @Component({ selector: 'redaction-confirm-delete-users-dialog', @@ -11,7 +12,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; styleUrls: ['./confirm-delete-users-dialog.component.scss'] }) export class ConfirmDeleteUsersDialogComponent { - checkboxes = [ + readonly checkboxes = [ { value: false, label: _('confirm-delete-users.impacted-dossiers') }, { value: false, label: _('confirm-delete-users.impacted-documents') } ]; @@ -22,12 +23,12 @@ export class ConfirmDeleteUsersDialogComponent { private readonly _appStateService: AppStateService, private readonly _loadingService: LoadingService, private readonly _userControllerService: UserControllerService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public users: User[] + readonly dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) readonly users: UserWrapper[] ) { this.dossiersCount = this._appStateService.allDossiers.filter(dw => { for (const user of this.users) { - if (dw.memberIds.indexOf(user.userId) !== -1) { + if (dw.memberIds.indexOf(user.id) !== -1) { return true; } } @@ -42,7 +43,7 @@ export class ConfirmDeleteUsersDialogComponent { async deleteUser() { if (this.valid) { this._loadingService.start(); - await this._userControllerService.deleteUsers(this.users.map(u => u.userId)).toPromise(); + await this._userControllerService.deleteUsers(this.users.map(u => u.id)).toPromise(); this.dialogRef.close(true); } else { this.showToast = true; diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts index 36951f4b0..5f571b70c 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.ts @@ -1,17 +1,15 @@ import { Component, EventEmitter, Injector, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { Field } from '../file-attributes-csv-import-dialog.component'; import { FileAttributeConfig } from '@redaction/red-ui-http'; -import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { fileAttributeTypesTranslations } from '../../../translations/file-attribute-types-translations'; @Component({ selector: 'redaction-active-fields-listing', templateUrl: './active-fields-listing.component.html', styleUrls: ['./active-fields-listing.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class ActiveFieldsListingComponent extends BaseListingComponent implements OnChanges { readonly circleButtonTypes = CircleButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts index 1c1001219..c9c1682c3 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/file-attributes-csv-import-dialog.component.ts @@ -8,10 +8,7 @@ import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; import { Toaster } from '@services/toaster.service'; import { TranslateService } from '@ngx-translate/core'; -import { FilterService, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; export interface Field { @@ -28,7 +25,7 @@ export interface Field { @Component({ templateUrl: './file-attributes-csv-import-dialog.component.html', styleUrls: ['./file-attributes-csv-import-dialog.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class FileAttributesCsvImportDialogComponent extends BaseListingComponent { protected readonly _primaryKey = 'csvColumn'; diff --git a/apps/red-ui/src/app/modules/admin/dialogs/smtp-auth-dialog/smtp-auth-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/smtp-auth-dialog/smtp-auth-dialog.component.ts index 6c54118ab..06e99ce26 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/smtp-auth-dialog/smtp-auth-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/smtp-auth-dialog/smtp-auth-dialog.component.ts @@ -19,7 +19,7 @@ export class SmtpAuthDialogComponent { @Inject(MAT_DIALOG_DATA) public data: SMTPConfigurationModel ) { this.authForm = this._formBuilder.group({ - user: [data?.user || this._userService.user.email, [Validators.required]], + user: [data?.user || this._userService.currentUser.email, [Validators.required]], password: [data?.password, Validators.required] }); } diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts index c9a043270..764693e33 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts @@ -5,10 +5,8 @@ import { ActivatedRoute } from '@angular/router'; import { PermissionsService } from '@services/permissions.service'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { DefaultColorType } from '@models/default-color-key.model'; import { defaultColorsTranslations } from '../../translations/default-colors-translations'; @@ -16,7 +14,7 @@ import { defaultColorsTranslations } from '../../translations/default-colors-tra templateUrl: './default-colors-screen.component.html', styleUrls: ['./default-colors-screen.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DefaultColorsScreenComponent extends BaseListingComponent<{ diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts index 9de2315c1..b895a0184 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts @@ -9,10 +9,8 @@ import { ActivatedRoute } from '@angular/router'; import { TypeValueWrapper } from '@models/file/type-value.wrapper'; import { TranslateService } from '@ngx-translate/core'; import { LoadingService } from '@services/loading.service'; -import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { AdminDialogService } from '../../services/admin-dialog.service'; const toChartConfig = (dict: TypeValueWrapper): DoughnutChartConfig => ({ @@ -25,7 +23,7 @@ const toChartConfig = (dict: TypeValueWrapper): DoughnutChartConfig => ({ @Component({ templateUrl: './dictionary-listing-screen.component.html', styleUrls: ['./dictionary-listing-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DictionaryListingScreenComponent extends BaseListingComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts index deadcb650..b4089dfec 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.ts @@ -1,13 +1,11 @@ import { Component, Injector, OnInit } from '@angular/core'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { DossierAttributeConfig } from '@redaction/red-ui-http'; import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; +import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; import { PermissionsService } from '@services/permissions.service'; import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service'; import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations'; @@ -15,7 +13,7 @@ import { dossierAttributeTypesTranslations } from '../../translations/dossier-at @Component({ templateUrl: './dossier-attributes-listing-screen.component.html', styleUrls: ['./dossier-attributes-listing-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DossierAttributesListingScreenComponent extends BaseListingComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts index e96584882..257d9125c 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.ts @@ -6,16 +6,14 @@ import { AdminDialogService } from '../../services/admin-dialog.service'; import { DossierTemplateModelWrapper } from '@models/file/dossier-template-model.wrapper'; import { LoadingService } from '@services/loading.service'; import { DossierTemplateControllerService } from '@redaction/red-ui-http'; -import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; @Component({ templateUrl: './dossier-templates-listing-screen.component.html', styleUrls: ['./dossier-templates-listing-screen.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DossierTemplatesListingScreenComponent extends BaseListingComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts index 9b28c5299..0048f8903 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts @@ -5,17 +5,15 @@ import { AppStateService } from '@state/app-state.service'; import { ActivatedRoute } from '@angular/router'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { LoadingService } from '@services/loading.service'; -import { CircleButtonTypes, FilterService, IconButtonTypes, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes, IconButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { fileAttributeTypesTranslations } from '../../translations/file-attribute-types-translations'; @Component({ templateUrl: './file-attributes-listing-screen.component.html', styleUrls: ['./file-attributes-listing-screen.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class FileAttributesListingScreenComponent extends BaseListingComponent implements OnInit, OnDestroy { readonly iconButtonTypes = IconButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts index 11d8cb85f..3a4950bd0 100644 --- a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts @@ -4,10 +4,8 @@ import { Dossier } from '@redaction/red-ui-http'; import { LoadingService } from '@services/loading.service'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import * as moment from 'moment'; -import { CircleButtonTypes, FilterService, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { DossiersService } from '../../../dossier/services/dossiers.service'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { ConfirmationDialogInput, TitleColors } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; @@ -20,7 +18,7 @@ const MINUTES_IN_AN_HOUR = 60; templateUrl: './trash-screen.component.html', styleUrls: ['./trash-screen.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [FilterService, SearchService, ScreenStateService, SortingService, DossiersService] + providers: [...DefaultListingServices, DossiersService] }) export class TrashScreenComponent extends BaseListingComponent implements OnInit { readonly circleButtonTypes = CircleButtonTypes; diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html index b486f7966..5ba720302 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html @@ -87,11 +87,7 @@
- +
{{ user.email || '-' }}
@@ -112,7 +108,7 @@ > implements OnInit { +export class UserListingScreenComponent extends BaseListingComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; readonly circleButtonTypes = CircleButtonTypes; readonly canDeleteSelected$ = this._canDeleteSelected$; collapsedDetails = false; chartData: DoughnutChartConfig[] = []; readonly translations = rolesTranslations; - protected readonly _primaryKey = 'userId'; + protected readonly _primaryKey = 'id'; @ViewChildren(InitialsAvatarComponent) private readonly _avatars: QueryList; @@ -47,7 +45,7 @@ export class UserListingScreenComponent extends BaseListingComponent imple get _canDeleteSelected$(): Observable { const entities$ = this.screenStateService.selectedEntities$; - return entities$.pipe(map(all => all.indexOf(this.userService.user) === -1)); + return entities$.pipe(map(all => all.indexOf(this.userService.currentUser) === -1)); } async ngOnInit() { @@ -55,19 +53,19 @@ export class UserListingScreenComponent extends BaseListingComponent imple this.searchService.setSearchKey('searchKey'); } - openAddEditUserDialog($event: MouseEvent, user?: User) { + openAddEditUserDialog($event: MouseEvent, user?: UserWrapper) { this._dialogService.openDialog('addEditUser', $event, user, async () => { await this._loadData(); }); } - openDeleteUsersDialog(users: User[], $event?: MouseEvent) { + openDeleteUsersDialog(users: UserWrapper[], $event?: MouseEvent) { this._dialogService.openDialog('deleteUsers', $event, users, async () => { await this._loadData(); }); } - getDisplayRoles(user: User) { + getDisplayRoles(user: UserWrapper) { const separator = ', '; return ( user.roles.map(role => this._translateService.instant(this.translations[role])).join(separator) || @@ -75,12 +73,12 @@ export class UserListingScreenComponent extends BaseListingComponent imple ); } - async toggleActive(user: User) { + async toggleActive(user: UserWrapper) { this._loadingService.start(); user.roles = this.userService.isActive(user) ? [] : ['RED_USER']; - await this._userControllerService.updateProfile(user, user.userId).toPromise(); + await this._userControllerService.updateProfile(user, user.id).toPromise(); await this._loadData(); - this._avatars.find(item => item.userId === user.userId).detectChanges(); + this._avatars.find(item => item.userId === user.id).detectChanges(); } bulkDelete() { @@ -108,22 +106,22 @@ export class UserListingScreenComponent extends BaseListingComponent imple label: 'REGULAR' }, { - value: this.allEntities.filter(user => this.userService.isManager(user) && !this.userService.isAdmin(user)).length, + value: this.allEntities.filter(user => user.isManager && !user.isAdmin).length, color: 'MANAGER', label: 'RED_MANAGER' }, { - value: this.allEntities.filter(user => this.userService.isManager(user) && this.userService.isAdmin(user)).length, + value: this.allEntities.filter(user => user.isManager && user.isAdmin).length, color: 'MANAGER_ADMIN', label: 'MANAGER_ADMIN' }, { - value: this.allEntities.filter(user => this.userService.isUserAdmin(user) && !this.userService.isAdmin(user)).length, + value: this.allEntities.filter(user => user.isUserAdmin && !user.isAdmin).length, color: 'USER_ADMIN', label: 'RED_USER_ADMIN' }, { - value: this.allEntities.filter(user => this.userService.isAdmin(user) && !this.userService.isManager(user)).length, + value: this.allEntities.filter(user => user.isAdmin && !user.isManager).length, color: 'ADMIN', label: 'RED_ADMIN' } diff --git a/apps/red-ui/src/app/modules/auth/red-role.guard.ts b/apps/red-ui/src/app/modules/auth/red-role.guard.ts index fd0af5036..5d53ce911 100644 --- a/apps/red-ui/src/app/modules/auth/red-role.guard.ts +++ b/apps/red-ui/src/app/modules/auth/red-role.guard.ts @@ -16,7 +16,7 @@ export class RedRoleGuard implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { return new Observable(obs => { - if (!this._userService.user.hasAnyREDRoles) { + if (!this._userService.currentUser.hasAnyREDRoles) { this._router.navigate(['/auth-error']); this._loadingService.stop(); obs.next(false); @@ -26,8 +26,8 @@ export class RedRoleGuard implements CanActivate { // we have at least 1 RED Role -> if it's not user he must be admin if ( - this._userService.user.isUserAdmin && - !this._userService.user.isAdmin && + this._userService.currentUser.isUserAdmin && + !this._userService.currentUser.isAdmin && !(state.url.startsWith('/main/admin/users') || state.url.startsWith('/main/my-profile')) ) { this._router.navigate(['/main/admin/users']); diff --git a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts index 03ae851bc..42859ed31 100644 --- a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts @@ -5,6 +5,7 @@ import { PermissionsService } from '@services/permissions.service'; import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { AnnotationActionsService } from '../../services/annotation-actions.service'; import { WebViewerInstance } from '@pdftron/webviewer'; +import { UserService } from '@services/user.service'; export const AnnotationButtonTypes = { dark: 'dark', @@ -28,9 +29,10 @@ export class AnnotationActionsComponent implements OnInit { annotationPermissions: AnnotationPermissions; constructor( - public appStateService: AppStateService, - public annotationActionsService: AnnotationActionsService, - private _permissionsService: PermissionsService + readonly appStateService: AppStateService, + readonly annotationActionsService: AnnotationActionsService, + private readonly _permissionsService: PermissionsService, + private readonly _userService: UserService ) {} private _annotations: AnnotationWrapper[]; @@ -89,7 +91,7 @@ export class AnnotationActionsComponent implements OnInit { private _setPermissions() { this.annotationPermissions = AnnotationPermissions.forUser( this._permissionsService.isApprover(), - this._permissionsService.currentUser, + this._userService.currentUser, this.annotations ); } diff --git a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts index 0e0443763..006223e29 100644 --- a/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/comments/comments.component.ts @@ -39,7 +39,7 @@ export class CommentsComponent { this.annotation.comments.push({ text: value, id: commentResponse.commentId, - user: this._userService.userId + user: this._userService.currentUser.id }); }); this.commentForm.reset(); diff --git a/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.html b/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.html index 4fa628321..f92cc9879 100644 --- a/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.html @@ -15,7 +15,7 @@
- + m.userId); + return this.userService.managerUsers.map(m => m.id); } get membersSelectOptions() { const searchQuery = this.searchForm.get('query').value; return this.userService.eligibleUsers - .filter(user => this.userService.getNameForId(user.userId).toLowerCase().includes(searchQuery.toLowerCase())) - .filter(user => this.selectedOwnerId !== user.userId) - .map(user => user.userId); + .filter(user => this.userService.getNameForId(user.id).toLowerCase().includes(searchQuery.toLowerCase())) + .filter(user => this.selectedOwnerId !== user.id) + .map(user => user.id); } get valid(): boolean { diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts index 96855bd5a..22a8c241b 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts @@ -103,7 +103,7 @@ export class AssignReviewerApproverDialogComponent { uniqueReviewers.add(file.currentReviewer); } } - let singleUser = uniqueReviewers.size === 1 ? uniqueReviewers.values().next().value : this.userService.userId; + let singleUser = uniqueReviewers.size === 1 ? uniqueReviewers.values().next().value : this.userService.currentUser.id; singleUser = this.singleUsersSelectOptions.indexOf(singleUser) >= 0 ? singleUser : this.singleUsersSelectOptions[0]; diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts index 1c02d2f98..4089d550d 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts @@ -16,10 +16,8 @@ import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { UserPreferenceService } from '@services/user-preference.service'; import { ButtonConfig } from '@shared/components/page-header/models/button-config.model'; -import { FilterService, NestedFilter, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { NestedFilter } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; import { workloadTranslations } from '../../translations/workload-translations'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @@ -36,14 +34,14 @@ const isLeavingScreen = event => event instanceof NavigationStart && event.url ! @Component({ templateUrl: './dossier-listing-screen.component.html', styleUrls: ['./dossier-listing-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DossierListingScreenComponent extends BaseListingComponent implements OnInit, AfterViewInit, OnDestroy, OnAttach, OnDetach { readonly itemSize = 95; - buttonConfigs: ButtonConfig[] = [ + readonly buttonConfigs: ButtonConfig[] = [ { label: _('dossier-listing.add-new'), action: () => this.openAddDossierDialog(), @@ -52,7 +50,7 @@ export class DossierListingScreenComponent type: 'primary' } ]; - tableColConfigs: TableColConfig[] = [ + readonly tableColConfigs: TableColConfig[] = [ { label: _('dossier-listing.table-col-names.name'), withSort: true, @@ -72,7 +70,7 @@ export class DossierListingScreenComponent ]; dossiersChartData: DoughnutChartConfig[] = []; documentsChartData: DoughnutChartConfig[] = []; - protected readonly _primaryKey = 'dossierName'; + protected readonly _primaryKey = 'numberOfMembers'; protected _tableHeaderLabel = _('dossier-listing.table-header.title'); private _lastScrollPosition: number; @ViewChild('needsWorkTemplate', { read: TemplateRef, static: true }) @@ -95,7 +93,7 @@ export class DossierListingScreenComponent } private get _userId() { - return this._userService.userId; + return this._userService.currentUser.id; } private get _activeDossiersCount(): number { diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index e358ba1de..e1a40cd1b 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -21,10 +21,8 @@ import { DossierWrapper } from '@state/model/dossier.wrapper'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import { ActionConfig } from '@shared/components/page-header/models/action-config.model'; -import { CircleButtonTypes, FilterService, keyChecker, NestedFilter, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { CircleButtonTypes, keyChecker, NestedFilter } from '@iqser/common-ui'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { LoadingService } from '@services/loading.service'; import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service'; import { DossierAttributeWithValue } from '@models/dossier-attributes.model'; @@ -38,7 +36,7 @@ import { annotationFilterChecker } from '@shared/components/filters/popup-filter @Component({ templateUrl: './dossier-overview-screen.component.html', styleUrls: ['./dossier-overview-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class DossierOverviewScreenComponent extends BaseListingComponent @@ -60,7 +58,7 @@ export class DossierOverviewScreenComponent } ]; dossierAttributes: DossierAttributeWithValue[] = []; - tableColConfigs: TableColConfig[] = [ + readonly tableColConfigs: TableColConfig[] = [ { label: _('dossier-overview.table-col-names.name'), withSort: true, @@ -125,7 +123,7 @@ export class DossierOverviewScreenComponent } get userId() { - return this._userService.userId; + return this._userService.currentUser.id; } get checkedRequiredFilters() { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 5ab0ffdd7..670215425 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -17,12 +17,11 @@ import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { PermissionsService } from '@services/permissions.service'; import { timer } from 'rxjs'; import { UserPreferenceService } from '@services/user-preference.service'; -import { UserService } from '@services/user.service'; +import { UserService, UserWrapper } from '@services/user.service'; import { FileManagementControllerService, FileStatus, StatusControllerService, - User, UserPreferenceControllerService } from '@redaction/red-ui-http'; import { PdfViewerDataService } from '../../services/pdf-viewer-data.service'; @@ -34,10 +33,8 @@ import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { LoadingService } from '@services/loading.service'; import { stampPDFPage } from '@utils/page-stamper'; import { TranslateService } from '@ngx-translate/core'; -import { AutoUnsubscribeComponent, CircleButtonTypes } from '@iqser/common-ui'; +import { AutoUnsubscribeComponent, CircleButtonTypes, NestedFilter, processFilters } from '@iqser/common-ui'; import { fileStatusTranslations } from '../../translations/file-status-translations'; -import { NestedFilter } from '@iqser/common-ui'; -import { processFilters } from '@iqser/common-ui'; import { handleFilterDelta } from '@shared/components/filters/popup-filter/utils/filter-utils'; const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f']; @@ -276,7 +273,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme const processStartTime = new Date().getTime(); this.annotationData = this.fileData.getAnnotations( this.appStateService.dictionaryData[this.appStateService.activeDossier.dossierTemplateId], - this.permissionsService.currentUser, + this.userService.currentUser, this.viewMode, this.userPreferenceService.areDevFeaturesEnabled ); @@ -467,8 +464,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme }); } - async assignReviewer(user: User | string) { - const reviewerId = typeof user === 'string' ? user : user.userId; + async assignReviewer(user: UserWrapper | string) { + const reviewerId = typeof user === 'string' ? user : user.id; const reviewerName = this.userService.getNameForId(reviewerId); const { dossierId, fileId, filename } = this.fileData.fileStatus; diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts index 20e835538..b763579f2 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts @@ -1,13 +1,11 @@ import { Component, Injector, OnDestroy } from '@angular/core'; -import { BaseListingComponent } from '@shared/base/base-listing.component'; +import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { MatchedDocument, SearchControllerService, SearchResult } from '@redaction/red-ui-http'; import { BehaviorSubject, Observable } from 'rxjs'; import { debounceTime, map, skip, switchMap, tap } from 'rxjs/operators'; import { ActivatedRoute, Router } from '@angular/router'; import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; -import { FilterService, keyChecker, SortingService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { ScreenStateService } from '@shared/services/screen-state.service'; +import { keyChecker } from '@iqser/common-ui'; import { AppStateService } from '@state/app-state.service'; import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { LoadingService } from '@services/loading.service'; @@ -36,7 +34,7 @@ interface SearchInput { @Component({ templateUrl: './search-screen.component.html', styleUrls: ['./search-screen.component.scss'], - providers: [FilterService, SearchService, ScreenStateService, SortingService] + providers: [...DefaultListingServices] }) export class SearchScreenComponent extends BaseListingComponent implements OnDestroy { readonly fileStatusTranslations = fileStatusTranslations; @@ -65,7 +63,7 @@ export class SearchScreenComponent extends BaseListingComponent implem label: _('search-screen.cols.pages') } ]; - protected readonly _primaryKey = 'fileName'; + protected readonly _primaryKey = 'filename'; protected readonly _tableHeaderLabel = _('search-screen.table-header'); constructor( diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 420533a70..862159e56 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -9,13 +9,15 @@ import { getFirstRelevantTextPart } from '@utils/functions'; import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { DossiersDialogService } from './dossiers-dialog.service'; import { BASE_HREF } from '../../../tokens'; +import { UserService } from '@services/user.service'; @Injectable() export class AnnotationActionsService { constructor( @Inject(BASE_HREF) private readonly _baseHref: string, - private readonly _permissionsService: PermissionsService, private readonly _ngZone: NgZone, + private readonly _userService: UserService, + private readonly _permissionsService: PermissionsService, private readonly _manualAnnotationService: ManualAnnotationService, private readonly _translateService: TranslateService, private readonly _dialogService: DossiersDialogService @@ -89,7 +91,7 @@ export class AnnotationActionsService { annotations.forEach(annotation => { const permissions = AnnotationPermissions.forUser( this._permissionsService.isApprover(), - this._permissionsService.currentUser, + this._userService.currentUser, annotation ); const value = permissions.canMarkTextOnlyAsFalsePositive ? annotation.value : this._getFalsePositiveText(annotation); @@ -132,9 +134,9 @@ export class AnnotationActionsService { ): Record[] { const availableActions = []; - const annotationPermissions = annotations.map(a => ({ - annotation: a, - permissions: AnnotationPermissions.forUser(this._permissionsService.isApprover(), this._permissionsService.currentUser, a) + const annotationPermissions = annotations.map(annotation => ({ + annotation, + permissions: AnnotationPermissions.forUser(this._permissionsService.isApprover(), this._userService.currentUser, annotation) })); const canRecategorizeImage = annotations.length === 1 && annotationPermissions[0].permissions.canRecategorizeImage; diff --git a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts index 30d46ee8e..438182380 100644 --- a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts @@ -154,7 +154,7 @@ export class FileActionService { .setFileReviewerForList( fileStatus.map(f => f.fileId), this._appStateService.activeDossierId, - this._userService.userId + this._userService.currentUser.id ) .toPromise(); await this._appStateService.reloadActiveDossierFiles(); diff --git a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts index c667365b1..79ac0396b 100644 --- a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts +++ b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts @@ -1,21 +1,22 @@ import { Component, Injector, OnDestroy, ViewChild } from '@angular/core'; -import { AutoUnsubscribeComponent, FilterService, SortingOrders, SortingService } from '@iqser/common-ui'; +import { AutoUnsubscribeComponent, FilterService, KeysOf, SearchService, SortingOrders, SortingService } from '@iqser/common-ui'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; -import { SearchService } from '../services/search.service'; import { ScreenStateService } from '../services/screen-state.service'; import { combineLatest, Observable } from 'rxjs'; import { distinctUntilChanged, map, switchMap } from 'rxjs/operators'; import { PermissionsService } from '@services/permissions.service'; +export const DefaultListingServices = [FilterService, SearchService, ScreenStateService, SortingService] as const; + @Component({ template: '' }) -export abstract class BaseListingComponent extends AutoUnsubscribeComponent implements OnDestroy { +export abstract class BaseListingComponent extends AutoUnsubscribeComponent implements OnDestroy { @ViewChild(CdkVirtualScrollViewport) readonly scrollViewport: CdkVirtualScrollViewport; readonly permissionsService = this._injector.get(PermissionsService); readonly filterService = this._injector.get(FilterService); - readonly sortingService = this._injector.get(SortingService); - readonly searchService = this._injector.get(SearchService); + readonly sortingService = this._injector.get>(SortingService); + readonly searchService = this._injector.get>(SearchService); readonly screenStateService = this._injector.get>(ScreenStateService); readonly sortedDisplayedEntities$ = this._sortedDisplayedEntities$; @@ -27,7 +28,7 @@ export abstract class BaseListingComponent extends AutoUnsubscribeComponent i * and in the default sorting and as the search field * @protected */ - protected abstract _primaryKey: string; + protected readonly _primaryKey: KeysOf; protected constructor(protected readonly _injector: Injector) { super(); diff --git a/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.ts b/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.ts index 8a9b71032..40cce4227 100644 --- a/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.ts @@ -1,6 +1,5 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; -import { User } from '@redaction/red-ui-http'; -import { UserService } from '@services/user.service'; +import { UserService, UserWrapper } from '@services/user.service'; @Component({ selector: 'redaction-assign-user-dropdown', @@ -9,25 +8,25 @@ import { UserService } from '@services/user.service'; changeDetection: ChangeDetectionStrategy.OnPush }) export class AssignUserDropdownComponent { - oldUser: User | string; - @Input() options: (User | string)[]; - @Output() save = new EventEmitter(); + oldUser: UserWrapper | string; + @Input() options: (UserWrapper | string)[]; + @Output() save = new EventEmitter(); @Output() cancel = new EventEmitter(); - private _currentUser: User | string; + private _currentUser: UserWrapper | string; constructor(private readonly _userService: UserService) {} - get value(): User | string { + get value(): UserWrapper | string { return this._currentUser; } @Input() - set value(value: User | string) { + set value(value: UserWrapper | string) { if (this.oldUser === undefined) this.oldUser = value; this._currentUser = value; } - getContext(user: User | string) { - return { userId: typeof user === 'string' ? user : user?.userId }; + getContext(user: UserWrapper | string) { + return { userId: typeof user === 'string' ? user : user?.id }; } } diff --git a/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html b/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html index 92241ad31..0d47530d6 100644 --- a/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html +++ b/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html @@ -1,5 +1,5 @@
diff --git a/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.ts b/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.ts index ce0e9d4cd..1104ee260 100644 --- a/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.ts @@ -1,8 +1,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy } from '@angular/core'; -import { UserService } from '@services/user.service'; -import { User } from '@redaction/red-ui-http'; +import { UserService, UserWrapper } from '@services/user.service'; import { TranslateService } from '@ngx-translate/core'; -import { Subscription } from 'rxjs'; +import { AutoUnsubscribeComponent } from '@iqser/common-ui'; @Component({ selector: 'redaction-initials-avatar', @@ -10,7 +9,7 @@ import { Subscription } from 'rxjs'; styleUrls: ['./initials-avatar.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class InitialsAvatarComponent implements OnChanges, OnDestroy { +export class InitialsAvatarComponent extends AutoUnsubscribeComponent implements OnChanges, OnDestroy { @Input() userId: string; @Input() color = 'lightgray'; @Input() size: 'small' | 'large' = 'small'; @@ -21,22 +20,21 @@ export class InitialsAvatarComponent implements OnChanges, OnDestroy { displayName: string; initials: string; colorClass: string; - user: User; - - private _subscription: Subscription; + user: UserWrapper; constructor( private readonly _userService: UserService, private readonly _translateService: TranslateService, private readonly _changeDetectorRef: ChangeDetectorRef ) { - this._subscription = _userService.usersReloaded$.subscribe(() => { + super(); + this.addSubscription = _userService.usersReloaded$.subscribe(() => { this.detectChanges(); }); } get hasBorder(): boolean { - return !!this.user && !this._isCurrentUser && this._userService.isManager(this.user); + return !!this.user && !this._isCurrentUser && this.user.isManager; } get disabled(): boolean { @@ -52,11 +50,7 @@ export class InitialsAvatarComponent implements OnChanges, OnDestroy { } private get _isCurrentUser(): boolean { - return this._userService.userId === this.user?.userId; - } - - ngOnDestroy() { - this._subscription?.unsubscribe(); + return this._userService.currentUser.id === this.user?.id; } ngOnChanges(): void { diff --git a/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.ts b/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.ts index 2a3e72672..f9552a534 100644 --- a/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/page-header/page-header.component.ts @@ -1,8 +1,7 @@ import { Component, Input, Optional } from '@angular/core'; import { ActionConfig } from '@shared/components/page-header/models/action-config.model'; import { ButtonConfig } from '@shared/components/page-header/models/button-config.model'; -import { FilterService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; +import { FilterService, SearchService } from '@iqser/common-ui'; import { distinctUntilChanged, map } from 'rxjs/operators'; import { combineLatest, Observable, of } from 'rxjs'; import { SearchPosition, SearchPositions } from '@shared/components/page-header/models/search-positions.type'; @@ -12,7 +11,7 @@ import { SearchPosition, SearchPositions } from '@shared/components/page-header/ templateUrl: './page-header.component.html', styleUrls: ['./page-header.component.scss'] }) -export class PageHeaderComponent { +export class PageHeaderComponent { readonly searchPositions = SearchPositions; @Input() pageLabel: string; @@ -26,7 +25,7 @@ export class PageHeaderComponent { readonly filters$ = this.filterService?.filterGroups$.pipe(map(all => all.filter(f => f.icon))); readonly showResetFilters$ = this._showResetFilters$; - constructor(@Optional() readonly filterService: FilterService, @Optional() readonly searchService: SearchService) {} + constructor(@Optional() readonly filterService: FilterService, @Optional() readonly searchService: SearchService) {} get _showResetFilters$(): Observable { if (!this.filterService) return of(false); diff --git a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts index 2dbe2d863..39b6985ac 100644 --- a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts @@ -1,5 +1,5 @@ import { Component, Input, Optional } from '@angular/core'; -import { SortingService } from '@iqser/common-ui'; +import { KeysOf, SortingService } from '@iqser/common-ui'; export interface TableColConfig { readonly column?: string; @@ -16,8 +16,8 @@ export interface TableColConfig { templateUrl: './table-col-name.component.html', styleUrls: ['./table-col-name.component.scss'] }) -export class TableColNameComponent { - @Input() column: string; +export class TableColNameComponent { + @Input() column: KeysOf; @Input() label: string; @Input() withSort = false; @Input() class: string; @@ -25,5 +25,5 @@ export class TableColNameComponent { @Input() rightIcon: string; @Input() rightIconTooltip: string; - constructor(@Optional() readonly sortingService: SortingService) {} + constructor(@Optional() readonly sortingService: SortingService) {} } diff --git a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts index 671e9ad91..ff2b6bd94 100644 --- a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts @@ -8,7 +8,7 @@ import { ScreenStateService } from '@shared/services/screen-state.service'; styleUrls: ['./table-header.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class TableHeaderComponent { +export class TableHeaderComponent { @Input() tableHeaderLabel: string; @Input() tableColConfigs: TableColConfig[]; @Input() hasEmptyColumn = false; diff --git a/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts b/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts index 0229c72c6..9a8bf2756 100644 --- a/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts +++ b/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts @@ -1,15 +1,13 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, combineLatest, Observable, pipe } from 'rxjs'; import { distinctUntilChanged, map, tap } from 'rxjs/operators'; -import { FilterService } from '@iqser/common-ui'; -import { SearchService } from '@shared/services/search.service'; -import { getFilteredEntities } from '@iqser/common-ui'; +import { FilterService, getFilteredEntities, SearchService } from '@iqser/common-ui'; const toLengthValue = (entities: unknown[]) => entities?.length ?? 0; const getLength = pipe(map(toLengthValue), distinctUntilChanged()); @Injectable() -export class ScreenStateService { +export class ScreenStateService { private readonly _allEntities$ = new BehaviorSubject([]); readonly allEntities$ = this._allEntities$.asObservable(); readonly allEntitiesLength$ = this._allEntities$.pipe(getLength); @@ -27,7 +25,7 @@ export class ScreenStateService { readonly areSomeEntitiesSelected$ = this._areSomeEntitiesSelected$; readonly notAllEntitiesSelected$ = this._notAllEntitiesSelected$; - constructor(private readonly _filterService: FilterService, private readonly _searchService: SearchService) { + constructor(private readonly _filterService: FilterService, private readonly _searchService: SearchService) { // setInterval(() => { // console.log('All entities subs: ', this._allEntities$.observers); // console.log('Displayed entities subs: ', this._displayedEntities$.observers); diff --git a/apps/red-ui/src/app/modules/shared/services/search.service.ts b/apps/red-ui/src/app/modules/shared/services/search.service.ts deleted file mode 100644 index d0049343c..000000000 --- a/apps/red-ui/src/app/modules/shared/services/search.service.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Injectable } from '@angular/core'; -import { FormBuilder } from '@angular/forms'; -import { startWith } from 'rxjs/operators'; - -@Injectable() -export class SearchService { - readonly searchForm = this._formBuilder.group({ - query: [''] - }); - readonly valueChanges$ = this.searchForm.get('query').valueChanges.pipe(startWith('')); - private _searchKey: string; - - constructor(private readonly _formBuilder: FormBuilder) {} - - get searchValue(): string { - return this.searchForm.get('query').value; - } - - set searchValue(value: string) { - this.searchForm.patchValue({ query: value }); - } - - searchIn(entities: T[]) { - if (!this._searchKey) return entities; - - const searchValue = this.searchValue.toLowerCase(); - return entities.filter(entity => this._searchField(entity).includes(searchValue)); - } - - setSearchKey(value: string): void { - this._searchKey = value; - } - - reset(): void { - this.searchForm.reset({ query: '' }, { emitEvent: true }); - } - - private _searchField(entity: T): string { - return entity[this._searchKey].toString().toLowerCase(); - } -} diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index 990c5bf9e..646aa34c4 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { AppStateService } from '@state/app-state.service'; import { UserService, UserWrapper } from './user.service'; import { FileStatusWrapper } from '@models/file/file-status.wrapper'; -import { User, Comment } from '@redaction/red-ui-http'; +import { Comment } from '@redaction/red-ui-http'; import { DossierWrapper } from '@state/model/dossier.wrapper'; @Injectable({ @@ -11,10 +11,6 @@ import { DossierWrapper } from '@state/model/dossier.wrapper'; export class PermissionsService { constructor(private readonly _appStateService: AppStateService, private readonly _userService: UserService) {} - get currentUser(): UserWrapper { - return this._userService.user; - } - private get _activeFile(): FileStatusWrapper | undefined { return this._appStateService.activeFile; } @@ -23,7 +19,7 @@ export class PermissionsService { return this._appStateService.activeDossier; } - isManager(user?: User) { + isManager(user?: UserWrapper) { return this._userService.isManager(user); } @@ -55,7 +51,7 @@ export class PermissionsService { } isFileReviewer(fileStatus = this._activeFile): boolean { - return fileStatus.currentReviewer === this._userService.userId; + return fileStatus.currentReviewer === this._userService.currentUser.id; } canDeleteFile(fileStatus = this._activeFile, dossier?: DossierWrapper): boolean { @@ -112,19 +108,19 @@ export class PermissionsService { return fileStatus?.isUnderReview && this.isReviewerOrApprover(fileStatus); } - isOwner(dossier = this._activeDossier, user = this.currentUser): boolean { + isOwner(dossier = this._activeDossier, user = this._userService.currentUser): boolean { return dossier?.ownerId === user.id; } - isApprover(dossier = this._activeDossier, user = this.currentUser): boolean { + isApprover(dossier = this._activeDossier, user = this._userService.currentUser): boolean { return dossier?.approverIds.indexOf(user.id) >= 0; } - isDossierReviewer(dossier = this._activeDossier, user = this.currentUser): boolean { + isDossierReviewer(dossier = this._activeDossier, user = this._userService.currentUser): boolean { return this.isDossierMember(dossier, user) && !this.isApprover(dossier, user); } - isDossierMember(dossier = this._activeDossier, user = this.currentUser): boolean { + isDossierMember(dossier = this._activeDossier, user = this._userService.currentUser): boolean { return dossier?.memberIds.includes(user.id); } @@ -156,18 +152,18 @@ export class PermissionsService { } canDeleteDossier(dossier = this._activeDossier): boolean { - return dossier.ownerId === this.currentUser.userId; + return dossier.ownerId === this._userService.currentUser.id; } - isAdmin(user = this.currentUser): boolean { + isAdmin(user = this._userService.currentUser): boolean { return user.isAdmin; } - isUserAdmin(user = this.currentUser): boolean { + isUserAdmin(user = this._userService.currentUser): boolean { return user.isUserAdmin; } - isUser(user = this.currentUser): boolean { + isUser(user = this._userService.currentUser): boolean { return user.isUser; } @@ -190,6 +186,6 @@ export class PermissionsService { } canDeleteComment(comment: Comment, fileStatus = this._activeFile) { - return (comment.user === this._userService.userId || this.isApprover()) && !fileStatus.isApproved; + return (comment.user === this._userService.currentUser.id || this.isApprover()) && !fileStatus.isApproved; } } diff --git a/apps/red-ui/src/app/services/user.service.ts b/apps/red-ui/src/app/services/user.service.ts index fe54e6647..1939cd5dc 100644 --- a/apps/red-ui/src/app/services/user.service.ts +++ b/apps/red-ui/src/app/services/user.service.ts @@ -1,10 +1,11 @@ -import { EventEmitter, Inject, Injectable } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { KeycloakService } from 'keycloak-angular'; import { KeycloakProfile } from 'keycloak-js'; import jwt_decode from 'jwt-decode'; import { User, UserControllerService } from '@redaction/red-ui-http'; import { wipeCaches } from '@redaction/red-cache'; import { BASE_HREF } from '../tokens'; +import { Subject } from 'rxjs'; export interface ProfileModel { username?: string; @@ -15,62 +16,27 @@ export interface ProfileModel { } export class UserWrapper { - name: string; + constructor(private readonly _user: KeycloakProfile | User, public roles: string[], public id: string) {} - constructor(private readonly _currentUser: KeycloakProfile | User, public roles: string[], public id: string) { - this.name = this.firstName && this.lastName ? `${this.firstName} ${this.lastName}` : this.username; - } + email = this._user.email; + username = this._user.username || this.email; + firstName = this._user.firstName; + lastName = this._user.lastName; + name = this.firstName && this.lastName ? `${this.firstName} ${this.lastName}` : this.username; + searchKey = this.name + this.username + this.email; - get username() { - return this._currentUser.username || this.email; - } - - get userId() { - return this.id; - } - - get email() { - return this._currentUser.email; - } - - get firstName() { - return this._currentUser.firstName; - } - - get lastName() { - return this._currentUser.lastName; - } - - get searchKey() { - return this.name + this.username + this.email; - } - - get isManager() { - return this.roles.indexOf('RED_MANAGER') >= 0; - } - - get isUserAdmin() { - return this.roles.indexOf('RED_USER_ADMIN') >= 0; - } - - get isUser() { - return this.roles.indexOf('RED_USER') >= 0; - } - - get isAdmin() { - return this.roles.indexOf('RED_ADMIN') >= 0; - } - - get hasAnyREDRoles() { - return this.isUser || this.isManager || this.isAdmin || this.isUserAdmin; - } + isManager = this.roles.indexOf('RED_MANAGER') >= 0; + isUserAdmin = this.roles.indexOf('RED_USER_ADMIN') >= 0; + isUser = this.roles.indexOf('RED_USER') >= 0; + isAdmin = this.roles.indexOf('RED_ADMIN') >= 0; + hasAnyREDRoles = this.isUser || this.isManager || this.isAdmin || this.isUserAdmin; } @Injectable({ providedIn: 'root' }) export class UserService { - usersReloaded$: EventEmitter = new EventEmitter(); + usersReloaded$ = new Subject(); private _currentUser: UserWrapper; private _allUsers: UserWrapper[]; @@ -86,31 +52,18 @@ export class UserService { return this._allRedUsers; } - get userId(): string { - return this._currentUser.id; - } - get managerUsers(): UserWrapper[] { - return this._allRedUsers.filter(u => u.roles.indexOf('RED_MANAGER') >= 0); + return this._allRedUsers.filter(user => user.isManager); } get eligibleUsers(): UserWrapper[] { - return this._allRedUsers.filter(u => u.roles.indexOf('RED_USER') >= 0 || u.roles.indexOf('RED_MANAGER') >= 0); + return this._allRedUsers.filter(user => user.isUser || user.isManager); } - get user() { + get currentUser(): UserWrapper { return this._currentUser; } - private static _hasAnyRedRole(user: UserWrapper) { - return ( - user.roles.indexOf('RED_USER') >= 0 || - user.roles.indexOf('RED_MANAGER') >= 0 || - user.roles.indexOf('RED_ADMIN') >= 0 || - user.roles.indexOf('RED_USER_ADMIN') >= 0 - ); - } - logout() { wipeCaches().then(); this._keycloakService.logout(window.location.origin + this._baseHref).then(); @@ -123,14 +76,14 @@ export class UserService { } async loadAllUsers() { - let allUsers = []; + let allUsers: User[]; if (this._currentUser.isUserAdmin) { allUsers = await this._userControllerService.getAllUsers().toPromise(); } else { allUsers = await this._userControllerService.getUsers().toPromise(); } this._allUsers = allUsers.map(user => new UserWrapper(user, user.roles, user.userId)); - this._allRedUsers = this._allUsers.filter(u => UserService._hasAnyRedRole(u)); + this._allRedUsers = this._allUsers.filter(user => user.hasAnyREDRoles); this.usersReloaded$.next(); return this._allUsers; } @@ -147,42 +100,43 @@ export class UserService { } getRedUserById(id: string) { - return this._allRedUsers.find(u => u.userId === id); + return this._allRedUsers.find(u => u.id === id); } getUserById(id: string) { - return this._allUsers ? this._allUsers.find(u => u.userId === id) : this.getRedUserById(id); + return this._allUsers ? this._allUsers.find(u => u.id === id) : this.getRedUserById(id); } - getNameForId(userId: string) { - return this.getName(this.getUserById(userId)); + getNameForId(userId: string): string | undefined { + const user = this.getUserById(userId); + return user ? this.getName(user) : undefined; } - getName({ firstName, lastName, username }: User = {}) { + getName({ firstName, lastName, username }: UserWrapper) { return firstName && lastName ? `${firstName} ${lastName}` : username; } - isManager(user: User | UserWrapper = this.user): boolean { + isManager(user: UserWrapper = this._currentUser): boolean { return user.roles.indexOf('RED_MANAGER') >= 0; } - isUser(user: User | UserWrapper = this.user): boolean { + isUser(user: UserWrapper = this._currentUser): boolean { return user.roles?.indexOf('RED_USER') >= 0; } - isUserAdmin(user: User | UserWrapper = this.user): boolean { + isUserAdmin(user: UserWrapper = this._currentUser): boolean { return user.roles?.indexOf('RED_USER_ADMIN') >= 0; } - isAdmin(user: User | UserWrapper = this.user): boolean { + isAdmin(user: UserWrapper = this._currentUser): boolean { return user.roles?.indexOf('RED_ADMIN') >= 0; } - isActive(user: User | UserWrapper = this.user): boolean { + isActive(user: UserWrapper = this._currentUser): boolean { return user.roles?.length > 0; } - hasAnyRole(requiredRoles: string[], user: User | UserWrapper = this.user) { + hasAnyRole(requiredRoles: string[], user: UserWrapper = this._currentUser) { if (requiredRoles?.length > 0) { for (const role of requiredRoles) if (user.roles.indexOf(role) >= 0) return true; diff --git a/apps/red-ui/src/app/state/app-state.guard.ts b/apps/red-ui/src/app/state/app-state.guard.ts index aed5ee2ef..75bfccedf 100644 --- a/apps/red-ui/src/app/state/app-state.guard.ts +++ b/apps/red-ui/src/app/state/app-state.guard.ts @@ -14,11 +14,11 @@ export class AppStateGuard implements CanActivate { ) {} async canActivate(route: ActivatedRouteSnapshot): Promise { - if (this._userService.user.isUserAdmin) { + if (this._userService.currentUser.isUserAdmin) { await this._userService.loadUsersIfNecessary(); } - if (this._userService.user.isUser || this._userService.user.isAdmin) { + if (this._userService.currentUser.isUser || this._userService.currentUser.isAdmin) { await this._userService.loadUsersIfNecessary(); await this._appStateService.loadDossierTemplatesIfNecessary(); await this._appStateService.loadDictionaryDataIfNecessary(); From d7e4090f4d712dcda133c3d37f66417db527d41d Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 6 Aug 2021 17:30:42 +0300 Subject: [PATCH 4/8] move table column name to common lib --- .../downloads-list-screen.component.html | 2 +- .../downloads-list-screen.component.ts | 9 ++-- .../active-fields-listing.component.html | 15 +++--- .../active-fields-listing.component.scss | 2 +- .../screens/audit/audit-screen.component.html | 16 +++--- .../default-colors-screen.component.html | 8 +-- .../dictionary-listing-screen.component.html | 12 ++--- .../dictionary-listing-screen.component.scss | 2 +- ...r-attributes-listing-screen.component.html | 12 ++--- ...r-attributes-listing-screen.component.scss | 2 +- ...er-templates-listing-screen.component.html | 16 +++--- ...er-templates-listing-screen.component.scss | 2 +- ...e-attributes-listing-screen.component.html | 20 ++++---- ...e-attributes-listing-screen.component.scss | 2 +- .../screens/trash/trash-screen.component.html | 17 +++---- .../screens/trash/trash-screen.component.scss | 2 +- .../user-listing-screen.component.html | 10 ++-- .../user-listing-screen.component.scss | 2 +- .../dossier-listing-screen.component.html | 5 +- .../dossier-listing-screen.component.ts | 9 ++-- .../dossier-overview-screen.component.html | 2 +- .../dossier-overview-screen.component.scss | 2 +- .../dossier-overview-screen.component.ts | 18 +++---- .../search-screen.component.html | 5 +- .../search-screen/search-screen.component.ts | 27 ++++------ .../src/app/modules/icons/icons.module.ts | 2 - .../shared/base/base-listing.component.ts | 30 +++++------ .../table-col-name.component.html | 12 ----- .../table-col-name.component.scss | 51 ------------------- .../table-col-name.component.ts | 29 ----------- .../table-header/table-header.component.html | 6 +-- .../table-header/table-header.component.ts | 4 +- .../src/app/modules/shared/shared.module.ts | 3 +- .../src/assets/icons/general/sort-asc.svg | 11 ---- .../src/assets/icons/general/sort-desc.svg | 11 ---- apps/red-ui/src/assets/styles/red-tables.scss | 19 ------- .../src/assets/styles/red-text-styles.scss | 23 --------- 37 files changed, 123 insertions(+), 297 deletions(-) delete mode 100644 apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.html delete mode 100644 apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.scss delete mode 100644 apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts delete mode 100644 apps/red-ui/src/assets/icons/general/sort-asc.svg delete mode 100644 apps/red-ui/src/assets/icons/general/sort-desc.svg diff --git a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.html b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.html index cc8b6956e..34208c997 100644 --- a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.html +++ b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.html @@ -7,7 +7,7 @@ [bulkActions]="bulkActions" [hasEmptyColumn]="true" [selectionEnabled]="true" - [tableColConfigs]="tableColConfigs" + [tableColumnConfigs]="tableColConfigs" [tableHeaderLabel]="tableHeaderLabel" > diff --git a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts index c9b53783d..54a4f9de0 100644 --- a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts +++ b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts @@ -3,9 +3,8 @@ import { FileDownloadService } from '@upload-download/services/file-download.ser import { DownloadStatusWrapper } from '@upload-download/model/download-status.wrapper'; import { DownloadControllerService } from '@redaction/red-ui-http'; import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; -import { CircleButtonTypes } from '@iqser/common-ui'; +import { CircleButtonTypes, TableColumnConfig } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; @Component({ selector: 'redaction-downloads-list-screen', @@ -16,14 +15,14 @@ import { TableColConfig } from '@shared/components/table-col-name/table-col-name export class DownloadsListScreenComponent extends BaseListingComponent implements OnInit { readonly circleButtonTypes = CircleButtonTypes; readonly itemSize = 80; - readonly tableColConfigs: TableColConfig[] = [ + protected readonly _primaryKey = 'storageId'; + readonly tableHeaderLabel = _('downloads-list.table-header.title'); + readonly tableColConfigs: TableColumnConfig[] = [ { label: _('downloads-list.table-col-names.name') }, { label: _('downloads-list.table-col-names.size') }, { label: _('downloads-list.table-col-names.date') }, { label: _('downloads-list.table-col-names.status') } ]; - protected readonly _primaryKey = 'storageId'; - protected readonly _tableHeaderLabel = _('downloads-list.table-header.title'); constructor( readonly fileDownloadService: FileDownloadService, diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.html b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.html index e036c7165..162b8475f 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.html +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.html @@ -54,25 +54,22 @@
- + - + - + > - + >
diff --git a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.scss b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.scss index 300d530d8..7af2b2f30 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.scss +++ b/apps/red-ui/src/app/modules/admin/dialogs/file-attributes-csv-import-dialog/active-fields-listing/active-fields-listing.component.scss @@ -1,6 +1,6 @@ @import '../../../../../../assets/styles/variables'; -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding: 0 13px 0 10px !important; diff --git a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html index c72caa634..08f230fa5 100644 --- a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html @@ -87,23 +87,23 @@
- - + - + - + + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html index 13f4e0f18..0113d7aab 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.html @@ -27,16 +27,16 @@
- + > - + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html index 972b7fc2b..4bfce719e 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html @@ -60,23 +60,23 @@
- + > - + > - + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.scss index 950836853..18cdad7f0 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.scss @@ -15,7 +15,7 @@ } } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html index cfad15a4d..d3be62bb8 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.html @@ -62,21 +62,21 @@
- + > - + > - + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss index 2dcca5af9..2016db53d 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-attributes-listing/dossier-attributes-listing-screen.component.scss @@ -9,7 +9,7 @@ padding: 0 24px 0 10px; } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html index ed7af38bd..31131457a 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.html @@ -53,25 +53,25 @@
- - + - + - + + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.scss index 6fd6360f8..5d6ba5f25 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/dossier-template-listing/dossier-templates-listing-screen.component.scss @@ -5,7 +5,7 @@ padding: 0 24px 0 10px; } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html index 69db731d0..bf302b737 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.html @@ -71,35 +71,35 @@
- + > - + > - + > - + > - + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.scss index b4d8ef8d5..89eddfa02 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.scss @@ -9,7 +9,7 @@ padding: 0 24px 0 10px; } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.html index 4d1ada6e4..aafbcf221 100644 --- a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.html @@ -36,25 +36,22 @@
- - - + + - + + >
diff --git a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.scss index f2e81812c..41c1395e0 100644 --- a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.scss @@ -9,7 +9,7 @@ } } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html index 5ba720302..f1cd91a66 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.html @@ -62,16 +62,16 @@
- + - + - + > - +
diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.scss b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.scss index 4c9b955f9..40aa50b5f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.scss +++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.scss @@ -3,7 +3,7 @@ padding: 0 24px 0 10px; } - redaction-table-col-name::ng-deep { + iqser-table-column-name::ng-deep { > div { padding: 0 13px 0 10px !important; } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.html index 8f4cbdf44..42721ebdc 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.html @@ -8,7 +8,10 @@
- + [] = [ { label: _('dossier-listing.table-col-names.name'), withSort: true, @@ -70,8 +71,6 @@ export class DossierListingScreenComponent ]; dossiersChartData: DoughnutChartConfig[] = []; documentsChartData: DoughnutChartConfig[] = []; - protected readonly _primaryKey = 'numberOfMembers'; - protected _tableHeaderLabel = _('dossier-listing.table-header.title'); private _lastScrollPosition: number; @ViewChild('needsWorkTemplate', { read: TemplateRef, static: true }) private readonly _needsWorkTemplate: TemplateRef; diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html index 5e8fdf75b..7d43be517 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html @@ -39,7 +39,7 @@ diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.scss b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.scss index 2ada265a7..b28ed76bb 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.scss +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.scss @@ -9,7 +9,7 @@ padding: 0 24px 0 10px; } -redaction-table-col-name::ng-deep { +iqser-table-column-name::ng-deep { > div { padding-left: 10px !important; } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index e1a40cd1b..7d799cea7 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -21,7 +21,7 @@ import { DossierWrapper } from '@state/model/dossier.wrapper'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; import { AppConfigKey, AppConfigService } from '@app-config/app-config.service'; import { ActionConfig } from '@shared/components/page-header/models/action-config.model'; -import { CircleButtonTypes, keyChecker, NestedFilter } from '@iqser/common-ui'; +import { CircleButtonTypes, keyChecker, NestedFilter, TableColumnConfig } from '@iqser/common-ui'; import { BaseListingComponent, DefaultListingServices } from '@shared/base/base-listing.component'; import { LoadingService } from '@services/loading.service'; import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service'; @@ -30,7 +30,6 @@ import { UserPreferenceService } from '@services/user-preference.service'; import { workloadTranslations } from '../../translations/workload-translations'; import { fileStatusTranslations } from '../../translations/file-status-translations'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; import { annotationFilterChecker } from '@shared/components/filters/popup-filter/utils/filter-utils'; @Component({ @@ -42,13 +41,12 @@ export class DossierOverviewScreenComponent extends BaseListingComponent implements OnInit, OnDestroy, OnDetach, OnAttach { - private readonly _lastOpenedFileKey = 'Dossier-Recent-' + this.activeDossier.dossierId; - protected readonly _primaryKey = 'filename'; readonly circleButtonTypes = CircleButtonTypes; - protected readonly _tableHeaderLabel = _('dossier-overview.table-header.title'); - readonly itemSize = 80; - collapsedDetails = false; + protected readonly _primaryKey = 'filename'; + readonly tableHeaderLabel = _('dossier-overview.table-header.title'); + private readonly _lastOpenedFileKey = 'Dossier-Recent-' + this.activeDossier.dossierId; + readonly actionConfigs: ActionConfig[] = [ { label: this._translateService.instant('dossier-overview.header-actions.edit'), @@ -57,8 +55,7 @@ export class DossierOverviewScreenComponent hide: !this.permissionsService.isManager() } ]; - dossierAttributes: DossierAttributeWithValue[] = []; - readonly tableColConfigs: TableColConfig[] = [ + readonly tableColumnConfigs: TableColumnConfig[] = [ { label: _('dossier-overview.table-col-names.name'), withSort: true, @@ -90,6 +87,9 @@ export class DossierOverviewScreenComponent column: 'statusSort' } ]; + + collapsedDetails = false; + dossierAttributes: DossierAttributeWithValue[] = []; @ViewChild(DossierDetailsComponent, { static: false }) private readonly _dossierDetailsComponent: DossierDetailsComponent; private _lastScrollPosition: number; diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html index bce8ba1ad..c3f629476 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html @@ -10,7 +10,10 @@
- + implem readonly searchPositions = SearchPositions; readonly itemSize = 85; + protected readonly _primaryKey = 'filename'; + readonly tableHeaderLabel = _('search-screen.table-header'); + readonly tableColumnConfigs: TableColumnConfig[] = [ + { label: _('search-screen.cols.document') }, + { label: _('search-screen.cols.status') }, + { label: _('search-screen.cols.dossier') }, + { label: _('search-screen.cols.pages') } + ]; readonly search$ = new BehaviorSubject(null); readonly searchResults$: Observable = this.search$.asObservable().pipe( switchMap(query => this._search(query)), @@ -49,22 +56,6 @@ export class SearchScreenComponent extends BaseListingComponent implem tap(result => this.screenStateService.setEntities(result)), tap(() => this._loadingService.stop()) ); - readonly tableColConfigs: TableColConfig[] = [ - { - label: _('search-screen.cols.document') - }, - { - label: _('search-screen.cols.status') - }, - { - label: _('search-screen.cols.dossier') - }, - { - label: _('search-screen.cols.pages') - } - ]; - protected readonly _primaryKey = 'filename'; - protected readonly _tableHeaderLabel = _('search-screen.table-header'); constructor( protected readonly _injector: Injector, diff --git a/apps/red-ui/src/app/modules/icons/icons.module.ts b/apps/red-ui/src/app/modules/icons/icons.module.ts index 6401b72b9..7e2e39b94 100644 --- a/apps/red-ui/src/app/modules/icons/icons.module.ts +++ b/apps/red-ui/src/app/modules/icons/icons.module.ts @@ -70,8 +70,6 @@ export class IconsModule { 'report', 'search', 'secret', - 'sort-asc', - 'sort-desc', 'status', 'status-collapse', 'status-expand', diff --git a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts index 79ac0396b..4ace3e486 100644 --- a/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts +++ b/apps/red-ui/src/app/modules/shared/base/base-listing.component.ts @@ -1,5 +1,13 @@ import { Component, Injector, OnDestroy, ViewChild } from '@angular/core'; -import { AutoUnsubscribeComponent, FilterService, KeysOf, SearchService, SortingOrders, SortingService } from '@iqser/common-ui'; +import { + AutoUnsubscribeComponent, + FilterService, + KeysOf, + SearchService, + SortingOrders, + SortingService, + TableColumnConfig +} from '@iqser/common-ui'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { ScreenStateService } from '../services/screen-state.service'; import { combineLatest, Observable } from 'rxjs'; @@ -22,7 +30,7 @@ export abstract class BaseListingComponent extends AutoUnsubsc readonly sortedDisplayedEntities$ = this._sortedDisplayedEntities$; readonly noMatch$ = this._noMatch$; - protected readonly _tableHeaderLabel: string; + readonly tableColumnConfigs: TableColumnConfig[]; /** * Key used in the *trackBy* function with **ngFor* or **cdkVirtualFor* * and in the default sorting and as the search field @@ -36,22 +44,14 @@ export abstract class BaseListingComponent extends AutoUnsubsc setTimeout(() => this.setInitialConfig()); } - get tableHeaderLabel(): string { - if (!this._tableHeaderLabel) { - throw new Error('Not implemented'); - } - - return this._tableHeaderLabel; - } - get allEntities(): T[] { return this.screenStateService.allEntities; } private get _sortedDisplayedEntities$(): Observable { - return this.sortingService.sortingOption$.pipe( - switchMap(() => this.screenStateService.displayedEntities$.pipe(map(entities => this.sortingService.defaultSort(entities)))) - ); + const sort = entities => this.sortingService.defaultSort(entities); + const sortedEntities = () => this.screenStateService.displayedEntities$.pipe(map(sort)); + return this.sortingService.sortingOption$.pipe(switchMap(sortedEntities)); } private get _noMatch$(): Observable { @@ -69,10 +69,6 @@ export abstract class BaseListingComponent extends AutoUnsubsc this.searchService.setSearchKey(this._primaryKey); } - ngOnDestroy(): void { - super.ngOnDestroy(); - } - canBulkDelete$(hasPermission = true): Observable { return this.screenStateService.areSomeEntitiesSelected$.pipe( map(areSomeEntitiesSelected => areSomeEntitiesSelected && hasPermission), diff --git a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.html b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.html deleted file mode 100644 index da89f5a0d..000000000 --- a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
- - {{ label }} - - - -
- - -
-
-
diff --git a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.scss b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.scss deleted file mode 100644 index b8d3cb571..000000000 --- a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.scss +++ /dev/null @@ -1,51 +0,0 @@ -@import '../../../../../assets/styles/variables'; - -:host { - display: flex; - height: 30px; - flex: 1; - - > div { - align-items: center; - display: flex; - width: 100%; - line-height: 11px; - padding: 0 24px; - - > mat-icon { - width: 10px; - height: 10px; - margin-right: 6px; - opacity: 0.7; - - &:not(:first-child) { - margin-left: 6px; - } - } - } - - .flex-end { - min-width: 58px; - } - - .sort-arrows-container { - display: none; - color: $primary; - margin-left: 8px; - - mat-icon { - height: 14px; - width: 6px; - } - } - - &:hover { - .sort-arrows-container { - display: initial; - } - } - - .sort-arrows-container.force-display { - display: initial; - } -} diff --git a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts b/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts deleted file mode 100644 index 39b6985ac..000000000 --- a/apps/red-ui/src/app/modules/shared/components/table-col-name/table-col-name.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, Optional } from '@angular/core'; -import { KeysOf, SortingService } from '@iqser/common-ui'; - -export interface TableColConfig { - readonly column?: string; - readonly label: string; - readonly withSort?: boolean; - readonly class?: string; - readonly leftIcon?: string; - readonly rightIcon?: string; - readonly rightIconTooltip?: string; -} - -@Component({ - selector: 'redaction-table-col-name', - templateUrl: './table-col-name.component.html', - styleUrls: ['./table-col-name.component.scss'] -}) -export class TableColNameComponent { - @Input() column: KeysOf; - @Input() label: string; - @Input() withSort = false; - @Input() class: string; - @Input() leftIcon: string; - @Input() rightIcon: string; - @Input() rightIconTooltip: string; - - constructor(@Optional() readonly sortingService: SortingService) {} -} diff --git a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.html b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.html index bf7465f3f..a7adb19b3 100644 --- a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.html +++ b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.html @@ -18,8 +18,8 @@
- + >
diff --git a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts index ff2b6bd94..06ffcd60b 100644 --- a/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/table-header/table-header.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input, TemplateRef } from '@angular/core'; -import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component'; import { ScreenStateService } from '@shared/services/screen-state.service'; +import { TableColumnConfig } from '@iqser/common-ui'; @Component({ selector: 'redaction-table-header', @@ -10,7 +10,7 @@ import { ScreenStateService } from '@shared/services/screen-state.service'; }) export class TableHeaderComponent { @Input() tableHeaderLabel: string; - @Input() tableColConfigs: TableColConfig[]; + @Input() tableColumnConfigs: TableColumnConfig[]; @Input() hasEmptyColumn = false; @Input() selectionEnabled = false; @Input() bulkActions: TemplateRef; diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts index ff6820f6c..35ebd9184 100644 --- a/apps/red-ui/src/app/modules/shared/shared.module.ts +++ b/apps/red-ui/src/app/modules/shared/shared.module.ts @@ -4,7 +4,6 @@ import { FullPageLoadingIndicatorComponent } from './components/full-page-loadin import { TranslateModule } from '@ngx-translate/core'; import { InitialsAvatarComponent } from './components/initials-avatar/initials-avatar.component'; import { ScrollingModule } from '@angular/cdk/scrolling'; -import { TableColNameComponent } from './components/table-col-name/table-col-name.component'; import { PaginationComponent } from './components/pagination/pagination.component'; import { FileDownloadBtnComponent } from './components/buttons/file-download-btn/file-download-btn.component'; import { UserButtonComponent } from './components/buttons/user-button/user-button.component'; @@ -41,7 +40,7 @@ const buttons = [FileDownloadBtnComponent, UserButtonComponent]; const components = [ FullPageLoadingIndicatorComponent, InitialsAvatarComponent, - TableColNameComponent, + TableHeaderComponent, PaginationComponent, InputWithActionComponent, AnnotationIconComponent, diff --git a/apps/red-ui/src/assets/icons/general/sort-asc.svg b/apps/red-ui/src/assets/icons/general/sort-asc.svg deleted file mode 100644 index 812184785..000000000 --- a/apps/red-ui/src/assets/icons/general/sort-asc.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/apps/red-ui/src/assets/icons/general/sort-desc.svg b/apps/red-ui/src/assets/icons/general/sort-desc.svg deleted file mode 100644 index f9211f8d1..000000000 --- a/apps/red-ui/src/assets/icons/general/sort-desc.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/apps/red-ui/src/assets/styles/red-tables.scss b/apps/red-ui/src/assets/styles/red-tables.scss index f0ec2d474..c745443f2 100644 --- a/apps/red-ui/src/assets/styles/red-tables.scss +++ b/apps/red-ui/src/assets/styles/red-tables.scss @@ -12,25 +12,6 @@ } } -.table-header { - display: flex; - border-bottom: 1px solid $separator; - - &.no-data:not([synced='true']) { - padding-left: 30px; - } - - redaction-table-col-name:last-of-type { - > div { - padding-right: 13px; - } - } - - &.selection-enabled redaction-table-col-name > div { - padding-left: 10px; - } -} - cdk-virtual-scroll-viewport { height: calc(100vh - 50px - 31px - 111px); overflow-y: hidden !important; diff --git a/apps/red-ui/src/assets/styles/red-text-styles.scss b/apps/red-ui/src/assets/styles/red-text-styles.scss index 6da1afefc..52c509f6a 100644 --- a/apps/red-ui/src/assets/styles/red-text-styles.scss +++ b/apps/red-ui/src/assets/styles/red-text-styles.scss @@ -55,29 +55,6 @@ pre { padding: 0 20px; } -.all-caps-label { - text-transform: uppercase; - opacity: 0.7; - font-size: 11px; - font-weight: 600; - letter-spacing: 0; - line-height: 14px; - transition: opacity 0.2s; - - &.cancel { - cursor: pointer; - - &:hover { - opacity: 1; - } - - &.disabled { - opacity: 0.3; - cursor: default; - } - } -} - .small-label { opacity: 0.7; font-size: 11px; From 49f737b19e6d948b189128dcfa06070f24c4119f Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 6 Aug 2021 18:27:09 +0300 Subject: [PATCH 5/8] update common lib --- apps/red-ui/src/assets/i18n/de.json | 2 +- apps/red-ui/src/assets/i18n/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index 6ce14af7a..19b17b1e8 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -1016,7 +1016,7 @@ "form": { "forgot-password": "" }, - "subtitle": "", + "subtitle": " ", "title": "" }, "subtitle": "Mit SMTP (Simple Mail Transfer Protocol) können Sie Ihre E-Mails über die angegebenen Servereinstellungen senden.", diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index a7ce2794a..befe97755 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1028,7 +1028,7 @@ "form": { "forgot-password": "Show Forgot password link on Login screen" }, - "subtitle": "", + "subtitle": " ", "title": "General Configurations" }, "subtitle": "SMTP (Simple Mail Transfer Protocol) enables you to send your emails through the specified server settings.", From b7208a085d0a143e3c0f5c9636234e3f250f0026 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Sat, 7 Aug 2021 02:28:11 +0300 Subject: [PATCH 6/8] remove duplicated methods --- .../base-screen/base-screen.component.html | 35 ++++---- .../base-screen/base-screen.component.ts | 88 ++++++------------- .../admin-side-nav.component.html | 7 +- .../admin-side-nav.component.ts | 69 +++++++++------ .../screens/audit/audit-screen.component.html | 2 +- .../screens/audit/audit-screen.component.ts | 11 +-- .../digital-signature-screen.component.html | 5 +- .../digital-signature-screen.component.ts | 10 +-- ...er-templates-listing-screen.component.html | 9 +- ...sier-templates-listing-screen.component.ts | 17 ++-- .../general-config-screen.component.html | 2 +- .../general-config-screen.component.ts | 19 ++-- .../license-information-screen.component.html | 2 +- .../license-information-screen.component.ts | 28 +++--- .../user-listing-screen.component.html | 6 +- .../user-listing-screen.component.ts | 24 ++--- .../src/app/modules/auth/red-role.guard.ts | 2 +- .../dossier-details.component.html | 2 +- .../dossier-details.component.ts | 3 +- .../dossier-listing-actions.component.html | 4 +- .../dossier-listing-actions.component.ts | 6 +- .../file-actions/file-actions.component.html | 2 +- .../file-actions/file-actions.component.ts | 8 +- .../team-members/team-members.component.html | 2 +- .../team-members/team-members.component.ts | 5 +- .../edit-dossier-team-members.component.ts | 12 +-- .../dossier-listing-screen.component.html | 2 +- .../dossier-listing-screen.component.ts | 17 ++-- .../dossier-overview-screen.component.ts | 31 +++---- .../user-button/user-button.component.html | 2 +- .../user-button/user-button.component.ts | 3 +- .../initials-avatar.component.ts | 2 +- .../services/file-download.service.ts | 10 +-- .../src/app/services/permissions.service.ts | 18 +--- apps/red-ui/src/app/services/user.service.ts | 21 +---- apps/red-ui/src/app/state/app-state.guard.ts | 2 +- 36 files changed, 219 insertions(+), 269 deletions(-) diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.html b/apps/red-ui/src/app/components/base-screen/base-screen.component.html index d25b81ec6..dd0b594a5 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.html +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.html @@ -1,7 +1,7 @@
- -