Skip to content

Commit

Permalink
refactor, improve code according to suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoMolinaro committed Dec 13, 2023
1 parent ec82139 commit 922172d
Show file tree
Hide file tree
Showing 51 changed files with 104 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AdminQualityAssuranceTopicsPageResolver } from './admin-quality-assuran
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 { SourceDataResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.reslover';
import { SourceDataResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.resolver';

@NgModule({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { AdminNotificationsRoutingModule } from './admin-notifications-routing.m
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 { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import {SuggestionNotificationsModule} from '../../suggestion-notifications/suggestion-notifications.module';
import {NotificationsModule} from '../../notifications/notifications.module';

@NgModule({
imports: [
CommonModule,
SharedModule,
CoreModule.forRoot(),
AdminNotificationsRoutingModule,
SuggestionNotificationsModule
NotificationsModule
],
declarations: [
AdminQualityAssuranceTopicsPageComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Router } from '@a
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceService } from '../../../suggestion-notifications/qa/source/quality-assurance-source.service';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceService } from '../../../notifications/qa/source/quality-assurance-source.service';
/**
* This class represents a resolver that retrieve the route data before the route is activated.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ import { SequenceService } from './shared/sequence.service';
import { CoreState } from './core-state.model';
import { GroupDataService } from './eperson/group-data.service';
import { SubmissionAccessesModel } from './config/models/config-submission-accesses.model';
import { QualityAssuranceTopicObject } from './suggestion-notifications/qa/models/quality-assurance-topic.model';
import { QualityAssuranceEventObject } from './suggestion-notifications/qa/models/quality-assurance-event.model';
import { QualityAssuranceSourceObject } from './suggestion-notifications/qa/models/quality-assurance-source.model';
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';
import { RatingAdvancedWorkflowInfo } from './tasks/models/rating-advanced-workflow-info.model';
import { AdvancedWorkflowInfo } from './tasks/models/advanced-workflow-info.model';
import { SelectReviewerAdvancedWorkflowInfo } from './tasks/models/select-reviewer-advanced-workflow-info.model';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QualityAssuranceSourceEffects } from './qa/source/quality-assurance-source.effects';
import { QualityAssuranceTopicsEffects } from './qa/topics/quality-assurance-topics.effects';

export const suggestionNotificationsEffects = [
export const notificationsEffects = [
QualityAssuranceTopicsEffects,
QualityAssuranceSourceEffects
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { TestBed } from '@angular/core/testing';
import { Store, StoreModule } from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing';
import { cold } from 'jasmine-marbles';
import { suggestionNotificationsReducers } from './suggestion-notifications.reducer';
import { SuggestionNotificationsStateService } from './suggestion-notifications-state.service';
import { suggestionNotificationsReducers } from './notifications.reducer';
import { NotificationsStateService } from './notifications-state.service';
import {
qualityAssuranceSourceObjectMissingPid,
qualityAssuranceSourceObjectMoreAbstract,
Expand All @@ -16,7 +16,7 @@ import { RetrieveAllTopicsAction } from './qa/topics/quality-assurance-topics.ac
import { RetrieveAllSourceAction } from './qa/source/quality-assurance-source.actions';

describe('NotificationsStateService', () => {
let service: SuggestionNotificationsStateService;
let service: NotificationsStateService;
let serviceAsAny: any;
let store: any;
let initialState: any;
Expand Down Expand Up @@ -67,14 +67,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down Expand Up @@ -159,14 +159,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down Expand Up @@ -255,14 +255,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down Expand Up @@ -325,14 +325,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down Expand Up @@ -417,14 +417,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down Expand Up @@ -513,14 +513,14 @@ describe('NotificationsStateService', () => {
],
providers: [
provideMockStore({ initialState }),
{ provide: SuggestionNotificationsStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});

beforeEach(() => {
store = TestBed.get(Store);
service = new SuggestionNotificationsStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import {
getQualityAssuranceSourceCurrentPageSelector,
getQualityAssuranceSourceTotalsSelector
} from './selectors';
import { QualityAssuranceTopicObject } from '../core/suggestion-notifications/qa/models/quality-assurance-topic.model';
import { SuggestionNotificationsState } from './suggestion-notifications.reducer';
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/suggestion-notifications/qa/models/quality-assurance-source.model';
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.
*/
@Injectable()
export class SuggestionNotificationsStateService {
export class NotificationsStateService {

/**
* Initialize the service variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ 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 { SuggestionNotificationsStateService } from './suggestion-notifications-state.service';
import { suggestionNotificationsReducers, SuggestionNotificationsState } from './suggestion-notifications.reducer';
import { suggestionNotificationsEffects } from './suggestion-notifications-effects';
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 {
QualityAssuranceTopicDataService
} from '../core/suggestion-notifications/qa/topics/quality-assurance-topic-data.service';
} from '../core/notifications/qa/topics/quality-assurance-topic-data.service';
import {
QualityAssuranceEventDataService
} from '../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
} 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 { SearchModule } from '../shared/search/search.module';
import { QualityAssuranceSourceComponent } from './qa/source/quality-assurance-source.component';
import { QualityAssuranceSourceService } from './qa/source/quality-assurance-source.service';
import {
QualityAssuranceSourceDataService
} from '../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
} from '../core/notifications/qa/source/quality-assurance-source-data.service';

const MODULES = [
CommonModule,
SharedModule,
SearchModule,
CoreModule.forRoot(),
StoreModule.forFeature('suggestionNotifications', suggestionNotificationsReducers, storeModuleConfig as StoreConfig<SuggestionNotificationsState, Action>),
EffectsModule.forFeature(suggestionNotificationsEffects),
EffectsModule.forFeature(notificationsEffects),
TranslateModule
];

Expand All @@ -50,7 +50,7 @@ const ENTRY_COMPONENTS = [
];

const PROVIDERS = [
SuggestionNotificationsStateService,
NotificationsStateService,
QualityAssuranceTopicsService,
QualityAssuranceSourceService,
QualityAssuranceTopicDataService,
Expand Down Expand Up @@ -82,5 +82,5 @@ const PROVIDERS = [
/**
* This module handles all components that are necessary for the OpenAIRE components
*/
export class SuggestionNotificationsModule {
export class NotificationsModule {
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ <h4 class="border-bottom pb-2">
</td>
<td><a *ngIf="eventElement?.target"
target="_blank"
rel="noopener noreferrer"
[routerLink]="['/items', eventElement?.target?.id]">{{eventElement.title}}</a>
<span *ngIf="!eventElement?.target">{{eventElement.title}}</span>
</td>
<td *ngIf="showTopic.indexOf('/PID') !== -1">
<p><span class="small">{{'quality-assurance.event.table.pidtype' | translate}}</span>&nbsp;<span class="badge badge-info">{{eventElement.event.message.type}}</span></p>
<p><span class="small">{{'quality-assurance.event.table.pidvalue' | translate}}</span><br>
<a *ngIf="hasPIDHref(eventElement.event.message); else noPID" href="{{getPIDHref(eventElement.event.message)}}" target="_blank">
<a *ngIf="hasPIDHref(eventElement.event.message); else noPID" href="{{getPIDHref(eventElement.event.message)}}" rel="noopener noreferrer" target="_blank">
{{eventElement.event.message.value}}
</a>
<ng-template #noPID><span class="badge badge-info">{{eventElement.event.message.value}}</span></ng-template>
Expand All @@ -84,7 +85,7 @@ <h4 class="border-bottom pb-2">
</p>
<p>
<span class="small">{{'quality-assurance.event.table.project' | translate}}</span><br>
<a href="https://explore.openaire.eu/search/project?projectId={{ eventElement.event.message.openaireId}}" target="_blank">{{eventElement.event.message.title}}</a>
<a href="{{openAireUrl}}{{ eventElement.event.message.openaireId}}" rel="noopener noreferrer" target="_blank">{{eventElement.event.message.title}}</a>
</p>
<p>
<span *ngIf="eventElement.event.message.acronym"><span class="small">{{'quality-assurance.event.table.acronym' | translate}}</span>&nbsp;<span class="badge badge-info">{{eventElement.event.message.acronym}}</span><br></span>
Expand All @@ -96,7 +97,7 @@ <h4 class="border-bottom pb-2">
<hr>
<div>
{{(eventElement.hasProject ? 'quality-assurance.event.project.found' : 'quality-assurance.event.project.notFound') | translate}}
<a target="_blank" *ngIf="eventElement.hasProject" title="{{eventElement.projectTitle}}" [routerLink]="['/items', eventElement.projectId]">{{eventElement.handle}} </a>
<a target="_blank" rel="noopener noreferrer" *ngIf="eventElement.hasProject" title="{{eventElement.projectTitle}}" [routerLink]="['/items', eventElement.projectId]">{{eventElement.handle}} </a>
<div class="btn-group">
<button *ngIf="!eventElement.hasProject"
class="btn btn-outline-primary btn-sm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { of as observableOf } from 'rxjs';
import {
QualityAssuranceEventDataService
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
} from '../../../core/notifications/qa/events/quality-assurance-event-data.service';
import { QualityAssuranceEventsComponent } from './quality-assurance-events.component';
import {
getMockQualityAssuranceEventRestService,
Expand All @@ -26,7 +26,7 @@ import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import {
QualityAssuranceEventObject
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
} 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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { RemoteData } from '../../../core/data/remote-data';
import {
OpenaireQualityAssuranceEventMessageObject,
QualityAssuranceEventObject
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
} from '../../../core/notifications/qa/models/quality-assurance-event.model';
import {
QualityAssuranceEventDataService
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
} 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';
Expand Down Expand Up @@ -95,6 +95,10 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
* @type {boolean}
*/
public showMore = false;
/**
* The Open Aire base url for project search
*/
public openAireUrl = 'https://explore.openaire.eu/search/project?projectId=';
/**
* The FindListOptions object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h4 class="modal-title" id="modal-title">{{ (labelPrefix + label + '.title') | t
<small>{{ (labelPrefix + label + '.publication' | translate) }}</small>
<div class="mb-3">
<div class="text-truncate">
<a target="_blank" href="/items/{{(externalSourceEntry.event.target|async)?.payload?.id}}">
<a target="_blank" [routerLink]="'/items/{{(externalSourceEntry.event.target|async)?.payload?.id}}'">
{{externalSourceEntry.title}}
</a>
</div>
Expand All @@ -18,7 +18,7 @@ <h4 class="modal-title" id="modal-title">{{ (labelPrefix + label + '.title') | t
<small>{{ (labelPrefix + label + '.bountToLocal' |translate) }}</small>
<div class="mb-3">
<div class="text-truncate">
<a target="_blank" href="/items/{{externalSourceEntry.projectId}}">
<a target="_blank" [routerLink]="'/items/{{externalSourceEntry.projectId}}'">
{{externalSourceEntry.projectTitle}}
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import {
OpenaireQualityAssuranceEventMessageObject,
QualityAssuranceEventObject,
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
} from '../../../core/notifications/qa/models/quality-assurance-event.model';
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
import { Item } from '../../../core/shared/item.model';

Expand Down
Loading

0 comments on commit 922172d

Please sign in to comment.