[Monitor Dashboard | Trunk]: Reset user menu items before build
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57884 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
d7a84cb3aa
commit
5da23e9673
|
@ -17,7 +17,6 @@ import {MenuItem} from "./openaireLibrary/sharedComponents/menu";
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
user: User;
|
user: User;
|
||||||
loginCheck: boolean = false;
|
|
||||||
hasSidebar: boolean = false;
|
hasSidebar: boolean = false;
|
||||||
hasHeader: boolean = false;
|
hasHeader: boolean = false;
|
||||||
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
||||||
|
@ -65,7 +64,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}));
|
}));
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.loginCheck = true;
|
|
||||||
this.buildMenu();
|
this.buildMenu();
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log("App couldn't fetch properties");
|
console.log("App couldn't fetch properties");
|
||||||
|
@ -96,6 +94,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
buildMenu() {
|
buildMenu() {
|
||||||
|
this.userMenuItems = [];
|
||||||
if (Session.isPortalAdministrator(this.user)) {
|
if (Session.isPortalAdministrator(this.user)) {
|
||||||
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
||||||
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
||||||
|
|
|
@ -25,347 +25,348 @@ import {MenuItem} from "../openaireLibrary/sharedComponents/menu";
|
||||||
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'monitor',
|
selector: 'monitor',
|
||||||
templateUrl: 'monitor.component.html',
|
templateUrl: 'monitor.component.html',
|
||||||
})
|
})
|
||||||
export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
||||||
private static sidebarStatus: {
|
private static sidebarStatus: {
|
||||||
id;
|
id;
|
||||||
status;
|
status;
|
||||||
};
|
};
|
||||||
public user: User;
|
public user: User;
|
||||||
public userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
public userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
||||||
public subscriptions: any[] = [];
|
public subscriptions: any[] = [];
|
||||||
public piwiksub: any;
|
public piwiksub: any;
|
||||||
public pageContents = null;
|
public pageContents = null;
|
||||||
public divContents = null;
|
public divContents = null;
|
||||||
public status: number;
|
public status: number;
|
||||||
public loading: boolean = true;
|
public loading: boolean = true;
|
||||||
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
||||||
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
||||||
public activeTopic: Topic = null;
|
public activeTopic: Topic = null;
|
||||||
public activeCategory: Category = null;
|
public activeCategory: Category = null;
|
||||||
public activeSubCategory: SubCategory = null;
|
public activeSubCategory: SubCategory = null;
|
||||||
public sideBar: Sidebar = null;
|
public sideBar: Sidebar = null;
|
||||||
public errorCodes: ErrorCodes;
|
public errorCodes: ErrorCodes;
|
||||||
public stakeholder: Stakeholder;
|
public stakeholder: Stakeholder;
|
||||||
public numberResults: Map<number, number> = new Map<number, number>();
|
public numberResults: Map<number, number> = new Map<number, number>();
|
||||||
public chartsActiveType: Map<number, IndicatorPath> = new Map<number, IndicatorPath>();
|
public chartsActiveType: Map<number, IndicatorPath> = new Map<number, IndicatorPath>();
|
||||||
private errorMessages: ErrorMessagesComponent;
|
private errorMessages: ErrorMessagesComponent;
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
fundingL0;
|
fundingL0;
|
||||||
startYear;
|
startYear;
|
||||||
endYear;
|
endYear;
|
||||||
|
|
||||||
public keyword: FormControl;
|
public keyword: FormControl;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _meta: Meta,
|
private _meta: Meta,
|
||||||
private _title: Title,
|
private _title: Title,
|
||||||
private _piwikService: PiwikService,
|
private _piwikService: PiwikService,
|
||||||
private helper: HelperService,
|
private helper: HelperService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private statisticsService: StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
private layoutService: LayoutService,
|
private layoutService: LayoutService,
|
||||||
private seoService: SEOService,
|
private seoService: SEOService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private sanitizer: DomSanitizer, private _fb: FormBuilder) {
|
private sanitizer: DomSanitizer, private _fb: FormBuilder) {
|
||||||
this.errorCodes = new ErrorCodes();
|
this.errorCodes = new ErrorCodes();
|
||||||
this.errorMessages = new ErrorMessagesComponent();
|
this.errorMessages = new ErrorMessagesComponent();
|
||||||
this.status = this.errorCodes.LOADING;
|
this.status = this.errorCodes.LOADING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.keyword = this._fb.control('');
|
this.keyword = this._fb.control('');
|
||||||
this.keyword.valueChanges.subscribe(value => {
|
this.keyword.valueChanges.subscribe(value => {
|
||||||
console.log("Keyword Changed!");
|
console.log("Keyword Changed!");
|
||||||
//TODO do a real action
|
//TODO do a real action
|
||||||
});
|
});
|
||||||
this.route.data
|
this.route.data
|
||||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||||
let subscription: Subscription;
|
let subscription: Subscription;
|
||||||
this.route.params.subscribe(params => {
|
this.route.params.subscribe(params => {
|
||||||
if(subscription) {
|
if (subscription) {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
this.properties = data.envSpecific;
|
this.properties = data.envSpecific;
|
||||||
var url = data.envSpecific.baseLink + this._router.url;
|
var url = data.envSpecific.baseLink + this._router.url;
|
||||||
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
|
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
|
||||||
this.status = this.errorCodes.LOADING;
|
this.status = this.errorCodes.LOADING;
|
||||||
this.numberResults = new Map<number, number>();
|
this.numberResults = new Map<number, number>();
|
||||||
this.chartsActiveType = new Map<number, IndicatorPath>();
|
this.chartsActiveType = new Map<number, IndicatorPath>();
|
||||||
// subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
// subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
||||||
let stakeholder: Stakeholder = null;
|
let stakeholder: Stakeholder = null;
|
||||||
if (params['stakeholder'] == "fwf") {
|
if (params['stakeholder'] == "fwf") {
|
||||||
stakeholder = new Stakeholder(null, "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF",
|
stakeholder = new Stakeholder(null, "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF",
|
||||||
false, "fwf", true, true, null);
|
false, "fwf", true, true, null);
|
||||||
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
||||||
stakeholder.logoUrl = "./assets/fwf.png";
|
stakeholder.logoUrl = "./assets/fwf.png";
|
||||||
} else if (params['stakeholder'] == "arc") {
|
} else if (params['stakeholder'] == "arc") {
|
||||||
stakeholder = new Stakeholder(null, "funder", "arc_________::ARC",
|
stakeholder = new Stakeholder(null, "funder", "arc_________::ARC",
|
||||||
"Australian Research Council (ARC)", "ARC",
|
"Australian Research Council (ARC)", "ARC",
|
||||||
false, null, true, true, null);
|
false, null, true, true, null);
|
||||||
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
||||||
stakeholder.logoUrl = "./assets/arc1.gif";
|
stakeholder.logoUrl = "./assets/arc1.gif";
|
||||||
} else {
|
|
||||||
stakeholder = new Stakeholder(null, "funder", "ec__________::EC",
|
|
||||||
"European Commission", "EC",
|
|
||||||
false, "ec", true, true, null);
|
|
||||||
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
|
||||||
stakeholder.logoUrl = "./assets/ec.png";
|
|
||||||
}
|
|
||||||
if (stakeholder) {
|
|
||||||
this.stakeholder = stakeholder;
|
|
||||||
this.seoService.createLinkForCanonicalURL(url, false);
|
|
||||||
this._meta.updateTag({content: url}, "property='og:url'");
|
|
||||||
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
|
|
||||||
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
|
|
||||||
this._meta.updateTag({content: description}, "name='description'");
|
|
||||||
this._meta.updateTag({content: description}, "property='og:description'");
|
|
||||||
this._meta.updateTag({content: title}, "property='og:title'");
|
|
||||||
this._title.setTitle(title);
|
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
|
||||||
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
|
|
||||||
}
|
|
||||||
//this.getDivContents();
|
|
||||||
this.getPageContents();
|
|
||||||
this.status = this.errorCodes.DONE;
|
|
||||||
this.setView(params);
|
|
||||||
}
|
|
||||||
// }, error => {
|
|
||||||
// this.navigateToError();
|
|
||||||
// });
|
|
||||||
this.subscriptions.push(subscription);
|
|
||||||
} else {
|
|
||||||
this.setView(params);
|
|
||||||
}
|
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
|
||||||
this.user = user;
|
|
||||||
this.buildMenu();
|
|
||||||
}, error => {
|
|
||||||
console.log("App couldn't fetch properties");
|
|
||||||
console.log(error);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
canExit() {
|
|
||||||
if (this.sideBar) {
|
|
||||||
let status = [];
|
|
||||||
this.sideBar.items.forEach(item => {
|
|
||||||
status.push(item.open);
|
|
||||||
});
|
|
||||||
MonitorComponent.sidebarStatus = {
|
|
||||||
id: this.activeTopic.alias,
|
|
||||||
status: status
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get open() {
|
|
||||||
return this.layoutService.open;
|
|
||||||
}
|
|
||||||
|
|
||||||
public toggleOpen(event = null) {
|
|
||||||
if (!event) {
|
|
||||||
this.layoutService.setOpen(!this.open);
|
|
||||||
} else if (event && event['value'] === true) {
|
|
||||||
this.layoutService.setOpen(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getPageContents() {
|
|
||||||
this.helper.getPageHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
|
||||||
this.pageContents = contents;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private getDivContents() {
|
|
||||||
this.helper.getDivHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
|
||||||
this.divContents = contents;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private setView(params: Params) {
|
|
||||||
if (params['topic']) {
|
|
||||||
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && topic.isPublic && topic.isActive);
|
|
||||||
if (this.activeTopic) {
|
|
||||||
if (params['category']) {
|
|
||||||
this.activeCategory = this.activeTopic.categories.find(category =>
|
|
||||||
(category.alias === params['category']) && category.isPublic && category.isActive);
|
|
||||||
if(!this.activeCategory) {
|
|
||||||
this.navigateToError();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
|
|
||||||
if (this.activeCategory) {
|
|
||||||
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
||||||
subCategory.isPublic && subCategory.isActive);
|
|
||||||
this.setSideBar();
|
|
||||||
if (this.activeSubCategory) {
|
|
||||||
this.setIndicators();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.setSideBar();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.activeCategory) {
|
|
||||||
if (params['subCategory']) {
|
|
||||||
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
||||||
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
|
|
||||||
if(!this.activeSubCategory) {
|
|
||||||
this.navigateToError();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
||||||
subCategory.isPublic && subCategory.isActive);
|
|
||||||
}
|
|
||||||
if (this.activeSubCategory) {
|
|
||||||
this.setSideBar();
|
|
||||||
this.setIndicators();
|
|
||||||
} else {
|
|
||||||
this.navigateToError();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.activeSubCategory = null;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.navigateToError();
|
stakeholder = new Stakeholder(null, "funder", "ec__________::EC",
|
||||||
return;
|
"European Commission", "EC",
|
||||||
|
false, "ec", true, true, null);
|
||||||
|
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
||||||
|
stakeholder.logoUrl = "./assets/ec.png";
|
||||||
}
|
}
|
||||||
|
if (stakeholder) {
|
||||||
|
this.stakeholder = stakeholder;
|
||||||
|
this.seoService.createLinkForCanonicalURL(url, false);
|
||||||
|
this._meta.updateTag({content: url}, "property='og:url'");
|
||||||
|
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
|
||||||
|
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
|
||||||
|
this._meta.updateTag({content: description}, "name='description'");
|
||||||
|
this._meta.updateTag({content: description}, "property='og:description'");
|
||||||
|
this._meta.updateTag({content: title}, "property='og:title'");
|
||||||
|
this._title.setTitle(title);
|
||||||
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
|
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
|
||||||
|
}
|
||||||
|
//this.getDivContents();
|
||||||
|
this.getPageContents();
|
||||||
|
this.status = this.errorCodes.DONE;
|
||||||
|
this.setView(params);
|
||||||
|
}
|
||||||
|
// }, error => {
|
||||||
|
// this.navigateToError();
|
||||||
|
// });
|
||||||
|
this.subscriptions.push(subscription);
|
||||||
|
} else {
|
||||||
|
this.setView(params);
|
||||||
|
}
|
||||||
|
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
|
this.user = user;
|
||||||
|
this.buildMenu();
|
||||||
|
}, error => {
|
||||||
|
console.log("App couldn't fetch properties");
|
||||||
|
console.log(error);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
canExit() {
|
||||||
|
if (this.sideBar) {
|
||||||
|
let status = [];
|
||||||
|
this.sideBar.items.forEach(item => {
|
||||||
|
status.push(item.open);
|
||||||
|
});
|
||||||
|
MonitorComponent.sidebarStatus = {
|
||||||
|
id: this.activeTopic.alias,
|
||||||
|
status: status
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get open() {
|
||||||
|
return this.layoutService.open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggleOpen(event = null) {
|
||||||
|
if (!event) {
|
||||||
|
this.layoutService.setOpen(!this.open);
|
||||||
|
} else if (event && event['value'] === true) {
|
||||||
|
this.layoutService.setOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getPageContents() {
|
||||||
|
this.helper.getPageHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
||||||
|
this.pageContents = contents;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDivContents() {
|
||||||
|
this.helper.getDivHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
||||||
|
this.divContents = contents;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private setView(params: Params) {
|
||||||
|
if (params['topic']) {
|
||||||
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && topic.isPublic && topic.isActive);
|
||||||
|
if (this.activeTopic) {
|
||||||
|
if (params['category']) {
|
||||||
|
this.activeCategory = this.activeTopic.categories.find(category =>
|
||||||
|
(category.alias === params['category']) && category.isPublic && category.isActive);
|
||||||
|
if (!this.activeCategory) {
|
||||||
|
this.navigateToError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.activeTopic = this.stakeholder.topics.find(topic => topic.isPublic && topic.isActive);
|
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
|
||||||
if (this.activeTopic) {
|
if (this.activeCategory) {
|
||||||
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
||||||
if (this.activeCategory) {
|
subCategory.isPublic && subCategory.isActive);
|
||||||
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => subCategory.isPublic && subCategory.isActive);
|
this.setSideBar();
|
||||||
if (this.activeSubCategory) {
|
if (this.activeSubCategory) {
|
||||||
this.setSideBar();
|
this.setIndicators();
|
||||||
this.setIndicators();
|
|
||||||
} else {
|
|
||||||
this.navigateToError();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.navigateToError();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.navigateToError();
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.setSideBar();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (this.activeCategory) {
|
||||||
|
if (params['subCategory']) {
|
||||||
private setSideBar() {
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
||||||
let items: Item[] = [];
|
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
|
||||||
this.activeTopic.categories.forEach((category, index) => {
|
if (!this.activeSubCategory) {
|
||||||
if (category.isPublic && category.isActive) {
|
this.navigateToError();
|
||||||
let subItems: Item[] = [];
|
return;
|
||||||
category.subCategories.forEach(subCategory => {
|
|
||||||
if (subCategory.isPublic && subCategory.isActive) {
|
|
||||||
subItems.push(new Item(subCategory.alias, subCategory.name, (
|
|
||||||
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias + '/' + subCategory.alias),
|
|
||||||
null, null, false));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let open = this.activeCategory.alias === category.alias;
|
|
||||||
if (MonitorComponent.sidebarStatus && MonitorComponent.sidebarStatus.id === this.activeTopic.alias) {
|
|
||||||
open = MonitorComponent.sidebarStatus.status[index];
|
|
||||||
}
|
|
||||||
items.push(new Item(category.alias, category.name, (
|
|
||||||
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias),
|
|
||||||
subItems, null, open));
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
if(items.length === 0) {
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
||||||
items.push(new Item('noCategories', 'No categories available yet', null, [], null, false));
|
subCategory.isPublic && subCategory.isActive);
|
||||||
|
}
|
||||||
|
if (this.activeSubCategory) {
|
||||||
|
this.setSideBar();
|
||||||
|
this.setIndicators();
|
||||||
|
} else {
|
||||||
|
this.navigateToError();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.activeSubCategory = null;
|
||||||
}
|
}
|
||||||
this.sideBar = new Sidebar(items, null);
|
} else {
|
||||||
}
|
this.navigateToError();
|
||||||
|
return;
|
||||||
private setIndicators() {
|
}
|
||||||
let urls: Map<string, number[]> = new Map<string, number[]>();
|
} else {
|
||||||
this.activeSubCategory.numbers.forEach((number, index) => {
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.isPublic && topic.isActive);
|
||||||
if (number.isActive && number.isPublic) {
|
if (this.activeTopic) {
|
||||||
let url = number.indicatorPaths[0].url;
|
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
|
||||||
//add fundingLevel0 filter in the query
|
if (this.activeCategory) {
|
||||||
if (this.fundingL0 && number.indicatorPaths[0].filters.get("fundingL0")) {
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => subCategory.isPublic && subCategory.isActive);
|
||||||
url = url + number.indicatorPaths[0].filters.get("fundingL0").replace(ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix, encodeURIComponent(this.fundingL0));
|
if (this.activeSubCategory) {
|
||||||
}
|
this.setSideBar();
|
||||||
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
this.setIndicators();
|
||||||
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
} else {
|
||||||
indexes.push(index);
|
this.navigateToError();
|
||||||
urls.set(pair, indexes);
|
}
|
||||||
}
|
} else {
|
||||||
});
|
this.navigateToError();
|
||||||
urls.forEach((indexes, pair) => {
|
|
||||||
pair = JSON.parse(pair);
|
|
||||||
this.statisticsService.getNumbers(pair[0], pair[1]).subscribe(response => {
|
|
||||||
indexes.forEach(index => {
|
|
||||||
let result = JSON.parse(JSON.stringify(response));
|
|
||||||
this.activeSubCategory.numbers[index].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
|
||||||
if (result) {
|
|
||||||
result = result[jsonPath];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.numberResults.set(index, result);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
this.activeSubCategory.charts.forEach((chart, index) => {
|
|
||||||
if (chart.indicatorPaths.length > 0) {
|
|
||||||
chart.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(chart.indicatorPaths[0]);
|
|
||||||
this.chartsActiveType.set(index, chart.indicatorPaths[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
|
||||||
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
|
||||||
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath, this.fundingL0, this.startYear, this.endYear)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public setActiveChart(index, type: string) {
|
|
||||||
let activeChart = this.activeSubCategory.charts[index].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
|
|
||||||
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
|
|
||||||
this.chartsActiveType.set(index, activeChart);
|
|
||||||
}
|
|
||||||
|
|
||||||
private navigateToError() {
|
|
||||||
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
|
|
||||||
}
|
|
||||||
|
|
||||||
public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) {
|
|
||||||
let url = stakeholder + '/' + topic + ((category) ? ('/'
|
|
||||||
+ category) : '') + ((subcategory) ? ('/' + subcategory) : '');
|
|
||||||
return this._router.navigate([url]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public quote(param: string): string {
|
|
||||||
return StringUtils.quote(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
|
||||||
if (this.piwiksub) {
|
|
||||||
this.piwiksub.unsubscribe();
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.navigateToError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private setSideBar() {
|
||||||
|
let items: Item[] = [];
|
||||||
|
this.activeTopic.categories.forEach((category, index) => {
|
||||||
|
if (category.isPublic && category.isActive) {
|
||||||
|
let subItems: Item[] = [];
|
||||||
|
category.subCategories.forEach(subCategory => {
|
||||||
|
if (subCategory.isPublic && subCategory.isActive) {
|
||||||
|
subItems.push(new Item(subCategory.alias, subCategory.name, (
|
||||||
|
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias + '/' + subCategory.alias),
|
||||||
|
null, null, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let open = this.activeCategory.alias === category.alias;
|
||||||
|
if (MonitorComponent.sidebarStatus && MonitorComponent.sidebarStatus.id === this.activeTopic.alias) {
|
||||||
|
open = MonitorComponent.sidebarStatus.status[index];
|
||||||
|
}
|
||||||
|
items.push(new Item(category.alias, category.name, (
|
||||||
|
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias),
|
||||||
|
subItems, null, open));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (items.length === 0) {
|
||||||
|
items.push(new Item('noCategories', 'No categories available yet', null, [], null, false));
|
||||||
|
}
|
||||||
|
this.sideBar = new Sidebar(items, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setIndicators() {
|
||||||
|
let urls: Map<string, number[]> = new Map<string, number[]>();
|
||||||
|
this.activeSubCategory.numbers.forEach((number, index) => {
|
||||||
|
if (number.isActive && number.isPublic) {
|
||||||
|
let url = number.indicatorPaths[0].url;
|
||||||
|
//add fundingLevel0 filter in the query
|
||||||
|
if (this.fundingL0 && number.indicatorPaths[0].filters.get("fundingL0")) {
|
||||||
|
url = url + number.indicatorPaths[0].filters.get("fundingL0").replace(ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix, encodeURIComponent(this.fundingL0));
|
||||||
|
}
|
||||||
|
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
||||||
|
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
||||||
|
indexes.push(index);
|
||||||
|
urls.set(pair, indexes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
urls.forEach((indexes, pair) => {
|
||||||
|
pair = JSON.parse(pair);
|
||||||
|
this.statisticsService.getNumbers(pair[0], pair[1]).subscribe(response => {
|
||||||
|
indexes.forEach(index => {
|
||||||
|
let result = JSON.parse(JSON.stringify(response));
|
||||||
|
this.activeSubCategory.numbers[index].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
||||||
|
if (result) {
|
||||||
|
result = result[jsonPath];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.numberResults.set(index, result);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.activeSubCategory.charts.forEach((chart, index) => {
|
||||||
|
if (chart.indicatorPaths.length > 0) {
|
||||||
|
chart.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(chart.indicatorPaths[0]);
|
||||||
|
this.chartsActiveType.set(index, chart.indicatorPaths[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
||||||
|
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
||||||
|
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath, this.fundingL0, this.startYear, this.endYear)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public setActiveChart(index, type: string) {
|
||||||
|
let activeChart = this.activeSubCategory.charts[index].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
|
||||||
|
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
|
||||||
|
this.chartsActiveType.set(index, activeChart);
|
||||||
|
}
|
||||||
|
|
||||||
|
private navigateToError() {
|
||||||
|
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
|
||||||
|
}
|
||||||
|
|
||||||
|
public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) {
|
||||||
|
let url = stakeholder + '/' + topic + ((category) ? ('/'
|
||||||
|
+ category) : '') + ((subcategory) ? ('/' + subcategory) : '');
|
||||||
|
return this._router.navigate([url]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public quote(param: string): string {
|
||||||
|
return StringUtils.quote(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
if (this.piwiksub) {
|
||||||
|
this.piwiksub.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildMenu() {
|
buildMenu() {
|
||||||
|
this.userMenuItems = [];
|
||||||
if (Session.isPortalAdministrator(this.user)) {
|
if (Session.isPortalAdministrator(this.user)) {
|
||||||
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
||||||
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
||||||
|
|
||||||
}
|
}
|
||||||
if(this.user) {
|
if (this.user) {
|
||||||
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue