diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 13948d94a..415f14fa1 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -268,7 +268,7 @@ export class FilePreviewScreenComponent ngOnDetach() { this._viewerHeaderService.resetCompareButtons(); - this._viewerHeaderService.enableLoadAllAnnotations(); + this._viewerHeaderService.enableLoadAllAnnotations(); // Reset the button state (since the viewer is reused between files) super.ngOnDetach(); this._changeRef.markForCheck(); } @@ -690,12 +690,12 @@ export class FilePreviewScreenComponent .subscribe(); this.addActiveScreenSubscription = this._readableRedactionsService.active$.pipe(switchMap(() => this.updateViewMode())).subscribe(); - this.addActiveScreenSubscription = this._viewModeService.viewMode$ + this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this._documentViewer.loaded$, this.state.file$]) .pipe( - tap(viewMode => + tap(([viewMode]) => viewMode === 'STANDARD' || viewMode === 'TEXT_HIGHLIGHTS' - ? this._viewerHeaderService.enableRotationButtons() - : this._viewerHeaderService.disableRotationButtons(), + ? this._viewerHeaderService.updateRotationButtons(true) + : this._viewerHeaderService.updateRotationButtons(false), ), ) .subscribe(); diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts index f4b0088be..aab9e08fc 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core'; import { IHeaderElement, RotationTypes } from '@red/domain'; import { HeaderElements, HeaderElementType } from '../../file-preview/utils/constants'; import { TranslateService } from '@ngx-translate/core'; -import { BASE_HREF_FN, BaseHrefFn, IqserPermissionsService } from '@iqser/common-ui'; +import { BASE_HREF_FN, BaseHrefFn } from '@iqser/common-ui'; import { TooltipsService } from './tooltips.service'; import { PageRotationService } from './page-rotation.service'; import { PdfViewer } from './pdf-viewer.service'; @@ -13,8 +13,8 @@ import { UserPreferenceService } from '@users/user-preference.service'; import { fromEvent, Observable, Subject } from 'rxjs'; import { ViewerEvent, VisibilityChangedEvent } from '../utils/types'; import { ReadableRedactionsService } from './readable-redactions.service'; -import { ROLES } from '@users/roles'; import { filter, map, tap } from 'rxjs/operators'; +import { PermissionsService } from '@services/permissions.service'; const divider: IHeaderElement = { type: 'divider', @@ -23,6 +23,7 @@ const divider: IHeaderElement = { @Injectable() export class ViewerHeaderService { readonly events$: Observable; + toggleLoadAnnotations$: Observable; #buttons: Map; readonly #config = new Map([ [HeaderElements.SHAPE_TOOL_GROUP_BUTTON, true], @@ -38,7 +39,6 @@ export class ViewerHeaderService { ]); #docBeforeCompare: Blob; readonly #events$ = new Subject(); - toggleLoadAnnotations$: Observable; constructor( @Inject(BASE_HREF_FN) private readonly _convertPath: BaseHrefFn, @@ -50,7 +50,7 @@ export class ViewerHeaderService { private readonly _tooltipsService: TooltipsService, private readonly _readableRedactionsService: ReadableRedactionsService, private readonly _userPreferenceService: UserPreferenceService, - private readonly _iqserPermissionsService: IqserPermissionsService, + private readonly _permissionsService: PermissionsService, ) { this.events$ = this.#events$.asObservable(); } @@ -169,11 +169,6 @@ export class ViewerHeaderService { }; } - #discardRotation(): void { - this._rotationService.discardRotation(); - this.disable(ROTATION_ACTION_BUTTONS); - } - private get _rotateRight(): IHeaderElement { return { type: 'actionButton', @@ -304,22 +299,27 @@ export class ViewerHeaderService { }); } - enableRotationButtons(): void { - if (this._iqserPermissionsService.has(ROLES.files.rotatePage)) { + updateRotationButtons(show: boolean): void { + const { dossierId, fileId } = this._pdf; + const file = this._filesMapService.get(dossierId, fileId); + if (show && this._permissionsService.canRotatePage(file)) { this.enable(ROTATION_BUTTONS); + } else { + this.disable(ROTATION_BUTTONS); + this.#discardRotation(); } } - disableRotationButtons(): void { - this.disable(ROTATION_BUTTONS); - this.#discardRotation(); - } - resetCompareButtons() { this.disable([HeaderElements.CLOSE_COMPARE_BUTTON]); this.enable([HeaderElements.COMPARE_BUTTON]); } + #discardRotation(): void { + this._rotationService.discardRotation(); + this.disable(ROTATION_ACTION_BUTTONS); + } + #toggleRotationActionButtons() { if (this._rotationService.hasRotations) { this.enable(ROTATION_ACTION_BUTTONS); diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index 725837e62..a955fb06f 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -349,6 +349,10 @@ export class PermissionsService { ); } + canRotatePage(file: File) { + return this.isFileAssignee(file) && this._iqserPermissionsService.has(ROLES.files.rotatePage); + } + canDownloadRedactedFile() { return this._iqserPermissionsService.has(ROLES.files.processDownload); } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 07317e72b..c81f4bc32 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,7 +1,7 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dev-04.iqser.cloud/redaction-gateway-v1", + "API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1", "APP_NAME": "RedactManager", "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", @@ -11,7 +11,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dev-04.iqser.cloud/auth/realms/redaction", + "OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",