implement items clickable, fix minor issues, add filters

This commit is contained in:
FrancescoMolinaro
2024-01-15 11:31:32 +01:00
parent 93777b9d61
commit f4c2b0b3fd
12 changed files with 166 additions and 135 deletions

View File

@@ -16,6 +16,7 @@ import {
AdminNotifySearchResultComponent
} from './admin-notify-search-result/admin-notify-search-result.component';
import { AdminNotifyMessagesService } from './services/admin-notify-messages.service';
import { AdminNotifyLogsResultComponent } from './admin-notify-logs/admin-notify-logs-result/admin-notify-logs-result.component';
const ENTRY_COMPONENTS = [
@@ -40,7 +41,9 @@ const ENTRY_COMPONENTS = [
AdminNotifyMetricsComponent,
AdminNotifyIncomingComponent,
AdminNotifyOutgoingComponent,
AdminNotifyDetailModalComponent
AdminNotifyDetailModalComponent,
AdminNotifySearchResultComponent,
AdminNotifyLogsResultComponent
]
})
export class AdminNotifyDashboardModule {

View File

@@ -15,29 +15,7 @@
<a class="nav-link" [routerLink]="'../outbound'" [queryParams]="{view: 'table'}">{{'admin.notify.dashboard.outbound-logs' | translate}}</a>
</ul>
<div class="container my-4">
<div class="row">
<div class="col-12 col-md-3 text-left h4">{{'admin.notify.dashboard.outbound' | translate}}</div>
<div class="col-md-9">
<ds-search-labels [inPlaceSearch]="true"></ds-search-labels>
<div class="h4">
<button (click)="resetDefaultConfiguration()" *ngIf="(selectedSearchConfig$ | async) !== defaultConfiguration" class="badge badge-primary mr-1 mb-1">
{{'admin.notify.dashboard.configuration' | translate}} {{ selectedSearchConfig$ | async }}
<span> ×</span>
</button>
</div>
</div>
</div>
</div>
<ds-themed-search
*ngIf="!isLoading"
[configuration]="selectedSearchConfig$ | async"
[showViewModes]="false"
[searchEnabled]="false"
[context]="context"
></ds-themed-search>
<ds-admin-notify-logs-result [defaultConfiguration]="'NOTIFY.incoming'" ></ds-admin-notify-logs-result>
</div>
</div>
</div>

View File

@@ -1,11 +1,6 @@
import { Component, Inject, OnInit } from '@angular/core';
import { Component, Inject } from '@angular/core';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component';
import { Context } from '../../../../core/shared/context.model';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { ViewMode } from '../../../../core/shared/view-mode.model';
@Component({
@@ -18,39 +13,7 @@ import { ViewMode } from '../../../../core/shared/view-mode.model';
}
]
})
export class AdminNotifyIncomingComponent implements OnInit{
public selectedSearchConfig$: Observable<string>;
public defaultConfiguration = 'NOTIFY.incoming';
public isLoading = true;
protected readonly context = Context.CoarNotify;
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
private router: Router,
private route: ActivatedRoute) {
}
ngOnInit() {
this.selectedSearchConfig$ = this.searchConfigService.getCurrentConfiguration(this.defaultConfiguration).pipe(
tap(() => this.isLoading = false)
);
}
public resetDefaultConfiguration() {
this.router.navigate([this.getResolvedUrl(this.route.snapshot)], {
queryParams: {
configuration: this.defaultConfiguration,
view: ViewMode.Table
},
});
}
/**
*
* @param route url path
* @returns url path
*/
private getResolvedUrl(route: ActivatedRouteSnapshot): string {
return route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/');
export class AdminNotifyIncomingComponent {
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
}
}

View File

@@ -0,0 +1,25 @@
<div class="container my-4">
<div class="row">
<div class="col-12 col-md-3 text-left h4">{{'admin.notify.dashboard.outbound' | translate}}</div>
<div class="col-md-9">
<ds-search-labels [inPlaceSearch]="true"></ds-search-labels>
<div class="h4">
<button (click)="resetDefaultConfiguration()" *ngIf="(selectedSearchConfig$ | async) !== defaultConfiguration" class="badge badge-primary mr-1 mb-1">
{{'admin.notify.dashboard.configuration' | translate}} {{ selectedSearchConfig$ | async }}
<span> ×</span>
</button>
</div>
</div>
</div>
</div>
<div >
<ds-themed-search
[configuration]="selectedSearchConfig$ | async"
[showViewModes]="false"
[searchEnabled]="false"
[context]="context"
></ds-themed-search>
</div>

View File

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminNotifyLogsResultComponent } from './admin-notify-logs-result.component';
describe('AdminNotifyLogsComponent', () => {
let component: AdminNotifyLogsResultComponent;
let fixture: ComponentFixture<AdminNotifyLogsResultComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AdminNotifyLogsResultComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(AdminNotifyLogsResultComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,58 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component';
import { Context } from '../../../../core/shared/context.model';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { Observable } from 'rxjs';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { ViewMode } from '../../../../core/shared/view-mode.model';
@Component({
selector: 'ds-admin-notify-logs-result',
templateUrl: './admin-notify-logs-result.component.html',
providers: [
{
provide: SEARCH_CONFIG_SERVICE,
useClass: SearchConfigurationService
}
]
})
export class AdminNotifyLogsResultComponent implements OnInit{
@Input()
defaultConfiguration: string;
public selectedSearchConfig$: Observable<string>;
protected readonly context = Context.CoarNotify;
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
private router: Router,
private route: ActivatedRoute) {
}
ngOnInit() {
// override the route reuse strategy to prevent issue on result loading
this.router.routeReuseStrategy.shouldReuseRoute = () => {
return false;
};
this.selectedSearchConfig$ = this.searchConfigService.getCurrentConfiguration(this.defaultConfiguration);
}
public resetDefaultConfiguration() {
this.router.navigate([this.getResolvedUrl(this.route.snapshot)], {
queryParams: {
configuration: this.defaultConfiguration,
view: ViewMode.Table,
},
});
}
/**
*
* @param route url path
* @returns url path
*/
private getResolvedUrl(route: ActivatedRouteSnapshot): string {
return route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/');
}
}

View File

@@ -15,29 +15,8 @@
<a class="nav-link active">{{'admin.notify.dashboard.outbound-logs' | translate}}</a>
</ul>
<div class="container my-4">
<div class="row">
<div class="col-12 col-md-3 text-left h4">{{'admin.notify.dashboard.outbound' | translate}}</div>
<div class="col-md-9">
<ds-search-labels [inPlaceSearch]="true"></ds-search-labels>
<div class="h4">
<button (click)="resetDefaultConfiguration()" *ngIf="(selectedSearchConfig$ | async) !== defaultConfiguration" class="badge badge-primary mr-1 mb-1">
{{'admin.notify.dashboard.configuration' | translate}} {{ selectedSearchConfig$ | async }}
<span> ×</span>
</button>
</div>
</div>
</div>
</div>
<ds-admin-notify-logs-result [defaultConfiguration]="'NOTIFY.outgoing'" ></ds-admin-notify-logs-result>
<ds-themed-search
*ngIf="!isLoading"
[configuration]="selectedSearchConfig$ | async"
[showViewModes]="false"
[searchEnabled]="false"
[context]="context"
></ds-themed-search>
</div>
</div>
</div>

View File

@@ -1,11 +1,6 @@
import { Component, Inject } from '@angular/core';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component';
import { Context } from '../../../../core/shared/context.model';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { Observable } from 'rxjs';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { ViewMode } from '../../../../core/shared/view-mode.model';
import { tap } from 'rxjs/operators';
@Component({
@@ -19,38 +14,6 @@ import { tap } from 'rxjs/operators';
]
})
export class AdminNotifyOutgoingComponent {
public selectedSearchConfig$: Observable<string>;
public defaultConfiguration = 'NOTIFY.outgoing';
public isLoading = true;
protected readonly context = Context.CoarNotify;
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
private router: Router,
private route: ActivatedRoute) {
}
ngOnInit() {
this.selectedSearchConfig$ = this.searchConfigService.getCurrentConfiguration(this.defaultConfiguration).pipe(
tap(() => this.isLoading = false)
);
}
public resetDefaultConfiguration() {
this.router.navigate([this.getResolvedUrl(this.route.snapshot)], {
queryParams: {
configuration: this.defaultConfiguration,
view: ViewMode.Table
},
});
}
/**
*
* @param route url path
* @returns url path
*/
private getResolvedUrl(route: ActivatedRouteSnapshot): string {
return route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/');
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
}
}

View File

@@ -13,14 +13,29 @@ export class AdminNotifyMetricsComponent {
boxesConfig: AdminNotifyMetricsRow[];
private incomingConfiguration = 'NOTIFY.incoming';
private involvedItemsSuffix = 'involvedItems';
private inboundPath = '/inbound';
private outboundPath = '/outbound';
private adminSearchPath = '/admin/search';
constructor(private router: Router) {
}
public navigateToSelectedSearchConfig(searchConfig: string) {
const isRelatedItemsConfig = searchConfig.endsWith(this.involvedItemsSuffix);
if (isRelatedItemsConfig) {
this.router.navigate([this.adminSearchPath], {
queryParams: {
configuration: searchConfig,
view: ViewMode.ListElement
},
});
return;
}
const isIncomingConfig = searchConfig.startsWith(this.incomingConfiguration);
const selectedPath = isIncomingConfig ? this.inboundPath : this.outboundPath;

View File

@@ -50,6 +50,26 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListEleme
private dateTypeKeys: string[] = ['queueLastStartTime', 'queueTimeout'];
/**
* Keys to be not shown in detail
* @private
*/
private hiddenKeys: string[] = [
'target',
'object',
'context',
'origin',
'_links',
'metadata',
'thumbnail',
'item',
'accessStatus',
'queueStatus',
'notificationId',
'notificationType',
];
/**
* The format for the date values
* @private
@@ -87,18 +107,8 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListEleme
const modalRef = this.modalService.open(AdminNotifyDetailModalComponent);
const messageToOpen = {...message};
// we delete not necessary or not readable keys
delete messageToOpen.target;
delete messageToOpen.object;
delete messageToOpen.context;
delete messageToOpen.origin;
delete messageToOpen._links;
delete messageToOpen.metadata;
delete messageToOpen.thumbnail;
delete messageToOpen.item;
delete messageToOpen.accessStatus;
delete messageToOpen.queueStatus;
const messageKeys = Object.keys(messageToOpen);
const messageKeys = Object.keys(messageToOpen).filter(key => !this.hiddenKeys.includes(key));
messageKeys.forEach(key => {
if (this.dateTypeKeys.includes(key)) {
messageToOpen[key] = this.datePipe.transform(messageToOpen[key], this.dateFormat);

View File

@@ -26,6 +26,18 @@ export class AdminNotifyMessage extends DSpaceObject {
@autoserialize
id: string;
/**
* The id of the notification
*/
@autoserialize
notificationId: string;
/**
* The type of the notification
*/
@autoserialize
notificationType: string;
/**
* The type of the notification
*/

View File

@@ -3471,6 +3471,8 @@
"admin.notify.dashboard.configuration": "Configuration: ",
"search.filters.applied.f.relateditem": "Related items",
"admin.notify.dashboard.outbound": "Outbound messages",
"admin.notify.dashboard.outbound-logs": "Logs/Outbound",