mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge remote-tracking branch 'origin/main' into CST-6876
# Conflicts: # src/app/shared/search/search.component.ts
This commit is contained in:
@@ -135,6 +135,9 @@ languages:
|
|||||||
- code: lv
|
- code: lv
|
||||||
label: Latviešu
|
label: Latviešu
|
||||||
active: true
|
active: true
|
||||||
|
- code: hi
|
||||||
|
label: Hindi
|
||||||
|
active: true
|
||||||
- code: hu
|
- code: hu
|
||||||
label: Magyar
|
label: Magyar
|
||||||
active: true
|
active: true
|
||||||
|
@@ -104,6 +104,8 @@
|
|||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"klaro": "^0.7.10",
|
"klaro": "^0.7.10",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"markdown-it": "^13.0.1",
|
||||||
|
"markdown-it-mathjax3": "^4.3.1",
|
||||||
"mirador": "^3.3.0",
|
"mirador": "^3.3.0",
|
||||||
"mirador-dl-plugin": "^0.13.0",
|
"mirador-dl-plugin": "^0.13.0",
|
||||||
"mirador-share-plugin": "^0.11.0",
|
"mirador-share-plugin": "^0.11.0",
|
||||||
@@ -116,6 +118,7 @@
|
|||||||
"ngx-moment": "^5.0.0",
|
"ngx-moment": "^5.0.0",
|
||||||
"ngx-pagination": "5.0.0",
|
"ngx-pagination": "5.0.0",
|
||||||
"ngx-sortablejs": "^11.1.0",
|
"ngx-sortablejs": "^11.1.0",
|
||||||
|
"ngx-ui-switch": "^11.0.1",
|
||||||
"nouislider": "^14.6.3",
|
"nouislider": "^14.6.3",
|
||||||
"pem": "1.14.4",
|
"pem": "1.14.4",
|
||||||
"postcss-cli": "^9.1.0",
|
"postcss-cli": "^9.1.0",
|
||||||
@@ -123,13 +126,13 @@
|
|||||||
"react-copy-to-clipboard": "^5.0.1",
|
"react-copy-to-clipboard": "^5.0.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
"sanitize-html": "^2.7.2",
|
||||||
"sortablejs": "1.13.0",
|
"sortablejs": "1.13.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
"url-parse": "^1.5.6",
|
"url-parse": "^1.5.6",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"webfontloader": "1.6.28",
|
"webfontloader": "1.6.28",
|
||||||
"zone.js": "~0.11.5",
|
"zone.js": "~0.11.5"
|
||||||
"ngx-ui-switch": "^11.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/custom-webpack": "~13.1.0",
|
"@angular-builders/custom-webpack": "~13.1.0",
|
||||||
@@ -155,6 +158,7 @@
|
|||||||
"@types/js-cookie": "2.2.6",
|
"@types/js-cookie": "2.2.6",
|
||||||
"@types/lodash": "^4.14.165",
|
"@types/lodash": "^4.14.165",
|
||||||
"@types/node": "^14.14.9",
|
"@types/node": "^14.14.9",
|
||||||
|
"@types/sanitize-html": "^2.6.2",
|
||||||
"@typescript-eslint/eslint-plugin": "5.11.0",
|
"@typescript-eslint/eslint-plugin": "5.11.0",
|
||||||
"@typescript-eslint/parser": "5.11.0",
|
"@typescript-eslint/parser": "5.11.0",
|
||||||
"axe-core": "^4.3.3",
|
"axe-core": "^4.3.3",
|
||||||
|
@@ -76,6 +76,10 @@ export function app() {
|
|||||||
*/
|
*/
|
||||||
const server = express();
|
const server = express();
|
||||||
|
|
||||||
|
// Tell Express to trust X-FORWARDED-* headers from proxies
|
||||||
|
// See https://expressjs.com/en/guide/behind-proxies.html
|
||||||
|
server.set('trust proxy', environment.ui.useProxies);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If production mode is enabled in the environment file:
|
* If production mode is enabled in the environment file:
|
||||||
* - Enable Angular's production mode
|
* - Enable Angular's production mode
|
||||||
|
@@ -238,7 +238,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
this.epersonService.deleteEPerson(ePerson).pipe(getFirstCompletedRemoteData()).subscribe((restResponse: RemoteData<NoContent>) => {
|
this.epersonService.deleteEPerson(ePerson).pipe(getFirstCompletedRemoteData()).subscribe((restResponse: RemoteData<NoContent>) => {
|
||||||
if (restResponse.hasSucceeded) {
|
if (restResponse.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: ePerson.name}));
|
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: ePerson.name}));
|
||||||
this.reset();
|
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + ePerson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
|
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + ePerson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
|
||||||
}
|
}
|
||||||
|
@@ -5,11 +5,12 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest as observableCombineLatest,
|
combineLatest as observableCombineLatest,
|
||||||
|
EMPTY,
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
Subscription
|
Subscription
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { catchError, map, switchMap, tap } from 'rxjs/operators';
|
import { catchError, defaultIfEmpty, map, switchMap, tap } from 'rxjs/operators';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||||
@@ -144,7 +145,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
return this.authorizationService.isAuthorized(FeatureID.AdministratorOf).pipe(
|
return this.authorizationService.isAuthorized(FeatureID.AdministratorOf).pipe(
|
||||||
switchMap((isSiteAdmin: boolean) => {
|
switchMap((isSiteAdmin: boolean) => {
|
||||||
return observableCombineLatest(groups.page.map((group: Group) => {
|
return observableCombineLatest([...groups.page.map((group: Group) => {
|
||||||
if (hasValue(group) && !this.deletedGroupsIds.includes(group.id)) {
|
if (hasValue(group) && !this.deletedGroupsIds.includes(group.id)) {
|
||||||
return observableCombineLatest([
|
return observableCombineLatest([
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self),
|
this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self),
|
||||||
@@ -165,8 +166,10 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return EMPTY;
|
||||||
}
|
}
|
||||||
})).pipe(map((dtos: GroupDtoModel[]) => {
|
})]).pipe(defaultIfEmpty([]), map((dtos: GroupDtoModel[]) => {
|
||||||
return buildPaginatedList(groups.pageInfo, dtos);
|
return buildPaginatedList(groups.pageInfo, dtos);
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
<div class="container">
|
||||||
|
<h2 id="header">{{'admin.batch-import.page.header' | translate}}</h2>
|
||||||
|
<p>{{'admin.batch-import.page.help' | translate}}</p>
|
||||||
|
<p *ngIf="dso">
|
||||||
|
selected collection: <b>{{getDspaceObjectName()}}</b>
|
||||||
|
<a href="javascript:void(0)" (click)="removeDspaceObject()">{{'admin.batch-import.page.remove' | translate}}</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<button class="btn btn-primary" (click)="this.selectCollection();">{{'admin.metadata-import.page.button.select-collection' | translate}}</button>
|
||||||
|
</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="validateOnly" [(ngModel)]="validateOnly">
|
||||||
|
<label class="form-check-label" for="validateOnly">
|
||||||
|
{{'admin.metadata-import.page.validateOnly' | translate}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<small id="validateOnlyHelpBlock" class="form-text text-muted">
|
||||||
|
{{'admin.batch-import.page.validateOnly.hint' | translate}}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ds-file-dropzone-no-uploader
|
||||||
|
(onFileAdded)="setFile($event)"
|
||||||
|
[dropMessageLabel]="'admin.batch-import.page.dropMsg'"
|
||||||
|
[dropMessageLabelReplacement]="'admin.batch-import.page.dropMsgReplace'">
|
||||||
|
</ds-file-dropzone-no-uploader>
|
||||||
|
|
||||||
|
<div class="space-children-mr">
|
||||||
|
<button class="btn btn-secondary" id="backButton"
|
||||||
|
(click)="this.onReturn();">{{'admin.metadata-import.page.button.return' | translate}}</button>
|
||||||
|
<button class="btn btn-primary" id="proceedButton"
|
||||||
|
(click)="this.importMetadata();">{{'admin.metadata-import.page.button.proceed' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -0,0 +1,151 @@
|
|||||||
|
import { ComponentFixture, fakeAsync, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { BatchImportPageComponent } from './batch-import-page.component';
|
||||||
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
|
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { FileValueAccessorDirective } from '../../shared/utils/file-value-accessor.directive';
|
||||||
|
import { FileValidator } from '../../shared/utils/require-file.validator';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import {
|
||||||
|
BATCH_IMPORT_SCRIPT_NAME,
|
||||||
|
ScriptDataService
|
||||||
|
} from '../../core/data/processes/script-data.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { Location } from '@angular/common';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
||||||
|
|
||||||
|
describe('BatchImportPageComponent', () => {
|
||||||
|
let component: BatchImportPageComponent;
|
||||||
|
let fixture: ComponentFixture<BatchImportPageComponent>;
|
||||||
|
|
||||||
|
let notificationService: NotificationsServiceStub;
|
||||||
|
let scriptService: any;
|
||||||
|
let router;
|
||||||
|
let locationStub;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
notificationService = new NotificationsServiceStub();
|
||||||
|
scriptService = jasmine.createSpyObj('scriptService',
|
||||||
|
{
|
||||||
|
invoke: createSuccessfulRemoteDataObject$({ processId: '46' })
|
||||||
|
}
|
||||||
|
);
|
||||||
|
router = jasmine.createSpyObj('router', {
|
||||||
|
navigateByUrl: jasmine.createSpy('navigateByUrl')
|
||||||
|
});
|
||||||
|
locationStub = jasmine.createSpyObj('location', {
|
||||||
|
back: jasmine.createSpy('back')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
init();
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
RouterTestingModule.withRoutes([])
|
||||||
|
],
|
||||||
|
declarations: [BatchImportPageComponent, FileValueAccessorDirective, FileValidator],
|
||||||
|
providers: [
|
||||||
|
{ provide: NotificationsService, useValue: notificationService },
|
||||||
|
{ provide: ScriptDataService, useValue: scriptService },
|
||||||
|
{ provide: Router, useValue: router },
|
||||||
|
{ provide: Location, useValue: locationStub },
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(BatchImportPageComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if back button is pressed', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#backButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('should do location.back', () => {
|
||||||
|
expect(locationStub.back).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if file is set', () => {
|
||||||
|
let fileMock: File;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fileMock = new File([''], 'filename.zip', { type: 'application/zip' });
|
||||||
|
component.setFile(fileMock);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if proceed button is pressed without validate only', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
component.validateOnly = false;
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('metadata-import script is invoked with --zip fileName and the mockFile', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '--zip', value: 'filename.zip' }),
|
||||||
|
];
|
||||||
|
parameterValues.push(Object.assign(new ProcessParameter(), { name: '--add' }));
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(BATCH_IMPORT_SCRIPT_NAME, parameterValues, [fileMock]);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/46');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if proceed button is pressed with validate only', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
component.validateOnly = true;
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('metadata-import script is invoked with --zip fileName and the mockFile and -v validate-only', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '--zip', value: 'filename.zip' }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '--add' }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-v', value: true }),
|
||||||
|
];
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(BATCH_IMPORT_SCRIPT_NAME, parameterValues, [fileMock]);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/46');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if proceed is pressed; but script invoke fails', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
spyOn(scriptService, 'invoke').and.returnValue(createFailedRemoteDataObject$('Error', 500));
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('error notification is shown', () => {
|
||||||
|
expect(notificationService.error).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,124 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { Location } from '@angular/common';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { BATCH_IMPORT_SCRIPT_NAME, ScriptDataService } from '../../core/data/processes/script-data.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
|
import { Process } from '../../process-page/processes/process.model';
|
||||||
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
|
import { getProcessDetailRoute } from '../../process-page/process-page-routing.paths';
|
||||||
|
import {
|
||||||
|
ImportBatchSelectorComponent
|
||||||
|
} from '../../shared/dso-selector/modal-wrappers/import-batch-selector/import-batch-selector.component';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-batch-import-page',
|
||||||
|
templateUrl: './batch-import-page.component.html'
|
||||||
|
})
|
||||||
|
export class BatchImportPageComponent {
|
||||||
|
/**
|
||||||
|
* The current value of the file
|
||||||
|
*/
|
||||||
|
fileObject: File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The validate only flag
|
||||||
|
*/
|
||||||
|
validateOnly = true;
|
||||||
|
/**
|
||||||
|
* dso object for community or collection
|
||||||
|
*/
|
||||||
|
dso: DSpaceObject = null;
|
||||||
|
|
||||||
|
public constructor(private location: Location,
|
||||||
|
protected translate: TranslateService,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
|
private scriptDataService: ScriptDataService,
|
||||||
|
private router: Router,
|
||||||
|
private modalService: NgbModal,
|
||||||
|
private dsoNameService: DSONameService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set file
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
setFile(file) {
|
||||||
|
this.fileObject = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When return button is pressed go to previous location
|
||||||
|
*/
|
||||||
|
public onReturn() {
|
||||||
|
this.location.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public selectCollection() {
|
||||||
|
const modalRef = this.modalService.open(ImportBatchSelectorComponent);
|
||||||
|
modalRef.componentInstance.response.pipe(take(1)).subscribe((dso) => {
|
||||||
|
this.dso = dso || null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts import-metadata script with --zip fileName (and the selected file)
|
||||||
|
*/
|
||||||
|
public importMetadata() {
|
||||||
|
if (this.fileObject == null) {
|
||||||
|
this.notificationsService.error(this.translate.get('admin.metadata-import.page.error.addFile'));
|
||||||
|
} else {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '--zip', value: this.fileObject.name }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '--add' })
|
||||||
|
];
|
||||||
|
if (this.dso) {
|
||||||
|
parameterValues.push(Object.assign(new ProcessParameter(), { name: '--collection', value: this.dso.uuid }));
|
||||||
|
}
|
||||||
|
if (this.validateOnly) {
|
||||||
|
parameterValues.push(Object.assign(new ProcessParameter(), { name: '-v', value: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scriptDataService.invoke(BATCH_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject]).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
).subscribe((rd: RemoteData<Process>) => {
|
||||||
|
if (rd.hasSucceeded) {
|
||||||
|
const title = this.translate.get('process.new.notification.success.title');
|
||||||
|
const content = this.translate.get('process.new.notification.success.content');
|
||||||
|
this.notificationsService.success(title, content);
|
||||||
|
if (isNotEmpty(rd.payload)) {
|
||||||
|
this.router.navigateByUrl(getProcessDetailRoute(rd.payload.processId));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const title = this.translate.get('process.new.notification.error.title');
|
||||||
|
const content = this.translate.get('process.new.notification.error.content');
|
||||||
|
this.notificationsService.error(title, content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return selected dspace object name
|
||||||
|
*/
|
||||||
|
getDspaceObjectName(): string {
|
||||||
|
if (this.dso) {
|
||||||
|
return this.dsoNameService.getName(this.dso);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove selected dso object
|
||||||
|
*/
|
||||||
|
removeDspaceObject(): void {
|
||||||
|
this.dso = null;
|
||||||
|
}
|
||||||
|
}
|
@@ -7,6 +7,7 @@ import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow
|
|||||||
import { I18nBreadcrumbsService } from '../core/breadcrumbs/i18n-breadcrumbs.service';
|
import { I18nBreadcrumbsService } from '../core/breadcrumbs/i18n-breadcrumbs.service';
|
||||||
import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curation-tasks.component';
|
import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curation-tasks.component';
|
||||||
import { REGISTRIES_MODULE_PATH } from './admin-routing-paths';
|
import { REGISTRIES_MODULE_PATH } from './admin-routing-paths';
|
||||||
|
import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -40,6 +41,12 @@ import { REGISTRIES_MODULE_PATH } from './admin-routing-paths';
|
|||||||
component: MetadataImportPageComponent,
|
component: MetadataImportPageComponent,
|
||||||
data: { title: 'admin.metadata-import.title', breadcrumbKey: 'admin.metadata-import' }
|
data: { title: 'admin.metadata-import.title', breadcrumbKey: 'admin.metadata-import' }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'batch-import',
|
||||||
|
resolve: { breadcrumb: I18nBreadcrumbResolver },
|
||||||
|
component: BatchImportPageComponent,
|
||||||
|
data: { title: 'admin.batch-import.title', breadcrumbKey: 'admin.batch-import' }
|
||||||
|
},
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
@@ -9,6 +9,7 @@ import { AdminWorkflowModuleModule } from './admin-workflow-page/admin-workflow.
|
|||||||
import { AdminSearchModule } from './admin-search-page/admin-search.module';
|
import { AdminSearchModule } from './admin-search-page/admin-search.module';
|
||||||
import { AdminSidebarSectionComponent } from './admin-sidebar/admin-sidebar-section/admin-sidebar-section.component';
|
import { AdminSidebarSectionComponent } from './admin-sidebar/admin-sidebar-section/admin-sidebar-section.component';
|
||||||
import { ExpandableAdminSidebarSectionComponent } from './admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component';
|
import { ExpandableAdminSidebarSectionComponent } from './admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component';
|
||||||
|
import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
// put only entry components that use custom decorator
|
// put only entry components that use custom decorator
|
||||||
@@ -28,7 +29,8 @@ const ENTRY_COMPONENTS = [
|
|||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AdminCurationTasksComponent,
|
AdminCurationTasksComponent,
|
||||||
MetadataImportPageComponent
|
MetadataImportPageComponent,
|
||||||
|
BatchImportPageComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AdminModule {
|
export class AdminModule {
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
import { Store, StoreModule } from '@ngrx/store';
|
import { Store, StoreModule } from '@ngrx/store';
|
||||||
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { CommonModule, DOCUMENT } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2';
|
|
||||||
|
|
||||||
// Load the implementations that should be tested
|
// Load the implementations that should be tested
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
@@ -73,7 +72,6 @@ describe('App component', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
|
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
|
||||||
{ provide: MetadataService, useValue: new MetadataServiceMock() },
|
{ provide: MetadataService, useValue: new MetadataServiceMock() },
|
||||||
{ provide: Angulartics2GoogleAnalytics, useValue: new AngularticsProviderMock() },
|
|
||||||
{ provide: Angulartics2DSpace, useValue: new AngularticsProviderMock() },
|
{ provide: Angulartics2DSpace, useValue: new AngularticsProviderMock() },
|
||||||
{ provide: AuthService, useValue: new AuthServiceMock() },
|
{ provide: AuthService, useValue: new AuthServiceMock() },
|
||||||
{ provide: Router, useValue: new RouterMock() },
|
{ provide: Router, useValue: new RouterMock() },
|
||||||
|
@@ -11,7 +11,6 @@ import { ActivatedRoute, Params, Router } from '@angular/router';
|
|||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
||||||
import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
@@ -29,7 +28,6 @@ import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
|
|||||||
* A metadata definition (a.k.a. browse id) is a short term used to describe one or multiple metadata fields.
|
* A metadata definition (a.k.a. browse id) is a short term used to describe one or multiple metadata fields.
|
||||||
* An example would be 'dateissued' for 'dc.date.issued'
|
* An example would be 'dateissued' for 'dc.date.issued'
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Date)
|
|
||||||
export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
|
export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,29 @@
|
|||||||
|
import {Component} from '@angular/core';
|
||||||
|
import { ThemedComponent } from '../../shared/theme-support/themed.component';
|
||||||
|
import { BrowseByDatePageComponent } from './browse-by-date-page.component';
|
||||||
|
import {BrowseByDataType, rendersBrowseBy} from '../browse-by-switcher/browse-by-decorator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Themed wrapper for BrowseByDatePageComponent
|
||||||
|
* */
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-themed-browse-by-metadata-page',
|
||||||
|
styleUrls: [],
|
||||||
|
templateUrl: '../../shared/theme-support/themed.component.html',
|
||||||
|
})
|
||||||
|
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Date)
|
||||||
|
export class ThemedBrowseByDatePageComponent
|
||||||
|
extends ThemedComponent<BrowseByDatePageComponent> {
|
||||||
|
protected getComponentName(): string {
|
||||||
|
return 'BrowseByDatePageComponent';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
|
return import(`../../../themes/${themeName}/app/browse-by/browse-by-date-page/browse-by-date-page.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importUnthemedComponent(): Promise<any> {
|
||||||
|
return import(`./browse-by-date-page.component`);
|
||||||
|
}
|
||||||
|
}
|
@@ -6,10 +6,10 @@
|
|||||||
<ds-comcol-page-header [name]="parentContext.name">
|
<ds-comcol-page-header [name]="parentContext.name">
|
||||||
</ds-comcol-page-header>
|
</ds-comcol-page-header>
|
||||||
<!-- Handle -->
|
<!-- Handle -->
|
||||||
<ds-comcol-page-handle
|
<ds-themed-comcol-page-handle
|
||||||
[content]="parentContext.handle"
|
[content]="parentContext.handle"
|
||||||
[title]="parentContext.type+'.page.handle'" >
|
[title]="parentContext.type+'.page.handle'" >
|
||||||
</ds-comcol-page-handle>
|
</ds-themed-comcol-page-handle>
|
||||||
<!-- Introductory text -->
|
<!-- Introductory text -->
|
||||||
<ds-comcol-page-content [content]="parentContext.introductoryText" [hasInnerHtml]="true">
|
<ds-comcol-page-content [content]="parentContext.introductoryText" [hasInnerHtml]="true">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
@@ -14,7 +14,6 @@ import { getFirstSucceededRemoteData } from '../../core/shared/operators';
|
|||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
||||||
import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
|
||||||
@@ -32,8 +31,7 @@ export const BBM_PAGINATION_ID = 'bbm';
|
|||||||
* or multiple metadata fields. An example would be 'author' for
|
* or multiple metadata fields. An example would be 'author' for
|
||||||
* 'dc.contributor.*'
|
* 'dc.contributor.*'
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Metadata)
|
export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
||||||
export class BrowseByMetadataPageComponent implements OnInit {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of browse-entries to display
|
* The list of browse-entries to display
|
||||||
@@ -93,7 +91,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
|||||||
startsWithOptions;
|
startsWithOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value we're browing items for
|
* The value we're browsing items for
|
||||||
* - When the value is not empty, we're browsing items
|
* - When the value is not empty, we're browsing items
|
||||||
* - When the value is empty, we're browsing browse-entries (values for the given metadata definition)
|
* - When the value is empty, we're browsing browse-entries (values for the given metadata definition)
|
||||||
*/
|
*/
|
||||||
|
@@ -0,0 +1,29 @@
|
|||||||
|
import {Component} from '@angular/core';
|
||||||
|
import { ThemedComponent } from '../../shared/theme-support/themed.component';
|
||||||
|
import { BrowseByMetadataPageComponent } from './browse-by-metadata-page.component';
|
||||||
|
import {BrowseByDataType, rendersBrowseBy} from '../browse-by-switcher/browse-by-decorator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Themed wrapper for BrowseByMetadataPageComponent
|
||||||
|
**/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-themed-browse-by-metadata-page',
|
||||||
|
styleUrls: [],
|
||||||
|
templateUrl: '../../shared/theme-support/themed.component.html',
|
||||||
|
})
|
||||||
|
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Metadata)
|
||||||
|
export class ThemedBrowseByMetadataPageComponent
|
||||||
|
extends ThemedComponent<BrowseByMetadataPageComponent> {
|
||||||
|
protected getComponentName(): string {
|
||||||
|
return 'BrowseByMetadataPageComponent';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
|
return import(`../../../themes/${themeName}/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importUnthemedComponent(): Promise<any> {
|
||||||
|
return import(`./browse-by-metadata-page.component`);
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,6 @@ import {
|
|||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||||
import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
@@ -23,7 +22,6 @@ import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
|
|||||||
/**
|
/**
|
||||||
* Component for browsing items by title (dc.title)
|
* Component for browsing items by title (dc.title)
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Title)
|
|
||||||
export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
||||||
|
|
||||||
public constructor(protected route: ActivatedRoute,
|
public constructor(protected route: ActivatedRoute,
|
||||||
|
@@ -0,0 +1,29 @@
|
|||||||
|
import {Component} from '@angular/core';
|
||||||
|
import { ThemedComponent } from '../../shared/theme-support/themed.component';
|
||||||
|
import { BrowseByTitlePageComponent } from './browse-by-title-page.component';
|
||||||
|
import {BrowseByDataType, rendersBrowseBy} from '../browse-by-switcher/browse-by-decorator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Themed wrapper for BrowseByTitlePageComponent
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-themed-browse-by-title-page',
|
||||||
|
styleUrls: [],
|
||||||
|
templateUrl: '../../shared/theme-support/themed.component.html',
|
||||||
|
})
|
||||||
|
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Title)
|
||||||
|
export class ThemedBrowseByTitlePageComponent
|
||||||
|
extends ThemedComponent<BrowseByTitlePageComponent> {
|
||||||
|
protected getComponentName(): string {
|
||||||
|
return 'BrowseByTitlePageComponent';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
|
return import(`../../../themes/${themeName}/app/browse-by/browse-by-title-page/browse-by-title-page.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importUnthemedComponent(): Promise<any> {
|
||||||
|
return import(`./browse-by-title-page.component`);
|
||||||
|
}
|
||||||
|
}
|
@@ -7,12 +7,20 @@ import { BrowseByDatePageComponent } from './browse-by-date-page/browse-by-date-
|
|||||||
import { BrowseBySwitcherComponent } from './browse-by-switcher/browse-by-switcher.component';
|
import { BrowseBySwitcherComponent } from './browse-by-switcher/browse-by-switcher.component';
|
||||||
import { ThemedBrowseBySwitcherComponent } from './browse-by-switcher/themed-browse-by-switcher.component';
|
import { ThemedBrowseBySwitcherComponent } from './browse-by-switcher/themed-browse-by-switcher.component';
|
||||||
import { ComcolModule } from '../shared/comcol/comcol.module';
|
import { ComcolModule } from '../shared/comcol/comcol.module';
|
||||||
|
import { ThemedBrowseByMetadataPageComponent } from './browse-by-metadata-page/themed-browse-by-metadata-page.component';
|
||||||
|
import { ThemedBrowseByDatePageComponent } from './browse-by-date-page/themed-browse-by-date-page.component';
|
||||||
|
import { ThemedBrowseByTitlePageComponent } from './browse-by-title-page/themed-browse-by-title-page.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
// put only entry components that use custom decorator
|
// put only entry components that use custom decorator
|
||||||
BrowseByTitlePageComponent,
|
BrowseByTitlePageComponent,
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataPageComponent,
|
||||||
BrowseByDatePageComponent
|
BrowseByDatePageComponent,
|
||||||
|
|
||||||
|
ThemedBrowseByMetadataPageComponent,
|
||||||
|
ThemedBrowseByDatePageComponent,
|
||||||
|
ThemedBrowseByTitlePageComponent,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
</ds-comcol-page-logo>
|
</ds-comcol-page-logo>
|
||||||
|
|
||||||
<!-- Handle -->
|
<!-- Handle -->
|
||||||
<ds-comcol-page-handle
|
<ds-themed-comcol-page-handle
|
||||||
[content]="collection.handle"
|
[content]="collection.handle"
|
||||||
[title]="'collection.page.handle'" >
|
[title]="'collection.page.handle'" >
|
||||||
</ds-comcol-page-handle>
|
</ds-themed-comcol-page-handle>
|
||||||
<!-- Introductory text -->
|
<!-- Introductory text -->
|
||||||
<ds-comcol-page-content
|
<ds-comcol-page-content
|
||||||
[content]="collection.introductoryText"
|
[content]="collection.introductoryText"
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
|
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
|
||||||
</ds-comcol-page-logo>
|
</ds-comcol-page-logo>
|
||||||
<!-- Handle -->
|
<!-- Handle -->
|
||||||
<ds-comcol-page-handle [content]="communityPayload.handle" [title]="'community.page.handle'">
|
<ds-themed-comcol-page-handle [content]="communityPayload.handle" [title]="'community.page.handle'">
|
||||||
</ds-comcol-page-handle>
|
</ds-themed-comcol-page-handle>
|
||||||
<!-- Introductory text -->
|
<!-- Introductory text -->
|
||||||
<ds-comcol-page-content [content]="communityPayload.introductoryText" [hasInnerHtml]="true">
|
<ds-comcol-page-content [content]="communityPayload.introductoryText" [hasInnerHtml]="true">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<ds-comcol-role
|
<ds-comcol-role
|
||||||
*ngFor="let comcolRole of getComcolRoles$() | async"
|
*ngFor="let comcolRole of comcolRoles$ | async"
|
||||||
[dso]="community$ | async"
|
[dso]="community$ | async"
|
||||||
[comcolRole]="comcolRole"
|
[comcolRole]="comcolRole"
|
||||||
>
|
>
|
||||||
|
@@ -78,8 +78,9 @@ describe('CommunityRolesComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a community admin role component', () => {
|
it('should display a community admin role component', (done) => {
|
||||||
expect(de.query(By.css('ds-comcol-role .community-admin')))
|
expect(de.query(By.css('ds-comcol-role .community-admin')))
|
||||||
.toBeTruthy();
|
.toBeTruthy();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -19,28 +19,14 @@ export class CommunityRolesComponent implements OnInit {
|
|||||||
dsoRD$: Observable<RemoteData<Community>>;
|
dsoRD$: Observable<RemoteData<Community>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The community to manage, as an observable.
|
* The different roles for the community, as an observable.
|
||||||
*/
|
*/
|
||||||
get community$(): Observable<Community> {
|
comcolRoles$: Observable<HALLink[]>;
|
||||||
return this.dsoRD$.pipe(
|
|
||||||
getFirstSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The different roles for the community.
|
* The community to manage, as an observable.
|
||||||
*/
|
*/
|
||||||
getComcolRoles$(): Observable<HALLink[]> {
|
community$: Observable<Community>;
|
||||||
return this.community$.pipe(
|
|
||||||
map((community) => [
|
|
||||||
{
|
|
||||||
name: 'community-admin',
|
|
||||||
href: community._links.adminGroup.href,
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
@@ -52,5 +38,22 @@ export class CommunityRolesComponent implements OnInit {
|
|||||||
first(),
|
first(),
|
||||||
map((data) => data.dso),
|
map((data) => data.dso),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.community$ = this.dsoRD$.pipe(
|
||||||
|
getFirstSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different roles for the community.
|
||||||
|
*/
|
||||||
|
this.comcolRoles$ = this.community$.pipe(
|
||||||
|
map((community) => [
|
||||||
|
{
|
||||||
|
name: 'community-admin',
|
||||||
|
href: community._links.adminGroup.href,
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -180,17 +180,20 @@ describe('CommunityPageSubCollectionList Component', () => {
|
|||||||
comp.community = mockCommunity;
|
comp.community = mockCommunity;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a list of collections', () => {
|
|
||||||
subCollList = collections;
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
const collList = fixture.debugElement.queryAll(By.css('li'));
|
it('should display a list of collections', () => {
|
||||||
expect(collList.length).toEqual(5);
|
waitForAsync(() => {
|
||||||
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
|
subCollList = collections;
|
||||||
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
|
fixture.detectChanges();
|
||||||
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
|
|
||||||
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
|
const collList = fixture.debugElement.queryAll(By.css('li'));
|
||||||
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
|
expect(collList.length).toEqual(5);
|
||||||
|
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
|
||||||
|
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
|
||||||
|
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
|
||||||
|
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
|
||||||
|
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not display the header when list of collections is empty', () => {
|
it('should not display the header when list of collections is empty', () => {
|
||||||
|
@@ -181,17 +181,20 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a list of sub-communities', () => {
|
|
||||||
subCommList = subcommunities;
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
const subComList = fixture.debugElement.queryAll(By.css('li'));
|
it('should display a list of sub-communities', () => {
|
||||||
expect(subComList.length).toEqual(5);
|
waitForAsync(() => {
|
||||||
expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1');
|
subCommList = subcommunities;
|
||||||
expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2');
|
fixture.detectChanges();
|
||||||
expect(subComList[2].nativeElement.textContent).toContain('SubCommunity 3');
|
|
||||||
expect(subComList[3].nativeElement.textContent).toContain('SubCommunity 4');
|
const subComList = fixture.debugElement.queryAll(By.css('li'));
|
||||||
expect(subComList[4].nativeElement.textContent).toContain('SubCommunity 5');
|
expect(subComList.length).toEqual(5);
|
||||||
|
expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1');
|
||||||
|
expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2');
|
||||||
|
expect(subComList[2].nativeElement.textContent).toContain('SubCommunity 3');
|
||||||
|
expect(subComList[3].nativeElement.textContent).toContain('SubCommunity 4');
|
||||||
|
expect(subComList[4].nativeElement.textContent).toContain('SubCommunity 5');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not display the header when list of sub-communities is empty', () => {
|
it('should not display the header when list of sub-communities is empty', () => {
|
||||||
|
54
src/app/core/cache/object-cache.actions.ts
vendored
54
src/app/core/cache/object-cache.actions.ts
vendored
@@ -13,7 +13,9 @@ export const ObjectCacheActionTypes = {
|
|||||||
REMOVE: type('dspace/core/cache/object/REMOVE'),
|
REMOVE: type('dspace/core/cache/object/REMOVE'),
|
||||||
RESET_TIMESTAMPS: type('dspace/core/cache/object/RESET_TIMESTAMPS'),
|
RESET_TIMESTAMPS: type('dspace/core/cache/object/RESET_TIMESTAMPS'),
|
||||||
ADD_PATCH: type('dspace/core/cache/object/ADD_PATCH'),
|
ADD_PATCH: type('dspace/core/cache/object/ADD_PATCH'),
|
||||||
APPLY_PATCH: type('dspace/core/cache/object/APPLY_PATCH')
|
APPLY_PATCH: type('dspace/core/cache/object/APPLY_PATCH'),
|
||||||
|
ADD_DEPENDENTS: type('dspace/core/cache/object/ADD_DEPENDENTS'),
|
||||||
|
REMOVE_DEPENDENTS: type('dspace/core/cache/object/REMOVE_DEPENDENTS')
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,13 +128,55 @@ export class ApplyPatchObjectCacheAction implements Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An NgRx action to add dependent request UUIDs to a cached object
|
||||||
|
*/
|
||||||
|
export class AddDependentsObjectCacheAction implements Action {
|
||||||
|
type = ObjectCacheActionTypes.ADD_DEPENDENTS;
|
||||||
|
payload: {
|
||||||
|
href: string;
|
||||||
|
dependentRequestUUIDs: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new AddDependentsObjectCacheAction
|
||||||
|
*
|
||||||
|
* @param href the self link of a cached object
|
||||||
|
* @param dependentRequestUUIDs the UUID of the request that depends on this object
|
||||||
|
*/
|
||||||
|
constructor(href: string, dependentRequestUUIDs: string[]) {
|
||||||
|
this.payload = {
|
||||||
|
href,
|
||||||
|
dependentRequestUUIDs,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An NgRx action to remove all dependent request UUIDs from a cached object
|
||||||
|
*/
|
||||||
|
export class RemoveDependentsObjectCacheAction implements Action {
|
||||||
|
type = ObjectCacheActionTypes.REMOVE_DEPENDENTS;
|
||||||
|
payload: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new RemoveDependentsObjectCacheAction
|
||||||
|
*
|
||||||
|
* @param href the self link of a cached object for which to remove all dependent request UUIDs
|
||||||
|
*/
|
||||||
|
constructor(href: string) {
|
||||||
|
this.payload = href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type to encompass all ObjectCacheActions
|
* A type to encompass all ObjectCacheActions
|
||||||
*/
|
*/
|
||||||
export type ObjectCacheAction
|
export type ObjectCacheAction
|
||||||
= AddToObjectCacheAction
|
= AddToObjectCacheAction
|
||||||
| RemoveFromObjectCacheAction
|
| RemoveFromObjectCacheAction
|
||||||
| ResetObjectCacheTimestampsAction
|
| ResetObjectCacheTimestampsAction
|
||||||
| AddPatchObjectCacheAction
|
| AddPatchObjectCacheAction
|
||||||
| ApplyPatchObjectCacheAction;
|
| ApplyPatchObjectCacheAction
|
||||||
|
| AddDependentsObjectCacheAction
|
||||||
|
| RemoveDependentsObjectCacheAction;
|
||||||
|
28
src/app/core/cache/object-cache.reducer.spec.ts
vendored
28
src/app/core/cache/object-cache.reducer.spec.ts
vendored
@@ -2,11 +2,13 @@ import * as deepFreeze from 'deep-freeze';
|
|||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import {
|
import {
|
||||||
|
AddDependentsObjectCacheAction,
|
||||||
AddPatchObjectCacheAction,
|
AddPatchObjectCacheAction,
|
||||||
AddToObjectCacheAction,
|
AddToObjectCacheAction,
|
||||||
ApplyPatchObjectCacheAction,
|
ApplyPatchObjectCacheAction,
|
||||||
|
RemoveDependentsObjectCacheAction,
|
||||||
RemoveFromObjectCacheAction,
|
RemoveFromObjectCacheAction,
|
||||||
ResetObjectCacheTimestampsAction
|
ResetObjectCacheTimestampsAction,
|
||||||
} from './object-cache.actions';
|
} from './object-cache.actions';
|
||||||
|
|
||||||
import { objectCacheReducer } from './object-cache.reducer';
|
import { objectCacheReducer } from './object-cache.reducer';
|
||||||
@@ -42,20 +44,22 @@ describe('objectCacheReducer', () => {
|
|||||||
timeCompleted: new Date().getTime(),
|
timeCompleted: new Date().getTime(),
|
||||||
msToLive: 900000,
|
msToLive: 900000,
|
||||||
requestUUIDs: [requestUUID1],
|
requestUUIDs: [requestUUID1],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
patches: [],
|
patches: [],
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
},
|
},
|
||||||
[selfLink2]: {
|
[selfLink2]: {
|
||||||
data: {
|
data: {
|
||||||
type: Item.type,
|
type: Item.type,
|
||||||
self: requestUUID2,
|
self: selfLink2,
|
||||||
foo: 'baz',
|
foo: 'baz',
|
||||||
_links: { self: { href: requestUUID2 } }
|
_links: { self: { href: selfLink2 } }
|
||||||
},
|
},
|
||||||
alternativeLinks: [altLink3, altLink4],
|
alternativeLinks: [altLink3, altLink4],
|
||||||
timeCompleted: new Date().getTime(),
|
timeCompleted: new Date().getTime(),
|
||||||
msToLive: 900000,
|
msToLive: 900000,
|
||||||
requestUUIDs: [selfLink2],
|
requestUUIDs: [requestUUID2],
|
||||||
|
dependentRequestUUIDs: [requestUUID1],
|
||||||
patches: [],
|
patches: [],
|
||||||
isDirty: false
|
isDirty: false
|
||||||
}
|
}
|
||||||
@@ -189,4 +193,20 @@ describe('objectCacheReducer', () => {
|
|||||||
expect((newState[selfLink1].data as any).name).toEqual(newName);
|
expect((newState[selfLink1].data as any).name).toEqual(newName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add dependent requests on ADD_DEPENDENTS', () => {
|
||||||
|
let newState = objectCacheReducer(testState, new AddDependentsObjectCacheAction(selfLink1, ['new', 'newer', 'newest']));
|
||||||
|
expect(newState[selfLink1].dependentRequestUUIDs).toEqual(['new', 'newer', 'newest']);
|
||||||
|
|
||||||
|
newState = objectCacheReducer(newState, new AddDependentsObjectCacheAction(selfLink2, ['more']));
|
||||||
|
expect(newState[selfLink2].dependentRequestUUIDs).toEqual([requestUUID1, 'more']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clear dependent requests on REMOVE_DEPENDENTS', () => {
|
||||||
|
let newState = objectCacheReducer(testState, new RemoveDependentsObjectCacheAction(selfLink1));
|
||||||
|
expect(newState[selfLink1].dependentRequestUUIDs).toEqual([]);
|
||||||
|
|
||||||
|
newState = objectCacheReducer(newState, new RemoveDependentsObjectCacheAction(selfLink2));
|
||||||
|
expect(newState[selfLink2].dependentRequestUUIDs).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
66
src/app/core/cache/object-cache.reducer.ts
vendored
66
src/app/core/cache/object-cache.reducer.ts
vendored
@@ -1,12 +1,13 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
import {
|
import {
|
||||||
|
AddDependentsObjectCacheAction,
|
||||||
AddPatchObjectCacheAction,
|
AddPatchObjectCacheAction,
|
||||||
AddToObjectCacheAction,
|
AddToObjectCacheAction,
|
||||||
ApplyPatchObjectCacheAction,
|
ApplyPatchObjectCacheAction,
|
||||||
ObjectCacheAction,
|
ObjectCacheAction,
|
||||||
ObjectCacheActionTypes,
|
ObjectCacheActionTypes, RemoveDependentsObjectCacheAction,
|
||||||
RemoveFromObjectCacheAction,
|
RemoveFromObjectCacheAction,
|
||||||
ResetObjectCacheTimestampsAction
|
ResetObjectCacheTimestampsAction,
|
||||||
} from './object-cache.actions';
|
} from './object-cache.actions';
|
||||||
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { CacheEntry } from './cache-entry';
|
import { CacheEntry } from './cache-entry';
|
||||||
@@ -69,6 +70,12 @@ export class ObjectCacheEntry implements CacheEntry {
|
|||||||
*/
|
*/
|
||||||
requestUUIDs: string[];
|
requestUUIDs: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of UUIDs for the requests that depend on this object.
|
||||||
|
* When this object is invalidated, these requests will be invalidated as well.
|
||||||
|
*/
|
||||||
|
dependentRequestUUIDs: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of patches that were made on the client side to this entry, but haven't been sent to the server yet
|
* An array of patches that were made on the client side to this entry, but haven't been sent to the server yet
|
||||||
*/
|
*/
|
||||||
@@ -134,6 +141,14 @@ export function objectCacheReducer(state = initialState, action: ObjectCacheActi
|
|||||||
return applyPatchObjectCache(state, action as ApplyPatchObjectCacheAction);
|
return applyPatchObjectCache(state, action as ApplyPatchObjectCacheAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ObjectCacheActionTypes.ADD_DEPENDENTS: {
|
||||||
|
return addDependentsObjectCacheState(state, action as AddDependentsObjectCacheAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
case ObjectCacheActionTypes.REMOVE_DEPENDENTS: {
|
||||||
|
return removeDependentsObjectCacheState(state, action as RemoveDependentsObjectCacheAction);
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -159,6 +174,7 @@ function addToObjectCache(state: ObjectCacheState, action: AddToObjectCacheActio
|
|||||||
timeCompleted: action.payload.timeCompleted,
|
timeCompleted: action.payload.timeCompleted,
|
||||||
msToLive: action.payload.msToLive,
|
msToLive: action.payload.msToLive,
|
||||||
requestUUIDs: [action.payload.requestUUID, ...(existing.requestUUIDs || [])],
|
requestUUIDs: [action.payload.requestUUID, ...(existing.requestUUIDs || [])],
|
||||||
|
dependentRequestUUIDs: existing.dependentRequestUUIDs || [],
|
||||||
isDirty: isNotEmpty(existing.patches),
|
isDirty: isNotEmpty(existing.patches),
|
||||||
patches: existing.patches || [],
|
patches: existing.patches || [],
|
||||||
alternativeLinks: [...(existing.alternativeLinks || []), ...newAltLinks]
|
alternativeLinks: [...(existing.alternativeLinks || []), ...newAltLinks]
|
||||||
@@ -252,3 +268,49 @@ function applyPatchObjectCache(state: ObjectCacheState, action: ApplyPatchObject
|
|||||||
}
|
}
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a list of dependent request UUIDs to a cached object, used when defining new dependencies
|
||||||
|
*
|
||||||
|
* @param state the current state
|
||||||
|
* @param action an AddDependentsObjectCacheAction
|
||||||
|
* @return the new state, with the dependent requests of the cached object updated
|
||||||
|
*/
|
||||||
|
function addDependentsObjectCacheState(state: ObjectCacheState, action: AddDependentsObjectCacheAction): ObjectCacheState {
|
||||||
|
const href = action.payload.href;
|
||||||
|
const newState = Object.assign({}, state);
|
||||||
|
|
||||||
|
if (hasValue(newState[href])) {
|
||||||
|
newState[href] = Object.assign({}, newState[href], {
|
||||||
|
dependentRequestUUIDs: [
|
||||||
|
...new Set([
|
||||||
|
...newState[href]?.dependentRequestUUIDs || [],
|
||||||
|
...action.payload.dependentRequestUUIDs,
|
||||||
|
])
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all dependent request UUIDs from a cached object, used to clear out-of-date depedencies
|
||||||
|
*
|
||||||
|
* @param state the current state
|
||||||
|
* @param action an AddDependentsObjectCacheAction
|
||||||
|
* @return the new state, with the dependent requests of the cached object updated
|
||||||
|
*/
|
||||||
|
function removeDependentsObjectCacheState(state: ObjectCacheState, action: RemoveDependentsObjectCacheAction): ObjectCacheState {
|
||||||
|
const href = action.payload;
|
||||||
|
const newState = Object.assign({}, state);
|
||||||
|
|
||||||
|
if (hasValue(newState[href])) {
|
||||||
|
newState[href] = Object.assign({}, newState[href], {
|
||||||
|
dependentRequestUUIDs: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
133
src/app/core/cache/object-cache.service.spec.ts
vendored
133
src/app/core/cache/object-cache.service.spec.ts
vendored
@@ -11,10 +11,12 @@ import { coreReducers} from '../core.reducers';
|
|||||||
import { RestRequestMethod } from '../data/rest-request-method';
|
import { RestRequestMethod } from '../data/rest-request-method';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import {
|
import {
|
||||||
|
AddDependentsObjectCacheAction,
|
||||||
|
RemoveDependentsObjectCacheAction,
|
||||||
AddPatchObjectCacheAction,
|
AddPatchObjectCacheAction,
|
||||||
AddToObjectCacheAction,
|
AddToObjectCacheAction,
|
||||||
ApplyPatchObjectCacheAction,
|
ApplyPatchObjectCacheAction,
|
||||||
RemoveFromObjectCacheAction
|
RemoveFromObjectCacheAction,
|
||||||
} from './object-cache.actions';
|
} from './object-cache.actions';
|
||||||
import { Patch } from './object-cache.reducer';
|
import { Patch } from './object-cache.reducer';
|
||||||
import { ObjectCacheService } from './object-cache.service';
|
import { ObjectCacheService } from './object-cache.service';
|
||||||
@@ -25,6 +27,7 @@ import { storeModuleConfig } from '../../app.reducer';
|
|||||||
import { TestColdObservable } from 'jasmine-marbles/src/test-observables';
|
import { TestColdObservable } from 'jasmine-marbles/src/test-observables';
|
||||||
import { IndexName } from '../index/index-name.model';
|
import { IndexName } from '../index/index-name.model';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
|
|
||||||
describe('ObjectCacheService', () => {
|
describe('ObjectCacheService', () => {
|
||||||
let service: ObjectCacheService;
|
let service: ObjectCacheService;
|
||||||
@@ -38,6 +41,7 @@ describe('ObjectCacheService', () => {
|
|||||||
let altLink1;
|
let altLink1;
|
||||||
let altLink2;
|
let altLink2;
|
||||||
let requestUUID;
|
let requestUUID;
|
||||||
|
let requestUUID2;
|
||||||
let alternativeLink;
|
let alternativeLink;
|
||||||
let timestamp;
|
let timestamp;
|
||||||
let timestamp2;
|
let timestamp2;
|
||||||
@@ -55,6 +59,7 @@ describe('ObjectCacheService', () => {
|
|||||||
altLink1 = 'https://alternative.link/endpoint/1234';
|
altLink1 = 'https://alternative.link/endpoint/1234';
|
||||||
altLink2 = 'https://alternative.link/endpoint/5678';
|
altLink2 = 'https://alternative.link/endpoint/5678';
|
||||||
requestUUID = '4d3a4ce8-a375-4b98-859b-39f0a014d736';
|
requestUUID = '4d3a4ce8-a375-4b98-859b-39f0a014d736';
|
||||||
|
requestUUID2 = 'c0f486c1-c4d3-4a03-b293-ca5b71ff0054';
|
||||||
alternativeLink = 'https://rest.api/endpoint/5e4f8a5-be98-4c51-9fd8-6bfedcbd59b7/item';
|
alternativeLink = 'https://rest.api/endpoint/5e4f8a5-be98-4c51-9fd8-6bfedcbd59b7/item';
|
||||||
timestamp = new Date().getTime();
|
timestamp = new Date().getTime();
|
||||||
timestamp2 = new Date().getTime() - 200;
|
timestamp2 = new Date().getTime() - 200;
|
||||||
@@ -71,13 +76,17 @@ describe('ObjectCacheService', () => {
|
|||||||
data: objectToCache,
|
data: objectToCache,
|
||||||
timeCompleted: timestamp,
|
timeCompleted: timestamp,
|
||||||
msToLive: msToLive,
|
msToLive: msToLive,
|
||||||
alternativeLinks: [altLink1, altLink2]
|
alternativeLinks: [altLink1, altLink2],
|
||||||
|
requestUUIDs: [requestUUID],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
};
|
};
|
||||||
cacheEntry2 = {
|
cacheEntry2 = {
|
||||||
data: objectToCache,
|
data: objectToCache,
|
||||||
timeCompleted: timestamp2,
|
timeCompleted: timestamp2,
|
||||||
msToLive: msToLive2,
|
msToLive: msToLive2,
|
||||||
alternativeLinks: [altLink2]
|
alternativeLinks: [altLink2],
|
||||||
|
requestUUIDs: [requestUUID2],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
};
|
};
|
||||||
invalidCacheEntry = Object.assign({}, cacheEntry, { msToLive: -1 });
|
invalidCacheEntry = Object.assign({}, cacheEntry, { msToLive: -1 });
|
||||||
operations = [{ op: 'replace', path: '/name', value: 'random string' } as Operation];
|
operations = [{ op: 'replace', path: '/name', value: 'random string' } as Operation];
|
||||||
@@ -343,4 +352,122 @@ describe('ObjectCacheService', () => {
|
|||||||
expect(store.dispatch).toHaveBeenCalledWith(new ApplyPatchObjectCacheAction(selfLink));
|
expect(store.dispatch).toHaveBeenCalledWith(new ApplyPatchObjectCacheAction(selfLink));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('request dependencies', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const state = Object.assign({}, initialState, {
|
||||||
|
core: Object.assign({}, initialState.core, {
|
||||||
|
'cache/object': {
|
||||||
|
['objectWithoutDependents']: {
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
|
},
|
||||||
|
['objectWithDependents']: {
|
||||||
|
dependentRequestUUIDs: [requestUUID],
|
||||||
|
},
|
||||||
|
[selfLink]: cacheEntry,
|
||||||
|
},
|
||||||
|
'index': {
|
||||||
|
'object/alt-link-to-self-link': {
|
||||||
|
[anotherLink]: selfLink,
|
||||||
|
['objectWithoutDependentsAlt']: 'objectWithoutDependents',
|
||||||
|
['objectWithDependentsAlt']: 'objectWithDependents',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
mockStore.setState(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addDependency', () => {
|
||||||
|
it('should dispatch an ADD_DEPENDENTS action', () => {
|
||||||
|
service.addDependency(selfLink, 'objectWithoutDependents');
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new AddDependentsObjectCacheAction('objectWithoutDependents', [requestUUID]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve alt links', () => {
|
||||||
|
service.addDependency(anotherLink, 'objectWithoutDependentsAlt');
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new AddDependentsObjectCacheAction('objectWithoutDependents', [requestUUID]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not dispatch if either href cannot be resolved to a cached self link', () => {
|
||||||
|
service.addDependency(selfLink, 'unknown');
|
||||||
|
service.addDependency('unknown', 'objectWithoutDependents');
|
||||||
|
service.addDependency('nothing', 'matches');
|
||||||
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not dispatch if either href is undefined', () => {
|
||||||
|
service.addDependency(selfLink, undefined);
|
||||||
|
service.addDependency(undefined, 'objectWithoutDependents');
|
||||||
|
service.addDependency(undefined, undefined);
|
||||||
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not dispatch if the dependency exists already', () => {
|
||||||
|
service.addDependency(selfLink, 'objectWithDependents');
|
||||||
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with observable hrefs', () => {
|
||||||
|
service.addDependency(observableOf(selfLink), observableOf('objectWithoutDependents'));
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new AddDependentsObjectCacheAction('objectWithoutDependents', [requestUUID]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should only dispatch once for the first value of either observable href', () => {
|
||||||
|
const testScheduler = new TestScheduler((actual, expected) => {
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
testScheduler.run(({ cold: tsCold, flush }) => {
|
||||||
|
const href$ = tsCold('--y-n-n', {
|
||||||
|
y: selfLink,
|
||||||
|
n: 'NOPE'
|
||||||
|
});
|
||||||
|
const dependsOnHref$ = tsCold('-y-n-n', {
|
||||||
|
y: 'objectWithoutDependents',
|
||||||
|
n: 'NOPE'
|
||||||
|
});
|
||||||
|
|
||||||
|
service.addDependency(href$, dependsOnHref$);
|
||||||
|
flush();
|
||||||
|
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new AddDependentsObjectCacheAction('objectWithoutDependents', [requestUUID]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not dispatch if either of the hrefs emits undefined', () => {
|
||||||
|
const testScheduler = new TestScheduler((actual, expected) => {
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
testScheduler.run(({ cold: tsCold, flush }) => {
|
||||||
|
const undefined$ = tsCold('--u');
|
||||||
|
|
||||||
|
service.addDependency(selfLink, undefined$);
|
||||||
|
service.addDependency(undefined$, 'objectWithoutDependents');
|
||||||
|
service.addDependency(undefined$, undefined$);
|
||||||
|
flush();
|
||||||
|
|
||||||
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('removeDependents', () => {
|
||||||
|
it('should dispatch a REMOVE_DEPENDENTS action', () => {
|
||||||
|
service.removeDependents('objectWithDependents');
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new RemoveDependentsObjectCacheAction('objectWithDependents'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve alt links', () => {
|
||||||
|
service.removeDependents('objectWithDependentsAlt');
|
||||||
|
expect(store.dispatch).toHaveBeenCalledOnceWith(new RemoveDependentsObjectCacheAction('objectWithDependents'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not dispatch if the href cannot be resolved to a cached self link', () => {
|
||||||
|
service.removeDependents('unknown');
|
||||||
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
107
src/app/core/cache/object-cache.service.ts
vendored
107
src/app/core/cache/object-cache.service.ts
vendored
@@ -4,23 +4,15 @@ import { applyPatch, Operation } from 'fast-json-patch';
|
|||||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
import { distinctUntilChanged, filter, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||||
import { hasValue, isNotEmpty, isEmpty } from '../../shared/empty.util';
|
import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { coreSelector } from '../core.selectors';
|
import { coreSelector } from '../core.selectors';
|
||||||
import { RestRequestMethod } from '../data/rest-request-method';
|
import { RestRequestMethod } from '../data/rest-request-method';
|
||||||
import {
|
import { selfLinkFromAlternativeLinkSelector, selfLinkFromUuidSelector } from '../index/index.selectors';
|
||||||
selfLinkFromAlternativeLinkSelector,
|
|
||||||
selfLinkFromUuidSelector
|
|
||||||
} from '../index/index.selectors';
|
|
||||||
import { GenericConstructor } from '../shared/generic-constructor';
|
import { GenericConstructor } from '../shared/generic-constructor';
|
||||||
import { getClassForType } from './builders/build-decorators';
|
import { getClassForType } from './builders/build-decorators';
|
||||||
import { LinkService } from './builders/link.service';
|
import { LinkService } from './builders/link.service';
|
||||||
import {
|
import { AddDependentsObjectCacheAction, AddPatchObjectCacheAction, AddToObjectCacheAction, ApplyPatchObjectCacheAction, RemoveDependentsObjectCacheAction, RemoveFromObjectCacheAction } from './object-cache.actions';
|
||||||
AddPatchObjectCacheAction,
|
|
||||||
AddToObjectCacheAction,
|
|
||||||
ApplyPatchObjectCacheAction,
|
|
||||||
RemoveFromObjectCacheAction
|
|
||||||
} from './object-cache.actions';
|
|
||||||
|
|
||||||
import { ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer';
|
import { ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer';
|
||||||
import { AddToSSBAction } from './server-sync-buffer.actions';
|
import { AddToSSBAction } from './server-sync-buffer.actions';
|
||||||
@@ -339,4 +331,97 @@ export class ObjectCacheService {
|
|||||||
this.store.dispatch(new ApplyPatchObjectCacheAction(selfLink));
|
this.store.dispatch(new ApplyPatchObjectCacheAction(selfLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new dependency between two cached objects.
|
||||||
|
* When {@link dependsOnHref$} is invalidated, {@link href$} will be invalidated as well.
|
||||||
|
*
|
||||||
|
* This method should be called _after_ requests have been sent;
|
||||||
|
* it will only work if both objects are already present in the cache.
|
||||||
|
*
|
||||||
|
* If either object is undefined, the dependency will not be added
|
||||||
|
*
|
||||||
|
* @param href$ the href of an object to add a dependency to
|
||||||
|
* @param dependsOnHref$ the href of the new dependency
|
||||||
|
*/
|
||||||
|
addDependency(href$: string | Observable<string>, dependsOnHref$: string | Observable<string>) {
|
||||||
|
if (hasNoValue(href$) || hasNoValue(dependsOnHref$)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof href$ === 'string') {
|
||||||
|
href$ = observableOf(href$);
|
||||||
|
}
|
||||||
|
if (typeof dependsOnHref$ === 'string') {
|
||||||
|
dependsOnHref$ = observableOf(dependsOnHref$);
|
||||||
|
}
|
||||||
|
|
||||||
|
observableCombineLatest([
|
||||||
|
href$,
|
||||||
|
dependsOnHref$.pipe(
|
||||||
|
switchMap(dependsOnHref => this.resolveSelfLink(dependsOnHref))
|
||||||
|
),
|
||||||
|
]).pipe(
|
||||||
|
switchMap(([href, dependsOnSelfLink]: [string, string]) => {
|
||||||
|
const dependsOnSelfLink$ = observableOf(dependsOnSelfLink);
|
||||||
|
|
||||||
|
return observableCombineLatest([
|
||||||
|
dependsOnSelfLink$,
|
||||||
|
dependsOnSelfLink$.pipe(
|
||||||
|
switchMap(selfLink => this.getBySelfLink(selfLink)),
|
||||||
|
map(oce => oce?.dependentRequestUUIDs || []),
|
||||||
|
),
|
||||||
|
this.getByHref(href).pipe(
|
||||||
|
// only add the latest request to keep dependency index from growing indefinitely
|
||||||
|
map((entry: ObjectCacheEntry) => entry?.requestUUIDs?.[0]),
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
take(1),
|
||||||
|
).subscribe(([dependsOnSelfLink, currentDependents, newDependent]: [string, string[], string]) => {
|
||||||
|
// don't dispatch if either href is invalid or if the new dependency already exists
|
||||||
|
if (hasValue(dependsOnSelfLink) && hasValue(newDependent) && !currentDependents.includes(newDependent)) {
|
||||||
|
this.store.dispatch(new AddDependentsObjectCacheAction(dependsOnSelfLink, [newDependent]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all dependent requests associated with a cache entry.
|
||||||
|
*
|
||||||
|
* @href the href of a cached object
|
||||||
|
*/
|
||||||
|
removeDependents(href: string) {
|
||||||
|
this.resolveSelfLink(href).pipe(
|
||||||
|
take(1),
|
||||||
|
).subscribe((selfLink: string) => {
|
||||||
|
if (hasValue(selfLink)) {
|
||||||
|
this.store.dispatch(new RemoveDependentsObjectCacheAction(selfLink));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the self link of an existing cached object from an arbitrary href
|
||||||
|
*
|
||||||
|
* @param href any href
|
||||||
|
* @return an observable of the self link corresponding to the given href.
|
||||||
|
* Will emit the given href if it was a self link, another href
|
||||||
|
* if the given href was an alt link, or undefined if there is no
|
||||||
|
* cached object for this href.
|
||||||
|
*/
|
||||||
|
private resolveSelfLink(href: string): Observable<string> {
|
||||||
|
return this.getBySelfLink(href).pipe(
|
||||||
|
switchMap((oce: ObjectCacheEntry) => {
|
||||||
|
if (isNotEmpty(oce)) {
|
||||||
|
return [href];
|
||||||
|
} else {
|
||||||
|
return this.store.pipe(
|
||||||
|
select(selfLinkFromAlternativeLinkSelector(href)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
|
|||||||
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
||||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../cache/object-cache.service';
|
||||||
import { FindListOptions } from '../find-list-options.model';
|
import { FindListOptions } from '../find-list-options.model';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf, combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
import { getMockRequestService } from '../../../shared/mocks/request.service.mock';
|
import { getMockRequestService } from '../../../shared/mocks/request.service.mock';
|
||||||
import { HALEndpointServiceStub } from '../../../shared/testing/hal-endpoint-service.stub';
|
import { HALEndpointServiceStub } from '../../../shared/testing/hal-endpoint-service.stub';
|
||||||
import { getMockRemoteDataBuildService } from '../../../shared/mocks/remote-data-build.service.mock';
|
import { getMockRemoteDataBuildService } from '../../../shared/mocks/remote-data-build.service.mock';
|
||||||
@@ -20,6 +20,7 @@ import { RemoteData } from '../remote-data';
|
|||||||
import { RequestEntryState } from '../request-entry-state.model';
|
import { RequestEntryState } from '../request-entry-state.model';
|
||||||
import { fakeAsync, tick } from '@angular/core/testing';
|
import { fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { BaseDataService } from './base-data.service';
|
import { BaseDataService } from './base-data.service';
|
||||||
|
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
|
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
@@ -65,7 +66,13 @@ describe('BaseDataService', () => {
|
|||||||
},
|
},
|
||||||
getByHref: () => {
|
getByHref: () => {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
},
|
||||||
|
addDependency: () => {
|
||||||
|
/* empty */
|
||||||
|
},
|
||||||
|
removeDependents: () => {
|
||||||
|
/* empty */
|
||||||
|
},
|
||||||
} as any;
|
} as any;
|
||||||
selfLink = 'https://rest.api/endpoint/1698f1d3-be98-4c51-9fd8-6bfedcbd59b7';
|
selfLink = 'https://rest.api/endpoint/1698f1d3-be98-4c51-9fd8-6bfedcbd59b7';
|
||||||
linksToFollow = [
|
linksToFollow = [
|
||||||
@@ -558,7 +565,8 @@ describe('BaseDataService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
getByHrefSpy = spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
getByHrefSpy = spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
||||||
requestUUIDs: ['request1', 'request2', 'request3']
|
requestUUIDs: ['request1', 'request2', 'request3'],
|
||||||
|
dependentRequestUUIDs: ['request4', 'request5']
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -570,6 +578,8 @@ describe('BaseDataService', () => {
|
|||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request4');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request5');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -582,6 +592,8 @@ describe('BaseDataService', () => {
|
|||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request4');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request5');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return an Observable that only emits true once all requests are stale', () => {
|
it('should return an Observable that only emits true once all requests are stale', () => {
|
||||||
@@ -591,9 +603,13 @@ describe('BaseDataService', () => {
|
|||||||
case 'request1':
|
case 'request1':
|
||||||
return cold('--(t|)', BOOLEAN);
|
return cold('--(t|)', BOOLEAN);
|
||||||
case 'request2':
|
case 'request2':
|
||||||
return cold('----(t|)', BOOLEAN);
|
|
||||||
case 'request3':
|
|
||||||
return cold('------(t|)', BOOLEAN);
|
return cold('------(t|)', BOOLEAN);
|
||||||
|
case 'request3':
|
||||||
|
return cold('---(t|)', BOOLEAN);
|
||||||
|
case 'request4':
|
||||||
|
return cold('-(t|)', BOOLEAN);
|
||||||
|
case 'request5':
|
||||||
|
return cold('----(t|)', BOOLEAN);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -607,9 +623,9 @@ describe('BaseDataService', () => {
|
|||||||
it('should only fire for the current state of the object (instead of tracking it)', () => {
|
it('should only fire for the current state of the object (instead of tracking it)', () => {
|
||||||
testScheduler.run(({ cold, flush }) => {
|
testScheduler.run(({ cold, flush }) => {
|
||||||
getByHrefSpy.and.returnValue(cold('a---b---c---', {
|
getByHrefSpy.and.returnValue(cold('a---b---c---', {
|
||||||
a: { requestUUIDs: ['request1'] }, // this is the state at the moment we're invalidating the cache
|
a: { requestUUIDs: ['request1'], dependentRequestUUIDs: [] }, // this is the state at the moment we're invalidating the cache
|
||||||
b: { requestUUIDs: ['request2'] }, // we shouldn't keep tracking the state
|
b: { requestUUIDs: ['request2'], dependentRequestUUIDs: [] }, // we shouldn't keep tracking the state
|
||||||
c: { requestUUIDs: ['request3'] }, // because we may invalidate when we shouldn't
|
c: { requestUUIDs: ['request3'], dependentRequestUUIDs: [] }, // because we may invalidate when we shouldn't
|
||||||
}));
|
}));
|
||||||
|
|
||||||
service.invalidateByHref('some-href');
|
service.invalidateByHref('some-href');
|
||||||
@@ -624,4 +640,42 @@ describe('BaseDataService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('addDependency', () => {
|
||||||
|
let addDependencySpy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
addDependencySpy = spyOn(objectCache, 'addDependency');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call objectCache.addDependency with the object\'s self link', () => {
|
||||||
|
addDependencySpy.and.callFake((href$: Observable<string>, dependsOn$: Observable<string>) => {
|
||||||
|
observableCombineLatest([href$, dependsOn$]).subscribe(([href, dependsOn]) => {
|
||||||
|
expect(href).toBe('object-href');
|
||||||
|
expect(dependsOn).toBe('dependsOnHref');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
(service as any).addDependency(
|
||||||
|
createSuccessfulRemoteDataObject$({ _links: { self: { href: 'object-href' } } }),
|
||||||
|
observableOf('dependsOnHref')
|
||||||
|
);
|
||||||
|
expect(addDependencySpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call objectCache.addDependency without an href if request failed', () => {
|
||||||
|
addDependencySpy.and.callFake((href$: Observable<string>, dependsOn$: Observable<string>) => {
|
||||||
|
observableCombineLatest([href$, dependsOn$]).subscribe(([href, dependsOn]) => {
|
||||||
|
expect(href).toBe(undefined);
|
||||||
|
expect(dependsOn).toBe('dependsOnHref');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
(service as any).addDependency(
|
||||||
|
createFailedRemoteDataObject$('something went wrong'),
|
||||||
|
observableOf('dependsOnHref')
|
||||||
|
);
|
||||||
|
expect(addDependencySpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,7 +23,9 @@ import { PaginatedList } from '../paginated-list.model';
|
|||||||
import { ObjectCacheEntry } from '../../cache/object-cache.reducer';
|
import { ObjectCacheEntry } from '../../cache/object-cache.reducer';
|
||||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../cache/object-cache.service';
|
||||||
import { HALDataService } from './hal-data-service.interface';
|
import { HALDataService } from './hal-data-service.interface';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../shared/operators';
|
||||||
|
|
||||||
|
export const EMBED_SEPARATOR = '%2F';
|
||||||
/**
|
/**
|
||||||
* Common functionality for data services.
|
* Common functionality for data services.
|
||||||
* Specific functionality that not all services would need
|
* Specific functionality that not all services would need
|
||||||
@@ -201,7 +203,7 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
|
|||||||
let nestEmbed = embedString;
|
let nestEmbed = embedString;
|
||||||
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
|
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
|
||||||
if (hasValue(linkToFollow) && linkToFollow.shouldEmbed) {
|
if (hasValue(linkToFollow) && linkToFollow.shouldEmbed) {
|
||||||
nestEmbed = nestEmbed + '/' + String(linkToFollow.name);
|
nestEmbed = nestEmbed + EMBED_SEPARATOR + String(linkToFollow.name);
|
||||||
// Add the nested embeds size if given in the FollowLinkConfig.FindListOptions
|
// Add the nested embeds size if given in the FollowLinkConfig.FindListOptions
|
||||||
if (hasValue(linkToFollow.findListOptions) && hasValue(linkToFollow.findListOptions.elementsPerPage)) {
|
if (hasValue(linkToFollow.findListOptions) && hasValue(linkToFollow.findListOptions.elementsPerPage)) {
|
||||||
const nestedEmbedSize = 'embed.size=' + nestEmbed.split('=')[1] + '=' + linkToFollow.findListOptions.elementsPerPage;
|
const nestedEmbedSize = 'embed.size=' + nestEmbed.split('=')[1] + '=' + linkToFollow.findListOptions.elementsPerPage;
|
||||||
@@ -352,19 +354,55 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate a cached object by its href
|
* Shorthand method to add a dependency to a cached object
|
||||||
* @param href the href to invalidate
|
* ```
|
||||||
|
* const out$ = this.findByHref(...); // or another method that sends a request
|
||||||
|
* this.addDependency(out$, dependsOnHref);
|
||||||
|
* ```
|
||||||
|
* When {@link dependsOnHref$} is invalidated, {@link object$} will be invalidated as well.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object$ the cached object
|
||||||
|
* @param dependsOnHref$ the href of the object it should depend on
|
||||||
*/
|
*/
|
||||||
public invalidateByHref(href: string): Observable<boolean> {
|
protected addDependency(object$: Observable<RemoteData<T | PaginatedList<T>>>, dependsOnHref$: string | Observable<string>) {
|
||||||
|
this.objectCache.addDependency(
|
||||||
|
object$.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
switchMap((rd: RemoteData<T>) => {
|
||||||
|
if (rd.hasSucceeded) {
|
||||||
|
return [rd.payload._links.self.href];
|
||||||
|
} else {
|
||||||
|
// undefined href will be skipped in objectCache.addDependency
|
||||||
|
return [undefined];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
dependsOnHref$
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate an existing DSpaceObject by marking all requests it is included in as stale
|
||||||
|
* @param href The self link of the object to be invalidated
|
||||||
|
* @return An Observable that will emit `true` once all requests are stale
|
||||||
|
*/
|
||||||
|
invalidateByHref(href: string): Observable<boolean> {
|
||||||
const done$ = new AsyncSubject<boolean>();
|
const done$ = new AsyncSubject<boolean>();
|
||||||
|
|
||||||
this.objectCache.getByHref(href).pipe(
|
this.objectCache.getByHref(href).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
switchMap((oce: ObjectCacheEntry) => observableFrom(oce.requestUUIDs).pipe(
|
switchMap((oce: ObjectCacheEntry) => {
|
||||||
mergeMap((requestUUID: string) => this.requestService.setStaleByUUID(requestUUID)),
|
return observableFrom([
|
||||||
toArray(),
|
...oce.requestUUIDs,
|
||||||
)),
|
...oce.dependentRequestUUIDs
|
||||||
|
]).pipe(
|
||||||
|
mergeMap((requestUUID: string) => this.requestService.setStaleByUUID(requestUUID)),
|
||||||
|
toArray(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
|
this.objectCache.removeDependents(href);
|
||||||
done$.next(true);
|
done$.next(true);
|
||||||
done$.complete();
|
done$.complete();
|
||||||
});
|
});
|
||||||
|
@@ -22,6 +22,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
|
|||||||
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
||||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../cache/object-cache.service';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { EMBED_SEPARATOR } from './base-data.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether calls to `FindAllData` methods are correctly patched through in a concrete data service that implements it
|
* Tests whether calls to `FindAllData` methods are correctly patched through in a concrete data service that implements it
|
||||||
@@ -276,7 +277,7 @@ describe('FindAllDataImpl', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should include nested linksToFollow 3lvl', () => {
|
it('should include nested linksToFollow 3lvl', () => {
|
||||||
const expected = `${endpoint}?embed=owningCollection/itemtemplate/relationships`;
|
const expected = `${endpoint}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
|
||||||
|
|
||||||
(service as any).getFindAllHref({}, null, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships')))).subscribe((value) => {
|
(service as any).getFindAllHref({}, null, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships')))).subscribe((value) => {
|
||||||
expect(value).toBe(expected);
|
expect(value).toBe(expected);
|
||||||
@@ -284,7 +285,7 @@ describe('FindAllDataImpl', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should include nested linksToFollow 2lvl and nested embed\'s size', () => {
|
it('should include nested linksToFollow 2lvl and nested embed\'s size', () => {
|
||||||
const expected = `${endpoint}?embed.size=owningCollection/itemtemplate=4&embed=owningCollection/itemtemplate`;
|
const expected = `${endpoint}?embed.size=owningCollection${EMBED_SEPARATOR}itemtemplate=4&embed=owningCollection${EMBED_SEPARATOR}itemtemplate`;
|
||||||
const config: FindListOptions = Object.assign(new FindListOptions(), {
|
const config: FindListOptions = Object.assign(new FindListOptions(), {
|
||||||
elementsPerPage: 4,
|
elementsPerPage: 4,
|
||||||
});
|
});
|
||||||
|
@@ -19,6 +19,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
|
|||||||
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
||||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../cache/object-cache.service';
|
||||||
import { IdentifiableDataService } from './identifiable-data.service';
|
import { IdentifiableDataService } from './identifiable-data.service';
|
||||||
|
import { EMBED_SEPARATOR } from './base-data.service';
|
||||||
|
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ describe('IdentifiableDataService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should include nested linksToFollow 3lvl', () => {
|
it('should include nested linksToFollow 3lvl', () => {
|
||||||
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection/itemtemplate/relationships`;
|
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
|
||||||
const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships'))));
|
const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships'))));
|
||||||
expect(result).toEqual(expected);
|
expect(result).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
@@ -178,7 +178,12 @@ describe('PatchDataImpl', () => {
|
|||||||
|
|
||||||
describe('patch', () => {
|
describe('patch', () => {
|
||||||
const dso = {
|
const dso = {
|
||||||
uuid: 'dso-uuid'
|
uuid: 'dso-uuid',
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'dso-href',
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const operations = [
|
const operations = [
|
||||||
Object.assign({
|
Object.assign({
|
||||||
@@ -188,14 +193,23 @@ describe('PatchDataImpl', () => {
|
|||||||
}) as Operation
|
}) as Operation
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach((done) => {
|
it('should send a PatchRequest', () => {
|
||||||
service.patch(dso, operations).subscribe(() => {
|
service.patch(dso, operations);
|
||||||
done();
|
expect(requestService.send).toHaveBeenCalledWith(jasmine.any(PatchRequest));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a PatchRequest', () => {
|
it('should invalidate the cached object if successfully patched', () => {
|
||||||
expect(requestService.send).toHaveBeenCalledWith(jasmine.any(PatchRequest));
|
spyOn(rdbService, 'buildFromRequestUUIDAndAwait');
|
||||||
|
spyOn(service, 'invalidateByHref');
|
||||||
|
|
||||||
|
service.patch(dso, operations);
|
||||||
|
|
||||||
|
expect(rdbService.buildFromRequestUUIDAndAwait).toHaveBeenCalled();
|
||||||
|
expect((rdbService.buildFromRequestUUIDAndAwait as jasmine.Spy).calls.argsFor(0)[0]).toBe(requestService.generateRequestId());
|
||||||
|
const callback = (rdbService.buildFromRequestUUIDAndAwait as jasmine.Spy).calls.argsFor(0)[1];
|
||||||
|
callback();
|
||||||
|
|
||||||
|
expect(service.invalidateByHref).toHaveBeenCalledWith('dso-href');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ export class PatchDataImpl<T extends CacheableObject> extends IdentifiableDataSe
|
|||||||
this.requestService.send(request);
|
this.requestService.send(request);
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.rdbService.buildFromRequestUUID(requestId);
|
return this.rdbService.buildFromRequestUUIDAndAwait(requestId, () => this.invalidateByHref(object._links.self.href));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,6 +9,7 @@ import { GetRequest, IdentifierType } from './request.models';
|
|||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
|
import { EMBED_SEPARATOR } from './base/base-data.service';
|
||||||
|
|
||||||
describe('DsoRedirectService', () => {
|
describe('DsoRedirectService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -174,7 +175,7 @@ describe('DsoRedirectService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should include nested linksToFollow 3lvl', () => {
|
it('should include nested linksToFollow 3lvl', () => {
|
||||||
const expected = `${requestUUIDURL}&embed=owningCollection/itemtemplate/relationships`;
|
const expected = `${requestUUIDURL}&embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
|
||||||
const result = (service as any).dataService.getIDHref(
|
const result = (service as any).dataService.getIDHref(
|
||||||
pidLink,
|
pidLink,
|
||||||
dsoUUID,
|
dsoUUID,
|
||||||
|
@@ -2,7 +2,7 @@ import { AuthorizationDataService } from './authorization-data.service';
|
|||||||
import { SiteDataService } from '../site-data.service';
|
import { SiteDataService } from '../site-data.service';
|
||||||
import { Site } from '../../shared/site.model';
|
import { Site } from '../../shared/site.model';
|
||||||
import { EPerson } from '../../eperson/models/eperson.model';
|
import { EPerson } from '../../eperson/models/eperson.model';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||||
import { FeatureID } from './feature-id';
|
import { FeatureID } from './feature-id';
|
||||||
import { hasValue } from '../../../shared/empty.util';
|
import { hasValue } from '../../../shared/empty.util';
|
||||||
import { RequestParam } from '../../cache/models/request-param.model';
|
import { RequestParam } from '../../cache/models/request-param.model';
|
||||||
@@ -12,10 +12,12 @@ import { createPaginatedList } from '../../../shared/testing/utils.test';
|
|||||||
import { Feature } from '../../shared/feature.model';
|
import { Feature } from '../../shared/feature.model';
|
||||||
import { FindListOptions } from '../find-list-options.model';
|
import { FindListOptions } from '../find-list-options.model';
|
||||||
import { testSearchDataImplementation } from '../base/search-data.spec';
|
import { testSearchDataImplementation } from '../base/search-data.spec';
|
||||||
|
import { getMockObjectCacheService } from '../../../shared/mocks/object-cache.service.mock';
|
||||||
|
|
||||||
describe('AuthorizationDataService', () => {
|
describe('AuthorizationDataService', () => {
|
||||||
let service: AuthorizationDataService;
|
let service: AuthorizationDataService;
|
||||||
let siteService: SiteDataService;
|
let siteService: SiteDataService;
|
||||||
|
let objectCache;
|
||||||
|
|
||||||
let site: Site;
|
let site: Site;
|
||||||
let ePerson: EPerson;
|
let ePerson: EPerson;
|
||||||
@@ -38,7 +40,8 @@ describe('AuthorizationDataService', () => {
|
|||||||
siteService = jasmine.createSpyObj('siteService', {
|
siteService = jasmine.createSpyObj('siteService', {
|
||||||
find: observableOf(site),
|
find: observableOf(site),
|
||||||
});
|
});
|
||||||
service = new AuthorizationDataService(requestService, undefined, undefined, undefined, siteService);
|
objectCache = getMockObjectCacheService();
|
||||||
|
service = new AuthorizationDataService(requestService, undefined, objectCache, undefined, siteService);
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -110,6 +113,43 @@ describe('AuthorizationDataService', () => {
|
|||||||
expect(service.searchBy).toHaveBeenCalledWith('object', createExpected(objectUrl, ePersonUuid, FeatureID.LoginOnBehalfOf), true, true);
|
expect(service.searchBy).toHaveBeenCalledWith('object', createExpected(objectUrl, ePersonUuid, FeatureID.LoginOnBehalfOf), true, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('dependencies', () => {
|
||||||
|
let addDependencySpy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
(service.searchBy as any).and.returnValue(observableOf('searchBy RD$'));
|
||||||
|
addDependencySpy = spyOn(service as any, 'addDependency');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add a dependency on the objectUrl', (done) => {
|
||||||
|
addDependencySpy.and.callFake((href$: Observable<string>, dependsOn$: Observable<string>) => {
|
||||||
|
observableCombineLatest([href$, dependsOn$]).subscribe(([href, dependsOn]) => {
|
||||||
|
expect(href).toBe('searchBy RD$');
|
||||||
|
expect(dependsOn).toBe('object-href');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
service.searchByObject(FeatureID.AdministratorOf, 'object-href').subscribe(() => {
|
||||||
|
expect(addDependencySpy).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add a dependency on the Site object if no objectUrl is given', (done) => {
|
||||||
|
addDependencySpy.and.callFake((object$: Observable<any>, dependsOn$: Observable<string>) => {
|
||||||
|
observableCombineLatest([object$, dependsOn$]).subscribe(([object, dependsOn]) => {
|
||||||
|
expect(object).toBe('searchBy RD$');
|
||||||
|
expect(dependsOn).toBe('test-site-href');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
service.searchByObject(FeatureID.AdministratorOf).subscribe(() => {
|
||||||
|
expect(addDependencySpy).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isAuthorized', () => {
|
describe('isAuthorized', () => {
|
||||||
|
@@ -11,10 +11,10 @@ import { followLink, FollowLinkConfig } from '../../../shared/utils/follow-link-
|
|||||||
import { RemoteData } from '../remote-data';
|
import { RemoteData } from '../remote-data';
|
||||||
import { PaginatedList } from '../paginated-list.model';
|
import { PaginatedList } from '../paginated-list.model';
|
||||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||||
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
|
import { hasNoValue, hasValue, isNotEmpty } from '../../../shared/empty.util';
|
||||||
import { RequestParam } from '../../cache/models/request-param.model';
|
import { RequestParam } from '../../cache/models/request-param.model';
|
||||||
import { AuthorizationSearchParams } from './authorization-search-params';
|
import { AuthorizationSearchParams } from './authorization-search-params';
|
||||||
import { addSiteObjectUrlIfEmpty, oneAuthorizationMatchesFeature } from './authorization-utils';
|
import { oneAuthorizationMatchesFeature } from './authorization-utils';
|
||||||
import { FeatureID } from './feature-id';
|
import { FeatureID } from './feature-id';
|
||||||
import { getFirstCompletedRemoteData } from '../../shared/operators';
|
import { getFirstCompletedRemoteData } from '../../shared/operators';
|
||||||
import { FindListOptions } from '../find-list-options.model';
|
import { FindListOptions } from '../find-list-options.model';
|
||||||
@@ -96,12 +96,28 @@ export class AuthorizationDataService extends BaseDataService<Authorization> imp
|
|||||||
* {@link HALLink}s should be automatically resolved
|
* {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
searchByObject(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Authorization>[]): Observable<RemoteData<PaginatedList<Authorization>>> {
|
searchByObject(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Authorization>[]): Observable<RemoteData<PaginatedList<Authorization>>> {
|
||||||
return observableOf(new AuthorizationSearchParams(objectUrl, ePersonUuid, featureId)).pipe(
|
const objectUrl$ = observableOf(objectUrl).pipe(
|
||||||
addSiteObjectUrlIfEmpty(this.siteService),
|
switchMap((url) => {
|
||||||
|
if (hasNoValue(url)) {
|
||||||
|
return this.siteService.find().pipe(
|
||||||
|
map((site) => site.self)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return observableOf(url);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const out$ = objectUrl$.pipe(
|
||||||
|
map((url: string) => new AuthorizationSearchParams(url, ePersonUuid, featureId)),
|
||||||
switchMap((params: AuthorizationSearchParams) => {
|
switchMap((params: AuthorizationSearchParams) => {
|
||||||
return this.searchBy(this.searchByObjectPath, this.createSearchOptions(params.objectUrl, options, params.ePersonUuid, params.featureId), useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
return this.searchBy(this.searchByObjectPath, this.createSearchOptions(params.objectUrl, options, params.ePersonUuid, params.featureId), useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.addDependency(out$, objectUrl$);
|
||||||
|
|
||||||
|
return out$;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,6 +24,8 @@ import { dataService } from '../base/data-service.decorator';
|
|||||||
|
|
||||||
export const METADATA_IMPORT_SCRIPT_NAME = 'metadata-import';
|
export const METADATA_IMPORT_SCRIPT_NAME = 'metadata-import';
|
||||||
export const METADATA_EXPORT_SCRIPT_NAME = 'metadata-export';
|
export const METADATA_EXPORT_SCRIPT_NAME = 'metadata-export';
|
||||||
|
export const BATCH_IMPORT_SCRIPT_NAME = 'import';
|
||||||
|
export const BATCH_EXPORT_SCRIPT_NAME = 'export';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@dataService(SCRIPT)
|
@dataService(SCRIPT)
|
||||||
|
@@ -307,7 +307,7 @@ describe('EPersonDataService', () => {
|
|||||||
it('should sent a patch request with an uuid, token and new password to the epersons endpoint', () => {
|
it('should sent a patch request with an uuid, token and new password to the epersons endpoint', () => {
|
||||||
service.patchPasswordWithToken('test-uuid', 'test-token', 'test-password');
|
service.patchPasswordWithToken('test-uuid', 'test-token', 'test-password');
|
||||||
|
|
||||||
const operation = Object.assign({ op: 'add', path: '/password', value: 'test-password' });
|
const operation = Object.assign({ op: 'add', path: '/password', value: { new_password: 'test-password' } });
|
||||||
const expected = new PatchRequest(requestService.generateRequestId(), epersonsEndpoint + '/test-uuid?token=test-token', [operation]);
|
const expected = new PatchRequest(requestService.generateRequestId(), epersonsEndpoint + '/test-uuid?token=test-token', [operation]);
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected);
|
expect(requestService.send).toHaveBeenCalledWith(expected);
|
||||||
|
@@ -3,7 +3,10 @@ import { createSelector, select, Store } from '@ngrx/store';
|
|||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { find, map, take } from 'rxjs/operators';
|
import { find, map, take } from 'rxjs/operators';
|
||||||
import { EPeopleRegistryCancelEPersonAction, EPeopleRegistryEditEPersonAction } from '../../access-control/epeople-registry/epeople-registry.actions';
|
import {
|
||||||
|
EPeopleRegistryCancelEPersonAction,
|
||||||
|
EPeopleRegistryEditEPersonAction
|
||||||
|
} from '../../access-control/epeople-registry/epeople-registry.actions';
|
||||||
import { EPeopleRegistryState } from '../../access-control/epeople-registry/epeople-registry.reducers';
|
import { EPeopleRegistryState } from '../../access-control/epeople-registry/epeople-registry.reducers';
|
||||||
import { AppState } from '../../app.reducer';
|
import { AppState } from '../../app.reducer';
|
||||||
import { hasNoValue, hasValue } from '../../shared/empty.util';
|
import { hasNoValue, hasValue } from '../../shared/empty.util';
|
||||||
@@ -318,7 +321,7 @@ export class EPersonDataService extends IdentifiableDataService<EPerson> impleme
|
|||||||
patchPasswordWithToken(uuid: string, token: string, password: string): Observable<RemoteData<EPerson>> {
|
patchPasswordWithToken(uuid: string, token: string, password: string): Observable<RemoteData<EPerson>> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
|
||||||
const operation = Object.assign({ op: 'add', path: '/password', value: password });
|
const operation = Object.assign({ op: 'add', path: '/password', value: { 'new_password': password } });
|
||||||
|
|
||||||
const hrefObs = this.halService.getEndpoint(this.linkPath).pipe(
|
const hrefObs = this.halService.getEndpoint(this.linkPath).pipe(
|
||||||
map((endpoint: string) => this.getIDHref(endpoint, uuid)),
|
map((endpoint: string) => this.getIDHref(endpoint, uuid)),
|
||||||
|
@@ -26,10 +26,9 @@ import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock';
|
|||||||
import { createPaginatedList, createRequestEntry$ } from '../../shared/testing/utils.test';
|
import { createPaginatedList, createRequestEntry$ } from '../../shared/testing/utils.test';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { FindListOptions } from '../data/find-list-options.model';
|
import { FindListOptions } from '../data/find-list-options.model';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
|
||||||
import { getMockLinkService } from '../../shared/mocks/link-service.mock';
|
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { ObjectCacheEntry } from '../cache/object-cache.reducer';
|
import { ObjectCacheEntry } from '../cache/object-cache.reducer';
|
||||||
|
import { getMockObjectCacheService } from '../../shared/mocks/object-cache.service.mock';
|
||||||
|
|
||||||
describe('GroupDataService', () => {
|
describe('GroupDataService', () => {
|
||||||
let service: GroupDataService;
|
let service: GroupDataService;
|
||||||
@@ -42,7 +41,7 @@ describe('GroupDataService', () => {
|
|||||||
let groups$;
|
let groups$;
|
||||||
let halService;
|
let halService;
|
||||||
let rdbService;
|
let rdbService;
|
||||||
let objectCache: ObjectCacheService;
|
let objectCache;
|
||||||
function init() {
|
function init() {
|
||||||
restEndpointURL = 'https://dspace.4science.it/dspace-spring-rest/api/eperson';
|
restEndpointURL = 'https://dspace.4science.it/dspace-spring-rest/api/eperson';
|
||||||
groupsEndpoint = `${restEndpointURL}/groups`;
|
groupsEndpoint = `${restEndpointURL}/groups`;
|
||||||
@@ -50,7 +49,7 @@ describe('GroupDataService', () => {
|
|||||||
groups$ = createSuccessfulRemoteDataObject$(createPaginatedList(groups));
|
groups$ = createSuccessfulRemoteDataObject$(createPaginatedList(groups));
|
||||||
rdbService = getMockRemoteDataBuildServiceHrefMap(undefined, { 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups': groups$ });
|
rdbService = getMockRemoteDataBuildServiceHrefMap(undefined, { 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups': groups$ });
|
||||||
halService = new HALEndpointServiceStub(restEndpointURL);
|
halService = new HALEndpointServiceStub(restEndpointURL);
|
||||||
objectCache = new ObjectCacheService(store, getMockLinkService());
|
objectCache = getMockObjectCacheService();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@@ -114,8 +113,9 @@ describe('GroupDataService', () => {
|
|||||||
|
|
||||||
describe('addSubGroupToGroup', () => {
|
describe('addSubGroupToGroup', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
objectCache.getByHref.and.returnValue(observableOf({
|
||||||
requestUUIDs: ['request1', 'request2']
|
requestUUIDs: ['request1', 'request2'],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
} as ObjectCacheEntry));
|
} as ObjectCacheEntry));
|
||||||
spyOn((service as any).deleteData, 'invalidateByHref');
|
spyOn((service as any).deleteData, 'invalidateByHref');
|
||||||
service.addSubGroupToGroup(GroupMock, GroupMock2).subscribe();
|
service.addSubGroupToGroup(GroupMock, GroupMock2).subscribe();
|
||||||
@@ -143,8 +143,9 @@ describe('GroupDataService', () => {
|
|||||||
|
|
||||||
describe('deleteSubGroupFromGroup', () => {
|
describe('deleteSubGroupFromGroup', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
objectCache.getByHref.and.returnValue(observableOf({
|
||||||
requestUUIDs: ['request1', 'request2']
|
requestUUIDs: ['request1', 'request2'],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
} as ObjectCacheEntry));
|
} as ObjectCacheEntry));
|
||||||
spyOn((service as any).deleteData, 'invalidateByHref');
|
spyOn((service as any).deleteData, 'invalidateByHref');
|
||||||
service.deleteSubGroupFromGroup(GroupMock, GroupMock2).subscribe();
|
service.deleteSubGroupFromGroup(GroupMock, GroupMock2).subscribe();
|
||||||
@@ -168,8 +169,9 @@ describe('GroupDataService', () => {
|
|||||||
|
|
||||||
describe('addMemberToGroup', () => {
|
describe('addMemberToGroup', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
objectCache.getByHref.and.returnValue(observableOf({
|
||||||
requestUUIDs: ['request1', 'request2']
|
requestUUIDs: ['request1', 'request2'],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
} as ObjectCacheEntry));
|
} as ObjectCacheEntry));
|
||||||
spyOn((service as any).deleteData, 'invalidateByHref');
|
spyOn((service as any).deleteData, 'invalidateByHref');
|
||||||
service.addMemberToGroup(GroupMock, EPersonMock2).subscribe();
|
service.addMemberToGroup(GroupMock, EPersonMock2).subscribe();
|
||||||
@@ -198,8 +200,9 @@ describe('GroupDataService', () => {
|
|||||||
|
|
||||||
describe('deleteMemberFromGroup', () => {
|
describe('deleteMemberFromGroup', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
objectCache.getByHref.and.returnValue(observableOf({
|
||||||
requestUUIDs: ['request1', 'request2']
|
requestUUIDs: ['request1', 'request2'],
|
||||||
|
dependentRequestUUIDs: [],
|
||||||
} as ObjectCacheEntry));
|
} as ObjectCacheEntry));
|
||||||
spyOn((service as any).deleteData, 'invalidateByHref');
|
spyOn((service as any).deleteData, 'invalidateByHref');
|
||||||
service.deleteMemberFromGroup(GroupMock, EPersonMock).subscribe();
|
service.deleteMemberFromGroup(GroupMock, EPersonMock).subscribe();
|
||||||
|
@@ -2,17 +2,25 @@ import { TestBed } from '@angular/core/testing';
|
|||||||
import { BrowserHardRedirectService } from './browser-hard-redirect.service';
|
import { BrowserHardRedirectService } from './browser-hard-redirect.service';
|
||||||
|
|
||||||
describe('BrowserHardRedirectService', () => {
|
describe('BrowserHardRedirectService', () => {
|
||||||
const origin = 'https://test-host.com:4000';
|
let origin: string;
|
||||||
const mockLocation = {
|
let mockLocation: Location;
|
||||||
href: undefined,
|
let service: BrowserHardRedirectService;
|
||||||
pathname: '/pathname',
|
|
||||||
search: '/search',
|
|
||||||
origin
|
|
||||||
} as Location;
|
|
||||||
|
|
||||||
const service: BrowserHardRedirectService = new BrowserHardRedirectService(mockLocation);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
origin = 'https://test-host.com:4000';
|
||||||
|
mockLocation = {
|
||||||
|
href: undefined,
|
||||||
|
pathname: '/pathname',
|
||||||
|
search: '/search',
|
||||||
|
origin,
|
||||||
|
replace: (url: string) => {
|
||||||
|
mockLocation.href = url;
|
||||||
|
}
|
||||||
|
} as Location;
|
||||||
|
spyOn(mockLocation, 'replace');
|
||||||
|
|
||||||
|
service = new BrowserHardRedirectService(mockLocation);
|
||||||
|
|
||||||
TestBed.configureTestingModule({});
|
TestBed.configureTestingModule({});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,8 +36,8 @@ describe('BrowserHardRedirectService', () => {
|
|||||||
service.redirect(redirect);
|
service.redirect(redirect);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the location', () => {
|
it('should call location.replace with the new url', () => {
|
||||||
expect(mockLocation.href).toEqual(redirect);
|
expect(mockLocation.replace).toHaveBeenCalledWith(redirect);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ export class BrowserHardRedirectService extends HardRedirectService {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
redirect(url: string) {
|
redirect(url: string) {
|
||||||
this.location.href = url;
|
this.location.replace(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,6 +6,10 @@
|
|||||||
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||||
|
@@ -6,6 +6,10 @@
|
|||||||
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||||
|
@@ -5,6 +5,10 @@
|
|||||||
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||||
|
@@ -1,33 +1,40 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div *ngIf="showThumbnails" class="col-3 col-md-2">
|
<div *ngIf="showThumbnails" class="col-3 col-md-2">
|
||||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
[routerLink]="[itemPageRoute]" class="dont-break-out">
|
[routerLink]="[itemPageRoute]" class="dont-break-out">
|
||||||
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
||||||
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
|
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
|
||||||
[alt]="'thumbnail.orgunit.alt'"
|
[alt]="'thumbnail.orgunit.alt'"
|
||||||
[placeholder]="'thumbnail.orgunit.placeholder'">
|
[placeholder]="'thumbnail.orgunit.placeholder'">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
||||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
|
||||||
<ds-truncatable [id]="dso.id">
|
[alt]="'thumbnail.orgunit.alt'"
|
||||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
[placeholder]="'thumbnail.orgunit.placeholder'">
|
||||||
rel="noopener noreferrer"
|
</ds-thumbnail>
|
||||||
[routerLink]="[itemPageRoute]" class="lead"
|
</span>
|
||||||
[innerHTML]="dsoTitle"></a>
|
</div>
|
||||||
<span *ngIf="linkType == linkTypes.None"
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
class="lead"
|
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||||
[innerHTML]="dsoTitle"></span>
|
<ds-truncatable [id]="dso.id">
|
||||||
<span class="text-muted">
|
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
[routerLink]="[itemPageRoute]" class="lead"
|
||||||
|
[innerHTML]="dsoTitle || ('orgunit.listelement.no-title' | translate)"></a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None"
|
||||||
|
class="lead"
|
||||||
|
[innerHTML]="dsoTitle || ('orgunit.listelement.no-title' | translate)"></span>
|
||||||
|
<span class="text-muted">
|
||||||
<span *ngIf="dso.allMetadata(['dc.description']).length > 0"
|
<span *ngIf="dso.allMetadata(['dc.description']).length > 0"
|
||||||
class="item-list-org-unit-description">
|
class="item-list-org-unit-description">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3"><span
|
<ds-truncatable-part [id]="dso.id" [minLines]="3"><span
|
||||||
[innerHTML]="firstMetadataValue('dc.description')"></span>
|
[innerHTML]="firstMetadataValue('dc.description')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</ds-truncatable>
|
</ds-truncatable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -10,6 +10,8 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared
|
|||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
|
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
|
||||||
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock';
|
||||||
|
|
||||||
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
|
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
|
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
|
||||||
@@ -66,6 +68,13 @@ const enviromentNoThumbs = {
|
|||||||
describe('OrgUnitSearchResultListElementComponent', () => {
|
describe('OrgUnitSearchResultListElementComponent', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)],
|
||||||
declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe],
|
declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
@@ -129,6 +138,13 @@ describe('OrgUnitSearchResultListElementComponent', () => {
|
|||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)],
|
||||||
declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe],
|
declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: TruncatableService, useValue: {}},
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
@@ -9,6 +9,13 @@
|
|||||||
[placeholder]="'thumbnail.person.placeholder'">
|
[placeholder]="'thumbnail.person.placeholder'">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
||||||
|
[defaultImage]="'assets/images/person-placeholder.svg'"
|
||||||
|
[alt]="'thumbnail.person.alt'"
|
||||||
|
[placeholder]="'thumbnail.person.placeholder'">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9 col-md-10' : 'col-12'">
|
<div [ngClass]="showThumbnails ? 'col-9 col-md-10' : 'col-12'">
|
||||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||||
@@ -16,10 +23,10 @@
|
|||||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
[routerLink]="[itemPageRoute]" class="lead"
|
[routerLink]="[itemPageRoute]" class="lead"
|
||||||
[innerHTML]="dsoTitle"></a>
|
[innerHTML]="dsoTitle || ('person.listelement.no-title' | translate)"></a>
|
||||||
<span *ngIf="linkType == linkTypes.None"
|
<span *ngIf="linkType == linkTypes.None"
|
||||||
class="lead"
|
class="lead"
|
||||||
[innerHTML]="dsoTitle"></span>
|
[innerHTML]="dsoTitle || ('person.listelement.no-title' | translate)"></span>
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"
|
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"
|
||||||
|
@@ -10,6 +10,8 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl
|
|||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
|
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
|
||||||
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock';
|
||||||
|
|
||||||
let personListElementComponent: PersonSearchResultListElementComponent;
|
let personListElementComponent: PersonSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
|
let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
|
||||||
@@ -66,6 +68,13 @@ const enviromentNoThumbs = {
|
|||||||
describe('PersonSearchResultListElementComponent', () => {
|
describe('PersonSearchResultListElementComponent', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)],
|
||||||
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
@@ -129,6 +138,13 @@ describe('PersonSearchResultListElementComponent', () => {
|
|||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)],
|
||||||
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: TruncatableService, useValue: {}},
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
@@ -9,6 +9,13 @@
|
|||||||
[placeholder]="'thumbnail.project.placeholder'">
|
[placeholder]="'thumbnail.project.placeholder'">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
||||||
|
[defaultImage]="'assets/images/project-placeholder.svg'"
|
||||||
|
[alt]="'thumbnail.project.alt'"
|
||||||
|
[placeholder]="'thumbnail.project.placeholder'">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
<ds-truncatable [id]="dso.id">
|
<ds-truncatable [id]="dso.id">
|
||||||
|
@@ -8,6 +8,13 @@
|
|||||||
[placeholder]="'thumbnail.person.placeholder'">
|
[placeholder]="'thumbnail.person.placeholder'">
|
||||||
</ds-thumbnail>
|
</ds-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
|
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
|
||||||
|
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
|
||||||
|
[defaultImage]="'assets/images/person-placeholder.svg'"
|
||||||
|
[alt]="'thumbnail.person.alt'"
|
||||||
|
[placeholder]="'thumbnail.person.placeholder'">
|
||||||
|
</ds-thumbnail>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0">
|
<nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0">
|
||||||
<ds-search-navbar></ds-search-navbar>
|
<ds-themed-search-navbar></ds-themed-search-navbar>
|
||||||
<ds-lang-switch></ds-lang-switch>
|
<ds-lang-switch></ds-lang-switch>
|
||||||
<ds-themed-auth-nav-menu></ds-themed-auth-nav-menu>
|
<ds-themed-auth-nav-menu></ds-themed-auth-nav-menu>
|
||||||
<ds-impersonate-navbar></ds-impersonate-navbar>
|
<ds-impersonate-navbar></ds-impersonate-navbar>
|
||||||
|
@@ -10,6 +10,9 @@ import { StatisticsModule } from '../statistics/statistics.module';
|
|||||||
import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component';
|
import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component';
|
||||||
import { ThemedHomePageComponent } from './themed-home-page.component';
|
import { ThemedHomePageComponent } from './themed-home-page.component';
|
||||||
import { RecentItemListComponent } from './recent-item-list/recent-item-list.component';
|
import { RecentItemListComponent } from './recent-item-list/recent-item-list.component';
|
||||||
|
import { JournalEntitiesModule } from '../entity-groups/journal-entities/journal-entities.module';
|
||||||
|
import { ResearchEntitiesModule } from '../entity-groups/research-entities/research-entities.module';
|
||||||
|
|
||||||
const DECLARATIONS = [
|
const DECLARATIONS = [
|
||||||
HomePageComponent,
|
HomePageComponent,
|
||||||
ThemedHomePageComponent,
|
ThemedHomePageComponent,
|
||||||
@@ -22,7 +25,9 @@ const DECLARATIONS = [
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
SharedModule,
|
SharedModule.withEntryComponents(),
|
||||||
|
JournalEntitiesModule.withEntryComponents(),
|
||||||
|
ResearchEntitiesModule.withEntryComponents(),
|
||||||
HomePageRoutingModule,
|
HomePageRoutingModule,
|
||||||
StatisticsModule.forRoot()
|
StatisticsModule.forRoot()
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<ng-container *ngVar="(itemRD$ | async) as itemRD">
|
<ng-container *ngVar="(itemRD$ | async) as itemRD">
|
||||||
<div class="mt-4" *ngIf="itemRD?.hasSucceeded && itemRD?.payload?.page.length > 0" @fadeIn>
|
<div class="mt-4" [ngClass]="placeholderFontClass" *ngIf="itemRD?.hasSucceeded && itemRD?.payload?.page.length > 0" @fadeIn>
|
||||||
<div class="d-flex flex-row border-bottom mb-4 pb-4 ng-tns-c416-2"></div>
|
<div class="d-flex flex-row border-bottom mb-4 pb-4 ng-tns-c416-2"></div>
|
||||||
<h2> {{'home.recent-submissions.head' | translate}}</h2>
|
<h2> {{'home.recent-submissions.head' | translate}}</h2>
|
||||||
<div class="my-4" *ngFor="let item of itemRD?.payload?.page">
|
<div class="my-4" *ngFor="let item of itemRD?.payload?.page">
|
||||||
@@ -12,4 +12,4 @@
|
|||||||
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.recent-submissions' | translate}}"></ds-error>
|
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.recent-submissions' | translate}}"></ds-error>
|
||||||
<ds-loading *ngIf="!itemRD || itemRD.isLoading" message="{{'loading.recent-submissions' | translate}}">
|
<ds-loading *ngIf="!itemRD || itemRD.isLoading" message="{{'loading.recent-submissions' | translate}}">
|
||||||
</ds-loading>
|
</ds-loading>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -10,8 +10,11 @@ import { SearchConfigurationService } from '../../core/shared/search/search-conf
|
|||||||
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||||
import { ViewMode } from 'src/app/core/shared/view-mode.model';
|
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { APP_CONFIG } from '../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../environments/environment';
|
||||||
|
import { PLATFORM_ID } from '@angular/core';
|
||||||
|
|
||||||
describe('RecentItemListComponent', () => {
|
describe('RecentItemListComponent', () => {
|
||||||
let component: RecentItemListComponent;
|
let component: RecentItemListComponent;
|
||||||
let fixture: ComponentFixture<RecentItemListComponent>;
|
let fixture: ComponentFixture<RecentItemListComponent>;
|
||||||
@@ -42,6 +45,8 @@ describe('RecentItemListComponent', () => {
|
|||||||
{ provide: SearchService, useValue: searchServiceStub },
|
{ provide: SearchService, useValue: searchServiceStub },
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
{ provide: PLATFORM_ID, useValue: 'browser' },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, ElementRef, Inject, OnInit, PLATFORM_ID } from '@angular/core';
|
||||||
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
||||||
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
|
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
@@ -11,12 +11,13 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
|
|||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||||
import {
|
import { toDSpaceObjectListRD } from '../../core/shared/operators';
|
||||||
toDSpaceObjectListRD
|
import { Observable } from 'rxjs';
|
||||||
} from '../../core/shared/operators';
|
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
import {
|
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
|
||||||
Observable,
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
} from 'rxjs';
|
import { setPlaceHolderAttributes } from '../../shared/utils/object-list-utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-recent-item-list',
|
selector: 'ds-recent-item-list',
|
||||||
templateUrl: './recent-item-list.component.html',
|
templateUrl: './recent-item-list.component.html',
|
||||||
@@ -31,14 +32,22 @@ export class RecentItemListComponent implements OnInit {
|
|||||||
itemRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
itemRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
||||||
paginationConfig: PaginationComponentOptions;
|
paginationConfig: PaginationComponentOptions;
|
||||||
sortConfig: SortOptions;
|
sortConfig: SortOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The view-mode we're currently on
|
* The view-mode we're currently on
|
||||||
* @type {ViewMode}
|
* @type {ViewMode}
|
||||||
*/
|
*/
|
||||||
viewMode = ViewMode.ListElement;
|
viewMode = ViewMode.ListElement;
|
||||||
constructor(private searchService: SearchService,
|
|
||||||
|
private _placeholderFontClass: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private searchService: SearchService,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
public searchConfigurationService: SearchConfigurationService
|
public searchConfigurationService: SearchConfigurationService,
|
||||||
|
protected elementRef: ElementRef,
|
||||||
|
@Inject(APP_CONFIG) private appConfig: AppConfig,
|
||||||
|
@Inject(PLATFORM_ID) private platformId: Object,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
|
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
|
||||||
@@ -50,16 +59,29 @@ export class RecentItemListComponent implements OnInit {
|
|||||||
this.sortConfig = new SortOptions(environment.homePage.recentSubmissions.sortField, SortDirection.DESC);
|
this.sortConfig = new SortOptions(environment.homePage.recentSubmissions.sortField, SortDirection.DESC);
|
||||||
}
|
}
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
const linksToFollow: FollowLinkConfig<Item>[] = [];
|
||||||
|
if (this.appConfig.browseBy.showThumbnails) {
|
||||||
|
linksToFollow.push(followLink('thumbnail'));
|
||||||
|
}
|
||||||
|
|
||||||
this.itemRD$ = this.searchService.search(
|
this.itemRD$ = this.searchService.search(
|
||||||
new PaginatedSearchOptions({
|
new PaginatedSearchOptions({
|
||||||
pagination: this.paginationConfig,
|
pagination: this.paginationConfig,
|
||||||
sort: this.sortConfig,
|
sort: this.sortConfig,
|
||||||
}),
|
}),
|
||||||
).pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
...linksToFollow,
|
||||||
|
).pipe(
|
||||||
|
toDSpaceObjectListRD()
|
||||||
|
) as Observable<RemoteData<PaginatedList<Item>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.paginationService.clearPagination(this.paginationConfig.id);
|
this.paginationService.clearPagination(this.paginationConfig.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadMore(): void {
|
onLoadMore(): void {
|
||||||
this.paginationService.updateRouteWithUrl(this.searchConfigurationService.paginationID, ['search'], {
|
this.paginationService.updateRouteWithUrl(this.searchConfigurationService.paginationID, ['search'], {
|
||||||
sortField: environment.homePage.recentSubmissions.sortField,
|
sortField: environment.homePage.recentSubmissions.sortField,
|
||||||
@@ -68,5 +90,17 @@ export class RecentItemListComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get placeholderFontClass(): string {
|
||||||
|
if (this._placeholderFontClass === undefined) {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
const width = this.elementRef.nativeElement.offsetWidth;
|
||||||
|
this._placeholderFontClass = setPlaceHolderAttributes(width);
|
||||||
|
} else {
|
||||||
|
this._placeholderFontClass = 'hide-placeholder-text';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this._placeholderFontClass;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -175,14 +175,18 @@ describe('TopLevelCommunityList Component', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a list of top-communities', () => {
|
|
||||||
const subComList = fixture.debugElement.queryAll(By.css('li'));
|
|
||||||
|
|
||||||
expect(subComList.length).toEqual(5);
|
it('should display a list of top-communities', () => {
|
||||||
expect(subComList[0].nativeElement.textContent).toContain('TopCommunity 1');
|
waitForAsync(() => {
|
||||||
expect(subComList[1].nativeElement.textContent).toContain('TopCommunity 2');
|
const subComList = fixture.debugElement.queryAll(By.css('li'));
|
||||||
expect(subComList[2].nativeElement.textContent).toContain('TopCommunity 3');
|
|
||||||
expect(subComList[3].nativeElement.textContent).toContain('TopCommunity 4');
|
expect(subComList.length).toEqual(5);
|
||||||
expect(subComList[4].nativeElement.textContent).toContain('TopCommunity 5');
|
expect(subComList[0].nativeElement.textContent).toContain('TopCommunity 1');
|
||||||
|
expect(subComList[1].nativeElement.textContent).toContain('TopCommunity 2');
|
||||||
|
expect(subComList[2].nativeElement.textContent).toContain('TopCommunity 3');
|
||||||
|
expect(subComList[3].nativeElement.textContent).toContain('TopCommunity 4');
|
||||||
|
expect(subComList[4].nativeElement.textContent).toContain('TopCommunity 5');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
<td class="w-100">
|
<td class="w-100">
|
||||||
<div class="value-field">
|
<div class="value-field">
|
||||||
<div *ngIf="!(editable | async)">
|
<div *ngIf="!(editable | async)">
|
||||||
<span class="dont-break-out">{{metadata?.value}}</span>
|
<span class="dont-break-out preserve-line-breaks">{{metadata?.value}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="(editable | async)" class="field-container">
|
<div *ngIf="(editable | async)" class="field-container">
|
||||||
<textarea class="form-control" type="textarea" attr.aria-labelledby="fieldValue" [(ngModel)]="metadata.value" [dsDebounce]
|
<textarea class="form-control" type="textarea" attr.aria-labelledby="fieldValue" [(ngModel)]="metadata.value" [dsDebounce]
|
||||||
|
@@ -6,6 +6,8 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { MetadataUriValuesComponent } from './metadata-uri-values.component';
|
import { MetadataUriValuesComponent } from './metadata-uri-values.component';
|
||||||
import { isNotEmpty } from '../../../shared/empty.util';
|
import { isNotEmpty } from '../../../shared/empty.util';
|
||||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||||
|
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../environments/environment';
|
||||||
|
|
||||||
let comp: MetadataUriValuesComponent;
|
let comp: MetadataUriValuesComponent;
|
||||||
let fixture: ComponentFixture<MetadataUriValuesComponent>;
|
let fixture: ComponentFixture<MetadataUriValuesComponent>;
|
||||||
@@ -33,6 +35,9 @@ describe('MetadataUriValuesComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [MetadataUriValuesComponent],
|
declarations: [MetadataUriValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(MetadataUriValuesComponent, {
|
}).overrideComponent(MetadataUriValuesComponent, {
|
||||||
|
@@ -1,5 +1,18 @@
|
|||||||
<ds-metadata-field-wrapper [label]="label | translate">
|
<ds-metadata-field-wrapper [label]="label | translate">
|
||||||
<span class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;">
|
<ng-container *ngFor="let mdValue of mdValues; let last=last;">
|
||||||
{{mdValue.value}}<span *ngIf="!last" [innerHTML]="separator"></span>
|
<ng-container *ngTemplateOutlet="(renderMarkdown ? markdown : simple); context: {value: mdValue.value, classes: 'dont-break-out preserve-line-breaks'}">
|
||||||
</span>
|
</ng-container>
|
||||||
|
<span class="separator" *ngIf="!last" [innerHTML]="separator"></span>
|
||||||
|
</ng-container>
|
||||||
</ds-metadata-field-wrapper>
|
</ds-metadata-field-wrapper>
|
||||||
|
|
||||||
|
<ng-template #markdown let-value="value" let-classes="classes">
|
||||||
|
<span class="{{classes}}" [innerHTML]="value | dsMarkdown | async">
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template #simple let-value="value" let-classes="classes">
|
||||||
|
<span class="{{classes}}">
|
||||||
|
{{value}}
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
@@ -5,6 +5,8 @@ import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock
|
|||||||
import { MetadataValuesComponent } from './metadata-values.component';
|
import { MetadataValuesComponent } from './metadata-values.component';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||||
|
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../environments/environment';
|
||||||
|
|
||||||
let comp: MetadataValuesComponent;
|
let comp: MetadataValuesComponent;
|
||||||
let fixture: ComponentFixture<MetadataValuesComponent>;
|
let fixture: ComponentFixture<MetadataValuesComponent>;
|
||||||
@@ -32,8 +34,11 @@ describe('MetadataValuesComponent', () => {
|
|||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
},
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [MetadataValuesComponent],
|
declarations: [MetadataValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(MetadataValuesComponent, {
|
}).overrideComponent(MetadataValuesComponent, {
|
||||||
@@ -58,7 +63,7 @@ describe('MetadataValuesComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should contain separators equal to the amount of metadata values minus one', () => {
|
it('should contain separators equal to the amount of metadata values minus one', () => {
|
||||||
const separators = fixture.debugElement.queryAll(By.css('span>span'));
|
const separators = fixture.debugElement.queryAll(By.css('span.separator'));
|
||||||
expect(separators.length).toBe(mockMetadata.length - 1);
|
expect(separators.length).toBe(mockMetadata.length - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Inject, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||||
|
import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
|
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
|
||||||
@@ -10,7 +11,12 @@ import { MetadataValue } from '../../../core/shared/metadata.models';
|
|||||||
styleUrls: ['./metadata-values.component.scss'],
|
styleUrls: ['./metadata-values.component.scss'],
|
||||||
templateUrl: './metadata-values.component.html'
|
templateUrl: './metadata-values.component.html'
|
||||||
})
|
})
|
||||||
export class MetadataValuesComponent {
|
export class MetadataValuesComponent implements OnChanges {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(APP_CONFIG) private appConfig: AppConfig,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The metadata values to display
|
* The metadata values to display
|
||||||
@@ -27,4 +33,19 @@ export class MetadataValuesComponent {
|
|||||||
*/
|
*/
|
||||||
@Input() label: string;
|
@Input() label: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the {@link MarkdownPipe} should be used to render these metadata values.
|
||||||
|
* This will only have effect if {@link MarkdownConfig#enabled} is true.
|
||||||
|
* Mathjax will only be rendered if {@link MarkdownConfig#mathjax} is true.
|
||||||
|
*/
|
||||||
|
@Input() enableMarkdown = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This variable will be true if both {@link environment.markdown.enabled} and {@link enableMarkdown} are true.
|
||||||
|
*/
|
||||||
|
renderMarkdown;
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
this.renderMarkdown = !!this.appConfig.markdown.enabled && this.enableMarkdown;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import { createPaginatedList } from '../../shared/testing/utils.test';
|
|||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { MiradorViewerService } from './mirador-viewer.service';
|
import { MiradorViewerService } from './mirador-viewer.service';
|
||||||
import { HostWindowService } from '../../shared/host-window.service';
|
import { HostWindowService } from '../../shared/host-window.service';
|
||||||
|
import { BundleDataService } from '../../core/data/bundle-data.service';
|
||||||
|
|
||||||
|
|
||||||
function getItem(metadata: MetadataMap) {
|
function getItem(metadata: MetadataMap) {
|
||||||
@@ -46,6 +47,7 @@ describe('MiradorViewerComponent with search', () => {
|
|||||||
declarations: [MiradorViewerComponent],
|
declarations: [MiradorViewerComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
{ provide: BitstreamDataService, useValue: {} },
|
||||||
|
{ provide: BundleDataService, useValue: {} },
|
||||||
{ provide: HostWindowService, useValue: mockHostWindowService }
|
{ provide: HostWindowService, useValue: mockHostWindowService }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -108,6 +110,7 @@ describe('MiradorViewerComponent with multiple images', () => {
|
|||||||
declarations: [MiradorViewerComponent],
|
declarations: [MiradorViewerComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
{ provide: BitstreamDataService, useValue: {} },
|
||||||
|
{ provide: BundleDataService, useValue: {} },
|
||||||
{ provide: HostWindowService, useValue: mockHostWindowService }
|
{ provide: HostWindowService, useValue: mockHostWindowService }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -167,6 +170,7 @@ describe('MiradorViewerComponent with a single image', () => {
|
|||||||
declarations: [MiradorViewerComponent],
|
declarations: [MiradorViewerComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
{ provide: BitstreamDataService, useValue: {} },
|
||||||
|
{ provide: BundleDataService, useValue: {} },
|
||||||
{ provide: HostWindowService, useValue: mockHostWindowService }
|
{ provide: HostWindowService, useValue: mockHostWindowService }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -225,6 +229,7 @@ describe('MiradorViewerComponent in development mode', () => {
|
|||||||
set: {
|
set: {
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MiradorViewerService, useValue: viewerService },
|
{ provide: MiradorViewerService, useValue: viewerService },
|
||||||
|
{ provide: BundleDataService, useValue: {} },
|
||||||
{ provide: HostWindowService, useValue: mockHostWindowService }
|
{ provide: HostWindowService, useValue: mockHostWindowService }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import { map, take } from 'rxjs/operators';
|
|||||||
import { isPlatformBrowser } from '@angular/common';
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
import { MiradorViewerService } from './mirador-viewer.service';
|
import { MiradorViewerService } from './mirador-viewer.service';
|
||||||
import { HostWindowService, WidthCategory } from '../../shared/host-window.service';
|
import { HostWindowService, WidthCategory } from '../../shared/host-window.service';
|
||||||
|
import { BundleDataService } from '../../core/data/bundle-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-mirador-viewer',
|
selector: 'ds-mirador-viewer',
|
||||||
@@ -55,6 +56,7 @@ export class MiradorViewerComponent implements OnInit {
|
|||||||
constructor(private sanitizer: DomSanitizer,
|
constructor(private sanitizer: DomSanitizer,
|
||||||
private viewerService: MiradorViewerService,
|
private viewerService: MiradorViewerService,
|
||||||
private bitstreamDataService: BitstreamDataService,
|
private bitstreamDataService: BitstreamDataService,
|
||||||
|
private bundleDataService: BundleDataService,
|
||||||
private hostWindowService: HostWindowService,
|
private hostWindowService: HostWindowService,
|
||||||
@Inject(PLATFORM_ID) private platformId: any) {
|
@Inject(PLATFORM_ID) private platformId: any) {
|
||||||
}
|
}
|
||||||
@@ -107,10 +109,10 @@ export class MiradorViewerComponent implements OnInit {
|
|||||||
this.notMobile = !(category === WidthCategory.XS || category === WidthCategory.SM);
|
this.notMobile = !(category === WidthCategory.XS || category === WidthCategory.SM);
|
||||||
});
|
});
|
||||||
|
|
||||||
// We need to set the multi property to true if the
|
// Set the multi property. The default mirador configuration adds a right
|
||||||
// item is searchable or when the ORIGINAL bundle contains more
|
// thumbnail navigation panel to the viewer when multi is 'true'.
|
||||||
// than 1 image. (The multi property determines whether the
|
|
||||||
// Mirador side thumbnail navigation panel is shown.)
|
// Set the multi property to 'true' if the item is searchable.
|
||||||
if (this.searchable) {
|
if (this.searchable) {
|
||||||
this.multi = true;
|
this.multi = true;
|
||||||
const observable = of('');
|
const observable = of('');
|
||||||
@@ -120,8 +122,12 @@ export class MiradorViewerComponent implements OnInit {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Sets the multi value based on the image count.
|
// Set the multi property based on the image count in IIIF-eligible bundles.
|
||||||
this.iframeViewerUrl = this.viewerService.getImageCount(this.object, this.bitstreamDataService).pipe(
|
// Any count greater than 1 sets the value to 'true'.
|
||||||
|
this.iframeViewerUrl = this.viewerService.getImageCount(
|
||||||
|
this.object,
|
||||||
|
this.bitstreamDataService,
|
||||||
|
this.bundleDataService).pipe(
|
||||||
map(c => {
|
map(c => {
|
||||||
if (c > 1) {
|
if (c > 1) {
|
||||||
this.multi = true;
|
this.multi = true;
|
||||||
|
@@ -1,14 +1,18 @@
|
|||||||
import { Injectable, isDevMode } from '@angular/core';
|
import { Injectable, isDevMode } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
import {
|
||||||
import { last, map, switchMap } from 'rxjs/operators';
|
getFirstCompletedRemoteData,
|
||||||
|
} from '../../core/shared/operators';
|
||||||
|
import { filter, last, map, mergeMap, switchMap } from 'rxjs/operators';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||||
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
|
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
|
||||||
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
|
||||||
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { Bundle } from '../../core/shared/bundle.model';
|
||||||
|
import { BundleDataService } from '../../core/data/bundle-data.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MiradorViewerService {
|
export class MiradorViewerService {
|
||||||
@@ -26,32 +30,64 @@ export class MiradorViewerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns observable of the number of images in the ORIGINAL bundle
|
* Returns observable of the number of images found in eligible IIIF bundles. Checks
|
||||||
|
* the mimetype of the first 5 bitstreams in each bundle.
|
||||||
* @param item
|
* @param item
|
||||||
* @param bitstreamDataService
|
* @param bitstreamDataService
|
||||||
|
* @param bundleDataService
|
||||||
|
* @returns the total image count
|
||||||
*/
|
*/
|
||||||
getImageCount(item: Item, bitstreamDataService: BitstreamDataService): Observable<number> {
|
getImageCount(item: Item, bitstreamDataService: BitstreamDataService, bundleDataService: BundleDataService):
|
||||||
let count = 0;
|
Observable<number> {
|
||||||
return bitstreamDataService.findAllByItemAndBundleName(item, 'ORIGINAL', {
|
let count = 0;
|
||||||
currentPage: 1,
|
return bundleDataService.findAllByItem(item).pipe(
|
||||||
elementsPerPage: 10
|
getFirstCompletedRemoteData(),
|
||||||
}, true, true, ...this.LINKS_TO_FOLLOW)
|
map((bundlesRD: RemoteData<PaginatedList<Bundle>>) => {
|
||||||
.pipe(
|
return bundlesRD.payload;
|
||||||
getFirstCompletedRemoteData(),
|
}),
|
||||||
map((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => bitstreamsRD.payload),
|
map((paginatedList: PaginatedList<Bundle>) => paginatedList.page),
|
||||||
map((paginatedList: PaginatedList<Bitstream>) => paginatedList.page),
|
switchMap((bundles: Bundle[]) => bundles),
|
||||||
switchMap((bitstreams: Bitstream[]) => bitstreams),
|
filter((b: Bundle) => this.isIiifBundle(b.name)),
|
||||||
switchMap((bitstream: Bitstream) => bitstream.format.pipe(
|
mergeMap((bundle: Bundle) => {
|
||||||
getFirstSucceededRemoteDataPayload(),
|
return bitstreamDataService.findAllByItemAndBundleName(item, bundle.name, {
|
||||||
map((format: BitstreamFormat) => format)
|
currentPage: 1,
|
||||||
)),
|
elementsPerPage: 5
|
||||||
map((format: BitstreamFormat) => {
|
}, true, true, ...this.LINKS_TO_FOLLOW).pipe(
|
||||||
if (format.mimetype.includes('image')) {
|
getFirstCompletedRemoteData(),
|
||||||
count++;
|
map((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {
|
||||||
}
|
return bitstreamsRD.payload;
|
||||||
return count;
|
}),
|
||||||
}),
|
map((paginatedList: PaginatedList<Bitstream>) => paginatedList.page),
|
||||||
last()
|
switchMap((bitstreams: Bitstream[]) => bitstreams),
|
||||||
|
switchMap((bitstream: Bitstream) => bitstream.format.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((formatRD: RemoteData<BitstreamFormat>) => {
|
||||||
|
return formatRD.payload;
|
||||||
|
}),
|
||||||
|
map((format: BitstreamFormat) => {
|
||||||
|
if (format.mimetype.includes('image')) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
last()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isIiifBundle(bundleName: string): boolean {
|
||||||
|
return !(
|
||||||
|
bundleName === 'OtherContent' ||
|
||||||
|
bundleName === 'LICENSE' ||
|
||||||
|
bundleName === 'THUMBNAIL' ||
|
||||||
|
bundleName === 'TEXT' ||
|
||||||
|
bundleName === 'METADATA' ||
|
||||||
|
bundleName === 'CC-LICENSE' ||
|
||||||
|
bundleName === 'BRANDED_PREVIEW'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,25 +3,30 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
|||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { ItemPageAbstractFieldComponent } from './item-page-abstract-field.component';
|
import { ItemPageAbstractFieldComponent } from './item-page-abstract-field.component';
|
||||||
import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loader.mock';
|
||||||
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
import { SharedModule } from '../../../../../shared/shared.module';
|
||||||
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
let comp: ItemPageAbstractFieldComponent;
|
let comp: ItemPageAbstractFieldComponent;
|
||||||
let fixture: ComponentFixture<ItemPageAbstractFieldComponent>;
|
let fixture: ComponentFixture<ItemPageAbstractFieldComponent>;
|
||||||
|
|
||||||
const mockField = 'dc.description.abstract';
|
|
||||||
const mockValue = 'test value';
|
|
||||||
|
|
||||||
describe('ItemPageAbstractFieldComponent', () => {
|
describe('ItemPageAbstractFieldComponent', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot({
|
imports: [
|
||||||
loader: {
|
TranslateModule.forRoot({
|
||||||
provide: TranslateLoader,
|
loader: {
|
||||||
useClass: TranslateLoaderMock
|
provide: TranslateLoader,
|
||||||
}
|
useClass: TranslateLoaderMock
|
||||||
})],
|
}
|
||||||
declarations: [ItemPageAbstractFieldComponent, MetadataValuesComponent],
|
}),
|
||||||
|
SharedModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
|
declarations: [ItemPageAbstractFieldComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemPageAbstractFieldComponent, {
|
}).overrideComponent(ItemPageAbstractFieldComponent, {
|
||||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
@@ -29,13 +34,13 @@ describe('ItemPageAbstractFieldComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ItemPageAbstractFieldComponent);
|
fixture = TestBed.createComponent(ItemPageAbstractFieldComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display display the correct metadata value', () => {
|
it('should render a ds-metadata-values', () => {
|
||||||
expect(fixture.nativeElement.innerHTML).toContain(mockValue);
|
expect(fixture.debugElement.query(By.css('ds-metadata-values'))).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -36,4 +36,8 @@ export class ItemPageAbstractFieldComponent extends ItemPageFieldComponent {
|
|||||||
*/
|
*/
|
||||||
label = 'item.page.abstract';
|
label = 'item.page.abstract';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the {@link MarkdownPipe} to render dc.description.abstract values
|
||||||
|
*/
|
||||||
|
enableMarkdown = true;
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loa
|
|||||||
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
||||||
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
||||||
import { ItemPageAuthorFieldComponent } from './item-page-author-field.component';
|
import { ItemPageAuthorFieldComponent } from './item-page-author-field.component';
|
||||||
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
|
||||||
let comp: ItemPageAuthorFieldComponent;
|
let comp: ItemPageAuthorFieldComponent;
|
||||||
let fixture: ComponentFixture<ItemPageAuthorFieldComponent>;
|
let fixture: ComponentFixture<ItemPageAuthorFieldComponent>;
|
||||||
@@ -21,6 +23,9 @@ describe('ItemPageAuthorFieldComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [ItemPageAuthorFieldComponent, MetadataValuesComponent],
|
declarations: [ItemPageAuthorFieldComponent, MetadataValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemPageAuthorFieldComponent, {
|
}).overrideComponent(ItemPageAuthorFieldComponent, {
|
||||||
|
@@ -5,6 +5,8 @@ import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loa
|
|||||||
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
||||||
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
||||||
import { ItemPageDateFieldComponent } from './item-page-date-field.component';
|
import { ItemPageDateFieldComponent } from './item-page-date-field.component';
|
||||||
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
|
||||||
let comp: ItemPageDateFieldComponent;
|
let comp: ItemPageDateFieldComponent;
|
||||||
let fixture: ComponentFixture<ItemPageDateFieldComponent>;
|
let fixture: ComponentFixture<ItemPageDateFieldComponent>;
|
||||||
@@ -21,6 +23,9 @@ describe('ItemPageDateFieldComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [ItemPageDateFieldComponent, MetadataValuesComponent],
|
declarations: [ItemPageDateFieldComponent, MetadataValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemPageDateFieldComponent, {
|
}).overrideComponent(ItemPageDateFieldComponent, {
|
||||||
|
@@ -5,6 +5,8 @@ import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loa
|
|||||||
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
|
||||||
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
||||||
import { GenericItemPageFieldComponent } from './generic-item-page-field.component';
|
import { GenericItemPageFieldComponent } from './generic-item-page-field.component';
|
||||||
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
|
||||||
let comp: GenericItemPageFieldComponent;
|
let comp: GenericItemPageFieldComponent;
|
||||||
let fixture: ComponentFixture<GenericItemPageFieldComponent>;
|
let fixture: ComponentFixture<GenericItemPageFieldComponent>;
|
||||||
@@ -23,6 +25,9 @@ describe('GenericItemPageFieldComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [GenericItemPageFieldComponent, MetadataValuesComponent],
|
declarations: [GenericItemPageFieldComponent, MetadataValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(GenericItemPageFieldComponent, {
|
}).overrideComponent(GenericItemPageFieldComponent, {
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
<div class="item-page-field">
|
<div class="item-page-field">
|
||||||
<ds-metadata-values [mdValues]="item?.allMetadata(fields)" [separator]="separator" [label]="label"></ds-metadata-values>
|
<ds-metadata-values
|
||||||
|
[mdValues]="item?.allMetadata(fields)"
|
||||||
|
[separator]="separator"
|
||||||
|
[label]="label"
|
||||||
|
[enableMarkdown]="enableMarkdown"
|
||||||
|
></ds-metadata-values>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -8,9 +8,14 @@ import { MetadataValuesComponent } from '../../../field-components/metadata-valu
|
|||||||
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||||
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||||
|
import { environment } from '../../../../../environments/environment';
|
||||||
|
import { MarkdownPipe } from '../../../../shared/utils/markdown.pipe';
|
||||||
|
import { SharedModule } from '../../../../shared/shared.module';
|
||||||
|
import { APP_CONFIG } from '../../../../../config/app-config.interface';
|
||||||
|
|
||||||
let comp: ItemPageFieldComponent;
|
let comp: ItemPageFieldComponent;
|
||||||
let fixture: ComponentFixture<ItemPageFieldComponent>;
|
let fixture: ComponentFixture<ItemPageFieldComponent>;
|
||||||
|
let markdownSpy;
|
||||||
|
|
||||||
const mockValue = 'test value';
|
const mockValue = 'test value';
|
||||||
const mockField = 'dc.test';
|
const mockField = 'dc.test';
|
||||||
@@ -18,32 +23,109 @@ const mockLabel = 'test label';
|
|||||||
const mockFields = [mockField];
|
const mockFields = [mockField];
|
||||||
|
|
||||||
describe('ItemPageFieldComponent', () => {
|
describe('ItemPageFieldComponent', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
TestBed.configureTestingModule({
|
let appConfig = Object.assign({}, environment, {
|
||||||
imports: [TranslateModule.forRoot({
|
markdown: {
|
||||||
loader: {
|
enabled: false,
|
||||||
provide: TranslateLoader,
|
mathjax: false,
|
||||||
useClass: TranslateLoaderMock
|
}
|
||||||
}
|
});
|
||||||
})],
|
|
||||||
|
const buildTestEnvironment = async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
SharedModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: appConfig },
|
||||||
|
],
|
||||||
declarations: [ItemPageFieldComponent, MetadataValuesComponent],
|
declarations: [ItemPageFieldComponent, MetadataValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemPageFieldComponent, {
|
}).overrideComponent(ItemPageFieldComponent, {
|
||||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
markdownSpy = spyOn(MarkdownPipe.prototype, 'transform');
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
fixture = TestBed.createComponent(ItemPageFieldComponent);
|
fixture = TestBed.createComponent(ItemPageFieldComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||||
comp.fields = mockFields;
|
comp.fields = mockFields;
|
||||||
comp.label = mockLabel;
|
comp.label = mockLabel;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should display display the correct metadata value', waitForAsync(async () => {
|
||||||
|
await buildTestEnvironment();
|
||||||
|
expect(fixture.nativeElement.innerHTML).toContain(mockValue);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display display the correct metadata value', () => {
|
describe('when markdown is disabled in the environment config', () => {
|
||||||
expect(fixture.nativeElement.innerHTML).toContain(mockValue);
|
|
||||||
|
beforeEach(waitForAsync(async () => {
|
||||||
|
appConfig.markdown.enabled = false;
|
||||||
|
await buildTestEnvironment();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('and markdown is disabled in this component', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.enableMarkdown = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not use the Markdown Pipe', () => {
|
||||||
|
expect(markdownSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('and markdown is enabled in this component', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.enableMarkdown = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not use the Markdown Pipe', () => {
|
||||||
|
expect(markdownSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when markdown is enabled in the environment config', () => {
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(async () => {
|
||||||
|
appConfig.markdown.enabled = true;
|
||||||
|
await buildTestEnvironment();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('and markdown is disabled in this component', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.enableMarkdown = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not use the Markdown Pipe', () => {
|
||||||
|
expect(markdownSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('and markdown is enabled in this component', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.enableMarkdown = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should use the Markdown Pipe', () => {
|
||||||
|
expect(markdownSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
|
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +17,11 @@ export class ItemPageFieldComponent {
|
|||||||
*/
|
*/
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the {@link MarkdownPipe} should be used to render this metadata.
|
||||||
|
*/
|
||||||
|
enableMarkdown = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields (schema.element.qualifier) used to render their values.
|
* Fields (schema.element.qualifier) used to render their values.
|
||||||
*/
|
*/
|
||||||
|
@@ -5,6 +5,8 @@ import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loa
|
|||||||
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
import { mockItemWithMetadataFieldAndValue } from '../item-page-field.component.spec';
|
||||||
import { ItemPageUriFieldComponent } from './item-page-uri-field.component';
|
import { ItemPageUriFieldComponent } from './item-page-uri-field.component';
|
||||||
import { MetadataUriValuesComponent } from '../../../../field-components/metadata-uri-values/metadata-uri-values.component';
|
import { MetadataUriValuesComponent } from '../../../../field-components/metadata-uri-values/metadata-uri-values.component';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
|
||||||
|
|
||||||
let comp: ItemPageUriFieldComponent;
|
let comp: ItemPageUriFieldComponent;
|
||||||
let fixture: ComponentFixture<ItemPageUriFieldComponent>;
|
let fixture: ComponentFixture<ItemPageUriFieldComponent>;
|
||||||
@@ -22,6 +24,9 @@ describe('ItemPageUriFieldComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
],
|
||||||
declarations: [ItemPageUriFieldComponent, MetadataUriValuesComponent],
|
declarations: [ItemPageUriFieldComponent, MetadataUriValuesComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemPageUriFieldComponent, {
|
}).overrideComponent(ItemPageUriFieldComponent, {
|
||||||
|
@@ -259,9 +259,15 @@ describe('MenuResolver', () => {
|
|||||||
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
||||||
id: 'import', visible: true,
|
id: 'import', visible: true,
|
||||||
}));
|
}));
|
||||||
|
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
||||||
|
id: 'import_batch', parentID: 'import', visible: true,
|
||||||
|
}));
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
||||||
id: 'export', visible: true,
|
id: 'export', visible: true,
|
||||||
}));
|
}));
|
||||||
|
expect(menuService.addSection).toHaveBeenCalledWith(MenuID.ADMIN, jasmine.objectContaining({
|
||||||
|
id: 'export_batch', parentID: 'export', visible: true,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -44,6 +44,9 @@ import {
|
|||||||
METADATA_IMPORT_SCRIPT_NAME,
|
METADATA_IMPORT_SCRIPT_NAME,
|
||||||
ScriptDataService
|
ScriptDataService
|
||||||
} from './core/data/processes/script-data.service';
|
} from './core/data/processes/script-data.service';
|
||||||
|
import {
|
||||||
|
ExportBatchSelectorComponent
|
||||||
|
} from './shared/dso-selector/modal-wrappers/export-batch-selector/export-batch-selector.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates all of the app's menus
|
* Creates all of the app's menus
|
||||||
@@ -440,6 +443,20 @@ export class MenuResolver implements Resolve<boolean> {
|
|||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
shouldPersistOnRouteChange: true
|
shouldPersistOnRouteChange: true
|
||||||
});
|
});
|
||||||
|
this.menuService.addSection(MenuID.ADMIN, {
|
||||||
|
id: 'export_batch',
|
||||||
|
parentID: 'export',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.export_batch',
|
||||||
|
function: () => {
|
||||||
|
this.modalService.open(ExportBatchSelectorComponent);
|
||||||
|
}
|
||||||
|
} as OnClickMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,20 +465,7 @@ export class MenuResolver implements Resolve<boolean> {
|
|||||||
* the import scripts exist and the current user is allowed to execute them
|
* the import scripts exist and the current user is allowed to execute them
|
||||||
*/
|
*/
|
||||||
createImportMenuSections() {
|
createImportMenuSections() {
|
||||||
const menuList = [
|
const menuList = [];
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'import_batch',
|
|
||||||
// parentID: 'import',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.import_batch',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// }
|
|
||||||
];
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, menuSection));
|
menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, menuSection));
|
||||||
|
|
||||||
observableCombineLatest([
|
observableCombineLatest([
|
||||||
@@ -498,6 +502,18 @@ export class MenuResolver implements Resolve<boolean> {
|
|||||||
} as LinkMenuItemModel,
|
} as LinkMenuItemModel,
|
||||||
shouldPersistOnRouteChange: true
|
shouldPersistOnRouteChange: true
|
||||||
});
|
});
|
||||||
|
this.menuService.addSection(MenuID.ADMIN, {
|
||||||
|
id: 'import_batch',
|
||||||
|
parentID: 'import',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.import_batch',
|
||||||
|
link: '/admin/batch-import'
|
||||||
|
} as LinkMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,15 +8,14 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { NotificationOptions } from '../../shared/notifications/models/notification-options.model';
|
|
||||||
import { UploaderOptions } from '../../shared/uploader/uploader-options.model';
|
import { UploaderOptions } from '../../shared/uploader/uploader-options.model';
|
||||||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
||||||
import { NotificationType } from '../../shared/notifications/models/notification-type';
|
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../shared/empty.util';
|
||||||
import { SearchResult } from '../../shared/search/models/search-result.model';
|
import { SearchResult } from '../../shared/search/models/search-result.model';
|
||||||
import { CollectionSelectorComponent } from '../collection-selector/collection-selector.component';
|
import { CollectionSelectorComponent } from '../collection-selector/collection-selector.component';
|
||||||
import { UploaderComponent } from '../../shared/uploader/uploader.component';
|
import { UploaderComponent } from '../../shared/uploader/uploader.component';
|
||||||
import { UploaderError } from '../../shared/uploader/uploader-error.model';
|
import { UploaderError } from '../../shared/uploader/uploader-error.model';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component represents the whole mydspace page header
|
* This component represents the whole mydspace page header
|
||||||
@@ -56,13 +55,15 @@ export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
|
|||||||
* @param {NotificationsService} notificationsService
|
* @param {NotificationsService} notificationsService
|
||||||
* @param {TranslateService} translate
|
* @param {TranslateService} translate
|
||||||
* @param {NgbModal} modalService
|
* @param {NgbModal} modalService
|
||||||
|
* @param {Router} router
|
||||||
*/
|
*/
|
||||||
constructor(private authService: AuthService,
|
constructor(private authService: AuthService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private halService: HALEndpointService,
|
private halService: HALEndpointService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private modalService: NgbModal) {
|
private modalService: NgbModal,
|
||||||
|
private router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,16 +88,9 @@ export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
|
|||||||
this.uploadEnd.emit(workspaceitems);
|
this.uploadEnd.emit(workspaceitems);
|
||||||
|
|
||||||
if (workspaceitems.length === 1) {
|
if (workspaceitems.length === 1) {
|
||||||
const options = new NotificationOptions();
|
|
||||||
options.timeOut = 0;
|
|
||||||
const link = '/workspaceitems/' + workspaceitems[0].id + '/edit';
|
const link = '/workspaceitems/' + workspaceitems[0].id + '/edit';
|
||||||
this.notificationsService.notificationWithAnchor(
|
// To avoid confusion and ambiguity, redirect the user on the publication page.
|
||||||
NotificationType.Success,
|
this.router.navigateByUrl(link);
|
||||||
options,
|
|
||||||
link,
|
|
||||||
'mydspace.general.text-here',
|
|
||||||
'mydspace.upload.upload-successful',
|
|
||||||
'here');
|
|
||||||
} else if (workspaceitems.length > 1) {
|
} else if (workspaceitems.length > 1) {
|
||||||
this.notificationsService.success(null, this.translate.get('mydspace.upload.upload-multiple-successful', {qty: workspaceitems.length}));
|
this.notificationsService.success(null, this.translate.get('mydspace.upload.upload-multiple-successful', {qty: workspaceitems.length}));
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ import { WorkflowItemSearchResultListElementComponent } from '../shared/object-l
|
|||||||
import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component';
|
import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component';
|
||||||
import { ClaimedApprovedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-approved-search-result/claimed-approved-search-result-list-element.component';
|
import { ClaimedApprovedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-approved-search-result/claimed-approved-search-result-list-element.component';
|
||||||
import { ClaimedDeclinedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-declined-search-result/claimed-declined-search-result-list-element.component';
|
import { ClaimedDeclinedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-declined-search-result/claimed-declined-search-result-list-element.component';
|
||||||
|
import { ResearchEntitiesModule } from '../entity-groups/research-entities/research-entities.module';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
// put only entry components that use custom decorator
|
// put only entry components that use custom decorator
|
||||||
@@ -38,6 +39,7 @@ const ENTRY_COMPONENTS = [
|
|||||||
CommonModule,
|
CommonModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
MyDspacePageRoutingModule,
|
MyDspacePageRoutingModule,
|
||||||
|
ResearchEntitiesModule.withEntryComponents()
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
...ENTRY_COMPONENTS
|
...ENTRY_COMPONENTS
|
||||||
|
@@ -4,7 +4,7 @@ nav.navbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Mobile menu styling **/
|
/** Mobile menu styling **/
|
||||||
@media screen and (max-width: map-get($grid-breakpoints, md)) {
|
@media screen and (max-width: map-get($grid-breakpoints, md)-0.02) {
|
||||||
.navbar {
|
.navbar {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
background-color: var(--bs-white);
|
background-color: var(--bs-white);
|
||||||
@@ -26,7 +26,7 @@ nav.navbar {
|
|||||||
|
|
||||||
/* TODO remove when https://github.com/twbs/bootstrap/issues/24726 is fixed */
|
/* TODO remove when https://github.com/twbs/bootstrap/issues/24726 is fixed */
|
||||||
.navbar-expand-md.navbar-container {
|
.navbar-expand-md.navbar-container {
|
||||||
@media screen and (max-width: map-get($grid-breakpoints, md)) {
|
@media screen and (max-width: map-get($grid-breakpoints, md)-0.02) {
|
||||||
> .container {
|
> .container {
|
||||||
padding: 0 var(--bs-spacer);
|
padding: 0 var(--bs-spacer);
|
||||||
}
|
}
|
||||||
|
@@ -74,6 +74,19 @@ describe('ProfilePageSecurityFormComponent', () => {
|
|||||||
|
|
||||||
expect(component.passwordValue.emit).toHaveBeenCalledWith('new-password');
|
expect(component.passwordValue.emit).toHaveBeenCalledWith('new-password');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should emit the value on password change with current password for profile-page', fakeAsync(() => {
|
||||||
|
spyOn(component.passwordValue, 'emit');
|
||||||
|
spyOn(component.currentPasswordValue, 'emit');
|
||||||
|
component.FORM_PREFIX = 'profile.security.form.';
|
||||||
|
component.ngOnInit();
|
||||||
|
component.formGroup.patchValue({password: 'new-password'});
|
||||||
|
component.formGroup.patchValue({'current-password': 'current-password'});
|
||||||
|
tick(300);
|
||||||
|
|
||||||
|
expect(component.passwordValue.emit).toHaveBeenCalledWith('new-password');
|
||||||
|
expect(component.currentPasswordValue.emit).toHaveBeenCalledWith('current-password');
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -27,6 +27,10 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
* Emits the value of the password
|
* Emits the value of the password
|
||||||
*/
|
*/
|
||||||
@Output() passwordValue = new EventEmitter<string>();
|
@Output() passwordValue = new EventEmitter<string>();
|
||||||
|
/**
|
||||||
|
* Emits the value of the current-password
|
||||||
|
*/
|
||||||
|
@Output() currentPasswordValue = new EventEmitter<string>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The form's input models
|
* The form's input models
|
||||||
@@ -70,6 +74,14 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
if (this.FORM_PREFIX === 'profile.security.form.') {
|
||||||
|
this.formModel.unshift(new DynamicInputModel({
|
||||||
|
id: 'current-password',
|
||||||
|
name: 'current-password',
|
||||||
|
inputType: 'password',
|
||||||
|
required: true
|
||||||
|
}));
|
||||||
|
}
|
||||||
if (this.passwordCanBeEmpty) {
|
if (this.passwordCanBeEmpty) {
|
||||||
this.formGroup = this.formService.createFormGroup(this.formModel,
|
this.formGroup = this.formService.createFormGroup(this.formModel,
|
||||||
{ validators: [this.checkPasswordsEqual] });
|
{ validators: [this.checkPasswordsEqual] });
|
||||||
@@ -94,6 +106,9 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
debounceTime(300),
|
debounceTime(300),
|
||||||
).subscribe((valueChange) => {
|
).subscribe((valueChange) => {
|
||||||
this.passwordValue.emit(valueChange.password);
|
this.passwordValue.emit(valueChange.password);
|
||||||
|
if (this.FORM_PREFIX === 'profile.security.form.') {
|
||||||
|
this.currentPasswordValue.emit(valueChange['current-password']);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
[FORM_PREFIX]="'profile.security.form.'"
|
[FORM_PREFIX]="'profile.security.form.'"
|
||||||
(isInvalid)="setInvalid($event)"
|
(isInvalid)="setInvalid($event)"
|
||||||
(passwordValue)="setPasswordValue($event)"
|
(passwordValue)="setPasswordValue($event)"
|
||||||
|
(currentPasswordValue)="setCurrentPasswordValue($event)"
|
||||||
></ds-profile-page-security-form>
|
></ds-profile-page-security-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -180,7 +180,7 @@ describe('ProfilePageComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.setPasswordValue('');
|
component.setPasswordValue('');
|
||||||
|
component.setCurrentPasswordValue('current-password');
|
||||||
result = component.updateSecurity();
|
result = component.updateSecurity();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -199,6 +199,7 @@ describe('ProfilePageComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.setPasswordValue('test');
|
component.setPasswordValue('test');
|
||||||
component.setInvalid(true);
|
component.setInvalid(true);
|
||||||
|
component.setCurrentPasswordValue('current-password');
|
||||||
result = component.updateSecurity();
|
result = component.updateSecurity();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -215,8 +216,11 @@ describe('ProfilePageComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.setPasswordValue('testest');
|
component.setPasswordValue('testest');
|
||||||
component.setInvalid(false);
|
component.setInvalid(false);
|
||||||
|
component.setCurrentPasswordValue('current-password');
|
||||||
|
|
||||||
operations = [{ op: 'add', path: '/password', value: 'testest' }];
|
operations = [
|
||||||
|
{ 'op': 'add', 'path': '/password', 'value': { 'new_password': 'testest', 'current_password': 'current-password' } }
|
||||||
|
];
|
||||||
result = component.updateSecurity();
|
result = component.updateSecurity();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -228,6 +232,28 @@ describe('ProfilePageComponent', () => {
|
|||||||
expect(epersonService.patch).toHaveBeenCalledWith(user, operations);
|
expect(epersonService.patch).toHaveBeenCalledWith(user, operations);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when password is filled in, and is valid but return 403', () => {
|
||||||
|
let result;
|
||||||
|
let operations;
|
||||||
|
|
||||||
|
it('should return call epersonService.patch', (done) => {
|
||||||
|
epersonService.patch.and.returnValue(observableOf(Object.assign(new RestResponse(false, 403, 'Error'))));
|
||||||
|
component.setPasswordValue('testest');
|
||||||
|
component.setInvalid(false);
|
||||||
|
component.setCurrentPasswordValue('current-password');
|
||||||
|
operations = [
|
||||||
|
{ 'op': 'add', 'path': '/password', 'value': {'new_password': 'testest', 'current_password': 'current-password' }}
|
||||||
|
];
|
||||||
|
result = component.updateSecurity();
|
||||||
|
epersonService.patch(user, operations).subscribe((response) => {
|
||||||
|
expect(response.statusCode).toEqual(403);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
expect(epersonService.patch).toHaveBeenCalledWith(user, operations);
|
||||||
|
expect(result).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('canChangePassword$', () => {
|
describe('canChangePassword$', () => {
|
||||||
|
@@ -67,6 +67,10 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
* The password filled in, in the security form
|
* The password filled in, in the security form
|
||||||
*/
|
*/
|
||||||
private password: string;
|
private password: string;
|
||||||
|
/**
|
||||||
|
* The current-password filled in, in the security form
|
||||||
|
*/
|
||||||
|
private currentPassword: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authenticated user
|
* The authenticated user
|
||||||
@@ -138,15 +142,14 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
updateSecurity() {
|
updateSecurity() {
|
||||||
const passEntered = isNotEmpty(this.password);
|
const passEntered = isNotEmpty(this.password);
|
||||||
|
|
||||||
if (this.invalidSecurity) {
|
if (this.invalidSecurity) {
|
||||||
this.notificationsService.error(this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.general'));
|
this.notificationsService.error(this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.general'));
|
||||||
}
|
}
|
||||||
if (!this.invalidSecurity && passEntered) {
|
if (!this.invalidSecurity && passEntered) {
|
||||||
const operation = {op: 'add', path: '/password', value: this.password} as Operation;
|
const operations = [
|
||||||
this.epersonService.patch(this.currentUser, [operation]).pipe(
|
{ 'op': 'add', 'path': '/password', 'value': { 'new_password': this.password, 'current_password': this.currentPassword } }
|
||||||
getFirstCompletedRemoteData()
|
] as Operation[];
|
||||||
).subscribe((response: RemoteData<EPerson>) => {
|
this.epersonService.patch(this.currentUser, operations).pipe(getFirstCompletedRemoteData()).subscribe((response: RemoteData<EPerson>) => {
|
||||||
if (response.hasSucceeded) {
|
if (response.hasSucceeded) {
|
||||||
this.notificationsService.success(
|
this.notificationsService.success(
|
||||||
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.title'),
|
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.title'),
|
||||||
@@ -154,7 +157,8 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.title'), response.errorMessage
|
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.title'),
|
||||||
|
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -170,6 +174,14 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
this.password = $event;
|
this.password = $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current-password value based on the value emitted from the security form
|
||||||
|
* @param $event
|
||||||
|
*/
|
||||||
|
setCurrentPasswordValue($event: string) {
|
||||||
|
this.currentPassword = $event;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit of the security form that triggers the updateProfile method
|
* Submit of the security form that triggers the updateProfile method
|
||||||
*/
|
*/
|
||||||
|
@@ -41,6 +41,11 @@ export class CreateProfileComponent implements OnInit {
|
|||||||
userInfoForm: FormGroup;
|
userInfoForm: FormGroup;
|
||||||
activeLangs: LangConfig[];
|
activeLangs: LangConfig[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the notification messages of this security form
|
||||||
|
*/
|
||||||
|
NOTIFICATIONS_PREFIX = 'register-page.create-profile.submit.';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private ePersonDataService: EPersonDataService,
|
private ePersonDataService: EPersonDataService,
|
||||||
@@ -161,13 +166,12 @@ export class CreateProfileComponent implements OnInit {
|
|||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
).subscribe((rd: RemoteData<EPerson>) => {
|
).subscribe((rd: RemoteData<EPerson>) => {
|
||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get('register-page.create-profile.submit.success.head'),
|
this.notificationsService.success(this.translateService.get(this.NOTIFICATIONS_PREFIX + 'success.head'),
|
||||||
this.translateService.get('register-page.create-profile.submit.success.content'));
|
this.translateService.get(this.NOTIFICATIONS_PREFIX + 'success.content'));
|
||||||
this.store.dispatch(new AuthenticateAction(this.email, this.password));
|
this.store.dispatch(new AuthenticateAction(this.email, this.password));
|
||||||
this.router.navigate(['/home']);
|
this.router.navigate(['/home']);
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get('register-page.create-profile.submit.error.head'),
|
this.notificationsService.error(this.translateService.get(this.NOTIFICATIONS_PREFIX + 'error.head'), rd.errorMessage);
|
||||||
this.translateService.get('register-page.create-profile.submit.error.content'));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@ import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
|
|||||||
import { NativeWindowRef, NativeWindowService } from '../core/services/window.service';
|
import { NativeWindowRef, NativeWindowService } from '../core/services/window.service';
|
||||||
import { MetadataService } from '../core/metadata/metadata.service';
|
import { MetadataService } from '../core/metadata/metadata.service';
|
||||||
import { MetadataServiceMock } from '../shared/mocks/metadata-service.mock';
|
import { MetadataServiceMock } from '../shared/mocks/metadata-service.mock';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2';
|
|
||||||
import { AngularticsProviderMock } from '../shared/mocks/angulartics-provider.service.mock';
|
import { AngularticsProviderMock } from '../shared/mocks/angulartics-provider.service.mock';
|
||||||
import { Angulartics2DSpace } from '../statistics/angulartics/dspace-provider';
|
import { Angulartics2DSpace } from '../statistics/angulartics/dspace-provider';
|
||||||
import { AuthService } from '../core/auth/auth.service';
|
import { AuthService } from '../core/auth/auth.service';
|
||||||
@@ -50,7 +49,6 @@ describe('RootComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
|
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
|
||||||
{ provide: MetadataService, useValue: new MetadataServiceMock() },
|
{ provide: MetadataService, useValue: new MetadataServiceMock() },
|
||||||
{ provide: Angulartics2GoogleAnalytics, useValue: new AngularticsProviderMock() },
|
|
||||||
{ provide: Angulartics2DSpace, useValue: new AngularticsProviderMock() },
|
{ provide: Angulartics2DSpace, useValue: new AngularticsProviderMock() },
|
||||||
{ provide: AuthService, useValue: new AuthServiceMock() },
|
{ provide: AuthService, useValue: new AuthServiceMock() },
|
||||||
{ provide: Router, useValue: new RouterMock() },
|
{ provide: Router, useValue: new RouterMock() },
|
||||||
|
@@ -5,7 +5,6 @@ import { Router } from '@angular/router';
|
|||||||
import { combineLatest as combineLatestObservable, Observable, of } from 'rxjs';
|
import { combineLatest as combineLatestObservable, Observable, of } from 'rxjs';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2';
|
|
||||||
|
|
||||||
import { MetadataService } from '../core/metadata/metadata.service';
|
import { MetadataService } from '../core/metadata/metadata.service';
|
||||||
import { HostWindowState } from '../shared/search/host-window.reducer';
|
import { HostWindowState } from '../shared/search/host-window.reducer';
|
||||||
@@ -51,7 +50,6 @@ export class RootComponent implements OnInit {
|
|||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private store: Store<HostWindowState>,
|
private store: Store<HostWindowState>,
|
||||||
private metadata: MetadataService,
|
private metadata: MetadataService,
|
||||||
private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics,
|
|
||||||
private angulartics2DSpace: Angulartics2DSpace,
|
private angulartics2DSpace: Angulartics2DSpace,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
24
src/app/search-navbar/themed-search-navbar.component.ts
Normal file
24
src/app/search-navbar/themed-search-navbar.component.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { ThemedComponent } from '../shared/theme-support/themed.component';
|
||||||
|
import { SearchNavbarComponent } from './search-navbar.component';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-themed-search-navbar',
|
||||||
|
styleUrls: [],
|
||||||
|
templateUrl: '../shared/theme-support/themed.component.html',
|
||||||
|
})
|
||||||
|
export class ThemedSearchNavbarComponent extends ThemedComponent<SearchNavbarComponent> {
|
||||||
|
|
||||||
|
protected getComponentName(): string {
|
||||||
|
return 'SearchNavbarComponent';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
|
return import(`../../themes/${themeName}/app/search-navbar/search-navbar.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importUnthemedComponent(): Promise<any> {
|
||||||
|
return import(`./search-navbar.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -198,11 +198,13 @@ describe('BrowseByComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use the base component to render browse entries', () => {
|
it('should use the base component to render browse entries', () => {
|
||||||
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
|
waitForAsync(() => {
|
||||||
expect(componentLoaders.length).toEqual(browseEntries.length);
|
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
|
||||||
componentLoaders.forEach((componentLoader) => {
|
expect(componentLoaders.length).toEqual(browseEntries.length);
|
||||||
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
|
componentLoaders.forEach((componentLoader) => {
|
||||||
expect(browseEntry.componentInstance).toBeInstanceOf(BrowseEntryListElementComponent);
|
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
|
||||||
|
expect(browseEntry.componentInstance).toBeInstanceOf(BrowseEntryListElementComponent);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -215,11 +217,13 @@ describe('BrowseByComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use the themed component to render browse entries', () => {
|
it('should use the themed component to render browse entries', () => {
|
||||||
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
|
waitForAsync(() => {
|
||||||
expect(componentLoaders.length).toEqual(browseEntries.length);
|
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
|
||||||
componentLoaders.forEach((componentLoader) => {
|
expect(componentLoaders.length).toEqual(browseEntries.length);
|
||||||
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
|
componentLoaders.forEach((componentLoader) => {
|
||||||
expect(browseEntry.componentInstance).toBeInstanceOf(MockThemedBrowseEntryListElementComponent);
|
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
|
||||||
|
expect(browseEntry.componentInstance).toBeInstanceOf(MockThemedBrowseEntryListElementComponent);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
import {Component, Input} from '@angular/core';
|
||||||
|
import { ThemedComponent } from '../../theme-support/themed.component';
|
||||||
|
import { ComcolPageHandleComponent } from './comcol-page-handle.component';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Themed wrapper for BreadcrumbsComponent
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-themed-comcol-page-handle',
|
||||||
|
styleUrls: [],
|
||||||
|
templateUrl: '../../theme-support/themed.component.html',
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
export class ThemedComcolPageHandleComponent extends ThemedComponent<ComcolPageHandleComponent> {
|
||||||
|
|
||||||
|
// Optional title
|
||||||
|
@Input() title: string;
|
||||||
|
|
||||||
|
// The value of "handle"
|
||||||
|
@Input() content: string;
|
||||||
|
|
||||||
|
inAndOutputNames: (keyof ComcolPageHandleComponent & keyof this)[] = ['title', 'content'];
|
||||||
|
|
||||||
|
protected getComponentName(): string {
|
||||||
|
return 'ComcolPageHandleComponent';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
|
return import(`../../../../themes/${themeName}/app/shared/comcol/comcol-page-handle/comcol-page-handle.component`);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected importUnthemedComponent(): Promise<any> {
|
||||||
|
return import(`./comcol-page-handle.component`);
|
||||||
|
}
|
||||||
|
}
|
@@ -2,6 +2,8 @@ import { NgModule } from '@angular/core';
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component';
|
import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component';
|
||||||
import { ComcolPageHandleComponent } from './comcol-page-handle/comcol-page-handle.component';
|
import { ComcolPageHandleComponent } from './comcol-page-handle/comcol-page-handle.component';
|
||||||
|
import { ThemedComcolPageHandleComponent} from './comcol-page-handle/themed-comcol-page-handle.component';
|
||||||
|
|
||||||
import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component';
|
import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component';
|
||||||
import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component';
|
import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component';
|
||||||
import { ComColFormComponent } from './comcol-forms/comcol-form/comcol-form.component';
|
import { ComColFormComponent } from './comcol-forms/comcol-form/comcol-form.component';
|
||||||
@@ -26,6 +28,9 @@ const COMPONENTS = [
|
|||||||
ComcolPageBrowseByComponent,
|
ComcolPageBrowseByComponent,
|
||||||
ThemedComcolPageBrowseByComponent,
|
ThemedComcolPageBrowseByComponent,
|
||||||
ComcolRoleComponent,
|
ComcolRoleComponent,
|
||||||
|
|
||||||
|
ThemedComcolPageHandleComponent
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -10,10 +10,12 @@ import { AuthService } from '../../core/auth/auth.service';
|
|||||||
import { CookieService } from '../../core/services/cookie.service';
|
import { CookieService } from '../../core/services/cookie.service';
|
||||||
import { getTestScheduler } from 'jasmine-marbles';
|
import { getTestScheduler } from 'jasmine-marbles';
|
||||||
import { MetadataValue } from '../../core/shared/metadata.models';
|
import { MetadataValue } from '../../core/shared/metadata.models';
|
||||||
import {clone, cloneDeep} from 'lodash';
|
import { clone, cloneDeep } from 'lodash';
|
||||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
import {createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$} from '../remote-data.utils';
|
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
|
||||||
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
|
import { ANONYMOUS_STORAGE_NAME_KLARO } from './klaro-configuration';
|
||||||
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
|
|
||||||
describe('BrowserKlaroService', () => {
|
describe('BrowserKlaroService', () => {
|
||||||
const trackingIdProp = 'google.analytics.key';
|
const trackingIdProp = 'google.analytics.key';
|
||||||
@@ -29,7 +31,7 @@ describe('BrowserKlaroService', () => {
|
|||||||
let configurationDataService: ConfigurationDataService;
|
let configurationDataService: ConfigurationDataService;
|
||||||
const createConfigSuccessSpy = (...values: string[]) => jasmine.createSpyObj('configurationDataService', {
|
const createConfigSuccessSpy = (...values: string[]) => jasmine.createSpyObj('configurationDataService', {
|
||||||
findByPropertyName: createSuccessfulRemoteDataObject$({
|
findByPropertyName: createSuccessfulRemoteDataObject$({
|
||||||
... new ConfigurationProperty(),
|
...new ConfigurationProperty(),
|
||||||
name: trackingIdProp,
|
name: trackingIdProp,
|
||||||
values: values,
|
values: values,
|
||||||
}),
|
}),
|
||||||
@@ -42,7 +44,9 @@ describe('BrowserKlaroService', () => {
|
|||||||
let findByPropertyName;
|
let findByPropertyName;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
user = new EPerson();
|
user = Object.assign(new EPerson(), {
|
||||||
|
uuid: 'test-user'
|
||||||
|
});
|
||||||
|
|
||||||
translateService = getMockTranslateService();
|
translateService = getMockTranslateService();
|
||||||
ePersonService = jasmine.createSpyObj('ePersonService', {
|
ePersonService = jasmine.createSpyObj('ePersonService', {
|
||||||
@@ -104,7 +108,7 @@ describe('BrowserKlaroService', () => {
|
|||||||
services: [{
|
services: [{
|
||||||
name: appName,
|
name: appName,
|
||||||
purposes: [purpose]
|
purposes: [purpose]
|
||||||
},{
|
}, {
|
||||||
name: googleAnalytics,
|
name: googleAnalytics,
|
||||||
purposes: [purpose]
|
purposes: [purpose]
|
||||||
}],
|
}],
|
||||||
@@ -219,6 +223,40 @@ describe('BrowserKlaroService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getSavedPreferences', () => {
|
||||||
|
let scheduler: TestScheduler;
|
||||||
|
beforeEach(() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when no user is autheticated', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service as any, 'getUser$').and.returnValue(observableOf(undefined));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the cookie consents object', () => {
|
||||||
|
scheduler.schedule(() => service.getSavedPreferences().subscribe());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect(cookieService.get).toHaveBeenCalledWith(ANONYMOUS_STORAGE_NAME_KLARO);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when user is autheticated', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service as any, 'getUser$').and.returnValue(observableOf(user));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the cookie consents object', () => {
|
||||||
|
scheduler.schedule(() => service.getSavedPreferences().subscribe());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect(cookieService.get).toHaveBeenCalledWith('klaro-' + user.uuid);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('setSettingsForUser when there are changes', () => {
|
describe('setSettingsForUser when there are changes', () => {
|
||||||
const cookieConsent = { test: 'testt' };
|
const cookieConsent = { test: 'testt' };
|
||||||
const cookieConsentString = '{test: \'testt\'}';
|
const cookieConsentString = '{test: \'testt\'}';
|
||||||
@@ -271,40 +309,40 @@ describe('BrowserKlaroService', () => {
|
|||||||
});
|
});
|
||||||
it('should not filter googleAnalytics when servicesToHide are empty', () => {
|
it('should not filter googleAnalytics when servicesToHide are empty', () => {
|
||||||
const filteredConfig = (service as any).filterConfigServices([]);
|
const filteredConfig = (service as any).filterConfigServices([]);
|
||||||
expect(filteredConfig).toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(filteredConfig).toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
it('should filter services using names passed as servicesToHide', () => {
|
it('should filter services using names passed as servicesToHide', () => {
|
||||||
const filteredConfig = (service as any).filterConfigServices([googleAnalytics]);
|
const filteredConfig = (service as any).filterConfigServices([googleAnalytics]);
|
||||||
expect(filteredConfig).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(filteredConfig).not.toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
it('should have been initialized with googleAnalytics', () => {
|
it('should have been initialized with googleAnalytics', () => {
|
||||||
service.initialize();
|
service.initialize();
|
||||||
expect(service.klaroConfig.services).toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(service.klaroConfig.services).toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
it('should filter googleAnalytics when empty configuration is retrieved', () => {
|
it('should filter googleAnalytics when empty configuration is retrieved', () => {
|
||||||
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
createSuccessfulRemoteDataObject$({
|
createSuccessfulRemoteDataObject$({
|
||||||
... new ConfigurationProperty(),
|
...new ConfigurationProperty(),
|
||||||
name: googleAnalytics,
|
name: googleAnalytics,
|
||||||
values: [],
|
values: [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
service.initialize();
|
service.initialize();
|
||||||
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
it('should filter googleAnalytics when an error occurs', () => {
|
it('should filter googleAnalytics when an error occurs', () => {
|
||||||
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
createFailedRemoteDataObject$('Erro while loading GA')
|
createFailedRemoteDataObject$('Erro while loading GA')
|
||||||
);
|
);
|
||||||
service.initialize();
|
service.initialize();
|
||||||
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
it('should filter googleAnalytics when an invalid payload is retrieved', () => {
|
it('should filter googleAnalytics when an invalid payload is retrieved', () => {
|
||||||
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
createSuccessfulRemoteDataObject$(null)
|
createSuccessfulRemoteDataObject$(null)
|
||||||
);
|
);
|
||||||
service.initialize();
|
service.initialize();
|
||||||
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({ name: googleAnalytics }));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -13,7 +13,7 @@ import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
|||||||
import { cloneDeep, debounce } from 'lodash';
|
import { cloneDeep, debounce } from 'lodash';
|
||||||
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
|
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { getFirstCompletedRemoteData} from '../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +121,23 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return saved preferences stored in the klaro cookie
|
||||||
|
*/
|
||||||
|
getSavedPreferences(): Observable<any> {
|
||||||
|
return this.getUser$().pipe(
|
||||||
|
map((user: EPerson) => {
|
||||||
|
let storageName;
|
||||||
|
if (isEmpty(user)) {
|
||||||
|
storageName = ANONYMOUS_STORAGE_NAME_KLARO;
|
||||||
|
} else {
|
||||||
|
storageName = this.getStorageName(user.uuid);
|
||||||
|
}
|
||||||
|
return this.cookieService.get(storageName);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize configuration for the logged in user
|
* Initialize configuration for the logged in user
|
||||||
* @param user The authenticated user
|
* @param user The authenticated user
|
||||||
|
@@ -12,6 +12,8 @@ export const HAS_AGREED_END_USER = 'dsHasAgreedEndUser';
|
|||||||
*/
|
*/
|
||||||
export const ANONYMOUS_STORAGE_NAME_KLARO = 'klaro-anonymous';
|
export const ANONYMOUS_STORAGE_NAME_KLARO = 'klaro-anonymous';
|
||||||
|
|
||||||
|
export const GOOGLE_ANALYTICS_KLARO_KEY = 'google-analytics';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Klaro configuration
|
* Klaro configuration
|
||||||
* For more information see https://kiprotect.com/docs/klaro/annotated-config
|
* For more information see https://kiprotect.com/docs/klaro/annotated-config
|
||||||
@@ -113,7 +115,7 @@ export const klaroConfiguration: any = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'google-analytics',
|
name: GOOGLE_ANALYTICS_KLARO_KEY,
|
||||||
purposes: ['statistical'],
|
purposes: ['statistical'],
|
||||||
required: false,
|
required: false,
|
||||||
cookies: [
|
cookies: [
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class representing a service for handling Klaro consent preferences and UI
|
* Abstract class representing a service for handling Klaro consent preferences and UI
|
||||||
*/
|
*/
|
||||||
@@ -11,7 +13,12 @@ export abstract class KlaroService {
|
|||||||
abstract initialize();
|
abstract initialize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a the dialog with the current consent preferences
|
* Shows a dialog with the current consent preferences
|
||||||
*/
|
*/
|
||||||
abstract showSettings();
|
abstract showSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return saved preferences stored in the klaro cookie
|
||||||
|
*/
|
||||||
|
abstract getSavedPreferences(): Observable<any>;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,9 @@ export enum SelectorActionType {
|
|||||||
CREATE = 'create',
|
CREATE = 'create',
|
||||||
EDIT = 'edit',
|
EDIT = 'edit',
|
||||||
EXPORT_METADATA = 'export-metadata',
|
EXPORT_METADATA = 'export-metadata',
|
||||||
SET_SCOPE = 'set-scope'
|
IMPORT_BATCH = 'import-batch',
|
||||||
|
SET_SCOPE = 'set-scope',
|
||||||
|
EXPORT_BATCH = 'export-batch'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user