mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[CST-12109] porting of box thatallows undo of QAEvent request
This commit is contained in:
@@ -86,6 +86,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
|
||||
*/
|
||||
|
@@ -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 } from '../../../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
|
||||
@@ -84,4 +88,17 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -103,6 +104,7 @@ const DECLARATIONS = [
|
||||
ItemAlertsComponent,
|
||||
ThemedItemAlertsComponent,
|
||||
BitstreamRequestACopyPageComponent,
|
||||
QaEventNotificationComponent
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@@ -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>
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<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>
|
||||
Added file
|
@@ -0,0 +1,7 @@
|
||||
.source-logo {
|
||||
max-height: var(--ds-header-logo-height);
|
||||
}
|
||||
|
||||
.sections-gap {
|
||||
gap: 1rem;
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
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();
|
||||
});
|
||||
});
|
@@ -0,0 +1,48 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators';
|
||||
import { Observable } 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: [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,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>
|
||||
</div>
|
||||
|
||||
|
@@ -15,6 +15,9 @@ import { MyDSpaceNewExternalDropdownComponent } from './my-dspace-new-submission
|
||||
import { ThemedMyDSpacePageComponent } from './themed-my-dspace-page.component';
|
||||
import { SearchModule } from '../shared/search/search.module';
|
||||
import { UploadModule } from '../shared/upload/upload.module';
|
||||
import {
|
||||
MyDspaceQaEventsNotificationsComponent
|
||||
} from './my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component';
|
||||
|
||||
const DECLARATIONS = [
|
||||
MyDSpacePageComponent,
|
||||
@@ -22,7 +25,8 @@ const DECLARATIONS = [
|
||||
MyDSpaceNewSubmissionComponent,
|
||||
CollectionSelectorComponent,
|
||||
MyDSpaceNewSubmissionDropdownComponent,
|
||||
MyDSpaceNewExternalDropdownComponent
|
||||
MyDSpaceNewExternalDropdownComponent,
|
||||
MyDspaceQaEventsNotificationsComponent
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@@ -0,0 +1,25 @@
|
||||
<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>
|
@@ -0,0 +1,6 @@
|
||||
.source-logo {
|
||||
max-height: var(--ds-header-logo-height);
|
||||
}
|
||||
.sections-gap {
|
||||
gap: 1rem;
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
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(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -287,6 +287,7 @@ import { NgxPaginationModule } from 'ngx-pagination';
|
||||
import {
|
||||
QualityAssuranceEventDataService
|
||||
} from '../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
|
||||
import { SplitPipe } from './utils/split.pipe';
|
||||
|
||||
const MODULES = [
|
||||
CommonModule,
|
||||
@@ -326,7 +327,8 @@ const PIPES = [
|
||||
ObjNgFor,
|
||||
BrowserOnlyPipe,
|
||||
MarkdownPipe,
|
||||
ShortNumberPipe
|
||||
ShortNumberPipe,
|
||||
SplitPipe
|
||||
];
|
||||
|
||||
const COMPONENTS = [
|
||||
|
10
src/app/shared/utils/split.pipe.ts
Normal file
10
src/app/shared/utils/split.pipe.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
@Pipe({
|
||||
name: 'dsSplit'
|
||||
})
|
||||
export class SplitPipe implements PipeTransform {
|
||||
transform(value: string, separator: string): string[] {
|
||||
return value.split(separator);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user