connect/src/app/app.component.ts

275 lines
15 KiB
TypeScript
Raw Normal View History

import {Component} from '@angular/core';
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import {Session, User} from './openaireLibrary/login/utils/helper.class';
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
@Component({
//changeDetection: ChangeDetectionStrategy.Default,
//encapsulation: ViewEncapsulation.Emulated,
selector: 'app-root',
styles: [`
`],
template: `
<div [class]="(community)?(community.id +'App communityApp'):'connectApp'">
<navbar *ngIf="properties && showMenu && !community" [portal]="properties.dashboard" [onlyTop]=false
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="false" communityId="connect"></navbar>
<navbar *ngIf="properties && showMenu && community" [portal]="properties.dashboard" [onlyTop]=false
[communityId]="community.id"
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"
searchRoute="/search/find/research-outcomes"
[showHomeMenuItem]="false"></navbar>
<customization *ngIf="properties && community" [properties]="properties"
[communityId]="community.id"></customization>
<div class="custom-main-content">
<main>
<router-outlet></router-outlet>
</main>
</div>
[Trunk | Connect]: Connect redesing 1. app.component.ts: <subscribe> and <invite> components added (floating buttons on the right side of each page for communities). 2. community.component.html: 3. community.component.ts: a. 'projectsCalculated' and 'contentProvidersCalculated' fields added, to calculate tootlip after both requests complete b. added methods for building tootips c. 'activeTab' set to 'summary'. 4. affiliations.component.html: minor phrasing changes (e.g. title). 5. curators.component.html: shortview changed. 6. results.component.ts: Title changed | 'View all' moved to the bottom. 7. customization.component.ts: Changed '--portal-main-color' from '#4C9CD5' to '#4687E6' | Changed '--portal-dark-color' from '#24857F' to '#2D72D6'. 8. invite.component.html: shortview changed. 9. invite.component.ts: 'properties' field as input (get it is called from app.component). 10. invite.module.ts & inviteBasic.module.ts: InviteBasicModule created to declare InviteComponent without routing and login guard | InviteModule imports InviteBasicModule and adds routing and login guar$ 11. subscribe.component.ts: Changes for subscribe button and members | 'properties' field as input (get it is called from app.component). 12. connect-custom.css: css for subscribe and invite buttons and for tooltip with 'community-page-tooltip' class. 13. customization.css: class 'communityBackground' added and css for 'subtitle' class inside 'communityBackground'. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58549 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-24 18:38:35 +02:00
<subscribe id="subscribeBtn" *ngIf="isClient && properties && communityId != null && communityId != ''"
[communityId]="communityId" [properties]="properties"></subscribe>
<!-- && managerOfCommunities -->
<invite id="inviteBtn" *ngIf="isClient && properties && communityId != null && communityId != '' && managerOfCommunities"
[longView]=false [buttonSizeSmall]=false [properties]="properties"></invite>
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
<cookie-law *ngIf="isClient" position="bottom">
OpenAIRE uses cookies in order to function properly.<br>
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible.
By using the OpenAIRE portal you accept our use of cookies. <a
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
points="7 4 13 10 7 16"></polyline></svg>
</span></a>
</cookie-law>
<bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false"
[properties]="properties"></bottom>
<bottom *ngIf="properties && isClient && showMenu && community" class=""
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"
[darkBackground]="false" [centered]="true"></bottom>
</div>
`
})
export class AppComponent {
isClient: boolean = false;
userMenuItems: MenuItem[] = [];
menuItems: RootMenuItem [] = [];
bottomMenuItems: MenuItem[] = [];
public community = null;
properties: EnvProperties;
showMenu: boolean = false;
communities = null;
subscriberOfCommunities = false;
managerOfCommunities = false;
user: User;
[Trunk | Connect]: Connect redesing 1. app.component.ts: <subscribe> and <invite> components added (floating buttons on the right side of each page for communities). 2. community.component.html: 3. community.component.ts: a. 'projectsCalculated' and 'contentProvidersCalculated' fields added, to calculate tootlip after both requests complete b. added methods for building tootips c. 'activeTab' set to 'summary'. 4. affiliations.component.html: minor phrasing changes (e.g. title). 5. curators.component.html: shortview changed. 6. results.component.ts: Title changed | 'View all' moved to the bottom. 7. customization.component.ts: Changed '--portal-main-color' from '#4C9CD5' to '#4687E6' | Changed '--portal-dark-color' from '#24857F' to '#2D72D6'. 8. invite.component.html: shortview changed. 9. invite.component.ts: 'properties' field as input (get it is called from app.component). 10. invite.module.ts & inviteBasic.module.ts: InviteBasicModule created to declare InviteComponent without routing and login guard | InviteModule imports InviteBasicModule and adds routing and login guar$ 11. subscribe.component.ts: Changes for subscribe button and members | 'properties' field as input (get it is called from app.component). 12. connect-custom.css: css for subscribe and invite buttons and for tooltip with 'community-page-tooltip' class. 13. customization.css: class 'communityBackground' added and css for 'subtitle' class inside 'communityBackground'. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58549 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-24 18:38:35 +02:00
communityId: string = "";
// community: {id:string, name:string, logoUrl:string};
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
private router: Router, private userManagementService: UserManagementService) {
router.events.forEach((event) => {
if (event instanceof NavigationStart) {
HelperFunctions.scroll();
}
});
}
ngOnInit() {
this.propertiesService.loadEnvironment()
.then(es => {
this.properties = this.propertiesService.envSpecific;
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
if (typeof document !== 'undefined') {
try {
this.isClient = true;
} catch (e) {
}
}
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.init();
});
}, error => {
console.log("App couldn't fetch properties");
console.log(error);
});
}
private init() {
let communityId: string = "";
if (this.properties.environment == "development") {
this.showMenu = false;
this.route.queryParams.subscribe(params => {
communityId = (params['communityId']) ? params['communityId'] : ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.buildMenu(communityId);
})
} else {
this.showMenu = false;
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.buildMenu(communityId);
}
[Trunk | Connect]: Connect redesing 1. app.component.ts: <subscribe> and <invite> components added (floating buttons on the right side of each page for communities). 2. community.component.html: 3. community.component.ts: a. 'projectsCalculated' and 'contentProvidersCalculated' fields added, to calculate tootlip after both requests complete b. added methods for building tootips c. 'activeTab' set to 'summary'. 4. affiliations.component.html: minor phrasing changes (e.g. title). 5. curators.component.html: shortview changed. 6. results.component.ts: Title changed | 'View all' moved to the bottom. 7. customization.component.ts: Changed '--portal-main-color' from '#4C9CD5' to '#4687E6' | Changed '--portal-dark-color' from '#24857F' to '#2D72D6'. 8. invite.component.html: shortview changed. 9. invite.component.ts: 'properties' field as input (get it is called from app.component). 10. invite.module.ts & inviteBasic.module.ts: InviteBasicModule created to declare InviteComponent without routing and login guard | InviteModule imports InviteBasicModule and adds routing and login guar$ 11. subscribe.component.ts: Changes for subscribe button and members | 'properties' field as input (get it is called from app.component). 12. connect-custom.css: css for subscribe and invite buttons and for tooltip with 'community-page-tooltip' class. 13. customization.css: class 'communityBackground' added and css for 'subtitle' class inside 'communityBackground'. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58549 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-24 18:38:35 +02:00
this.communityId = communityId;
}
public buildMenu(communityId: string) {
let community = null;
this.community = null;
this._communitiesService.getCommunitiesState().subscribe(
communities => {
if (!communities || communities.length == 0 && communityId !== null && communityId !== '') {
return;
}
for (var com of communities) {
if ((communityId && communityId != "" && com.communityId == communityId
&& community != null) ||
(
!(communityId && communityId != "" && com.communityId == communityId)
&&
this.managerOfCommunities && this.subscriberOfCommunities)) {
break;
}
if (this.user && com['status'] != "hidden") {
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
this.managerOfCommunities = true;
} else if (com.managers.indexOf(this.user.email) != -1) {
this.managerOfCommunities = true;
}
}
if (communityId && communityId != "" && com.communityId == communityId) {
community = com;
let isCommunityManager: boolean = false;
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
isCommunityManager = true;
} else if (this.user && com.managers.indexOf(this.user.email) != -1) {
isCommunityManager = true;
}
this.community = {
id: community.communityId,
name: (community.shortTitle) ? community.shortTitle : community.title,
logoUrl: community.logoUrl
};
this.menuItems = [];
/* this.menuItems.push(
{
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find", "/search/find/publications", "/search/find/datasets", "/search/find/software", "/search/find/other", "/search/find/projects", "/search/find/dataproviders"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
items: [
new MenuItem("", "Research outcomes", "", "/search/find/research-outcomes", false, [], ["/search/find/research-outcomes"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
]
});*/
this.menuItems.push({
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
items: []
});
this.menuItems.push(
{
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
items: [
new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})
]
});
this.menuItems.push(
{
rootItem: new MenuItem("about", "About", "", "", false, [], [], {}),
items: [
new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Gateway curators", "", "/curators", false, [], ["/curators"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Sources and methology", "", "/content", false, [], ["/content"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Projects and funding Opportunities", "", "/projects", false, [], ["/projects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "National Bulletins", "", "/national-bulletins", false, [], ["/national-bulletins"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
//new MenuItem("", "Subjects", "", "/subjects", false, [], ["/subjects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
]
});
if (isCommunityManager) {
this.menuItems.push(
{
rootItem: new MenuItem("manage", "Manage", 'https://beta.admin.connect.openaire.eu/dashboard?communityId=' + community.communityId, "", false, [], [], {}),
items: []
});
}
}
}
if (community == null) {
this.menuItems = [];
this.menuItems.push({
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], null, {}),
items: [
new MenuItem("", "Learn the process", "", "/about/learn-how", false, [], [], {}),
new MenuItem("", "Publications", "", "/publications", false, [], ["/publications"], {}),
new MenuItem("", "Roadmap", "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard", "", false, [], [], {}),
new MenuItem("", "FAQs", "", "/about/faq", false, [], ["/about/faq"], {})
]
});
this.menuItems.push({
rootItem: new MenuItem("communities", "Communities", "", "/search/find/communities", false, [], null, {}),
items: []
});
this.menuItems.push({
rootItem: new MenuItem("contact-us", "Contact us", "", "/contact-us", false, [], null, {}),
items: []
});
this.bottomMenuItems = [
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
];
this.userMenuItems = [];
if (Session.isPortalAdministrator(this.user)) {
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
"", false, [], [], {}))
}
if (this.user) {
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
"/myCommunities", false, [], [], {}));
}
} else {
this.bottomMenuItems = [
new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
];
if (this.properties.showContent) {
this.bottomMenuItems.push(new MenuItem("", "Sources and methology", "", "/content", false, [], [], {}));
}
if(this.user) {
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Invite users", "", "/invite", false, [], [], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
];
if (this.managerOfCommunities) {
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {}))
}
}
}
this.showMenu = true;
});
}
}