[CST-12145] get qa-sources by target for item-page & refactor

This commit is contained in:
Alisa Ismailati
2023-11-02 17:49:19 +01:00
parent 8e0af9bcee
commit d31dc4d5fd
12 changed files with 94 additions and 61 deletions

View File

@@ -16,6 +16,7 @@ import { PaginatedList } from '../../../data/paginated-list.model';
import { FindListOptions } from '../../../data/find-list-options.model';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
import { SearchData, SearchDataImpl } from 'src/app/core/data/base/search-data';
/**
* The service handling all Quality Assurance source REST requests.
@@ -25,6 +26,9 @@ import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
export class QualityAssuranceSourceDataService extends IdentifiableDataService<QualityAssuranceSourceObject> {
private findAllData: FindAllData<QualityAssuranceSourceObject>;
private searchAllData: SearchData<QualityAssuranceSourceObject>;
private searchByTargetMethod = 'byTarget';
/**
* Initialize service variables
@@ -43,6 +47,7 @@ export class QualityAssuranceSourceDataService extends IdentifiableDataService<Q
) {
super('qualityassurancesources', requestService, rdbService, objectCache, halService);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.searchAllData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
}
/**
@@ -84,4 +89,16 @@ export class QualityAssuranceSourceDataService extends IdentifiableDataService<Q
public getSource(id: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<QualityAssuranceSourceObject>> {
return this.findById(id, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Retrieves a paginated list of QualityAssuranceSourceObject objects that are associated with a given target object.
* @param options The options for the search query.
* @param useCachedVersionIfAvailable Whether to use a cached version of the data if available.
* @param reRequestOnStale Whether to re-request the data if the cached version is stale.
* @param linksToFollow The links to follow to retrieve the data.
* @returns An observable that emits a RemoteData object containing the paginated list of QualityAssuranceSourceObject objects.
*/
public getSourcesByTarget(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceSourceObject>>> {
return this.searchAllData.searchBy(this.searchByTargetMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
}

View File

@@ -1,9 +1,14 @@
<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>
<ng-container *ngIf="(getQualityAssuranceSources$() | async)?.length > 0">
<ng-container *ngFor="let source of (getQualityAssuranceSources$() | async)">
<div class="alert alert-info d-flex flex-row" *ngIf="source.totalEvents > 0">
<img class="source-logo" src="assets/images/qa-{{(source.id | dsSplit: ':')[0]}}-logo.png" alt="{{source.id}} 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, item.id]"
class="btn btn-primary align-self-center">{{'item.qa-event-notification-info.check.button' | translate
}}</button>
</div>
</div>
</div>
</ng-container>
</ng-container>

View File

@@ -1,5 +1,5 @@
.notify-logo {
.source-logo {
max-height: var(--ds-header-logo-height);
}

View File

@@ -1,82 +1,50 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } 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 '../../../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 { Observable, tap } from 'rxjs';
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';
import { QualityAssuranceSourceDataService } from '../../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
import { QualityAssuranceSourceObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-source.model';
@Component({
selector: 'ds-qa-event-notification',
templateUrl: './qa-event-notification.component.html',
styleUrls: ['./qa-event-notification.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [QualityAssuranceTopicDataService, QualityAssuranceEventDataService]
providers: [QualityAssuranceSourceDataService]
})
/**
* Component for displaying quality assurance event notifications for an item.
*/
export class QaEventNotificationComponent implements OnInit {
export class QaEventNotificationComponent {
/**
* The item to display quality assurance event notifications for.
*/
@Input() item: Item;
/**
* 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,
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
) { }
ngOnInit() {
this.getEventsByTopicsAndTarget();
}
/**
* 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.
* Returns an Observable of QualityAssuranceSourceObject[] for the current item.
* @returns An Observable of QualityAssuranceSourceObject[] for the current item.
* Note: sourceId is composed as: id: "sourceName:<target>"
*/
getEventsByTopicsAndTarget() {
getQualityAssuranceSources$(): Observable<QualityAssuranceSourceObject[]> {
const findListTopicOptions: FindListOptions = {
searchParams: [new RequestParam('source', this.source), new RequestParam('target', this.item.id)]
searchParams: [new RequestParam('target', this.item.uuid)]
};
this.events$ = this.qualityAssuranceTopicDataService.searchTopics(findListTopicOptions).pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),
mergeMap((topics: QualityAssuranceTopicObject[]) => {
return from(topics).pipe(
concatMap((topic: QualityAssuranceTopicObject) => {
const findListEventOptions: FindListOptions = {
searchParams: [new RequestParam('topic', topic.name), new RequestParam('target', this.item.id)]
};
return this.qualityAssuranceEventDataService.searchEventsByTopic(findListEventOptions);
} )
);
}),
return this.qualityAssuranceSourceDataService.getSourcesByTarget(findListTopicOptions)
.pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),

View File

@@ -1,10 +1,27 @@
<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">
<ng-container *ngFor="let source of sources$ | async">
<div
class="alert alert-info d-flex flex-row"
*ngIf="source.totalEvents > 0"
>
<img
class="source-logo"
src="assets/images/qa-{{ source.id }}-logo.png"
alt="{{ source.id }} 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 class="pl-4 align-self-center">
{{
"mydspace.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"
>
{{ "mydspace.qa-event-notification-info.check.button" | translate }}
</button>
</div>
</div>
</ng-container>

View File

@@ -1,5 +1,5 @@
.notify-logo {
.source-logo {
max-height: var(--ds-header-logo-height);
}

View File

@@ -284,6 +284,7 @@ import {
} from '../item-page/simple/field-components/specific-field/title/themed-item-page-field.component';
import { BitstreamListItemComponent } from './object-list/bitstream-list-item/bitstream-list-item.component';
import { NgxPaginationModule } from 'ngx-pagination';
import { SplitPipe } from './utils/split.pipe';
const MODULES = [
CommonModule,
@@ -323,7 +324,8 @@ const PIPES = [
ObjNgFor,
BrowserOnlyPipe,
MarkdownPipe,
ShortNumberPipe
ShortNumberPipe,
SplitPipe,
];
const COMPONENTS = [

View File

@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'dsSplit'
})
export class SplitPipe implements PipeTransform {
transform(value: string, separator: string): string[] {
return value.split(separator);
}
}

View File

@@ -2452,6 +2452,10 @@
"item.qa-event-notification-info.check.button": "Check",
"mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
"mydspace.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

@@ -3731,6 +3731,14 @@
// TODO New key - Add a translation
"item.qa-event-notification-info.check.button": "Check",
// "mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
// TODO New key - Add a translation
"mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
// "mydspace.qa-event-notification-info.check.button": "Check",
// TODO New key - Add a translation
"mydspace.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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB