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