mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Merge branch 'master' into w2p-57053_menu-angular6
Conflicts: webpack.config.js
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
<div class="simple-view-element">
|
<div class="simple-view-element" [class.d-none]="content.textContent.trim().length === 0">
|
||||||
<span *ngIf="content.children.length != 0">
|
|
||||||
<h5 class="simple-view-element-header" *ngIf="label">{{ label }}</h5>
|
<h5 class="simple-view-element-header" *ngIf="label">{{ label }}</h5>
|
||||||
</span>
|
|
||||||
<div #content class="simple-view-element-body">
|
<div #content class="simple-view-element-body">
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -7,7 +7,8 @@ import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.componen
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-component-with-content',
|
selector: 'ds-component-with-content',
|
||||||
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
|
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
|
||||||
' <div class="my content">\n' +
|
' <div class="my-content">\n' +
|
||||||
|
' <span></span>\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
'</ds-metadata-field-wrapper>'
|
'</ds-metadata-field-wrapper>'
|
||||||
})
|
})
|
||||||
@@ -30,25 +31,37 @@ describe('MetadataFieldWrapperComponent', () => {
|
|||||||
|
|
||||||
const wrapperSelector = '.simple-view-element';
|
const wrapperSelector = '.simple-view-element';
|
||||||
const labelSelector = '.simple-view-element-header';
|
const labelSelector = '.simple-view-element-header';
|
||||||
|
const contentSelector = '.my-content';
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeDefined();
|
expect(component).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not show a label when there is no content', () => {
|
it('should not show the component when there is no content', () => {
|
||||||
component.label = 'test label';
|
component.label = 'test label';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const debugLabel = fixture.debugElement.query(By.css(labelSelector));
|
const parentNative = fixture.nativeElement;
|
||||||
expect(debugLabel).toBeNull();
|
const nativeWrapper = parentNative.querySelector(wrapperSelector);
|
||||||
|
expect(nativeWrapper.classList.contains('d-none')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show a label when there is content', () => {
|
it('should not show the component when there is DOM content but no text', () => {
|
||||||
const parentFixture = TestBed.createComponent(ContentComponent);
|
const parentFixture = TestBed.createComponent(ContentComponent);
|
||||||
parentFixture.detectChanges();
|
parentFixture.detectChanges();
|
||||||
const parentComponent = parentFixture.componentInstance;
|
|
||||||
const parentNative = parentFixture.nativeElement;
|
const parentNative = parentFixture.nativeElement;
|
||||||
const nativeLabel = parentNative.querySelector(labelSelector);
|
const nativeWrapper = parentNative.querySelector(wrapperSelector);
|
||||||
expect(nativeLabel.textContent).toContain('test label');
|
expect(nativeWrapper.classList.contains('d-none')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the component when there is text content', () => {
|
||||||
|
const parentFixture = TestBed.createComponent(ContentComponent);
|
||||||
|
parentFixture.detectChanges();
|
||||||
|
const parentNative = parentFixture.nativeElement;
|
||||||
|
const nativeContent = parentNative.querySelector(contentSelector);
|
||||||
|
nativeContent.textContent = 'lorem ipsum';
|
||||||
|
const nativeWrapper = parentNative.querySelector(wrapperSelector);
|
||||||
|
parentFixture.detectChanges();
|
||||||
|
expect(nativeWrapper.classList.contains('d-none')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -148,7 +148,7 @@ describe('AuthService test', () => {
|
|||||||
(state as any).core = Object.create({});
|
(state as any).core = Object.create({});
|
||||||
(state as any).core.auth = authenticatedState;
|
(state as any).core.auth = authenticatedState;
|
||||||
});
|
});
|
||||||
authService = new AuthService({}, window, authReqService, router, cookieService, store, rdbService);
|
authService = new AuthService({}, window, undefined, authReqService, router, cookieService, store, rdbService);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return true when user is logged in', () => {
|
it('should return true when user is logged in', () => {
|
||||||
@@ -207,7 +207,7 @@ describe('AuthService test', () => {
|
|||||||
(state as any).core = Object.create({});
|
(state as any).core = Object.create({});
|
||||||
(state as any).core.auth = authenticatedState;
|
(state as any).core.auth = authenticatedState;
|
||||||
});
|
});
|
||||||
authService = new AuthService({}, window, authReqService, router, cookieService, store, rdbService);
|
authService = new AuthService({}, window, undefined, authReqService, router, cookieService, store, rdbService);
|
||||||
storage = (authService as any).storage;
|
storage = (authService as any).storage;
|
||||||
spyOn(storage, 'get');
|
spyOn(storage, 'get');
|
||||||
spyOn(storage, 'remove');
|
spyOn(storage, 'remove');
|
||||||
|
@@ -9,10 +9,10 @@ import {
|
|||||||
take,
|
take,
|
||||||
withLatestFrom
|
withLatestFrom
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable, Optional } from '@angular/core';
|
||||||
import { PRIMARY_OUTLET, Router, UrlSegmentGroup, UrlTree } from '@angular/router';
|
import { PRIMARY_OUTLET, Router, UrlSegmentGroup, UrlTree } from '@angular/router';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { REQUEST } from '@nguniversal/express-engine/tokens';
|
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||||
|
|
||||||
import { RouterReducerState } from '@ngrx/router-store';
|
import { RouterReducerState } from '@ngrx/router-store';
|
||||||
import { select, Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
@@ -59,6 +59,7 @@ export class AuthService {
|
|||||||
constructor(@Inject(REQUEST) protected req: any,
|
constructor(@Inject(REQUEST) protected req: any,
|
||||||
@Inject(NativeWindowService) protected _window: NativeWindowRef,
|
@Inject(NativeWindowService) protected _window: NativeWindowRef,
|
||||||
protected authRequestService: AuthRequestService,
|
protected authRequestService: AuthRequestService,
|
||||||
|
@Optional() @Inject(RESPONSE) private response: any,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected storage: CookieService,
|
protected storage: CookieService,
|
||||||
protected store: Store<AppState>,
|
protected store: Store<AppState>,
|
||||||
@@ -345,6 +346,10 @@ export class AuthService {
|
|||||||
if (this._window.nativeWindow.location) {
|
if (this._window.nativeWindow.location) {
|
||||||
// Hard redirect to login page, so that all state is definitely lost
|
// Hard redirect to login page, so that all state is definitely lost
|
||||||
this._window.nativeWindow.location.href = redirectUrl;
|
this._window.nativeWindow.location.href = redirectUrl;
|
||||||
|
} else if (this.response) {
|
||||||
|
if (!this.response._headerSent) {
|
||||||
|
this.response.redirect(302, redirectUrl);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl(redirectUrl);
|
this.router.navigateByUrl(redirectUrl);
|
||||||
}
|
}
|
||||||
|
2
src/app/core/cache/response-cache.models.ts
vendored
2
src/app/core/cache/response-cache.models.ts
vendored
@@ -140,7 +140,7 @@ export class ErrorResponse extends RestResponse {
|
|||||||
|
|
||||||
constructor(error: RequestError) {
|
constructor(error: RequestError) {
|
||||||
super(false, error.statusText);
|
super(false, error.statusText);
|
||||||
// console.error(error);
|
console.error(error);
|
||||||
this.errorMessage = error.message;
|
this.errorMessage = error.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,25 +37,8 @@ export abstract class ComColDataService<TNormalized extends NormalizedObject, TD
|
|||||||
tap((href: string) => {
|
tap((href: string) => {
|
||||||
const request = new FindByIDRequest(this.requestService.generateRequestId(), href, options.scopeID);
|
const request = new FindByIDRequest(this.requestService.generateRequestId(), href, options.scopeID);
|
||||||
this.requestService.configure(request);
|
this.requestService.configure(request);
|
||||||
}),);
|
}));
|
||||||
|
|
||||||
// return scopeCommunityHrefObs.pipe(
|
|
||||||
// mergeMap((href: string) => this.responseCache.get(href)),
|
|
||||||
// map((entry: ResponseCacheEntry) => entry.response),
|
|
||||||
// mergeMap((response) => {
|
|
||||||
// if (response.isSuccessful) {
|
|
||||||
// const community$: Observable<NormalizedCommunity> = this.objectCache.getByUUID(scopeID);
|
|
||||||
// return community$.pipe(
|
|
||||||
// map((community) => community._links[this.linkPath]),
|
|
||||||
// filter((href) => isNotEmpty(href)),
|
|
||||||
// distinctUntilChanged()
|
|
||||||
// );
|
|
||||||
// } else if (!response.isSuccessful) {
|
|
||||||
// return observableThrowError(new Error(`The Community with scope ${scopeID} couldn't be retrieved`))
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
// distinctUntilChanged()
|
|
||||||
// );
|
|
||||||
const responses = scopeCommunityHrefObs.pipe(
|
const responses = scopeCommunityHrefObs.pipe(
|
||||||
mergeMap((href: string) => this.responseCache.get(href)),
|
mergeMap((href: string) => this.responseCache.get(href)),
|
||||||
map((entry: ResponseCacheEntry) => entry.response));
|
map((entry: ResponseCacheEntry) => entry.response));
|
||||||
|
@@ -17,6 +17,7 @@ import { ngExpressEngine } from '@nguniversal/express-engine';
|
|||||||
|
|
||||||
import { ROUTES } from './routes';
|
import { ROUTES } from './routes';
|
||||||
import { ENV_CONFIG } from './config';
|
import { ENV_CONFIG } from './config';
|
||||||
|
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||||
|
|
||||||
export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||||
const app = express();
|
const app = express();
|
||||||
@@ -31,9 +32,21 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
|||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
app.engine('html', ngExpressEngine({
|
app.engine('html', (_, options, callback) =>
|
||||||
bootstrap: bootstrap
|
ngExpressEngine({
|
||||||
}));
|
bootstrap: bootstrap,
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: REQUEST,
|
||||||
|
useValue: options.req,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: RESPONSE,
|
||||||
|
useValue: options.req.res,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})(_, options, callback)
|
||||||
|
);
|
||||||
|
|
||||||
app.set('view engine', 'html');
|
app.set('view engine', 'html');
|
||||||
app.set('views', 'src');
|
app.set('views', 'src');
|
||||||
@@ -53,9 +66,11 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
|||||||
function ngApp(req, res) {
|
function ngApp(req, res) {
|
||||||
|
|
||||||
function onHandleError(parentZoneDelegate, currentZone, targetZone, error) {
|
function onHandleError(parentZoneDelegate, currentZone, targetZone, error) {
|
||||||
|
if (!res._headerSent) {
|
||||||
console.warn('Error in SSR, serving for direct CSR');
|
console.warn('Error in SSR, serving for direct CSR');
|
||||||
res.sendFile('index.csr.html', { root: './src' });
|
res.sendFile('index.csr.html', { root: './src' });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ENV_CONFIG.universal.preboot) {
|
if (ENV_CONFIG.universal.preboot) {
|
||||||
Zone.current.fork({ name: 'CSR fallback', onHandleError }).run(() => {
|
Zone.current.fork({ name: 'CSR fallback', onHandleError }).run(() => {
|
||||||
|
@@ -27,7 +27,6 @@ module.exports = function(env, options) {
|
|||||||
getAotPlugin('client', !!env.aot)
|
getAotPlugin('client', !!env.aot)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.mode === 'production') {
|
if (options.mode === 'production') {
|
||||||
serverConfig = webpackMerge({}, serverConfig, prodPartial);
|
serverConfig = webpackMerge({}, serverConfig, prodPartial);
|
||||||
clientConfig = webpackMerge({}, clientConfig, prodPartial);
|
clientConfig = webpackMerge({}, clientConfig, prodPartial);
|
||||||
|
Reference in New Issue
Block a user