Add hasMachineCache: true in production. Fix css loading bug when a community is restricted.
This commit is contained in:
parent
a855a7491d
commit
59b6d14342
|
@ -1,4 +1,13 @@
|
||||||
import {Component, ElementRef, Inject, OnDestroy, OnInit, RendererFactory2, ViewChild, ViewEncapsulation} from '@angular/core';
|
import {
|
||||||
|
Component,
|
||||||
|
ElementRef,
|
||||||
|
Inject,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit, PLATFORM_ID,
|
||||||
|
RendererFactory2,
|
||||||
|
ViewChild,
|
||||||
|
ViewEncapsulation
|
||||||
|
} from '@angular/core';
|
||||||
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
|
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
|
||||||
|
|
||||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
|
@ -11,14 +20,14 @@ import {UserManagementService} from "./openaireLibrary/services/user-management.
|
||||||
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
||||||
import {properties} from '../environments/environment';
|
import {properties} from '../environments/environment';
|
||||||
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
||||||
import {AsyncSubject, Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
import {CommunityService} from "./openaireLibrary/connect/community/community.service";
|
import {CommunityService} from "./openaireLibrary/connect/community/community.service";
|
||||||
import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
|
import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
|
||||||
import {LoginErrorCodes} from "./openaireLibrary/login/utils/guardHelper.class";
|
import {LoginErrorCodes} from "./openaireLibrary/login/utils/guardHelper.class";
|
||||||
import {CustomizationOptions, Layout} from "./openaireLibrary/connect/community/CustomizationOptions";
|
import {Layout} from "./openaireLibrary/connect/community/CustomizationOptions";
|
||||||
import {CustomizationService} from "./openaireLibrary/services/customization.service";
|
import {CustomizationService} from "./openaireLibrary/services/customization.service";
|
||||||
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
||||||
import {Meta} from "@angular/platform-browser";
|
import {makeStateKey, Meta, StateKey, TransferState} from "@angular/platform-browser";
|
||||||
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
|
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
|
||||||
import {SEOService} from "./openaireLibrary/sharedComponents/SEO/SEO.service";
|
import {SEOService} from "./openaireLibrary/sharedComponents/SEO/SEO.service";
|
||||||
import {UntypedFormBuilder, UntypedFormGroup, Validators} from "@angular/forms";
|
import {UntypedFormBuilder, UntypedFormGroup, Validators} from "@angular/forms";
|
||||||
|
@ -29,7 +38,8 @@ import {QuickContactComponent} from "./openaireLibrary/sharedComponents/quick-co
|
||||||
import {Composer} from "./openaireLibrary/utils/email/composer";
|
import {Composer} from "./openaireLibrary/utils/email/composer";
|
||||||
import {NotificationHandler} from "./openaireLibrary/utils/notification-handler";
|
import {NotificationHandler} from "./openaireLibrary/utils/notification-handler";
|
||||||
import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields";
|
import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields";
|
||||||
import {DOCUMENT} from "@angular/common";
|
import {DOCUMENT, isPlatformServer} from "@angular/common";
|
||||||
|
import {AdvancedAsyncSubject} from "./openaireLibrary/utils/AdvancedAsyncSubject";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
|
@ -44,7 +54,9 @@ import {DOCUMENT} from "@angular/common";
|
||||||
<a routerLink="/get-started">Get Started</a>
|
<a routerLink="/get-started">Get Started</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<a *ngIf="showGetStarted" extra-m class="uk-button uk-button-small uk-button-primary uk-text-uppercase uk-margin-left" routerLink="/get-started">Get Started</a>
|
<a *ngIf="showGetStarted" extra-m
|
||||||
|
class="uk-button uk-button-small uk-button-primary uk-text-uppercase uk-margin-left"
|
||||||
|
routerLink="/get-started">Get Started</a>
|
||||||
</navbar>
|
</navbar>
|
||||||
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.communityId" [onlyTop]=false
|
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.communityId" [onlyTop]=false
|
||||||
[communityId]="community.communityId" [header]="header"
|
[communityId]="community.communityId" [header]="header"
|
||||||
|
@ -65,7 +77,8 @@ import {DOCUMENT} from "@angular/common";
|
||||||
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
|
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
|
||||||
[URL]="properties.domain + properties.baseLink"
|
[URL]="properties.domain + properties.baseLink"
|
||||||
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
|
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
|
||||||
[name]="(community.shortTitle) ? community.shortTitle : community.title" [description]="community.description">
|
[name]="(community.shortTitle) ? community.shortTitle : community.title"
|
||||||
|
[description]="community.description">
|
||||||
</schema2jsonld>
|
</schema2jsonld>
|
||||||
<div class="custom-main-content">
|
<div class="custom-main-content">
|
||||||
<main>
|
<main>
|
||||||
|
@ -92,14 +105,14 @@ import {DOCUMENT} from "@angular/common";
|
||||||
[properties]="properties"></bottom>
|
[properties]="properties"></bottom>
|
||||||
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
|
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
|
||||||
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
||||||
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties"
|
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties" [centered]="true"></bottom>
|
||||||
[darkBackground]="true" [centered]="true"></bottom>
|
|
||||||
<quick-contact #quickContact *ngIf="showQuickContact && contactForm" (sendEmitter)="send($event)"
|
<quick-contact #quickContact *ngIf="showQuickContact && contactForm" (sendEmitter)="send($event)"
|
||||||
[contact]="'Help'" [images]="images" [background]="{class: 'uk-background-primary', dark: false}"
|
[contact]="'Help'" [images]="images" [background]="{class: 'uk-background-primary', dark: false}"
|
||||||
[contactForm]="contactForm" [sending]="sending"></quick-contact>
|
[contactForm]="contactForm" [sending]="sending"></quick-contact>
|
||||||
<modal-alert #modal [overflowBody]="false"></modal-alert>
|
<modal-alert #modal [overflowBody]="false"></modal-alert>
|
||||||
<role-verification *ngIf="community" service="connect"
|
<role-verification *ngIf="community" service="connect"
|
||||||
[id]="community.communityId" [name]="community.title" [type]="community.type"></role-verification>
|
[id]="community.communityId" [name]="community.title"
|
||||||
|
[type]="community.type"></role-verification>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -131,8 +144,13 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
layouts: Layout[] = null;
|
layouts: Layout[] = null;
|
||||||
layoutDefault: Layout = null;
|
layoutDefault: Layout = null;
|
||||||
layoutConnect: Layout = null;
|
layoutConnect: Layout = null;
|
||||||
layoutSub = new AsyncSubject();
|
layoutSub = new AdvancedAsyncSubject<Layout[]>();
|
||||||
previewLayout = null;
|
previewLayout = null;
|
||||||
|
/**
|
||||||
|
* key for portal identity check (client - server: using transfer state
|
||||||
|
* */
|
||||||
|
key: StateKey<string> = makeStateKey<string>('portal');
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
||||||
private _communitiesService: CommunitiesService, private smoothScroll: SmoothScroll,
|
private _communitiesService: CommunitiesService, private smoothScroll: SmoothScroll,
|
||||||
private router: Router, private userManagementService: UserManagementService,
|
private router: Router, private userManagementService: UserManagementService,
|
||||||
|
@ -141,7 +159,10 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
private quickContactService: QuickContactService,
|
private quickContactService: QuickContactService,
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
private emailService: EmailService,
|
private emailService: EmailService,
|
||||||
@Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2
|
@Inject(DOCUMENT) private document,
|
||||||
|
private transferState: TransferState,
|
||||||
|
@Inject(PLATFORM_ID) private platformId: any,
|
||||||
|
private rendererFactory: RendererFactory2
|
||||||
) {
|
) {
|
||||||
this.subscriptions.push(router.events.forEach((event) => {
|
this.subscriptions.push(router.events.forEach((event) => {
|
||||||
if (event instanceof NavigationEnd) {
|
if (event instanceof NavigationEnd) {
|
||||||
|
@ -157,7 +178,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
||||||
this.previewLayout = (data['previewLayout'] && data['previewLayout'].length > 0 ? data['previewLayout'] : null);
|
this.previewLayout = (data['previewLayout'] && data['previewLayout'].length > 0 ? data['previewLayout'] : null);
|
||||||
if (this.properties.environment == "production" || this.properties.environment == "development") {
|
if (this.properties.environment == "production" || this.properties.environment == "development") {
|
||||||
|
@ -177,7 +197,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.init();
|
this.init();
|
||||||
}, error => {
|
}, error => {
|
||||||
this.init()}));
|
this.init();
|
||||||
|
}));
|
||||||
this.subscriptions.push(this.quickContactService.isDisplayed.subscribe(display => {
|
this.subscriptions.push(this.quickContactService.isDisplayed.subscribe(display => {
|
||||||
this.showQuickContact = display;
|
this.showQuickContact = display;
|
||||||
}));
|
}));
|
||||||
|
@ -238,9 +259,9 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.userManagementService.fixRedirectURL = null;
|
this.userManagementService.fixRedirectURL = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initCss(communityId, suffix = null) {
|
initCss(communityId, suffix = null) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const renderer = this.rendererFactory.createRenderer(this.document, {
|
const renderer = this.rendererFactory.createRenderer(this.document, {
|
||||||
id: '-1',
|
id: '-1',
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
@ -259,13 +280,10 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
renderer.appendChild(head, script);
|
renderer.appendChild(head, script);
|
||||||
} else if (!this.previewLayout) {
|
} else if (!this.previewLayout) {
|
||||||
this.document.getElementById("dashboardStyle").href = ((communityId) ? communityId : this.properties.adminToolsPortalType) + (suffix ? "-" + suffix : "") + ".css";
|
this.document.getElementById("dashboardStyle").href = ((communityId) ? communityId : this.properties.adminToolsPortalType) + (suffix ? "-" + suffix : "") + ".css";
|
||||||
// console.log(this.document.getElementById("dashboardStyle"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Renderrer Error to append style ', e);
|
console.error('Renderrer Error to append style ', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initAdminToolCommunity(communityId) {
|
initAdminToolCommunity(communityId) {
|
||||||
|
@ -281,8 +299,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.configurationService.initCommunityInformation(this.properties, (communityId) ? communityId : this.properties.adminToolsPortalType);
|
this.configurationService.initCommunityInformation(this.properties, (communityId) ? communityId : this.properties.adminToolsPortalType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayouts() {
|
getLayouts() {
|
||||||
this.customizationService.getLayouts(this.properties).subscribe(
|
this.customizationService.getLayouts(this.properties).subscribe(
|
||||||
layouts => {
|
layouts => {
|
||||||
|
@ -290,17 +308,22 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.layoutDefault = layouts.filter(layout => layout.portalPid == 'default')[0];
|
this.layoutDefault = layouts.filter(layout => layout.portalPid == 'default')[0];
|
||||||
this.layoutConnect = layouts.filter(layout => layout.portalPid == 'connect')[0];
|
this.layoutConnect = layouts.filter(layout => layout.portalPid == 'connect')[0];
|
||||||
this.layoutSub.next(this.layouts);
|
this.layoutSub.next(this.layouts);
|
||||||
this.layoutSub.complete();
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
this.layoutSub.next([]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
initLayout(communityId) {
|
initLayout(communityId) {
|
||||||
if(!this.layout && (typeof location == 'undefined') && !this.previewLayout) {
|
let portal = this.transferState.get<string>(this.key, null);
|
||||||
|
if(isPlatformServer(this.platformId)) {
|
||||||
|
this.transferState.set(this.key, communityId);
|
||||||
|
}
|
||||||
|
if (!this.layout && (portal !== communityId) && !this.previewLayout) {
|
||||||
// if((typeof location == 'undefined') && !this.previewLayout) {
|
// if((typeof location == 'undefined') && !this.previewLayout) {
|
||||||
this.subscriptions.push(this.layoutSub.subscribe(value => {
|
this.subscriptions.push(this.layoutSub.subscribe(value => {
|
||||||
|
this.layouts = value;
|
||||||
this.layout = this.layouts.filter(layout => layout.portalPid == communityId)[0] ? this.layouts.filter(layout => layout.portalPid == communityId)[0] : this.layouts.filter(layout => layout.portalPid == 'default')[0];
|
this.layout = this.layouts.filter(layout => layout.portalPid == communityId)[0] ? this.layouts.filter(layout => layout.portalPid == communityId)[0] : this.layouts.filter(layout => layout.portalPid == 'default')[0];
|
||||||
this.initCss(this.layout.portalPid, this.layout.date ? this.layout.date : null)
|
this.initCss(this.layout.portalPid, this.layout.date ? this.layout.date : null)
|
||||||
}));
|
}));
|
||||||
|
@ -309,6 +332,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.initCss(communityId, this.previewLayout.split(communityId)[1]);
|
this.initCss(communityId, this.previewLayout.split(communityId)[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildMenu(communityId: string) {
|
public buildMenu(communityId: string) {
|
||||||
if (communityId) {
|
if (communityId) {
|
||||||
if (!this.community || this.communityId !== communityId) {
|
if (!this.community || this.communityId !== communityId) {
|
||||||
|
@ -333,7 +357,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
|
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
|
||||||
this.communityId = this.community.communityId;
|
this.communityId = this.community.communityId;
|
||||||
this.initAdminToolCommunity(this.communityId);
|
this.initAdminToolCommunity(this.communityId);
|
||||||
|
|
||||||
this.header = {
|
this.header = {
|
||||||
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
|
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
|
||||||
route: "/",
|
route: "/",
|
||||||
|
@ -408,10 +431,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
this.showMenu = true;
|
this.showMenu = true;
|
||||||
} else {
|
} else {
|
||||||
this.initAdminToolCommunity(this.communityId);
|
|
||||||
|
|
||||||
this.communityId = null;
|
this.communityId = null;
|
||||||
this.properties.adminToolsPortalType = "connect";
|
|
||||||
this.configurationService.initCommunityInformation(this.properties, "connect");
|
this.configurationService.initCommunityInformation(this.properties, "connect");
|
||||||
// this.initAdminToolCommunity(null);
|
// this.initAdminToolCommunity(null);
|
||||||
this.buildConnectMenu(true);
|
this.buildConnectMenu(true);
|
||||||
|
@ -437,9 +457,9 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildConnectMenu(restrictedData: boolean = false) {
|
buildConnectMenu(restrictedData: boolean = false) {
|
||||||
this.initAdminToolCommunity(null);
|
this.initAdminToolCommunity(null);
|
||||||
|
|
||||||
let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu";
|
let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu";
|
||||||
this.header = {
|
this.header = {
|
||||||
route: restrictedData ? "" : "/",
|
route: restrictedData ? "" : "/",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 95a3cc3ff62983d593730827a8d07fd43887627b
|
Subproject commit 39a7ed58be27513c05598edc18cf095eb5b044c5
|
|
@ -114,5 +114,6 @@ export let properties: EnvProperties = {
|
||||||
altMetricsAPIURL: "https://api.altmetric.com/v1/doi/",
|
altMetricsAPIURL: "https://api.altmetric.com/v1/doi/",
|
||||||
b2noteAPIURL: 'https://b2note.eudat.eu/',
|
b2noteAPIURL: 'https://b2note.eudat.eu/',
|
||||||
adminPortalURL: "https://admin.connect.openaire.eu",
|
adminPortalURL: "https://admin.connect.openaire.eu",
|
||||||
myOrcidLinksPage: "/my-orcid-links"
|
myOrcidLinksPage: "/my-orcid-links",
|
||||||
|
hasMachineCache: true
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue