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

41 lines
1.2 KiB
TypeScript

/**
* Created by stefania on 3/21/16.
*/
import { Component } 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 {
communityId:string= null;
communityType = null;
properties:EnvProperties;
constructor( private route: ActivatedRoute, private _communityService:CommunityService) {}
ngOnInit() {
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(data => {
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);
}
);
});
});
}
}