forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in coar-CST-12145 (pull request DSpace#967)
Coar CST-12145 Approved-by: Andrea Bollini
- Loading branch information
Showing
25 changed files
with
333 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
8 changes: 8 additions & 0 deletions
8
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / tests (16.x)
|
||
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(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...e-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
8 changes: 8 additions & 0 deletions
8
...e-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
23 changes: 23 additions & 0 deletions
23
...age/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
...ace-page/my-dspace-qa-events-notifications/my-dspace-qa-events-notifications.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
); | ||
} | ||
} |
Oops, something went wrong.