From 8bcdfb98874ba28d5eb2c7659374b2db48fbde67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Wed, 6 Jan 2021 18:10:28 +0200 Subject: [PATCH] Display rule sets from API --- apps/red-ui/src/app/app.module.ts | 20 ++-- .../admin-breadcrumbs.component.html | 10 +- .../admin-breadcrumbs.component.ts | 10 +- .../project-template-actions.component.ts | 37 -------- .../rule-set-actions.component.html} | 4 +- .../rule-set-actions.component.scss} | 0 .../rule-set-actions.component.ts | 37 ++++++++ .../rule-set-view-switch.component.html} | 0 .../rule-set-view-switch.component.scss} | 0 .../rule-set-view-switch.component.ts} | 16 ++-- apps/red-ui/src/app/dialogs/dialog.service.ts | 21 ++-- .../dictionary-listing-screen.component.html | 5 +- .../dictionary-listing-screen.component.ts | 13 ++- ...-edit-project-template-dialog.component.ts | 55 ----------- ...ject-templates-listing-screen.component.ts | 94 ------------------ .../add-edit-rule-set-dialog.component.html} | 6 +- .../add-edit-rule-set-dialog.component.scss} | 0 .../add-edit-rule-set-dialog.component.ts | 56 +++++++++++ .../rule-sets-listing-screen.component.html} | 33 +++---- .../rule-sets-listing-screen.component.scss} | 0 .../rule-sets-listing-screen.component.ts | 95 +++++++++++++++++++ .../rules-screen/rules-screen.component.html | 5 +- .../rules-screen/rules-screen.component.ts | 12 +-- apps/red-ui/src/app/state/app-state.guard.ts | 1 + .../red-ui/src/app/state/app-state.service.ts | 59 ++++-------- apps/red-ui/src/app/utils/sorting.service.ts | 4 +- libs/red-ui-http/src/lib/api.module.ts | 2 + 27 files changed, 291 insertions(+), 304 deletions(-) delete mode 100644 apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts rename apps/red-ui/src/app/components/{project-template-actions/project-template-actions.component.html => rule-set-actions/rule-set-actions.component.html} (79%) rename apps/red-ui/src/app/components/{project-template-actions/project-template-actions.component.scss => rule-set-actions/rule-set-actions.component.scss} (100%) create mode 100644 apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.ts rename apps/red-ui/src/app/components/{project-template-view-switch/project-template-view-switch.component.html => rule-set-view-switch/rule-set-view-switch.component.html} (100%) rename apps/red-ui/src/app/components/{project-template-view-switch/project-template-view-switch.component.scss => rule-set-view-switch/rule-set-view-switch.component.scss} (100%) rename apps/red-ui/src/app/components/{project-template-view-switch/project-template-view-switch.component.ts => rule-set-view-switch/rule-set-view-switch.component.ts} (53%) delete mode 100644 apps/red-ui/src/app/screens/admin/project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component.ts delete mode 100644 apps/red-ui/src/app/screens/admin/project-templates-listing-screen/project-templates-listing-screen.component.ts rename apps/red-ui/src/app/screens/admin/{project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component.html => rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component.html} (89%) rename apps/red-ui/src/app/screens/admin/{project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component.scss => rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component.scss} (100%) create mode 100644 apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component.ts rename apps/red-ui/src/app/screens/admin/{project-templates-listing-screen/project-templates-listing-screen.component.html => rule-sets-listing-screen/rule-sets-listing-screen.component.html} (79%) rename apps/red-ui/src/app/screens/admin/{project-templates-listing-screen/project-templates-listing-screen.component.scss => rule-sets-listing-screen/rule-sets-listing-screen.component.scss} (100%) create mode 100644 apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component.ts diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index b46078f62..b3f4625ce 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -98,10 +98,10 @@ import { HtmlDebugScreenComponent } from './screens/html-debug-screen/html-debug import { ReportDownloadBtnComponent } from './components/buttons/report-download-btn/report-download-btn.component'; import { ProjectListingActionsComponent } from './screens/project-listing-screen/project-listing-actions/project-listing-actions.component'; import { HasScrollbarDirective } from './utils/has-scrollbar.directive'; -import { ProjectTemplatesListingScreenComponent } from './screens/admin/project-templates-listing-screen/project-templates-listing-screen.component'; -import { AddEditProjectTemplateDialogComponent } from './screens/admin/project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component'; -import { ProjectTemplateActionsComponent } from './components/project-template-actions/project-template-actions.component'; -import { ProjectTemplateViewSwitchComponent } from './components/project-template-view-switch/project-template-view-switch.component'; +import { RuleSetsListingScreenComponent } from './screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component'; +import { AddEditRuleSetDialogComponent } from './screens/admin/rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component'; +import { RuleSetActionsComponent } from './components/rule-set-actions/rule-set-actions.component'; +import { RuleSetViewSwitchComponent } from './components/rule-set-view-switch/rule-set-view-switch.component'; import { MatSliderModule } from '@angular/material/slider'; import { PendingChangesGuard } from './utils/can-deactivate.guard'; @@ -178,14 +178,14 @@ const routes = [ children: [ { path: '', - component: ProjectTemplatesListingScreenComponent, + component: RuleSetsListingScreenComponent, canActivate: [CompositeRouteGuard], data: { routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] } }, { - path: ':templateId', + path: ':ruleSetId', children: [ { path: 'dictionaries', @@ -313,8 +313,8 @@ const matImports = [ CircleButtonComponent, ChevronButtonComponent, DictionaryListingScreenComponent, - ProjectTemplatesListingScreenComponent, - AddEditProjectTemplateDialogComponent, + RuleSetsListingScreenComponent, + AddEditRuleSetDialogComponent, SyncWidthDirective, HasScrollbarDirective, AddEditDictionaryDialogComponent, @@ -329,8 +329,8 @@ const matImports = [ HtmlDebugScreenComponent, ReportDownloadBtnComponent, ProjectListingActionsComponent, - ProjectTemplateActionsComponent, - ProjectTemplateViewSwitchComponent + RuleSetActionsComponent, + RuleSetViewSwitchComponent ], imports: [ BrowserModule, diff --git a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html index 5549ff5ea..33266b062 100644 --- a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html +++ b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html @@ -5,7 +5,7 @@ [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active" translate="project-templates" - *ngIf="root || !!projectTemplate" + *ngIf="root || !!ruleSet" > - + - - {{ projectTemplate.name }} + + {{ ruleSet.name }} @@ -37,7 +37,7 @@ {{ dictionary.label }} diff --git a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts index b4931d79d..d7b4e412c 100644 --- a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts +++ b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { TypeValue } from '@redaction/red-ui-http'; -import { AppStateService, ProjectTemplate } from '../../state/app-state.service'; +import { RuleSetModel, TypeValue } from '@redaction/red-ui-http'; +import { AppStateService } from '../../state/app-state.service'; import { UserPreferenceService } from '../../common/service/user-preference.service'; import { PermissionsService } from '../../common/service/permissions.service'; @@ -12,7 +12,7 @@ import { PermissionsService } from '../../common/service/permissions.service'; }) export class AdminBreadcrumbsComponent implements OnInit { public dictionary: TypeValue; - public projectTemplate: ProjectTemplate; + public ruleSet: RuleSetModel; @Input() public root = false; @@ -25,8 +25,8 @@ export class AdminBreadcrumbsComponent implements OnInit { ngOnInit(): void { this._activatedRoute.params.subscribe((params) => { - if (params.templateId) { - this.projectTemplate = this._appStateService.getProjectTemplateById(params.templateId); + if (params.ruleSetId) { + this.ruleSet = this._appStateService.getRuleSetById(params.ruleSetId); } if (params.type) { this.dictionary = this._appStateService.getDictionaryTypeValue(params.type); diff --git a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts b/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts deleted file mode 100644 index 7316bdd35..000000000 --- a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { ProjectTemplate } from '../../state/app-state.service'; -import { DialogService } from '../../dialogs/dialog.service'; -import { PermissionsService } from '../../common/service/permissions.service'; - -@Component({ - selector: 'redaction-project-template-actions', - templateUrl: './project-template-actions.component.html', - styleUrls: ['./project-template-actions.component.scss'] -}) -export class ProjectTemplateActionsComponent implements OnInit { - @Input() template: ProjectTemplate; - @Output() loadTemplatesData = new EventEmitter(); - - constructor(private readonly _dialogService: DialogService, public readonly permissionsService: PermissionsService) {} - - ngOnInit(): void {} - - openAddEditTemplateDialog(template?: ProjectTemplate) { - this._dialogService.openAddEditTemplateDialog(template, async (newTemplate) => { - if (newTemplate) { - this.loadTemplatesData.emit(); - } - }); - } - - openEditTemplateDialog($event: any, pt: ProjectTemplate) { - $event.stopPropagation(); - this.openAddEditTemplateDialog(pt); - } - - openDeleteTemplateDialog($event: any, template: ProjectTemplate) { - this._dialogService.openDeleteProjectTemplateDialog($event, template, async () => { - this.loadTemplatesData.emit(); - }); - } -} diff --git a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html b/apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html similarity index 79% rename from apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html rename to apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html index 9b0edb1f4..04d19f2f8 100644 --- a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html +++ b/apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html @@ -1,6 +1,6 @@
(); + + constructor(private readonly _dialogService: DialogService, public readonly permissionsService: PermissionsService) {} + + ngOnInit(): void {} + + openAddEditRuleSetDialog(ruleSet?: RuleSetModel) { + this._dialogService.openAddEditRuleSetDialog(ruleSet, async (newRuleSet) => { + if (newRuleSet) { + this.loadRuleSetsData.emit(); + } + }); + } + + openEditRuleSetDialog($event: any, ruleSet: RuleSetModel) { + $event.stopPropagation(); + this.openAddEditRuleSetDialog(ruleSet); + } + + openDeleteRuleSetDialog($event: any, ruleSet: RuleSetModel) { + this._dialogService.openDeleteRuleSetDialog($event, ruleSet, async () => { + this.loadRuleSetsData.emit(); + }); + } +} diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.html b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.html similarity index 100% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.html rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.html diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.scss b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.scss similarity index 100% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.scss rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.scss diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts similarity index 53% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts index 170a27221..c5ef646b8 100644 --- a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts +++ b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts @@ -2,26 +2,26 @@ import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; @Component({ - selector: 'redaction-project-template-view-switch', - templateUrl: './project-template-view-switch.component.html', - styleUrls: ['./project-template-view-switch.component.scss'] + selector: 'redaction-rule-set-view-switch', + templateUrl: './rule-set-view-switch.component.html', + styleUrls: ['./rule-set-view-switch.component.scss'] }) -export class ProjectTemplateViewSwitchComponent implements OnInit { +export class RuleSetViewSwitchComponent implements OnInit { @Input() public screen: 'rules' | 'dictionaries'; - private readonly _projectTemplateId: string; + private readonly _ruleSetId: string; constructor(private readonly _actr: ActivatedRoute, private _router: Router) { - this._projectTemplateId = this._actr.snapshot.params.templateId; + this._ruleSetId = this._actr.snapshot.params.ruleSetId; } ngOnInit(): void {} public switchView($event) { if ($event.value === 'dictionaries') { - this._router.navigate(['ui/admin/project-templates/' + this._projectTemplateId + '/dictionaries']); + this._router.navigate(['ui/admin/project-templates/' + this._ruleSetId + '/dictionaries']); } else { - this._router.navigate(['ui/admin/project-templates/' + this._projectTemplateId + '/rules']); + this._router.navigate(['ui/admin/project-templates/' + this._ruleSetId + '/rules']); } } } diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 1dff8b33a..76a992b44 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -1,10 +1,17 @@ import { Injectable } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { DictionaryControllerService, FileManagementControllerService, FileStatus, ManualRedactionControllerService, TypeValue } from '@redaction/red-ui-http'; +import { + DictionaryControllerService, + FileManagementControllerService, + FileStatus, + ManualRedactionControllerService, + RuleSetModel, + TypeValue +} from '@redaction/red-ui-http'; import { ConfirmationDialogComponent, ConfirmationDialogInput } from './confirmation-dialog/confirmation-dialog.component'; import { NotificationService, NotificationType } from '../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; -import { AppStateService, ProjectTemplate } from '../state/app-state.service'; +import { AppStateService } from '../state/app-state.service'; import { AddEditProjectDialogComponent } from './add-edit-project-dialog/add-edit-project-dialog.component'; import { AssignOwnerDialogComponent } from './assign-owner-dialog/assign-owner-dialog.component'; import { ManualRedactionEntryWrapper } from '../screens/file/model/manual-redaction-entry.wrapper'; @@ -13,7 +20,7 @@ import { ManualAnnotationDialogComponent } from './manual-redaction-dialog/manua import { ManualAnnotationService } from '../screens/file/service/manual-annotation.service'; import { ProjectWrapper } from '../state/model/project.wrapper'; import { AddEditDictionaryDialogComponent } from '../screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component'; -import { AddEditProjectTemplateDialogComponent } from '../screens/admin/project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component'; +import { AddEditRuleSetDialogComponent } from '../screens/admin/rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component'; import { DEFAULT_RUL_SET_UUID } from '../utils/rule-set-default'; const dialogConfig = { @@ -175,7 +182,7 @@ export class DialogService { return ref; } - public openDeleteProjectTemplateDialog($event: MouseEvent, projectTemplate: ProjectTemplate, cb?: Function): MatDialogRef { + public openDeleteRuleSetDialog($event: MouseEvent, ruleSet: RuleSetModel, cb?: Function): MatDialogRef { $event.stopPropagation(); const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); ref.afterClosed().subscribe(async (result) => { @@ -285,10 +292,10 @@ export class DialogService { return ref; } - public openAddEditTemplateDialog(template: ProjectTemplate, cb?: Function): MatDialogRef { - const ref = this._dialog.open(AddEditProjectTemplateDialogComponent, { + public openAddEditRuleSetDialog(ruleSet: RuleSetModel, cb?: Function): MatDialogRef { + const ref = this._dialog.open(AddEditRuleSetDialogComponent, { ...dialogConfig, - data: template, + data: ruleSet, autoFocus: true }); diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html index f67bc5685..7417f7e3b 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html @@ -2,11 +2,10 @@