[master | FIXED]: Fix glitch with styles and dubbed sidabar items.

This commit is contained in:
Konstantinos Triantafyllou 2024-01-11 16:04:38 +02:00
parent 4533970798
commit 5e47e4c237
2 changed files with 81 additions and 76 deletions

View File

@ -58,12 +58,13 @@ export class AdminComponent extends SidebarBaseComponent implements OnInit {
this.stakeholder = stakeholder; this.stakeholder = stakeholder;
this.setProperties(this.stakeholder.alias, this.stakeholder.type); this.setProperties(this.stakeholder.alias, this.stakeholder.type);
this.layoutService.setRootClass(this.stakeholder.type); this.layoutService.setRootClass(this.stakeholder.type);
this.sideBarItems = [];
this.sideBarItems.push(new MenuItem("general", "General", "", "/admin/" + this.stakeholder.alias, false, [], [], {}, {name: 'badge'})); this.sideBarItems.push(new MenuItem("general", "General", "", "/admin/" + this.stakeholder.alias, false, [], [], {}, {name: 'badge'}));
this.sideBarItems.push(new MenuItem("indicators", "Indicators", "", "/admin/" + this.stakeholder.alias + '/indicators', false, [], [], {}, {name: 'bar_chart'}, null, "uk-visible@m")); this.sideBarItems.push(new MenuItem("indicators", "Indicators", "", "/admin/" + this.stakeholder.alias + '/indicators', false, [], [], {}, {name: 'bar_chart'}, null, "uk-visible@m"));
if (this.stakeholder.defaultId) { if (this.stakeholder.defaultId) {
this.sideBarItems.push(new MenuItem("users", "Users", "", "/admin/" + this.stakeholder.alias + '/users', false, [], [], {}, {name: 'group'}, null, "uk-visible@m", "/admin/" + this.stakeholder.alias + "/users")); this.sideBarItems.push(new MenuItem("users", "Users", "", "/admin/" + this.stakeholder.alias + '/users', false, [], [], {}, {name: 'group'}, null, "uk-visible@m", "/admin/" + this.stakeholder.alias + "/users"));
} }
if (this.isAdmin) { if (this.isAdmin && this.stakeholder.defaultId) {
this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, "uk-visible@m", "/admin/" + this.stakeholder.alias + "/admin-tools")); this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, "uk-visible@m", "/admin/" + this.stakeholder.alias + "/admin-tools"));
} }
if (this.hasAdminMenu) { if (this.hasAdminMenu) {

View File

@ -1,4 +1,4 @@
import {ChangeDetectorRef, Component, OnInit} from '@angular/core'; import {AfterViewInit, ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {MenuItem} from "./openaireLibrary/sharedComponents/menu"; import {MenuItem} from "./openaireLibrary/sharedComponents/menu";
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component"; import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
@ -20,13 +20,13 @@ import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
template: ` template: `
<div class="uk-background-default">
<navbar *ngIf="hasHeader" portal="irish_monitor" [menuItems]="menuItems" [showMenu]="true"
[header]="header" [user]="user" [userMenuItems]="userMenuItems"></navbar>
<div *ngIf="loading"> <div *ngIf="loading">
<loading [full]="true"></loading> <loading [full]="true"></loading>
</div> </div>
<div *ngIf="!loading" class="uk-background-default"> <div [class.uk-hidden]="loading" [ngClass]="rootClass">
<navbar *ngIf="hasHeader" portal="irish_monitor" [menuItems]="menuItems" [showMenu]="true"
[header]="header" [user]="user" [userMenuItems]="userMenuItems"></navbar>
<div [ngClass]="rootClass">
<div id="modal-container"></div> <div id="modal-container"></div>
<main> <main>
<router-outlet></router-outlet> <router-outlet></router-outlet>
@ -44,15 +44,6 @@ import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
points="7 4 13 10 7 16"></polyline></svg> points="7 4 13 10 7 16"></polyline></svg>
</span></a>--> </span></a>-->
</cookie-law> </cookie-law>
<!--<cookie-law *ngIf="isClient" position="top" cookieName="logActions-NOAMIreland">
National Open Access Monitor - Ireland, creates public logs for user actions.<br>
By using the National Open Access Monitor - Ireland portal you consent to log your actions <a
routerLink="/public-logs"> View Public logs <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
points="7 4 13 10 7 16"></polyline></svg>
</span></a>
</cookie-law>-->
<footer class="uk-text-center uk-text-small uk-border-top"> <footer class="uk-text-center uk-text-small uk-border-top">
<div class="uk-tile-default"> <div class="uk-tile-default">
<div class="uk-section uk-container"> <div class="uk-section uk-container">
@ -67,26 +58,32 @@ import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
Developed by <a href="https://www.openaire.eu/" target="_blank">OpenAIRE</a> Developed by <a href="https://www.openaire.eu/" target="_blank">OpenAIRE</a>
</div> </div>
<div class="uk-margin-bottom uk-container uk-container-small"> <div class="uk-margin-bottom uk-container uk-container-small">
The National Open Access Monitor, Ireland is delivered as part of the National Open Access Monitor Project, The National Open Access Monitor, Ireland is delivered as part of the National Open Access Monitor
managed by the <a href="https://irel.ie/" target="_blank">Irish Research eLibrary (IReL)</a> at Maynooth University. Project,
The project has received funding from Ireland's <a href="https://dri.ie/norf/" target="_blank">National Open Research Forum (NORF)</a> managed by the <a href="https://irel.ie/" target="_blank">Irish Research eLibrary (IReL)</a> at
Maynooth University.
The project has received funding from Ireland's <a href="https://dri.ie/norf/" target="_blank">National
Open Research Forum (NORF)</a>
under the Open Research Fund Call. under the Open Research Fund Call.
</div> </div>
<div class="uk-margin-bottom"> <div class="uk-margin-bottom">
<img title="Rialtas" src="assets/Rialtas_Mark_Std_Colour.png" class=" uk-padding-xsmall uk-padding-remove-vertical" style="height: 50px;"> <img title="Rialtas" src="assets/Rialtas_Mark_Std_Colour.png"
<img title="HEA" src="assets/hea-logo.png" class=" uk-padding-xsmall uk-padding-remove-vertical" style="height: 30px;"> class=" uk-padding-xsmall uk-padding-remove-vertical" style="height: 50px;">
<img title="Maynooth University" src="assets/Maynooth University Logo.png" class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;"> <img title="HEA" src="assets/hea-logo.png" class=" uk-padding-xsmall uk-padding-remove-vertical"
<img title="IRel" src="assets/IReL logo.png" class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;"> style="height: 30px;">
<img title="NORF" src="assets/norf.jpg" class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;"> <img title="Maynooth University" src="assets/Maynooth University Logo.png"
<img title="OpenAIRE" src="assets/common-assets/common/Logo_Horizontal.png" class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;"> class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;">
<img title="IRel" src="assets/IReL logo.png" class=" uk-padding-small uk-padding-remove-vertical"
style="height: 30px;">
<img title="OpenAIRE" src="assets/common-assets/common/Logo_Horizontal.png"
class=" uk-padding-small uk-padding-remove-vertical" style="height: 30px;">
</div> </div>
</div> </div>
</div> </div>
</footer> </footer>
` `
}) })
export class AppComponent extends ResearcherBaseComponent implements OnInit { export class AppComponent extends ResearcherBaseComponent implements OnInit, AfterViewInit {
loading: boolean = false; loading: boolean = false;
hasHeader: boolean = true; hasHeader: boolean = true;
rootClass: string; rootClass: string;
@ -113,7 +110,7 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
private configurationService: ConfigurationService, private configurationService: ConfigurationService,
private customFilterService: CustomFilterService, private customFilterService: CustomFilterService,
private userManagementService: UserManagementService, private userManagementService: UserManagementService,
private userProfileService:UserProfileService, private userProfileService: UserProfileService,
protected _searchOrcidService: SearchOrcidService, protected _searchOrcidService: SearchOrcidService,
protected _searchResearchResultsService: SearchResearchResultsService protected _searchResearchResultsService: SearchResearchResultsService
) { ) {
@ -135,7 +132,7 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.isClient = typeof document !== 'undefined'; this.isClient = typeof document !== 'undefined';
if(this.properties.environment == 'beta') { if (this.properties.environment == 'beta') {
this.header.environmentBadge = { this.header.environmentBadge = {
asset: 'assets/badge/sandbox.svg' asset: 'assets/badge/sandbox.svg'
} }
@ -147,18 +144,23 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
} }
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
if(user){ if (user) {
this.userProfileService.initUserProfile() this.userProfileService.initUserProfile()
}else{ } else {
this.userProfileService.setUserProfile(null); this.userProfileService.setUserProfile(null);
} }
this.initialize(); this.initialize();
})); }));
}
ngAfterViewInit() {
this.subscriptions.push(this.layoutService.rootClass.subscribe(rootClass => { this.subscriptions.push(this.layoutService.rootClass.subscribe(rootClass => {
if(rootClass && this.isClient) { this.loading = true;
this.cdr.detectChanges();
if (rootClass && this.isClient) {
let link = <HTMLLinkElement>document.getElementById('theme'); let link = <HTMLLinkElement>document.getElementById('theme');
let append = false; let append = false;
if(!link) { if (!link) {
link = document.createElement('link'); link = document.createElement('link');
link.rel = 'stylesheet'; link.rel = 'stylesheet';
link.id = 'theme'; link.id = 'theme';
@ -166,14 +168,17 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
} }
link.href = rootClass + '.css'; link.href = rootClass + '.css';
link.onerror = (error) => console.log(error); link.onerror = (error) => console.log(error);
if(append) { if (append) {
document.head.appendChild(link); document.head.appendChild(link);
} }
} }
this.rootClass = rootClass; this.rootClass = rootClass;
this.cdr.detectChanges(); this.cdr.detectChanges();
setTimeout(() => {
this.loading = false;
this.cdr.detectChanges();
}, 500)
})); }));
} }
initialize() { initialize() {
@ -184,9 +189,9 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, "/researcher"), new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, "/researcher"),
new MenuItem("repository", "Repository Monitors", "", "/repository", false, [], null, {}, null, null, null, "/repository") new MenuItem("repository", "Repository Monitors", "", "/repository", false, [], null, {}, null, null, null, "/repository")
]; ];
if(this.properties.environment != "beta"){ if (this.properties.environment != "beta") {
this.menuItems.push( this.menuItems.push(
new MenuItem("resources", "Resources & Help", "", "", false, [], null, {}, null, null, null, "/resources","_blank", "internal", false, new MenuItem("resources", "Resources & Help", "", "", false, [], null, {}, null, null, null, "/resources", "_blank", "internal", false,
[ [
new MenuItem("how-it-works", "How it works?", "", "", false, [], null, {}, null, null, null, null, "_self"), new MenuItem("how-it-works", "How it works?", "", "", false, [], null, {}, null, null, null, null, "_self"),
new MenuItem("about", "About", "", "/how-it-works/about", false, [], null, {}, null, null, null, "/how-it-works/about"), new MenuItem("about", "About", "", "/how-it-works/about", false, [], null, {}, null, null, null, "/how-it-works/about"),
@ -205,15 +210,14 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
} }
if (this.user) { if (this.user) {
this.userMenuItems = []; this.userMenuItems = [];
// this.user.orcid = '0000-0003-4768-182X'; if (this.user.orcid) {
if(this.user.orcid) {
this.authorId = Identifier.getRawORCID(this.user.orcid); this.authorId = Identifier.getRawORCID(this.user.orcid);
this.results = { this.results = {
success: (res: string | number) => { success: (res: string | number) => {
if(+res > 0) { if (+res > 0) {
this.userMenuItems.push(new MenuItem("my-researcher", "My Researcher Monitor", "", "/researcher/" + this.authorId, false, [], null, {}, null, null, null, null)); this.userMenuItems.push(new MenuItem("my-researcher", "My Researcher Monitor", "", "/researcher/" + this.authorId, false, [], null, {}, null, null, null, null));
this.staticUserItems(); this.staticUserItems();
}else{ } else {
this.staticUserItems(); this.staticUserItems();
} }
} }
@ -236,10 +240,10 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit {
this.userMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'})); this.userMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'}));
} }
if (Session.isPortalAdministrator(this.user)) { if (Session.isPortalAdministrator(this.user)) {
this.userMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {},null, null, "uk-visible@m")); this.userMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {}, null, null, "uk-visible@m"));
} }
if(Session.isPortalAdministrator(this.user) || Session.isCurator('country', this.user)) { if (Session.isPortalAdministrator(this.user) || Session.isCurator('country', this.user)) {
this.userMenuItems.push(new MenuItem("irishOptions", "Irish options", "", "/admin/irish/admin-tools/pages", false, [], [], {},null, null, "uk-visible@m")); this.userMenuItems.push(new MenuItem("irishOptions", "Irish options", "", "/admin/irish/admin-tools/pages", false, [], [], {}, null, null, "uk-visible@m"));
} }
} }