From e87c12cca30d98fc7ef19199323410a2f6cf082d Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Fri, 27 Oct 2023 18:28:52 +0200 Subject: [PATCH] [CST-12145] implementation of item-page & y dspace coar-notify notifications --- .../admin-notifications-routing.module.ts | 15 +++++ .../quality-assurance-event-data.service.ts | 18 +---- .../quality-assurance-topic-data.service.ts | 31 +-------- .../qa-event-notification.component.html | 12 ++-- .../qa-event-notification.component.scss | 8 +++ .../qa-event-notification.component.ts | 67 ++++++++++++++----- ...ace-qa-events-notifications.component.html | 12 +++- ...ace-qa-events-notifications.component.scss | 8 +++ ...space-qa-events-notifications.component.ts | 31 ++++----- .../quality-assurance-topics.component.ts | 8 +++ .../quality-assurance-topics.service.ts | 18 +++++ src/assets/i18n/en.json5 | 4 ++ src/assets/i18n/it.json5 | 8 +++ 13 files changed, 153 insertions(+), 87 deletions(-) diff --git a/src/app/admin/admin-notifications/admin-notifications-routing.module.ts b/src/app/admin/admin-notifications/admin-notifications-routing.module.ts index 60fa679777..6d02ac8292 100644 --- a/src/app/admin/admin-notifications/admin-notifications-routing.module.ts +++ b/src/app/admin/admin-notifications/admin-notifications-routing.module.ts @@ -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}`, diff --git a/src/app/core/suggestion-notifications/qa/events/quality-assurance-event-data.service.ts b/src/app/core/suggestion-notifications/qa/events/quality-assurance-event-data.service.ts index 5e9a4f430b..6c333cc6f5 100644 --- a/src/app/core/suggestion-notifications/qa/events/quality-assurance-event-data.service.ts +++ b/src/app/core/suggestion-notifications/qa/events/quality-assurance-event-data.service.ts @@ -86,27 +86,11 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService[]): Observable>> { - options.searchParams = [ - { - fieldName: 'topic', - fieldValue: topic - } - ]; - - if (hasValue(target)) { - options.searchParams.push({ - fieldName: 'target', - fieldValue: target - }); - } - + public searchEventsByTopic(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig[]): Observable>> { return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow); } diff --git a/src/app/core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service.ts b/src/app/core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service.ts index 92ae87e252..626674a5ad 100644 --- a/src/app/core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service.ts +++ b/src/app/core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service.ts @@ -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>. - */ - public getTopicsByTargetAndSource(target: string, source?: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { - 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 */ diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html index be0e7ac763..eb663fceb0 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html @@ -1,5 +1,9 @@ - - asdfasdf - + +
+ +
+
{{'item.qa-event-notification.check.notification-info' | translate : {num: (events$ | async)?.length} }}
+ +
+
-asfasdfasdf diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.scss b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.scss index e69de29bb2..1cc0db27c8 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.scss +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.scss @@ -0,0 +1,8 @@ + +.notify-logo { + max-height: var(--ds-header-logo-height); +} + +.sections-gap { + gap: 1rem; +} diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts index ecb9904cef..455629c026 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts @@ -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; + /** + * 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')}); + ); } } diff --git a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.html b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.html index db0611e8f8..fb73cff905 100644 --- a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.html +++ b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.html @@ -1 +1,11 @@ -

my-dspace-qa-events-notifications works!

+ + +
+ +
+
{{'item.qa-event-notification.check.notification-info' | translate : {num: source.totalEvents} }}
+ +
+
+
+
diff --git a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.scss b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.scss index e69de29bb2..1cc0db27c8 100644 --- a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.scss +++ b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.scss @@ -0,0 +1,8 @@ + +.notify-logo { + max-height: var(--ds-header-logo-height); +} + +.sections-gap { + gap: 1rem; +} diff --git a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.ts b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.ts index d0c42d9bcb..8b7127dd89 100644 --- a/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.ts +++ b/src/app/my-dspace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.ts @@ -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 = 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) => { - 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(), + ); } } diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts index 3c8b4f8f38..6d96795ea3 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts @@ -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(); } diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts index 6820791dff..c94ffe72d4 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts @@ -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>) => { @@ -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; + } } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 7a68fc60c8..7e0eea931e 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -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", diff --git a/src/assets/i18n/it.json5 b/src/assets/i18n/it.json5 index 4131d0bee6..961fea3ae7 100644 --- a/src/assets/i18n/it.json5 +++ b/src/assets/i18n/it.json5 @@ -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",