Skip to content

Commit

Permalink
Added the TaskAuditLogPage component [#413]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Jul 20, 2020
1 parent c9c2beb commit 56b53ec
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
import { RouterModule, Routes } from '@angular/router';
import { BuildDetailsPageComponent } from 'app/backend-status/pages/build-details-page/build-details-page.component';
import { NgModule } from '@angular/core';
import { TaskAuditLogPageComponent } from 'app/backend-status/pages/task-audit-log-page/task-audit-log-page.component';
import { AdminGuard } from 'app/user';

const routes: Routes = [
{
path: 'build/details',
component: BuildDetailsPageComponent
},
{
path: 'admin/tasks/logs',
component: TaskAuditLogPageComponent,
canActivate: [AdminGuard]
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ import { TranslateModule } from '@ngx-translate/core';
import { TaskAuditLogEffects } from 'app/backend-status/effects/task-audit-log.effects';
import { TaskAuditLogPageComponent } from './pages/task-audit-log-page/task-audit-log-page.component';
import { TaskAuditLogAdaptor } from 'app/backend-status/adaptors/task-audit-log.adaptor';
import { TableModule } from 'primeng/table';

@NgModule({
declarations: [BuildDetailsPageComponent],
declarations: [BuildDetailsPageComponent, TaskAuditLogPageComponent],
imports: [
CommonModule,
BackendStatusRoutingModule,
Expand All @@ -46,7 +47,8 @@ import { TaskAuditLogAdaptor } from 'app/backend-status/adaptors/task-audit-log.
fromTaskAuditLog.TASK_AUDIT_LOG_FEATURE_KEY,
fromTaskAuditLog.reducer
),
EffectsModule.forFeature([BuildDetailsEffects, TaskAuditLogEffects])
EffectsModule.forFeature([BuildDetailsEffects, TaskAuditLogEffects]),
TableModule
],
exports: [CommonModule],
providers: [BuildDetailsService, BuildDetailsAdaptor, TaskAuditLogAdaptor]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<p-table [value]="entries"
[rows]="rows"
[paginator]="true"
paginatorPosition="both">
<ng-template pTemplate="colgroup">
<col class="cx-table-column-medium"/>
<col class="cx-table-column-medium"/>
<col class="cx-table-column-medium"/>
<col/>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th id="task-start-time">{{"task-audit-log-page.table.header.start-time"|translate}}</th>
<th id="task-end-time">{{"task-audit-log-page.table.header.end-time"|translate}}</th>
<th id="task-successful">{{"task-audit-log-page.table.header.successful"|translate}}</th>
<th id="task-description">{{"task-audit-log-page.table.header.description"|translate}}</th>
</tr>
</ng-template>
<ng-template pTemplate="body"
let-entry>
<tr>
<td class="cx-table-column-align-center">{{entry.startTime|date:'medium'}}</td>
<td class="cx-table-column-align-center">{{entry.endTime|date:'medium'}}</td>
<td class="cx-table-column-align-center">{{entry.successful}}</td>
<td class="cx-no-wrap-text">{{entry.description}}</td>
</tr>
</ng-template>
</p-table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2020, The ComiXed Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TaskAuditLogPageComponent } from './task-audit-log-page.component';
import { TableModule } from 'primeng/table';
import { TranslateModule } from '@ngx-translate/core';
import { LoggerModule } from '@angular-ru/logger';
import { StoreModule } from '@ngrx/store';
import {
reducer,
TASK_AUDIT_LOG_FEATURE_KEY
} from 'app/backend-status/reducers/task-audit-log.reducer';
import { EffectsModule } from '@ngrx/effects';
import { TaskAuditLogEffects } from 'app/backend-status/effects/task-audit-log.effects';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MessageService } from 'primeng/api';
import { LibraryModule } from 'app/library/library.module';
import { RouterTestingModule } from '@angular/router/testing';

describe('TaskAuditLogPageComponent', () => {
let component: TaskAuditLogPageComponent;
let fixture: ComponentFixture<TaskAuditLogPageComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
LibraryModule,
RouterTestingModule,
HttpClientTestingModule,
TranslateModule.forRoot(),
LoggerModule.forRoot(),
StoreModule.forRoot({}),
StoreModule.forFeature(TASK_AUDIT_LOG_FEATURE_KEY, reducer),
EffectsModule.forRoot([]),
EffectsModule.forFeature([TaskAuditLogEffects]),
TableModule
],
declarations: [TaskAuditLogPageComponent],
providers: [MessageService]
}).compileComponents();

fixture = TestBed.createComponent(TaskAuditLogPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2020, The ComiXed Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { TaskAuditLogEntry } from 'app/backend-status/models/task-audit-log-entry';
import { LoggerService } from '@angular-ru/logger';
import { TaskAuditLogAdaptor } from 'app/backend-status/adaptors/task-audit-log.adaptor';
import { LibraryDisplayAdaptor } from 'app/user/adaptors/library-display.adaptor';

@Component({
selector: 'app-task-audit-log-page',
templateUrl: './task-audit-log-page.component.html',
styleUrls: ['./task-audit-log-page.component.scss']
})
export class TaskAuditLogPageComponent implements OnInit, OnDestroy {
fetchingSubscription: Subscription;
fetching = false;
entriesSubscription: Subscription;
entries: TaskAuditLogEntry[] = [];
rowsSubscription: Subscription;
rows = 0;

constructor(
private logger: LoggerService,
private taskAuditLogAdaptor: TaskAuditLogAdaptor,
private libraryDisplayAdaptor: LibraryDisplayAdaptor
) {
this.fetchingSubscription = this.taskAuditLogAdaptor.fetchingEntries$.subscribe(
fetching => {
this.fetching = fetching;
if (fetching === false) {
this.taskAuditLogAdaptor.getEntries();
}
}
);
this.entriesSubscription = this.taskAuditLogAdaptor.entries$.subscribe(
entries => (this.entries = entries)
);
this.rowsSubscription = this.libraryDisplayAdaptor.rows$.subscribe(
rows => (this.rows = rows)
);
}

ngOnInit() {}

ngOnDestroy() {
this.fetchingSubscription.unsubscribe();
this.entriesSubscription.unsubscribe();
this.rowsSubscription.unsubscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ export class NavigationBarComponent implements OnInit {
routerLink: ['/comics/missing'],
visible: this.isAdmin
},
{
separator: true,
visible: this.authenticated
},
{
label: this.translateService.instant(
'main-menu.item.admin.task-audit-log'
),
routerLink: ['/admin/tasks/logs'],
visible: this.isAdmin
},
{
label: this.translateService.instant(
'main-menu.item.admin.clear-image-cache'
Expand Down
10 changes: 10 additions & 0 deletions comixed-frontend/src/assets/i18n/en/backend-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@
"detail": "Failed to get task audit log entries."
}
}
},
"task-audit-log-page": {
"table": {
"header": {
"start-time": "Started",
"end-time": "Ended",
"successful": "Success?",
"description": "Description"
}
}
}
}
1 change: 1 addition & 0 deletions comixed-frontend/src/assets/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"import": "Import",
"duplicate-pages": "Duplicate Pages",
"missing-comics": "Missing Comics",
"task-audit-log": "Task Logs",
"clear-image-cache": "Clear Image Cache"
},
"help": {
Expand Down
10 changes: 10 additions & 0 deletions comixed-frontend/src/assets/i18n/es/backend-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@
"detail": "Failed to get task audit log entries."
}
}
},
"task-audit-log-page": {
"table": {
"header": {
"start-time": "Started",
"end-time": "Ended",
"successful": "Success?",
"description": "Description"
}
}
}
}
1 change: 1 addition & 0 deletions comixed-frontend/src/assets/i18n/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"import": "Importar",
"duplicate-pages": "Páginas duplicadas",
"missing-comics": "Cómics que faltan",
"task-audit-log": "Task Logs",
"clear-image-cache": "Clear Image Cache"
},
"help": {
Expand Down
10 changes: 10 additions & 0 deletions comixed-frontend/src/assets/i18n/fr/backend-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@
"detail": "Failed to get task audit log entries."
}
}
},
"task-audit-log-page": {
"table": {
"header": {
"start-time": "Started",
"end-time": "Ended",
"successful": "Success?",
"description": "Description"
}
}
}
}
1 change: 1 addition & 0 deletions comixed-frontend/src/assets/i18n/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"import": "Importer",
"duplicate-pages": "Pages dupliquées",
"missing-comics": "Bandes dessinées manquantes",
"task-audit-log": "Task Logs",
"clear-image-cache": "Vider le cache des images"
},
"help": {
Expand Down
10 changes: 10 additions & 0 deletions comixed-frontend/src/assets/i18n/pt/backend-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@
"detail": "Failed to get task audit log entries."
}
}
},
"task-audit-log-page": {
"table": {
"header": {
"start-time": "Started",
"end-time": "Ended",
"successful": "Success?",
"description": "Description"
}
}
}
}
1 change: 1 addition & 0 deletions comixed-frontend/src/assets/i18n/pt/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"import": "Import",
"duplicate-pages": "Duplicate Pages",
"missing-comics": "Missing Comics",
"task-audit-log": "Task Logs",
"clear-image-cache": "Clear Image Cache"
},
"help": {
Expand Down

0 comments on commit 56b53ec

Please sign in to comment.