Skip to content

Commit

Permalink
Merge pull request DSpace#2751 from 4Science/coar-notify-7-part-two
Browse files Browse the repository at this point in the history
Coar Notify Integration - Administer/Log
  • Loading branch information
tdonohue authored Mar 4, 2024
2 parents 76f5d34 + 0f7965e commit 761b0c2
Show file tree
Hide file tree
Showing 80 changed files with 3,666 additions and 70 deletions.
60 changes: 59 additions & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,67 @@ comcolSelectionSort:


# Search settings
search:
search:
# Settings to enable/disable or configure advanced search filters.
advancedFilters:
enabled: false
# List of filters to enable in "Advanced Search" dropdown
filter: [ 'title', 'author', 'subject', 'entityType' ]


# Notify metrics
# Configuration for Notify Admin Dashboard for metrics visualization
notifyMetrics:
# Configuration for received messages
- title: 'admin-notify-dashboard.received-ldn'
boxes:
- color: '#B8DAFF'
title: 'admin-notify-dashboard.NOTIFY.incoming.accepted'
config: 'NOTIFY.incoming.accepted'
description: 'admin-notify-dashboard.NOTIFY.incoming.accepted.description'
- color: '#D4EDDA'
title: 'admin-notify-dashboard.NOTIFY.incoming.processed'
config: 'NOTIFY.incoming.processed'
description: 'admin-notify-dashboard.NOTIFY.incoming.processed.description'
- color: '#FDBBC7'
title: 'admin-notify-dashboard.NOTIFY.incoming.failure'
config: 'NOTIFY.incoming.failure'
description: 'admin-notify-dashboard.NOTIFY.incoming.failure.description'
- color: '#FDBBC7'
title: 'admin-notify-dashboard.NOTIFY.incoming.untrusted'
config: 'NOTIFY.incoming.untrusted'
description: 'admin-notify-dashboard.NOTIFY.incoming.untrusted.description'
- color: '#43515F'
title: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems'
textColor: '#fff'
config: 'NOTIFY.incoming.involvedItems'
description: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems.description'
# Configuration for outgoing messages
- title: 'admin-notify-dashboard.generated-ldn'
boxes:
- color: '#B8DAFF'
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued'
config: 'NOTIFY.outgoing.queued'
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued.description'
- color: '#FDEEBB'
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry'
config: 'NOTIFY.outgoing.queued_for_retry'
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry.description'
- color: '#FDBBC7'
title: 'admin-notify-dashboard.NOTIFY.outgoing.failure'
config: 'NOTIFY.outgoing.failure'
description: 'admin-notify-dashboard.NOTIFY.outgoing.failure.description'
- color: '#43515F'
title: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems'
textColor: '#fff'
config: 'NOTIFY.outgoing.involvedItems'
description: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems.description'
- color: '#D4EDDA'
title: 'admin-notify-dashboard.NOTIFY.outgoing.delivered'
config: 'NOTIFY.outgoing.delivered'
description: 'admin-notify-dashboard.NOTIFY.outgoing.delivered.description'





Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translat
id="ldnUrl"
name="ldnUrl"
type="text">
<div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" class="error-text">
{{ 'ldn-new-service.form.error.ldnurl' | translate }}
<div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" >
<div *ngIf="formModel.get('ldnUrl').errors['required']" class="error-text">
{{ 'ldn-new-service.form.error.ldnurl' | translate }}
</div>
<div *ngIf="formModel.get('ldnUrl').errors['ldnUrlAlreadyAssociated']" class="error-text">
{{ 'ldn-new-service.form.error.ldnurl.ldnUrlAlreadyAssociated' | translate }}
</div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
TemplateRef,
ViewChild
} from '@angular/core';
import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
import {
FormArray,
FormBuilder,
FormGroup,
Validators
} from '@angular/forms';
import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
import {ActivatedRoute, Router} from '@angular/router';
import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
Expand Down Expand Up @@ -167,6 +172,9 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
this.closeModal();
this.sendBack();
} else {
if (!this.formModel.errors) {
this.setLdnUrlError();
}
this.notificationService.error(this.translateService.get('ldn-service-notification.created.failure.title'),
this.translateService.get('ldn-service-notification.created.failure.body'));
this.closeModal();
Expand Down Expand Up @@ -405,6 +413,9 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
this.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
this.translateService.get('admin.registries.services-formats.modify.success.content'));
} else {
if (!this.formModel.errors) {
this.setLdnUrlError();
}
this.notificationService.error(this.translateService.get('admin.registries.services-formats.modify.failure.head'),
this.translateService.get('admin.registries.services-formats.modify.failure.content'));
this.closeModal();
Expand Down Expand Up @@ -554,4 +565,14 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
automatic: '',
});
}


/**
* set ldnUrl error in case of unprocessable entity and provided value
*/
private setLdnUrlError(): void {
const control = this.formModel.controls.ldnUrl;
const controlErrors = control.errors || {};
control.setErrors({...controlErrors, ldnUrlAlreadyAssociated: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('LdnServicesService test', () => {

rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: createSuccessfulRemoteDataObject$({}, 500),
buildFromRequestUUID: createSuccessfulRemoteDataObject$({}, 500),
buildList: cold('a', { a: remoteDataMocks.Success })
});

Expand Down Expand Up @@ -111,6 +112,20 @@ describe('LdnServicesService test', () => {
done();
});
});

it('should invoke service', (done) => {
const constraints = [{void: true}];
const files = [new File([],'fileName')];
spyOn(service as any, 'getInvocationFormData');
spyOn(service, 'getBrowseEndpoint').and.returnValue(observableOf('testEndpoint'));
service.invoke('serviceName', 'serviceId', constraints, files).subscribe(result => {
expect((service as any).getInvocationFormData).toHaveBeenCalledWith(constraints, files);
expect(service.getBrowseEndpoint).toHaveBeenCalled();
expect(result).toBeInstanceOf(RemoteData);
done();
});

});
});

});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
import {ChangeDetectorRef, EventEmitter} from '@angular/core';
import { ChangeDetectorRef, EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
import {NotificationsService} from '../../../shared/notifications/notifications.service';
import {NotificationsServiceStub} from '../../../shared/testing/notifications-service.stub';
import {TranslateModule, TranslateService} from '@ngx-translate/core';
Expand All @@ -21,8 +21,6 @@ describe('LdnServicesOverviewComponent', () => {
let ldnServicesService;
let paginationService;
let modalService: NgbModal;
let notificationsService: NotificationsService;
let translateService: TranslateService;

const translateServiceStub = {
get: () => of('translated-text'),
Expand All @@ -33,7 +31,11 @@ describe('LdnServicesOverviewComponent', () => {

beforeEach(async () => {
paginationService = new PaginationServiceStub();
ldnServicesService = jasmine.createSpyObj('LdnServicesService', ['findAll', 'delete', 'patch']);
ldnServicesService = jasmine.createSpyObj('ldnServicesService', {
'findAll': createSuccessfulRemoteDataObject$({}),
'delete': createSuccessfulRemoteDataObject$({}),
'patch': createSuccessfulRemoteDataObject$({}),
});
await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [LdnServicesOverviewComponent],
Expand All @@ -50,9 +52,10 @@ describe('LdnServicesOverviewComponent', () => {
}
},
{provide: ChangeDetectorRef, useValue: {}},
{provide: NotificationsService, useValue: NotificationsServiceStub},
{provide: NotificationsService, useValue: new NotificationsServiceStub()},
{provide: TranslateService, useValue: translateServiceStub},
]
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
});

Expand All @@ -62,8 +65,6 @@ describe('LdnServicesOverviewComponent', () => {
ldnServicesService = TestBed.inject(LdnServicesService);
paginationService = TestBed.inject(PaginationService);
modalService = TestBed.inject(NgbModal);
notificationsService = TestBed.inject(NotificationsService);
translateService = TestBed.inject(TranslateService);
component.modalRef = jasmine.createSpyObj({close: null});
component.isProcessingSub = jasmine.createSpyObj({unsubscribe: null});
component.ldnServicesRD$ = of({} as RemoteData<PaginatedList<LdnService>>);
Expand Down Expand Up @@ -141,4 +142,22 @@ describe('LdnServicesOverviewComponent', () => {
expect(deleteSpy).toHaveBeenCalledWith(serviceId);
}));
});

describe('selectServiceToDelete', () => {
it('should set service to delete', fakeAsync(() => {
spyOn(component, 'openDeleteModal');
const serviceId = 123;
component.selectServiceToDelete(serviceId);
expect(component.selectedServiceId).toEqual(serviceId);
expect(component.openDeleteModal).toHaveBeenCalled();
}));
});

describe('toggleStatus', () => {
it('should toggle status', (() => {
component.toggleStatus({enabled: false}, ldnServicesService);
expect(ldnServicesService.patch).toHaveBeenCalled();
}));
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
import {
SiteAdministratorGuard
} from '../../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
import {
AdminNotifyIncomingComponent
} from './admin-notify-logs/admin-notify-incoming/admin-notify-incoming.component';
import {
AdminNotifyOutgoingComponent
} from './admin-notify-logs/admin-notify-outgoing/admin-notify-outgoing.component';
import { NotifyInfoGuard } from '../../core/coar-notify/notify-info/notify-info.guard';

@NgModule({
imports: [
RouterModule.forChild([
{
canActivate: [SiteAdministratorGuard, NotifyInfoGuard],
path: '',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
},
component: AdminNotifyDashboardComponent,
pathMatch: 'full',
data: {
title: 'admin.notify.dashboard.page.title',
breadcrumbKey: 'admin.notify.dashboard',
},
},
{
path: 'inbound',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
},
component: AdminNotifyIncomingComponent,
canActivate: [SiteAdministratorGuard, NotifyInfoGuard],
data: {
title: 'admin.notify.dashboard.page.title',
breadcrumbKey: 'admin.notify.dashboard',
},
},
{
path: 'outbound',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
},
component: AdminNotifyOutgoingComponent,
canActivate: [SiteAdministratorGuard, NotifyInfoGuard],
data: {
title: 'admin.notify.dashboard.page.title',
breadcrumbKey: 'admin.notify.dashboard',
},
}
])
],
})
/**
* Routing module for the Notifications section of the admin sidebar
*/
export class AdminNotifyDashboardRoutingModule {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="container">
<div class="row">
<div class="col-12">
<h1 class="border-bottom pb-2">{{'admin-notify-dashboard.title'| translate}}</h1>
<div class="my-4">{{'admin-notify-dashboard.description' | translate}}</div>
<div>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active">{{'admin-notify-dashboard.metrics' | translate}}</a>
</li>
<li class="nav-item">
<a class="nav-link" [routerLink]="'inbound'" [queryParams]="{view: 'table'}">{{'admin.notify.dashboard.inbound-logs' | translate}}</a>
</li>
<li class="nav-item">
<a class="nav-link" [routerLink]="'outbound'" [queryParams]="{view: 'table'}">{{'admin.notify.dashboard.outbound-logs' | translate}}</a>
</ul>
<div class="mt-2">
<ds-admin-notify-metrics *ngIf="(notifyMetricsRows$ | async)?.length" [boxesConfig]="notifyMetricsRows$ | async"></ds-admin-notify-metrics>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
import { TranslateModule } from '@ngx-translate/core';
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import { SearchService } from '../../core/shared/search/search.service';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { buildPaginatedList } from '../../core/data/paginated-list.model';
import { AdminNotifySearchResult } from './models/admin-notify-message-search-result.model';
import { AdminNotifyMessage } from './models/admin-notify-message.model';

describe('AdminNotifyDashboardComponent', () => {
let component: AdminNotifyDashboardComponent;
let fixture: ComponentFixture<AdminNotifyDashboardComponent>;

let item1;
let item2;
let item3;
let searchResult1;
let searchResult2;
let searchResult3;
let results;

const mockBoxes = [
{ title: 'admin-notify-dashboard.received-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] },
{ title: 'admin-notify-dashboard.generated-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] }
];

beforeEach(async () => {
item1 = Object.assign(new AdminNotifyMessage(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
item2 = Object.assign(new AdminNotifyMessage(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });
item3 = Object.assign(new AdminNotifyMessage(), { uuid: 'c3bcbff5-ec0c-4831-8e4c-94b9c933ccac' });
searchResult1 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item1 });
searchResult2 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item2 });
searchResult3 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item3 });
results = buildPaginatedList(undefined, [searchResult1, searchResult2, searchResult3]);

await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NgbNavModule],
declarations: [ AdminNotifyDashboardComponent ],
providers: [{ provide: SearchService, useValue: { search: () => createSuccessfulRemoteDataObject$(results)}}]
})
.compileComponents();

fixture = TestBed.createComponent(AdminNotifyDashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', (done) => {
component.notifyMetricsRows$.subscribe(boxes => {
expect(boxes).toEqual(mockBoxes);
done();
});
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 761b0c2

Please sign in to comment.