[CST-12145] implementation of item-page & y dspace coar-notify notifications

This commit is contained in:
Alisa Ismailati
2023-10-27 18:28:52 +02:00
parent 4fd475f6b7
commit e87c12cca3
13 changed files with 153 additions and 87 deletions

View File

@@ -49,6 +49,21 @@ import { SourceDataResolver } from './admin-quality-assurance-source-page-compon
showBreadcrumbsFluid: false
}
},
{
canActivate: [ AuthenticatedGuard ],
path: `${QUALITY_ASSURANCE_EDIT_PATH}/:sourceId/:targetId`,
component: AdminQualityAssuranceTopicsPageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
openaireQualityAssuranceTopicsParams: AdminQualityAssuranceTopicsPageResolver
},
data: {
title: 'admin.quality-assurance.page.title',
breadcrumbKey: 'admin.quality-assurance',
showBreadcrumbsFluid: false
}
},
{
canActivate: [ AuthenticatedGuard ],
path: `${QUALITY_ASSURANCE_EDIT_PATH}`,

View File

@@ -86,27 +86,11 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
/**
* Service for retrieving Quality Assurance events by topic and target.
* @param topic The topic of the events to retrieve.
* @param target (Optional) The target of the events to retrieve (the item's uuid).
* @param options (Optional) The search options to use when retrieving the events.
* @param linksToFollow (Optional) The links to follow when retrieving the events.
* @returns An observable of the remote data containing the paginated list of Quality Assurance events.
*/
public getEventsByTopicAndTarget(topic: string, target?: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceEventObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceEventObject>>> {
options.searchParams = [
{
fieldName: 'topic',
fieldValue: topic
}
];
if (hasValue(target)) {
options.searchParams.push({
fieldName: 'target',
fieldValue: target
});
}
public searchEventsByTopic(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceEventObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceEventObject>>> {
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
}

View File

@@ -16,8 +16,7 @@ import { IdentifiableDataService } from '../../../data/base/identifiable-data.se
import { dataService } from '../../../data/base/data-service.decorator';
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from '../models/quality-assurance-topic-object.resource-type';
import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
import { hasValue } from 'src/app/shared/empty.util';
import { SearchData, SearchDataImpl } from 'src/app/core/data/base/search-data';
import { SearchData, SearchDataImpl } from '../../../../core/data/base/search-data';
/**
* The service handling all Quality Assurance topic REST requests.
@@ -68,34 +67,6 @@ export class QualityAssuranceTopicDataService extends IdentifiableDataService<Qu
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Retrieves a paginated list of QualityAssuranceTopicObjects by target and source.
* @param target The target to search for (the item's uuid).
* @param source The source to search for (optional).
* @param options The find list options (optional).
* @param useCachedVersionIfAvailable Whether to use a cached version if available (optional, default is true).
* @param reRequestOnStale Whether to re-request if the cached version is stale (optional, default is true).
* @param linksToFollow The links to follow (optional).
* @returns An observable of RemoteData<PaginatedList<QualityAssuranceTopicObject>>.
*/
public getTopicsByTargetAndSource(target: string, source?: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceTopicObject>>> {
options.searchParams = [
{
fieldName: 'target',
fieldValue: target
}
];
if (hasValue(source)) {
options.searchParams.push({
fieldName: 'source',
fieldValue: source
});
}
return this.searchData.searchBy(this.searchByTargetMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Clear FindAll topics requests from cache
*/

View File

@@ -1,5 +1,9 @@
<ng-container *ngIf="events.length > 0">
asdfasdf
<ds-alert [type]="AlertTypeInfo" [content]="'asdf' | translate"></ds-alert>
<ng-container *ngIf="(events$ | async)?.length > 0">
<div class="alert alert-info d-flex flex-row">
<img class="notify-logo" src="assets/images/notify-coar-icon.png" alt="Repository logo">
<div class="w-100 d-flex justify-content-between">
<div class="pl-4 align-self-center">{{'item.qa-event-notification.check.notification-info' | translate : {num: (events$ | async)?.length} }} </div>
<button [routerLink]="['/admin/notifications/quality-assurance', source, item.id]" class="btn btn-primary align-self-center">{{'item.qa-event-notification-info.check.button' | translate }}</button>
</div>
</div>
</ng-container>
asfasdfasdf

View File

@@ -0,0 +1,8 @@
.notify-logo {
max-height: var(--ds-header-logo-height);
}
.sections-gap {
gap: 1rem;
}

View File

@@ -1,12 +1,14 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators';
import { QualityAssuranceEventDataService } from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
import { QualityAssuranceTopicDataService } from '../../../core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service';
import { QualityAssuranceTopicObject } from 'src/app/core/suggestion-notifications/qa/models/quality-assurance-topic.model';
import { Observable, concatMap, from, map, mergeMap, of, switchMap, tap } from 'rxjs';
import { QualityAssuranceEventObject } from 'src/app/core/suggestion-notifications/qa/models/quality-assurance-event.model';
import { AlertType } from 'src/app/shared/alert/aletr-type';
import { QualityAssuranceTopicObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-topic.model';
import { Observable, concatMap, from, mergeMap } from 'rxjs';
import { QualityAssuranceEventObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
import { AlertType } from '../../../shared/alert/aletr-type';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { RequestParam } from '../../../core/cache/models/request-param.model';
@Component({
selector: 'ds-qa-event-notification',
@@ -15,44 +17,73 @@ import { AlertType } from 'src/app/shared/alert/aletr-type';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [QualityAssuranceTopicDataService, QualityAssuranceEventDataService]
})
export class QaEventNotificationComponent {
/**
* Component for displaying quality assurance event notifications for an item.
*/
export class QaEventNotificationComponent implements OnInit {
/**
* The item to display quality assurance event notifications for.
*/
@Input() item: Item;
events: QualityAssuranceEventObject[] = [];
/**
* An observable of quality assurance events for the item.
*/
events$: Observable<QualityAssuranceEventObject[]>;
/**
* The type of alert to display for the notification.
*/
AlertTypeInfo = AlertType.Info;
/**
* The source of the quality assurance events.
*/
source = 'coar-notify';
constructor(
private qualityAssuranceEventDataService: QualityAssuranceEventDataService,
private qualityAssuranceTopicDataService: QualityAssuranceTopicDataService,
) { }
ngOnInit(): void {
ngOnInit() {
this.getEventsByTopicsAndTarget();
}
getEventsByTopicsAndTarget(): void {
// TODO: add source 'coar-notify'
this.qualityAssuranceTopicDataService.getTopicsByTargetAndSource(this.item.id).pipe(
/**
* Retrieves quality assurance events by topics and target.
* First, it retrieves the topics by target and source.
* -> target: item.id
* -> source: 'coar-notify'
* Then, it retrieves the events by topic and target.
*/
getEventsByTopicsAndTarget() {
const findListTopicOptions: FindListOptions = {
searchParams: [new RequestParam('source', this.source), new RequestParam('target', this.item.id)]
};
// const findListEventOptions: FindListOptions = {
// searchParams: [new RequestParam('topic', topic.name), new RequestParam('target', this.item.id)]
// };
this.events$ = this.qualityAssuranceTopicDataService.getTopics(findListTopicOptions).pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),
tap((topics: QualityAssuranceTopicObject[]) => console.log(topics, 'topics')),
mergeMap((topics: QualityAssuranceTopicObject[]) => {
return from(topics).pipe(
concatMap((topic: QualityAssuranceTopicObject) => {
return this.qualityAssuranceEventDataService.getEventsByTopicAndTarget(topic.name, this.item.id).pipe(
tap((events: any) => console.log(events, 'events')),
);
const findListEventOptions: FindListOptions = {
searchParams: [new RequestParam('topic', topic.name), new RequestParam('target', this.item.id)]
};
return this.qualityAssuranceEventDataService.searchEventsByTopic(findListEventOptions);
} )
);
}),
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),
).subscribe((events: QualityAssuranceEventObject[]) => {
this.events = events;
console.log(events, 'events2')});
);
}
}

View File

@@ -1 +1,11 @@
<p>my-dspace-qa-events-notifications works!</p>
<ng-container *ngIf="(sources$ | async)?.length > 0">
<ng-container *ngFor="let source of (sources$ | async)" >
<div class="alert alert-info d-flex flex-row" *ngIf="source.totalEvents > 0">
<img class="notify-logo" src="assets/images/notify-coar-icon.png" alt="Repository logo">
<div class="w-100 d-flex justify-content-between">
<div class="pl-4 align-self-center">{{'item.qa-event-notification.check.notification-info' | translate : {num: source.totalEvents} }} </div>
<button [routerLink]="['/admin/notifications/quality-assurance', source.id]" class="btn btn-primary align-self-center">{{'item.qa-event-notification-info.check.button' | translate }}</button>
</div>
</div>
</ng-container>
</ng-container>

View File

@@ -0,0 +1,8 @@
.notify-logo {
max-height: var(--ds-header-logo-height);
}
.sections-gap {
gap: 1rem;
}

View File

@@ -1,9 +1,7 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { QualityAssuranceSourceDataService } from '../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
import { getFirstCompletedRemoteData } from 'src/app/core/shared/operators';
import { map } from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../core/shared/operators';
import { Observable, of, tap } from 'rxjs';
import { QualityAssuranceSourceObject } from 'src/app/core/suggestion-notifications/qa/models/quality-assurance-source.model';
@Component({
@@ -12,7 +10,9 @@ import { QualityAssuranceSourceObject } from 'src/app/core/suggestion-notificati
styleUrls: ['./my-dspace-qa-events-notifications.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyDspaceQaEventsNotificationsComponent {
export class MyDspaceQaEventsNotificationsComponent implements OnInit {
sources$: Observable<QualityAssuranceSourceObject[]> = of([]);
constructor(private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService) { }
@@ -21,19 +21,16 @@ export class MyDspaceQaEventsNotificationsComponent {
}
getSources() {
this.qualityAssuranceSourceDataService.getSource('coar-notify')
this.sources$ = this.qualityAssuranceSourceDataService.getSources()
.pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<QualityAssuranceSourceObject>) => {
if (rd.hasSucceeded) {
return rd.payload;
} else {
throw new Error('Can\'t retrieve Quality Assurance source');
tap((rd) => {
if (rd.hasFailed) {
throw new Error('Can\'t retrieve Quality Assurance sources');
}
})
)
.subscribe((sources) => {
console.log(sources);
});
}),
getRemoteDataPayload(),
getPaginatedListPayload(),
);
}
}

View File

@@ -60,6 +60,12 @@ export class QualityAssuranceTopicsComponent implements OnInit {
*/
public sourceId: string;
/**
* This property represents a targetId (item-id) which is used to retrive a topic
* @type {string}
*/
public targetId: string;
/**
* Initialize the component variables.
* @param {PaginationService} paginationService
@@ -80,7 +86,9 @@ export class QualityAssuranceTopicsComponent implements OnInit {
*/
ngOnInit(): void {
this.sourceId = this.activatedRoute.snapshot.paramMap.get('sourceId');
this.targetId = this.activatedRoute.snapshot.paramMap.get('targetId');
this.qualityAssuranceTopicsService.setSourceId(this.sourceId);
this.qualityAssuranceTopicsService.setTargetId(this.targetId);
this.topics$ = this.notificationsStateService.getQualityAssuranceTopics();
this.totalElements$ = this.notificationsStateService.getQualityAssuranceTopicsTotals();
}

View File

@@ -13,6 +13,7 @@ import {
import { RequestParam } from '../../../core/cache/models/request-param.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { hasValue } from '../../../shared/empty.util';
/**
* The service handling all Quality Assurance topic requests to the REST service.
@@ -33,6 +34,11 @@ export class QualityAssuranceTopicsService {
*/
sourceId: string;
/**
* targetId used to get topics
*/
targetId: string;
/**
* Return the list of Quality Assurance topics managing pagination and errors.
*
@@ -53,6 +59,10 @@ export class QualityAssuranceTopicsService {
searchParams: [new RequestParam('source', this.sourceId)]
};
if (hasValue(this.targetId)) {
findListOptions.searchParams.push(new RequestParam('target', this.targetId));
}
return this.qualityAssuranceTopicRestService.getTopics(findListOptions).pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<PaginatedList<QualityAssuranceTopicObject>>) => {
@@ -72,4 +82,12 @@ export class QualityAssuranceTopicsService {
setSourceId(sourceId: string) {
this.sourceId = sourceId;
}
/**
* set targetId which is used to get topics
* @param targetId string
*/
setTargetId(targetId: string) {
this.targetId = targetId;
}
}

View File

@@ -2448,6 +2448,10 @@
"item.truncatable-part.show-less": "Collapse",
"item.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
"item.qa-event-notification-info.check.button": "Check",
"workflow-item.search.result.delete-supervision.modal.header": "Delete Supervision Order",
"workflow-item.search.result.delete-supervision.modal.info": "Are you sure you want to delete Supervision Order",

View File

@@ -3723,6 +3723,14 @@
// "item.truncatable-part.show-less": "Collapse",
"item.truncatable-part.show-less": "Riduci",
// "item.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
// TODO New key - Add a translation
"item.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
// "item.qa-event-notification-info.check.button": "Check",
// TODO New key - Add a translation
"item.qa-event-notification-info.check.button": "Check",
// "workflow-item.search.result.delete-supervision.modal.header": "Delete Supervision Order",
// TODO New key - Add a translation
"workflow-item.search.result.delete-supervision.modal.header": "Delete Supervision Order",