Revision 59969
Added by Argiro Kokogiannaki over 3 years ago
app.component.ts | ||
---|---|---|
1 | 1 |
import {Component} from '@angular/core'; |
2 |
import {ActivatedRoute, NavigationEnd, NavigationStart, Router} from '@angular/router'; |
|
3 | 2 |
|
4 | 3 |
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; |
5 | 4 |
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; |
6 | 5 |
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; |
7 |
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; |
|
8 | 6 |
import {FilterInfo, PortalAggregators} from "./utils/aggregators"; |
9 | 7 |
import {UserManagementService} from "./openaireLibrary/services/user-management.service"; |
10 | 8 |
import {User} from "./openaireLibrary/login/utils/helper.class"; |
... | ... | |
12 | 10 |
import {portalProperties} from "../environments/environment-aggregator"; |
13 | 11 |
import {properties} from "../environments/environment"; |
14 | 12 |
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper"; |
13 |
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service"; |
|
14 |
import {Subscriber} from "rxjs"; |
|
15 | 15 |
|
16 | 16 |
@Component({ |
17 | 17 |
selector: 'app-root', |
... | ... | |
53 | 53 |
footer = portalProperties.sectionFooter; |
54 | 54 |
header: Header; |
55 | 55 |
agg: FilterInfo = null; |
56 |
|
|
56 |
subscriptions = []; |
|
57 | 57 |
constructor(private propertiesService: EnvironmentSpecificService, |
58 |
private userManagementService: UserManagementService) { |
|
58 |
private userManagementService: UserManagementService, private configurationService: ConfigurationService) { |
|
59 |
this.id = ConnectHelper.getCommunityFromDomain(this.properties.domain); |
|
60 |
this.agg = PortalAggregators.getFilterInfoByMenuId(this.id); |
|
61 |
this.configurationService.initStaticCommunityInformation(PortalAggregators.getCommunityInfoByMenuId(this.id)); |
|
59 | 62 |
} |
60 |
|
|
63 |
ngOnDestroy() { |
|
64 |
this.subscriptions.forEach(subscription => { |
|
65 |
if (subscription instanceof Subscriber) { |
|
66 |
subscription.unsubscribe(); |
|
67 |
} |
|
68 |
}); |
|
69 |
this.configurationService.clearSubscriptions(); |
|
70 |
this.userManagementService.clearSubscriptions(); |
|
71 |
} |
|
61 | 72 |
ngOnInit() { |
62 | 73 |
if (typeof document !== 'undefined') { |
63 | 74 |
this.isClient = true; |
... | ... | |
76 | 87 |
}; |
77 | 88 |
this.buildMenu(); |
78 | 89 |
} |
79 |
this.userManagementService.getUserInfo().subscribe(user => { |
|
90 |
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
80 | 91 |
this.user = user; |
81 | 92 |
this.loginCheck = true; |
82 | 93 |
this.userMenuItems = []; |
83 | 94 |
if (this.user) { |
84 | 95 |
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); |
85 | 96 |
} |
86 |
}); |
|
97 |
}));
|
|
87 | 98 |
} |
88 | 99 |
|
89 | 100 |
private buildMenu() { |
90 | 101 |
this.menuItems = [ |
91 | 102 |
{rootItem: new MenuItem("home", "Home", "", "/", false, [], null, {}), items: []}, |
92 | 103 |
{ |
93 |
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], null, {}),
|
|
104 |
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
|
|
94 | 105 |
items: [] |
95 | 106 |
}, |
96 | 107 |
{ |
97 |
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], null, {}), |
|
98 |
//rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}), |
|
108 |
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}), |
|
99 | 109 |
items: [] |
100 |
//rootItem: new MenuItem("share", "Share", "", "", false, [], null, {}), |
|
101 |
//items: [new MenuItem("", "Publications", "", "/participate/deposit-publications", false, ["publication"], null, {}), |
|
102 |
// new MenuItem("", "Research Data", "", "/participate/deposit-datasets", false, ["dataset"], null, {})] |
|
103 | 110 |
}, |
104 | 111 |
{ |
105 |
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], null, {}),
|
|
106 |
items: [new MenuItem("", "Start linking", "", "/participate/claim", false, [], null, {}),
|
|
112 |
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
|
113 |
items: [new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
|
107 | 114 |
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})] |
108 | 115 |
} |
109 | 116 |
]; |
110 | 117 |
let params = {}; |
111 | 118 |
params[this.agg.queryFieldName] = this.agg.valueId; |
112 |
if ((portalProperties.entities.publication.isEnabled && portalProperties.entities.publication.simpleSearchPage) || |
|
113 |
(portalProperties.entities.dataset.isEnabled && portalProperties.entities.dataset.simpleSearchPage) || |
|
114 |
(portalProperties.entities.software.isEnabled && portalProperties.entities.software.simpleSearchPage) || |
|
115 |
portalProperties.entities.other.isEnabled && portalProperties.entities.other.simpleSearchPage) { |
|
116 |
|
|
117 |
this.menuItems[1].items.push(new MenuItem("", "Research outcomes", "", "/search/find/research-outcomes", false, [], [], params)) |
|
118 |
} |
|
119 |
|
|
120 |
if (portalProperties.entities.project.isEnabled && portalProperties.entities.project.simpleSearchPage) { |
|
121 |
this.menuItems[1].items.push(new MenuItem("", "Projects", "", "/search/find/projects/", false, [], [], |
|
122 |
{cf: true})) |
|
123 |
} |
|
124 |
if (portalProperties.entities.datasource.isEnabled && portalProperties.entities.datasource.simpleSearchPage) { |
|
125 |
this.menuItems[1].items.push(new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, [], [], params)) |
|
126 |
} |
|
127 |
if (portalProperties.entities.organization.isEnabled && portalProperties.entities.organization.simpleSearchPage) { |
|
128 |
this.menuItems[1].items.push(new MenuItem("", "Organizations", "", "/search/find/organizations/", false, [], [], params)) |
|
129 |
} |
|
119 |
this.menuItems[1].items.push(new MenuItem("", "Research outcomes", "", "/search/find/research-outcomes", false, [], ["/search/find/research-outcomes"], params)) |
|
120 |
|
|
121 |
this.menuItems[1].items.push(new MenuItem("", "Projects", "", "/search/find/projects", false, ["project"], ["/search/find/projects"], |
|
122 |
{cf: true})); |
|
123 |
this.menuItems[1].items.push(new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], params)) |
|
124 |
this.menuItems[1].items.push(new MenuItem("", "Organizations", "", "/search/find/organizations", false, ["organization"], ["/search/find/organizations"], params)) |
|
125 |
|
|
130 | 126 |
} |
131 | 127 |
} |
Also available in: Unified diff
[Aggregator|Trunk]
- use mock admin tool response for enabled entities/ pages
- disable helptexts
- remove unused components
- add again isRoute enabled for claims/ deposit pages