[CST-12145] partial commit

This commit is contained in:
Alisa Ismailati
2023-10-24 11:06:38 +02:00
parent 2eb71604ee
commit 318f057ca4
15 changed files with 184 additions and 2 deletions

View File

@@ -84,6 +84,32 @@ 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 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
});
}
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
}
/**
* Clear findByTopic requests from cache
*/

View File

@@ -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 { hasValue } from 'src/app/shared/empty.util';
/**
* The service handling all Quality Assurance topic REST requests.
@@ -62,6 +63,34 @@ 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.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Clear FindAll topics requests from cache
*/

View File

@@ -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({

View File

@@ -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>

View File

@@ -32,7 +32,7 @@ import { LinkDefinition, LinkHeadService } from '../../core/services/link-head.s
styleUrls: ['./item-page.component.scss'],
templateUrl: './item-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [fadeInOut]
animations: [fadeInOut],
})
export class ItemPageComponent implements OnInit, OnDestroy {

View File

@@ -0,0 +1 @@
<p>qa-event-notification works!</p>

View File

@@ -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();
});
});

View File

@@ -0,0 +1,34 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData } 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';
@Component({
selector: 'ds-qa-event-notification',
templateUrl: './qa-event-notification.component.html',
styleUrls: ['./qa-event-notification.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [QualityAssuranceTopicDataService, QualityAssuranceEventDataService]
})
export class QaEventNotificationComponent {
@Input() item: Item;
constructor(
protected qualityAssuranceEventDataService: QualityAssuranceEventDataService,
protected qualityAssuranceTopicDataService: QualityAssuranceTopicDataService,
) { }
ngOnInit(): void {
this.getTopics();
}
getTopics(): void {
this.qualityAssuranceTopicDataService.getTopicsByTargetAndSource(this.item.id, 'coar-notify', {}, true, true).pipe(
getFirstCompletedRemoteData(),
).subscribe((topics) => {
console.log(topics);
});
}
}

View File

@@ -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>

View File

@@ -16,6 +16,7 @@ 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,
@@ -23,7 +24,8 @@ const DECLARATIONS = [
MyDSpaceNewSubmissionComponent,
CollectionSelectorComponent,
MyDSpaceNewSubmissionDropdownComponent,
MyDSpaceNewExternalDropdownComponent
MyDSpaceNewExternalDropdownComponent,
MyDspaceQaEventsNotificationsComponent,
];
@NgModule({

View File

@@ -0,0 +1 @@
<p>my-dspace-qa-events-notifications works!</p>

View File

@@ -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();
});
});

View File

@@ -0,0 +1,39 @@
import { ChangeDetectionStrategy, Component } 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 { 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 {
constructor(private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService) { }
ngOnInit(): void {
this.getSources();
}
getSources() {
this.qualityAssuranceSourceDataService.getSource('coar-notify')
.pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<QualityAssuranceSourceObject>) => {
if (rd.hasSucceeded) {
return rd.payload;
} else {
throw new Error('Can\'t retrieve Quality Assurance source');
}
})
)
.subscribe((sources) => {
console.log(sources);
});
}
}