2022-06-27 14:02:16 +02:00
|
|
|
import {ChangeDetectorRef, Component, ElementRef, Inject, Input, Renderer2, ViewChild} from '@angular/core';
|
2019-04-24 14:02:11 +02:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2021-10-21 12:18:28 +02:00
|
|
|
import {DOCUMENT, Location} from '@angular/common';
|
2019-04-24 14:02:11 +02:00
|
|
|
import {Meta, Title} from '@angular/platform-browser';
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
|
|
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
|
|
|
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
|
|
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
2018-11-26 14:07:58 +01:00
|
|
|
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
2019-09-13 09:47:29 +02:00
|
|
|
import {Session, User} from '../openaireLibrary/login/utils/helper.class';
|
2019-04-11 11:39:46 +02:00
|
|
|
import {StatisticsForDashboardComponent} from '../statistics/statistics.component';
|
2019-04-24 14:02:11 +02:00
|
|
|
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
2019-06-05 15:39:02 +02:00
|
|
|
import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service";
|
|
|
|
import {SearchCommunityProjectsService} from "../openaireLibrary/connect/projects/searchProjects.service";
|
|
|
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
2019-07-31 12:42:45 +02:00
|
|
|
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
|
2019-08-02 16:56:03 +02:00
|
|
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
2019-09-13 09:47:29 +02:00
|
|
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
2020-05-07 12:29:52 +02:00
|
|
|
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
2020-05-31 13:34:51 +02:00
|
|
|
import {FetchResearchResults} from "../openaireLibrary/utils/fetchEntitiesClasses/fetchResearchResults.class";
|
|
|
|
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
2020-07-15 17:53:19 +02:00
|
|
|
import {Subscription} from "rxjs";
|
2020-07-17 01:25:23 +02:00
|
|
|
import {properties} from "../../environments/environment";
|
2021-05-17 12:10:27 +02:00
|
|
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
2021-05-25 00:18:32 +02:00
|
|
|
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
2022-06-30 17:25:22 +02:00
|
|
|
import {OpenaireEntities} from '../openaireLibrary/utils/properties/searchFields';
|
2024-03-11 12:27:27 +01:00
|
|
|
import {PluginsService} from "../openaireLibrary/services/plugins.service";
|
|
|
|
import {PluginTemplate} from "../openaireLibrary/utils/entities/adminTool/pluginTemplate";
|
|
|
|
import {Plugin} from "../openaireLibrary/utils/entities/adminTool/plugin";
|
|
|
|
import {PluginUtils} from "../openaireLibrary/dashboard/plugins/utils/pluginUtils";
|
2019-04-24 14:02:11 +02:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
@Component({
|
2019-04-24 14:02:11 +02:00
|
|
|
selector: 'community',
|
|
|
|
templateUrl: 'community.component.html',
|
2024-03-11 12:27:27 +01:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
})
|
2018-03-12 17:34:48 +01:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
export class CommunityComponent {
|
2019-08-02 16:56:03 +02:00
|
|
|
public url: string = null;
|
2021-02-19 18:52:12 +01:00
|
|
|
properties: EnvProperties = properties;
|
2018-03-22 16:38:42 +01:00
|
|
|
@Input() communityId = null;
|
2018-02-28 14:10:11 +01:00
|
|
|
public community = null;
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2023-07-13 10:48:23 +02:00
|
|
|
public portal = null;
|
2024-03-11 12:27:27 +01:00
|
|
|
subscriptions: Subscription[] = [];
|
2019-09-13 09:47:29 +02:00
|
|
|
private user: User;
|
2024-03-11 12:27:27 +01:00
|
|
|
public showLoading = true;
|
|
|
|
pluginTemplates: PluginTemplate[] = [];
|
|
|
|
plugins: Plugin[] = [];
|
|
|
|
public pluginsByPlacement: Map<string,{plugin:Plugin, template:PluginTemplate}[]> = new Map();
|
|
|
|
public pluginUtils = new PluginUtils();
|
2021-05-25 00:18:32 +02:00
|
|
|
|
2019-04-24 14:02:11 +02:00
|
|
|
constructor(
|
2019-02-18 16:15:53 +01:00
|
|
|
private element: ElementRef,
|
2019-04-24 14:02:11 +02:00
|
|
|
private route: ActivatedRoute,
|
|
|
|
private _router: Router,
|
|
|
|
private location: Location,
|
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
|
|
|
private _piwikService: PiwikService,
|
|
|
|
private config: ConfigurationService,
|
|
|
|
private _communityService: CommunityService,
|
2024-03-11 12:27:27 +01:00
|
|
|
|
2019-09-13 09:47:29 +02:00
|
|
|
private seoService: SEOService,
|
2021-10-21 12:18:28 +02:00
|
|
|
private userManagementService: UserManagementService,
|
2024-03-11 12:27:27 +01:00
|
|
|
private _pluginsService:PluginsService) {
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2019-04-24 14:02:11 +02:00
|
|
|
var description = "OpenAIRE - Connect, Community Dashboard, research community";
|
|
|
|
var title = "OpenAIRE - Connect";
|
|
|
|
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);
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
}
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
public ngOnInit() {
|
2024-03-11 12:27:27 +01:00
|
|
|
this.url = properties.domain + properties.baseLink + this._router.url;
|
2020-07-17 01:25:23 +02:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.url, false);
|
|
|
|
this._meta.updateTag({content: this.url}, "property='og:url'");
|
2024-03-11 12:27:27 +01:00
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
2020-07-17 01:25:23 +02:00
|
|
|
this.user = user;
|
|
|
|
}));
|
2024-03-11 12:27:27 +01:00
|
|
|
this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe(
|
2021-02-19 18:52:12 +01:00
|
|
|
community => {
|
2021-05-18 09:29:16 +02:00
|
|
|
this.community = community;
|
2021-05-17 12:10:27 +02:00
|
|
|
if(community && !ConnectHelper.isPrivate(community, this.user)) {
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2020-07-17 01:25:23 +02:00
|
|
|
this._meta.updateTag({content: community.description}, "name='description'");
|
|
|
|
this._meta.updateTag({content: community.description}, "property='og:description'");
|
|
|
|
this._meta.updateTag({content: community.title}, "property='og:title'");
|
|
|
|
this._title.setTitle(community.title);
|
2024-03-11 12:27:27 +01:00
|
|
|
this.subscriptions.push(this._piwikService.trackView(this.properties, community.title).subscribe());
|
|
|
|
this.getPagePlugins();
|
|
|
|
|
2020-07-17 01:25:23 +02:00
|
|
|
}
|
2021-02-19 18:52:12 +01:00
|
|
|
}));
|
2021-09-07 12:13:06 +02:00
|
|
|
|
2024-03-11 12:27:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getPagePlugins() {
|
|
|
|
this.showLoading = true;
|
2024-04-04 08:29:37 +02:00
|
|
|
this.subscriptions.push(this._pluginsService.getPluginTemplatesByPageRoute(this.properties.adminToolsAPIURL, this.community.communityId, this._router.url.split('?')[0] ).subscribe(
|
2024-03-11 12:27:27 +01:00
|
|
|
templates => {
|
|
|
|
this.pluginTemplates = templates;
|
|
|
|
|
2024-04-04 08:29:37 +02:00
|
|
|
this.subscriptions.push(this._pluginsService.getPluginsByPageRoute(this.properties.adminToolsAPIURL, this.community.communityId, this._router.url.split('?')[0]).subscribe(
|
2024-03-11 12:27:27 +01:00
|
|
|
plugins => {
|
|
|
|
this.plugins = plugins;
|
|
|
|
this.pluginsByPlacement = new Map();
|
|
|
|
for(let pos of this.pluginUtils.placementsOptions){
|
|
|
|
this.pluginsByPlacement.set(pos.value,[]);
|
|
|
|
}
|
|
|
|
let self = this;
|
|
|
|
this.pluginTemplates.forEach(_ => {
|
|
|
|
let plugin:Plugin = null;
|
|
|
|
for(let pl of plugins){
|
|
|
|
if (pl.templateId == _._id){
|
|
|
|
plugin = pl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!plugin){
|
|
|
|
plugin = new Plugin("", "",_);
|
|
|
|
this.plugins.push(plugin);
|
|
|
|
}
|
|
|
|
plugin.object = PluginUtils.initializeObjectAndCompare(_.code,plugin.object)
|
|
|
|
this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ });
|
|
|
|
});
|
|
|
|
for(let placement of this.pluginUtils.placementsOptions){
|
|
|
|
this.pluginsByPlacement.get(placement.value).sort(function (a, b) {
|
|
|
|
return a.plugin.order - b.plugin.order;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
error => {}));
|
2021-11-08 16:41:25 +01:00
|
|
|
|
2021-02-19 18:52:12 +01:00
|
|
|
},
|
2024-03-11 12:27:27 +01:00
|
|
|
error => {}));
|
2021-05-18 09:29:16 +02:00
|
|
|
}
|
2018-01-26 16:00:07 +01:00
|
|
|
}
|