Use new base components and adjust irish configuration.

This commit is contained in:
Konstantinos Triantafyllou 2023-11-13 15:00:45 +02:00
parent dfa7c2a8c2
commit a7114a39b0
8 changed files with 103 additions and 71 deletions

View File

@ -1,28 +1,47 @@
import {Component, OnInit} from "@angular/core"; import {ChangeDetectorRef, Component, OnInit} from "@angular/core";
import {BaseComponent} from "../openaireLibrary/sharedComponents/base/base.component";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {SidebarBaseComponent} from "../openaireLibrary/dashboard/sharedComponents/sidebar/sidebar-base.component";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder";
import {MenuItem} from "../openaireLibrary/sharedComponents/menu";
@Component({ @Component({
selector: 'admin', selector: 'admin',
template: ` template: `
<div class="sidebar_main_swipe uk-flex uk-background-default"
[class.sidebar_main_active]="open && (hasSidebar || hasInternalSidebar)"
[class.sidebar_mini]="!open && (hasSidebar || hasInternalSidebar)"
[class.sidebar_hover]="hover">
<dashboard-sidebar *ngIf="hasSidebar && !hasInternalSidebar && sideBarItems.length > 0" [items]="sideBarItems" [backItem]="backItem"></dashboard-sidebar>
<div class="uk-width-1-1">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div>
</div>
` `
}) })
export class AdminComponent extends BaseComponent implements OnInit { export class AdminComponent extends SidebarBaseComponent implements OnInit {
stakeholder: Stakeholder;
constructor(protected _route: ActivatedRoute, constructor(protected _route: ActivatedRoute,
private stakeholderService: StakeholderService, protected _router: Router,
protected _router: Router) { protected layoutService: LayoutService,
super() protected cdr: ChangeDetectorRef,
private stakeholderService: StakeholderService) {
super();
this.initRouterParams(this._route); this.initRouterParams(this._route);
} }
ngOnInit() { ngOnInit() {
super.ngOnInit();
this.subscriptions.push(this.params.subscribe(params => { this.subscriptions.push(this.params.subscribe(params => {
this.sideBarItems = [];
if(params['alias']) { if(params['alias']) {
this.subscriptions.push(this.stakeholderService.getStakeholder(params['alias']).subscribe()); this.subscriptions.push(this.stakeholderService.getStakeholder(params['alias']).subscribe(stakeholder => {
this.stakeholder = stakeholder;
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"));
}));
} else { } else {
this.stakeholderService.setStakeholder(null); this.stakeholderService.setStakeholder(null);
} }

View File

@ -2,17 +2,34 @@ import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common"; import {CommonModule} from "@angular/common";
import {RouterModule} from "@angular/router"; import {RouterModule} from "@angular/router";
import {AdminComponent} from "./admin.component"; import {AdminComponent} from "./admin.component";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {SideBarModule} from "../openaireLibrary/dashboard/sharedComponents/sidebar/sideBar.module";
@NgModule({ @NgModule({
imports: [CommonModule, RouterModule.forChild([ imports: [CommonModule, RouterModule.forChild([
{path: '', component: AdminComponent, children: [ {
{path: '', loadChildren: () => import('../openaireLibrary/monitor-admin/manageStakeholders/manageStakeholders.module').then(m => m.ManageStakeholdersModule)}, path: '', component: AdminComponent, children: [
{path: ':alias', children: [ {
{path: '', loadChildren: () => import('../openaireLibrary/monitor-admin/general/general.module').then(m => m.GeneralModule)} path: '',
loadChildren: () => import('../openaireLibrary/monitor-admin/manageStakeholders/manageStakeholders.module').then(m => m.ManageStakeholdersModule)
},
{
path: ':alias', children: [
{
path: '',
loadChildren: () => import('../openaireLibrary/monitor-admin/general/general.module').then(m => m.GeneralModule)
},
{
matcher: HelperFunctions.routingMatcher(['indicators', 'indicators/:topic']),
loadChildren: () => import('../openaireLibrary/monitor-admin/topic/topic.module').then(m => m.TopicModule),
data: {hasInternalSidebar: true},
pathMatch: 'full'
},
] ]
} }
]} ]
])], }
]), SideBarModule],
declarations: [AdminComponent], declarations: [AdminComponent],
exports: [AdminComponent] exports: [AdminComponent]
}) })

View File

@ -2,13 +2,13 @@ import {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";
import {BaseComponent} from "./openaireLibrary/sharedComponents/base/base.component";
import {StakeholderEntities} from "./openaireLibrary/monitor/entities/stakeholder";
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service"; import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
import {Irish} from "./shared/irish"; import {Irish} from "./shared/irish";
import {CustomFilterService} from "./shared/customFilter.service"; import {CustomFilterService} from "./shared/customFilter.service";
import {UserManagementService} from "./openaireLibrary/services/user-management.service"; import {UserManagementService} from "./openaireLibrary/services/user-management.service";
import {User} from "./openaireLibrary/login/utils/helper.class"; import {User} from "./openaireLibrary/login/utils/helper.class";
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
import {StakeholderBaseComponent} from "./openaireLibrary/monitor-admin/utils/stakeholder-base.component";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -19,26 +19,17 @@ import {User} from "./openaireLibrary/login/utils/helper.class";
<div *ngIf="!loading"> <div *ngIf="!loading">
<div> <div>
<div id="modal-container"></div> <div id="modal-container"></div>
<navbar *ngIf="hasHeader" portal="irish_monitor" [menuItems]="menuItems" [showMenu]="true" [header]="header" [user]="user" [userMenuItems]="[]"></navbar> <navbar *ngIf="hasHeader" portal="irish_monitor" [menuItems]="menuItems" [showMenu]="true"
<div class="sidebar_main_swipe"> [header]="header" [user]="user" [userMenuItems]="[]"></navbar>
<main> <main>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</main> </main>
<bottom id="bottom" [centered]="true" [properties]="properties" [showMenuItems]="true"></bottom>
</div>
<div *ngIf="view" class="preview uk-text-small uk-flex uk-flex-middle">
<span>You are currently in a <span class="uk-text-bold">"Preview"</span> mode. <span class="uk-visible@m"><a (click)="removeView()">The current view</a> of this dashboard may differ.</span></span>
</div> </div>
</div> </div>
</div> `
`,
styles: []
}) })
export class AppComponent extends BaseComponent implements OnInit { export class AppComponent extends StakeholderBaseComponent implements OnInit {
title = 'irish-monitor';
loading: boolean = false; loading: boolean = false;
stakeholderEntities = StakeholderEntities;
view: boolean = false;
hasHeader: boolean = true; hasHeader: boolean = true;
header: Header = { header: Header = {
route: "/", route: "/",
@ -54,19 +45,18 @@ export class AppComponent extends BaseComponent implements OnInit {
constructor(protected _route: ActivatedRoute, constructor(protected _route: ActivatedRoute,
protected _router: Router, protected _router: Router,
private smoothScroll: SmoothScroll,
private configurationService: ConfigurationService, private customFilterService:CustomFilterService, private configurationService: ConfigurationService, private customFilterService:CustomFilterService,
private userManagementService: UserManagementService) { private userManagementService: UserManagementService) {
super(); super();
this.configurationService.initStaticPortal(this.irish.portal); this.configurationService.initStaticPortal(this.irish.portal);
//Test track event
// let json = {test: "json"}
// this._piwikService.doTrackEvent(properties,"test", properties.piwikSiteId,location.href,"Linking", "Link", JSON.stringify(json) )
} }
ngOnDestroy() { ngOnDestroy() {
super.ngOnDestroy(); super.ngOnDestroy();
this.customFilterService.clearSubscriptions(); this.customFilterService.clearSubscriptions();
this.configurationService.clearSubscriptions() this.configurationService.clearSubscriptions();
this.smoothScroll.clearSubscriptions();
} }
ngOnInit() { ngOnInit() {
@ -78,16 +68,12 @@ export class AppComponent extends BaseComponent implements OnInit {
initialize() { initialize() {
this.menuItems = [ this.menuItems = [
new MenuItem("national", this.stakeholderEntities.COUNTRY + ' ' + this.stakeholderEntities.STAKEHOLDER, "", "/", false, [], null, {}, null, null, null, null), new MenuItem("national", this.stakeholderUtils.entities.country + ' ' + this.stakeholderUtils.entities.stakeholders, "", "/", false, [], null, {}, null, null, null, null),
new MenuItem("rpo", this.stakeholderEntities.ORGANIZATION + ' ' + this.stakeholderEntities.STAKEHOLDERS, "", "/rpo", false, [], null, {}, null, null, null, null), new MenuItem("rpo", this.stakeholderUtils.entities.organization + ' ' + this.stakeholderUtils.entities.stakeholders, "", "/rpo", false, [], null, {}, null, null, null, null),
new MenuItem("rfo", this.stakeholderEntities.FUNDER + ' ' + this.stakeholderEntities.STAKEHOLDERS, "", "/rfo", false, [], null, {}, null, null, null, null), new MenuItem("rfo", this.stakeholderUtils.entities.funder + ' ' + this.stakeholderUtils.entities.stakeholders, "", "/rfo", false, [], null, {}, null, null, null, null),
new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, null), new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, null),
new MenuItem("repository", "Repository Monitors", "", "/", false, [], null, {}, null, null, null, null), new MenuItem("repository", "Repository Monitors", "", "/", false, [], null, {}, null, null, null, null),
new MenuItem("upload-dois", "Upload DOIs", "", "/upload-dois", false, [], null, {}, null, null, null, null) new MenuItem("upload-dois", "Upload DOIs", "", "/upload-dois", false, [], null, {}, null, null, null, null)
]; ];
} }
public removeView() {
this._router.navigate([], {relativeTo: this._route});
}
} }

@ -1 +1 @@
Subproject commit 50a8d53221bab7f5cdadcec66d22032ac048281c Subproject commit e80f73f9a9ceb65bff5b326e5b187b943415d7ad

View File

@ -6,7 +6,7 @@
<ng-container *ngIf="!showLoading && stakeholders?.length"> <ng-container *ngIf="!showLoading && stakeholders?.length">
<div class="uk-flex uk-flex-middle uk-flex-center uk-position-relative"> <div class="uk-flex uk-flex-middle uk-flex-center uk-position-relative">
<div search-input [searchControl]="keywordControl" searchInputClass="border-bottom" iconPosition="left" <div search-input [searchControl]="keywordControl" searchInputClass="border-bottom" iconPosition="left"
placeholder="Search for {{typeAsLabel}} {{entities.STAKEHOLDERS}}" [disabled]="showLoading" class="uk-width-1-2@m uk-width-1-1"> placeholder="Search for {{typeAsLabel}} {{entities.stakeholders}}" [disabled]="showLoading" class="uk-width-1-2@m uk-width-1-1">
</div> </div>
<div class="uk-flex uk-flex-middle uk-position-right"> <div class="uk-flex uk-flex-middle uk-position-right">
<a (click)="gridView = true" [ngClass]="gridView ? 'active' : ''" class="uk-link-reset uk-margin-small-right">Grid</a> <a (click)="gridView = true" [ngClass]="gridView ? 'active' : ''" class="uk-link-reset uk-margin-small-right">Grid</a>
@ -38,7 +38,7 @@
</div> </div>
<div class="uk-margin-large-top" id="target"> <div class="uk-margin-large-top" id="target">
<div *ngIf="!filteredStakeholders || filteredStakeholders?.length == 0" class="uk-text-center"> <div *ngIf="!filteredStakeholders || filteredStakeholders?.length == 0" class="uk-text-center">
No {{entities.STAKEHOLDERS}} available No {{entities.stakeholders}} available
</div> </div>
<!-- STAKEHOLDERS --> <!-- STAKEHOLDERS -->
<!-- Grid view --> <!-- Grid view -->

View File

@ -1,22 +1,19 @@
import {ChangeDetectorRef, Component, OnInit} from "@angular/core"; import {ChangeDetectorRef, Component, OnInit} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {Stakeholder, StakeholderEntities, StakeholderType} from "../../openaireLibrary/monitor/entities/stakeholder"; import {Stakeholder, StakeholderType} from "../../openaireLibrary/monitor/entities/stakeholder";
import {BaseComponent} from "../../openaireLibrary/sharedComponents/base/base.component";
import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service";
import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {LayoutService} from "src/app/openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {LayoutService} from "src/app/openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {FormBuilder, FormControl} from "@angular/forms"; import {FormBuilder, FormControl} from "@angular/forms";
import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {StakeholderUtils} from "src/app/openaireLibrary/monitor-admin/utils/indicator-utils"; import {StakeholderBaseComponent} from "../../openaireLibrary/monitor-admin/utils/stakeholder-base.component";
@Component({ @Component({
selector: 'browse-stakeholder', selector: 'browse-stakeholder',
templateUrl: `browse-stakeholder.component.html` templateUrl: `browse-stakeholder.component.html`
}) })
export class BrowseStakeholderComponent extends BaseComponent implements OnInit { export class BrowseStakeholderComponent extends StakeholderBaseComponent implements OnInit {
entities = StakeholderEntities;
stakeholderUtils: StakeholderUtils = new StakeholderUtils();
stakeholderType: StakeholderType; stakeholderType: StakeholderType;
stakeholders: Stakeholder[] = []; stakeholders: Stakeholder[] = [];
filteredStakeholders: Stakeholder[] = []; filteredStakeholders: Stakeholder[] = [];
@ -32,9 +29,9 @@ export class BrowseStakeholderComponent extends BaseComponent implements OnInit
pageSize: number = 10; pageSize: number = 10;
keywordControl: FormControl; keywordControl: FormControl;
constructor(private route: ActivatedRoute, constructor(protected _route: ActivatedRoute,
private stakeholderService: StakeholderService,
protected _router: Router, protected _router: Router,
private stakeholderService: StakeholderService,
private layoutService: LayoutService, private layoutService: LayoutService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fb: FormBuilder) { private fb: FormBuilder) {
@ -51,7 +48,7 @@ export class BrowseStakeholderComponent extends BaseComponent implements OnInit
{value: 'alphDsc', label: 'Alphabetically Dsc. (Z-A)'}, {value: 'alphDsc', label: 'Alphabetically Dsc. (Z-A)'},
{value: 'oaDsc', label: '"Open Access %" Dsc.'} {value: 'oaDsc', label: '"Open Access %" Dsc.'}
]; ];
this.stakeholderType = this.route.snapshot.data.type; this.stakeholderType = this._route.snapshot.data.type;
if(!this.stakeholderType) { if(!this.stakeholderType) {
this.navigateToError(); this.navigateToError();
} }

View File

@ -1,5 +1,5 @@
import {StakeholderEntities, stakeholderTypes} from "../openaireLibrary/monitor/entities/stakeholder";
import {Portal} from "../openaireLibrary/utils/entities/adminTool/portal"; import {Portal} from "../openaireLibrary/utils/entities/adminTool/portal";
import {StakeholderConfiguration} from "../openaireLibrary/monitor-admin/utils/indicator-utils";
export class Irish { export class Irish {
public static METADATA_PREFIX = 'NOAMI | '; public static METADATA_PREFIX = 'NOAMI | ';
@ -7,19 +7,27 @@ export class Irish {
public portal: Portal = Portal.getMockCommunityInfo("noami", "Noami",[],[]); public portal: Portal = Portal.getMockCommunityInfo("noami", "Noami",[],[]);
constructor() { constructor() {
(StakeholderEntities as any)['STAKEHOLDER'] = 'Monitor'; StakeholderConfiguration.ENTITIES.stakeholder = 'Monitor';
(StakeholderEntities as any)['STAKEHOLDERS'] = 'Monitors'; StakeholderConfiguration.ENTITIES.stakeholders = 'Monitors';
(StakeholderEntities as any)['FUNDER'] = 'RFO'; StakeholderConfiguration.ENTITIES.funder = 'RFO';
(StakeholderEntities as any)['FUNDERS'] = 'RFOs'; StakeholderConfiguration.ENTITIES.funders = 'RFOs';
(StakeholderEntities as any)['ORGANIZATION'] = 'RPO'; StakeholderConfiguration.ENTITIES.organization = 'RPO';
(StakeholderEntities as any)['ORGANIZATIONS'] = 'RPOs'; StakeholderConfiguration.ENTITIES.organizations = 'RPOs';
stakeholderTypes.length = 0; StakeholderConfiguration.TYPES = [
stakeholderTypes.push( {value: 'funder', label: StakeholderConfiguration.ENTITIES.funder},
{value: 'funder', label: StakeholderEntities.FUNDER}, {value: 'organization', label: StakeholderConfiguration.ENTITIES.organization},
{value: 'organization', label: StakeholderEntities.ORGANIZATION}, {value: 'country', label: StakeholderConfiguration.ENTITIES.country}
{value: 'country', label: StakeholderEntities.COUNTRY} ]
);
StakeholderConfiguration.FUNDER_TYPES = [
{value: 'private', label: 'Private'},
{value: 'government', label: 'Government'}
];
StakeholderConfiguration.VISIBILITIES = [
{icon: 'earth', value: "PUBLIC", label: 'Public'},
]
} }
} }

View File

@ -10,11 +10,16 @@ import {common, commonDev} from "../app/openaireLibrary/utils/properties/environ
let props: EnvProperties = { let props: EnvProperties = {
monitorServiceAPIURL: "http://duffy.di.uoa.gr:19380/uoa-monitor-service", monitorServiceAPIURL: "http://duffy.di.uoa.gr:19380/uoa-monitor-service",
// monitorServiceAPIURL: "http://duffy.di.uoa.gr:19680/uoa-irish-monitor-service/", // monitorServiceAPIURL: "http://duffy.di.uoa.gr:19680/uoa-irish-monitor-service/",
monitorStatsFrameUrl:"https://stats.madgik.di.uoa.gr/stats-api/",
searchOrcidURL: "https://pub.orcid.org/v3.0/", searchOrcidURL: "https://pub.orcid.org/v3.0/",
piwikSiteId: "407", piwikSiteId: "407",
enablePiwikTrack:false, enablePiwikTrack:false,
piwikBaseUrl: 'https://beta.analytics.openaire.eu/piwik.php?idsite=', piwikBaseUrl: 'https://beta.analytics.openaire.eu/piwik.php?idsite=',
disableFrameLoad: true,
adminToolsPortalType: 'irish',
adminToolsCommunity: 'irish'
} }
export let properties: EnvProperties = { export let properties: EnvProperties = {
...common, ...commonDev, ...props ...common, ...commonDev, ...props
} }