Skip to content

Commit

Permalink
Merged in coar-CST-12145 (pull request DSpace#967)
Browse files Browse the repository at this point in the history
Coar CST-12145

Approved-by: Andrea Bollini
  • Loading branch information
alisaismailati authored and abollini committed Nov 3, 2023
2 parents 2790f1e + d31dc4d commit 9ffc778
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
}

/**
* Service for retrieving Quality Assurance events by topic and target.
* @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 searchEventsByTopic(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceEventObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceEventObject>>> {
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
}

/**
* Clear findByTopic requests from cache
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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 { SearchData, SearchDataImpl } from '../../../../core/data/base/search-data';

/**
* The service handling all Quality Assurance topic REST requests.
Expand All @@ -25,6 +26,9 @@ import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
export class QualityAssuranceTopicDataService extends IdentifiableDataService<QualityAssuranceTopicObject> {

private findAllData: FindAllData<QualityAssuranceTopicObject>;
private searchData: SearchData<QualityAssuranceTopicObject>;

private searchByTargetMethod = 'byTarget';

/**
* Initialize service variables
Expand All @@ -43,6 +47,7 @@ export class QualityAssuranceTopicDataService extends IdentifiableDataService<Qu
) {
super('qualityassurancetopics', requestService, rdbService, objectCache, halService);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
}

/**
Expand All @@ -62,6 +67,18 @@ export class QualityAssuranceTopicDataService extends IdentifiableDataService<Qu
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}

/**
* Search for Quality Assurance topics.
* @param options The search options.
* @param useCachedVersionIfAvailable Whether to use cached version if available.
* @param reRequestOnStale Whether to re-request on stale.
* @param linksToFollow The links to follow.
* @returns An observable of remote data containing a paginated list of Quality Assurance topics.
*/
public searchTopics(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceTopicObject>>> {
return this.searchData.searchBy(this.searchByTargetMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}

/**
* Clear FindAll topics requests from cache
*/
Expand Down
2 changes: 2 additions & 0 deletions src/app/item-page/item-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { ThemedItemAlertsComponent } from './alerts/themed-item-alerts.component
import {
ThemedFullFileSectionComponent
} from './full/field-components/file-section/themed-full-file-section.component';
import { QaEventNotificationComponent } from './simple/qa-event-notification/qa-event-notification.component';

const ENTRY_COMPONENTS = [
// put only entry components that use custom decorator
Expand Down Expand Up @@ -103,6 +104,7 @@ const DECLARATIONS = [
ItemAlertsComponent,
ThemedItemAlertsComponent,
BitstreamRequestACopyPageComponent,
QaEventNotificationComponent
];

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/app/item-page/simple/item-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
<div *ngIf="itemRD?.payload as item">
<ds-themed-item-alerts [item]="item"></ds-themed-item-alerts>
<ds-qa-event-notification [item]="item"></ds-qa-event-notification>
<ds-item-versions-notice [item]="item"></ds-item-versions-notice>
<ds-view-tracker [object]="item"></ds-view-tracker>
<ds-listable-object-component-loader *ngIf="!item.isWithdrawn || (isAdmin$|async)" [object]="item" [viewMode]="viewMode"></ds-listable-object-component-loader>
Expand Down
2 changes: 1 addition & 1 deletion src/app/item-page/simple/item-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { NotifyInfoService } from 'src/app/core/coar-notify/notify-info/notify-i
styleUrls: ['./item-page.component.scss'],
templateUrl: './item-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [fadeInOut]
animations: [fadeInOut],
})
export class ItemPageComponent implements OnInit, OnDestroy {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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>
</ng-container>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.source-logo {
max-height: var(--ds-header-logo-height);
}

.sections-gap {
gap: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { QaEventNotificationComponent } from './qa-event-notification.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ QaEventNotificationComponent ]
})
.compileComponents();

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators';
import { Observable, tap } from 'rxjs';

Check failure on line 4 in src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'tap' is defined but never used

Check failure on line 4 in src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'tap' is defined but never used
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: [QualityAssuranceSourceDataService]
})
/**
* Component for displaying quality assurance event notifications for an item.
*/
export class QaEventNotificationComponent {

/**
* The item to display quality assurance event notifications for.
*/
@Input() item: Item;

/**
* The type of alert to display for the notification.
*/
AlertTypeInfo = AlertType.Info;

constructor(
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
) { }

/**
* 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>"
*/
getQualityAssuranceSources$(): Observable<QualityAssuranceSourceObject[]> {
const findListTopicOptions: FindListOptions = {
searchParams: [new RequestParam('target', this.item.uuid)]
};
return this.qualityAssuranceSourceDataService.getSourcesByTarget(findListTopicOptions)
.pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),
);
}
}
1 change: 1 addition & 0 deletions src/app/my-dspace-page/my-dspace-page.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="container">
<ds-my-dspace-qa-events-notifications></ds-my-dspace-qa-events-notifications>
<ds-my-dspace-new-submission *dsShowOnlyForRole="[roleTypeEnum.Submitter]"></ds-my-dspace-new-submission>
<ds-suggestions-notification></ds-suggestions-notification>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/app/my-dspace-page/my-dspace-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ import { ThemedMyDSpacePageComponent } from './themed-my-dspace-page.component';
import { SearchModule } from '../shared/search/search.module';
import { UploadModule } from '../shared/upload/upload.module';
import { SuggestionNotificationsModule } from '../suggestion-notifications/suggestion-notifications.module';
import { MyDspaceQaEventsNotificationsComponent } from './my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component';

const DECLARATIONS = [
MyDSpacePageComponent,
ThemedMyDSpacePageComponent,
MyDSpaceNewSubmissionComponent,
CollectionSelectorComponent,
MyDSpaceNewSubmissionDropdownComponent,
MyDSpaceNewExternalDropdownComponent
MyDSpaceNewExternalDropdownComponent,
MyDspaceQaEventsNotificationsComponent,
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<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="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">
{{
"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>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.source-logo {
max-height: var(--ds-header-logo-height);
}

.sections-gap {
gap: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MyDspaceQaEventsNotificationsComponent } from './my-dspace-qa-events-notifications.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MyDspaceQaEventsNotificationsComponent ]
})
.compileComponents();

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { QualityAssuranceSourceDataService } from '../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
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({
selector: 'ds-my-dspace-qa-events-notifications',
templateUrl: './my-dspace-qa-events-notifications.component.html',
styleUrls: ['./my-dspace-qa-events-notifications.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyDspaceQaEventsNotificationsComponent implements OnInit {

/**
* An Observable that emits an array of QualityAssuranceSourceObject.
*/
sources$: Observable<QualityAssuranceSourceObject[]> = of([]);

constructor(private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService) { }

ngOnInit(): void {
this.getSources();
}

/**
* Retrieves the sources for Quality Assurance.
* @returns An Observable of the sources for Quality Assurance.
* @throws An error if the retrieval of Quality Assurance sources fails.
*/
getSources() {
this.sources$ = this.qualityAssuranceSourceDataService.getSources()
.pipe(
getFirstCompletedRemoteData(),
tap((rd) => {
if (rd.hasFailed) {
throw new Error('Can\'t retrieve Quality Assurance sources');
}
}),
getRemoteDataPayload(),
getPaginatedListPayload(),
);
}
}
Loading

0 comments on commit 9ffc778

Please sign in to comment.