code cleanup and license removal

This commit is contained in:
Timo Bejan 2020-11-14 02:59:01 +02:00
parent d199af2b39
commit 1ad5c5e788
10 changed files with 19 additions and 39 deletions

View File

@ -7,7 +7,6 @@ export enum AppConfigKey {
OAUTH_URL = 'OAUTH_URL',
OAUTH_CLIENT_ID = 'OAUTH_CLIENT_ID',
API_URL = 'API_URL',
PDFTRON_LICENSE = 'PDFTRON_LICENSE',
ADMIN_CONTACT_NAME = 'ADMIN_CONTACT_NAME',
ADMIN_CONTACT_URL = 'ADMIN_CONTACT_URL'
}

View File

@ -19,7 +19,7 @@
<div class="red-input-group" *ngIf="!isDictionaryRequest">
<label translate="manual-annotation.dialog.content.legalBasis"></label>
<input type="text" [value]="redactionForm.get('reason').value.legalBasis" disabled />
<input type="text" [value]="redactionForm.get('reason').value?.legalBasis" disabled />
</div>
<div class="red-input-group">

View File

@ -32,7 +32,6 @@
[fileData]="displayData"
[fileStatus]="appStateService.activeFile"
(annotationSelected)="handleAnnotationSelected($event)"
(keyUp)="handleKeyEvent($event)"
(manualAnnotationRequested)="openManualRedactionDialog($event)"
(pageChanged)="viewerPageChanged($event)"
(viewerReady)="viewerReady($event)"

View File

@ -406,9 +406,9 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy {
if (!this.redactedView) {
this._annotationDrawService.drawAnnotations(
this.instance,
this.annotations.filter((item) => (annotationIdToDraw ? item.id === annotationIdToDraw : true)),
!!annotationIdToDraw
this.annotations.filter((item) => (annotationIdToDraw ? item.id === annotationIdToDraw : true))
);
document.querySelectorAll('iframe')[0].click();
}
});
}

View File

@ -1,5 +1,5 @@
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { AppConfigKey, AppConfigService } from '../../../app-config/app-config.service';
import { AppConfigService } from '../../../app-config/app-config.service';
import { ManualRedactionEntry, Rectangle } from '@redaction/red-ui-http';
import WebViewer, { WebViewerInstance } from '@pdftron/webviewer';
import { TranslateService } from '@ngx-translate/core';
@ -10,6 +10,7 @@ import { AnnotationWrapper } from '../model/annotation.wrapper';
import { ManualAnnotationService } from '../service/manual-annotation.service';
import { FileStatusWrapper } from '../model/file-status.wrapper';
import { KeycloakService } from 'keycloak-angular';
import { environment } from '../../../../environments/environment';
export interface ViewerState {
displayMode?: any;
@ -37,7 +38,6 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
@Output() annotationSelected = new EventEmitter<string>();
@Output() manualAnnotationRequested = new EventEmitter<ManualRedactionEntryWrapper>();
@Output() pageChanged = new EventEmitter<number>();
@Output() keyUp = new EventEmitter<KeyboardEvent>();
@Output() viewerReady = new EventEmitter<WebViewerInstance>();
@ -74,10 +74,9 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}
private _loadViewer() {
const license = this._appConfigService.getConfig(AppConfigKey.PDFTRON_LICENSE);
WebViewer(
{
licenseKey: license,
licenseKey: environment.licenseKey ? atob(environment.licenseKey) : null,
isReadOnly: true,
path: '/assets/wv-resources'
},
@ -95,24 +94,12 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}
});
// instance.docViewer.on('pageComplete', (p) => {
// this._ngZone.run(() => this.pageChanged.emit(p));
// });
instance.docViewer.on('pageComplete', (p) => {
this._ngZone.run(() => this.pageChanged.emit(p));
});
instance.docViewer.on('documentLoaded', this._documentLoaded);
// instance.docViewer.on('keyDown', ($event) => {
// if ($event.key.startsWith('Arrow')) {
// $event.preventDefault();
// }
// });
//
// instance.docViewer.on('keyUp', ($event) => {
// if ($event.key.startsWith('Arrow')) {
// this.keyUp.emit($event);
// }
// });
// initialize state
this._restoreState(null, instance);

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { WebViewerInstance } from '@pdftron/webviewer';
import { ManualRedactionEntry, Rectangle } from '@redaction/red-ui-http';
import { Rectangle } from '@redaction/red-ui-http';
import { hexToRgb } from '../../../utils/functions';
import { AppStateService } from '../../../state/app-state.service';
import { AnnotationWrapper } from '../model/annotation.wrapper';
@ -11,22 +11,18 @@ import { AnnotationWrapper } from '../model/annotation.wrapper';
export class AnnotationDrawService {
constructor(private readonly _appStateService: AppStateService) {}
public drawAnnotations(activeViewer: WebViewerInstance, annotationWrappers: AnnotationWrapper[], redraw: boolean = false) {
public drawAnnotations(activeViewer: WebViewerInstance, annotationWrappers: AnnotationWrapper[]) {
const annotations = [];
annotationWrappers.forEach((annotation) => {
annotations.push(this.drawAnnotation(activeViewer, annotation));
annotations.push(this.computeAnnotation(activeViewer, annotation));
});
const annotationManager = activeViewer.annotManager;
annotationManager.addAnnotations(annotations, true);
if (redraw) {
annotations.forEach((annotation) => {
annotationManager.redrawAnnotation(annotation);
});
}
annotationManager.drawAnnotationsFromList(annotations);
}
public drawAnnotation(activeViewer: WebViewerInstance, annotationWrapper: AnnotationWrapper) {
public computeAnnotation(activeViewer: WebViewerInstance, annotationWrapper: AnnotationWrapper) {
const pageNumber = annotationWrapper.pageNumber;
const highlight = new activeViewer.Annotations.TextHighlightAnnotation();
highlight.PageNumber = pageNumber;

View File

@ -1,6 +1,5 @@
{
"OAUTH_URL": "https://redkc-staging.iqser.cloud/auth/realms/redaction",
"OAUTH_CLIENT_ID": "redaction",
"API_URL": "https://timo-redaction-dev.iqser.cloud",
"PDFTRON_LICENSE": ""
"API_URL": "https://timo-redaction-dev.iqser.cloud"
}

View File

@ -1,3 +1,4 @@
export const environment = {
production: true
production: true,
licenseKey: undefined
};

View File

@ -3,7 +3,8 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
production: false,
licenseKey: undefined
};
/*

View File

@ -3,12 +3,10 @@
OAUTH_CLIENT_ID="${OAUTH_CLIENT_ID:-gin-client}"
OAUTH_URL="${OAUTH_URL:-https://keycloak-dev.iqser.cloud/auth/realms/dev}"
API_URL="${API_URL:-}"
PDFTRON_LICENSE="${PDFTRON_LICENSE:-}"
echo '{
"OAUTH_CLIENT_ID":"'"$OAUTH_CLIENT_ID"'",
"OAUTH_URL":"'"$OAUTH_URL"'",
"PDFTRON_LICENSE":"'"$PDFTRON_LICENSE"'",
"API_URL":"'"$API_URL"'"
}' > /usr/share/nginx/html/assets/config/config.json