connect-admin/src/app/pages/dashboard/dashboard.component.ts

46 lines
1.4 KiB
TypeScript

/**
* Created by stefania on 3/21/16.
*/
import {Component, ElementRef, OnInit} from '@angular/core';
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 implements OnInit {
communityId: string = null;
communityType = null;
properties: EnvProperties;
constructor( private element: ElementRef, private route: ActivatedRoute, private _communityService: CommunityService) {}
ngOnInit() {
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(data => {
this.scroll();
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);
}
);
});
});
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
}