Pull request #237: Redaction log changes
Merge in RED/ui from redaction-log-changes to master * commit 'f26cbbaa1c4c6ff76c5c263b13383734a801f5b3': minor fixes and - RED-1758 OCR Fix - RED-1593 more work on integrating backend redaction log redaction log from backend pt. 1
This commit is contained in:
commit
9d5c531492
@ -185,7 +185,7 @@
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
"code": 100,
|
||||
"code": 140,
|
||||
"tabWidth": 4,
|
||||
"ignorePattern": "^import .*"
|
||||
}
|
||||
|
||||
@ -34,9 +34,8 @@ export class AnnotationPermissions {
|
||||
const permissions: AnnotationPermissions = new AnnotationPermissions();
|
||||
|
||||
permissions.canUndo =
|
||||
annotation.isUndoableSuperType &&
|
||||
(annotation.userId === user.id ||
|
||||
(annotation.userId && isApprover && !annotation.isSuggestion));
|
||||
(!isApprover && annotation.isSuggestion) ||
|
||||
(isApprover && annotation.isUndoableActionForApprover);
|
||||
|
||||
permissions.canForceRedaction = annotation.isSkipped && !permissions.canUndo;
|
||||
|
||||
|
||||
@ -6,10 +6,10 @@ export class AnnotationWrapper {
|
||||
| 'add-dictionary'
|
||||
| 'remove-dictionary'
|
||||
| 'remove-only-here'
|
||||
| 'change-legal-basis'
|
||||
| 'suggestion-change-legal-basis'
|
||||
| 'suggestion-add-dictionary'
|
||||
| 'suggestion-force-redaction'
|
||||
| 'change-legal-basis'
|
||||
| 'suggestion-remove-dictionary'
|
||||
| 'suggestion-add'
|
||||
| 'suggestion-remove'
|
||||
@ -29,7 +29,6 @@ export class AnnotationWrapper {
|
||||
shortContent: string;
|
||||
content: string;
|
||||
value: string;
|
||||
userId: string;
|
||||
typeLabel: string;
|
||||
pageNumber: number;
|
||||
hint: boolean;
|
||||
@ -41,6 +40,8 @@ export class AnnotationWrapper {
|
||||
legalBasis: string;
|
||||
legalBasisChangeValue?: string;
|
||||
|
||||
manual?: boolean;
|
||||
|
||||
image?: boolean;
|
||||
force?: boolean;
|
||||
|
||||
@ -54,21 +55,8 @@ export class AnnotationWrapper {
|
||||
|
||||
constructor() {}
|
||||
|
||||
get isUndoableSuperType() {
|
||||
return (
|
||||
this.superType === 'add-dictionary' ||
|
||||
this.superType === 'remove-dictionary' ||
|
||||
this.superType === 'suggestion-add-dictionary' ||
|
||||
this.superType === 'suggestion-force-redaction' ||
|
||||
this.superType === 'suggestion-remove-dictionary' ||
|
||||
this.superType === 'suggestion-change-legal-basis' ||
|
||||
this.superType === 'suggestion-add' ||
|
||||
this.superType === 'change-legal-basis' ||
|
||||
this.superType === 'suggestion-remove' ||
|
||||
this.superType === 'skipped' ||
|
||||
this.superType === 'redaction' ||
|
||||
this.superType === 'manual-redaction'
|
||||
);
|
||||
get isUndoableActionForApprover() {
|
||||
return this.manual;
|
||||
}
|
||||
|
||||
get isChangeLogRemoved() {
|
||||
@ -219,7 +207,6 @@ export class AnnotationWrapper {
|
||||
annotationWrapper._origin = redactionLogEntry;
|
||||
|
||||
annotationWrapper.annotationId = redactionLogEntry.id;
|
||||
annotationWrapper.force = redactionLogEntry.force;
|
||||
annotationWrapper.isChangeLogEntry = redactionLogEntry.isChangeLogEntry;
|
||||
annotationWrapper.changeLogType = redactionLogEntry.changeLogType;
|
||||
annotationWrapper.redaction = redactionLogEntry.redacted;
|
||||
@ -233,14 +220,14 @@ export class AnnotationWrapper {
|
||||
annotationWrapper.textBefore = redactionLogEntry.textBefore;
|
||||
annotationWrapper.textAfter = redactionLogEntry.textAfter;
|
||||
annotationWrapper.dictionaryOperation = redactionLogEntry.dictionaryEntry;
|
||||
annotationWrapper.userId = redactionLogEntry.userId;
|
||||
annotationWrapper.image = redactionLogEntry.image;
|
||||
annotationWrapper.legalBasisChangeValue = redactionLogEntry.legalBasisChangeValue;
|
||||
annotationWrapper.comments = redactionLogEntry.comments || [];
|
||||
annotationWrapper.legalBasis = redactionLogEntry.legalBasis;
|
||||
annotationWrapper.manual = redactionLogEntry.manual;
|
||||
|
||||
this._createContent(annotationWrapper, redactionLogEntry);
|
||||
this._setSuperType(annotationWrapper, redactionLogEntry);
|
||||
this._handleSkippedState(annotationWrapper, redactionLogEntry);
|
||||
this._handleRecommendations(annotationWrapper, redactionLogEntry);
|
||||
annotationWrapper.typeLabel = 'annotation-type.' + annotationWrapper.superType;
|
||||
|
||||
@ -262,25 +249,35 @@ export class AnnotationWrapper {
|
||||
annotationWrapper: AnnotationWrapper,
|
||||
redactionLogEntryWrapper: RedactionLogEntryWrapper
|
||||
) {
|
||||
if (redactionLogEntryWrapper.legalBasisChangeValue) {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-change-legal-basis';
|
||||
} else if (redactionLogEntryWrapper.actionPendingReanalysis) {
|
||||
annotationWrapper.superType = 'change-legal-basis';
|
||||
if (redactionLogEntryWrapper.recommendation) {
|
||||
if (redactionLogEntryWrapper.redacted) {
|
||||
annotationWrapper.superType = 'recommendation';
|
||||
} else {
|
||||
annotationWrapper.superType = 'redaction';
|
||||
annotationWrapper.superType = 'skipped';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.recommendation) {
|
||||
if (redactionLogEntryWrapper.redacted) {
|
||||
annotationWrapper.superType = 'recommendation';
|
||||
return;
|
||||
if (redactionLogEntryWrapper.manualRedactionType === 'FORCE_REDACT') {
|
||||
annotationWrapper.force = true;
|
||||
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-force-redaction';
|
||||
} else if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
annotationWrapper.superType = 'redaction';
|
||||
} else {
|
||||
annotationWrapper.superType = 'skipped';
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.manualRedactionType === 'LEGAL_BASIS_CHANGE') {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-change-legal-basis';
|
||||
} else {
|
||||
annotationWrapper.superType = 'redaction';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.status === 'DECLINED') {
|
||||
@ -295,45 +292,53 @@ export class AnnotationWrapper {
|
||||
if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
annotationWrapper.superType = 'add-dictionary';
|
||||
}
|
||||
} else {
|
||||
if (redactionLogEntryWrapper.redacted) {
|
||||
if (redactionLogEntryWrapper.force) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.manualRedactionType === 'ADD') {
|
||||
if (redactionLogEntryWrapper.dictionaryEntry) {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-add-dictionary';
|
||||
}
|
||||
if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
annotationWrapper.superType = 'add-dictionary';
|
||||
}
|
||||
} else {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-add';
|
||||
}
|
||||
if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
annotationWrapper.superType = 'manual-redaction';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.redacted) {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
if (redactionLogEntryWrapper.dictionaryEntry) {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.status === 'REQUESTED'
|
||||
? 'suggestion-add'
|
||||
: 'redaction';
|
||||
} else if (redactionLogEntryWrapper.type === 'manual') {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.status === 'REQUESTED'
|
||||
? 'suggestion-add'
|
||||
: 'manual-redaction';
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'suggestion-add-dictionary'
|
||||
: 'suggestion-remove-dictionary';
|
||||
} else {
|
||||
if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
if (redactionLogEntryWrapper.dictionaryEntry) {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'suggestion-add-dictionary'
|
||||
: 'suggestion-remove-dictionary';
|
||||
} else {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'suggestion-add'
|
||||
: 'suggestion-remove';
|
||||
}
|
||||
}
|
||||
if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
if (redactionLogEntryWrapper.dictionaryEntry) {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'add-dictionary'
|
||||
: 'remove-dictionary';
|
||||
} else {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'manual-redaction'
|
||||
: 'remove-only-here';
|
||||
}
|
||||
}
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'suggestion-add'
|
||||
: 'suggestion-remove';
|
||||
}
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.status === 'APPROVED') {
|
||||
if (redactionLogEntryWrapper.dictionaryEntry) {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'add-dictionary'
|
||||
: 'remove-dictionary';
|
||||
} else {
|
||||
annotationWrapper.superType =
|
||||
redactionLogEntryWrapper.manualRedactionType === 'ADD'
|
||||
? 'manual-redaction'
|
||||
: 'remove-only-here';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,30 +352,6 @@ export class AnnotationWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static _handleSkippedState(
|
||||
annotationWrapper: AnnotationWrapper,
|
||||
redactionLogEntryWrapper: RedactionLogEntryWrapper
|
||||
) {
|
||||
if (annotationWrapper.superType !== 'skipped') return;
|
||||
|
||||
if (!annotationWrapper.userId) {
|
||||
if (
|
||||
redactionLogEntryWrapper.manualRedactionType === 'REMOVE' ||
|
||||
redactionLogEntryWrapper.manualRedactionType === 'UNDO'
|
||||
) {
|
||||
annotationWrapper.superType = 'pending-analysis';
|
||||
return;
|
||||
}
|
||||
} else if (redactionLogEntryWrapper.status === 'REQUESTED') {
|
||||
annotationWrapper.superType = 'suggestion-force-redaction';
|
||||
return;
|
||||
}
|
||||
|
||||
if (redactionLogEntryWrapper.actionPendingReanalysis) {
|
||||
annotationWrapper.superType = 'pending-analysis';
|
||||
}
|
||||
}
|
||||
|
||||
private static _createContent(
|
||||
annotationWrapper: AnnotationWrapper,
|
||||
entry: RedactionLogEntryWrapper
|
||||
|
||||
@ -1,11 +1,4 @@
|
||||
import {
|
||||
IdRemoval,
|
||||
ManualRedactionEntry,
|
||||
ManualRedactions,
|
||||
RedactionChangeLog,
|
||||
RedactionLog,
|
||||
ViewedPages
|
||||
} from '@redaction/red-ui-http';
|
||||
import { RedactionChangeLog, RedactionLog, ViewedPages } from '@redaction/red-ui-http';
|
||||
import { FileStatusWrapper } from './file-status.wrapper';
|
||||
import { UserWrapper } from '@services/user.service';
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
@ -24,7 +17,6 @@ export class FileDataModel {
|
||||
public fileData: Blob,
|
||||
public redactionLog: RedactionLog,
|
||||
public redactionChangeLog: RedactionChangeLog,
|
||||
public manualRedactions: ManualRedactions,
|
||||
public viewedPages?: ViewedPages
|
||||
) {}
|
||||
|
||||
@ -34,7 +26,7 @@ export class FileDataModel {
|
||||
viewMode: ViewMode,
|
||||
areDevFeaturesEnabled: boolean
|
||||
): AnnotationData {
|
||||
const entries: RedactionLogEntryWrapper[] = this._convertData(dictionaryData);
|
||||
const entries: RedactionLogEntryWrapper[] = this._convertData();
|
||||
let allAnnotations = entries
|
||||
.map(entry => AnnotationWrapper.fromData(entry))
|
||||
.filter(ann => !this.fileStatus.excludedPages.includes(ann.pageNumber));
|
||||
@ -59,9 +51,7 @@ export class FileDataModel {
|
||||
};
|
||||
}
|
||||
|
||||
private _convertData(dictionaryData: {
|
||||
[p: string]: TypeValueWrapper;
|
||||
}): RedactionLogEntryWrapper[] {
|
||||
private _convertData(): RedactionLogEntryWrapper[] {
|
||||
let result: RedactionLogEntryWrapper[] = [];
|
||||
|
||||
this.redactionChangeLog?.redactionLogEntry?.forEach(changeLogEntry => {
|
||||
@ -74,14 +64,10 @@ export class FileDataModel {
|
||||
return;
|
||||
}
|
||||
|
||||
const redactionLogEntryWrapper: RedactionLogEntryWrapper = {
|
||||
actionPendingReanalysis: false
|
||||
};
|
||||
const redactionLogEntryWrapper: RedactionLogEntryWrapper = {};
|
||||
|
||||
Object.assign(redactionLogEntryWrapper, changeLogEntry);
|
||||
|
||||
redactionLogEntryWrapper.comments =
|
||||
this.manualRedactions.comments[redactionLogEntryWrapper.id];
|
||||
redactionLogEntryWrapper.isChangeLogEntry = true;
|
||||
redactionLogEntryWrapper.changeLogType = changeLogEntry.changeType;
|
||||
redactionLogEntryWrapper.id = 'changed-log-removed-' + redactionLogEntryWrapper.id;
|
||||
@ -89,10 +75,16 @@ export class FileDataModel {
|
||||
}
|
||||
});
|
||||
|
||||
const reasonAnnotationIds = [];
|
||||
this.redactionLog.redactionLogEntry?.forEach(redactionLogEntry => {
|
||||
// false positive entries from the redaction-log need to be skipped
|
||||
if (redactionLogEntry.type?.toLowerCase() === 'false_positive') {
|
||||
return;
|
||||
if (
|
||||
redactionLogEntry.manual &&
|
||||
(redactionLogEntry.status === 'APPROVED' ||
|
||||
redactionLogEntry.status === 'REQUESTED')
|
||||
) {
|
||||
// for dictionary entries -> I.E accepted recommendations or false positives,
|
||||
// check reason
|
||||
reasonAnnotationIds.push(redactionLogEntry.reason);
|
||||
}
|
||||
|
||||
const existingChangeLogEntry = this.redactionChangeLog?.redactionLogEntry?.find(
|
||||
@ -100,208 +92,23 @@ export class FileDataModel {
|
||||
);
|
||||
|
||||
// copy the redactionLog Entry
|
||||
const redactionLogEntryWrapper: RedactionLogEntryWrapper = {
|
||||
actionPendingReanalysis: false
|
||||
};
|
||||
const redactionLogEntryWrapper: RedactionLogEntryWrapper = {};
|
||||
Object.assign(redactionLogEntryWrapper, redactionLogEntry);
|
||||
redactionLogEntryWrapper.comments =
|
||||
this.manualRedactions.comments[redactionLogEntryWrapper.id];
|
||||
redactionLogEntryWrapper.isChangeLogEntry = !!existingChangeLogEntry;
|
||||
redactionLogEntryWrapper.changeLogType = 'ADDED';
|
||||
result.push(redactionLogEntryWrapper);
|
||||
});
|
||||
|
||||
this.manualRedactions.forceRedactions?.forEach(forceRedaction => {
|
||||
const relevantRedactionLogEntry = result.find(r => r.id === forceRedaction.id);
|
||||
|
||||
if (forceRedaction.status === 'DECLINED') {
|
||||
relevantRedactionLogEntry.status = 'DECLINED';
|
||||
relevantRedactionLogEntry.userId = forceRedaction.user;
|
||||
relevantRedactionLogEntry.dictionaryEntry = false;
|
||||
relevantRedactionLogEntry.force = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// an entry for this request already exists in the redactionLog
|
||||
if (relevantRedactionLogEntry) {
|
||||
relevantRedactionLogEntry.userId = forceRedaction.user;
|
||||
relevantRedactionLogEntry.dictionaryEntry = false;
|
||||
relevantRedactionLogEntry.force = true;
|
||||
|
||||
// if statuses differ
|
||||
if (
|
||||
!forceRedaction.processedDate ||
|
||||
forceRedaction.status !== relevantRedactionLogEntry.status
|
||||
) {
|
||||
relevantRedactionLogEntry.actionPendingReanalysis = true;
|
||||
relevantRedactionLogEntry.status = forceRedaction.status;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.manualRedactions.entriesToAdd?.forEach(manual => {
|
||||
const markedAsReasonRedactionLogEntry = result.find(r => r.id === manual.reason);
|
||||
|
||||
const relevantRedactionLogEntry = result.find(r => r.id === manual.id);
|
||||
|
||||
// a redaction-log entry is marked as a reason for another entry - hide it
|
||||
if (markedAsReasonRedactionLogEntry) {
|
||||
if (
|
||||
!this._hasBeenProcessed(manual) ||
|
||||
!['APPROVED', 'DECLINED'].includes(manual.status)
|
||||
) {
|
||||
markedAsReasonRedactionLogEntry.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
// an entry for this request already exists in the redactionLog
|
||||
if (relevantRedactionLogEntry) {
|
||||
if (relevantRedactionLogEntry.status === 'DECLINED') {
|
||||
relevantRedactionLogEntry.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
relevantRedactionLogEntry.userId = manual.user;
|
||||
relevantRedactionLogEntry.dictionaryEntry = manual.addToDictionary;
|
||||
|
||||
// if statuses differ
|
||||
if (relevantRedactionLogEntry.status !== manual.status) {
|
||||
relevantRedactionLogEntry.actionPendingReanalysis = true;
|
||||
relevantRedactionLogEntry.status = manual.status;
|
||||
}
|
||||
} else {
|
||||
// dictionary modifying requests that have been processed already updated
|
||||
// the dictionary and should not be drawn
|
||||
if (manual.addToDictionary && this._hasBeenProcessed(manual)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// no entry exists in the redaction log - create it
|
||||
const dictionary = dictionaryData[manual.type];
|
||||
|
||||
const redactionLogEntryWrapper: RedactionLogEntryWrapper = {};
|
||||
|
||||
redactionLogEntryWrapper.id = manual.id;
|
||||
redactionLogEntryWrapper.dictionaryEntry = manual.addToDictionary;
|
||||
redactionLogEntryWrapper.legalBasis = manual.legalBasis;
|
||||
redactionLogEntryWrapper.positions = manual.positions;
|
||||
redactionLogEntryWrapper.reason = manual.reason;
|
||||
redactionLogEntryWrapper.status = manual.status;
|
||||
redactionLogEntryWrapper.type = manual.type;
|
||||
redactionLogEntryWrapper.userId = manual.user;
|
||||
redactionLogEntryWrapper.value = manual.value;
|
||||
redactionLogEntryWrapper.redacted = !dictionary.hint;
|
||||
redactionLogEntryWrapper.hint = dictionary.hint;
|
||||
redactionLogEntryWrapper.manualRedactionType = 'ADD';
|
||||
redactionLogEntryWrapper.manual = true;
|
||||
redactionLogEntryWrapper.comments =
|
||||
this.manualRedactions.comments[redactionLogEntryWrapper.id];
|
||||
if (markedAsReasonRedactionLogEntry) {
|
||||
// cleanup reason if the reason is another annotationId
|
||||
// it is not needed for drawing
|
||||
redactionLogEntryWrapper.reason = null;
|
||||
}
|
||||
|
||||
result.push(redactionLogEntryWrapper);
|
||||
}
|
||||
});
|
||||
|
||||
this.manualRedactions.idsToRemove?.forEach(idToRemove => {
|
||||
const relevantRedactionLogEntry = result.find(r => r.id === idToRemove.id);
|
||||
|
||||
if (!relevantRedactionLogEntry) {
|
||||
// idRemove for something that doesn't exist - skip
|
||||
return;
|
||||
} else {
|
||||
relevantRedactionLogEntry.userId = idToRemove.user;
|
||||
relevantRedactionLogEntry.dictionaryEntry = idToRemove.removeFromDictionary;
|
||||
|
||||
// if statuses differ
|
||||
if (relevantRedactionLogEntry.status !== idToRemove.status) {
|
||||
relevantRedactionLogEntry.actionPendingReanalysis = true;
|
||||
relevantRedactionLogEntry.status = idToRemove.status;
|
||||
}
|
||||
|
||||
if (this._hasBeenProcessed(idToRemove)) {
|
||||
if (idToRemove.status === 'DECLINED') {
|
||||
relevantRedactionLogEntry.status = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.manualRedactions.legalBasisChanges?.forEach(legalBasisChange => {
|
||||
const relevantRedactionLogEntry = result.find(r => r.id === legalBasisChange.id);
|
||||
|
||||
if (!relevantRedactionLogEntry) {
|
||||
// legalBasisChanges for something that doesn't exist - skip
|
||||
return;
|
||||
} else {
|
||||
relevantRedactionLogEntry.legalBasisChangeValue = legalBasisChange.legalBasis;
|
||||
relevantRedactionLogEntry.userId = legalBasisChange.user;
|
||||
// if statuses differ
|
||||
if (relevantRedactionLogEntry.status !== legalBasisChange.status) {
|
||||
relevantRedactionLogEntry.actionPendingReanalysis = true;
|
||||
relevantRedactionLogEntry.status = legalBasisChange.status;
|
||||
}
|
||||
|
||||
if (this._hasBeenProcessed(legalBasisChange)) {
|
||||
if (legalBasisChange.status === 'DECLINED') {
|
||||
relevantRedactionLogEntry.status = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
result = result.filter(r => reasonAnnotationIds.indexOf(r.id) < 0);
|
||||
|
||||
result.forEach(redactionLogEntry => {
|
||||
redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis;
|
||||
|
||||
if (redactionLogEntry.manual) {
|
||||
if (redactionLogEntry.manualRedactionType === 'ADD') {
|
||||
const foundManualEntry = this.manualRedactions.entriesToAdd.find(
|
||||
me => me.id === redactionLogEntry.id
|
||||
);
|
||||
|
||||
// ADD has been undone - not yet processed
|
||||
if (!foundManualEntry) {
|
||||
redactionLogEntry.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (redactionLogEntry.manualRedactionType === 'LEGAL_BASIS_CHANGE') {
|
||||
const legalBasisChanges = this.manualRedactions.legalBasisChanges.find(
|
||||
me => me.id === redactionLogEntry.id
|
||||
);
|
||||
// ADD has been undone - not yet processed
|
||||
if (!legalBasisChanges) {
|
||||
redactionLogEntry.manual = false;
|
||||
redactionLogEntry.manualRedactionType = 'UNDO';
|
||||
redactionLogEntry.status = null;
|
||||
}
|
||||
}
|
||||
if (redactionLogEntry.manualRedactionType === 'REMOVE') {
|
||||
const foundManualEntry = this.manualRedactions.idsToRemove.find(
|
||||
me => me.id === redactionLogEntry.id
|
||||
);
|
||||
// REMOVE has been undone - not yet processed
|
||||
if (!foundManualEntry) {
|
||||
redactionLogEntry.manual = false;
|
||||
redactionLogEntry.manualRedactionType = 'UNDO';
|
||||
redactionLogEntry.status = null;
|
||||
}
|
||||
}
|
||||
if (redactionLogEntry.id === '96a9fad412ac0ccc340c9ee53f97986b') {
|
||||
redactionLogEntry.dictionaryEntry = true;
|
||||
}
|
||||
|
||||
redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis;
|
||||
});
|
||||
|
||||
// remove undone entriesToAdd and idsToRemove
|
||||
result = result.filter(redactionLogEntry => !redactionLogEntry.hidden);
|
||||
return result;
|
||||
}
|
||||
|
||||
private _hasBeenProcessed(entry: ManualRedactionEntry | IdRemoval): boolean {
|
||||
return !entry.processedDate
|
||||
? false
|
||||
: new Date(entry.processedDate).getTime() <
|
||||
new Date(this.fileStatus.lastProcessed).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ export interface RedactionLogEntryWrapper {
|
||||
legalBasis?: string;
|
||||
legalBasisMapping?: Array<LegalBasisMapping>;
|
||||
manual?: boolean;
|
||||
manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE';
|
||||
manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE' | 'FORCE_REDACT';
|
||||
matchedRule?: number;
|
||||
positions?: Array<Rectangle>;
|
||||
reason?: string;
|
||||
@ -20,14 +20,11 @@ export interface RedactionLogEntryWrapper {
|
||||
textBefore?: string;
|
||||
type?: string;
|
||||
value?: string;
|
||||
force?: boolean;
|
||||
image?: boolean;
|
||||
|
||||
recommendation?: boolean;
|
||||
recommendationAnnotationId?: string;
|
||||
|
||||
actionPendingReanalysis?: boolean;
|
||||
|
||||
hidden?: boolean;
|
||||
|
||||
userId?: string;
|
||||
|
||||
@ -27,7 +27,10 @@ export class RedRoleGuard implements CanActivate {
|
||||
if (
|
||||
this._userService.user.isUserAdmin &&
|
||||
!this._userService.user.isAdmin &&
|
||||
!state.url.startsWith('/main/admin/users')
|
||||
!(
|
||||
state.url.startsWith('/main/admin/users') ||
|
||||
state.url.startsWith('/main/my-profile')
|
||||
)
|
||||
) {
|
||||
this._router.navigate(['/main/admin/users']);
|
||||
obs.next(false);
|
||||
|
||||
@ -115,7 +115,7 @@
|
||||
|
||||
<redaction-circle-button
|
||||
(action)="ocrFile($event)"
|
||||
*ngIf="canOcr && screen === 'dossier-overview'"
|
||||
*ngIf="canOcr"
|
||||
[tooltipPosition]="tooltipPosition"
|
||||
[type]="buttonType"
|
||||
icon="red:ocr"
|
||||
|
||||
@ -78,6 +78,8 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
@ViewChild(PdfViewerComponent) viewerComponent: PdfViewerComponent;
|
||||
private _instance: WebViewerInstance;
|
||||
private _lastPage: string;
|
||||
private _reloadFileOnReanalysis = false;
|
||||
|
||||
@ViewChild('fileWorkloadComponent') private _workloadComponent: FileWorkloadComponent;
|
||||
|
||||
constructor(
|
||||
@ -254,7 +256,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
}
|
||||
|
||||
async ngOnAttach(previousRoute: ActivatedRouteSnapshot) {
|
||||
console.log('on attach');
|
||||
if (!this.permissionsService.canOpenFile(this.appStateService.activeFile)) {
|
||||
await this._router.navigate(['/main/dossiers/' + this.dossierId]);
|
||||
return;
|
||||
@ -501,6 +502,11 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
this.viewDocumentInfo = false;
|
||||
return;
|
||||
|
||||
case 'ocr-file':
|
||||
this._updateCanPerformActions();
|
||||
this._reloadFileOnReanalysis = true;
|
||||
return;
|
||||
|
||||
default:
|
||||
this._updateCanPerformActions();
|
||||
}
|
||||
@ -605,7 +611,8 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
this.fileReanalysedSubscription = this.appStateService.fileReanalysed.subscribe(
|
||||
async (fileStatus: FileStatusWrapper) => {
|
||||
if (fileStatus.fileId === this.fileId) {
|
||||
await this._loadFileData(true);
|
||||
await this._loadFileData(!this._reloadFileOnReanalysis);
|
||||
this._reloadFileOnReanalysis = false;
|
||||
this.viewReady = true;
|
||||
this._updateCanPerformActions();
|
||||
this._cleanupAndRedrawManualAnnotations();
|
||||
@ -633,7 +640,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
this.fileData.redactionLog = fileData.redactionLog;
|
||||
this.fileData.redactionChangeLog = fileData.redactionChangeLog;
|
||||
this.fileData.fileStatus = fileData.fileStatus;
|
||||
this.fileData.manualRedactions = fileData.manualRedactions;
|
||||
this.rebuildFilters(true);
|
||||
} else {
|
||||
this.fileData = fileData;
|
||||
@ -657,9 +663,10 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
/* Get the documentElement (<html>) to display the page in fullscreen */
|
||||
|
||||
private _cleanupAndRedrawManualAnnotations() {
|
||||
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe(manualRedactions => {
|
||||
this.fileData.manualRedactions = manualRedactions;
|
||||
this.rebuildFilters();
|
||||
this._fileDownloadService
|
||||
.loadActiveFileRedactionLogPreview()
|
||||
.subscribe(redactionLogPreview => {
|
||||
this.fileData.redactionLog = redactionLogPreview;
|
||||
this._annotationDrawService.drawAnnotations(
|
||||
this._instance,
|
||||
this.annotationData.allAnnotations,
|
||||
@ -674,8 +681,10 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
|
||||
const currentPageAnnotationIds = currentPageAnnotations.map(a => a.id);
|
||||
this.fileData.fileStatus = await this.appStateService.reloadActiveFile();
|
||||
|
||||
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe(manualRedactions => {
|
||||
this.fileData.manualRedactions = manualRedactions;
|
||||
this._fileDownloadService
|
||||
.loadActiveFileRedactionLogPreview()
|
||||
.subscribe(redactionLogPreview => {
|
||||
this.fileData.redactionLog = redactionLogPreview;
|
||||
this.rebuildFilters();
|
||||
if (this.viewMode === 'STANDARD') {
|
||||
currentPageAnnotationIds.forEach(id => {
|
||||
|
||||
@ -17,14 +17,14 @@ export class PdfViewerDataService {
|
||||
constructor(
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _man: ManualRedactionControllerService,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _manualRedactionControllerService: ManualRedactionControllerService,
|
||||
private readonly _redactionLogControllerService: RedactionLogControllerService,
|
||||
private readonly _viewedPagesControllerService: ViewedPagesControllerService
|
||||
) {}
|
||||
|
||||
loadActiveFileManualAnnotations() {
|
||||
return this._manualRedactionControllerService.getManualRedaction(
|
||||
loadActiveFileRedactionLogPreview() {
|
||||
return this._redactionLogControllerService.getRedactionLogPreview(
|
||||
this._appStateService.activeDossierId,
|
||||
this._appStateService.activeFileId
|
||||
);
|
||||
@ -34,25 +34,20 @@ export class PdfViewerDataService {
|
||||
const dossierId = this._appStateService.activeDossierId;
|
||||
const fileId = this._appStateService.activeFileId;
|
||||
|
||||
this._man.getManualRedaction(dossierId, fileId).subscribe();
|
||||
|
||||
const file$ = this.downloadOriginalFile(this._appStateService.activeFile);
|
||||
const reactionLog$ = this._redactionLogControllerService
|
||||
.getRedactionLog(dossierId, fileId)
|
||||
.getRedactionLogPreview(dossierId, fileId)
|
||||
.pipe(catchError(() => of({})));
|
||||
const redactionChangeLog$ = this._redactionLogControllerService
|
||||
.getRedactionChangeLog(dossierId, fileId)
|
||||
.pipe(catchError(() => of({})));
|
||||
const manualRedactions$ = this._manualRedactionControllerService
|
||||
.getManualRedaction(dossierId, fileId)
|
||||
.pipe(catchError(() => of({})));
|
||||
const viewedPages$ = this.getViewedPagesForActiveFile();
|
||||
|
||||
return forkJoin([
|
||||
file$,
|
||||
reactionLog$,
|
||||
redactionChangeLog$,
|
||||
manualRedactions$,
|
||||
viewedPages$
|
||||
]).pipe(map(data => new FileDataModel(this._appStateService.activeFile, ...data)));
|
||||
return forkJoin([file$, reactionLog$, redactionChangeLog$, viewedPages$]).pipe(
|
||||
map(data => new FileDataModel(this._appStateService.activeFile, ...data))
|
||||
);
|
||||
}
|
||||
|
||||
getViewedPagesForActiveFile() {
|
||||
|
||||
@ -29,7 +29,7 @@ export class FileDownloadService {
|
||||
) {
|
||||
interval(5000).subscribe(() => {
|
||||
if (_permissionsService.isUser()) {
|
||||
this.getDownloadStatus().subscribe(() => {});
|
||||
this.getDownloadStatus().subscribe(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -33,8 +33,8 @@ export class FileUploadService {
|
||||
private readonly _uploadControllerService: UploadControllerService,
|
||||
private readonly _dialogService: UploadDownloadDialogService
|
||||
) {
|
||||
this._uploadControllerService.defaultHeaders =
|
||||
this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true' );
|
||||
this._uploadControllerService.defaultHeaders =
|
||||
this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true');
|
||||
interval(2500).subscribe(() => {
|
||||
this._handleUploads();
|
||||
});
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
*/ /* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http';
|
||||
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||
import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@ -22,7 +21,7 @@ import { DossierAttributesConfig } from '../model/dossierAttributesConfig';
|
||||
import { DossierAttributesReq } from '../model/dossierAttributesReq';
|
||||
import { DossierAttributesRes } from '../model/dossierAttributesRes';
|
||||
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { BASE_PATH } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@ -11,15 +11,14 @@
|
||||
*/ /* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http';
|
||||
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||
import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Dossier } from '../model/dossier';
|
||||
import { DossierRequest } from '../model/dossierRequest';
|
||||
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { BASE_PATH } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
*/ /* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http';
|
||||
import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
|
||||
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { BASE_PATH } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@ -201,6 +201,82 @@ export class RedactionLogControllerService {
|
||||
}
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Gets the redaction log preview
|
||||
* None
|
||||
* @param dossierId dossierId
|
||||
* @param fileId fileId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getRedactionLogPreview(
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<RedactionLog>;
|
||||
public getRedactionLogPreview(
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<RedactionLog>>;
|
||||
public getRedactionLogPreview(
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<RedactionLog>>;
|
||||
public getRedactionLogPreview(
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false
|
||||
): Observable<any> {
|
||||
if (dossierId === null || dossierId === undefined) {
|
||||
throw new Error(
|
||||
'Required parameter dossierId was null or undefined when calling getRedactionLogPreview.'
|
||||
);
|
||||
}
|
||||
|
||||
if (fileId === null || fileId === undefined) {
|
||||
throw new Error(
|
||||
'Required parameter fileId was null or undefined when calling getRedactionLogPreview.'
|
||||
);
|
||||
}
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
// authentication (RED-OAUTH) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken =
|
||||
typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = ['application/json'];
|
||||
const httpHeaderAcceptSelected: string | undefined =
|
||||
this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.request<RedactionLog>(
|
||||
'get',
|
||||
`${this.basePath}/sectionGrid/${encodeURIComponent(
|
||||
String(dossierId)
|
||||
)}/${encodeURIComponent(String(fileId))}/preview`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the section grid for a fileId
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user