2018-10-30 16:31:16 +01:00
|
|
|
/**
|
|
|
|
* Created by stefania on 3/21/16.
|
|
|
|
*/
|
|
|
|
|
2018-12-03 12:33:03 +01:00
|
|
|
import { Component, ElementRef } from '@angular/core';
|
2018-10-30 16:31:16 +01:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
import {CommunityService} from "./openaireLibrary/connect/community/community.service";
|
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'dashboard',
|
|
|
|
templateUrl: 'dashboard.component.html',
|
|
|
|
})
|
|
|
|
|
|
|
|
export class DashboardComponent {
|
|
|
|
communityId:string= null;
|
|
|
|
communityType = null;
|
|
|
|
properties:EnvProperties;
|
|
|
|
|
2018-12-03 12:33:03 +01:00
|
|
|
constructor( private element: ElementRef, private route: ActivatedRoute, private _communityService:CommunityService) {}
|
2018-10-30 16:31:16 +01:00
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
this.route.queryParams.subscribe(data => {
|
2018-12-03 12:33:03 +01:00
|
|
|
this.scroll();
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
this.communityId = ((data['communityId'])?data['communityId']:data['community']);
|
|
|
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
|
|
|
community => {
|
|
|
|
this.communityType = community.type;
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.error('Server responded: ' + error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-12-03 12:33:03 +01:00
|
|
|
public scroll() {
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
this.element.nativeElement.scrollIntoView();
|
|
|
|
}
|
|
|
|
}
|
2018-10-30 16:31:16 +01:00
|
|
|
}
|