1
|
import {Component} from '@angular/core';
|
2
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
3
|
|
4
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
5
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
6
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
7
|
|
8
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
9
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
10
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
11
|
|
12
|
@Component({
|
13
|
//changeDetection: ChangeDetectionStrategy.Default,
|
14
|
//encapsulation: ViewEncapsulation.Emulated,
|
15
|
selector: 'app-root',
|
16
|
styles: [`
|
17
|
`],
|
18
|
template: `
|
19
|
|
20
|
<navbar *ngIf="properties" [portal]="properties.dashboard" [properties]=properties [onlyTop]=false [user]="user"
|
21
|
[communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems></navbar>
|
22
|
<div class="custom-main-content">
|
23
|
<main>
|
24
|
<router-outlet></router-outlet>
|
25
|
</main>
|
26
|
</div>
|
27
|
<cookie-law *ngIf="isClient" position="bottom">
|
28
|
OpenAIRE uses cookies in order to function properly.<br>
|
29
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
|
30
|
experience possible.
|
31
|
By using the OpenAIRE portal you accept our use of cookies. <a
|
32
|
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
33
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
|
34
|
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
|
35
|
</span></a>
|
36
|
</cookie-law>
|
37
|
<bottom *ngIf="isClient && properties" [properties]="properties"></bottom>
|
38
|
|
39
|
`
|
40
|
|
41
|
})
|
42
|
export class AppComponent {
|
43
|
isClient: boolean = false;
|
44
|
clientLoad = 0;
|
45
|
|
46
|
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {}),
|
47
|
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {})]
|
48
|
|
49
|
|
50
|
menuItems: RootMenuItem [] = [];
|
51
|
|
52
|
feedbackmail: string;
|
53
|
properties: EnvProperties;
|
54
|
user: User;
|
55
|
|
56
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
57
|
private router: Router, private userManagementService: UserManagementService) {
|
58
|
router.events.forEach((event) => {
|
59
|
if (event instanceof NavigationStart) {
|
60
|
HelperFunctions.scroll();
|
61
|
}
|
62
|
});
|
63
|
}
|
64
|
|
65
|
ngOnInit() {
|
66
|
|
67
|
if (typeof document !== 'undefined') {
|
68
|
try {
|
69
|
this.isClient = true;
|
70
|
|
71
|
} catch (e) {
|
72
|
}
|
73
|
|
74
|
}
|
75
|
this.propertiesService.loadEnvironment()
|
76
|
.then(es => {
|
77
|
this.propertiesService.setEnvProperties(es);
|
78
|
this.properties = this.propertiesService.envSpecific;
|
79
|
this.feedbackmail = this.properties.feedbackmail;
|
80
|
this.userManagementService.getUserInfo().subscribe(user => {
|
81
|
this.user = user;
|
82
|
this.buildMenu();
|
83
|
});
|
84
|
//console.log(this.properties.loginUrl);
|
85
|
}, error => {
|
86
|
console.log("App couldn't fetch properties");
|
87
|
console.log(error);
|
88
|
|
89
|
});
|
90
|
}
|
91
|
|
92
|
buildMenu() {
|
93
|
//TODO add check for research results route
|
94
|
this.menuItems = [
|
95
|
{
|
96
|
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
|
97
|
items: [
|
98
|
new MenuItem("", "Research Outcomes", "", "/search/find/research-results", false, [], [], {}),
|
99
|
new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], {}),
|
100
|
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {}),
|
101
|
new MenuItem("", "Organizations", "", "/search/find/organizations/", false, ["organization"], ["/search/find/organizations"], {})
|
102
|
]
|
103
|
},
|
104
|
{
|
105
|
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}),
|
106
|
//rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}),
|
107
|
items: []
|
108
|
//rootItem: new MenuItem("share", "Share", "", "", false, [], ["/participate/deposit-publications", "/participate/deposit-datasets"], {}),
|
109
|
//items: [new MenuItem("", "Publications", "", "/participate/deposit-publications", false, ["publication"], ["/participate/deposit-publications"], {}),
|
110
|
// new MenuItem("", "Research Data", "", "/participate/deposit-datasets", false, ["dataset"], ["/participate/deposit-datasets"], {})]
|
111
|
},
|
112
|
{
|
113
|
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
114
|
items: [new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
115
|
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})]
|
116
|
},
|
117
|
{
|
118
|
rootItem: new MenuItem("datasources", "Content Providers", "", "", false, ["datasource"], [], {}),
|
119
|
items: [new MenuItem("", "Data Policies", "https://beta.openaire.eu/oa-policies-mandates", "", false, ["datasource"], [""], {}),
|
120
|
new MenuItem("", "Repositories", "", "/search/content-providers", false, ["datasource"], ["/search/content-providers"], {}),
|
121
|
new MenuItem("", "Journals", "", "/search/journals", false, ["datasource"], ["/search/journals"], {}),
|
122
|
new MenuItem("", "Registries", "", "/search/entity-registries", false, ["datasource"], ["/search/entity-registries"], {}),
|
123
|
new MenuItem("", "Browse all", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {})]
|
124
|
}
|
125
|
];
|
126
|
if (Session.isPortalAdministrator(this.user)) {
|
127
|
this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
|
128
|
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
129
|
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
130
|
|
131
|
} else if (Session.isClaimsCurator(this.user)) {
|
132
|
this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
|
133
|
|
134
|
}
|
135
|
if(this.user) {
|
136
|
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
137
|
}
|
138
|
}
|
139
|
}
|
140
|
|