1
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
2
|
import {ViewChild, ChangeDetectionStrategy} from '@angular/core';
|
3
|
import {ViewEncapsulation} from '@angular/core';
|
4
|
import {ActivatedRoute, Router} from '@angular/router';
|
5
|
import {Location} from '@angular/common';
|
6
|
import {Title, Meta} from '@angular/platform-browser';
|
7
|
|
8
|
import {Observable} from 'rxjs/Observable';
|
9
|
|
10
|
import "rxjs/add/observable/zip";
|
11
|
|
12
|
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
13
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
14
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
15
|
|
16
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
17
|
import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service';
|
18
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
19
|
|
20
|
@Component({
|
21
|
selector: 'communities',
|
22
|
templateUrl: 'communities.component.html',
|
23
|
})
|
24
|
|
25
|
export class CommunitiesComponent {
|
26
|
public piwiksub: any;
|
27
|
public subfunders: any;
|
28
|
|
29
|
public pageTitle = "OpenAIRE"
|
30
|
|
31
|
public communitiesResults = null;
|
32
|
|
33
|
properties:EnvProperties;
|
34
|
|
35
|
constructor (
|
36
|
private route: ActivatedRoute,
|
37
|
private _router: Router,
|
38
|
private location: Location,
|
39
|
private _meta: Meta,
|
40
|
private _title: Title,
|
41
|
private _piwikService:PiwikService,
|
42
|
private _communitiesService:CommunitiesService,
|
43
|
private config: ConfigurationService) {
|
44
|
|
45
|
var description = "Community Dashboard";
|
46
|
var title = "Community Dashboard";
|
47
|
|
48
|
this._meta.updateTag({content:description},"name='description'");
|
49
|
this._meta.updateTag({content:description},"property='og:description'");
|
50
|
this._meta.updateTag({content:title},"property='og:title'");
|
51
|
this._title.setTitle(title);
|
52
|
}
|
53
|
|
54
|
public ngOnInit() {
|
55
|
this.route.data
|
56
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
57
|
this.properties = data.envSpecific;
|
58
|
var url = data.envSpecific.baseLink+this._router.url
|
59
|
this._meta.updateTag({content:url},"property='og:url'");
|
60
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
61
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe();
|
62
|
}
|
63
|
|
64
|
this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe(
|
65
|
communitiesResults => {
|
66
|
this.communitiesResults = communitiesResults;
|
67
|
//console.log(communitiesResults);
|
68
|
});
|
69
|
});
|
70
|
}
|
71
|
|
72
|
public ngOnDestroy() {
|
73
|
if(this.piwiksub){
|
74
|
this.piwiksub.unsubscribe();
|
75
|
}
|
76
|
}
|
77
|
isProduction():boolean{
|
78
|
return ConnectHelper.isProduction(document.location.hostname);
|
79
|
|
80
|
}
|
81
|
getProductionPrefix():string{
|
82
|
return ConnectHelper.getProductionPrefix(document.location.hostname);
|
83
|
}
|
84
|
}
|