code cleanup

This commit is contained in:
Timo 2021-04-21 08:33:19 +03:00
parent eaf16142f0
commit bef172e3ab
12 changed files with 148 additions and 129 deletions

View File

@ -95,11 +95,17 @@ export class AnnotationWrapper {
}
get isImage() {
return this.dictionary === 'image' || this.image;
return this.dictionary?.toLowerCase() === 'image' || this.image;
}
get isOCR() {
return this.dictionary?.toLowerCase() === 'ocr';
}
get isFalsePositive() {
return this.dictionary === 'false_positive' && (this.superType === 'skipped' || this.superType === 'hint' || this.superType === 'redaction');
return (
this.dictionary?.toLowerCase() === 'false_positive' && (this.superType === 'skipped' || this.superType === 'hint' || this.superType === 'redaction')
);
}
get isManualRedaction() {
@ -218,7 +224,7 @@ export class AnnotationWrapper {
return;
}
if (annotationWrapper.dictionary === 'false_positive') {
if (annotationWrapper.dictionary?.toLowerCase() === 'false_positive') {
if (redactionLogEntryWrapper.status === 'REQUESTED') {
annotationWrapper.superType = 'suggestion-add-dictionary';
}

View File

@ -86,7 +86,7 @@ export class FileDataModel {
this.redactionLog.redactionLogEntry.forEach((redactionLogEntry) => {
// false positive entries from the redaction-log need to be skipped
if (redactionLogEntry.type === 'false_positive') {
if (redactionLogEntry.type?.toLowerCase() === 'false_positive') {
return;
}

View File

@ -43,7 +43,7 @@ export class FileAttributesListingScreenComponent extends BaseListingComponent<F
this.allEntities = response?.fileAttributeConfigs || [];
} catch (e) {
} finally {
this._executeSearch();
this._executeSearchImmediately();
this.viewReady = true;
this.loading = false;
}

View File

@ -33,7 +33,7 @@ export class RuleSetsListingScreenComponent extends BaseListingComponent<RuleSet
public loadRuleSetsData() {
this._appStateService.reset();
this.allEntities = this._appStateService.ruleSets;
this._executeSearch();
this._executeSearchImmediately();
this._loadRuleSetStats();
}

View File

@ -69,7 +69,7 @@ export class UserListingScreenComponent extends BaseListingComponent<User> imple
private async _loadData() {
this.allEntities = (await this._userControllerService.getAllUsers({ requestId: new Date().toISOString() }).toPromise()).users;
this._executeSearch();
this._executeSearchImmediately();
this._computeStats();
this.viewReady = true;
this.loading = false;

View File

@ -81,7 +81,7 @@ export class AnnotationDrawService {
highlight.ReadOnly = true;
// change log entries are drawn lighter
highlight.Opacity = annotationWrapper.isChangeLogRemoved ? 0.2 : 1;
highlight.Hidden = annotationWrapper.isChangeLogRemoved || (hideSkipped && annotationWrapper.isSkipped);
highlight.Hidden = annotationWrapper.isChangeLogRemoved || (hideSkipped && annotationWrapper.isSkipped) || annotationWrapper.isOCR;
highlight.setCustomData('redaction', annotationWrapper.isRedacted);
highlight.setCustomData('skipped', annotationWrapper.isSkipped);

View File

@ -85,6 +85,10 @@ export class BaseListingComponent<T = any> {
@debounce(200)
protected _executeSearch() {
this._executeSearchImmediately();
}
protected _executeSearchImmediately() {
this.displayedEntities = (this.filters.length ? this.filteredEntities : this.allEntities).filter((entity) =>
this._searchField(entity).toLowerCase().includes(this.searchForm.get('query').value.toLowerCase())
);

View File

@ -0,0 +1,22 @@
import { Pipe, PipeTransform } from '@angular/core';
import { orderBy } from 'lodash';
@Pipe({ name: 'sortBy' })
export class SortByPipe implements PipeTransform {
transform<T>(value: T[], order = '', column: string = ''): T[] {
if (!value || order === '' || !order) {
return value;
} // no array
if (!column || column === '') {
if (order === 'asc') {
return value.sort();
} else {
return value.sort().reverse();
}
} // sort 1d array
if (value.length <= 1) {
return value;
} // array with only one item
return orderBy(value, [column], [order]);
}
}

View File

@ -13,7 +13,6 @@ import { IconButtonComponent } from './components/buttons/icon-button/icon-butto
import { UserButtonComponent } from './components/buttons/user-button/user-button.component';
import { MatConfigModule } from '../mat-config/mat-config.module';
import { SearchInputComponent } from './components/search-input/search-input.component';
import { NgpSortModule } from 'ngp-sort-pipe';
import { IconsModule } from '../icons/icons.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AnnotationIconComponent } from './components/annotation-icon/annotation-icon.component';
@ -28,6 +27,7 @@ import { ConfirmationDialogComponent } from './dialogs/confirmation-dialog/confi
import { FilterComponent } from './components/filter/filter.component';
import { EmptyStateComponent } from './components/empty-state/empty-state.component';
import { BaseListingComponent } from './base/base-listing.component';
import { SortByPipe } from './components/sort-pipe/sort-by.pipe';
const buttons = [ChevronButtonComponent, CircleButtonComponent, FileDownloadBtnComponent, IconButtonComponent, UserButtonComponent];
@ -46,13 +46,14 @@ const components = [
ConfirmationDialogComponent,
EmptyStateComponent,
BaseListingComponent,
SortByPipe,
...buttons
];
const utils = [HumanizePipe, SyncWidthDirective, HasScrollbarDirective];
const modules = [MatConfigModule, TranslateModule, ScrollingModule, NgpSortModule, IconsModule, FormsModule, ReactiveFormsModule];
const modules = [MatConfigModule, TranslateModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule];
@NgModule({
declarations: [...components, ...utils],

View File

@ -13,7 +13,7 @@ import { StatusOverlayService } from './services/status-overlay.service';
import { FileDropOverlayService } from './services/file-drop-overlay.service';
@NgModule({
imports: [CommonModule, SharedModule, NgxDropzoneModule, OverlayModule],
imports: [CommonModule, SharedModule, OverlayModule],
declarations: [FileDropComponent, UploadStatusOverlay, OverwriteFilesDialogComponent],
entryComponents: [FileDropComponent, UploadStatusOverlay],
providers: [UploadDownloadDialogService, FileUploadService, FileDownloadService, StatusOverlayService, FileDropOverlayService],

View File

@ -1,109 +1,107 @@
{
"name": "redaction",
"version": "1.0.74",
"private": true,
"license": "MIT",
"scripts": {
"affected": "nx affected",
"affected:apps": "nx affected:apps",
"affected:build": "nx affected:build",
"affected:dep-graph": "nx affected:dep-graph",
"affected:e2e": "nx affected:e2e",
"affected:libs": "nx affected:libs",
"affected:lint": "nx affected:lint",
"affected:test": "nx affected:test",
"build": "nx build",
"build-lint-all": "ng lint --project=red-ui-http --fix && ng build --project=red-ui-http && ng lint --project=red-ui --fix && ng build --project=red-ui --prod",
"dep-graph": "nx dep-graph",
"e2e": "nx e2e",
"format": "nx format:write",
"format:check": "nx format:check",
"format:write": "nx format:write",
"help": "nx help",
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
"lint": "nx workspace-lint && nx lint",
"nx": "nx",
"start": "nx serve",
"test": "nx test",
"update": "nx migrate latest",
"workspace-schematic": "nx workspace-schematic"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged && ng lint --project=red-ui-http && ng lint --project=red-ui --fix"
"name": "redaction",
"version": "1.0.74",
"private": true,
"license": "MIT",
"scripts": {
"affected": "nx affected",
"affected:apps": "nx affected:apps",
"affected:build": "nx affected:build",
"affected:dep-graph": "nx affected:dep-graph",
"affected:e2e": "nx affected:e2e",
"affected:libs": "nx affected:libs",
"affected:lint": "nx affected:lint",
"affected:test": "nx affected:test",
"build": "nx build",
"build-lint-all": "ng lint --project=red-ui-http --fix && ng build --project=red-ui-http && ng lint --project=red-ui --fix && ng build --project=red-ui --prod",
"dep-graph": "nx dep-graph",
"e2e": "nx e2e",
"format": "nx format:write",
"format:check": "nx format:check",
"format:write": "nx format:write",
"help": "nx help",
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
"lint": "nx workspace-lint && nx lint",
"nx": "nx",
"start": "nx serve",
"test": "nx test",
"update": "nx migrate latest",
"workspace-schematic": "nx workspace-schematic"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged && ng lint --project=red-ui-http && ng lint --project=red-ui --fix"
}
},
"dependencies": {
"@angular/animations": "~11.0.1",
"@angular/cdk": "~11.0.1",
"@angular/common": "~11.0.1",
"@angular/compiler": "~11.0.1",
"@angular/core": "~11.0.1",
"@angular/forms": "~11.0.1",
"@angular/material": "~11.0.1",
"@angular/material-moment-adapter": "^11.0.2",
"@angular/platform-browser": "~11.0.1",
"@angular/platform-browser-dynamic": "~11.0.1",
"@angular/router": "~11.0.1",
"@angular/service-worker": "~11.0.1",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@nrwl/angular": "^10.2.0",
"@pdftron/webviewer": "7.3.0-20210223",
"@swimlane/ngx-charts": "^17.0.0",
"file-saver": "^2.0.2",
"jwt-decode": "^3.0.0",
"keycloak-angular": "^8.0.1",
"keycloak-js": "10.0.2",
"lint-staged": "^10.5.0",
"ng2-ace-editor": "^0.3.9",
"ngx-color-picker": "^10.1.0",
"ngx-toastr": "^13.0.0",
"papaparse": "^5.3.0",
"rxjs": "~6.6.0",
"scroll-into-view-if-needed": "^2.2.26",
"streamsaver": "^2.0.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",
"@angular-devkit/build-ng-packagr": "~0.1002.0",
"@angular/cli": "~11.0.2",
"@angular/compiler": "~11.0.1",
"@angular/compiler-cli": "~11.0.1",
"@angular/language-service": "~11.0.2",
"@nrwl/cypress": "10.2.0",
"@nrwl/jest": "10.2.0",
"@nrwl/workspace": "10.2.0",
"@types/cypress": "^1.1.3",
"@types/jasmine": "~3.6.0",
"@types/jest": "26.0.8",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"cypress": "^5.6.0",
"cypress-file-upload": "^4.1.1",
"cypress-keycloak": "^1.5.0",
"cypress-keycloak-commands": "^1.2.0",
"cypress-localstorage-commands": "^1.2.4",
"dotenv": "6.2.0",
"eslint": "6.8.0",
"google-translate-api-browser": "^1.1.71",
"husky": "^4.3.0",
"jest": "26.2.2",
"jest-preset-angular": "8.2.1",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"ng-packagr": "^10.1.2",
"prettier": "2.0.4",
"pretty-quick": "^3.1.0",
"superagent": "^6.1.0",
"superagent-promise": "^1.1.0",
"ts-jest": "26.1.4",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
},
"dependencies": {
"@angular/animations": "~11.0.1",
"@angular/cdk": "~11.0.1",
"@angular/common": "~11.0.1",
"@angular/compiler": "~11.0.1",
"@angular/core": "~11.0.1",
"@angular/forms": "~11.0.1",
"@angular/material": "~11.0.1",
"@angular/material-moment-adapter": "^11.0.2",
"@angular/platform-browser": "~11.0.1",
"@angular/platform-browser-dynamic": "~11.0.1",
"@angular/router": "~11.0.1",
"@angular/service-worker": "~11.0.1",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@nrwl/angular": "^10.2.0",
"@pdftron/webviewer": "7.3.0-20210223",
"@swimlane/ngx-charts": "^17.0.0",
"file-saver": "^2.0.2",
"jwt-decode": "^3.0.0",
"keycloak-angular": "^8.0.1",
"keycloak-js": "10.0.2",
"lint-staged": "^10.5.0",
"ng2-ace-editor": "^0.3.9",
"ngp-sort-pipe": "^0.0.4",
"ngx-color-picker": "^10.1.0",
"ngx-dropzone": "^2.2.2",
"ngx-toastr": "^13.0.0",
"papaparse": "^5.3.0",
"rxjs": "~6.6.0",
"scroll-into-view-if-needed": "^2.2.26",
"streamsaver": "^2.0.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",
"@angular-devkit/build-ng-packagr": "~0.1002.0",
"@angular/cli": "~11.0.2",
"@angular/compiler": "~11.0.1",
"@angular/compiler-cli": "~11.0.1",
"@angular/language-service": "~11.0.2",
"@nrwl/cypress": "10.2.0",
"@nrwl/jest": "10.2.0",
"@nrwl/workspace": "10.2.0",
"@types/cypress": "^1.1.3",
"@types/jasmine": "~3.6.0",
"@types/jest": "26.0.8",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"cypress": "^5.6.0",
"cypress-file-upload": "^4.1.1",
"cypress-keycloak": "^1.5.0",
"cypress-keycloak-commands": "^1.2.0",
"cypress-localstorage-commands": "^1.2.4",
"dotenv": "6.2.0",
"eslint": "6.8.0",
"google-translate-api-browser": "^1.1.71",
"husky": "^4.3.0",
"jest": "26.2.2",
"jest-preset-angular": "8.2.1",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"ng-packagr": "^10.1.2",
"prettier": "2.0.4",
"pretty-quick": "^3.1.0",
"superagent": "^6.1.0",
"superagent-promise": "^1.1.0",
"ts-jest": "26.1.4",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}

View File

@ -8601,11 +8601,6 @@ ng2-ace-editor@^0.3.9:
ace-builds "^1.4.2"
brace "^0.11.1"
ngp-sort-pipe@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/ngp-sort-pipe/-/ngp-sort-pipe-0.0.4.tgz#9d70caff0ee34f32f2ea1df16c7333b72df72b56"
integrity sha512-tqyxsjb1mKROKhQB7oIcKaDSamPaNNwQ7norqxnOLRNjMdvG0b+XofIAZQpa/cG+SN6lmdCjtzOvwhOjHzpHmA==
ngx-color-picker@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/ngx-color-picker/-/ngx-color-picker-10.1.0.tgz#19a6993a74bb3553024623b20ca6ebffd2c50f9c"
@ -8613,13 +8608,6 @@ ngx-color-picker@^10.1.0:
dependencies:
tslib "^2.0.0"
ngx-dropzone@^2.2.2:
version "2.3.0"
resolved "https://registry.yarnpkg.com/ngx-dropzone/-/ngx-dropzone-2.3.0.tgz#fb34bceb0d8ad3c00c314b957d095018d15c5fe9"
integrity sha512-Mhsu6MW1yJRxLPRPbwal7y18trokU9josTD8GDb8wFRmaCd/N+dJeMDXn0XsxtDhlZ7vWqbpEr9k0ej4Na3v8Q==
dependencies:
tslib "^1.9.0"
ngx-toastr@^13.0.0:
version "13.0.0"
resolved "https://registry.yarnpkg.com/ngx-toastr/-/ngx-toastr-13.0.0.tgz#7d011117c4352d824399de2478d2aedeec5c9391"