mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Merge remote-tracking branch 'remotes/origin/main' into authorities_and_controlled_vocabularies
# Conflicts: # src/app/shared/shared.module.ts
This commit is contained in:
5
.github/pull_request_template.md
vendored
5
.github/pull_request_template.md
vendored
@@ -21,8 +21,5 @@ _This checklist provides a reminder of what we are going to look for when review
|
|||||||
- [ ] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
|
- [ ] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
|
||||||
- [ ] My PR passes [TSLint](https://palantir.github.io/tslint/) validation using `yarn run lint`
|
- [ ] My PR passes [TSLint](https://palantir.github.io/tslint/) validation using `yarn run lint`
|
||||||
- [ ] My PR includes [TypeDoc](https://typedoc.org/) comments for _all new (or modified) public methods and classes_. It also includes TypeDoc for large or complex private methods.
|
- [ ] My PR includes [TypeDoc](https://typedoc.org/) comments for _all new (or modified) public methods and classes_. It also includes TypeDoc for large or complex private methods.
|
||||||
- [ ] My PR passes all specs/tests and includes new/updated specs for any bug fixes, improvements or new features. A few reminders about what constitutes good tests:
|
- [ ] My PR passes all specs/tests and includes new/updated specs or tests based on the [Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Testing+Guide).
|
||||||
* Include tests for different user types (if behavior differs), including: (1) Anonymous user, (2) Logged in user (non-admin), and (3) Administrator.
|
|
||||||
* Include tests for error scenarios, e.g. when errors/warnings should appear (or buttons should be disabled).
|
|
||||||
* For bug fixes, include a test that reproduces the bug and proves it is fixed. For clarity, it may be useful to provide the test in a separate commit from the bug fix.
|
|
||||||
- [ ] If my PR includes new, third-party dependencies (in `package.json`), I've made sure their licenses align with the [DSpace BSD License](https://github.com/DSpace/DSpace/blob/main/LICENSE) based on the [Licensing of Contributions](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines#CodeContributionGuidelines-LicensingofContributions) documentation.
|
- [ ] If my PR includes new, third-party dependencies (in `package.json`), I've made sure their licenses align with the [DSpace BSD License](https://github.com/DSpace/DSpace/blob/main/LICENSE) based on the [Licensing of Contributions](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines#CodeContributionGuidelines-LicensingofContributions) documentation.
|
||||||
|
@@ -51,10 +51,10 @@ before_script:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
# build app and run all tests
|
# build app and run all tests
|
||||||
- ng lint
|
- ng lint || travis_terminate 1;
|
||||||
- travis_wait yarn run build:prod
|
- travis_wait yarn run build:prod || travis_terminate 1;
|
||||||
- yarn test:headless
|
- yarn test:headless || travis_terminate 1;
|
||||||
- yarn run e2e:ci
|
- yarn run e2e:ci || travis_terminate 1;
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
# Shutdown docker after everything runs
|
# Shutdown docker after everything runs
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
"builder": "@angular-builders/custom-webpack:browser",
|
"builder": "@angular-builders/custom-webpack:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"customWebpackConfig": {
|
"customWebpackConfig": {
|
||||||
"path": "./webpack/webpack.common.ts",
|
"path": "./webpack/webpack.browser.ts",
|
||||||
"mergeStrategies": {
|
"mergeStrategies": {
|
||||||
"loaders": "prepend"
|
"loaders": "prepend"
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,8 @@
|
|||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
"aot": false,
|
"aot": false,
|
||||||
"assets": [
|
"assets": [
|
||||||
"src/assets"
|
"src/assets",
|
||||||
|
"src/robots.txt"
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/styles.scss"
|
"src/styles.scss"
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
"builder": "@angular-builders/custom-webpack:karma",
|
"builder": "@angular-builders/custom-webpack:karma",
|
||||||
"options": {
|
"options": {
|
||||||
"customWebpackConfig": {
|
"customWebpackConfig": {
|
||||||
"path": "./webpack/webpack.common.ts",
|
"path": "./webpack/webpack.test.ts",
|
||||||
"mergeStrategies": {
|
"mergeStrategies": {
|
||||||
"loaders": "prepend"
|
"loaders": "prepend"
|
||||||
}
|
}
|
||||||
|
@@ -146,6 +146,7 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^0.4.10",
|
"fork-ts-checker-webpack-plugin": "^0.4.10",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
|
"http-proxy-middleware": "^1.0.5",
|
||||||
"jasmine-core": "^3.3.0",
|
"jasmine-core": "^3.3.0",
|
||||||
"jasmine-marbles": "0.3.1",
|
"jasmine-marbles": "0.3.1",
|
||||||
"jasmine-spec-reporter": "~4.2.1",
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
|
@@ -54,6 +54,13 @@ import(environmentFilePath)
|
|||||||
function generateEnvironmentFile(file: GlobalConfig): void {
|
function generateEnvironmentFile(file: GlobalConfig): void {
|
||||||
file.production = production;
|
file.production = production;
|
||||||
buildBaseUrls(file);
|
buildBaseUrls(file);
|
||||||
|
|
||||||
|
// TODO remove workaround in beta 5
|
||||||
|
if (file.rest.nameSpace.match("(.*)/api/?$") !== null) {
|
||||||
|
const newValue = getNameSpace(file.rest.nameSpace);
|
||||||
|
console.log(colors.white.bgMagenta.bold(`The rest.nameSpace property in your environment file or in your DSPACE_REST_NAMESPACE environment variable ends with '/api'.\nThis is deprecated. As '/api' isn't configurable on the rest side, it shouldn't be repeated in every environment file.\nPlease change the rest nameSpace to '${newValue}'`));
|
||||||
|
}
|
||||||
|
|
||||||
const contents = `export const environment = ` + JSON.stringify(file);
|
const contents = `export const environment = ` + JSON.stringify(file);
|
||||||
writeFile(targetPath, contents, (err) => {
|
writeFile(targetPath, contents, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -112,5 +119,16 @@ function getPort(port: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNameSpace(nameSpace: string): string {
|
function getNameSpace(nameSpace: string): string {
|
||||||
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
|
// TODO remove workaround in beta 5
|
||||||
|
const apiMatches = nameSpace.match("(.*)/api/?$");
|
||||||
|
if (apiMatches != null) {
|
||||||
|
let newValue = '/'
|
||||||
|
if (hasValue(apiMatches[1])) {
|
||||||
|
newValue = apiMatches[1];
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ import { enableProdMode, NgModuleFactory, Type } from '@angular/core';
|
|||||||
|
|
||||||
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||||
import { environment } from './src/environments/environment';
|
import { environment } from './src/environments/environment';
|
||||||
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set path for the browser application's dist folder
|
* Set path for the browser application's dist folder
|
||||||
@@ -106,6 +107,11 @@ app.set('view engine', 'html');
|
|||||||
*/
|
*/
|
||||||
app.set('views', DIST_FOLDER);
|
app.set('views', DIST_FOLDER);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy the sitemaps
|
||||||
|
*/
|
||||||
|
app.use('/sitemap**', createProxyMiddleware({ target: `${environment.rest.baseUrl}/sitemaps`, changeOrigin: true }));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adds a cache control header to the response
|
* Adds a cache control header to the response
|
||||||
* The cache control value can be configured in the environments file and defaults to max-age=60
|
* The cache control value can be configured in the environments file and defaults to max-age=60
|
||||||
|
@@ -0,0 +1,15 @@
|
|||||||
|
<div class="container">
|
||||||
|
<h2 id="header">{{'admin.metadata-import.page.header' | translate}}</h2>
|
||||||
|
<p>{{'admin.metadata-import.page.help' | translate}}</p>
|
||||||
|
|
||||||
|
<ds-file-dropzone-no-uploader
|
||||||
|
(onFileAdded)="setFile($event)"
|
||||||
|
[dropMessageLabel]="'admin.metadata-import.page.dropMsg'"
|
||||||
|
[dropMessageLabelReplacement]="'admin.metadata-import.page.dropMsgReplace'">
|
||||||
|
</ds-file-dropzone-no-uploader>
|
||||||
|
|
||||||
|
<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>
|
@@ -0,0 +1,151 @@
|
|||||||
|
import { Location } from '@angular/common';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import {
|
||||||
|
METADATA_IMPORT_SCRIPT_NAME,
|
||||||
|
ScriptDataService
|
||||||
|
} from '../../core/data/processes/script-data.service';
|
||||||
|
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||||
|
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
|
import { FileValueAccessorDirective } from '../../shared/utils/file-value-accessor.directive';
|
||||||
|
import { FileValidator } from '../../shared/utils/require-file.validator';
|
||||||
|
import { MetadataImportPageComponent } from './metadata-import-page.component';
|
||||||
|
|
||||||
|
describe('MetadataImportPageComponent', () => {
|
||||||
|
let comp: MetadataImportPageComponent;
|
||||||
|
let fixture: ComponentFixture<MetadataImportPageComponent>;
|
||||||
|
|
||||||
|
let user;
|
||||||
|
|
||||||
|
let notificationService: NotificationsServiceStub;
|
||||||
|
let scriptService: any;
|
||||||
|
let router;
|
||||||
|
let authService;
|
||||||
|
let locationStub;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
notificationService = new NotificationsServiceStub();
|
||||||
|
scriptService = jasmine.createSpyObj('scriptService',
|
||||||
|
{
|
||||||
|
invoke: observableOf({
|
||||||
|
response:
|
||||||
|
{
|
||||||
|
isSuccessful: true,
|
||||||
|
resourceSelfLinks: ['https://localhost:8080/api/core/processes/45']
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
user = Object.assign(new EPerson(), {
|
||||||
|
id: 'userId',
|
||||||
|
email: 'user@test.com'
|
||||||
|
});
|
||||||
|
authService = jasmine.createSpyObj('authService', {
|
||||||
|
getAuthenticatedUserFromStore: observableOf(user)
|
||||||
|
});
|
||||||
|
router = jasmine.createSpyObj('router', {
|
||||||
|
navigateByUrl: jasmine.createSpy('navigateByUrl')
|
||||||
|
});
|
||||||
|
locationStub = jasmine.createSpyObj('location', {
|
||||||
|
back: jasmine.createSpy('back')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
init();
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
RouterTestingModule.withRoutes([])
|
||||||
|
],
|
||||||
|
declarations: [MetadataImportPageComponent, FileValueAccessorDirective, FileValidator],
|
||||||
|
providers: [
|
||||||
|
{ provide: NotificationsService, useValue: notificationService },
|
||||||
|
{ provide: ScriptDataService, useValue: scriptService },
|
||||||
|
{ provide: Router, useValue: router },
|
||||||
|
{ provide: AuthService, useValue: authService },
|
||||||
|
{ provide: Location, useValue: locationStub },
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(MetadataImportPageComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(comp).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.txt', { type: 'text/plain' });
|
||||||
|
comp.setFile(fileMock);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if proceed button is pressed', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('metadata-import script is invoked with its -e currentUserEmail, -f fileName and the mockFile', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-e', value: user.email }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: 'filename.txt' }),
|
||||||
|
];
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [fileMock]);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/45');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if proceed is pressed; but script invoke fails', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
spyOn(scriptService, 'invoke').and.returnValue(observableOf({
|
||||||
|
response:
|
||||||
|
{
|
||||||
|
isSuccessful: false,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
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,106 @@
|
|||||||
|
import { Location } from '@angular/common';
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { map, switchMap, take } from 'rxjs/operators';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import { METADATA_IMPORT_SCRIPT_NAME, ScriptDataService } from '../../core/data/processes/script-data.service';
|
||||||
|
import { RequestEntry } from '../../core/data/request.reducer';
|
||||||
|
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||||
|
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
||||||
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-metadata-import-page',
|
||||||
|
templateUrl: './metadata-import-page.component.html'
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component that represents a metadata import page for administrators
|
||||||
|
*/
|
||||||
|
export class MetadataImportPageComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current value of the file
|
||||||
|
*/
|
||||||
|
fileObject: File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authenticated user's email
|
||||||
|
*/
|
||||||
|
private currentUserEmail$: Observable<string>;
|
||||||
|
|
||||||
|
public constructor(protected authService: AuthService,
|
||||||
|
private location: Location,
|
||||||
|
protected translate: TranslateService,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
|
private scriptDataService: ScriptDataService,
|
||||||
|
private router: Router) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set file
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
setFile(file) {
|
||||||
|
this.fileObject = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method provided by Angular. Invoked after the constructor.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.currentUserEmail$ = this.authService.getAuthenticatedUserFromStore().pipe(
|
||||||
|
map((user: EPerson) => user.email)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When return button is pressed go to previous location
|
||||||
|
*/
|
||||||
|
public onReturn() {
|
||||||
|
this.location.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts import-metadata script with -e currentUserEmail -f fileName (and the selected file)
|
||||||
|
*/
|
||||||
|
public importMetadata() {
|
||||||
|
if (this.fileObject == null) {
|
||||||
|
this.notificationsService.error(this.translate.get('admin.metadata-import.page.error.addFile'));
|
||||||
|
} else {
|
||||||
|
this.currentUserEmail$.pipe(
|
||||||
|
switchMap((email: string) => {
|
||||||
|
if (isNotEmpty(email)) {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-e', value: email }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: this.fileObject.name }),
|
||||||
|
];
|
||||||
|
return this.scriptDataService.invoke(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject])
|
||||||
|
.pipe(
|
||||||
|
take(1),
|
||||||
|
map((requestEntry: RequestEntry) => {
|
||||||
|
if (requestEntry.response.isSuccessful) {
|
||||||
|
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);
|
||||||
|
const response: any = requestEntry.response;
|
||||||
|
if (isNotEmpty(response.resourceSelfLinks)) {
|
||||||
|
const processNumber = response.resourceSelfLinks[0].split('/').pop();
|
||||||
|
this.router.navigateByUrl('/processes/' + processNumber);
|
||||||
|
}
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
take(1)
|
||||||
|
).subscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { getAdminModulePath } from '../app-routing.module';
|
import { getAdminModulePath } from '../app-routing.module';
|
||||||
|
import { MetadataImportPageComponent } from './admin-import-metadata-page/metadata-import-page.component';
|
||||||
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
||||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow-page.component';
|
import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow-page.component';
|
||||||
@@ -48,6 +49,12 @@ export function getAccessControlModulePath() {
|
|||||||
component: AdminCurationTasksComponent,
|
component: AdminCurationTasksComponent,
|
||||||
data: { title: 'admin.curation-tasks.title', breadcrumbKey: 'admin.curation-tasks' }
|
data: { title: 'admin.curation-tasks.title', breadcrumbKey: 'admin.curation-tasks' }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'metadata-import',
|
||||||
|
resolve: { breadcrumb: I18nBreadcrumbResolver },
|
||||||
|
component: MetadataImportPageComponent,
|
||||||
|
data: { title: 'admin.metadata-import.title', breadcrumbKey: 'admin.metadata-import' }
|
||||||
|
},
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<div class="sidebar-collapsible">
|
<div class="sidebar-collapsible">
|
||||||
<span class="section-header-text">
|
<span class="section-header-text">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<ng-container *ngFor="let section of (sections | async)">
|
<ng-container *ngFor="let section of (sections | async)">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="sectionComponents.get(section.id); injector: sectionInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,4 +49,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -2,6 +2,7 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core
|
|||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { ScriptDataService } from '../../core/data/processes/script-data.service';
|
||||||
import { AdminSidebarComponent } from './admin-sidebar.component';
|
import { AdminSidebarComponent } from './admin-sidebar.component';
|
||||||
import { MenuService } from '../../shared/menu/menu.service';
|
import { MenuService } from '../../shared/menu/menu.service';
|
||||||
import { MenuServiceStub } from '../../shared/testing/menu-service.stub';
|
import { MenuServiceStub } from '../../shared/testing/menu-service.stub';
|
||||||
@@ -21,11 +22,13 @@ describe('AdminSidebarComponent', () => {
|
|||||||
let fixture: ComponentFixture<AdminSidebarComponent>;
|
let fixture: ComponentFixture<AdminSidebarComponent>;
|
||||||
const menuService = new MenuServiceStub();
|
const menuService = new MenuServiceStub();
|
||||||
let authorizationService: AuthorizationDataService;
|
let authorizationService: AuthorizationDataService;
|
||||||
|
let scriptService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
authorizationService = jasmine.createSpyObj('authorizationService', {
|
authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
isAuthorized: observableOf(true)
|
isAuthorized: observableOf(true)
|
||||||
});
|
});
|
||||||
|
scriptService = jasmine.createSpyObj('scriptService', { scriptWithNameExistsAndCanExecute: observableOf(true) });
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, RouterTestingModule],
|
imports: [TranslateModule.forRoot(), NoopAnimationsModule, RouterTestingModule],
|
||||||
declarations: [AdminSidebarComponent],
|
declarations: [AdminSidebarComponent],
|
||||||
@@ -36,9 +39,11 @@ describe('AdminSidebarComponent', () => {
|
|||||||
{ provide: AuthService, useClass: AuthServiceStub },
|
{ provide: AuthService, useClass: AuthServiceStub },
|
||||||
{ provide: ActivatedRoute, useValue: {} },
|
{ provide: ActivatedRoute, useValue: {} },
|
||||||
{ provide: AuthorizationDataService, useValue: authorizationService },
|
{ provide: AuthorizationDataService, useValue: authorizationService },
|
||||||
|
{ provide: ScriptDataService, useValue: scriptService },
|
||||||
{
|
{
|
||||||
provide: NgbModal, useValue: {
|
provide: NgbModal, useValue: {
|
||||||
open: () => {/*comment*/}
|
open: () => {/*comment*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
import { Component, Injector, OnInit } from '@angular/core';
|
import { Component, Injector, OnInit } from '@angular/core';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { combineLatest as combineLatestObservable } from 'rxjs';
|
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { first, map } from 'rxjs/operators';
|
import { first, map, take } from 'rxjs/operators';
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import {
|
||||||
|
METADATA_EXPORT_SCRIPT_NAME,
|
||||||
|
METADATA_IMPORT_SCRIPT_NAME,
|
||||||
|
ScriptDataService
|
||||||
|
} from '../../core/data/processes/script-data.service';
|
||||||
import { slideHorizontal, slideSidebar } from '../../shared/animations/slide';
|
import { slideHorizontal, slideSidebar } from '../../shared/animations/slide';
|
||||||
import { CreateCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component';
|
import { CreateCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component';
|
||||||
import { CreateCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component';
|
import { CreateCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component';
|
||||||
@@ -11,6 +16,9 @@ import { CreateItemParentSelectorComponent } from '../../shared/dso-selector/mod
|
|||||||
import { EditCollectionSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component';
|
import { EditCollectionSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component';
|
||||||
import { EditCommunitySelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component';
|
import { EditCommunitySelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component';
|
||||||
import { EditItemSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component';
|
import { EditItemSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component';
|
||||||
|
import {
|
||||||
|
ExportMetadataSelectorComponent
|
||||||
|
} from '../../shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
||||||
import { MenuID, MenuItemType } from '../../shared/menu/initial-menus-state';
|
import { MenuID, MenuItemType } from '../../shared/menu/initial-menus-state';
|
||||||
import { LinkMenuItemModel } from '../../shared/menu/menu-item/models/link.model';
|
import { LinkMenuItemModel } from '../../shared/menu/menu-item/models/link.model';
|
||||||
import { OnClickMenuItemModel } from '../../shared/menu/menu-item/models/onclick.model';
|
import { OnClickMenuItemModel } from '../../shared/menu/menu-item/models/onclick.model';
|
||||||
@@ -64,7 +72,8 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
private variableService: CSSVariableService,
|
private variableService: CSSVariableService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
private authorizationService: AuthorizationDataService
|
private authorizationService: AuthorizationDataService,
|
||||||
|
private scriptDataService: ScriptDataService,
|
||||||
) {
|
) {
|
||||||
super(menuService, injector);
|
super(menuService, injector);
|
||||||
}
|
}
|
||||||
@@ -75,6 +84,8 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.createMenu();
|
this.createMenu();
|
||||||
this.createSiteAdministratorMenuSections();
|
this.createSiteAdministratorMenuSections();
|
||||||
|
this.createExportMenuSections();
|
||||||
|
this.createImportMenuSections();
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.sidebarWidth = this.variableService.getVariable('sidebarItemsWidth');
|
this.sidebarWidth = this.variableService.getVariable('sidebarItemsWidth');
|
||||||
this.authService.isAuthenticated()
|
this.authService.isAuthenticated()
|
||||||
@@ -88,7 +99,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
this.sidebarOpen = !collapsed;
|
this.sidebarOpen = !collapsed;
|
||||||
this.sidebarClosed = collapsed;
|
this.sidebarClosed = collapsed;
|
||||||
});
|
});
|
||||||
this.sidebarExpanded = combineLatestObservable(this.menuCollapsed, this.menuPreviewCollapsed)
|
this.sidebarExpanded = observableCombineLatest(this.menuCollapsed, this.menuPreviewCollapsed)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(([collapsed, previewCollapsed]) => (!collapsed || !previewCollapsed))
|
map(([collapsed, previewCollapsed]) => (!collapsed || !previewCollapsed))
|
||||||
);
|
);
|
||||||
@@ -225,94 +236,18 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Import */
|
/* Curation tasks */
|
||||||
{
|
{
|
||||||
id: 'import',
|
id: 'curation_tasks',
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.import'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'sign-in-alt',
|
|
||||||
index: 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'import_metadata',
|
|
||||||
parentID: 'import',
|
|
||||||
active: false,
|
active: false,
|
||||||
visible: true,
|
visible: true,
|
||||||
model: {
|
model: {
|
||||||
type: MenuItemType.LINK,
|
type: MenuItemType.LINK,
|
||||||
text: 'menu.section.import_metadata',
|
text: 'menu.section.curation_task',
|
||||||
link: ''
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'import_batch',
|
|
||||||
parentID: 'import',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.import_batch',
|
|
||||||
link: ''
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
/* Export */
|
|
||||||
{
|
|
||||||
id: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.export'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'sign-out-alt',
|
|
||||||
index: 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'export_community',
|
|
||||||
parentID: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.export_community',
|
|
||||||
link: ''
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'export_collection',
|
|
||||||
parentID: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.export_collection',
|
|
||||||
link: ''
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'export_item',
|
|
||||||
parentID: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.export_item',
|
|
||||||
link: ''
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
}, {
|
|
||||||
id: 'export_metadata',
|
|
||||||
parentID: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.export_metadata',
|
|
||||||
link: ''
|
link: ''
|
||||||
} as LinkMenuItemModel,
|
} as LinkMenuItemModel,
|
||||||
|
icon: 'filter',
|
||||||
|
index: 7
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Statistics */
|
/* Statistics */
|
||||||
@@ -362,6 +297,146 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create menu sections dependent on whether or not the current user is a site administrator and on whether or not
|
||||||
|
* the export scripts exist and the current user is allowed to execute them
|
||||||
|
*/
|
||||||
|
createExportMenuSections() {
|
||||||
|
const menuList = [
|
||||||
|
/* Export */
|
||||||
|
{
|
||||||
|
id: 'export',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.export'
|
||||||
|
} as TextMenuItemModel,
|
||||||
|
icon: 'sign-out-alt',
|
||||||
|
index: 3,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'export_community',
|
||||||
|
parentID: 'export',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.export_community',
|
||||||
|
link: ''
|
||||||
|
} as LinkMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'export_collection',
|
||||||
|
parentID: 'export',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.export_collection',
|
||||||
|
link: ''
|
||||||
|
} as LinkMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'export_item',
|
||||||
|
parentID: 'export',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.export_item',
|
||||||
|
link: ''
|
||||||
|
} as LinkMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
},
|
||||||
|
];
|
||||||
|
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));
|
||||||
|
|
||||||
|
observableCombineLatest(
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||||
|
// this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME)
|
||||||
|
).pipe(
|
||||||
|
// TODO uncomment when #635 (https://github.com/DSpace/dspace-angular/issues/635) is fixed; otherwise even in production mode, the metadata export button is only available after a refresh (and not in dev mode)
|
||||||
|
// filter(([authorized, metadataExportScriptExists]: boolean[]) => authorized && metadataExportScriptExists),
|
||||||
|
take(1)
|
||||||
|
).subscribe(() => {
|
||||||
|
this.menuService.addSection(this.menuID, {
|
||||||
|
id: 'export_metadata',
|
||||||
|
parentID: 'export',
|
||||||
|
active: true,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.export_metadata',
|
||||||
|
function: () => {
|
||||||
|
this.modalService.open(ExportMetadataSelectorComponent);
|
||||||
|
}
|
||||||
|
} as OnClickMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create menu sections dependent on whether or not the current user is a site administrator and on whether or not
|
||||||
|
* the import scripts exist and the current user is allowed to execute them
|
||||||
|
*/
|
||||||
|
createImportMenuSections() {
|
||||||
|
const menuList = [
|
||||||
|
/* Import */
|
||||||
|
{
|
||||||
|
id: 'import',
|
||||||
|
active: false,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.import'
|
||||||
|
} as TextMenuItemModel,
|
||||||
|
icon: 'sign-in-alt',
|
||||||
|
index: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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(this.menuID, Object.assign(menuSection, {
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
})));
|
||||||
|
|
||||||
|
observableCombineLatest(
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||||
|
// this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_IMPORT_SCRIPT_NAME)
|
||||||
|
).pipe(
|
||||||
|
// TODO uncomment when #635 (https://github.com/DSpace/dspace-angular/issues/635) is fixed
|
||||||
|
// filter(([authorized, metadataImportScriptExists]: boolean[]) => authorized && metadataImportScriptExists),
|
||||||
|
take(1)
|
||||||
|
).subscribe(() => {
|
||||||
|
this.menuService.addSection(this.menuID, {
|
||||||
|
id: 'import_metadata',
|
||||||
|
parentID: 'import',
|
||||||
|
active: true,
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.import_metadata',
|
||||||
|
link: '/admin/metadata-import'
|
||||||
|
} as LinkMenuItemModel,
|
||||||
|
shouldPersistOnRouteChange: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create menu sections dependent on whether or not the current user is a site administrator
|
* Create menu sections dependent on whether or not the current user is a site administrator
|
||||||
*/
|
*/
|
||||||
|
@@ -12,16 +12,16 @@
|
|||||||
(click)="toggleSection($event)">
|
(click)="toggleSection($event)">
|
||||||
<span class="section-header-text">
|
<span class="section-header-text">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</span>
|
</span>
|
||||||
<i class="fas fa-chevron-right fa-pull-right"
|
<i class="fas fa-chevron-right fa-pull-right"
|
||||||
[@rotate]="(expanded | async) ? 'expanded' : 'collapsed'" [title]="('menu.section.toggle.' + section.id) | translate"></i>
|
[@rotate]="(expanded | async) ? 'expanded' : 'collapsed'" [title]="('menu.section.toggle.' + section.id) | translate"></i>
|
||||||
</a>
|
</a>
|
||||||
<ul class="sidebar-sub-level-items list-unstyled" @slide *ngIf="(expanded | async)">
|
<ul class="sidebar-sub-level-items list-unstyled" @slide *ngIf="(expanded | async)">
|
||||||
<li *ngFor="let subSection of (subSections | async)">
|
<li *ngFor="let subSection of (subSections$ | async)">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(subSection.id); injector: itemInjectors.get(subSection.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(subSection.id).component; injector: (sectionMap$ | async).get(subSection.id).injector;"></ng-container>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { SharedModule } from '../shared/shared.module';
|
import { SharedModule } from '../shared/shared.module';
|
||||||
import { AdminAccessControlModule } from './admin-access-control/admin-access-control.module';
|
import { AdminAccessControlModule } from './admin-access-control/admin-access-control.module';
|
||||||
|
import { MetadataImportPageComponent } from './admin-import-metadata-page/metadata-import-page.component';
|
||||||
import { AdminRegistriesModule } from './admin-registries/admin-registries.module';
|
import { AdminRegistriesModule } from './admin-registries/admin-registries.module';
|
||||||
import { AdminRoutingModule } from './admin-routing.module';
|
import { AdminRoutingModule } from './admin-routing.module';
|
||||||
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
||||||
@@ -40,7 +41,9 @@ import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curati
|
|||||||
|
|
||||||
WorkflowItemSearchResultAdminWorkflowListElementComponent,
|
WorkflowItemSearchResultAdminWorkflowListElementComponent,
|
||||||
WorkflowItemSearchResultAdminWorkflowGridElementComponent,
|
WorkflowItemSearchResultAdminWorkflowGridElementComponent,
|
||||||
WorkflowItemAdminWorkflowActionsComponent
|
WorkflowItemAdminWorkflowActionsComponent,
|
||||||
|
|
||||||
|
MetadataImportPageComponent
|
||||||
|
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
@@ -54,7 +57,9 @@ import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curati
|
|||||||
|
|
||||||
WorkflowItemSearchResultAdminWorkflowListElementComponent,
|
WorkflowItemSearchResultAdminWorkflowListElementComponent,
|
||||||
WorkflowItemSearchResultAdminWorkflowGridElementComponent,
|
WorkflowItemSearchResultAdminWorkflowGridElementComponent,
|
||||||
WorkflowItemAdminWorkflowActionsComponent
|
WorkflowItemAdminWorkflowActionsComponent,
|
||||||
|
|
||||||
|
MetadataImportPageComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AdminModule {
|
export class AdminModule {
|
||||||
|
@@ -1,29 +1,87 @@
|
|||||||
<ds-metadata-field-wrapper [label]="label | translate">
|
<ds-metadata-field-wrapper [label]="label | translate">
|
||||||
<div class="file-section row" *ngFor="let file of (bitstreams$ | async); let last=last;">
|
<div *ngVar="(originals$ | async)?.payload as originals">
|
||||||
<div class="col-3">
|
<h5 class="simple-view-element-header">{{"item.page.filesection.original.bundle" | translate}}</h5>
|
||||||
<ds-thumbnail [thumbnail]="(file.thumbnail | async)?.payload"></ds-thumbnail>
|
<ds-pagination *ngIf="originals?.page?.length > 0"
|
||||||
</div>
|
[hideGear]="true"
|
||||||
<div class="col-7">
|
[hidePagerWhenSinglePage]="true"
|
||||||
<dl class="row">
|
[paginationOptions]="originalOptions"
|
||||||
<dt class="col-md-4">{{"item.page.filesection.name" | translate}}</dt>
|
[pageInfoState]="originals"
|
||||||
<dd class="col-md-8">{{file.name}}</dd>
|
[collectionSize]="originals?.totalElements"
|
||||||
|
[disableRouteParameterUpdate]="true"
|
||||||
<dt class="col-md-4">{{"item.page.filesection.size" | translate}}</dt>
|
(pageChange)="switchOriginalPage($event)">
|
||||||
<dd class="col-md-8">{{(file.sizeBytes) | dsFileSize }}</dd>
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="col-md-4">{{"item.page.filesection.format" | translate}}</dt>
|
|
||||||
<dd class="col-md-8">{{(file.format | async)?.payload?.description}}</dd>
|
<div class="file-section row" *ngFor="let file of originals?.page;">
|
||||||
|
<div class="col-3">
|
||||||
|
<ds-thumbnail [thumbnail]="(file.thumbnail | async)?.payload"></ds-thumbnail>
|
||||||
|
</div>
|
||||||
|
<div class="col-7">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.name" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{file.name}}</dd>
|
||||||
|
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.size" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{(file.sizeBytes) | dsFileSize }}</dd>
|
||||||
|
|
||||||
|
|
||||||
<dt class="col-md-4">{{"item.page.filesection.description" | translate}}</dt>
|
<dt class="col-md-4">{{"item.page.filesection.format" | translate}}</dt>
|
||||||
<dd class="col-md-8">{{file.firstMetadataValue("dc.description")}}</dd>
|
<dd class="col-md-8">{{(file.format | async)?.payload?.description}}</dd>
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="col-2">
|
<dt class="col-md-4">{{"item.page.filesection.description" | translate}}</dt>
|
||||||
<ds-file-download-link [href]="file._links.content.href" [download]="file.name">
|
<dd class="col-md-8">{{file.firstMetadataValue("dc.description")}}</dd>
|
||||||
{{"item.page.filesection.download" | translate}}
|
</dl>
|
||||||
</ds-file-download-link>
|
</div>
|
||||||
</div>
|
<div class="col-2">
|
||||||
|
<ds-file-download-link [href]="file._links.content.href" [download]="file.name">
|
||||||
|
{{"item.page.filesection.download" | translate}}
|
||||||
|
</ds-file-download-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngVar="(licenses$ | async)?.payload as licenses">
|
||||||
|
<h5 class="simple-view-element-header">{{"item.page.filesection.license.bundle" | translate}}</h5>
|
||||||
|
<ds-pagination *ngIf="licenses?.page?.length > 0"
|
||||||
|
[hideGear]="true"
|
||||||
|
[hidePagerWhenSinglePage]="true"
|
||||||
|
[paginationOptions]="licenseOptions"
|
||||||
|
[pageInfoState]="licenses"
|
||||||
|
[collectionSize]="licenses?.totalElements"
|
||||||
|
[disableRouteParameterUpdate]="true"
|
||||||
|
(pageChange)="switchLicensePage($event)">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="file-section row" *ngFor="let file of licenses?.page;">
|
||||||
|
<div class="col-3">
|
||||||
|
<ds-thumbnail [thumbnail]="(file.thumbnail | async)?.payload"></ds-thumbnail>
|
||||||
|
</div>
|
||||||
|
<div class="col-7">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.name" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{file.name}}</dd>
|
||||||
|
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.size" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{(file.sizeBytes) | dsFileSize }}</dd>
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.format" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{(file.format | async)?.payload?.description}}</dd>
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="col-md-4">{{"item.page.filesection.description" | translate}}</dt>
|
||||||
|
<dd class="col-md-8">{{file.firstMetadataValue("dc.description")}}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<ds-file-download-link [href]="file._links.content.href" [download]="file.name">
|
||||||
|
{{"item.page.filesection.download" | translate}}
|
||||||
|
</ds-file-download-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-pagination>
|
||||||
</div>
|
</div>
|
||||||
</ds-metadata-field-wrapper>
|
</ds-metadata-field-wrapper>
|
||||||
|
@@ -0,0 +1,117 @@
|
|||||||
|
import {FullFileSectionComponent} from './full-file-section.component';
|
||||||
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
import {createSuccessfulRemoteDataObject$} from '../../../../shared/remote-data.utils';
|
||||||
|
import {createPaginatedList} from '../../../../shared/testing/utils.test';
|
||||||
|
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||||
|
import {TranslateLoaderMock} from '../../../../shared/mocks/translate-loader.mock';
|
||||||
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
|
import {VarDirective} from '../../../../shared/utils/var.directive';
|
||||||
|
import {FileSizePipe} from '../../../../shared/utils/file-size-pipe';
|
||||||
|
import {MetadataFieldWrapperComponent} from '../../../field-components/metadata-field-wrapper/metadata-field-wrapper.component';
|
||||||
|
import {BitstreamDataService} from '../../../../core/data/bitstream-data.service';
|
||||||
|
import {NO_ERRORS_SCHEMA} from '@angular/core';
|
||||||
|
import {Bitstream} from '../../../../core/shared/bitstream.model';
|
||||||
|
import {of as observableOf} from 'rxjs';
|
||||||
|
import {MockBitstreamFormat1} from '../../../../shared/mocks/item.mock';
|
||||||
|
import {By} from '@angular/platform-browser';
|
||||||
|
|
||||||
|
describe('FullFileSectionComponent', () => {
|
||||||
|
let comp: FullFileSectionComponent;
|
||||||
|
let fixture: ComponentFixture<FullFileSectionComponent>;
|
||||||
|
|
||||||
|
const mockBitstream: Bitstream = Object.assign(new Bitstream(),
|
||||||
|
{
|
||||||
|
sizeBytes: 10201,
|
||||||
|
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content',
|
||||||
|
format: observableOf(MockBitstreamFormat1),
|
||||||
|
bundleName: 'ORIGINAL',
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713'
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
id: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||||
|
uuid: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||||
|
type: 'bitstream',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: 'test_word.docx'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const bitstreamDataService = jasmine.createSpyObj('bitstreamDataService', {
|
||||||
|
findAllByItemAndBundleName: createSuccessfulRemoteDataObject$(createPaginatedList([mockBitstream, mockBitstream, mockBitstream]))
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}), BrowserAnimationsModule],
|
||||||
|
declarations: [FullFileSectionComponent, VarDirective, FileSizePipe, MetadataFieldWrapperComponent],
|
||||||
|
providers: [
|
||||||
|
{provide: BitstreamDataService, useValue: bitstreamDataService}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(FullFileSectionComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('when the full file section gets loaded with bitstreams available', () => {
|
||||||
|
it ('should contain a list with bitstreams', () => {
|
||||||
|
const fileSection = fixture.debugElement.queryAll(By.css('.file-section'));
|
||||||
|
expect(fileSection.length).toEqual(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when we press the pageChange button for original bundle', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.switchOriginalPage(2);
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('should give the value to the currentpage', () => {
|
||||||
|
expect(comp.originalOptions.currentPage).toBe(2);
|
||||||
|
})
|
||||||
|
it ('should call the next function on the originalCurrentPage', (done) => {
|
||||||
|
comp.originalCurrentPage$.subscribe((event) => {
|
||||||
|
expect(event).toEqual(2);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('when we press the pageChange button for license bundle', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.switchLicensePage(2);
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('should give the value to the currentpage', () => {
|
||||||
|
expect(comp.licenseOptions.currentPage).toBe(2);
|
||||||
|
})
|
||||||
|
it ('should call the next function on the licenseCurrentPage', (done) => {
|
||||||
|
comp.licenseCurrentPage$.subscribe((event) => {
|
||||||
|
expect(event).toEqual(2);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@@ -1,13 +1,15 @@
|
|||||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { map, startWith } from 'rxjs/operators';
|
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||||
|
|
||||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { getFirstSucceededRemoteListPayload } from '../../../../core/shared/operators';
|
|
||||||
import { followLink } from '../../../../shared/utils/follow-link-config.model';
|
import { followLink } from '../../../../shared/utils/follow-link-config.model';
|
||||||
import { FileSectionComponent } from '../../../simple/field-components/file-section/file-section.component';
|
import { FileSectionComponent } from '../../../simple/field-components/file-section/file-section.component';
|
||||||
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
|
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||||
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
|
import { switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders the file section of the item
|
* This component renders the file section of the item
|
||||||
@@ -25,7 +27,23 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
|
|||||||
|
|
||||||
label: string;
|
label: string;
|
||||||
|
|
||||||
bitstreams$: Observable<Bitstream[]>;
|
originals$: Observable<RemoteData<PaginatedList<Bitstream>>>;
|
||||||
|
licenses$: Observable<RemoteData<PaginatedList<Bitstream>>>;
|
||||||
|
|
||||||
|
pageSize = 5;
|
||||||
|
originalOptions = Object.assign(new PaginationComponentOptions(),{
|
||||||
|
id: 'original-bitstreams-options',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: this.pageSize
|
||||||
|
});
|
||||||
|
originalCurrentPage$ = new BehaviorSubject<number>(1);
|
||||||
|
|
||||||
|
licenseOptions = Object.assign(new PaginationComponentOptions(),{
|
||||||
|
id: 'license-bitstreams-options',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: this.pageSize
|
||||||
|
});
|
||||||
|
licenseCurrentPage$ = new BehaviorSubject<number>(1);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
bitstreamDataService: BitstreamDataService
|
bitstreamDataService: BitstreamDataService
|
||||||
@@ -34,40 +52,45 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize(): void {
|
initialize(): void {
|
||||||
// TODO pagination
|
this.originals$ = this.originalCurrentPage$.pipe(
|
||||||
const originals$ = this.bitstreamDataService.findAllByItemAndBundleName(
|
switchMap((pageNumber: number) => this.bitstreamDataService.findAllByItemAndBundleName(
|
||||||
this.item,
|
this.item,
|
||||||
'ORIGINAL',
|
'ORIGINAL',
|
||||||
{ elementsPerPage: Number.MAX_SAFE_INTEGER },
|
{ elementsPerPage: this.pageSize, currentPage: pageNumber },
|
||||||
followLink( 'format')
|
followLink( 'format')
|
||||||
).pipe(
|
))
|
||||||
getFirstSucceededRemoteListPayload(),
|
|
||||||
startWith([])
|
|
||||||
);
|
);
|
||||||
const licenses$ = this.bitstreamDataService.findAllByItemAndBundleName(
|
|
||||||
this.item,
|
this.licenses$ = this.licenseCurrentPage$.pipe(
|
||||||
'LICENSE',
|
switchMap((pageNumber: number) => this.bitstreamDataService.findAllByItemAndBundleName(
|
||||||
{ elementsPerPage: Number.MAX_SAFE_INTEGER },
|
this.item,
|
||||||
followLink( 'format')
|
'LICENSE',
|
||||||
).pipe(
|
{ elementsPerPage: this.pageSize, currentPage: pageNumber },
|
||||||
getFirstSucceededRemoteListPayload(),
|
followLink( 'format')
|
||||||
startWith([])
|
))
|
||||||
);
|
|
||||||
this.bitstreams$ = observableCombineLatest(originals$, licenses$).pipe(
|
|
||||||
map(([o, l]) => [...o, ...l]),
|
|
||||||
map((files: Bitstream[]) =>
|
|
||||||
files.map(
|
|
||||||
(original) => {
|
|
||||||
original.thumbnail = this.bitstreamDataService.getMatchingThumbnail(this.item, original);
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the current page for the original bundle bitstreams
|
||||||
|
* @param page
|
||||||
|
*/
|
||||||
|
switchOriginalPage(page: number) {
|
||||||
|
this.originalOptions.currentPage = page;
|
||||||
|
this.originalCurrentPage$.next(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the current page for the license bundle bitstreams
|
||||||
|
* @param page
|
||||||
|
*/
|
||||||
|
switchLicensePage(page: number) {
|
||||||
|
this.licenseOptions.currentPage = page;
|
||||||
|
this.licenseCurrentPage$.next(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,13 @@
|
|||||||
<span>({{(file?.sizeBytes) | dsFileSize }})</span>
|
<span>({{(file?.sizeBytes) | dsFileSize }})</span>
|
||||||
<span *ngIf="!last" innerHTML="{{separator}}"></span>
|
<span *ngIf="!last" innerHTML="{{separator}}"></span>
|
||||||
</ds-file-download-link>
|
</ds-file-download-link>
|
||||||
|
<ds-loading *ngIf="isLoading" message="{{'loading.default' | translate}}" [showMessage]="false"></ds-loading>
|
||||||
|
<div *ngIf="!isLastPage" class="mt-1" id="view-more">
|
||||||
|
<a class="bitstream-view-more btn btn-outline-secondary btn-sm" [routerLink]="" (click)="getNextPage()">{{'item.page.bitstreams.view-more' | translate}}</a>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="isLastPage && currentPage != 1" class="mt-1" id="collapse">
|
||||||
|
<a class="bitstream-collapse btn btn-outline-secondary btn-sm" [routerLink]="" (click)="currentPage = undefined; getNextPage();">{{'item.page.bitstreams.collapse' | translate}}</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ds-metadata-field-wrapper>
|
</ds-metadata-field-wrapper>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -0,0 +1,169 @@
|
|||||||
|
import {FileSectionComponent} from './file-section.component';
|
||||||
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||||
|
import {TranslateLoaderMock} from '../../../../shared/mocks/translate-loader.mock';
|
||||||
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
|
import {VarDirective} from '../../../../shared/utils/var.directive';
|
||||||
|
import {NO_ERRORS_SCHEMA} from '@angular/core';
|
||||||
|
import {BitstreamDataService} from '../../../../core/data/bitstream-data.service';
|
||||||
|
import {createSuccessfulRemoteDataObject$} from '../../../../shared/remote-data.utils';
|
||||||
|
import {By} from '@angular/platform-browser';
|
||||||
|
import {Bitstream} from '../../../../core/shared/bitstream.model';
|
||||||
|
import {of as observableOf} from 'rxjs';
|
||||||
|
import {MockBitstreamFormat1} from '../../../../shared/mocks/item.mock';
|
||||||
|
import {FileSizePipe} from '../../../../shared/utils/file-size-pipe';
|
||||||
|
import {PageInfo} from '../../../../core/shared/page-info.model';
|
||||||
|
import {MetadataFieldWrapperComponent} from '../../../field-components/metadata-field-wrapper/metadata-field-wrapper.component';
|
||||||
|
import {createPaginatedList} from '../../../../shared/testing/utils.test';
|
||||||
|
|
||||||
|
describe('FileSectionComponent', () => {
|
||||||
|
let comp: FileSectionComponent;
|
||||||
|
let fixture: ComponentFixture<FileSectionComponent>;
|
||||||
|
|
||||||
|
const bitstreamDataService = jasmine.createSpyObj('bitstreamDataService', {
|
||||||
|
findAllByItemAndBundleName: createSuccessfulRemoteDataObject$(createPaginatedList([]))
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockBitstream: Bitstream = Object.assign(new Bitstream(),
|
||||||
|
{
|
||||||
|
sizeBytes: 10201,
|
||||||
|
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content',
|
||||||
|
format: observableOf(MockBitstreamFormat1),
|
||||||
|
bundleName: 'ORIGINAL',
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713'
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
id: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||||
|
uuid: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||||
|
type: 'bitstream',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: 'test_word.docx'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}), BrowserAnimationsModule],
|
||||||
|
declarations: [FileSectionComponent, VarDirective, FileSizePipe, MetadataFieldWrapperComponent],
|
||||||
|
providers: [
|
||||||
|
{provide: BitstreamDataService, useValue: bitstreamDataService}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(FileSectionComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('when the bitstreams are loading', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.bitstreams$.next([mockBitstream]);
|
||||||
|
comp.isLoading = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display a loading component', () => {
|
||||||
|
const loading = fixture.debugElement.query(By.css('ds-loading'));
|
||||||
|
expect(loading.nativeElement).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the "Show more" button is clicked', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.bitstreams$.next([mockBitstream]);
|
||||||
|
comp.currentPage = 1;
|
||||||
|
comp.isLastPage = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call the service to retrieve more bitstreams', () => {
|
||||||
|
const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more'));
|
||||||
|
viewMore.triggerEventHandler('click', null);
|
||||||
|
expect(bitstreamDataService.findAllByItemAndBundleName).toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('one bitstream should be on the page', () => {
|
||||||
|
const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more'));
|
||||||
|
viewMore.triggerEventHandler('click', null);
|
||||||
|
const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-file-download-link'));
|
||||||
|
expect(fileDownloadLink.length).toEqual(1);
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('when it is then clicked again', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
bitstreamDataService.findAllByItemAndBundleName.and.returnValue(createSuccessfulRemoteDataObject$(createPaginatedList([mockBitstream])));
|
||||||
|
const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more'));
|
||||||
|
viewMore.triggerEventHandler('click', null);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
})
|
||||||
|
it('should contain another bitstream', () => {
|
||||||
|
const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-file-download-link'));
|
||||||
|
expect(fileDownloadLink.length).toEqual(2);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when its the last page of bitstreams', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.bitstreams$.next([mockBitstream]);
|
||||||
|
comp.isLastPage = true;
|
||||||
|
comp.currentPage = 2;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not contain a view more link', () => {
|
||||||
|
const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more'));
|
||||||
|
expect(viewMore).toBeNull();
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should contain a view less link', () => {
|
||||||
|
const viewLess = fixture.debugElement.query(By.css('.bitstream-collapse'));
|
||||||
|
expect(viewLess).toBeDefined();
|
||||||
|
})
|
||||||
|
|
||||||
|
it('clicking on the view less link should reset the pages and call getNextPage()', () => {
|
||||||
|
const pageInfo = Object.assign(new PageInfo(), {
|
||||||
|
elementsPerPage: 3,
|
||||||
|
totalElements: 5,
|
||||||
|
totalPages: 2,
|
||||||
|
currentPage: 1,
|
||||||
|
_links: {
|
||||||
|
self: {href: 'https://rest.api/core/bitstreams/'},
|
||||||
|
next: {href: 'https://rest.api/core/bitstreams?page=2'}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const PaginatedList = Object.assign(createPaginatedList([mockBitstream]), {
|
||||||
|
pageInfo: pageInfo
|
||||||
|
});
|
||||||
|
bitstreamDataService.findAllByItemAndBundleName.and.returnValue(createSuccessfulRemoteDataObject$(PaginatedList));
|
||||||
|
const viewLess = fixture.debugElement.query(By.css('.bitstream-collapse'));
|
||||||
|
viewLess.triggerEventHandler('click', null);
|
||||||
|
expect(bitstreamDataService.findAllByItemAndBundleName).toHaveBeenCalled();
|
||||||
|
expect(comp.currentPage).toBe(1);
|
||||||
|
expect(comp.isLastPage).toBeFalse();
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
@@ -1,10 +1,13 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||||
|
|
||||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { getFirstSucceededRemoteListPayload } from '../../../../core/shared/operators';
|
import { filter, takeWhile } from 'rxjs/operators';
|
||||||
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
|
import { hasNoValue, hasValue } from '../../../../shared/empty.util';
|
||||||
|
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders the file section of the item
|
* This component renders the file section of the item
|
||||||
@@ -22,7 +25,15 @@ export class FileSectionComponent implements OnInit {
|
|||||||
|
|
||||||
separator = '<br/>';
|
separator = '<br/>';
|
||||||
|
|
||||||
bitstreams$: Observable<Bitstream[]>;
|
bitstreams$: BehaviorSubject<Bitstream[]>;
|
||||||
|
|
||||||
|
currentPage: number;
|
||||||
|
|
||||||
|
isLoading: boolean;
|
||||||
|
|
||||||
|
isLastPage: boolean;
|
||||||
|
|
||||||
|
pageSize = 5;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected bitstreamDataService: BitstreamDataService
|
protected bitstreamDataService: BitstreamDataService
|
||||||
@@ -30,13 +41,31 @@ export class FileSectionComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.initialize();
|
this.getNextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize(): void {
|
/**
|
||||||
this.bitstreams$ = this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL').pipe(
|
* This method will retrieve the next page of Bitstreams from the external BitstreamDataService call.
|
||||||
getFirstSucceededRemoteListPayload()
|
* It'll retrieve the currentPage from the class variables and it'll add the next page of bitstreams with the
|
||||||
);
|
* already existing one.
|
||||||
|
* If the currentPage variable is undefined, we'll set it to 1 and retrieve the first page of Bitstreams
|
||||||
|
*/
|
||||||
|
getNextPage(): void {
|
||||||
|
this.isLoading = true;
|
||||||
|
if (this.currentPage === undefined) {
|
||||||
|
this.currentPage = 1;
|
||||||
|
this.bitstreams$ = new BehaviorSubject([]);
|
||||||
|
} else {
|
||||||
|
this.currentPage++;
|
||||||
|
}
|
||||||
|
this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL', { currentPage: this.currentPage, elementsPerPage: this.pageSize }).pipe(
|
||||||
|
filter((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => hasValue(bitstreamsRD)),
|
||||||
|
takeWhile((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => hasNoValue(bitstreamsRD.payload) && hasNoValue(bitstreamsRD.error), true)
|
||||||
|
).subscribe((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {
|
||||||
|
const current: Bitstream[] = this.bitstreams$.getValue();
|
||||||
|
this.bitstreams$.next([...current, ...bitstreamsRD.payload.page]);
|
||||||
|
this.isLoading = false;
|
||||||
|
this.isLastPage = this.currentPage === bitstreamsRD.payload.totalPages;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ import { HostWindowState } from './shared/search/host-window.reducer';
|
|||||||
import { NativeWindowRef, NativeWindowService } from './core/services/window.service';
|
import { NativeWindowRef, NativeWindowService } from './core/services/window.service';
|
||||||
import { isAuthenticated } from './core/auth/selectors';
|
import { isAuthenticated } from './core/auth/selectors';
|
||||||
import { AuthService } from './core/auth/auth.service';
|
import { AuthService } from './core/auth/auth.service';
|
||||||
import variables from '../styles/_exposed_variables.scss';
|
|
||||||
import { CSSVariableService } from './shared/sass-helper/sass-helper.service';
|
import { CSSVariableService } from './shared/sass-helper/sass-helper.service';
|
||||||
import { MenuService } from './shared/menu/menu.service';
|
import { MenuService } from './shared/menu/menu.service';
|
||||||
import { MenuID } from './shared/menu/initial-menus-state';
|
import { MenuID } from './shared/menu/initial-menus-state';
|
||||||
|
@@ -206,7 +206,7 @@ export class AuthService {
|
|||||||
return this.store.pipe(
|
return this.store.pipe(
|
||||||
select(getAuthenticatedUserId),
|
select(getAuthenticatedUserId),
|
||||||
hasValueOperator(),
|
hasValueOperator(),
|
||||||
switchMap((id: string) => this.epersonService.findById(id)),
|
switchMap((id: string) => this.epersonService.findById(id) ),
|
||||||
getAllSucceededRemoteDataPayload()
|
getAllSucceededRemoteDataPayload()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -139,8 +139,8 @@ export class RemoteDataBuildService {
|
|||||||
const pageInfo$ = requestEntry$.pipe(
|
const pageInfo$ = requestEntry$.pipe(
|
||||||
filterSuccessfulResponses(),
|
filterSuccessfulResponses(),
|
||||||
map((response: DSOSuccessResponse) => {
|
map((response: DSOSuccessResponse) => {
|
||||||
if (hasValue((response as DSOSuccessResponse).pageInfo)) {
|
if (hasValue(response.pageInfo)) {
|
||||||
return (response as DSOSuccessResponse).pageInfo;
|
return Object.assign(new PageInfo(), response.pageInfo);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@@ -12,12 +12,17 @@ import { Script } from '../../../process-page/scripts/script.model';
|
|||||||
import { ProcessParameter } from '../../../process-page/processes/process-parameter.model';
|
import { ProcessParameter } from '../../../process-page/processes/process-parameter.model';
|
||||||
import { find, map, switchMap } from 'rxjs/operators';
|
import { find, map, switchMap } from 'rxjs/operators';
|
||||||
import { URLCombiner } from '../../url-combiner/url-combiner';
|
import { URLCombiner } from '../../url-combiner/url-combiner';
|
||||||
|
import { RemoteData } from '../remote-data';
|
||||||
import { MultipartPostRequest, RestRequest } from '../request.models';
|
import { MultipartPostRequest, RestRequest } from '../request.models';
|
||||||
import { RequestService } from '../request.service';
|
import { RequestService } from '../request.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { RequestEntry } from '../request.reducer';
|
import { RequestEntry } from '../request.reducer';
|
||||||
import { dataService } from '../../cache/builders/build-decorators';
|
import { dataService } from '../../cache/builders/build-decorators';
|
||||||
import { SCRIPT } from '../../../process-page/scripts/script.resource-type';
|
import { SCRIPT } from '../../../process-page/scripts/script.resource-type';
|
||||||
|
import { hasValue } from '../../../shared/empty.util';
|
||||||
|
|
||||||
|
export const METADATA_IMPORT_SCRIPT_NAME = 'metadata-import';
|
||||||
|
export const METADATA_EXPORT_SCRIPT_NAME = 'metadata-export';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@dataService(SCRIPT)
|
@dataService(SCRIPT)
|
||||||
@@ -58,4 +63,16 @@ export class ScriptDataService extends DataService<Script> {
|
|||||||
});
|
});
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a script with given name exist; user needs to be allowed to execute script for this to to not throw a 401 Unauthorized
|
||||||
|
* @param scriptName script we want to check exists (and we can execute)
|
||||||
|
*/
|
||||||
|
public scriptWithNameExistsAndCanExecute(scriptName: string): Observable<boolean> {
|
||||||
|
return this.findById(scriptName).pipe(
|
||||||
|
find((rd: RemoteData<Script>) => hasValue(rd.payload) || hasValue(rd.error)),
|
||||||
|
map((rd: RemoteData<Script>) => {
|
||||||
|
return hasValue(rd.payload);
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,4 +4,5 @@ export enum DSpaceObjectType {
|
|||||||
ITEM = 'ITEM',
|
ITEM = 'ITEM',
|
||||||
COLLECTION = 'COLLECTION',
|
COLLECTION = 'COLLECTION',
|
||||||
COMMUNITY = 'COMMUNITY',
|
COMMUNITY = 'COMMUNITY',
|
||||||
|
DSPACEOBJECT = 'DSPACEOBJECT',
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ describe('HALEndpointService', () => {
|
|||||||
describe('getRootEndpointMap', () => {
|
describe('getRootEndpointMap', () => {
|
||||||
it('should configure a new EndpointMapRequest', () => {
|
it('should configure a new EndpointMapRequest', () => {
|
||||||
(service as any).getRootEndpointMap();
|
(service as any).getRootEndpointMap();
|
||||||
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl);
|
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl + '/api');
|
||||||
expect(requestService.configure).toHaveBeenCalledWith(expected);
|
expect(requestService.configure).toHaveBeenCalledWith(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ export class HALEndpointService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected getRootHref(): string {
|
protected getRootHref(): string {
|
||||||
return new RESTURLCombiner('/').toString();
|
return new RESTURLCombiner('/api').toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getRootEndpointMap(): Observable<EndpointMap> {
|
protected getRootEndpointMap(): Observable<EndpointMap> {
|
||||||
|
@@ -5,13 +5,13 @@
|
|||||||
id="browseDropdown" (click)="toggleSection($event)"
|
id="browseDropdown" (click)="toggleSection($event)"
|
||||||
data-toggle="dropdown">
|
data-toggle="dropdown">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</a>
|
</a>
|
||||||
<ul @slide *ngIf="(active | async)" (click)="deactivateSection($event)"
|
<ul @slide *ngIf="(active | async)" (click)="deactivateSection($event)"
|
||||||
class="m-0 shadow-none border-top-0 dropdown-menu show">
|
class="m-0 shadow-none border-top-0 dropdown-menu show">
|
||||||
<ng-container *ngFor="let subSection of (subSections | async)">
|
<ng-container *ngFor="let subSection of (subSections$ | async)">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(subSection.id); injector: itemInjectors.get(subSection.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(subSection.id).component; injector: (sectionMap$ | async).get(subSection.id).injector;"></ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<ul class="navbar-nav mr-auto shadow-none">
|
<ul class="navbar-nav mr-auto shadow-none">
|
||||||
<ng-container *ngFor="let section of (sections | async)">
|
<ng-container *ngFor="let section of (sections | async)">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="sectionComponents.get(section.id); injector: sectionInjectors.get(section.id);"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
<div>
|
||||||
|
<div class="modal-header">{{ headerLabel | translate:{dsoName: dso?.name} }}
|
||||||
|
<button type="button" class="close" (click)="close()" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>{{ infoLabel | translate:{dsoName: dso?.name} }}</p>
|
||||||
|
<button type="button" class="cancel btn btn-secondary" (click)="cancelPressed()" aria-label="Cancel">
|
||||||
|
{{ cancelLabel | translate:{dsoName: dso?.name} }}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="confirm btn btn-primary" (click)="confirmPressed()" aria-label="Confirm" ngbAutofocus>
|
||||||
|
{{ confirmLabel | translate:{dsoName: dso?.name} }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -0,0 +1,126 @@
|
|||||||
|
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { ConfirmationModalComponent } from './confirmation-modal.component';
|
||||||
|
|
||||||
|
describe('ConfirmationModalComponent', () => {
|
||||||
|
let component: ConfirmationModalComponent;
|
||||||
|
let fixture: ComponentFixture<ConfirmationModalComponent>;
|
||||||
|
let debugElement: DebugElement;
|
||||||
|
|
||||||
|
const modalStub = jasmine.createSpyObj('modalStub', ['close']);
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot()],
|
||||||
|
declarations: [ConfirmationModalComponent],
|
||||||
|
providers: [
|
||||||
|
{ provide: NgbActiveModal, useValue: modalStub }
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ConfirmationModalComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
debugElement = fixture.debugElement;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('close', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.close();
|
||||||
|
});
|
||||||
|
it('should call the close method on the active modal', () => {
|
||||||
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('confirmPressed', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(component.response, 'next');
|
||||||
|
component.confirmPressed();
|
||||||
|
});
|
||||||
|
it('should call the close method on the active modal', () => {
|
||||||
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('behaviour subject should have true as next', () => {
|
||||||
|
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cancelPressed', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(component.response, 'next');
|
||||||
|
component.cancelPressed();
|
||||||
|
});
|
||||||
|
it('should call the close method on the active modal', () => {
|
||||||
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('behaviour subject should have false as next', () => {
|
||||||
|
expect(component.response.next).toHaveBeenCalledWith(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the click method emits on close button', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
spyOn(component, 'close');
|
||||||
|
debugElement.query(By.css('button.close')).triggerEventHandler('click', {
|
||||||
|
preventDefault: () => {/**/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tick();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('should call the close method on the component', () => {
|
||||||
|
expect(component.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the click method emits on cancel button', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
spyOn(component, 'close');
|
||||||
|
spyOn(component.response, 'next');
|
||||||
|
debugElement.query(By.css('button.cancel')).triggerEventHandler('click', {
|
||||||
|
preventDefault: () => {/**/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tick();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('should call the close method on the component', () => {
|
||||||
|
expect(component.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('behaviour subject should have false as next', () => {
|
||||||
|
expect(component.response.next).toHaveBeenCalledWith(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the click method emits on confirm button', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
spyOn(component, 'close');
|
||||||
|
spyOn(component.response, 'next');
|
||||||
|
debugElement.query(By.css('button.confirm')).triggerEventHandler('click', {
|
||||||
|
preventDefault: () => {/**/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tick();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('should call the close method on the component', () => {
|
||||||
|
expect(component.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('behaviour subject should have true as next', () => {
|
||||||
|
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -0,0 +1,48 @@
|
|||||||
|
import { Component, Input, Output } from '@angular/core';
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { Subject } from 'rxjs/internal/Subject';
|
||||||
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-confirmation-modal',
|
||||||
|
templateUrl: 'confirmation-modal.component.html',
|
||||||
|
})
|
||||||
|
export class ConfirmationModalComponent {
|
||||||
|
@Input() headerLabel: string;
|
||||||
|
@Input() infoLabel: string;
|
||||||
|
@Input() cancelLabel: string;
|
||||||
|
@Input() confirmLabel: string;
|
||||||
|
@Input() dso: DSpaceObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event fired when the cancel or confirm button is clicked, with respectively false or true
|
||||||
|
*/
|
||||||
|
@Output()
|
||||||
|
response: Subject<boolean> = new Subject();
|
||||||
|
|
||||||
|
constructor(protected activeModal: NgbActiveModal) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm the action that led to the modal
|
||||||
|
*/
|
||||||
|
confirmPressed() {
|
||||||
|
this.response.next(true);
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel the action that led to the modal and close modal
|
||||||
|
*/
|
||||||
|
cancelPressed() {
|
||||||
|
this.response.next(false);
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the modal
|
||||||
|
*/
|
||||||
|
close() {
|
||||||
|
this.activeModal.close();
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,7 @@
|
|||||||
class="list-group-item list-group-item-action border-0 list-entry"
|
class="list-group-item list-group-item-action border-0 list-entry"
|
||||||
title="{{ listEntry.indexableObject.name }}"
|
title="{{ listEntry.indexableObject.name }}"
|
||||||
(click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement>
|
(click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement>
|
||||||
<ds-listable-object-component-loader [object]="listEntry" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
<ds-listable-object-component-loader [object]="listEntry" [viewMode]="viewMode"
|
||||||
|
[linkType]=linkTypes.None></ds-listable-object-component-loader>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -13,6 +13,7 @@ import { FormControl } from '@angular/forms';
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { debounceTime, startWith, switchMap } from 'rxjs/operators';
|
import { debounceTime, startWith, switchMap } from 'rxjs/operators';
|
||||||
import { SearchService } from '../../../core/shared/search/search.service';
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
|
import { CollectionElementLinkType } from '../../object-collection/collection-element-link.type';
|
||||||
import { PaginatedSearchOptions } from '../../search/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../search/paginated-search-options.model';
|
||||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
@@ -76,6 +77,11 @@ export class DSOSelectorComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
debounceTime = 500;
|
debounceTime = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The available link types
|
||||||
|
*/
|
||||||
|
linkTypes = CollectionElementLinkType;
|
||||||
|
|
||||||
constructor(private searchService: SearchService) {
|
constructor(private searchService: SearchService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +99,7 @@ export class DSOSelectorComponent implements OnInit {
|
|||||||
return this.searchService.search(
|
return this.searchService.search(
|
||||||
new PaginatedSearchOptions({
|
new PaginatedSearchOptions({
|
||||||
query: query,
|
query: query,
|
||||||
dsoType: this.type,
|
dsoType: this.type !== DSpaceObjectType.DSPACEOBJECT ? this.type : null,
|
||||||
pagination: this.defaultPagination
|
pagination: this.defaultPagination
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
import { Injectable, Input, OnInit } from '@angular/core';
|
import { Injectable, Input, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||||
import { hasValue, isNotEmpty } from '../../empty.util';
|
import { hasValue, isNotEmpty } from '../../empty.util';
|
||||||
|
|
||||||
export enum SelectorActionType {
|
export enum SelectorActionType {
|
||||||
CREATE = 'create',
|
CREATE = 'create',
|
||||||
EDIT = 'edit'
|
EDIT = 'edit',
|
||||||
|
EXPORT_METADATA = 'export-metadata'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +24,7 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit {
|
|||||||
@Input() dsoRD: RemoteData<DSpaceObject>;
|
@Input() dsoRD: RemoteData<DSpaceObject>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the DSO that's being edited or created
|
* The type of the DSO that's being edited, created or exported
|
||||||
*/
|
*/
|
||||||
objectType: DSpaceObjectType;
|
objectType: DSpaceObjectType;
|
||||||
|
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { EditItemSelectorComponent } from './edit-item-selector.component';
|
import { EditItemSelectorComponent } from './edit-item-selector.component';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
|
||||||
import { RouterStub } from '../../../testing/router.stub';
|
import { RouterStub } from '../../../testing/router.stub';
|
||||||
import * as itemRouter from '../../../../+item-page/item-page-routing.module';
|
import * as itemRouter from '../../../../+item-page/item-page-routing.module';
|
||||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
|
@@ -0,0 +1,211 @@
|
|||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { DebugElement, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { NgbActiveModal, NgbModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { METADATA_EXPORT_SCRIPT_NAME, ScriptDataService } from '../../../../core/data/processes/script-data.service';
|
||||||
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { ProcessParameter } from '../../../../process-page/processes/process-parameter.model';
|
||||||
|
import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component';
|
||||||
|
import { TranslateLoaderMock } from '../../../mocks/translate-loader.mock';
|
||||||
|
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
|
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
||||||
|
import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils';
|
||||||
|
import { ExportMetadataSelectorComponent } from './export-metadata-selector.component';
|
||||||
|
|
||||||
|
// No way to add entryComponents yet to testbed; alternative implemented; source: https://stackoverflow.com/questions/41689468/how-to-shallow-test-a-component-with-an-entrycomponents
|
||||||
|
@NgModule({
|
||||||
|
imports: [ NgbModalModule,
|
||||||
|
TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useClass: TranslateLoaderMock
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
exports: [],
|
||||||
|
declarations: [ConfirmationModalComponent],
|
||||||
|
providers: [],
|
||||||
|
entryComponents: [ConfirmationModalComponent],
|
||||||
|
})
|
||||||
|
class ModelTestModule { }
|
||||||
|
|
||||||
|
describe('ExportMetadataSelectorComponent', () => {
|
||||||
|
let component: ExportMetadataSelectorComponent;
|
||||||
|
let fixture: ComponentFixture<ExportMetadataSelectorComponent>;
|
||||||
|
let debugElement: DebugElement;
|
||||||
|
let modalRef;
|
||||||
|
|
||||||
|
let router;
|
||||||
|
let notificationService: NotificationsServiceStub;
|
||||||
|
let scriptService;
|
||||||
|
|
||||||
|
const mockItem = Object.assign(new Item(), {
|
||||||
|
id: 'fake-id',
|
||||||
|
handle: 'fake/handle',
|
||||||
|
lastModified: '2018'
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockCollection: Collection = Object.assign(new Collection(), {
|
||||||
|
id: 'test-collection-1-1',
|
||||||
|
name: 'test-collection-1',
|
||||||
|
handle: 'fake/test-collection-1',
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockCommunity = Object.assign(new Community(), {
|
||||||
|
id: 'test-uuid',
|
||||||
|
handle: 'fake/test-community-1',
|
||||||
|
});
|
||||||
|
|
||||||
|
const itemRD = createSuccessfulRemoteDataObject(mockItem);
|
||||||
|
const modalStub = jasmine.createSpyObj('modalStub', ['close']);
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
notificationService = new NotificationsServiceStub();
|
||||||
|
router = jasmine.createSpyObj('router', {
|
||||||
|
navigateByUrl: jasmine.createSpy('navigateByUrl')
|
||||||
|
});
|
||||||
|
scriptService = jasmine.createSpyObj('scriptService',
|
||||||
|
{
|
||||||
|
invoke: observableOf({
|
||||||
|
response:
|
||||||
|
{
|
||||||
|
isSuccessful: true,
|
||||||
|
resourceSelfLinks: ['https://localhost:8080/api/core/processes/45']
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), ModelTestModule],
|
||||||
|
declarations: [ExportMetadataSelectorComponent],
|
||||||
|
providers: [
|
||||||
|
{ provide: NgbActiveModal, useValue: modalStub },
|
||||||
|
{ provide: NotificationsService, useValue: notificationService },
|
||||||
|
{ provide: ScriptDataService, useValue: scriptService },
|
||||||
|
{
|
||||||
|
provide: ActivatedRoute,
|
||||||
|
useValue: {
|
||||||
|
root: {
|
||||||
|
snapshot: {
|
||||||
|
data: {
|
||||||
|
dso: itemRD,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: Router, useValue: router
|
||||||
|
}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ExportMetadataSelectorComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
debugElement = fixture.debugElement;
|
||||||
|
const modalService = TestBed.get(NgbModal);
|
||||||
|
modalRef = modalService.open(ConfirmationModalComponent);
|
||||||
|
modalRef.componentInstance.response = observableOf(true);
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if item is selected', () => {
|
||||||
|
let scriptRequestSucceeded;
|
||||||
|
beforeEach((done) => {
|
||||||
|
component.navigate(mockItem).subscribe((succeeded: boolean) => {
|
||||||
|
scriptRequestSucceeded = succeeded;
|
||||||
|
done()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should show error notification', () => {
|
||||||
|
expect(notificationService.error).toHaveBeenCalled();
|
||||||
|
expect(scriptRequestSucceeded).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if collection is selected', () => {
|
||||||
|
let scriptRequestSucceeded;
|
||||||
|
beforeEach((done) => {
|
||||||
|
spyOn((component as any).modalService, 'open').and.returnValue(modalRef);
|
||||||
|
component.navigate(mockCollection).subscribe((succeeded: boolean) => {
|
||||||
|
scriptRequestSucceeded = succeeded;
|
||||||
|
done()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('metadata-export script is invoked with its -i handle and -f uuid.csv', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-i', value: mockCollection.handle }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: mockCollection.uuid + '.csv' }),
|
||||||
|
];
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_EXPORT_SCRIPT_NAME, parameterValues, []);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(scriptRequestSucceeded).toBeTrue();
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/45');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if community is selected', () => {
|
||||||
|
let scriptRequestSucceeded;
|
||||||
|
beforeEach((done) => {
|
||||||
|
spyOn((component as any).modalService, 'open').and.returnValue(modalRef);
|
||||||
|
component.navigate(mockCommunity).subscribe((succeeded: boolean) => {
|
||||||
|
scriptRequestSucceeded = succeeded;
|
||||||
|
done()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('metadata-export script is invoked with its -i handle and -f uuid.csv', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-i', value: mockCommunity.handle }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: mockCommunity.uuid + '.csv' }),
|
||||||
|
];
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_EXPORT_SCRIPT_NAME, parameterValues, []);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(scriptRequestSucceeded).toBeTrue();
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/45');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if community/collection is selected; but script invoke fails', () => {
|
||||||
|
let scriptRequestSucceeded;
|
||||||
|
beforeEach((done) => {
|
||||||
|
spyOn((component as any).modalService, 'open').and.returnValue(modalRef);
|
||||||
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
spyOn(scriptService, 'invoke').and.returnValue(observableOf({
|
||||||
|
response:
|
||||||
|
{
|
||||||
|
isSuccessful: false,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
component.navigate(mockCommunity).subscribe((succeeded: boolean) => {
|
||||||
|
scriptRequestSucceeded = succeeded;
|
||||||
|
done()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('error notification is shown', () => {
|
||||||
|
expect(scriptRequestSucceeded).toBeFalse();
|
||||||
|
expect(notificationService.error).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -0,0 +1,106 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { take, map, switchMap } from 'rxjs/operators';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { METADATA_EXPORT_SCRIPT_NAME, ScriptDataService } from '../../../../core/data/processes/script-data.service';
|
||||||
|
import { RequestEntry } from '../../../../core/data/request.reducer';
|
||||||
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
|
import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model';
|
||||||
|
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||||
|
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { ProcessParameter } from '../../../../process-page/processes/process-parameter.model';
|
||||||
|
import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component';
|
||||||
|
import { isNotEmpty } from '../../../empty.util';
|
||||||
|
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
|
import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils';
|
||||||
|
import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../dso-selector-modal-wrapper.component';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component to wrap a list of existing dso's inside a modal
|
||||||
|
* Used to choose a dso from to export metadata of
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-export-metadata-selector',
|
||||||
|
templateUrl: '../dso-selector-modal-wrapper.component.html',
|
||||||
|
})
|
||||||
|
export class ExportMetadataSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit {
|
||||||
|
objectType = DSpaceObjectType.DSPACEOBJECT;
|
||||||
|
selectorType = DSpaceObjectType.DSPACEOBJECT;
|
||||||
|
action = SelectorActionType.EXPORT_METADATA;
|
||||||
|
|
||||||
|
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router,
|
||||||
|
protected notificationsService: NotificationsService, protected translationService: TranslateService,
|
||||||
|
protected scriptDataService: ScriptDataService,
|
||||||
|
private modalService: NgbModal) {
|
||||||
|
super(activeModal, route);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the dso is a collection or community: start export-metadata script & navigate to process if successful
|
||||||
|
* Otherwise show error message
|
||||||
|
*/
|
||||||
|
navigate(dso: DSpaceObject): Observable<boolean> {
|
||||||
|
if (dso instanceof Collection || dso instanceof Community) {
|
||||||
|
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||||
|
modalRef.componentInstance.dso = dso;
|
||||||
|
modalRef.componentInstance.headerLabel = 'confirmation-modal.export-metadata.header';
|
||||||
|
modalRef.componentInstance.infoLabel = 'confirmation-modal.export-metadata.info';
|
||||||
|
modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-metadata.cancel';
|
||||||
|
modalRef.componentInstance.confirmLabel = 'confirmation-modal.export-metadata.confirm';
|
||||||
|
const resp$ = modalRef.componentInstance.response.pipe(switchMap((confirm: boolean) => {
|
||||||
|
if (confirm) {
|
||||||
|
const startScriptSucceeded$ = this.startScriptNotifyAndRedirect(dso, dso.handle);
|
||||||
|
return startScriptSucceeded$.pipe(
|
||||||
|
switchMap((r: boolean) => {
|
||||||
|
return observableOf(r);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
const modalRefExport = this.modalService.open(ExportMetadataSelectorComponent);
|
||||||
|
modalRefExport.componentInstance.dsoRD = createSuccessfulRemoteDataObject(dso);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
resp$.subscribe();
|
||||||
|
return resp$;
|
||||||
|
} else {
|
||||||
|
this.notificationsService.error(this.translationService.get('dso-selector.export-metadata.notValidDSO'));
|
||||||
|
return observableOf(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start export-metadata script of dso & navigate to process if successful
|
||||||
|
* Otherwise show error message
|
||||||
|
* @param dso Dso to export
|
||||||
|
*/
|
||||||
|
private startScriptNotifyAndRedirect(dso: DSpaceObject, handle: string): Observable<boolean> {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-i', value: handle }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: dso.uuid + '.csv' }),
|
||||||
|
];
|
||||||
|
return this.scriptDataService.invoke(METADATA_EXPORT_SCRIPT_NAME, parameterValues, [])
|
||||||
|
.pipe(
|
||||||
|
take(1),
|
||||||
|
map((requestEntry: RequestEntry) => {
|
||||||
|
if (requestEntry.response.isSuccessful) {
|
||||||
|
const title = this.translationService.get('process.new.notification.success.title');
|
||||||
|
const content = this.translationService.get('process.new.notification.success.content');
|
||||||
|
this.notificationsService.success(title, content);
|
||||||
|
const response: any = requestEntry.response;
|
||||||
|
if (isNotEmpty(response.resourceSelfLinks)) {
|
||||||
|
const processNumber = response.resourceSelfLinks[0].split('/').pop();
|
||||||
|
this.router.navigateByUrl('/processes/' + processNumber);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
const title = this.translationService.get('process.new.notification.error.title');
|
||||||
|
const content = this.translationService.get('process.new.notification.error.content');
|
||||||
|
this.notificationsService.error(title, content);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,28 @@
|
|||||||
|
<div ng2FileDrop
|
||||||
|
class="ds-document-drop-zone position-fixed h-100 w-100"
|
||||||
|
[class.ds-document-drop-zone-active]="(isOverDocumentDropZone | async)"
|
||||||
|
[uploader]="uploader"
|
||||||
|
(onFileDrop)="setFile($event)"
|
||||||
|
(fileOver)="fileOverDocument($event)">
|
||||||
|
</div>
|
||||||
|
<div *ngIf="(isOverDocumentDropZone | async)"
|
||||||
|
class="ds-document-drop-zone-inner position-fixed h-100 w-100 p-2">
|
||||||
|
<div
|
||||||
|
class="ds-document-drop-zone-inner-content position-relative d-flex flex-column justify-content-center text-center h-100 w-100">
|
||||||
|
<p class="text-primary">{{ dropMessageLabel | translate}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="well ds-base-drop-zone mt-1 mb-3 text-muted p-2">
|
||||||
|
<p class="text-center m-0 p-0 d-flex justify-content-center align-items-center"
|
||||||
|
*ngIf="fileObject!=null"> {{ fileObject.name }} </p>
|
||||||
|
<p class="text-center m-0 p-0 d-flex justify-content-center align-items-center">
|
||||||
|
<span><i class="fas fa-cloud-upload"
|
||||||
|
aria-hidden="true"></i> {{ (fileObject == null ? dropMessageLabel : dropMessageLabelReplacement) | translate}} {{'uploader.or' | translate}}</span>
|
||||||
|
<label class="btn btn-link m-0 p-0 ml-1">
|
||||||
|
<input class="form-control-file d-none" requireFile #file="ngModel" type="file" name="file-upload"
|
||||||
|
id="file-upload"
|
||||||
|
[ngModel]="fileObject" (ngModelChange)="setFile($event)">
|
||||||
|
{{'uploader.browse' | translate}}
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
</div>
|
@@ -0,0 +1,92 @@
|
|||||||
|
import { Component, EventEmitter, HostListener, Input, OnInit, Output } from '@angular/core';
|
||||||
|
import { uniqueId } from 'lodash';
|
||||||
|
import { FileUploader } from 'ng2-file-upload';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { UploaderOptions } from '../uploader/uploader-options.model';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component to have a file dropzone without that dropping/choosing a file in browse automatically triggers
|
||||||
|
* the uploader, instead an event is emitted with the file that was added.
|
||||||
|
*
|
||||||
|
* Here only one file is allowed to be selected, so if one is selected/dropped the message changes to a
|
||||||
|
* replace message.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-file-dropzone-no-uploader',
|
||||||
|
templateUrl: './file-dropzone-no-uploader.component.html',
|
||||||
|
styleUrls: ['./file-dropzone-no-uploader.scss']
|
||||||
|
})
|
||||||
|
export class FileDropzoneNoUploaderComponent implements OnInit {
|
||||||
|
|
||||||
|
public isOverDocumentDropZone: Observable<boolean>;
|
||||||
|
public uploader: FileUploader;
|
||||||
|
public uploaderId: string;
|
||||||
|
|
||||||
|
@Input() dropMessageLabel: string;
|
||||||
|
@Input() dropMessageLabelReplacement: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function to call when file is added
|
||||||
|
*/
|
||||||
|
@Output() onFileAdded: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The uploader configuration options
|
||||||
|
* @type {UploaderOptions}
|
||||||
|
*/
|
||||||
|
uploadFilesOptions: UploaderOptions = Object.assign(new UploaderOptions(), {
|
||||||
|
// URL needs to contain something to not produce any errors. We are using onFileDrop; not the uploader
|
||||||
|
url: 'placeholder',
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current value of the file
|
||||||
|
*/
|
||||||
|
fileObject: File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method provided by Angular. Invoked after the constructor.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.uploaderId = 'ds-drag-and-drop-uploader' + uniqueId();
|
||||||
|
this.isOverDocumentDropZone = observableOf(false);
|
||||||
|
this.uploader = new FileUploader({
|
||||||
|
// required, but using onFileDrop, not uploader
|
||||||
|
url: 'placeholder',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:drop', ['$event'])
|
||||||
|
onDrop(event: any) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:dragover', ['$event'])
|
||||||
|
onDragOver(event: any) {
|
||||||
|
// Show drop area on the page
|
||||||
|
event.preventDefault();
|
||||||
|
if ((event.target as any).tagName !== 'HTML') {
|
||||||
|
this.isOverDocumentDropZone = observableOf(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when files are dragged on the window document drop area.
|
||||||
|
*/
|
||||||
|
public fileOverDocument(isOver: boolean) {
|
||||||
|
if (!isOver) {
|
||||||
|
this.isOverDocumentDropZone = observableOf(isOver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set file
|
||||||
|
* @param files
|
||||||
|
*/
|
||||||
|
setFile(files) {
|
||||||
|
this.fileObject = files.length > 0 ? files[0] : undefined;
|
||||||
|
this.onFileAdded.emit(this.fileObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
.ds-base-drop-zone {
|
||||||
|
border: 2px dashed $gray-600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ds-document-drop-zone {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ds-document-drop-zone-active {
|
||||||
|
z-index: $drop-zone-area-z-index !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ds-document-drop-zone-inner {
|
||||||
|
background-color: rgba($white, 0.7);
|
||||||
|
z-index: $drop-zone-area-inner-z-index;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ds-document-drop-zone-inner-content {
|
||||||
|
border: 4px dashed map-get($theme-colors, primary);
|
||||||
|
z-index: $drop-zone-area-inner-z-index;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ds-document-drop-zone-inner-content p {
|
||||||
|
font-size: ($font-size-lg * 2.5);
|
||||||
|
}
|
@@ -1,13 +1,15 @@
|
|||||||
import { Component, Injector } from '@angular/core';
|
import { Component, Injector, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { MenuService } from '../menu.service';
|
import { MenuService } from '../menu.service';
|
||||||
import { MenuSection } from '../menu.reducer';
|
import { MenuSection } from '../menu.reducer';
|
||||||
import { getComponentForMenuItemType } from '../menu-item.decorator';
|
import { getComponentForMenuItemType } from '../menu-item.decorator';
|
||||||
import { MenuID, MenuItemType } from '../initial-menus-state';
|
import { MenuID, MenuItemType } from '../initial-menus-state';
|
||||||
import { hasNoValue } from '../../empty.util';
|
import { hasNoValue, hasValue } from '../../empty.util';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { MenuItemModel } from '../menu-item/models/menu-item.model';
|
import { MenuItemModel } from '../menu-item/models/menu-item.model';
|
||||||
import { distinctUntilChanged } from 'rxjs/operators';
|
import { distinctUntilChanged, switchMap } from 'rxjs/operators';
|
||||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||||
|
import { Subscription } from 'rxjs/internal/Subscription';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic implementation of a menu section's component
|
* A basic implementation of a menu section's component
|
||||||
@@ -16,7 +18,7 @@ import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
|||||||
selector: 'ds-menu-section',
|
selector: 'ds-menu-section',
|
||||||
template: ''
|
template: ''
|
||||||
})
|
})
|
||||||
export class MenuSectionComponent {
|
export class MenuSectionComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observable that emits whether or not this section is currently active
|
* Observable that emits whether or not this section is currently active
|
||||||
@@ -28,20 +30,24 @@ export class MenuSectionComponent {
|
|||||||
*/
|
*/
|
||||||
menuID: MenuID;
|
menuID: MenuID;
|
||||||
|
|
||||||
/**
|
|
||||||
* List of Injectors for each dynamically rendered menu item of this section
|
|
||||||
*/
|
|
||||||
itemInjectors: Map<string, Injector> = new Map<string, Injector>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of child Components for each dynamically rendered menu item of this section
|
|
||||||
*/
|
|
||||||
itemComponents: Map<string, GenericConstructor<MenuSectionComponent>> = new Map<string, GenericConstructor<MenuSectionComponent>>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of available subsections in this section
|
* List of available subsections in this section
|
||||||
*/
|
*/
|
||||||
subSections: Observable<MenuSection[]>;
|
subSections$: Observable<MenuSection[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of components and injectors for each dynamically rendered menu section
|
||||||
|
*/
|
||||||
|
sectionMap$: BehaviorSubject<Map<string, {
|
||||||
|
injector: Injector,
|
||||||
|
component: GenericConstructor<MenuSectionComponent>
|
||||||
|
}>> = new BehaviorSubject(new Map());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
constructor(public section: MenuSection, protected menuService: MenuService, protected injector: Injector) {
|
constructor(public section: MenuSection, protected menuService: MenuService, protected injector: Injector) {
|
||||||
}
|
}
|
||||||
@@ -85,15 +91,34 @@ export class MenuSectionComponent {
|
|||||||
* Method for initializing all injectors and component constructors for the menu items in this section
|
* Method for initializing all injectors and component constructors for the menu items in this section
|
||||||
*/
|
*/
|
||||||
private initializeInjectorData() {
|
private initializeInjectorData() {
|
||||||
this.itemInjectors.set(this.section.id, this.getItemModelInjector(this.section.model));
|
this.updateSectionMap(
|
||||||
this.itemComponents.set(this.section.id, this.getMenuItemComponent(this.section.model));
|
this.section.id,
|
||||||
this.subSections = this.menuService.getSubSectionsByParentID(this.menuID, this.section.id);
|
this.getItemModelInjector(this.section.model),
|
||||||
this.subSections.subscribe((sections: MenuSection[]) => {
|
this.getMenuItemComponent(this.section.model)
|
||||||
sections.forEach((section: MenuSection) => {
|
);
|
||||||
this.itemInjectors.set(section.id, this.getItemModelInjector(section.model));
|
this.subSections$ = this.menuService.getSubSectionsByParentID(this.menuID, this.section.id);
|
||||||
this.itemComponents.set(section.id, this.getMenuItemComponent(section.model));
|
this.subs.push(
|
||||||
|
this.subSections$.pipe(
|
||||||
|
// if you return an array from a switchMap it will emit each element as a separate event.
|
||||||
|
// So this switchMap is equivalent to a subscribe with a forEach inside
|
||||||
|
switchMap((sections: MenuSection[]) => sections)
|
||||||
|
).subscribe((section: MenuSection) => {
|
||||||
|
this.updateSectionMap(
|
||||||
|
section.id,
|
||||||
|
this.getItemModelInjector(section.model),
|
||||||
|
this.getMenuItemComponent(section.model)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the sectionMap
|
||||||
|
*/
|
||||||
|
private updateSectionMap(id, injector, component) {
|
||||||
|
const nextMap = this.sectionMap$.getValue();
|
||||||
|
nextMap.set(id, { injector, component });
|
||||||
|
this.sectionMap$.next(nextMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,4 +149,12 @@ export class MenuSectionComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsubscribe from open subscriptions
|
||||||
|
*/
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.subs
|
||||||
|
.filter((subscription) => hasValue(subscription))
|
||||||
|
.forEach((subscription) => subscription.unsubscribe());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,14 @@ import { Observable } from 'rxjs/internal/Observable';
|
|||||||
import { MenuService } from './menu.service';
|
import { MenuService } from './menu.service';
|
||||||
import { MenuID } from './initial-menus-state';
|
import { MenuID } from './initial-menus-state';
|
||||||
import { MenuSection } from './menu.reducer';
|
import { MenuSection } from './menu.reducer';
|
||||||
import { distinctUntilChanged, first, map } from 'rxjs/operators';
|
import { distinctUntilChanged, map, switchMap } from 'rxjs/operators';
|
||||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { MenuSectionComponent } from './menu-section/menu-section.component';
|
import { MenuSectionComponent } from './menu-section/menu-section.component';
|
||||||
import { getComponentForMenu } from './menu-section.decorator';
|
import { getComponentForMenu } from './menu-section.decorator';
|
||||||
import { Subscription } from 'rxjs/internal/Subscription';
|
import { Subscription } from 'rxjs/internal/Subscription';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { compareArraysUsingIds } from '../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic implementation of a MenuComponent
|
* A basic implementation of a MenuComponent
|
||||||
@@ -44,14 +46,12 @@ export class MenuComponent implements OnInit, OnDestroy {
|
|||||||
sections: Observable<MenuSection[]>;
|
sections: Observable<MenuSection[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of Injectors for each dynamically rendered menu section
|
* Map of components and injectors for each dynamically rendered menu section
|
||||||
*/
|
*/
|
||||||
sectionInjectors: Map<string, Injector> = new Map<string, Injector>();
|
sectionMap$: BehaviorSubject<Map<string, {
|
||||||
|
injector: Injector,
|
||||||
/**
|
component: GenericConstructor<MenuSectionComponent>
|
||||||
* List of child Components for each dynamically rendered menu section
|
}>> = new BehaviorSubject(new Map());
|
||||||
*/
|
|
||||||
sectionComponents: Map<string, GenericConstructor<MenuSectionComponent>> = new Map<string, GenericConstructor<MenuSectionComponent>>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent unnecessary rerendering
|
* Prevent unnecessary rerendering
|
||||||
@@ -79,13 +79,25 @@ export class MenuComponent implements OnInit, OnDestroy {
|
|||||||
this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID);
|
this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID);
|
||||||
this.menuPreviewCollapsed = this.menuService.isMenuPreviewCollapsed(this.menuID);
|
this.menuPreviewCollapsed = this.menuService.isMenuPreviewCollapsed(this.menuID);
|
||||||
this.menuVisible = this.menuService.isMenuVisible(this.menuID);
|
this.menuVisible = this.menuService.isMenuVisible(this.menuID);
|
||||||
this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(distinctUntilChanged((x, y) => JSON.stringify(x) === JSON.stringify(y)));
|
this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(distinctUntilChanged(compareArraysUsingIds()));
|
||||||
this.subs.push(this.sections.subscribe((sections: MenuSection[]) => {
|
this.subs.push(
|
||||||
sections.forEach((section: MenuSection) => {
|
this.sections.pipe(
|
||||||
this.sectionInjectors.set(section.id, this.getSectionDataInjector(section));
|
// if you return an array from a switchMap it will emit each element as a separate event.
|
||||||
this.getSectionComponent(section).pipe(first()).subscribe((constr) => this.sectionComponents.set(section.id, constr));
|
// So this switchMap is equivalent to a subscribe with a forEach inside
|
||||||
});
|
switchMap((sections: MenuSection[]) => sections),
|
||||||
}));
|
switchMap((section: MenuSection) => this.getSectionComponent(section).pipe(
|
||||||
|
map((component: GenericConstructor<MenuSectionComponent>) => ({ section, component }))
|
||||||
|
)),
|
||||||
|
distinctUntilChanged((x,y) => x.section.id === y.section.id)
|
||||||
|
).subscribe(({ section, component}) => {
|
||||||
|
const nextMap = this.sectionMap$.getValue();
|
||||||
|
nextMap.set(section.id, {
|
||||||
|
injector: this.getSectionDataInjector(section),
|
||||||
|
component
|
||||||
|
});
|
||||||
|
this.sectionMap$.next(nextMap);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,6 +18,9 @@ import { MomentModule } from 'ngx-moment';
|
|||||||
import { TooltipModule } from 'ngx-bootstrap';
|
import { TooltipModule } from 'ngx-bootstrap';
|
||||||
|
|
||||||
import { ComcolRoleComponent } from './comcol-forms/edit-comcol-page/comcol-role/comcol-role.component';
|
import { ComcolRoleComponent } from './comcol-forms/edit-comcol-page/comcol-role/comcol-role.component';
|
||||||
|
import { ConfirmationModalComponent } from './confirmation-modal/confirmation-modal.component';
|
||||||
|
import { ExportMetadataSelectorComponent } from './dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
||||||
|
import { FileDropzoneNoUploaderComponent } from './file-dropzone-no-uploader/file-dropzone-no-uploader.component';
|
||||||
import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component';
|
import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component';
|
||||||
import { EnumKeysPipe } from './utils/enum-keys-pipe';
|
import { EnumKeysPipe } from './utils/enum-keys-pipe';
|
||||||
import { FileSizePipe } from './utils/file-size-pipe';
|
import { FileSizePipe } from './utils/file-size-pipe';
|
||||||
@@ -305,6 +308,7 @@ const COMPONENTS = [
|
|||||||
ThumbnailComponent,
|
ThumbnailComponent,
|
||||||
GridThumbnailComponent,
|
GridThumbnailComponent,
|
||||||
UploaderComponent,
|
UploaderComponent,
|
||||||
|
FileDropzoneNoUploaderComponent,
|
||||||
ItemListPreviewComponent,
|
ItemListPreviewComponent,
|
||||||
MyDSpaceItemStatusComponent,
|
MyDSpaceItemStatusComponent,
|
||||||
ItemSubmitterComponent,
|
ItemSubmitterComponent,
|
||||||
@@ -396,6 +400,8 @@ const COMPONENTS = [
|
|||||||
GroupSearchBoxComponent,
|
GroupSearchBoxComponent,
|
||||||
FileDownloadLinkComponent,
|
FileDownloadLinkComponent,
|
||||||
CollectionDropdownComponent,
|
CollectionDropdownComponent,
|
||||||
|
ExportMetadataSelectorComponent,
|
||||||
|
ConfirmationModalComponent,
|
||||||
VocabularyTreeviewComponent
|
VocabularyTreeviewComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -472,8 +478,10 @@ const ENTRY_COMPONENTS = [
|
|||||||
ClaimedTaskActionsReturnToPoolComponent,
|
ClaimedTaskActionsReturnToPoolComponent,
|
||||||
ClaimedTaskActionsEditMetadataComponent,
|
ClaimedTaskActionsEditMetadataComponent,
|
||||||
FileDownloadLinkComponent,
|
FileDownloadLinkComponent,
|
||||||
VocabularyTreeviewComponent,
|
CurationFormComponent,
|
||||||
CurationFormComponent
|
ExportMetadataSelectorComponent,
|
||||||
|
ConfirmationModalComponent
|
||||||
|
VocabularyTreeviewComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
const SHARED_ITEM_PAGE_COMPONENTS = [
|
const SHARED_ITEM_PAGE_COMPONENTS = [
|
||||||
|
@@ -442,6 +442,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"admin.metadata-import.breadcrumbs": "Import Metadata",
|
||||||
|
|
||||||
|
"admin.metadata-import.title": "Import Metadata",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.header": "Import Metadata",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.help": "You can drop or browse CSV files that contain batch metadata operations on files here",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.dropMsg": "Drop a metadata CSV to import",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.dropMsgReplace": "Drop to replace the metadata CSV to import",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.button.return": "Return",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.button.proceed": "Proceed",
|
||||||
|
|
||||||
|
"admin.metadata-import.page.error.addFile": "Select file first!",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"auth.errors.invalid-user": "Invalid email address or password.",
|
"auth.errors.invalid-user": "Invalid email address or password.",
|
||||||
|
|
||||||
@@ -967,12 +987,26 @@
|
|||||||
|
|
||||||
"dso-selector.edit.item.head": "Edit item",
|
"dso-selector.edit.item.head": "Edit item",
|
||||||
|
|
||||||
|
"dso-selector.export-metadata.dspaceobject.head": "Export metadata from",
|
||||||
|
|
||||||
|
"dso-selector.export-metadata.notValidDSO": "You can only export metadata for collections and communities",
|
||||||
|
|
||||||
"dso-selector.no-results": "No {{ type }} found",
|
"dso-selector.no-results": "No {{ type }} found",
|
||||||
|
|
||||||
"dso-selector.placeholder": "Search for a {{ type }}",
|
"dso-selector.placeholder": "Search for a {{ type }}",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"confirmation-modal.export-metadata.header": "Export metadata for {{ dsoName }}",
|
||||||
|
|
||||||
|
"confirmation-modal.export-metadata.info": "Are you sure you want to export metadata for {{ dsoName }}",
|
||||||
|
|
||||||
|
"confirmation-modal.export-metadata.cancel": "Cancel",
|
||||||
|
|
||||||
|
"confirmation-modal.export-metadata.confirm": "Export",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"error.bitstream": "Error fetching bitstream",
|
"error.bitstream": "Error fetching bitstream",
|
||||||
|
|
||||||
"error.browse-by": "Error fetching items",
|
"error.browse-by": "Error fetching items",
|
||||||
@@ -1566,6 +1600,13 @@
|
|||||||
|
|
||||||
"item.page.uri": "URI",
|
"item.page.uri": "URI",
|
||||||
|
|
||||||
|
"item.page.bitstreams.view-more": "Show more",
|
||||||
|
|
||||||
|
"item.page.bitstreams.collapse": "Collapse",
|
||||||
|
|
||||||
|
"item.page.filesection.original.bundle" : "Original bundle",
|
||||||
|
|
||||||
|
"item.page.filesection.license.bundle" : "License bundle",
|
||||||
|
|
||||||
|
|
||||||
"item.select.confirm": "Confirm selected",
|
"item.select.confirm": "Confirm selected",
|
||||||
@@ -3112,6 +3153,6 @@
|
|||||||
|
|
||||||
"workflow-item.send-back.button.cancel": "Cancel",
|
"workflow-item.send-back.button.cancel": "Cancel",
|
||||||
|
|
||||||
"workflow-item.send-back.button.confirm": "Send back",
|
"workflow-item.send-back.button.confirm": "Send back"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
151
src/robots.txt
Normal file
151
src/robots.txt
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
# The URL to the DSpace sitemaps
|
||||||
|
# XML sitemap is listed first as it is preferred by most search engines
|
||||||
|
Sitemap: /sitemap_index.xml
|
||||||
|
Sitemap: /sitemap_index.html
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Default Access Group
|
||||||
|
# (NOTE: blank lines are not allowable in a group record)
|
||||||
|
##########################
|
||||||
|
User-agent: *
|
||||||
|
# Disable access to Discovery search and filters; admin pages; processes; submission; workspace; workflow & profile page
|
||||||
|
Disallow: /search
|
||||||
|
Disallow: /admin/*
|
||||||
|
Disallow: /processes
|
||||||
|
Disallow: /submit
|
||||||
|
Disallow: /workspaceitems
|
||||||
|
Disallow: /profile
|
||||||
|
Disallow: /workflowitems
|
||||||
|
|
||||||
|
# Optionally uncomment the following line ONLY if sitemaps are working
|
||||||
|
# and you have verified that your site is being indexed correctly.
|
||||||
|
# Disallow: /browse/*
|
||||||
|
#
|
||||||
|
# If you have configured DSpace (Solr-based) Statistics to be publicly
|
||||||
|
# accessible, then you may not want this content to be indexed
|
||||||
|
# Disallow: /statistics
|
||||||
|
#
|
||||||
|
# You also may wish to disallow access to the following paths, in order
|
||||||
|
# to stop web spiders from accessing user-based content
|
||||||
|
# Disallow: /contact
|
||||||
|
# Disallow: /feedback
|
||||||
|
# Disallow: /forgot
|
||||||
|
# Disallow: /login
|
||||||
|
# Disallow: /register
|
||||||
|
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Section for misbehaving bots
|
||||||
|
# The following directives to block specific robots were borrowed from Wikipedia's robots.txt
|
||||||
|
##############################
|
||||||
|
|
||||||
|
# advertising-related bots:
|
||||||
|
User-agent: Mediapartners-Google*
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
# Crawlers that are kind enough to obey, but which we'd rather not have
|
||||||
|
# unless they're feeding search engines.
|
||||||
|
User-agent: UbiCrawler
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: DOC
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Zao
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
# Some bots are known to be trouble, particularly those designed to copy
|
||||||
|
# entire sites. Please obey robots.txt.
|
||||||
|
User-agent: sitecheck.internetseer.com
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Zealbot
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: MSIECrawler
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: SiteSnagger
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: WebStripper
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: WebCopier
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Fetch
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Offline Explorer
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Teleport
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: TeleportPro
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: WebZIP
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: linko
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: HTTrack
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Microsoft.URL.Control
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Xenu
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: larbin
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: libwww
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: ZyBORG
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-agent: Download Ninja
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
# Misbehaving: requests much too fast:
|
||||||
|
User-agent: fast
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
#
|
||||||
|
# If your DSpace is going down because of someone using recursive wget,
|
||||||
|
# you can activate the following rule.
|
||||||
|
#
|
||||||
|
# If your own faculty is bringing down your dspace with recursive wget,
|
||||||
|
# you can advise them to use the --wait option to set the delay between hits.
|
||||||
|
#
|
||||||
|
#User-agent: wget
|
||||||
|
#Disallow: /
|
||||||
|
|
||||||
|
#
|
||||||
|
# The 'grub' distributed client has been *very* poorly behaved.
|
||||||
|
#
|
||||||
|
User-agent: grub-client
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
#
|
||||||
|
# Doesn't follow robots.txt anyway, but...
|
||||||
|
#
|
||||||
|
User-agent: k2spider
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
#
|
||||||
|
# Hits many times per second, not acceptable
|
||||||
|
# http://www.nameprotect.com/botinfo.html
|
||||||
|
User-agent: NPBot
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
# A capture bot, downloads gazillions of pages with no public benefit
|
||||||
|
# http://www.webreaper.net/
|
||||||
|
User-agent: WebReaper
|
||||||
|
Disallow: /
|
@@ -1,45 +0,0 @@
|
|||||||
const webpackMerge = require('webpack-merge');
|
|
||||||
|
|
||||||
const prodPartial = require('./webpack/webpack.prod');
|
|
||||||
|
|
||||||
module.exports = (env, options) => {
|
|
||||||
env = env || {};
|
|
||||||
const commonPartial = require('./webpack/webpack.common')(env);
|
|
||||||
const clientPartial = require('./webpack/webpack.client')(env);
|
|
||||||
const { getAotPlugin } = require('./webpack/webpack.aot')(env);
|
|
||||||
const { getServerWebpackPartial } = require('./webpack/webpack.server')(env);
|
|
||||||
|
|
||||||
if (env.aot) {
|
|
||||||
console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const serverPartial = getServerWebpackPartial(env.aot);
|
|
||||||
|
|
||||||
let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
|
|
||||||
plugins: [
|
|
||||||
getAotPlugin('server', !!env.aot)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
|
|
||||||
plugins: [
|
|
||||||
getAotPlugin('client', !!env.aot)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
if (options.mode === 'production') {
|
|
||||||
serverConfig = webpackMerge({}, serverConfig, prodPartial);
|
|
||||||
clientConfig = webpackMerge({}, clientConfig, prodPartial);
|
|
||||||
}
|
|
||||||
|
|
||||||
const configs = [];
|
|
||||||
|
|
||||||
if (!env.aot) {
|
|
||||||
configs.push(clientConfig, serverConfig);
|
|
||||||
} else if (env.client) {
|
|
||||||
configs.push(clientConfig);
|
|
||||||
} else if (env.server) {
|
|
||||||
configs.push(serverConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configs;
|
|
||||||
};
|
|
8
webpack/webpack.browser.ts
Normal file
8
webpack/webpack.browser.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { commonExports } from './webpack.common';
|
||||||
|
|
||||||
|
module.exports = Object.assign({}, commonExports, {
|
||||||
|
target: 'web',
|
||||||
|
node: {
|
||||||
|
module: 'empty'
|
||||||
|
}
|
||||||
|
});
|
@@ -21,11 +21,13 @@ export const copyWebpackOptions = [
|
|||||||
}, {
|
}, {
|
||||||
from: path.join(__dirname, '..', 'src', 'assets', 'i18n'),
|
from: path.join(__dirname, '..', 'src', 'assets', 'i18n'),
|
||||||
to: path.join('assets', 'i18n')
|
to: path.join('assets', 'i18n')
|
||||||
|
}, {
|
||||||
|
from: path.join(__dirname, '..', 'src', 'robots.txt'),
|
||||||
|
to: path.join('robots.txt')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const commonExports = {
|
export const commonExports = {
|
||||||
target: 'web',
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new CopyWebpackPlugin(copyWebpackOptions),
|
new CopyWebpackPlugin(copyWebpackOptions),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
@@ -37,9 +39,6 @@ export const commonExports = {
|
|||||||
defaultAttribute: 'defer'
|
defaultAttribute: 'defer'
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
node: {
|
|
||||||
module: 'empty'
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@@ -99,5 +98,3 @@ export const commonExports = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = commonExports;
|
|
||||||
|
@@ -1,48 +1,12 @@
|
|||||||
|
import { commonExports } from './webpack.common';
|
||||||
|
import { buildRoot, projectRoot } from './helpers';
|
||||||
|
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
||||||
const CompressionPlugin = require('compression-webpack-plugin');
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
|
||||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
||||||
const cssnano = require('cssnano');
|
|
||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require('webpack-node-externals');
|
||||||
|
|
||||||
import { buildRoot, globalCSSImports, projectRoot, theme, themedTest, themedUse, themePath } from './helpers';
|
module.exports = Object.assign({}, commonExports, {
|
||||||
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
const ScriptExtPlugin = require('script-ext-html-webpack-plugin');
|
|
||||||
|
|
||||||
export const copyWebpackOptions = [
|
|
||||||
{
|
|
||||||
from: path.join(__dirname, '..', 'node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'),
|
|
||||||
to: path.join('assets', 'fonts'),
|
|
||||||
force: undefined
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: path.join(__dirname, '..', 'src', 'assets', 'fonts'),
|
|
||||||
to: path.join('assets', 'fonts')
|
|
||||||
}, {
|
|
||||||
from: path.join(__dirname, '..', 'src', 'assets', 'images'),
|
|
||||||
to: path.join('assets', 'images')
|
|
||||||
}, {
|
|
||||||
from: path.join(__dirname, '..', 'src', 'assets', 'i18n'),
|
|
||||||
to: path.join('assets', 'i18n')
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export const commonExports = {
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new CopyWebpackPlugin(copyWebpackOptions),
|
...commonExports.plugins,
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: buildRoot('./index.html', ),
|
|
||||||
output: projectRoot('dist'),
|
|
||||||
inject: 'head'
|
|
||||||
}),
|
|
||||||
new ScriptExtPlugin({
|
|
||||||
defaultAttribute: 'defer'
|
|
||||||
}),
|
|
||||||
new webpack.EnvironmentPlugin({
|
new webpack.EnvironmentPlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
NODE_ENV: JSON.stringify('production'),
|
NODE_ENV: JSON.stringify('production'),
|
||||||
@@ -50,64 +14,6 @@ export const commonExports = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: (filePath) => themedTest(filePath, 'scss'),
|
|
||||||
use: (info) => themedUse(info.resource, 'scss')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: (filePath) => themedTest(filePath, 'html'),
|
|
||||||
use: (info) => themedUse(info.resource, 'html')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.ts$/,
|
|
||||||
loader: '@ngtools/webpack'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
exclude: [
|
|
||||||
/node_modules/,
|
|
||||||
buildRoot('styles/_exposed_variables.scss'),
|
|
||||||
buildRoot('styles/_variables.scss')
|
|
||||||
],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'sass-loader',
|
|
||||||
options: {
|
|
||||||
sourceMap: true,
|
|
||||||
includePaths: [projectRoot('./'), path.join(themePath, 'styles')]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'sass-resources-loader',
|
|
||||||
options: {
|
|
||||||
resources: globalCSSImports()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /(_exposed)?_variables.scss$/,
|
|
||||||
exclude: [/node_modules/],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'postcss-loader',
|
|
||||||
options: {
|
|
||||||
sourceMap: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'sass-loader',
|
|
||||||
options: {
|
|
||||||
sourceMap: true,
|
|
||||||
includePaths: [projectRoot('./'), path.join(themePath, 'styles')]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
recordsOutputPath: projectRoot('webpack.records.json'),
|
recordsOutputPath: projectRoot('webpack.records.json'),
|
||||||
entry: buildRoot('./main.server.ts'),
|
entry: buildRoot('./main.server.ts'),
|
||||||
@@ -122,6 +28,4 @@ export const commonExports = {
|
|||||||
/sortablejs/,
|
/sortablejs/,
|
||||||
/ngx/]
|
/ngx/]
|
||||||
})],
|
})],
|
||||||
};
|
});
|
||||||
|
|
||||||
module.exports = commonExports;
|
|
||||||
|
8
webpack/webpack.test.ts
Normal file
8
webpack/webpack.test.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { commonExports } from './webpack.common';
|
||||||
|
|
||||||
|
module.exports = Object.assign({}, commonExports, {
|
||||||
|
target: 'web',
|
||||||
|
node: {
|
||||||
|
module: 'empty'
|
||||||
|
}
|
||||||
|
});
|
35
yarn.lock
35
yarn.lock
@@ -1162,6 +1162,13 @@
|
|||||||
"@types/minimatch" "*"
|
"@types/minimatch" "*"
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/http-proxy@^1.17.4":
|
||||||
|
version "1.17.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
|
||||||
|
integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/jasmine@*", "@types/jasmine@^3.3.9":
|
"@types/jasmine@*", "@types/jasmine@^3.3.9":
|
||||||
version "3.5.7"
|
version "3.5.7"
|
||||||
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.5.7.tgz#c4237935a4b0db31ada6b0de10e2b0658e7b2643"
|
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.5.7.tgz#c4237935a4b0db31ada6b0de10e2b0658e7b2643"
|
||||||
@@ -2090,7 +2097,7 @@ braces@^2.3.1, braces@^2.3.2:
|
|||||||
split-string "^3.0.2"
|
split-string "^3.0.2"
|
||||||
to-regex "^3.0.1"
|
to-regex "^3.0.1"
|
||||||
|
|
||||||
braces@^3.0.2, braces@~3.0.2:
|
braces@^3.0.1, braces@^3.0.2, braces@~3.0.2:
|
||||||
version "3.0.2"
|
version "3.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
|
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
|
||||||
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
|
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
|
||||||
@@ -5131,6 +5138,17 @@ http-proxy-middleware@0.19.1:
|
|||||||
lodash "^4.17.11"
|
lodash "^4.17.11"
|
||||||
micromatch "^3.1.10"
|
micromatch "^3.1.10"
|
||||||
|
|
||||||
|
http-proxy-middleware@^1.0.5:
|
||||||
|
version "1.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.0.5.tgz#4c6e25d95a411e3d750bc79ccf66290675176dc2"
|
||||||
|
integrity sha512-CKzML7u4RdGob8wuKI//H8Ein6wNTEQR7yjVEzPbhBLGdOfkfvgTnp2HLnniKBDP9QW4eG10/724iTWLBeER3g==
|
||||||
|
dependencies:
|
||||||
|
"@types/http-proxy" "^1.17.4"
|
||||||
|
http-proxy "^1.18.1"
|
||||||
|
is-glob "^4.0.1"
|
||||||
|
lodash "^4.17.19"
|
||||||
|
micromatch "^4.0.2"
|
||||||
|
|
||||||
http-proxy@^1.17.0:
|
http-proxy@^1.17.0:
|
||||||
version "1.18.0"
|
version "1.18.0"
|
||||||
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a"
|
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a"
|
||||||
@@ -6324,6 +6342,11 @@ lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17
|
|||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||||
|
|
||||||
|
lodash@^4.17.19:
|
||||||
|
version "4.17.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
|
||||||
|
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
|
||||||
|
|
||||||
log-driver@^1.2.7:
|
log-driver@^1.2.7:
|
||||||
version "1.2.7"
|
version "1.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8"
|
resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8"
|
||||||
@@ -6580,6 +6603,14 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
|
|||||||
snapdragon "^0.8.1"
|
snapdragon "^0.8.1"
|
||||||
to-regex "^3.0.2"
|
to-regex "^3.0.2"
|
||||||
|
|
||||||
|
micromatch@^4.0.2:
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
|
||||||
|
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
|
||||||
|
dependencies:
|
||||||
|
braces "^3.0.1"
|
||||||
|
picomatch "^2.0.5"
|
||||||
|
|
||||||
miller-rabin@^4.0.0:
|
miller-rabin@^4.0.0:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
|
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
|
||||||
@@ -7615,7 +7646,7 @@ picomatch@^2.0.4, picomatch@^2.0.7:
|
|||||||
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"
|
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"
|
||||||
integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==
|
integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==
|
||||||
|
|
||||||
picomatch@^2.2.1:
|
picomatch@^2.0.5, picomatch@^2.2.1:
|
||||||
version "2.2.2"
|
version "2.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
|
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
|
||||||
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
|
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
|
||||||
|
Reference in New Issue
Block a user