/**
 * Created by stefania on 3/21/16.
 */

import { Component } from '@angular/core';
import {Properties} from './utils/properties';
import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
import {ActivatedRoute} from '@angular/router';

@Component({
  selector: 'metadata-registry-service',
  templateUrl: './app.component.html',
})

export class AppComponent {
  title = 'Metadata Registry Service';
  isClient:boolean = false;


   userMenuItems:MenuItem[] =  [ new MenuItem("","My profile","","",false,[],[],{})];

   menuItems:RootMenuItem [] = [];

//   menuItems:RootMenuItem [] = [
//     {rootItem: new MenuItem("search","Search","","/search/find",false,[],["/search/find"],{}),
//       items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],{}),
//       new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],{}),
//       new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],{}),
//       new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],{}),
//       new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],{}),
//       new MenuItem("","Organizations","","/search/find/organizations/",false,["organization"],["/search/find/organizations"],{})
//     ]}
//
// ];
logInUrl = null;
logOutUrl = null;
community: {id:string, name:string, logoUrl:string};

   constructor(  private  route: ActivatedRoute) {}

   ngOnInit() {
     this.route.queryParams.subscribe(data => {

       if(data['community'] && data['community']!=""){
         this.community = {id: data['community'], name: "Egi Federation", logoUrl:"https:\/\/egi.eu/wp-content/uploads/2016/05/cropped-logo_site-1-300x300.png"};


       }else{
         this.community = null;

       }

   });
     this.logInUrl = Properties.getLoginURL();
     this.logOutUrl = Properties.getLogoutURL();
     console.log("login url "+this.logInUrl)
     if (typeof document !== 'undefined') {
       try{
         this.isClient = true;
       }catch (e) {
       }
     }
   }
}
