1
0

Autofix lint issues

This commit is contained in:
Yury Bondarenko
2023-12-19 09:42:08 +01:00
parent 4a87c9a8b4
commit ca1d81048a
58 changed files with 1617 additions and 1386 deletions

View File

@@ -4,18 +4,16 @@ import { RouterModule } from '@angular/router';
import { AuthenticatedGuard } from '../../core/auth/authenticated.guard'; import { AuthenticatedGuard } from '../../core/auth/authenticated.guard';
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver'; import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
import { I18nBreadcrumbsService } from '../../core/breadcrumbs/i18n-breadcrumbs.service'; import { I18nBreadcrumbsService } from '../../core/breadcrumbs/i18n-breadcrumbs.service';
import { QUALITY_ASSURANCE_EDIT_PATH } from './admin-notifications-routing-paths';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
import { AdminQualityAssuranceTopicsPageResolver } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
import { AdminQualityAssuranceEventsPageResolver } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.resolver';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import { AdminQualityAssuranceSourcePageResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
import { QualityAssuranceBreadcrumbResolver } from '../../core/breadcrumbs/quality-assurance-breadcrumb.resolver'; import { QualityAssuranceBreadcrumbResolver } from '../../core/breadcrumbs/quality-assurance-breadcrumb.resolver';
import { QualityAssuranceBreadcrumbService } from '../../core/breadcrumbs/quality-assurance-breadcrumb.service'; import { QualityAssuranceBreadcrumbService } from '../../core/breadcrumbs/quality-assurance-breadcrumb.service';
import { import { QUALITY_ASSURANCE_EDIT_PATH } from './admin-notifications-routing-paths';
SourceDataResolver import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
} from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.resolver'; import { AdminQualityAssuranceEventsPageResolver } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.resolver';
import { SourceDataResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.resolver';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import { AdminQualityAssuranceSourcePageResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
import { AdminQualityAssuranceTopicsPageResolver } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -27,13 +25,13 @@ import {
pathMatch: 'full', pathMatch: 'full',
resolve: { resolve: {
breadcrumb: QualityAssuranceBreadcrumbResolver, breadcrumb: QualityAssuranceBreadcrumbResolver,
openaireQualityAssuranceTopicsParams: AdminQualityAssuranceTopicsPageResolver openaireQualityAssuranceTopicsParams: AdminQualityAssuranceTopicsPageResolver,
}, },
data: { data: {
title: 'admin.quality-assurance.page.title', title: 'admin.quality-assurance.page.title',
breadcrumbKey: 'admin.quality-assurance', breadcrumbKey: 'admin.quality-assurance',
showBreadcrumbsFluid: false showBreadcrumbsFluid: false,
} },
}, },
{ {
canActivate: [ AuthenticatedGuard ], canActivate: [ AuthenticatedGuard ],
@@ -43,13 +41,13 @@ import {
resolve: { resolve: {
breadcrumb: I18nBreadcrumbResolver, breadcrumb: I18nBreadcrumbResolver,
openaireQualityAssuranceSourceParams: AdminQualityAssuranceSourcePageResolver, openaireQualityAssuranceSourceParams: AdminQualityAssuranceSourcePageResolver,
sourceData: SourceDataResolver sourceData: SourceDataResolver,
}, },
data: { data: {
title: 'admin.notifications.source.breadcrumbs', title: 'admin.notifications.source.breadcrumbs',
breadcrumbKey: 'admin.notifications.source', breadcrumbKey: 'admin.notifications.source',
showBreadcrumbsFluid: false showBreadcrumbsFluid: false,
} },
}, },
{ {
canActivate: [ AuthenticatedGuard ], canActivate: [ AuthenticatedGuard ],
@@ -58,15 +56,15 @@ import {
pathMatch: 'full', pathMatch: 'full',
resolve: { resolve: {
breadcrumb: QualityAssuranceBreadcrumbResolver, breadcrumb: QualityAssuranceBreadcrumbResolver,
openaireQualityAssuranceEventsParams: AdminQualityAssuranceEventsPageResolver openaireQualityAssuranceEventsParams: AdminQualityAssuranceEventsPageResolver,
}, },
data: { data: {
title: 'admin.notifications.event.page.title', title: 'admin.notifications.event.page.title',
breadcrumbKey: 'admin.notifications.event', breadcrumbKey: 'admin.notifications.event',
showBreadcrumbsFluid: false showBreadcrumbsFluid: false,
} },
} },
]) ]),
], ],
providers: [ providers: [
I18nBreadcrumbResolver, I18nBreadcrumbResolver,
@@ -76,8 +74,8 @@ import {
AdminQualityAssuranceEventsPageResolver, AdminQualityAssuranceEventsPageResolver,
AdminQualityAssuranceSourcePageResolver, AdminQualityAssuranceSourcePageResolver,
QualityAssuranceBreadcrumbResolver, QualityAssuranceBreadcrumbResolver,
QualityAssuranceBreadcrumbService QualityAssuranceBreadcrumbService,
] ],
}) })
/** /**
* Routing module for the Notifications section of the admin sidebar * Routing module for the Notifications section of the admin sidebar

View File

@@ -1,12 +1,13 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CoreModule } from '../../core/core.module'; import { CoreModule } from '../../core/core.module';
import { NotificationsModule } from '../../notifications/notifications.module';
import { SharedModule } from '../../shared/shared.module'; import { SharedModule } from '../../shared/shared.module';
import { AdminNotificationsRoutingModule } from './admin-notifications-routing.module'; import { AdminNotificationsRoutingModule } from './admin-notifications-routing.module';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component'; import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component'; import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import {NotificationsModule} from '../../notifications/notifications.module'; import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -14,14 +15,14 @@ import {NotificationsModule} from '../../notifications/notifications.module';
SharedModule, SharedModule,
CoreModule.forRoot(), CoreModule.forRoot(),
AdminNotificationsRoutingModule, AdminNotificationsRoutingModule,
NotificationsModule NotificationsModule,
], ],
declarations: [ declarations: [
AdminQualityAssuranceTopicsPageComponent, AdminQualityAssuranceTopicsPageComponent,
AdminQualityAssuranceEventsPageComponent, AdminQualityAssuranceEventsPageComponent,
AdminQualityAssuranceSourcePageComponent AdminQualityAssuranceSourcePageComponent,
], ],
entryComponents: [] entryComponents: [],
}) })
/** /**
* This module handles all components related to the notifications pages * This module handles all components related to the notifications pages

View File

@@ -1,5 +1,10 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {
async,
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page.component'; import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page.component';
describe('AdminQualityAssuranceEventsPageComponent', () => { describe('AdminQualityAssuranceEventsPageComponent', () => {
@@ -9,7 +14,7 @@ describe('AdminQualityAssuranceEventsPageComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceEventsPageComponent ], declarations: [ AdminQualityAssuranceEventsPageComponent ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}) })
.compileComponents(); .compileComponents();
})); }));

View File

@@ -5,7 +5,7 @@ import { Component } from '@angular/core';
*/ */
@Component({ @Component({
selector: 'ds-quality-assurance-events-page', selector: 'ds-quality-assurance-events-page',
templateUrl: './admin-quality-assurance-events-page.component.html' templateUrl: './admin-quality-assurance-events-page.component.html',
}) })
export class AdminQualityAssuranceEventsPageComponent { export class AdminQualityAssuranceEventsPageComponent {

View File

@@ -1,5 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import {
ActivatedRouteSnapshot,
Resolve,
RouterStateSnapshot,
} from '@angular/router';
/** /**
* Interface for the route parameters. * Interface for the route parameters.
@@ -26,7 +30,7 @@ export class AdminQualityAssuranceEventsPageResolver implements Resolve<AdminQua
return { return {
pageId: route.queryParams.pageId, pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10), pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10) currentPage: parseInt(route.queryParams.page, 10),
}; };
} }
} }

View File

@@ -1,11 +1,17 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Router } from '@angular/router'; import {
ActivatedRouteSnapshot,
Resolve,
Router,
RouterStateSnapshot,
} from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { environment } from '../../../../environments/environment';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model'; import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceService } from '../../../notifications/qa/source/quality-assurance-source.service'; import { QualityAssuranceSourceService } from '../../../notifications/qa/source/quality-assurance-source.service';
import {environment} from '../../../../environments/environment';
/** /**
* This class represents a resolver that retrieve the route data before the route is activated. * This class represents a resolver that retrieve the route data before the route is activated.
*/ */
@@ -18,7 +24,7 @@ export class SourceDataResolver implements Resolve<Observable<QualityAssuranceSo
*/ */
constructor( constructor(
private qualityAssuranceSourceService: QualityAssuranceSourceService, private qualityAssuranceSourceService: QualityAssuranceSourceService,
private router: Router private router: Router,
) { } ) { }
/** /**
* Method for resolving the parameters in the current route. * Method for resolving the parameters in the current route.

View File

@@ -1,5 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; import {
ActivatedRouteSnapshot,
Resolve,
RouterStateSnapshot,
} from '@angular/router';
/** /**
* Interface for the route parameters. * Interface for the route parameters.
@@ -26,7 +30,7 @@ export class AdminQualityAssuranceSourcePageResolver implements Resolve<AdminQua
return { return {
pageId: route.queryParams.pageId, pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10), pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10) currentPage: parseInt(route.queryParams.page, 10),
}; };
} }
} }

View File

@@ -1,5 +1,8 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page.component'; import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page.component';
@@ -10,7 +13,7 @@ describe('AdminQualityAssuranceSourcePageComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceSourcePageComponent ], declarations: [ AdminQualityAssuranceSourcePageComponent ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}) })
.compileComponents(); .compileComponents();
}); });

View File

@@ -1,5 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; import {
ActivatedRouteSnapshot,
Resolve,
RouterStateSnapshot,
} from '@angular/router';
/** /**
* Interface for the route parameters. * Interface for the route parameters.
@@ -26,7 +30,7 @@ export class AdminQualityAssuranceTopicsPageResolver implements Resolve<AdminQua
return { return {
pageId: route.queryParams.pageId, pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10), pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10) currentPage: parseInt(route.queryParams.page, 10),
}; };
} }
} }

View File

@@ -1,5 +1,10 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {
async,
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page.component'; import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page.component';
describe('AdminQualityAssuranceTopicsPageComponent', () => { describe('AdminQualityAssuranceTopicsPageComponent', () => {
@@ -9,7 +14,7 @@ describe('AdminQualityAssuranceTopicsPageComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceTopicsPageComponent ], declarations: [ AdminQualityAssuranceTopicsPageComponent ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}) })
.compileComponents(); .compileComponents();
})); }));

View File

@@ -5,7 +5,7 @@ import { Component } from '@angular/core';
*/ */
@Component({ @Component({
selector: 'ds-notification-qa-page', selector: 'ds-notification-qa-page',
templateUrl: './admin-quality-assurance-topics-page.component.html' templateUrl: './admin-quality-assurance-topics-page.component.html',
}) })
export class AdminQualityAssuranceTopicsPageComponent { export class AdminQualityAssuranceTopicsPageComponent {

View File

@@ -7,8 +7,8 @@ import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curati
import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component'; import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component';
import { MetadataImportPageComponent } from './admin-import-metadata-page/metadata-import-page.component'; import { MetadataImportPageComponent } from './admin-import-metadata-page/metadata-import-page.component';
import { import {
NOTIFICATIONS_MODULE_PATH,
REGISTRIES_MODULE_PATH, REGISTRIES_MODULE_PATH,
NOTIFICATIONS_MODULE_PATH
} from './admin-routing-paths'; } from './admin-routing-paths';
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component'; import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow-page.component'; import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow-page.component';

View File

@@ -15,8 +15,8 @@ describe('QualityAssuranceBreadcrumbResolver', () => {
return this[param]; return this[param];
}, },
sourceId: 'testSourceId', sourceId: 'testSourceId',
topicId: 'testTopicId' topicId: 'testTopicId',
} },
}; };
qualityAssuranceBreadcrumbService = {}; qualityAssuranceBreadcrumbService = {};
resolver = new QualityAssuranceBreadcrumbResolver(qualityAssuranceBreadcrumbService); resolver = new QualityAssuranceBreadcrumbResolver(qualityAssuranceBreadcrumbService);

View File

@@ -1,10 +1,15 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {QualityAssuranceBreadcrumbService} from './quality-assurance-breadcrumb.service'; import {
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router'; ActivatedRouteSnapshot,
Resolve,
RouterStateSnapshot,
} from '@angular/router';
import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model'; import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model';
import { QualityAssuranceBreadcrumbService } from './quality-assurance-breadcrumb.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root',
}) })
export class QualityAssuranceBreadcrumbResolver implements Resolve<BreadcrumbConfig<string>> { export class QualityAssuranceBreadcrumbResolver implements Resolve<BreadcrumbConfig<string>> {
constructor(protected breadcrumbService: QualityAssuranceBreadcrumbService) {} constructor(protected breadcrumbService: QualityAssuranceBreadcrumbService) {}

View File

@@ -1,6 +1,10 @@
import { TestBed, waitForAsync } from '@angular/core/testing'; import {
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; TestBed,
waitForAsync,
} from '@angular/core/testing';
import { getTestScheduler } from 'jasmine-marbles'; import { getTestScheduler } from 'jasmine-marbles';
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
import { QualityAssuranceBreadcrumbService } from './quality-assurance-breadcrumb.service'; import { QualityAssuranceBreadcrumbService } from './quality-assurance-breadcrumb.service';
describe('QualityAssuranceBreadcrumbService', () => { describe('QualityAssuranceBreadcrumbService', () => {
@@ -33,7 +37,7 @@ describe('QualityAssuranceBreadcrumbService', () => {
it('should return a breadcrumb based on a string', () => { it('should return a breadcrumb based on a string', () => {
const breadcrumbs = service.getBreadcrumbs(exampleString, exampleURL); const breadcrumbs = service.getBreadcrumbs(exampleString, exampleURL);
getTestScheduler().expectObservable(breadcrumbs).toBe('(a|)', { a: [new Breadcrumb(exampleQaKey, exampleURL), getTestScheduler().expectObservable(breadcrumbs).toBe('(a|)', { a: [new Breadcrumb(exampleQaKey, exampleURL),
new Breadcrumb(exampleString, exampleURL + exampleString)] new Breadcrumb(exampleString, exampleURL + exampleString)],
}); });
}); });
}); });

View File

@@ -1,11 +1,15 @@
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
import { BreadcrumbsProviderService } from './breadcrumbsProviderService';
import { Observable, of as observableOf } from 'rxjs';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { getFirstCompletedRemoteData } from '../shared/operators';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import {
Observable,
of as observableOf,
} from 'rxjs';
import { map } from 'rxjs/operators';
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
import { QualityAssuranceTopicDataService } from '../notifications/qa/topics/quality-assurance-topic-data.service'; import { QualityAssuranceTopicDataService } from '../notifications/qa/topics/quality-assurance-topic-data.service';
import { getFirstCompletedRemoteData } from '../shared/operators';
import { BreadcrumbsProviderService } from './breadcrumbsProviderService';
@@ -13,7 +17,7 @@ import { QualityAssuranceTopicDataService } from '../notifications/qa/topics/qua
* Service to calculate QA breadcrumbs for a single part of the route * Service to calculate QA breadcrumbs for a single part of the route
*/ */
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root',
}) })
export class QualityAssuranceBreadcrumbService implements BreadcrumbsProviderService<string> { export class QualityAssuranceBreadcrumbService implements BreadcrumbsProviderService<string> {
@@ -42,7 +46,7 @@ export class QualityAssuranceBreadcrumbService implements BreadcrumbsProviderSer
return [new Breadcrumb(this.translationService.instant(this.QUALITY_ASSURANCE_BREADCRUMB_KEY), url), return [new Breadcrumb(this.translationService.instant(this.QUALITY_ASSURANCE_BREADCRUMB_KEY), url),
new Breadcrumb(sourceId, `${url}${sourceId}`), new Breadcrumb(sourceId, `${url}${sourceId}`),
new Breadcrumb(topicId, undefined)]; new Breadcrumb(topicId, undefined)];
}) }),
); );
} else { } else {
return observableOf([new Breadcrumb(this.translationService.instant(this.QUALITY_ASSURANCE_BREADCRUMB_KEY), url), return observableOf([new Breadcrumb(this.translationService.instant(this.QUALITY_ASSURANCE_BREADCRUMB_KEY), url),

View File

@@ -1,8 +1,17 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; import {
ModuleWithProviders,
NgModule,
Optional,
SkipSelf,
} from '@angular/core';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { Action, StoreConfig, StoreModule } from '@ngrx/store'; import {
Action,
StoreConfig,
StoreModule,
} from '@ngrx/store';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
import { storeModuleConfig } from '../app.reducer'; import { storeModuleConfig } from '../app.reducer';
@@ -14,7 +23,11 @@ import { isNotEmpty } from '../shared/empty.util';
import { HostWindowService } from '../shared/host-window.service'; import { HostWindowService } from '../shared/host-window.service';
import { MenuService } from '../shared/menu/menu.service'; import { MenuService } from '../shared/menu/menu.service';
import { EndpointMockingRestService } from '../shared/mocks/dspace-rest/endpoint-mocking-rest.service'; import { EndpointMockingRestService } from '../shared/mocks/dspace-rest/endpoint-mocking-rest.service';
import { MOCK_RESPONSE_MAP, mockResponseMap, ResponseMapMock } from '../shared/mocks/dspace-rest/mocks/response-map.mock'; import {
MOCK_RESPONSE_MAP,
mockResponseMap,
ResponseMapMock,
} from '../shared/mocks/dspace-rest/mocks/response-map.mock';
import { NotificationsService } from '../shared/notifications/notifications.service'; import { NotificationsService } from '../shared/notifications/notifications.service';
import { AccessStatusObject } from '../shared/object-collection/shared/badges/access-status-badge/access-status.model'; import { AccessStatusObject } from '../shared/object-collection/shared/badges/access-status-badge/access-status.model';
import { IdentifierData } from '../shared/object-list/identifier-data/identifier-data.model'; import { IdentifierData } from '../shared/object-list/identifier-data/identifier-data.model';
@@ -94,6 +107,9 @@ import { JsonPatchOperationsBuilder } from './json-patch/builder/json-patch-oper
import { MetadataService } from './metadata/metadata.service'; import { MetadataService } from './metadata/metadata.service';
import { MetadataField } from './metadata/metadata-field.model'; import { MetadataField } from './metadata/metadata-field.model';
import { MetadataSchema } from './metadata/metadata-schema.model'; import { MetadataSchema } from './metadata/metadata-schema.model';
import { QualityAssuranceEventObject } from './notifications/qa/models/quality-assurance-event.model';
import { QualityAssuranceSourceObject } from './notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceTopicObject } from './notifications/qa/models/quality-assurance-topic.model';
import { OrcidHistory } from './orcid/model/orcid-history.model'; import { OrcidHistory } from './orcid/model/orcid-history.model';
import { OrcidQueue } from './orcid/model/orcid-queue.model'; import { OrcidQueue } from './orcid/model/orcid-queue.model';
import { OrcidAuthService } from './orcid/orcid-auth.service'; import { OrcidAuthService } from './orcid/orcid-auth.service';
@@ -108,7 +124,10 @@ import { ResourcePolicyDataService } from './resource-policy/resource-policy-dat
import { RoleService } from './roles/role.service'; import { RoleService } from './roles/role.service';
import { LinkHeadService } from './services/link-head.service'; import { LinkHeadService } from './services/link-head.service';
import { ServerResponseService } from './services/server-response.service'; import { ServerResponseService } from './services/server-response.service';
import { NativeWindowFactory, NativeWindowService } from './services/window.service'; import {
NativeWindowFactory,
NativeWindowService,
} from './services/window.service';
import { Authorization } from './shared/authorization.model'; import { Authorization } from './shared/authorization.model';
import { Bitstream } from './shared/bitstream.model'; import { Bitstream } from './shared/bitstream.model';
import { BitstreamFormat } from './shared/bitstream-format.model'; import { BitstreamFormat } from './shared/bitstream-format.model';
@@ -173,9 +192,6 @@ import { TaskObject } from './tasks/models/task-object.model';
import { WorkflowAction } from './tasks/models/workflow-action-object.model'; import { WorkflowAction } from './tasks/models/workflow-action-object.model';
import { PoolTaskDataService } from './tasks/pool-task-data.service'; import { PoolTaskDataService } from './tasks/pool-task-data.service';
import { TaskResponseParsingService } from './tasks/task-response-parsing.service'; import { TaskResponseParsingService } from './tasks/task-response-parsing.service';
import { QualityAssuranceTopicObject } from './notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceEventObject } from './notifications/qa/models/quality-assurance-event.model';
import { QualityAssuranceSourceObject } from './notifications/qa/models/quality-assurance-source.model';
/** /**
* When not in production, endpoint responses can be mocked for testing purposes * When not in production, endpoint responses can be mocked for testing purposes

View File

@@ -1,27 +1,29 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ReplaceOperation } from 'fast-json-patch';
import { TestScheduler } from 'rxjs/testing'; import {
cold,
getTestScheduler,
} from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing';
import { RequestService } from '../../../data/request.service';
import { buildPaginatedList } from '../../../data/paginated-list.model';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service';
import { RestResponse } from '../../../cache/response.models';
import { PageInfo } from '../../../shared/page-info.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { QualityAssuranceEventDataService } from './quality-assurance-event-data.service';
import { import {
qualityAssuranceEventObjectMissingPid, qualityAssuranceEventObjectMissingPid,
qualityAssuranceEventObjectMissingPid2, qualityAssuranceEventObjectMissingPid2,
qualityAssuranceEventObjectMissingProjectFound qualityAssuranceEventObjectMissingProjectFound,
} from '../../../../shared/mocks/notifications.mock'; } from '../../../../shared/mocks/notifications.mock';
import { ReplaceOperation } from 'fast-json-patch'; import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { RequestEntry } from '../../../data/request-entry.model'; import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service';
import { RestResponse } from '../../../cache/response.models';
import { FindListOptions } from '../../../data/find-list-options.model'; import { FindListOptions } from '../../../data/find-list-options.model';
import { buildPaginatedList } from '../../../data/paginated-list.model';
import { RequestService } from '../../../data/request.service';
import { RequestEntry } from '../../../data/request-entry.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { PageInfo } from '../../../shared/page-info.model';
import { QualityAssuranceEventDataService } from './quality-assurance-event-data.service';
describe('QualityAssuranceEventDataService', () => { describe('QualityAssuranceEventDataService', () => {
let scheduler: TestScheduler; let scheduler: TestScheduler;
@@ -54,8 +56,8 @@ describe('QualityAssuranceEventDataService', () => {
{ {
path: '/status', path: '/status',
op: 'replace', op: 'replace',
value: status value: status,
} },
]; ];
beforeEach(() => { beforeEach(() => {
@@ -69,7 +71,7 @@ describe('QualityAssuranceEventDataService', () => {
send: true, send: true,
removeByHrefSubstring: {}, removeByHrefSubstring: {},
getByHref: jasmine.createSpy('getByHref'), getByHref: jasmine.createSpy('getByHref'),
getByUUID: jasmine.createSpy('getByUUID') getByUUID: jasmine.createSpy('getByUUID'),
}); });
responseCacheEntryB = new RequestEntry(); responseCacheEntryB = new RequestEntry();
@@ -82,18 +84,18 @@ describe('QualityAssuranceEventDataService', () => {
rdbService = jasmine.createSpyObj('rdbService', { rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: cold('(a)', { buildSingle: cold('(a)', {
a: qaEventObjectRD a: qaEventObjectRD,
}), }),
buildList: cold('(a)', { buildList: cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}), }),
buildFromRequestUUID: jasmine.createSpy('buildFromRequestUUID'), buildFromRequestUUID: jasmine.createSpy('buildFromRequestUUID'),
buildFromRequestUUIDAndAwait: jasmine.createSpy('buildFromRequestUUIDAndAwait') buildFromRequestUUIDAndAwait: jasmine.createSpy('buildFromRequestUUIDAndAwait'),
}); });
objectCache = {} as ObjectCacheService; objectCache = {} as ObjectCacheService;
halService = jasmine.createSpyObj('halService', { halService = jasmine.createSpyObj('halService', {
getEndpoint: cold('a|', { a: endpointURL }) getEndpoint: cold('a|', { a: endpointURL }),
}); });
notificationsService = {} as NotificationsService; notificationsService = {} as NotificationsService;
@@ -106,7 +108,7 @@ describe('QualityAssuranceEventDataService', () => {
objectCache, objectCache,
halService, halService,
notificationsService, notificationsService,
comparator comparator,
); );
serviceASAny = service; serviceASAny = service;
@@ -130,9 +132,9 @@ describe('QualityAssuranceEventDataService', () => {
searchParams: [ searchParams: [
{ {
fieldName: 'topic', fieldName: 'topic',
fieldValue: topic fieldValue: topic,
} },
] ],
}; };
service.getEventsByTopic(topic); service.getEventsByTopic(topic);
expect(serviceASAny.searchData.searchBy).toHaveBeenCalledWith('findByTopic', options, true, true); expect(serviceASAny.searchData.searchBy).toHaveBeenCalledWith('findByTopic', options, true, true);
@@ -141,7 +143,7 @@ describe('QualityAssuranceEventDataService', () => {
it('should return a RemoteData<PaginatedList<QualityAssuranceEventObject>> for the object with the given Topic', () => { it('should return a RemoteData<PaginatedList<QualityAssuranceEventObject>> for the object with the given Topic', () => {
const result = service.getEventsByTopic(topic); const result = service.getEventsByTopic(topic);
const expected = cold('(a)', { const expected = cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -158,14 +160,14 @@ describe('QualityAssuranceEventDataService', () => {
service.getEvent(qualityAssuranceEventObjectMissingPid.id).subscribe( service.getEvent(qualityAssuranceEventObjectMissingPid.id).subscribe(
(res) => { (res) => {
expect(serviceASAny.findById).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid.id, true, true); expect(serviceASAny.findById).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid.id, true, true);
} },
); );
}); });
it('should return a RemoteData for the object with the given URL', () => { it('should return a RemoteData for the object with the given URL', () => {
const result = service.getEvent(qualityAssuranceEventObjectMissingPid.id); const result = service.getEvent(qualityAssuranceEventObjectMissingPid.id);
const expected = cold('(a)', { const expected = cold('(a)', {
a: qaEventObjectRD a: qaEventObjectRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -183,14 +185,14 @@ describe('QualityAssuranceEventDataService', () => {
service.patchEvent(status, qualityAssuranceEventObjectMissingPid).subscribe( service.patchEvent(status, qualityAssuranceEventObjectMissingPid).subscribe(
(res) => { (res) => {
expect(serviceASAny.patchData.patch).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid, operation); expect(serviceASAny.patchData.patch).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid, operation);
} },
); );
}); });
it('should return a RemoteData with HTTP 200', () => { it('should return a RemoteData with HTTP 200', () => {
const result = service.patchEvent(status, qualityAssuranceEventObjectMissingPid); const result = service.patchEvent(status, qualityAssuranceEventObjectMissingPid);
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingPid) a: createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingPid),
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -207,14 +209,14 @@ describe('QualityAssuranceEventDataService', () => {
service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID).subscribe( service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID).subscribe(
(res) => { (res) => {
expect(serviceASAny.postOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID); expect(serviceASAny.postOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID);
} },
); );
}); });
it('should return a RestResponse with HTTP 201', () => { it('should return a RestResponse with HTTP 201', () => {
const result = service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID); const result = service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID);
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingProjectFound) a: createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingProjectFound),
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -231,14 +233,14 @@ describe('QualityAssuranceEventDataService', () => {
service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id).subscribe( service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id).subscribe(
(res) => { (res) => {
expect(serviceASAny.deleteOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id); expect(serviceASAny.deleteOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id);
} },
); );
}); });
it('should return a RestResponse with HTTP 204', () => { it('should return a RestResponse with HTTP 204', () => {
const result = service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id); const result = service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id);
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject({}) a: createSuccessfulRemoteDataObject({}),
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });

View File

@@ -1,30 +1,47 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { find, take } from 'rxjs/operators';
import { ReplaceOperation } from 'fast-json-patch'; import { ReplaceOperation } from 'fast-json-patch';
import { Observable } from 'rxjs';
import {
find,
take,
} from 'rxjs/operators';
import { HALEndpointService } from '../../../shared/hal-endpoint.service'; import { hasValue } from '../../../../shared/empty.util';
import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service'; import { ObjectCacheService } from '../../../cache/object-cache.service';
import {
CreateData,
CreateDataImpl,
} from '../../../data/base/create-data';
import { dataService } from '../../../data/base/data-service.decorator'; import { dataService } from '../../../data/base/data-service.decorator';
import { RequestService } from '../../../data/request.service'; import {
DeleteData,
DeleteDataImpl,
} from '../../../data/base/delete-data';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import {
PatchData,
PatchDataImpl,
} from '../../../data/base/patch-data';
import {
SearchData,
SearchDataImpl,
} from '../../../data/base/search-data';
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
import { FindListOptions } from '../../../data/find-list-options.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { RemoteData } from '../../../data/remote-data'; import { RemoteData } from '../../../data/remote-data';
import {
DeleteByIDRequest,
PostRequest,
} from '../../../data/request.models';
import { RequestService } from '../../../data/request.service';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NoContent } from '../../../shared/NoContent.model';
import { QualityAssuranceEventObject } from '../models/quality-assurance-event.model'; import { QualityAssuranceEventObject } from '../models/quality-assurance-event.model';
import { QUALITY_ASSURANCE_EVENT_OBJECT } from '../models/quality-assurance-event-object.resource-type'; import { QUALITY_ASSURANCE_EVENT_OBJECT } from '../models/quality-assurance-event-object.resource-type';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { NoContent } from '../../../shared/NoContent.model';
import { FindListOptions } from '../../../data/find-list-options.model';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { CreateData, CreateDataImpl } from '../../../data/base/create-data';
import { PatchData, PatchDataImpl } from '../../../data/base/patch-data';
import { DeleteData, DeleteDataImpl } from '../../../data/base/delete-data';
import { SearchData, SearchDataImpl } from '../../../data/base/search-data';
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
import { hasValue } from '../../../../shared/empty.util';
import { DeleteByIDRequest, PostRequest } from '../../../data/request.models';
/** /**
* The service handling all Quality Assurance topic REST requests. * The service handling all Quality Assurance topic REST requests.
@@ -53,7 +70,7 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
protected halService: HALEndpointService, protected halService: HALEndpointService,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected comparator: DefaultChangeAnalyzer<QualityAssuranceEventObject> protected comparator: DefaultChangeAnalyzer<QualityAssuranceEventObject>,
) { ) {
super('qualityassuranceevents', requestService, rdbService, objectCache, halService); super('qualityassuranceevents', requestService, rdbService, objectCache, halService);
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive); this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
@@ -78,8 +95,8 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
options.searchParams = [ options.searchParams = [
{ {
fieldName: 'topic', fieldName: 'topic',
fieldValue: topic fieldValue: topic,
} },
]; ];
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow); return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
} }
@@ -122,8 +139,8 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
{ {
path: '/status', path: '/status',
op: 'replace', op: 'replace',
value: status value: status,
} },
]; ];
return this.patchData.patch(dso, operation); return this.patchData.patch(dso, operation);
} }
@@ -189,7 +206,7 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
const hrefObs = this.getIDHrefObs(objectId); const hrefObs = this.getIDHrefObs(objectId);
hrefObs.pipe( hrefObs.pipe(
take(1) take(1),
).subscribe((href: string) => { ).subscribe((href: string) => {
const request = new PostRequest(requestId, href + '/related?item=' + relatedItemId, body); const request = new PostRequest(requestId, href + '/related?item=' + relatedItemId, body);
if (hasValue(this.responseMsToLive)) { if (hasValue(this.responseMsToLive)) {

View File

@@ -1,15 +1,23 @@
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
import {
autoserialize,
autoserializeAs,
deserialize,
} from 'cerialize';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
import { QUALITY_ASSURANCE_EVENT_OBJECT } from './quality-assurance-event-object.resource-type'; import {
import { excludeFromEquals } from '../../../utilities/equals.decorators'; link,
import { ResourceType } from '../../../shared/resource-type'; typedObject,
} from '../../../cache/builders/build-decorators';
import { CacheableObject } from '../../../cache/cacheable-object.model';
import { RemoteData } from '../../../data/remote-data';
import { HALLink } from '../../../shared/hal-link.model'; import { HALLink } from '../../../shared/hal-link.model';
import { Item } from '../../../shared/item.model'; import { Item } from '../../../shared/item.model';
import { ITEM } from '../../../shared/item.resource-type'; import { ITEM } from '../../../shared/item.resource-type';
import { link, typedObject } from '../../../cache/builders/build-decorators'; import { ResourceType } from '../../../shared/resource-type';
import { RemoteData } from '../../../data/remote-data'; import { excludeFromEquals } from '../../../utilities/equals.decorators';
import {CacheableObject} from '../../../cache/cacheable-object.model'; import { QUALITY_ASSURANCE_EVENT_OBJECT } from './quality-assurance-event-object.resource-type';
/** /**
* The interface representing the Quality Assurance event message * The interface representing the Quality Assurance event message

View File

@@ -1,11 +1,14 @@
import { autoserialize, deserialize } from 'cerialize'; import {
autoserialize,
deserialize,
} from 'cerialize';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
import { typedObject } from '../../../cache/builders/build-decorators'; import { typedObject } from '../../../cache/builders/build-decorators';
import { QUALITY_ASSURANCE_SOURCE_OBJECT } from './quality-assurance-source-object.resource-type';
import { CacheableObject } from '../../../cache/cacheable-object.model'; import { CacheableObject } from '../../../cache/cacheable-object.model';
import { HALLink } from '../../../shared/hal-link.model';
import { ResourceType } from '../../../shared/resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { QUALITY_ASSURANCE_SOURCE_OBJECT } from './quality-assurance-source-object.resource-type';
/** /**
* The interface representing the Quality Assurance source model * The interface representing the Quality Assurance source model

View File

@@ -1,11 +1,14 @@
import { autoserialize, deserialize } from 'cerialize'; import {
autoserialize,
deserialize,
} from 'cerialize';
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from './quality-assurance-topic-object.resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
import { typedObject } from '../../../cache/builders/build-decorators'; import { typedObject } from '../../../cache/builders/build-decorators';
import { CacheableObject } from '../../../cache/cacheable-object.model'; import { CacheableObject } from '../../../cache/cacheable-object.model';
import { HALLink } from '../../../shared/hal-link.model';
import { ResourceType } from '../../../shared/resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from './quality-assurance-topic-object.resource-type';
/** /**
* The interface representing the Quality Assurance topic model * The interface representing the Quality Assurance topic model

View File

@@ -1,23 +1,25 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {
import { TestScheduler } from 'rxjs/testing'; cold,
getTestScheduler,
} from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing';
import { RequestService } from '../../../data/request.service'; import {
import { buildPaginatedList } from '../../../data/paginated-list.model'; qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid,
} from '../../../../shared/mocks/notifications.mock';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service'; import { ObjectCacheService } from '../../../cache/object-cache.service';
import { RestResponse } from '../../../cache/response.models'; import { RestResponse } from '../../../cache/response.models';
import { PageInfo } from '../../../shared/page-info.model'; import { buildPaginatedList } from '../../../data/paginated-list.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service'; import { RequestService } from '../../../data/request.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import {
qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid
} from '../../../../shared/mocks/notifications.mock';
import { RequestEntry } from '../../../data/request-entry.model'; import { RequestEntry } from '../../../data/request-entry.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { PageInfo } from '../../../shared/page-info.model';
import { QualityAssuranceSourceDataService } from './quality-assurance-source-data.service'; import { QualityAssuranceSourceDataService } from './quality-assurance-source-data.service';
describe('QualityAssuranceSourceDataService', () => { describe('QualityAssuranceSourceDataService', () => {
@@ -56,16 +58,16 @@ describe('QualityAssuranceSourceDataService', () => {
rdbService = jasmine.createSpyObj('rdbService', { rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: cold('(a)', { buildSingle: cold('(a)', {
a: qaSourceObjectRD a: qaSourceObjectRD,
}), }),
buildList: cold('(a)', { buildList: cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}), }),
}); });
objectCache = {} as ObjectCacheService; objectCache = {} as ObjectCacheService;
halService = jasmine.createSpyObj('halService', { halService = jasmine.createSpyObj('halService', {
getEndpoint: cold('a|', { a: endpointURL }) getEndpoint: cold('a|', { a: endpointURL }),
}); });
notificationsService = {} as NotificationsService; notificationsService = {} as NotificationsService;
@@ -77,7 +79,7 @@ describe('QualityAssuranceSourceDataService', () => {
rdbService, rdbService,
objectCache, objectCache,
halService, halService,
notificationsService notificationsService,
); );
spyOn((service as any).findAllData, 'findAll').and.callThrough(); spyOn((service as any).findAllData, 'findAll').and.callThrough();
@@ -89,7 +91,7 @@ describe('QualityAssuranceSourceDataService', () => {
service.getSources().subscribe( service.getSources().subscribe(
(res) => { (res) => {
expect((service as any).findAllData.findAll).toHaveBeenCalledWith({}, true, true); expect((service as any).findAllData.findAll).toHaveBeenCalledWith({}, true, true);
} },
); );
done(); done();
}); });
@@ -97,7 +99,7 @@ describe('QualityAssuranceSourceDataService', () => {
it('should return a RemoteData<PaginatedList<QualityAssuranceSourceObject>> for the object with the given URL', () => { it('should return a RemoteData<PaginatedList<QualityAssuranceSourceObject>> for the object with the given URL', () => {
const result = service.getSources(); const result = service.getSources();
const expected = cold('(a)', { const expected = cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -108,7 +110,7 @@ describe('QualityAssuranceSourceDataService', () => {
service.getSource(qualityAssuranceSourceObjectMorePid.id).subscribe( service.getSource(qualityAssuranceSourceObjectMorePid.id).subscribe(
(res) => { (res) => {
expect((service as any).findById).toHaveBeenCalledWith(qualityAssuranceSourceObjectMorePid.id, true, true); expect((service as any).findById).toHaveBeenCalledWith(qualityAssuranceSourceObjectMorePid.id, true, true);
} },
); );
done(); done();
}); });
@@ -116,7 +118,7 @@ describe('QualityAssuranceSourceDataService', () => {
it('should return a RemoteData<QualityAssuranceSourceObject> for the object with the given URL', () => { it('should return a RemoteData<QualityAssuranceSourceObject> for the object with the given URL', () => {
const result = service.getSource(qualityAssuranceSourceObjectMorePid.id); const result = service.getSource(qualityAssuranceSourceObjectMorePid.id);
const expected = cold('(a)', { const expected = cold('(a)', {
a: qaSourceObjectRD a: qaSourceObjectRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });

View File

@@ -1,21 +1,23 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service'; import { ObjectCacheService } from '../../../cache/object-cache.service';
import { dataService } from '../../../data/base/data-service.decorator'; import { dataService } from '../../../data/base/data-service.decorator';
import { RequestService } from '../../../data/request.service'; import {
FindAllData,
FindAllDataImpl,
} from '../../../data/base/find-all-data';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { FindListOptions } from '../../../data/find-list-options.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { RemoteData } from '../../../data/remote-data'; import { RemoteData } from '../../../data/remote-data';
import { RequestService } from '../../../data/request.service';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { QualityAssuranceSourceObject } from '../models/quality-assurance-source.model'; import { QualityAssuranceSourceObject } from '../models/quality-assurance-source.model';
import { QUALITY_ASSURANCE_SOURCE_OBJECT } from '../models/quality-assurance-source-object.resource-type'; import { QUALITY_ASSURANCE_SOURCE_OBJECT } from '../models/quality-assurance-source-object.resource-type';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
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';
/** /**
* The service handling all Quality Assurance source REST requests. * The service handling all Quality Assurance source REST requests.
@@ -39,7 +41,7 @@ export class QualityAssuranceSourceDataService extends IdentifiableDataService<Q
protected rdbService: RemoteDataBuildService, protected rdbService: RemoteDataBuildService,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
protected halService: HALEndpointService, protected halService: HALEndpointService,
protected notificationsService: NotificationsService protected notificationsService: NotificationsService,
) { ) {
super('qualityassurancesources', requestService, rdbService, objectCache, halService); super('qualityassurancesources', requestService, rdbService, objectCache, halService);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);

View File

@@ -1,24 +1,26 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {
import { TestScheduler } from 'rxjs/testing'; cold,
getTestScheduler,
} from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing';
import { RequestService } from '../../../data/request.service'; import {
import { buildPaginatedList } from '../../../data/paginated-list.model'; qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid,
} from '../../../../shared/mocks/notifications.mock';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service'; import { ObjectCacheService } from '../../../cache/object-cache.service';
import { RestResponse } from '../../../cache/response.models'; import { RestResponse } from '../../../cache/response.models';
import { PageInfo } from '../../../shared/page-info.model'; import { buildPaginatedList } from '../../../data/paginated-list.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service'; import { RequestService } from '../../../data/request.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { QualityAssuranceTopicDataService } from './quality-assurance-topic-data.service';
import {
qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid
} from '../../../../shared/mocks/notifications.mock';
import { RequestEntry } from '../../../data/request-entry.model'; import { RequestEntry } from '../../../data/request-entry.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { PageInfo } from '../../../shared/page-info.model';
import { QualityAssuranceTopicDataService } from './quality-assurance-topic-data.service';
describe('QualityAssuranceTopicDataService', () => { describe('QualityAssuranceTopicDataService', () => {
let scheduler: TestScheduler; let scheduler: TestScheduler;
@@ -56,16 +58,16 @@ describe('QualityAssuranceTopicDataService', () => {
rdbService = jasmine.createSpyObj('rdbService', { rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: cold('(a)', { buildSingle: cold('(a)', {
a: qaTopicObjectRD a: qaTopicObjectRD,
}), }),
buildList: cold('(a)', { buildList: cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}), }),
}); });
objectCache = {} as ObjectCacheService; objectCache = {} as ObjectCacheService;
halService = jasmine.createSpyObj('halService', { halService = jasmine.createSpyObj('halService', {
getEndpoint: cold('a|', { a: endpointURL }) getEndpoint: cold('a|', { a: endpointURL }),
}); });
notificationsService = {} as NotificationsService; notificationsService = {} as NotificationsService;
@@ -77,7 +79,7 @@ describe('QualityAssuranceTopicDataService', () => {
rdbService, rdbService,
objectCache, objectCache,
halService, halService,
notificationsService notificationsService,
); );
spyOn((service as any).findAllData, 'findAll').and.callThrough(); spyOn((service as any).findAllData, 'findAll').and.callThrough();
@@ -89,7 +91,7 @@ describe('QualityAssuranceTopicDataService', () => {
service.getTopics().subscribe( service.getTopics().subscribe(
(res) => { (res) => {
expect((service as any).findAllData.findAll).toHaveBeenCalledWith({}, true, true); expect((service as any).findAllData.findAll).toHaveBeenCalledWith({}, true, true);
} },
); );
done(); done();
}); });
@@ -97,7 +99,7 @@ describe('QualityAssuranceTopicDataService', () => {
it('should return a RemoteData<PaginatedList<QualityAssuranceTopicObject>> for the object with the given URL', () => { it('should return a RemoteData<PaginatedList<QualityAssuranceTopicObject>> for the object with the given URL', () => {
const result = service.getTopics(); const result = service.getTopics();
const expected = cold('(a)', { const expected = cold('(a)', {
a: paginatedListRD a: paginatedListRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -108,7 +110,7 @@ describe('QualityAssuranceTopicDataService', () => {
service.getTopic(qualityAssuranceTopicObjectMorePid.id).subscribe( service.getTopic(qualityAssuranceTopicObjectMorePid.id).subscribe(
(res) => { (res) => {
expect((service as any).findById).toHaveBeenCalledWith(qualityAssuranceTopicObjectMorePid.id, true, true); expect((service as any).findById).toHaveBeenCalledWith(qualityAssuranceTopicObjectMorePid.id, true, true);
} },
); );
done(); done();
}); });
@@ -116,7 +118,7 @@ describe('QualityAssuranceTopicDataService', () => {
it('should return a RemoteData<QualityAssuranceTopicObject> for the object with the given URL', () => { it('should return a RemoteData<QualityAssuranceTopicObject> for the object with the given URL', () => {
const result = service.getTopic(qualityAssuranceTopicObjectMorePid.id); const result = service.getTopic(qualityAssuranceTopicObjectMorePid.id);
const expected = cold('(a)', { const expected = cold('(a)', {
a: qaTopicObjectRD a: qaTopicObjectRD,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });

View File

@@ -1,21 +1,23 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../cache/object-cache.service'; import { ObjectCacheService } from '../../../cache/object-cache.service';
import { RequestService } from '../../../data/request.service';
import { RemoteData } from '../../../data/remote-data';
import { QualityAssuranceTopicObject } from '../models/quality-assurance-topic.model';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { FindListOptions } from '../../../data/find-list-options.model';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { dataService } from '../../../data/base/data-service.decorator'; import { dataService } from '../../../data/base/data-service.decorator';
import {
FindAllData,
FindAllDataImpl,
} from '../../../data/base/find-all-data';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { FindListOptions } from '../../../data/find-list-options.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { RemoteData } from '../../../data/remote-data';
import { RequestService } from '../../../data/request.service';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { QualityAssuranceTopicObject } from '../models/quality-assurance-topic.model';
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from '../models/quality-assurance-topic-object.resource-type'; import { QUALITY_ASSURANCE_TOPIC_OBJECT } from '../models/quality-assurance-topic-object.resource-type';
import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
/** /**
* The service handling all Quality Assurance topic REST requests. * The service handling all Quality Assurance topic REST requests.
@@ -39,7 +41,7 @@ export class QualityAssuranceTopicDataService extends IdentifiableDataService<Qu
protected rdbService: RemoteDataBuildService, protected rdbService: RemoteDataBuildService,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
protected halService: HALEndpointService, protected halService: HALEndpointService,
protected notificationsService: NotificationsService protected notificationsService: NotificationsService,
) { ) {
super('qualityassurancetopics', requestService, rdbService, objectCache, halService); super('qualityassurancetopics', requestService, rdbService, objectCache, halService);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);

View File

@@ -530,7 +530,7 @@ export class MenuResolver implements Resolve<boolean> {
createSiteAdministratorMenuSections() { createSiteAdministratorMenuSections() {
combineLatest([ combineLatest([
this.authorizationService.isAuthorized(FeatureID.AdministratorOf), this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
this.authorizationService.isAuthorized(FeatureID.CanSeeQA) this.authorizationService.isAuthorized(FeatureID.CanSeeQA),
]) ])
.subscribe(([authorized, canSeeQA]) => { .subscribe(([authorized, canSeeQA]) => {
const menuList = [ const menuList = [
@@ -541,10 +541,10 @@ export class MenuResolver implements Resolve<boolean> {
visible: authorized && canSeeQA, visible: authorized && canSeeQA,
model: { model: {
type: MenuItemType.TEXT, type: MenuItemType.TEXT,
text: 'menu.section.notifications' text: 'menu.section.notifications',
} as TextMenuItemModel, } as TextMenuItemModel,
icon: 'bell', icon: 'bell',
index: 4 index: 4,
}, },
{ {
id: 'notifications_quality-assurance', id: 'notifications_quality-assurance',
@@ -554,7 +554,7 @@ export class MenuResolver implements Resolve<boolean> {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.quality-assurance', text: 'menu.section.quality-assurance',
link: '/admin/notifications/quality-assurance' link: '/admin/notifications/quality-assurance',
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
/* Admin Search */ /* Admin Search */

View File

@@ -3,5 +3,5 @@ import { QualityAssuranceTopicsEffects } from './qa/topics/quality-assurance-top
export const notificationsEffects = [ export const notificationsEffects = [
QualityAssuranceTopicsEffects, QualityAssuranceTopicsEffects,
QualityAssuranceSourceEffects QualityAssuranceSourceEffects,
]; ];

View File

@@ -1,19 +1,23 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { Store, StoreModule } from '@ngrx/store'; import {
Store,
StoreModule,
} from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing'; import { provideMockStore } from '@ngrx/store/testing';
import { cold } from 'jasmine-marbles'; import { cold } from 'jasmine-marbles';
import { suggestionNotificationsReducers } from './notifications.reducer';
import { NotificationsStateService } from './notifications-state.service';
import { import {
qualityAssuranceSourceObjectMissingPid, qualityAssuranceSourceObjectMissingPid,
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMorePid,
qualityAssuranceTopicObjectMissingPid, qualityAssuranceTopicObjectMissingPid,
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid qualityAssuranceTopicObjectMorePid,
} from '../shared/mocks/notifications.mock'; } from '../shared/mocks/notifications.mock';
import { RetrieveAllTopicsAction } from './qa/topics/quality-assurance-topics.actions'; import { suggestionNotificationsReducers } from './notifications.reducer';
import { NotificationsStateService } from './notifications-state.service';
import { RetrieveAllSourceAction } from './qa/source/quality-assurance-source.actions'; import { RetrieveAllSourceAction } from './qa/source/quality-assurance-source.actions';
import { RetrieveAllTopicsAction } from './qa/topics/quality-assurance-topics.actions';
describe('NotificationsStateService', () => { describe('NotificationsStateService', () => {
let service: NotificationsStateService; let service: NotificationsStateService;
@@ -33,9 +37,9 @@ describe('NotificationsStateService', () => {
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0, totalElements: 0,
totalLoadedPages: 0 totalLoadedPages: 0,
} },
} },
}; };
} else { } else {
initialState = { initialState = {
@@ -44,16 +48,16 @@ describe('NotificationsStateService', () => {
topics: [ topics: [
qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMorePid,
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMissingPid qualityAssuranceTopicObjectMissingPid,
], ],
processing: false, processing: false,
loaded: true, loaded: true,
totalPages: 1, totalPages: 1,
currentPage: 1, currentPage: 1,
totalElements: 3, totalElements: 3,
totalLoadedPages: 1 totalLoadedPages: 1,
} },
} },
}; };
} }
} }
@@ -67,8 +71,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -83,7 +87,7 @@ describe('NotificationsStateService', () => {
it('Should return an empty array', () => { it('Should return an empty array', () => {
const result = service.getQualityAssuranceTopics(); const result = service.getQualityAssuranceTopics();
const expected = cold('(a)', { const expected = cold('(a)', {
a: [] a: [],
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -93,7 +97,7 @@ describe('NotificationsStateService', () => {
it('Should return zero (0)', () => { it('Should return zero (0)', () => {
const result = service.getQualityAssuranceTopicsTotalPages(); const result = service.getQualityAssuranceTopicsTotalPages();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -103,7 +107,7 @@ describe('NotificationsStateService', () => {
it('Should return minus one (0)', () => { it('Should return minus one (0)', () => {
const result = service.getQualityAssuranceTopicsCurrentPage(); const result = service.getQualityAssuranceTopicsCurrentPage();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -113,7 +117,7 @@ describe('NotificationsStateService', () => {
it('Should return zero (0)', () => { it('Should return zero (0)', () => {
const result = service.getQualityAssuranceTopicsTotals(); const result = service.getQualityAssuranceTopicsTotals();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -123,7 +127,7 @@ describe('NotificationsStateService', () => {
it('Should return TRUE', () => { it('Should return TRUE', () => {
const result = service.isQualityAssuranceTopicsLoading(); const result = service.isQualityAssuranceTopicsLoading();
const expected = cold('(a)', { const expected = cold('(a)', {
a: true a: true,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -133,7 +137,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceTopicsLoaded(); const result = service.isQualityAssuranceTopicsLoaded();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -143,7 +147,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceTopicsProcessing(); const result = service.isQualityAssuranceTopicsProcessing();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -159,8 +163,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -178,8 +182,8 @@ describe('NotificationsStateService', () => {
a: [ a: [
qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMorePid,
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMissingPid qualityAssuranceTopicObjectMissingPid,
] ],
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -189,7 +193,7 @@ describe('NotificationsStateService', () => {
it('Should return one (1)', () => { it('Should return one (1)', () => {
const result = service.getQualityAssuranceTopicsTotalPages(); const result = service.getQualityAssuranceTopicsTotalPages();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 1 a: 1,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -199,7 +203,7 @@ describe('NotificationsStateService', () => {
it('Should return minus zero (1)', () => { it('Should return minus zero (1)', () => {
const result = service.getQualityAssuranceTopicsCurrentPage(); const result = service.getQualityAssuranceTopicsCurrentPage();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 1 a: 1,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -209,7 +213,7 @@ describe('NotificationsStateService', () => {
it('Should return three (3)', () => { it('Should return three (3)', () => {
const result = service.getQualityAssuranceTopicsTotals(); const result = service.getQualityAssuranceTopicsTotals();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 3 a: 3,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -219,7 +223,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceTopicsLoading(); const result = service.isQualityAssuranceTopicsLoading();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -229,7 +233,7 @@ describe('NotificationsStateService', () => {
it('Should return TRUE', () => { it('Should return TRUE', () => {
const result = service.isQualityAssuranceTopicsLoaded(); const result = service.isQualityAssuranceTopicsLoaded();
const expected = cold('(a)', { const expected = cold('(a)', {
a: true a: true,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -239,7 +243,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceTopicsProcessing(); const result = service.isQualityAssuranceTopicsProcessing();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -255,8 +259,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -291,9 +295,9 @@ describe('NotificationsStateService', () => {
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0, totalElements: 0,
totalLoadedPages: 0 totalLoadedPages: 0,
} },
} },
}; };
} else { } else {
initialState = { initialState = {
@@ -302,16 +306,16 @@ describe('NotificationsStateService', () => {
source: [ source: [
qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMorePid,
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMissingPid qualityAssuranceSourceObjectMissingPid,
], ],
processing: false, processing: false,
loaded: true, loaded: true,
totalPages: 1, totalPages: 1,
currentPage: 1, currentPage: 1,
totalElements: 3, totalElements: 3,
totalLoadedPages: 1 totalLoadedPages: 1,
} },
} },
}; };
} }
} }
@@ -325,8 +329,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -341,7 +345,7 @@ describe('NotificationsStateService', () => {
it('Should return an empty array', () => { it('Should return an empty array', () => {
const result = service.getQualityAssuranceSource(); const result = service.getQualityAssuranceSource();
const expected = cold('(a)', { const expected = cold('(a)', {
a: [] a: [],
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -351,7 +355,7 @@ describe('NotificationsStateService', () => {
it('Should return zero (0)', () => { it('Should return zero (0)', () => {
const result = service.getQualityAssuranceSourceTotalPages(); const result = service.getQualityAssuranceSourceTotalPages();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -361,7 +365,7 @@ describe('NotificationsStateService', () => {
it('Should return minus one (0)', () => { it('Should return minus one (0)', () => {
const result = service.getQualityAssuranceSourceCurrentPage(); const result = service.getQualityAssuranceSourceCurrentPage();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -371,7 +375,7 @@ describe('NotificationsStateService', () => {
it('Should return zero (0)', () => { it('Should return zero (0)', () => {
const result = service.getQualityAssuranceSourceTotals(); const result = service.getQualityAssuranceSourceTotals();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 0 a: 0,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -381,7 +385,7 @@ describe('NotificationsStateService', () => {
it('Should return TRUE', () => { it('Should return TRUE', () => {
const result = service.isQualityAssuranceSourceLoading(); const result = service.isQualityAssuranceSourceLoading();
const expected = cold('(a)', { const expected = cold('(a)', {
a: true a: true,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -391,7 +395,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceSourceLoaded(); const result = service.isQualityAssuranceSourceLoaded();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -401,7 +405,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceSourceProcessing(); const result = service.isQualityAssuranceSourceProcessing();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -417,8 +421,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -436,8 +440,8 @@ describe('NotificationsStateService', () => {
a: [ a: [
qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMorePid,
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMissingPid qualityAssuranceSourceObjectMissingPid,
] ],
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -447,7 +451,7 @@ describe('NotificationsStateService', () => {
it('Should return one (1)', () => { it('Should return one (1)', () => {
const result = service.getQualityAssuranceSourceTotalPages(); const result = service.getQualityAssuranceSourceTotalPages();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 1 a: 1,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -457,7 +461,7 @@ describe('NotificationsStateService', () => {
it('Should return minus zero (1)', () => { it('Should return minus zero (1)', () => {
const result = service.getQualityAssuranceSourceCurrentPage(); const result = service.getQualityAssuranceSourceCurrentPage();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 1 a: 1,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -467,7 +471,7 @@ describe('NotificationsStateService', () => {
it('Should return three (3)', () => { it('Should return three (3)', () => {
const result = service.getQualityAssuranceSourceTotals(); const result = service.getQualityAssuranceSourceTotals();
const expected = cold('(a)', { const expected = cold('(a)', {
a: 3 a: 3,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -477,7 +481,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceSourceLoading(); const result = service.isQualityAssuranceSourceLoading();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -487,7 +491,7 @@ describe('NotificationsStateService', () => {
it('Should return TRUE', () => { it('Should return TRUE', () => {
const result = service.isQualityAssuranceSourceLoaded(); const result = service.isQualityAssuranceSourceLoaded();
const expected = cold('(a)', { const expected = cold('(a)', {
a: true a: true,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -497,7 +501,7 @@ describe('NotificationsStateService', () => {
it('Should return FALSE', () => { it('Should return FALSE', () => {
const result = service.isQualityAssuranceSourceProcessing(); const result = service.isQualityAssuranceSourceProcessing();
const expected = cold('(a)', { const expected = cold('(a)', {
a: false a: false,
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -513,8 +517,8 @@ describe('NotificationsStateService', () => {
], ],
providers: [ providers: [
provideMockStore({ initialState }), provideMockStore({ initialState }),
{ provide: NotificationsStateService, useValue: service } { provide: NotificationsStateService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });

View File

@@ -1,26 +1,30 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { select, Store } from '@ngrx/store'; import {
select,
Store,
} from '@ngrx/store';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { QualityAssuranceSourceObject } from '../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceTopicObject } from '../core/notifications/qa/models/quality-assurance-topic.model';
import { SuggestionNotificationsState } from './notifications.reducer';
import { RetrieveAllSourceAction } from './qa/source/quality-assurance-source.actions';
import { RetrieveAllTopicsAction } from './qa/topics/quality-assurance-topics.actions';
import { import {
getQualityAssuranceSourceCurrentPageSelector,
getQualityAssuranceSourceTotalPagesSelector,
getQualityAssuranceSourceTotalsSelector,
getQualityAssuranceTopicsCurrentPageSelector, getQualityAssuranceTopicsCurrentPageSelector,
getQualityAssuranceTopicsTotalPagesSelector, getQualityAssuranceTopicsTotalPagesSelector,
getQualityAssuranceTopicsTotalsSelector, getQualityAssuranceTopicsTotalsSelector,
isQualityAssuranceTopicsLoadedSelector,
qualityAssuranceTopicsObjectSelector,
isQualityAssuranceTopicsProcessingSelector,
qualityAssuranceSourceObjectSelector,
isQualityAssuranceSourceLoadedSelector, isQualityAssuranceSourceLoadedSelector,
isQualityAssuranceSourceProcessingSelector, isQualityAssuranceSourceProcessingSelector,
getQualityAssuranceSourceTotalPagesSelector, isQualityAssuranceTopicsLoadedSelector,
getQualityAssuranceSourceCurrentPageSelector, isQualityAssuranceTopicsProcessingSelector,
getQualityAssuranceSourceTotalsSelector qualityAssuranceSourceObjectSelector,
qualityAssuranceTopicsObjectSelector,
} from './selectors'; } from './selectors';
import { QualityAssuranceTopicObject } from '../core/notifications/qa/models/quality-assurance-topic.model';
import { SuggestionNotificationsState } from './notifications.reducer';
import { RetrieveAllTopicsAction } from './qa/topics/quality-assurance-topics.actions';
import { QualityAssuranceSourceObject } from '../core/notifications/qa/models/quality-assurance-source.model';
import { RetrieveAllSourceAction } from './qa/source/quality-assurance-source.actions';
/** /**
* The service handling the Notifications State. * The service handling the Notifications State.
@@ -56,7 +60,7 @@ export class NotificationsStateService {
public isQualityAssuranceTopicsLoading(): Observable<boolean> { public isQualityAssuranceTopicsLoading(): Observable<boolean> {
return this.store.pipe( return this.store.pipe(
select(isQualityAssuranceTopicsLoadedSelector), select(isQualityAssuranceTopicsLoadedSelector),
map((loaded: boolean) => !loaded) map((loaded: boolean) => !loaded),
); );
} }
@@ -144,7 +148,7 @@ export class NotificationsStateService {
public isQualityAssuranceSourceLoading(): Observable<boolean> { public isQualityAssuranceSourceLoading(): Observable<boolean> {
return this.store.pipe( return this.store.pipe(
select(isQualityAssuranceSourceLoadedSelector), select(isQualityAssuranceSourceLoadedSelector),
map((loaded: boolean) => !loaded) map((loaded: boolean) => !loaded),
); );
} }

View File

@@ -1,31 +1,32 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Action, StoreConfig, StoreModule } from '@ngrx/store'; import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module';
import { storeModuleConfig } from '../app.reducer';
import { QualityAssuranceTopicsComponent } from './qa/topics/quality-assurance-topics.component';
import { QualityAssuranceEventsComponent } from './qa/events/quality-assurance-events.component';
import { NotificationsStateService } from './notifications-state.service';
import { suggestionNotificationsReducers, SuggestionNotificationsState } from './notifications.reducer';
import { notificationsEffects } from './notifications-effects';
import { QualityAssuranceTopicsService } from './qa/topics/quality-assurance-topics.service';
import { import {
QualityAssuranceTopicDataService Action,
} from '../core/notifications/qa/topics/quality-assurance-topic-data.service'; StoreConfig,
import { StoreModule,
QualityAssuranceEventDataService } from '@ngrx/store';
} from '../core/notifications/qa/events/quality-assurance-event-data.service';
import { ProjectEntryImportModalComponent } from './qa/project-entry-import-modal/project-entry-import-modal.component';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { storeModuleConfig } from '../app.reducer';
import { CoreModule } from '../core/core.module';
import { QualityAssuranceEventDataService } from '../core/notifications/qa/events/quality-assurance-event-data.service';
import { QualityAssuranceSourceDataService } from '../core/notifications/qa/source/quality-assurance-source-data.service';
import { QualityAssuranceTopicDataService } from '../core/notifications/qa/topics/quality-assurance-topic-data.service';
import { SearchModule } from '../shared/search/search.module'; import { SearchModule } from '../shared/search/search.module';
import { SharedModule } from '../shared/shared.module';
import {
suggestionNotificationsReducers,
SuggestionNotificationsState,
} from './notifications.reducer';
import { notificationsEffects } from './notifications-effects';
import { NotificationsStateService } from './notifications-state.service';
import { QualityAssuranceEventsComponent } from './qa/events/quality-assurance-events.component';
import { ProjectEntryImportModalComponent } from './qa/project-entry-import-modal/project-entry-import-modal.component';
import { QualityAssuranceSourceComponent } from './qa/source/quality-assurance-source.component'; import { QualityAssuranceSourceComponent } from './qa/source/quality-assurance-source.component';
import { QualityAssuranceSourceService } from './qa/source/quality-assurance-source.service'; import { QualityAssuranceSourceService } from './qa/source/quality-assurance-source.service';
import { import { QualityAssuranceTopicsComponent } from './qa/topics/quality-assurance-topics.component';
QualityAssuranceSourceDataService import { QualityAssuranceTopicsService } from './qa/topics/quality-assurance-topics.service';
} from '../core/notifications/qa/source/quality-assurance-source-data.service';
const MODULES = [ const MODULES = [
CommonModule, CommonModule,
@@ -34,19 +35,19 @@ const MODULES = [
CoreModule.forRoot(), CoreModule.forRoot(),
StoreModule.forFeature('suggestionNotifications', suggestionNotificationsReducers, storeModuleConfig as StoreConfig<SuggestionNotificationsState, Action>), StoreModule.forFeature('suggestionNotifications', suggestionNotificationsReducers, storeModuleConfig as StoreConfig<SuggestionNotificationsState, Action>),
EffectsModule.forFeature(notificationsEffects), EffectsModule.forFeature(notificationsEffects),
TranslateModule TranslateModule,
]; ];
const COMPONENTS = [ const COMPONENTS = [
QualityAssuranceTopicsComponent, QualityAssuranceTopicsComponent,
QualityAssuranceEventsComponent, QualityAssuranceEventsComponent,
QualityAssuranceSourceComponent QualityAssuranceSourceComponent,
]; ];
const DIRECTIVES = [ ]; const DIRECTIVES = [ ];
const ENTRY_COMPONENTS = [ const ENTRY_COMPONENTS = [
ProjectEntryImportModalComponent ProjectEntryImportModalComponent,
]; ];
const PROVIDERS = [ const PROVIDERS = [
@@ -55,28 +56,28 @@ const PROVIDERS = [
QualityAssuranceSourceService, QualityAssuranceSourceService,
QualityAssuranceTopicDataService, QualityAssuranceTopicDataService,
QualityAssuranceSourceDataService, QualityAssuranceSourceDataService,
QualityAssuranceEventDataService QualityAssuranceEventDataService,
]; ];
@NgModule({ @NgModule({
imports: [ imports: [
...MODULES ...MODULES,
], ],
declarations: [ declarations: [
...COMPONENTS, ...COMPONENTS,
...DIRECTIVES, ...DIRECTIVES,
...ENTRY_COMPONENTS ...ENTRY_COMPONENTS,
], ],
providers: [ providers: [
...PROVIDERS ...PROVIDERS,
], ],
entryComponents: [ entryComponents: [
...ENTRY_COMPONENTS ...ENTRY_COMPONENTS,
], ],
exports: [ exports: [
...COMPONENTS, ...COMPONENTS,
...DIRECTIVES ...DIRECTIVES,
] ],
}) })
/** /**

View File

@@ -1,7 +1,11 @@
import { ActionReducerMap, createFeatureSelector } from '@ngrx/store'; import {
ActionReducerMap,
createFeatureSelector,
} from '@ngrx/store';
import { import {
qualityAssuranceSourceReducer, qualityAssuranceSourceReducer,
QualityAssuranceSourceState QualityAssuranceSourceState,
} from './qa/source/quality-assurance-source.reducer'; } from './qa/source/quality-assurance-source.reducer';
import { import {
qualityAssuranceTopicsReducer, qualityAssuranceTopicsReducer,
@@ -18,7 +22,7 @@ export interface SuggestionNotificationsState {
export const suggestionNotificationsReducers: ActionReducerMap<SuggestionNotificationsState> = { export const suggestionNotificationsReducers: ActionReducerMap<SuggestionNotificationsState> = {
qaTopic: qualityAssuranceTopicsReducer, qaTopic: qualityAssuranceTopicsReducer,
qaSource: qualityAssuranceSourceReducer qaSource: qualityAssuranceSourceReducer,
}; };
export const suggestionNotificationsSelector = createFeatureSelector<SuggestionNotificationsState>('suggestionNotifications'); export const suggestionNotificationsSelector = createFeatureSelector<SuggestionNotificationsState>('suggestionNotifications');

View File

@@ -1,47 +1,61 @@
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { of as observableOf } from 'rxjs';
import { import {
QualityAssuranceEventDataService Component,
} from '../../../core/notifications/qa/events/quality-assurance-event-data.service'; NO_ERRORS_SCHEMA,
import { QualityAssuranceEventsComponent } from './quality-assurance-events.component'; } from '@angular/core';
import {
ComponentFixture,
inject,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import {
cold,
getTestScheduler,
} from 'jasmine-marbles';
import { of as observableOf } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import {
SortDirection,
SortOptions,
} from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceEventDataService } from '../../../core/notifications/qa/events/quality-assurance-event-data.service';
import { QualityAssuranceEventObject } from '../../../core/notifications/qa/models/quality-assurance-event.model';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { PageInfo } from '../../../core/shared/page-info.model';
import { import {
getMockQualityAssuranceEventRestService, getMockQualityAssuranceEventRestService,
ItemMockPid10,
ItemMockPid8, ItemMockPid8,
ItemMockPid9, ItemMockPid9,
ItemMockPid10,
NotificationsMockDspaceObject, NotificationsMockDspaceObject,
qualityAssuranceEventObjectMissingProjectFound, qualityAssuranceEventObjectMissingProjectFound,
qualityAssuranceEventObjectMissingProjectNotFound qualityAssuranceEventObjectMissingProjectNotFound,
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock'; import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
import { createTestComponent } from '../../../shared/testing/utils.test'; import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import {
QualityAssuranceEventObject
} from '../../../core/notifications/qa/models/quality-assurance-event.model';
import { QualityAssuranceEventData } from '../project-entry-import-modal/project-entry-import-modal.component';
import { TestScheduler } from 'rxjs/testing';
import { cold, getTestScheduler } from 'jasmine-marbles';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { PageInfo } from '../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { import {
createNoContentRemoteDataObject$, createNoContentRemoteDataObject$,
createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject,
createSuccessfulRemoteDataObject$ createSuccessfulRemoteDataObject$,
} from '../../../shared/remote-data.utils'; } from '../../../shared/remote-data.utils';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
import { PaginationService } from '../../../core/pagination/pagination.service'; import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import { createTestComponent } from '../../../shared/testing/utils.test';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { QualityAssuranceEventData } from '../project-entry-import-modal/project-entry-import-modal.component';
import { QualityAssuranceEventsComponent } from './quality-assurance-events.component';
describe('QualityAssuranceEventsComponent test suite', () => { describe('QualityAssuranceEventsComponent test suite', () => {
let fixture: ComponentFixture<QualityAssuranceEventsComponent>; let fixture: ComponentFixture<QualityAssuranceEventsComponent>;
@@ -52,22 +66,22 @@ describe('QualityAssuranceEventsComponent test suite', () => {
const modalStub = { const modalStub = {
open: () => ( { result: new Promise((res, rej) => 'do') } ), open: () => ( { result: new Promise((res, rej) => 'do') } ),
close: () => null, close: () => null,
dismiss: () => null dismiss: () => null,
}; };
const qualityAssuranceEventRestServiceStub: any = getMockQualityAssuranceEventRestService(); const qualityAssuranceEventRestServiceStub: any = getMockQualityAssuranceEventRestService();
const activatedRouteParams = { const activatedRouteParams = {
qualityAssuranceEventsParams: { qualityAssuranceEventsParams: {
currentPage: 0, currentPage: 0,
pageSize: 10 pageSize: 10,
} },
}; };
const activatedRouteParamsMap = { const activatedRouteParamsMap = {
id: 'ENRICH!MISSING!PROJECT' id: 'ENRICH!MISSING!PROJECT',
}; };
const events: QualityAssuranceEventObject[] = [ const events: QualityAssuranceEventObject[] = [
qualityAssuranceEventObjectMissingProjectFound, qualityAssuranceEventObjectMissingProjectFound,
qualityAssuranceEventObjectMissingProjectNotFound qualityAssuranceEventObjectMissingProjectNotFound,
]; ];
const paginationService = new PaginationServiceStub(); const paginationService = new PaginationServiceStub();
@@ -82,7 +96,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
handle: ItemMockPid10.handle, handle: ItemMockPid10.handle,
reason: null, reason: null,
isRunning: false, isRunning: false,
target: ItemMockPid8 target: ItemMockPid8,
}; };
} }
@@ -97,7 +111,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
handle: null, handle: null,
reason: null, reason: null,
isRunning: false, isRunning: false,
target: ItemMockPid9 target: ItemMockPid9,
}; };
} }
@@ -118,9 +132,9 @@ describe('QualityAssuranceEventsComponent test suite', () => {
{ provide: NotificationsService, useValue: new NotificationsServiceStub() }, { provide: NotificationsService, useValue: new NotificationsServiceStub() },
{ provide: TranslateService, useValue: getMockTranslateService() }, { provide: TranslateService, useValue: getMockTranslateService() },
{ provide: PaginationService, useValue: paginationService }, { provide: PaginationService, useValue: paginationService },
QualityAssuranceEventsComponent QualityAssuranceEventsComponent,
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}).compileComponents().then(); }).compileComponents().then();
scheduler = getTestScheduler(); scheduler = getTestScheduler();
})); }));
@@ -166,8 +180,8 @@ describe('QualityAssuranceEventsComponent test suite', () => {
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: [ a: [
getQualityAssuranceEventData1(), getQualityAssuranceEventData1(),
getQualityAssuranceEventData2() getQualityAssuranceEventData2(),
] ],
}); });
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);
}); });
@@ -213,10 +227,10 @@ describe('QualityAssuranceEventsComponent test suite', () => {
externalSourceEntry: null, externalSourceEntry: null,
label: null, label: null,
importedObject: observableOf({ importedObject: observableOf({
indexableObject: NotificationsMockDspaceObject indexableObject: NotificationsMockDspaceObject,
}) }),
} },
} },
); );
scheduler.schedule(() => { scheduler.schedule(() => {
comp.openModalLookup(getQualityAssuranceEventData1()); comp.openModalLookup(getQualityAssuranceEventData1());
@@ -233,7 +247,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
const action = 'ACCEPTED'; const action = 'ACCEPTED';
spyOn(compAsAny, 'getQualityAssuranceEvents').and.returnValue(observableOf([ spyOn(compAsAny, 'getQualityAssuranceEvents').and.returnValue(observableOf([
getQualityAssuranceEventData1(), getQualityAssuranceEventData1(),
getQualityAssuranceEventData2() getQualityAssuranceEventData2(),
])); ]));
qualityAssuranceEventRestServiceStub.patchEvent.and.returnValue(createSuccessfulRemoteDataObject$({})); qualityAssuranceEventRestServiceStub.patchEvent.and.returnValue(createSuccessfulRemoteDataObject$({}));
@@ -292,14 +306,14 @@ describe('QualityAssuranceEventsComponent test suite', () => {
comp.topic = activatedRouteParamsMap.id; comp.topic = activatedRouteParamsMap.id;
const options: FindListOptions = Object.assign(new FindListOptions(), { const options: FindListOptions = Object.assign(new FindListOptions(), {
currentPage: comp.paginationConfig.currentPage, currentPage: comp.paginationConfig.currentPage,
elementsPerPage: comp.paginationConfig.pageSize elementsPerPage: comp.paginationConfig.pageSize,
}); });
const pageInfo = new PageInfo({ const pageInfo = new PageInfo({
elementsPerPage: comp.paginationConfig.pageSize, elementsPerPage: comp.paginationConfig.pageSize,
totalElements: 2, totalElements: 2,
totalPages: 1, totalPages: 1,
currentPage: comp.paginationConfig.currentPage currentPage: comp.paginationConfig.currentPage,
}); });
const array = [ const array = [
qualityAssuranceEventObjectMissingProjectFound, qualityAssuranceEventObjectMissingProjectFound,
@@ -310,7 +324,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
qualityAssuranceEventRestServiceStub.getEventsByTopic.and.returnValue(observableOf(paginatedListRD)); qualityAssuranceEventRestServiceStub.getEventsByTopic.and.returnValue(observableOf(paginatedListRD));
spyOn(compAsAny, 'fetchEvents').and.returnValue(observableOf([ spyOn(compAsAny, 'fetchEvents').and.returnValue(observableOf([
getQualityAssuranceEventData1(), getQualityAssuranceEventData1(),
getQualityAssuranceEventData2() getQualityAssuranceEventData2(),
])); ]));
scheduler.schedule(() => { scheduler.schedule(() => {
@@ -321,7 +335,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
expect(compAsAny.qualityAssuranceEventRestService.getEventsByTopic).toHaveBeenCalledWith( expect(compAsAny.qualityAssuranceEventRestService.getEventsByTopic).toHaveBeenCalledWith(
activatedRouteParamsMap.id, activatedRouteParamsMap.id,
options, options,
followLink('target'),followLink('related') followLink('target'),followLink('related'),
); );
expect(compAsAny.fetchEvents).toHaveBeenCalled(); expect(compAsAny.fetchEvents).toHaveBeenCalled();
}); });
@@ -333,7 +347,7 @@ describe('QualityAssuranceEventsComponent test suite', () => {
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``,
}) })
class TestComponent { class TestComponent {

View File

@@ -1,36 +1,56 @@
import { Component, OnDestroy, OnInit } from '@angular/core'; import {
Component,
OnDestroy,
OnInit,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject, combineLatest, from, Observable, of, Subscription } from 'rxjs'; import {
import { distinctUntilChanged, last, map, mergeMap, scan, switchMap, take, tap } from 'rxjs/operators'; BehaviorSubject,
combineLatest,
from,
Observable,
of,
Subscription,
} from 'rxjs';
import {
distinctUntilChanged,
last,
map,
mergeMap,
scan,
switchMap,
take,
tap,
} from 'rxjs/operators';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; import { environment } from '../../../../environments/environment';
import {
SortDirection,
SortOptions,
} from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { QualityAssuranceEventDataService } from '../../../core/notifications/qa/events/quality-assurance-event-data.service';
import { import {
QualityAssuranceEventObject,
SourceQualityAssuranceEventMessageObject, SourceQualityAssuranceEventMessageObject,
QualityAssuranceEventObject
} from '../../../core/notifications/qa/models/quality-assurance-event.model'; } from '../../../core/notifications/qa/models/quality-assurance-event.model';
import {
QualityAssuranceEventDataService
} from '../../../core/notifications/qa/events/quality-assurance-event-data.service';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { Metadata } from '../../../core/shared/metadata.utils';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { hasValue } from '../../../shared/empty.util';
import { ItemSearchResult } from '../../../shared/object-collection/shared/item-search-result.model';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import {
ProjectEntryImportModalComponent,
QualityAssuranceEventData
} from '../project-entry-import-modal/project-entry-import-modal.component';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { PaginationService } from '../../../core/pagination/pagination.service'; import { PaginationService } from '../../../core/pagination/pagination.service';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import { Metadata } from '../../../core/shared/metadata.utils';
import {environment} from '../../../../environments/environment'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { hasValue } from '../../../shared/empty.util';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { ItemSearchResult } from '../../../shared/object-collection/shared/item-search-result.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import {
ProjectEntryImportModalComponent,
QualityAssuranceEventData,
} from '../project-entry-import-modal/project-entry-import-modal.component';
/** /**
* Component to display the Quality Assurance event list. * Component to display the Quality Assurance event list.
@@ -49,7 +69,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
id: 'bep', id: 'bep',
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
pageSizeOptions: [5, 10, 20, 40, 60] pageSizeOptions: [5, 10, 20, 40, 60],
}); });
/** /**
* The Quality Assurance event list sort options. * The Quality Assurance event list sort options.
@@ -125,7 +145,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private qualityAssuranceEventRestService: QualityAssuranceEventDataService, private qualityAssuranceEventRestService: QualityAssuranceEventDataService,
private paginationService: PaginationService, private paginationService: PaginationService,
private translateService: TranslateService private translateService: TranslateService,
) { ) {
} }
@@ -146,7 +166,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
this.showTopic = id.replace(regEx, '/'); this.showTopic = id.replace(regEx, '/');
this.topic = id; this.topic = id;
return this.getQualityAssuranceEvents(); return this.getQualityAssuranceEvents();
}) }),
).subscribe((events: QualityAssuranceEventData[]) => { ).subscribe((events: QualityAssuranceEventData[]) => {
this.eventsUpdated$.next(events); this.eventsUpdated$.next(events);
this.isEventPageLoading.next(false); this.isEventPageLoading.next(false);
@@ -203,7 +223,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
}, },
(_reason) => { (_reason) => {
this.selectedReason = null; this.selectedReason = null;
} },
); );
} }
@@ -215,7 +235,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
*/ */
public openModalLookup(eventData: QualityAssuranceEventData): void { public openModalLookup(eventData: QualityAssuranceEventData): void {
this.modalRef = this.modalService.open(ProjectEntryImportModalComponent, { this.modalRef = this.modalService.open(ProjectEntryImportModalComponent, {
size: 'lg' size: 'lg',
}); });
const modalComp = this.modalRef.componentInstance; const modalComp = this.modalRef.componentInstance;
modalComp.externalSourceEntry = eventData; modalComp.externalSourceEntry = eventData;
@@ -228,9 +248,9 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
eventData, eventData,
object.indexableObject.id, object.indexableObject.id,
projectTitle.value, projectTitle.value,
object.indexableObject.handle object.indexableObject.handle,
); );
}) }),
); );
} }
@@ -250,20 +270,20 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
switchMap((rd: RemoteData<QualityAssuranceEventObject>) => { switchMap((rd: RemoteData<QualityAssuranceEventObject>) => {
if (rd.hasSucceeded) { if (rd.hasSucceeded) {
this.notificationsService.success( this.notificationsService.success(
this.translateService.instant('quality-assurance.event.action.saved') this.translateService.instant('quality-assurance.event.action.saved'),
); );
return this.getQualityAssuranceEvents(); return this.getQualityAssuranceEvents();
} else { } else {
this.notificationsService.error( this.notificationsService.error(
this.translateService.instant('quality-assurance.event.action.error') this.translateService.instant('quality-assurance.event.action.error'),
); );
return of(this.eventsUpdated$.value); return of(this.eventsUpdated$.value);
} }
}) }),
).subscribe((events: QualityAssuranceEventData[]) => { ).subscribe((events: QualityAssuranceEventData[]) => {
this.eventsUpdated$.next(events); this.eventsUpdated$.next(events);
eventData.isRunning = false; eventData.isRunning = false;
}) }),
); );
} }
@@ -286,7 +306,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
.subscribe((rd: RemoteData<QualityAssuranceEventObject>) => { .subscribe((rd: RemoteData<QualityAssuranceEventObject>) => {
if (rd.hasSucceeded) { if (rd.hasSucceeded) {
this.notificationsService.success( this.notificationsService.success(
this.translateService.instant('quality-assurance.event.project.bounded') this.translateService.instant('quality-assurance.event.project.bounded'),
); );
eventData.hasProject = true; eventData.hasProject = true;
eventData.projectTitle = projectTitle; eventData.projectTitle = projectTitle;
@@ -294,11 +314,11 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
eventData.projectId = projectId; eventData.projectId = projectId;
} else { } else {
this.notificationsService.error( this.notificationsService.error(
this.translateService.instant('quality-assurance.event.project.error') this.translateService.instant('quality-assurance.event.project.error'),
); );
} }
eventData.isRunning = false; eventData.isRunning = false;
}) }),
); );
} }
@@ -315,7 +335,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
.subscribe((rd: RemoteData<QualityAssuranceEventObject>) => { .subscribe((rd: RemoteData<QualityAssuranceEventObject>) => {
if (rd.hasSucceeded) { if (rd.hasSucceeded) {
this.notificationsService.success( this.notificationsService.success(
this.translateService.instant('quality-assurance.event.project.removed') this.translateService.instant('quality-assurance.event.project.removed'),
); );
eventData.hasProject = false; eventData.hasProject = false;
eventData.projectTitle = null; eventData.projectTitle = null;
@@ -323,11 +343,11 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
eventData.projectId = null; eventData.projectId = null;
} else { } else {
this.notificationsService.error( this.notificationsService.error(
this.translateService.instant('quality-assurance.event.project.error') this.translateService.instant('quality-assurance.event.project.error'),
); );
} }
eventData.isRunning = false; eventData.isRunning = false;
}) }),
); );
} }
@@ -356,7 +376,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
switchMap((options: FindListOptions) => this.qualityAssuranceEventRestService.getEventsByTopic( switchMap((options: FindListOptions) => this.qualityAssuranceEventRestService.getEventsByTopic(
this.topic, this.topic,
options, options,
followLink('target'), followLink('related') followLink('target'), followLink('related'),
)), )),
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
switchMap((rd: RemoteData<PaginatedList<QualityAssuranceEventObject>>) => { switchMap((rd: RemoteData<PaginatedList<QualityAssuranceEventObject>>) => {
@@ -374,7 +394,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
take(1), take(1),
tap(() => { tap(() => {
this.qualityAssuranceEventRestService.clearFindByTopicRequests(); this.qualityAssuranceEventRestService.clearFindByTopicRequests();
}) }),
); );
} }
@@ -401,7 +421,7 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
); );
const target$ = event.target.pipe( const target$ = event.target.pipe(
getFirstCompletedRemoteData() getFirstCompletedRemoteData(),
); );
return combineLatest([related$, target$]).pipe( return combineLatest([related$, target$]).pipe(
map(([relatedItemRD, targetItemRD]: [RemoteData<Item>, RemoteData<Item>]) => { map(([relatedItemRD, targetItemRD]: [RemoteData<Item>, RemoteData<Item>]) => {
@@ -424,11 +444,11 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
data.handle = relatedItemRD?.payload?.handle; data.handle = relatedItemRD?.payload?.handle;
} }
return data; return data;
}) }),
); );
}), }),
scan((acc: any, value: any) => [...acc, value], []), scan((acc: any, value: any) => [...acc, value], []),
last() last(),
); );
} }
} }

View File

@@ -1,25 +1,37 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; import {
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing'; Component,
NO_ERRORS_SCHEMA,
} from '@angular/core';
import {
async,
ComponentFixture,
inject,
TestBed,
} from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { SearchService } from '../../../core/shared/search/search.service';
import { Item } from '../../../core/shared/item.model';
import { createTestComponent } from '../../../shared/testing/utils.test';
import { ImportType, ProjectEntryImportModalComponent } from './project-entry-import-modal.component';
import { SelectableListService } from '../../../shared/object-list/selectable-list/selectable-list.service';
import { getMockSearchService } from '../../../shared/mocks/search-service.mock';
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { buildPaginatedList } from '../../../core/data/paginated-list.model'; import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { Item } from '../../../core/shared/item.model';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { SearchService } from '../../../core/shared/search/search.service';
import { import {
ItemMockPid10, ItemMockPid10,
NotificationsMockDspaceObject,
qualityAssuranceEventObjectMissingProjectFound, qualityAssuranceEventObjectMissingProjectFound,
NotificationsMockDspaceObject
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { getMockSearchService } from '../../../shared/mocks/search-service.mock';
import { SelectableListService } from '../../../shared/object-list/selectable-list/selectable-list.service';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
import { createTestComponent } from '../../../shared/testing/utils.test';
import {
ImportType,
ProjectEntryImportModalComponent,
} from './project-entry-import-modal.component';
const eventData = { const eventData = {
event: qualityAssuranceEventObjectMissingProjectFound, event: qualityAssuranceEventObjectMissingProjectFound,
@@ -30,28 +42,28 @@ const eventData = {
projectId: ItemMockPid10.id, projectId: ItemMockPid10.id,
handle: ItemMockPid10.handle, handle: ItemMockPid10.handle,
reason: null, reason: null,
isRunning: false isRunning: false,
}; };
const searchString = 'Test project to search'; const searchString = 'Test project to search';
const pagination = Object.assign( const pagination = Object.assign(
new PaginationComponentOptions(), { new PaginationComponentOptions(), {
id: 'notifications-project-bound', id: 'notifications-project-bound',
pageSize: 3 pageSize: 3,
} },
); );
const searchOptions = Object.assign(new PaginatedSearchOptions( const searchOptions = Object.assign(new PaginatedSearchOptions(
{ {
configuration: 'funding', configuration: 'funding',
query: searchString, query: searchString,
pagination: pagination pagination: pagination,
} },
)); ));
const pageInfo = new PageInfo({ const pageInfo = new PageInfo({
elementsPerPage: 3, elementsPerPage: 3,
totalElements: 1, totalElements: 1,
totalPages: 1, totalPages: 1,
currentPage: 1 currentPage: 1,
}); });
const array = [ const array = [
NotificationsMockDspaceObject, NotificationsMockDspaceObject,
@@ -83,9 +95,9 @@ describe('ProjectEntryImportModalComponent test suite', () => {
{ provide: NgbActiveModal, useValue: modalStub }, { provide: NgbActiveModal, useValue: modalStub },
{ provide: SearchService, useValue: searchServiceStub }, { provide: SearchService, useValue: searchServiceStub },
{ provide: SelectableListService, useValue: jasmine.createSpyObj('selectableListService', ['deselect', 'select', 'deselectAll']) }, { provide: SelectableListService, useValue: jasmine.createSpyObj('selectableListService', ['deselect', 'select', 'deselectAll']) },
ProjectEntryImportModalComponent ProjectEntryImportModalComponent,
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}).compileComponents().then(); }).compileComponents().then();
})); }));
@@ -203,7 +215,7 @@ describe('ProjectEntryImportModalComponent test suite', () => {
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``,
}) })
class TestComponent { class TestComponent {
eventData = eventData; eventData = eventData;

View File

@@ -1,23 +1,36 @@
import { Component, EventEmitter, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of as observableOf, Subscription } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { SearchResult } from '../../../shared/search/models/search-result.model';
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
import { CollectionElementLinkType } from '../../../shared/object-collection/collection-element-link.type';
import { Context } from '../../../core/shared/context.model';
import { SelectableListService } from '../../../shared/object-list/selectable-list/selectable-list.service';
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { SearchService } from '../../../core/shared/search/search.service';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { import {
SourceQualityAssuranceEventMessageObject, Component,
EventEmitter,
Input,
OnInit,
} from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import {
Observable,
of as observableOf,
Subscription,
} from 'rxjs';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data';
import {
QualityAssuranceEventObject, QualityAssuranceEventObject,
SourceQualityAssuranceEventMessageObject,
} from '../../../core/notifications/qa/models/quality-assurance-event.model'; } from '../../../core/notifications/qa/models/quality-assurance-event.model';
import { hasValue, isNotEmpty } from '../../../shared/empty.util'; import { Context } from '../../../core/shared/context.model';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { SearchService } from '../../../core/shared/search/search.service';
import {
hasValue,
isNotEmpty,
} from '../../../shared/empty.util';
import { CollectionElementLinkType } from '../../../shared/object-collection/collection-element-link.type';
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
import { SelectableListService } from '../../../shared/object-list/selectable-list/selectable-list.service';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
import { SearchResult } from '../../../shared/search/models/search-result.model';
/** /**
* The possible types of import for the external entry * The possible types of import for the external entry
@@ -79,7 +92,7 @@ export interface QualityAssuranceEventData {
@Component({ @Component({
selector: 'ds-project-entry-import-modal', selector: 'ds-project-entry-import-modal',
styleUrls: ['./project-entry-import-modal.component.scss'], styleUrls: ['./project-entry-import-modal.component.scss'],
templateUrl: './project-entry-import-modal.component.html' templateUrl: './project-entry-import-modal.component.html',
}) })
/** /**
* Component to display a modal window for linking a project to an Quality Assurance event * Component to display a modal window for linking a project to an Quality Assurance event
@@ -185,14 +198,14 @@ export class ProjectEntryImportModalComponent implements OnInit {
{ {
configuration: this.configuration, configuration: this.configuration,
query: this.projectTitle, query: this.projectTitle,
pagination: this.pagination pagination: this.pagination,
} },
)); ));
this.localEntitiesRD$ = this.searchService.search(this.searchOptions); this.localEntitiesRD$ = this.searchService.search(this.searchOptions);
this.subs.push( this.subs.push(
this.localEntitiesRD$.subscribe( this.localEntitiesRD$.subscribe(
() => this.isLoading$ = observableOf(false) () => this.isLoading$ = observableOf(false),
) ),
); );
} }
@@ -215,14 +228,14 @@ export class ProjectEntryImportModalComponent implements OnInit {
{ {
configuration: this.configuration, configuration: this.configuration,
query: (searchTitle) ? searchTitle.replace(filterRegEx, '') : searchTitle, query: (searchTitle) ? searchTitle.replace(filterRegEx, '') : searchTitle,
pagination: this.pagination pagination: this.pagination,
} },
)); ));
this.localEntitiesRD$ = this.searchService.search(this.searchOptions); this.localEntitiesRD$ = this.searchService.search(this.searchOptions);
this.subs.push( this.subs.push(
this.localEntitiesRD$.subscribe( this.localEntitiesRD$.subscribe(
() => this.isLoading$ = observableOf(false) () => this.isLoading$ = observableOf(false),
) ),
); );
} }
} }

View File

@@ -1,7 +1,8 @@
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { type } from '../../../shared/ngrx/type';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model'; import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { type } from '../../../shared/ngrx/type';
/** /**
* For each action type in an action group, make a simple * For each action type in an action group, make a simple
@@ -38,7 +39,7 @@ export class RetrieveAllSourceAction implements Action {
constructor(elementsPerPage: number, currentPage: number) { constructor(elementsPerPage: number, currentPage: number) {
this.payload = { this.payload = {
elementsPerPage, elementsPerPage,
currentPage currentPage,
}; };
} }
} }
@@ -80,7 +81,7 @@ export class AddSourceAction implements Action {
source, source,
totalPages, totalPages,
currentPage, currentPage,
totalElements totalElements,
}; };
} }

View File

@@ -1,20 +1,29 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; import {
Component,
NO_ERRORS_SCHEMA,
} from '@angular/core';
import {
ComponentFixture,
inject,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { cold } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { createTestComponent } from '../../../shared/testing/utils.test'; import { PaginationService } from '../../../core/pagination/pagination.service';
import { import {
getMockNotificationsStateService, getMockNotificationsStateService,
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid qualityAssuranceSourceObjectMorePid,
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { QualityAssuranceSourceComponent } from './quality-assurance-source.component';
import { NotificationsStateService } from '../../notifications-state.service';
import { cold } from 'jasmine-marbles';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
import { PaginationService } from '../../../core/pagination/pagination.service'; import { createTestComponent } from '../../../shared/testing/utils.test';
import { NotificationsStateService } from '../../notifications-state.service';
import { QualityAssuranceSourceComponent } from './quality-assurance-source.component';
describe('QualityAssuranceSourceComponent test suite', () => { describe('QualityAssuranceSourceComponent test suite', () => {
let fixture: ComponentFixture<QualityAssuranceSourceComponent>; let fixture: ComponentFixture<QualityAssuranceSourceComponent>;
@@ -24,8 +33,8 @@ describe('QualityAssuranceSourceComponent test suite', () => {
const activatedRouteParams = { const activatedRouteParams = {
qualityAssuranceSourceParams: { qualityAssuranceSourceParams: {
currentPage: 0, currentPage: 0,
pageSize: 5 pageSize: 5,
} },
}; };
const paginationService = new PaginationServiceStub(); const paginationService = new PaginationServiceStub();
@@ -43,13 +52,13 @@ describe('QualityAssuranceSourceComponent test suite', () => {
{ provide: NotificationsStateService, useValue: mockNotificationsStateService }, { provide: NotificationsStateService, useValue: mockNotificationsStateService },
{ provide: ActivatedRoute, useValue: { data: observableOf(activatedRouteParams), params: observableOf({}) } }, { provide: ActivatedRoute, useValue: { data: observableOf(activatedRouteParams), params: observableOf({}) } },
{ provide: PaginationService, useValue: paginationService }, { provide: PaginationService, useValue: paginationService },
QualityAssuranceSourceComponent QualityAssuranceSourceComponent,
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}).compileComponents().then(() => { }).compileComponents().then(() => {
mockNotificationsStateService.getQualityAssuranceSource.and.returnValue(observableOf([ mockNotificationsStateService.getQualityAssuranceSource.and.returnValue(observableOf([
qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMorePid,
qualityAssuranceSourceObjectMoreAbstract qualityAssuranceSourceObjectMoreAbstract,
])); ]));
mockNotificationsStateService.getQualityAssuranceSourceTotalPages.and.returnValue(observableOf(1)); mockNotificationsStateService.getQualityAssuranceSourceTotalPages.and.returnValue(observableOf(1));
mockNotificationsStateService.getQualityAssuranceSourceCurrentPage.and.returnValue(observableOf(0)); mockNotificationsStateService.getQualityAssuranceSourceCurrentPage.and.returnValue(observableOf(0));
@@ -103,11 +112,11 @@ describe('QualityAssuranceSourceComponent test suite', () => {
expect(comp.sources$).toBeObservable(cold('(a|)', { expect(comp.sources$).toBeObservable(cold('(a|)', {
a: [ a: [
qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMorePid,
qualityAssuranceSourceObjectMoreAbstract qualityAssuranceSourceObjectMoreAbstract,
] ],
})); }));
expect(comp.totalElements$).toBeObservable(cold('(a|)', { expect(comp.totalElements$).toBeObservable(cold('(a|)', {
a: 2 a: 2,
})); }));
}); });
@@ -122,13 +131,13 @@ describe('QualityAssuranceSourceComponent test suite', () => {
it(('isSourceLoading should return FALSE'), () => { it(('isSourceLoading should return FALSE'), () => {
expect(comp.isSourceLoading()).toBeObservable(cold('(a|)', { expect(comp.isSourceLoading()).toBeObservable(cold('(a|)', {
a: false a: false,
})); }));
}); });
it(('isSourceProcessing should return FALSE'), () => { it(('isSourceProcessing should return FALSE'), () => {
expect(comp.isSourceProcessing()).toBeObservable(cold('(a|)', { expect(comp.isSourceProcessing()).toBeObservable(cold('(a|)', {
a: false a: false,
})); }));
}); });
@@ -145,7 +154,7 @@ describe('QualityAssuranceSourceComponent test suite', () => {
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``,
}) })
class TestComponent { class TestComponent {

View File

@@ -1,13 +1,23 @@
import { Component, OnInit } from '@angular/core'; import {
import { PaginationService } from '../../../core/pagination/pagination.service'; Component,
import { Observable, Subscription } from 'rxjs'; OnInit,
import { distinctUntilChanged, take } from 'rxjs/operators'; } from '@angular/core';
import {
Observable,
Subscription,
} from 'rxjs';
import {
distinctUntilChanged,
take,
} from 'rxjs/operators';
import { AdminQualityAssuranceSourcePageParams } from '../../../admin/admin-notifications/admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
import { SortOptions } from '../../../core/cache/models/sort-options.model'; import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model'; import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { hasValue } from '../../../shared/empty.util';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { NotificationsStateService } from '../../notifications-state.service'; import { NotificationsStateService } from '../../notifications-state.service';
import { AdminQualityAssuranceSourcePageParams } from '../../../admin/admin-notifications/admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
import { hasValue } from '../../../shared/empty.util';
/** /**
* Component to display the Quality Assurance source list. * Component to display the Quality Assurance source list.
@@ -15,7 +25,7 @@ import { hasValue } from '../../../shared/empty.util';
@Component({ @Component({
selector: 'ds-quality-assurance-source', selector: 'ds-quality-assurance-source',
templateUrl: './quality-assurance-source.component.html', templateUrl: './quality-assurance-source.component.html',
styleUrls: ['./quality-assurance-source.component.scss'] styleUrls: ['./quality-assurance-source.component.scss'],
}) })
export class QualityAssuranceSourceComponent implements OnInit { export class QualityAssuranceSourceComponent implements OnInit {
@@ -26,7 +36,7 @@ export class QualityAssuranceSourceComponent implements OnInit {
public paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), { public paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'btp', id: 'btp',
pageSize: 10, pageSize: 10,
pageSizeOptions: [5, 10, 20, 40, 60] pageSizeOptions: [5, 10, 20, 40, 60],
}); });
/** /**
* The Quality Assurance source list sort options. * The Quality Assurance source list sort options.
@@ -71,10 +81,10 @@ export class QualityAssuranceSourceComponent implements OnInit {
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.subs.push( this.subs.push(
this.notificationsStateService.isQualityAssuranceSourceLoaded().pipe( this.notificationsStateService.isQualityAssuranceSourceLoaded().pipe(
take(1) take(1),
).subscribe(() => { ).subscribe(() => {
this.getQualityAssuranceSource(); this.getQualityAssuranceSource();
}) }),
); );
} }
@@ -107,7 +117,7 @@ export class QualityAssuranceSourceComponent implements OnInit {
).subscribe((options: PaginationComponentOptions) => { ).subscribe((options: PaginationComponentOptions) => {
this.notificationsStateService.dispatchRetrieveQualityAssuranceSource( this.notificationsStateService.dispatchRetrieveQualityAssuranceSource(
options.pageSize, options.pageSize,
options.currentPage options.currentPage,
); );
}); });
} }

View File

@@ -1,26 +1,31 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {
Actions,
createEffect,
ofType,
} from '@ngrx/effects';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { catchError, map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import {
catchError,
map,
switchMap,
tap,
withLatestFrom,
} from 'rxjs/operators';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceDataService } from '../../../core/notifications/qa/source/quality-assurance-source-data.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { import {
AddSourceAction, AddSourceAction,
QualityAssuranceSourceActionTypes, QualityAssuranceSourceActionTypes,
RetrieveAllSourceAction, RetrieveAllSourceAction,
RetrieveAllSourceErrorAction, RetrieveAllSourceErrorAction,
} from './quality-assurance-source.actions'; } from './quality-assurance-source.actions';
import {
QualityAssuranceSourceObject
} from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceService } from './quality-assurance-source.service'; import { QualityAssuranceSourceService } from './quality-assurance-source.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import {
QualityAssuranceSourceDataService
} from '../../../core/notifications/qa/source/quality-assurance-source-data.service';
/** /**
* Provides effect methods for the Quality Assurance source actions. * Provides effect methods for the Quality Assurance source actions.
@@ -37,19 +42,19 @@ export class QualityAssuranceSourceEffects {
switchMap(([action, currentState]: [RetrieveAllSourceAction, any]) => { switchMap(([action, currentState]: [RetrieveAllSourceAction, any]) => {
return this.qualityAssuranceSourceService.getSources( return this.qualityAssuranceSourceService.getSources(
action.payload.elementsPerPage, action.payload.elementsPerPage,
action.payload.currentPage action.payload.currentPage,
).pipe( ).pipe(
map((sources: PaginatedList<QualityAssuranceSourceObject>) => map((sources: PaginatedList<QualityAssuranceSourceObject>) =>
new AddSourceAction(sources.page, sources.totalPages, sources.currentPage, sources.totalElements) new AddSourceAction(sources.page, sources.totalPages, sources.currentPage, sources.totalElements),
), ),
catchError((error: Error) => { catchError((error: Error) => {
if (error) { if (error) {
console.error(error.message); console.error(error.message);
} }
return observableOf(new RetrieveAllSourceErrorAction()); return observableOf(new RetrieveAllSourceErrorAction());
}) }),
); );
}) }),
)); ));
/** /**
@@ -59,7 +64,7 @@ export class QualityAssuranceSourceEffects {
ofType(QualityAssuranceSourceActionTypes.RETRIEVE_ALL_SOURCE_ERROR), ofType(QualityAssuranceSourceActionTypes.RETRIEVE_ALL_SOURCE_ERROR),
tap(() => { tap(() => {
this.notificationsService.error(null, this.translate.get('quality-assurance.source.error.service.retrieve')); this.notificationsService.error(null, this.translate.get('quality-assurance.source.error.service.retrieve'));
}) }),
), { dispatch: false }); ), { dispatch: false });
/** /**
@@ -69,7 +74,7 @@ export class QualityAssuranceSourceEffects {
ofType(QualityAssuranceSourceActionTypes.ADD_SOURCE), ofType(QualityAssuranceSourceActionTypes.ADD_SOURCE),
tap(() => { tap(() => {
this.qualityAssuranceSourceDataService.clearFindAllSourceRequests(); this.qualityAssuranceSourceDataService.clearFindAllSourceRequests();
}) }),
), { dispatch: false }); ), { dispatch: false });
/** /**
@@ -87,7 +92,7 @@ export class QualityAssuranceSourceEffects {
private translate: TranslateService, private translate: TranslateService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private qualityAssuranceSourceService: QualityAssuranceSourceService, private qualityAssuranceSourceService: QualityAssuranceSourceService,
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
) { ) {
} }
} }

View File

@@ -1,13 +1,16 @@
import {
qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid,
} from '../../../shared/mocks/notifications.mock';
import { import {
AddSourceAction, AddSourceAction,
RetrieveAllSourceAction, RetrieveAllSourceAction,
RetrieveAllSourceErrorAction RetrieveAllSourceErrorAction,
} from './quality-assurance-source.actions'; } from './quality-assurance-source.actions';
import { qualityAssuranceSourceReducer, QualityAssuranceSourceState } from './quality-assurance-source.reducer';
import { import {
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceReducer,
qualityAssuranceSourceObjectMorePid QualityAssuranceSourceState,
} from '../../../shared/mocks/notifications.mock'; } from './quality-assurance-source.reducer';
describe('qualityAssuranceSourceReducer test suite', () => { describe('qualityAssuranceSourceReducer test suite', () => {
let qualityAssuranceSourceInitialState: QualityAssuranceSourceState; let qualityAssuranceSourceInitialState: QualityAssuranceSourceState;
@@ -21,7 +24,7 @@ import {
loaded: false, loaded: false,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}; };
}); });
@@ -54,12 +57,12 @@ import {
loaded: true, loaded: true,
totalPages: 1, totalPages: 1,
currentPage: 0, currentPage: 0,
totalElements: 2 totalElements: 2,
}; };
const action = new AddSourceAction( const action = new AddSourceAction(
[ qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMoreAbstract ], [ qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMoreAbstract ],
1, 0, 2 1, 0, 2,
); );
const newState = qualityAssuranceSourceReducer(qualityAssuranceSourceInitialState, action); const newState = qualityAssuranceSourceReducer(qualityAssuranceSourceInitialState, action);

View File

@@ -1,5 +1,8 @@
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model'; import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceActionTypes, QualityAssuranceSourceActions } from './quality-assurance-source.actions'; import {
QualityAssuranceSourceActions,
QualityAssuranceSourceActionTypes,
} from './quality-assurance-source.actions';
/** /**
* The interface representing the Quality Assurance source state. * The interface representing the Quality Assurance source state.
@@ -22,7 +25,7 @@ const qualityAssuranceSourceInitialState: QualityAssuranceSourceState = {
loaded: false, loaded: false,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}; };
/** /**
@@ -40,7 +43,7 @@ export function qualityAssuranceSourceReducer(state = qualityAssuranceSourceInit
case QualityAssuranceSourceActionTypes.RETRIEVE_ALL_SOURCE: { case QualityAssuranceSourceActionTypes.RETRIEVE_ALL_SOURCE: {
return Object.assign({}, state, { return Object.assign({}, state, {
source: [], source: [],
processing: true processing: true,
}); });
} }
@@ -51,7 +54,7 @@ export function qualityAssuranceSourceReducer(state = qualityAssuranceSourceInit
loaded: true, loaded: true,
totalPages: action.payload.totalPages, totalPages: action.payload.totalPages,
currentPage: state.currentPage, currentPage: state.currentPage,
totalElements: action.payload.totalElements totalElements: action.payload.totalElements,
}); });
} }
@@ -61,7 +64,7 @@ export function qualityAssuranceSourceReducer(state = qualityAssuranceSourceInit
loaded: true, loaded: true,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}); });
} }

View File

@@ -1,20 +1,22 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { cold } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { QualityAssuranceSourceService } from './quality-assurance-source.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; import {
SortDirection,
SortOptions,
} from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceDataService } from '../../../core/notifications/qa/source/quality-assurance-source-data.service';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { import {
getMockQualityAssuranceSourceRestService, getMockQualityAssuranceSourceRestService,
qualityAssuranceSourceObjectMoreAbstract, qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid qualityAssuranceSourceObjectMorePid,
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils'; import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { cold } from 'jasmine-marbles'; import { QualityAssuranceSourceService } from './quality-assurance-source.service';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import {
QualityAssuranceSourceDataService
} from '../../../core/notifications/qa/source/quality-assurance-source-data.service';
import { FindListOptions } from '../../../core/data/find-list-options.model';
describe('QualityAssuranceSourceService', () => { describe('QualityAssuranceSourceService', () => {
let service: QualityAssuranceSourceService; let service: QualityAssuranceSourceService;
@@ -33,8 +35,8 @@ describe('QualityAssuranceSourceService', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
{ provide: QualityAssuranceSourceDataService, useClass: getMockQualityAssuranceSourceRestService }, { provide: QualityAssuranceSourceDataService, useClass: getMockQualityAssuranceSourceRestService },
{ provide: QualityAssuranceSourceService, useValue: service } { provide: QualityAssuranceSourceService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -52,7 +54,7 @@ describe('QualityAssuranceSourceService', () => {
const findListOptions: FindListOptions = { const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage, elementsPerPage: elementsPerPage,
currentPage: currentPage, currentPage: currentPage,
sort: sortOptions sort: sortOptions,
}; };
const result = service.getSources(elementsPerPage, currentPage); const result = service.getSources(elementsPerPage, currentPage);
expect((service as any).qualityAssuranceSourceRestService.getSources).toHaveBeenCalledWith(findListOptions); expect((service as any).qualityAssuranceSourceRestService.getSources).toHaveBeenCalledWith(findListOptions);
@@ -60,7 +62,7 @@ describe('QualityAssuranceSourceService', () => {
it('Should return a paginated list of Quality Assurance Source', () => { it('Should return a paginated list of Quality Assurance Source', () => {
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: paginatedList a: paginatedList,
}); });
const result = service.getSources(elementsPerPage, currentPage); const result = service.getSources(elementsPerPage, currentPage);
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);

View File

@@ -1,18 +1,16 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { import {
QualityAssuranceSourceDataService SortDirection,
} from '../../../core/notifications/qa/source/quality-assurance-source-data.service'; SortOptions,
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; } from '../../../core/cache/models/sort-options.model';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import {
QualityAssuranceSourceObject
} from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import { FindListOptions } from '../../../core/data/find-list-options.model';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceDataService } from '../../../core/notifications/qa/source/quality-assurance-source-data.service';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
/** /**
@@ -26,7 +24,7 @@ export class QualityAssuranceSourceService {
* @param {QualityAssuranceSourceDataService} qualityAssuranceSourceRestService * @param {QualityAssuranceSourceDataService} qualityAssuranceSourceRestService
*/ */
constructor( constructor(
private qualityAssuranceSourceRestService: QualityAssuranceSourceDataService private qualityAssuranceSourceRestService: QualityAssuranceSourceDataService,
) { ) {
} }
@@ -46,7 +44,7 @@ export class QualityAssuranceSourceService {
const findListOptions: FindListOptions = { const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage, elementsPerPage: elementsPerPage,
currentPage: currentPage, currentPage: currentPage,
sort: sortOptions sort: sortOptions,
}; };
return this.qualityAssuranceSourceRestService.getSources(findListOptions).pipe( return this.qualityAssuranceSourceRestService.getSources(findListOptions).pipe(
@@ -57,7 +55,7 @@ export class QualityAssuranceSourceService {
} else { } else {
throw new Error('Can\'t retrieve Quality Assurance source from the Broker source REST service'); throw new Error('Can\'t retrieve Quality Assurance source from the Broker source REST service');
} }
}) }),
); );
} }
} }

View File

@@ -1,7 +1,8 @@
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { type } from '../../../shared/ngrx/type';
import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model'; import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { type } from '../../../shared/ngrx/type';
/** /**
* For each action type in an action group, make a simple * For each action type in an action group, make a simple
@@ -38,7 +39,7 @@ export class RetrieveAllTopicsAction implements Action {
constructor(elementsPerPage: number, currentPage: number) { constructor(elementsPerPage: number, currentPage: number) {
this.payload = { this.payload = {
elementsPerPage, elementsPerPage,
currentPage currentPage,
}; };
} }
} }
@@ -80,7 +81,7 @@ export class AddTopicsAction implements Action {
topics, topics,
totalPages, totalPages,
currentPage, currentPage,
totalElements totalElements,
}; };
} }

View File

@@ -1,21 +1,30 @@
/* eslint-disable no-empty, @typescript-eslint/no-empty-function */ /* eslint-disable no-empty, @typescript-eslint/no-empty-function */
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; import {
Component,
NO_ERRORS_SCHEMA,
} from '@angular/core';
import {
ComponentFixture,
inject,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { cold } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { createTestComponent } from '../../../shared/testing/utils.test'; import { PaginationService } from '../../../core/pagination/pagination.service';
import { import {
getMockNotificationsStateService, getMockNotificationsStateService,
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid qualityAssuranceTopicObjectMorePid,
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { QualityAssuranceTopicsComponent } from './quality-assurance-topics.component';
import { NotificationsStateService } from '../../notifications-state.service';
import { cold } from 'jasmine-marbles';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
import { PaginationService } from '../../../core/pagination/pagination.service'; import { createTestComponent } from '../../../shared/testing/utils.test';
import { NotificationsStateService } from '../../notifications-state.service';
import { QualityAssuranceTopicsComponent } from './quality-assurance-topics.component';
import { QualityAssuranceTopicsService } from './quality-assurance-topics.service'; import { QualityAssuranceTopicsService } from './quality-assurance-topics.service';
describe('QualityAssuranceTopicsComponent test suite', () => { describe('QualityAssuranceTopicsComponent test suite', () => {
@@ -26,8 +35,8 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
const activatedRouteParams = { const activatedRouteParams = {
qualityAssuranceTopicsParams: { qualityAssuranceTopicsParams: {
currentPage: 0, currentPage: 0,
pageSize: 5 pageSize: 5,
} },
}; };
const paginationService = new PaginationServiceStub(); const paginationService = new PaginationServiceStub();
@@ -51,13 +60,13 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
{ provide: PaginationService, useValue: paginationService }, { provide: PaginationService, useValue: paginationService },
QualityAssuranceTopicsComponent, QualityAssuranceTopicsComponent,
// tslint:disable-next-line: no-empty // tslint:disable-next-line: no-empty
{ provide: QualityAssuranceTopicsService, useValue: { setSourceId: (sourceId: string) => { } }} { provide: QualityAssuranceTopicsService, useValue: { setSourceId: (sourceId: string) => { } } },
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA],
}).compileComponents().then(() => { }).compileComponents().then(() => {
mockNotificationsStateService.getQualityAssuranceTopics.and.returnValue(observableOf([ mockNotificationsStateService.getQualityAssuranceTopics.and.returnValue(observableOf([
qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMorePid,
qualityAssuranceTopicObjectMoreAbstract qualityAssuranceTopicObjectMoreAbstract,
])); ]));
mockNotificationsStateService.getQualityAssuranceTopicsTotalPages.and.returnValue(observableOf(1)); mockNotificationsStateService.getQualityAssuranceTopicsTotalPages.and.returnValue(observableOf(1));
mockNotificationsStateService.getQualityAssuranceTopicsCurrentPage.and.returnValue(observableOf(0)); mockNotificationsStateService.getQualityAssuranceTopicsCurrentPage.and.returnValue(observableOf(0));
@@ -111,11 +120,11 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
expect(comp.topics$).toBeObservable(cold('(a|)', { expect(comp.topics$).toBeObservable(cold('(a|)', {
a: [ a: [
qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMorePid,
qualityAssuranceTopicObjectMoreAbstract qualityAssuranceTopicObjectMoreAbstract,
] ],
})); }));
expect(comp.totalElements$).toBeObservable(cold('(a|)', { expect(comp.totalElements$).toBeObservable(cold('(a|)', {
a: 2 a: 2,
})); }));
}); });
@@ -130,13 +139,13 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
it(('isTopicsLoading should return FALSE'), () => { it(('isTopicsLoading should return FALSE'), () => {
expect(comp.isTopicsLoading()).toBeObservable(cold('(a|)', { expect(comp.isTopicsLoading()).toBeObservable(cold('(a|)', {
a: false a: false,
})); }));
}); });
it(('isTopicsProcessing should return FALSE'), () => { it(('isTopicsProcessing should return FALSE'), () => {
expect(comp.isTopicsProcessing()).toBeObservable(cold('(a|)', { expect(comp.isTopicsProcessing()).toBeObservable(cold('(a|)', {
a: false a: false,
})); }));
}); });
@@ -153,7 +162,7 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``,
}) })
class TestComponent { class TestComponent {

View File

@@ -1,20 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { distinctUntilChanged, take } from 'rxjs/operators';
import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { import {
QualityAssuranceTopicObject Component,
} from '../../../core/notifications/qa/models/quality-assurance-topic.model'; OnInit,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {
Observable,
Subscription,
} from 'rxjs';
import {
distinctUntilChanged,
take,
} from 'rxjs/operators';
import { AdminQualityAssuranceTopicsPageParams } from '../../../admin/admin-notifications/admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { hasValue } from '../../../shared/empty.util'; import { hasValue } from '../../../shared/empty.util';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { NotificationsStateService } from '../../notifications-state.service'; import { NotificationsStateService } from '../../notifications-state.service';
import {
AdminQualityAssuranceTopicsPageParams
} from '../../../admin/admin-notifications/admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { ActivatedRoute } from '@angular/router';
import { QualityAssuranceTopicsService } from './quality-assurance-topics.service'; import { QualityAssuranceTopicsService } from './quality-assurance-topics.service';
/** /**
@@ -33,7 +37,7 @@ export class QualityAssuranceTopicsComponent implements OnInit {
public paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), { public paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'btp', id: 'btp',
pageSize: 10, pageSize: 10,
pageSizeOptions: [5, 10, 20, 40, 60] pageSizeOptions: [5, 10, 20, 40, 60],
}); });
/** /**
* The Quality Assurance topic list sort options. * The Quality Assurance topic list sort options.
@@ -71,7 +75,7 @@ export class QualityAssuranceTopicsComponent implements OnInit {
private paginationService: PaginationService, private paginationService: PaginationService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private notificationsStateService: NotificationsStateService, private notificationsStateService: NotificationsStateService,
private qualityAssuranceTopicsService: QualityAssuranceTopicsService private qualityAssuranceTopicsService: QualityAssuranceTopicsService,
) { ) {
} }
@@ -91,10 +95,10 @@ export class QualityAssuranceTopicsComponent implements OnInit {
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.subs.push( this.subs.push(
this.notificationsStateService.isQualityAssuranceTopicsLoaded().pipe( this.notificationsStateService.isQualityAssuranceTopicsLoaded().pipe(
take(1) take(1),
).subscribe(() => { ).subscribe(() => {
this.getQualityAssuranceTopics(); this.getQualityAssuranceTopics();
}) }),
); );
} }
@@ -127,7 +131,7 @@ export class QualityAssuranceTopicsComponent implements OnInit {
).subscribe((options: PaginationComponentOptions) => { ).subscribe((options: PaginationComponentOptions) => {
this.notificationsStateService.dispatchRetrieveQualityAssuranceTopics( this.notificationsStateService.dispatchRetrieveQualityAssuranceTopics(
options.pageSize, options.pageSize,
options.currentPage options.currentPage,
); );
}); });
} }

View File

@@ -1,26 +1,31 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {
Actions,
createEffect,
ofType,
} from '@ngrx/effects';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { catchError, map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import {
catchError,
map,
switchMap,
tap,
withLatestFrom,
} from 'rxjs/operators';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceTopicDataService } from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { import {
AddTopicsAction, AddTopicsAction,
QualityAssuranceTopicActionTypes, QualityAssuranceTopicActionTypes,
RetrieveAllTopicsAction, RetrieveAllTopicsAction,
RetrieveAllTopicsErrorAction, RetrieveAllTopicsErrorAction,
} from './quality-assurance-topics.actions'; } from './quality-assurance-topics.actions';
import {
QualityAssuranceTopicObject
} from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceTopicsService } from './quality-assurance-topics.service'; import { QualityAssuranceTopicsService } from './quality-assurance-topics.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import {
QualityAssuranceTopicDataService
} from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service';
/** /**
* Provides effect methods for the Quality Assurance topics actions. * Provides effect methods for the Quality Assurance topics actions.
@@ -37,19 +42,19 @@ export class QualityAssuranceTopicsEffects {
switchMap(([action, currentState]: [RetrieveAllTopicsAction, any]) => { switchMap(([action, currentState]: [RetrieveAllTopicsAction, any]) => {
return this.qualityAssuranceTopicService.getTopics( return this.qualityAssuranceTopicService.getTopics(
action.payload.elementsPerPage, action.payload.elementsPerPage,
action.payload.currentPage action.payload.currentPage,
).pipe( ).pipe(
map((topics: PaginatedList<QualityAssuranceTopicObject>) => map((topics: PaginatedList<QualityAssuranceTopicObject>) =>
new AddTopicsAction(topics.page, topics.totalPages, topics.currentPage, topics.totalElements) new AddTopicsAction(topics.page, topics.totalPages, topics.currentPage, topics.totalElements),
), ),
catchError((error: Error) => { catchError((error: Error) => {
if (error) { if (error) {
console.error(error.message); console.error(error.message);
} }
return observableOf(new RetrieveAllTopicsErrorAction()); return observableOf(new RetrieveAllTopicsErrorAction());
}) }),
); );
}) }),
)); ));
/** /**
@@ -59,7 +64,7 @@ export class QualityAssuranceTopicsEffects {
ofType(QualityAssuranceTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR), ofType(QualityAssuranceTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR),
tap(() => { tap(() => {
this.notificationsService.error(null, this.translate.get('quality-assurance.topic.error.service.retrieve')); this.notificationsService.error(null, this.translate.get('quality-assurance.topic.error.service.retrieve'));
}) }),
), { dispatch: false }); ), { dispatch: false });
/** /**
@@ -69,7 +74,7 @@ export class QualityAssuranceTopicsEffects {
ofType(QualityAssuranceTopicActionTypes.ADD_TOPICS), ofType(QualityAssuranceTopicActionTypes.ADD_TOPICS),
tap(() => { tap(() => {
this.qualityAssuranceTopicDataService.clearFindAllTopicsRequests(); this.qualityAssuranceTopicDataService.clearFindAllTopicsRequests();
}) }),
), { dispatch: false }); ), { dispatch: false });
/** /**
@@ -87,6 +92,6 @@ export class QualityAssuranceTopicsEffects {
private translate: TranslateService, private translate: TranslateService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private qualityAssuranceTopicService: QualityAssuranceTopicsService, private qualityAssuranceTopicService: QualityAssuranceTopicsService,
private qualityAssuranceTopicDataService: QualityAssuranceTopicDataService private qualityAssuranceTopicDataService: QualityAssuranceTopicDataService,
) { } ) { }
} }

View File

@@ -1,13 +1,16 @@
import {
qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid,
} from '../../../shared/mocks/notifications.mock';
import { import {
AddTopicsAction, AddTopicsAction,
RetrieveAllTopicsAction, RetrieveAllTopicsAction,
RetrieveAllTopicsErrorAction RetrieveAllTopicsErrorAction,
} from './quality-assurance-topics.actions'; } from './quality-assurance-topics.actions';
import { qualityAssuranceTopicsReducer, QualityAssuranceTopicState } from './quality-assurance-topics.reducer';
import { import {
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicsReducer,
qualityAssuranceTopicObjectMorePid QualityAssuranceTopicState,
} from '../../../shared/mocks/notifications.mock'; } from './quality-assurance-topics.reducer';
describe('qualityAssuranceTopicsReducer test suite', () => { describe('qualityAssuranceTopicsReducer test suite', () => {
let qualityAssuranceTopicInitialState: QualityAssuranceTopicState; let qualityAssuranceTopicInitialState: QualityAssuranceTopicState;
@@ -21,7 +24,7 @@ describe('qualityAssuranceTopicsReducer test suite', () => {
loaded: false, loaded: false,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}; };
}); });
@@ -54,12 +57,12 @@ describe('qualityAssuranceTopicsReducer test suite', () => {
loaded: true, loaded: true,
totalPages: 1, totalPages: 1,
currentPage: 0, currentPage: 0,
totalElements: 2 totalElements: 2,
}; };
const action = new AddTopicsAction( const action = new AddTopicsAction(
[ qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMoreAbstract ], [ qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMoreAbstract ],
1, 0, 2 1, 0, 2,
); );
const newState = qualityAssuranceTopicsReducer(qualityAssuranceTopicInitialState, action); const newState = qualityAssuranceTopicsReducer(qualityAssuranceTopicInitialState, action);

View File

@@ -1,5 +1,8 @@
import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model'; import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceTopicActionTypes, QualityAssuranceTopicsActions } from './quality-assurance-topics.actions'; import {
QualityAssuranceTopicActionTypes,
QualityAssuranceTopicsActions,
} from './quality-assurance-topics.actions';
/** /**
* The interface representing the Quality Assurance topic state. * The interface representing the Quality Assurance topic state.
@@ -22,7 +25,7 @@ const qualityAssuranceTopicInitialState: QualityAssuranceTopicState = {
loaded: false, loaded: false,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}; };
/** /**
@@ -40,7 +43,7 @@ export function qualityAssuranceTopicsReducer(state = qualityAssuranceTopicIniti
case QualityAssuranceTopicActionTypes.RETRIEVE_ALL_TOPICS: { case QualityAssuranceTopicActionTypes.RETRIEVE_ALL_TOPICS: {
return Object.assign({}, state, { return Object.assign({}, state, {
topics: [], topics: [],
processing: true processing: true,
}); });
} }
@@ -51,7 +54,7 @@ export function qualityAssuranceTopicsReducer(state = qualityAssuranceTopicIniti
loaded: true, loaded: true,
totalPages: action.payload.totalPages, totalPages: action.payload.totalPages,
currentPage: state.currentPage, currentPage: state.currentPage,
totalElements: action.payload.totalElements totalElements: action.payload.totalElements,
}); });
} }
@@ -61,7 +64,7 @@ export function qualityAssuranceTopicsReducer(state = qualityAssuranceTopicIniti
loaded: true, loaded: true,
totalPages: 0, totalPages: 0,
currentPage: 0, currentPage: 0,
totalElements: 0 totalElements: 0,
}); });
} }

View File

@@ -1,21 +1,23 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { cold } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { QualityAssuranceTopicsService } from './quality-assurance-topics.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; import { RequestParam } from '../../../core/cache/models/request-param.model';
import { import {
QualityAssuranceTopicDataService SortDirection,
} from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service'; SortOptions,
} from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceTopicDataService } from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { import {
getMockQualityAssuranceTopicRestService, getMockQualityAssuranceTopicRestService,
qualityAssuranceTopicObjectMoreAbstract, qualityAssuranceTopicObjectMoreAbstract,
qualityAssuranceTopicObjectMorePid qualityAssuranceTopicObjectMorePid,
} from '../../../shared/mocks/notifications.mock'; } from '../../../shared/mocks/notifications.mock';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils'; import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { cold } from 'jasmine-marbles'; import { QualityAssuranceTopicsService } from './quality-assurance-topics.service';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { RequestParam } from '../../../core/cache/models/request-param.model';
import { FindListOptions } from '../../../core/data/find-list-options.model';
describe('QualityAssuranceTopicsService', () => { describe('QualityAssuranceTopicsService', () => {
let service: QualityAssuranceTopicsService; let service: QualityAssuranceTopicsService;
@@ -34,8 +36,8 @@ describe('QualityAssuranceTopicsService', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
{ provide: QualityAssuranceTopicDataService, useClass: getMockQualityAssuranceTopicRestService }, { provide: QualityAssuranceTopicDataService, useClass: getMockQualityAssuranceTopicRestService },
{ provide: QualityAssuranceTopicsService, useValue: service } { provide: QualityAssuranceTopicsService, useValue: service },
] ],
}).compileComponents(); }).compileComponents();
}); });
@@ -54,7 +56,7 @@ describe('QualityAssuranceTopicsService', () => {
elementsPerPage: elementsPerPage, elementsPerPage: elementsPerPage,
currentPage: currentPage, currentPage: currentPage,
sort: sortOptions, sort: sortOptions,
searchParams: [new RequestParam('source', 'ENRICH!MORE!ABSTRACT')] searchParams: [new RequestParam('source', 'ENRICH!MORE!ABSTRACT')],
}; };
service.setSourceId('ENRICH!MORE!ABSTRACT'); service.setSourceId('ENRICH!MORE!ABSTRACT');
const result = service.getTopics(elementsPerPage, currentPage); const result = service.getTopics(elementsPerPage, currentPage);
@@ -63,7 +65,7 @@ describe('QualityAssuranceTopicsService', () => {
it('Should return a paginated list of Quality Assurance topics', () => { it('Should return a paginated list of Quality Assurance topics', () => {
const expected = cold('(a|)', { const expected = cold('(a|)', {
a: paginatedList a: paginatedList,
}); });
const result = service.getTopics(elementsPerPage, currentPage); const result = service.getTopics(elementsPerPage, currentPage);
expect(result).toBeObservable(expected); expect(result).toBeObservable(expected);

View File

@@ -1,17 +1,17 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import {
QualityAssuranceTopicDataService
} from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import {
QualityAssuranceTopicObject
} from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { RequestParam } from '../../../core/cache/models/request-param.model'; import { RequestParam } from '../../../core/cache/models/request-param.model';
import {
SortDirection,
SortOptions,
} from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import { FindListOptions } from '../../../core/data/find-list-options.model';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data';
import { QualityAssuranceTopicObject } from '../../../core/notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceTopicDataService } from '../../../core/notifications/qa/topics/quality-assurance-topic-data.service';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
/** /**
@@ -25,7 +25,7 @@ export class QualityAssuranceTopicsService {
* @param {QualityAssuranceTopicDataService} qualityAssuranceTopicRestService * @param {QualityAssuranceTopicDataService} qualityAssuranceTopicRestService
*/ */
constructor( constructor(
private qualityAssuranceTopicRestService: QualityAssuranceTopicDataService private qualityAssuranceTopicRestService: QualityAssuranceTopicDataService,
) { } ) { }
/** /**
@@ -50,7 +50,7 @@ export class QualityAssuranceTopicsService {
elementsPerPage: elementsPerPage, elementsPerPage: elementsPerPage,
currentPage: currentPage, currentPage: currentPage,
sort: sortOptions, sort: sortOptions,
searchParams: [new RequestParam('source', this.sourceId)] searchParams: [new RequestParam('source', this.sourceId)],
}; };
return this.qualityAssuranceTopicRestService.getTopics(findListOptions).pipe( return this.qualityAssuranceTopicRestService.getTopics(findListOptions).pipe(
@@ -61,7 +61,7 @@ export class QualityAssuranceTopicsService {
} else { } else {
throw new Error('Can\'t retrieve Quality Assurance topics from the Broker topics REST service'); throw new Error('Can\'t retrieve Quality Assurance topics from the Broker topics REST service');
} }
}) }),
); );
} }

View File

@@ -1,12 +1,18 @@
import { createFeatureSelector, createSelector, MemoizedSelector } from '@ngrx/store';
import { subStateSelector } from '../shared/selector.util';
import { suggestionNotificationsSelector, SuggestionNotificationsState } from './notifications.reducer';
import { QualityAssuranceTopicObject } from '../core/notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceTopicState } from './qa/topics/quality-assurance-topics.reducer';
import { QualityAssuranceSourceState } from './qa/source/quality-assurance-source.reducer';
import { import {
QualityAssuranceSourceObject createFeatureSelector,
} from '../core/notifications/qa/models/quality-assurance-source.model'; createSelector,
MemoizedSelector,
} from '@ngrx/store';
import { QualityAssuranceSourceObject } from '../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceTopicObject } from '../core/notifications/qa/models/quality-assurance-topic.model';
import { subStateSelector } from '../shared/selector.util';
import {
suggestionNotificationsSelector,
SuggestionNotificationsState,
} from './notifications.reducer';
import { QualityAssuranceSourceState } from './qa/source/quality-assurance-source.reducer';
import { QualityAssuranceTopicState } from './qa/topics/quality-assurance-topics.reducer';
/** /**
* Returns the Notifications state. * Returns the Notifications state.
@@ -43,7 +49,7 @@ export function qualityAssuranceTopicsObjectSelector(): MemoizedSelector<Suggest
* @return {boolean} * @return {boolean}
*/ */
export const isQualityAssuranceTopicsLoadedSelector = createSelector(_getNotificationsState, export const isQualityAssuranceTopicsLoadedSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaTopic.loaded (state: SuggestionNotificationsState) => state.qaTopic.loaded,
); );
/** /**
@@ -52,7 +58,7 @@ export const isQualityAssuranceTopicsLoadedSelector = createSelector(_getNotific
* @return {boolean} * @return {boolean}
*/ */
export const isQualityAssuranceTopicsProcessingSelector = createSelector(_getNotificationsState, export const isQualityAssuranceTopicsProcessingSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaTopic.processing (state: SuggestionNotificationsState) => state.qaTopic.processing,
); );
/** /**
@@ -61,7 +67,7 @@ export const isQualityAssuranceTopicsProcessingSelector = createSelector(_getNot
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceTopicsTotalPagesSelector = createSelector(_getNotificationsState, export const getQualityAssuranceTopicsTotalPagesSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaTopic.totalPages (state: SuggestionNotificationsState) => state.qaTopic.totalPages,
); );
/** /**
@@ -70,7 +76,7 @@ export const getQualityAssuranceTopicsTotalPagesSelector = createSelector(_getNo
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceTopicsCurrentPageSelector = createSelector(_getNotificationsState, export const getQualityAssuranceTopicsCurrentPageSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaTopic.currentPage (state: SuggestionNotificationsState) => state.qaTopic.currentPage,
); );
/** /**
@@ -79,7 +85,7 @@ export const getQualityAssuranceTopicsCurrentPageSelector = createSelector(_getN
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceTopicsTotalsSelector = createSelector(_getNotificationsState, export const getQualityAssuranceTopicsTotalsSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaTopic.totalElements (state: SuggestionNotificationsState) => state.qaTopic.totalElements,
); );
// Quality Assurance source // Quality Assurance source
@@ -109,7 +115,7 @@ export function qualityAssuranceSourceObjectSelector(): MemoizedSelector<Suggest
* @return {boolean} * @return {boolean}
*/ */
export const isQualityAssuranceSourceLoadedSelector = createSelector(_getNotificationsState, export const isQualityAssuranceSourceLoadedSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaSource.loaded (state: SuggestionNotificationsState) => state.qaSource.loaded,
); );
/** /**
@@ -118,7 +124,7 @@ export const isQualityAssuranceSourceLoadedSelector = createSelector(_getNotific
* @return {boolean} * @return {boolean}
*/ */
export const isQualityAssuranceSourceProcessingSelector = createSelector(_getNotificationsState, export const isQualityAssuranceSourceProcessingSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaSource.processing (state: SuggestionNotificationsState) => state.qaSource.processing,
); );
/** /**
@@ -127,7 +133,7 @@ export const isQualityAssuranceSourceProcessingSelector = createSelector(_getNot
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceSourceTotalPagesSelector = createSelector(_getNotificationsState, export const getQualityAssuranceSourceTotalPagesSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaSource.totalPages (state: SuggestionNotificationsState) => state.qaSource.totalPages,
); );
/** /**
@@ -136,7 +142,7 @@ export const getQualityAssuranceSourceTotalPagesSelector = createSelector(_getNo
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceSourceCurrentPageSelector = createSelector(_getNotificationsState, export const getQualityAssuranceSourceCurrentPageSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaSource.currentPage (state: SuggestionNotificationsState) => state.qaSource.currentPage,
); );
/** /**
@@ -145,5 +151,5 @@ export const getQualityAssuranceSourceCurrentPageSelector = createSelector(_getN
* @return {number} * @return {number}
*/ */
export const getQualityAssuranceSourceTotalsSelector = createSelector(_getNotificationsState, export const getQualityAssuranceSourceTotalsSelector = createSelector(_getNotificationsState,
(state: SuggestionNotificationsState) => state.qaSource.totalElements (state: SuggestionNotificationsState) => state.qaSource.totalElements,
); );

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,8 @@
import { createSelector, MemoizedSelector } from '@ngrx/store'; import {
createSelector,
MemoizedSelector,
} from '@ngrx/store';
import { hasValue } from './empty.util'; import { hasValue } from './empty.util';
/** /**

View File

@@ -17,9 +17,9 @@ import { InfoConfig } from './info-config.interface';
import { ItemConfig } from './item-config.interface'; import { ItemConfig } from './item-config.interface';
import { LangConfig } from './lang-config.interface'; import { LangConfig } from './lang-config.interface';
import { MarkdownConfig } from './markdown-config.interface'; import { MarkdownConfig } from './markdown-config.interface';
import { QualityAssuranceConfig } from './quality-assurance.config';
import { MediaViewerConfig } from './media-viewer-config.interface'; import { MediaViewerConfig } from './media-viewer-config.interface';
import { INotificationBoardOptions } from './notifications-config.interfaces'; import { INotificationBoardOptions } from './notifications-config.interfaces';
import { QualityAssuranceConfig } from './quality-assurance.config';
import { ServerConfig } from './server-config.interface'; import { ServerConfig } from './server-config.interface';
import { SubmissionConfig } from './submission-config.interface'; import { SubmissionConfig } from './submission-config.interface';
import { ThemeConfig } from './theme.config'; import { ThemeConfig } from './theme.config';

View File

@@ -18,11 +18,11 @@ import { LangConfig } from './lang-config.interface';
import { MarkdownConfig } from './markdown-config.interface'; import { MarkdownConfig } from './markdown-config.interface';
import { MediaViewerConfig } from './media-viewer-config.interface'; import { MediaViewerConfig } from './media-viewer-config.interface';
import { INotificationBoardOptions } from './notifications-config.interfaces'; import { INotificationBoardOptions } from './notifications-config.interfaces';
import { QualityAssuranceConfig } from './quality-assurance.config';
import { ServerConfig } from './server-config.interface'; import { ServerConfig } from './server-config.interface';
import { SubmissionConfig } from './submission-config.interface'; import { SubmissionConfig } from './submission-config.interface';
import { ThemeConfig } from './theme.config'; import { ThemeConfig } from './theme.config';
import { UIServerConfig } from './ui-server-config.interface'; import { UIServerConfig } from './ui-server-config.interface';
import { QualityAssuranceConfig } from './quality-assurance.config';
export class DefaultAppConfig implements AppConfig { export class DefaultAppConfig implements AppConfig {
production = false; production = false;
@@ -438,7 +438,7 @@ export class DefaultAppConfig implements AppConfig {
qualityAssuranceConfig: QualityAssuranceConfig = { qualityAssuranceConfig: QualityAssuranceConfig = {
sourceUrlMapForProjectSearch: { sourceUrlMapForProjectSearch: {
openaire: 'https://explore.openaire.eu/search/project?projectId=' openaire: 'https://explore.openaire.eu/search/project?projectId=',
}, },
pageSize: 5, pageSize: 5,
}; };

View File

@@ -309,7 +309,7 @@ export const environment: BuildConfig = {
}, },
qualityAssuranceConfig: { qualityAssuranceConfig: {
sourceUrlMapForProjectSearch: { sourceUrlMapForProjectSearch: {
openaire: 'https://explore.openaire.eu/search/project?projectId=' openaire: 'https://explore.openaire.eu/search/project?projectId=',
}, },
pageSize: 5, pageSize: 5,
}, },