Revision 61408
Added by Konstantinos Triantafyllou over 2 years ago
app.component.ts | ||
---|---|---|
1 | 1 |
import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from '@angular/core'; |
2 |
import {ActivatedRoute, NavigationEnd, Params, Router} from '@angular/router'; |
|
2 |
import {ActivatedRoute, Data, NavigationEnd, Params, Router} from '@angular/router';
|
|
3 | 3 |
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; |
4 | 4 |
import {Role, Session, User} from './openaireLibrary/login/utils/helper.class'; |
5 | 5 |
import {UserManagementService} from "./openaireLibrary/services/user-management.service"; |
... | ... | |
16 | 16 |
import {Option} from "./openaireLibrary/sharedComponents/input/input.component"; |
17 | 17 |
import {StakeholderUtils} from "./utils/indicator-utils"; |
18 | 18 |
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll"; |
19 |
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper"; |
|
19 | 20 |
|
20 | 21 |
|
21 | 22 |
@Component({ |
... | ... | |
26 | 27 |
properties: EnvProperties = properties; |
27 | 28 |
user: User; |
28 | 29 |
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null); |
30 |
data: BehaviorSubject<Data> = new BehaviorSubject<Data>(null); |
|
29 | 31 |
hasSidebar: boolean = false; |
30 | 32 |
hasHeader: boolean = false; |
31 | 33 |
hasAdminMenu: boolean = false; |
... | ... | |
71 | 73 |
while (r.firstChild) { |
72 | 74 |
r = r.firstChild; |
73 | 75 |
} |
74 |
let params = r.snapshot.params; |
|
75 | 76 |
this.paramsResolved = true; |
76 |
this.params.next(params); |
|
77 |
this.params.next(r.snapshot.params); |
|
78 |
this.data.next(r.snapshot.data); |
|
77 | 79 |
} |
78 | 80 |
})); |
79 | 81 |
} |
... | ... | |
128 | 130 |
if (stakeholder) { |
129 | 131 |
this.stakeholder = stakeholder; |
130 | 132 |
LinksResolver.setProperties(this.stakeholder.alias); |
131 |
this.setProperties(this.stakeholder.type, this.stakeholder.alias);
|
|
133 |
this.setProperties(this.stakeholder.alias, this.stakeholder.type);
|
|
132 | 134 |
if (isSearch) { |
133 | 135 |
this.activeTopic = null; |
134 | 136 |
} else if (params && params['topic'] && !this.activeTopic) { |
... | ... | |
142 | 144 |
} else { |
143 | 145 |
this.stakeholder = null; |
144 | 146 |
LinksResolver.resetProperties(); |
145 |
this.resetProperties(); |
|
146 | 147 |
this.navigateToError(); |
147 | 148 |
this.buildMenu(); |
148 | 149 |
this.loading = false; |
... | ... | |
166 | 167 |
this.stakeholder = null; |
167 | 168 |
this.buildMenu(); |
168 | 169 |
this.loading = false; |
169 |
this.resetProperties(); |
|
170 | 170 |
} |
171 | 171 |
} |
172 | 172 |
})); |
173 |
this.subscriptions.push(this.data.subscribe(data => { |
|
174 |
if(data && data.portal) { |
|
175 |
this.setProperties(data.portal); |
|
176 |
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity); |
|
177 |
} |
|
178 |
})); |
|
173 | 179 |
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { |
174 | 180 |
this.user = user; |
175 | 181 |
if (user) { |
... | ... | |
416 | 422 |
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user)); |
417 | 423 |
} |
418 | 424 |
|
419 |
private resolvePageInner() { |
|
420 |
if (document !== undefined) { |
|
421 |
let header = document.getElementById('pager_header_content'); |
|
422 |
let inner = document.getElementById('page_content_inner'); |
|
423 |
if (header) { |
|
424 |
inner.setAttribute('style', '{margin-top:' + header.offsetHeight + '}'); |
|
425 |
} else { |
|
426 |
inner.setAttribute('style', '{margin-top:' + 0 + '}'); |
|
427 |
} |
|
428 |
} |
|
425 |
public isPublicOrIsMember(visibility: Visibility): boolean { |
|
426 |
return !(visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC")); |
|
429 | 427 |
} |
430 | 428 |
|
431 |
public isPublicOrIsMember(visibility: Visibility): boolean { |
|
432 |
if (visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC")) { |
|
433 |
return false; |
|
429 |
setProperties(id, type = null){ |
|
430 |
this.properties.adminToolsCommunity = id; |
|
431 |
if(type) { |
|
432 |
this.properties.adminToolsPortalType = type; |
|
433 |
} else { |
|
434 |
ConnectHelper.setPortalTypeFromPid(id); |
|
434 | 435 |
} |
435 |
return true; |
|
436 |
} |
|
437 |
setProperties(type, communityId){ |
|
438 |
this.properties.adminToolsCommunity = communityId; |
|
439 |
this.properties.adminToolsPortalType = type; |
|
440 | 436 |
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity); |
441 | 437 |
} |
442 |
resetProperties(){ |
|
443 |
this.properties.adminToolsCommunity = "monitor"; |
|
444 |
this.properties.adminToolsPortalType = "monitor"; |
|
445 |
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity); |
|
446 |
} |
|
447 |
|
|
448 |
/* createSearchParameters() { |
|
449 |
if (!this.stakeholder) { |
|
450 |
return {}; |
|
451 |
} |
|
452 |
if (this.stakeholder.type == "funder") { |
|
453 |
return {"relfunder": encodeURIComponent("\"" + this.stakeholder.index_id + "||" + this.stakeholder.index_name + "||" + this.stakeholder.index_shortName + "\"")}; |
|
454 |
} else if (this.stakeholder.type == "ri") { |
|
455 |
return {"community": encodeURIComponent("\"" + this.stakeholder.index_id + "||" + this.stakeholder.index_name + "\"")}; |
|
456 |
} else if (this.stakeholder.type == "organization") { |
|
457 |
return {"cf": true}; |
|
458 |
} |
|
459 |
}*/ |
|
460 | 438 |
} |
Also available in: Unified diff
[Monitor Dashboard | Trunk]: Update to angular 11