Skip to content

Commit bfc6de5

Browse files
[DURACOM-317] clean up, add expandable section, refactor to presentation component
1 parent 54c396c commit bfc6de5

17 files changed

Lines changed: 405 additions & 336 deletions

src/app/app-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const APP_ROUTES: Route[] = [
268268
{
269269
path: 'auditlogs',
270270
loadChildren: () => import('./audit-page/audit-page-routes').then((m) => m.ROUTES),
271-
canActivate: [authenticatedGuard, endUserAgreementCurrentUserGuard],
271+
canActivate: [siteAdministratorGuard, endUserAgreementCurrentUserGuard],
272272
},
273273
{
274274
path: 'subscriptions',

src/app/audit-page/audit-page-routes.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Route } from '@angular/router';
22

33
import { authenticatedGuard } from '../core/auth/authenticated.guard';
44
import { i18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
5-
import { auditPageResolver } from './audit-page.resolver';
6-
import { AuditDetailComponent } from './detail/audit-detail.component';
75
import { ObjectAuditOverviewComponent } from './object-audit-overview/object-audit-overview.component';
86
import { AuditOverviewComponent } from './overview/audit-overview.component';
97

@@ -18,15 +16,6 @@ export const ROUTES: Route[] = [
1816
data: { title: 'audit.overview.title', breadcrumbKey: 'audit.overview' },
1917
resolve: { breadcrumb: i18nBreadcrumbResolver },
2018
},
21-
{
22-
path: ':id',
23-
component: AuditDetailComponent,
24-
data: { title: 'audit.detail.title', breadcrumbKey: 'audit.detail' },
25-
resolve: {
26-
process: auditPageResolver,
27-
breadcrumb: i18nBreadcrumbResolver,
28-
},
29-
},
3019
{
3120
path: 'object/:objectId',
3221
component: ObjectAuditOverviewComponent,

src/app/audit-page/audit-page.resolver.spec.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/app/audit-page/audit-page.resolver.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
@if (audits.totalElements === 0) {
2+
<div>{{ 'audit.data.not-found' | translate }}</div>
3+
} @else {
4+
<ds-pagination
5+
[paginationOptions]="pageConfig"
6+
[collectionSize]="audits?.totalElements"
7+
[hideGear]="true"
8+
[hidePagerWhenSinglePage]="true">
9+
<div class="table-responsive">
10+
<table class="table table-striped table-hover">
11+
<thead>
12+
<tr>
13+
<th>{{ 'audit.overview.table.entityType' | translate }}</th>
14+
<th>{{ 'audit.overview.table.eperson' | translate }}</th>
15+
<th>{{ 'audit.overview.table.timestamp' | translate }}</th>
16+
@if (isOverviewPage) {
17+
<th>{{ 'audit.overview.table.objectUUID' | translate }}</th>
18+
<th>{{ 'audit.overview.table.objectType' | translate }}</th>
19+
<th>{{ 'audit.overview.table.subjectUUID' | translate }}</th>
20+
<th>{{ 'audit.overview.table.subjectType' | translate }}</th>
21+
} @else {
22+
<th>{{ 'audit.overview.table.other' | translate }}</th>
23+
}
24+
</tr>
25+
</thead>
26+
<tbody>
27+
@for (audit of audits?.page; track audit) {
28+
<tr>
29+
<td>
30+
@if (audit.hasDetails) {
31+
<div role="button" class="d-flex align-items-center" (click)="toggleCollapse(audit)">
32+
<div class="btn btn-link p-1 mr-1">
33+
@if (audit.isCollapsed) {
34+
<i class="fas fa-caret-right"></i>
35+
} @else {
36+
<i class="fas fa-caret-down"></i>
37+
}
38+
</div>
39+
<div>
40+
{{ audit.eventType }}
41+
</div>
42+
</div>
43+
} @else {
44+
<div class="ml-4">
45+
{{ audit.eventType }}
46+
</div>
47+
}
48+
</td>
49+
<td>{{ audit.epersonName }}</td>
50+
<td>{{ audit.timeStamp | date:dateFormat}}</td>
51+
@if (isOverviewPage) {
52+
<td>
53+
@if (audit.objectUUID) {
54+
<a [routerLink]="['/auditlogs/object/', audit.objectUUID]">{{audit.objectUUID}}</a>
55+
}
56+
</td>
57+
<td>{{ audit.objectType }}</td>
58+
<td>{{ audit.subjectUUID }}</td>
59+
<td>{{ audit.subjectType }}</td>
60+
} @else {
61+
<td>
62+
@if (object && object.id === audit.objectUUID) {
63+
<span>
64+
@if (audit.otherAuditObject; as dso) {
65+
{{ dsoNameService.getName(dso) }} <em>({{ dso.type }})</em>
66+
} @else {
67+
{{ dataNotAvailable }}
68+
}
69+
</span>
70+
} @else {
71+
{{ dataNotAvailable }}
72+
}
73+
</td>
74+
}
75+
</tr>
76+
@if (audit.hasDetails) {
77+
<tr [(ngbCollapse)]="audit.isCollapsed" [id]="audit.id" [ngClass]="{'border-top-0': !audit.isCollapsed}" class="w-100 nested-row">
78+
<td colspan="4" class="border-top-0">
79+
<div class="w-100">
80+
<div class="d-flex flex-column mw-100 w-100">
81+
@if (audit.metadataField) {
82+
<div class="d-flex mb-1">
83+
<small class="font-weight-bold me-2" >{{"audit.detail.metadata.field" | translate}}</small>
84+
<small>{{ audit.metadataField | dsStringReplace: "_":"." }}</small>
85+
</div>
86+
}
87+
@if (audit.value) {
88+
<div class="d-flex mb-1">
89+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.value" | translate}}</small>
90+
<small class="content dont-break-out preserve-line-breaks">
91+
{{ audit.value }}
92+
</small>
93+
</div>
94+
}
95+
@if (audit.authority) {
96+
<div class="d-flex mb-1">
97+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.authority" | translate}}</small>
98+
<small>{{ audit.authority }}</small>
99+
</div>
100+
}
101+
@if (audit.confidence !== null) {
102+
<div class="d-flex mb-1">
103+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.confidence" | translate}}</small>
104+
<small>{{ audit.confidence }}</small>
105+
</div>
106+
}
107+
@if (audit.place !== null) {
108+
<div class="d-flex mb-1">
109+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.place" | translate}}</small>
110+
<small>{{ audit.place }}</small>
111+
</div>
112+
}
113+
@if (audit.action) {
114+
<div class="d-flex mb-1">
115+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.action" | translate}}</small>
116+
<small>{{ audit.action }}</small>
117+
</div>
118+
}
119+
@if (audit.checksum) {
120+
<div class="d-flex">
121+
<small class="font-weight-bold me-2">{{"audit.detail.metadata.checksum" | translate}}</small>
122+
<small>{{ audit.checksum }}</small>
123+
</div>
124+
}
125+
</div>
126+
</div>
127+
</td>
128+
</tr>
129+
}
130+
}
131+
</tbody>
132+
</table>
133+
</div>
134+
</ds-pagination>
135+
}
136+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import {
2+
AsyncPipe,
3+
DatePipe,
4+
NgClass,
5+
} from '@angular/common';
6+
import {
7+
ChangeDetectorRef,
8+
Component,
9+
Input,
10+
} from '@angular/core';
11+
import { RouterLink } from '@angular/router';
12+
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
13+
import { TranslateModule } from '@ngx-translate/core';
14+
15+
import { AUDIT_PERSON_NOT_AVAILABLE } from '../../core/audit/audit-data.service';
16+
import { Audit } from '../../core/audit/model/audit.model';
17+
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
18+
import { PaginatedList } from '../../core/data/paginated-list.model';
19+
import { DSpaceObject } from '../../core/shared/dspace-object.model';
20+
import { PaginationComponent } from '../../shared/pagination/pagination.component';
21+
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
22+
import { StringReplacePipe } from '../../shared/utils/string-replace.pipe';
23+
import { VarDirective } from '../../shared/utils/var.directive';
24+
25+
@Component({
26+
selector: 'ds-audit-table',
27+
templateUrl: './audit-table.component.html',
28+
imports: [
29+
PaginationComponent,
30+
AsyncPipe,
31+
TranslateModule,
32+
VarDirective,
33+
RouterLink,
34+
DatePipe,
35+
StringReplacePipe,
36+
NgClass,
37+
NgbCollapseModule,
38+
],
39+
standalone: true,
40+
})
41+
export class AuditTableComponent {
42+
/**
43+
* The Audit items to be shown
44+
*/
45+
@Input() audits: PaginatedList<Audit>;
46+
47+
/**
48+
* Config for pagination
49+
*/
50+
@Input() pageConfig: PaginationComponentOptions;
51+
52+
/**
53+
* Whether the table is used for a an overview of all the site's Audits
54+
*/
55+
@Input() isOverviewPage: boolean;
56+
57+
/**
58+
* The DSpaceObject used in case of a detail audit page
59+
*/
60+
@Input() object: DSpaceObject;
61+
62+
protected readonly dataNotAvailable = AUDIT_PERSON_NOT_AVAILABLE;
63+
64+
/**
65+
* Date format to use for start and end time of audits
66+
*/
67+
protected readonly dateFormat = 'yyyy-MM-dd HH:mm:ss';
68+
69+
constructor(
70+
public dsoNameService: DSONameService,
71+
private changeDetectorRef: ChangeDetectorRef,
72+
) {}
73+
74+
75+
toggleCollapse(audit: Audit) {
76+
audit.isCollapsed = !audit.isCollapsed;
77+
this.changeDetectorRef.detectChanges();
78+
}
79+
}

src/app/audit-page/detail/audit-detail.component.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)