Project

General

Profile

1
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {ActivatedRoute} from '@angular/router';
4

    
5
import { EnvProperties} from './openaireLibrary/utils/properties/env-properties';
6
import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
7
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
8
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
9
import {Session} from './openaireLibrary/login/utils/helper.class';
10
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
11

    
12
@Component({
13
  //changeDetection: ChangeDetectionStrategy.Default,
14
  //encapsulation: ViewEncapsulation.Emulated,
15
  selector: 'app-root',
16
  styles: [`
17
  `],
18
  template: `
19

    
20
        <navbar *ngIf= "properties && showMenu && !community" portal="connect" onlyTop=false    [userMenuItems]=userMenuItems [menuItems]=menuItems
21
        [(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl"  [(cookieDomain)]="properties.cookieDomain"  [showMenu]=showMenu></navbar>
22
        <navbar *ngIf= "properties && showMenu  && community" portal="connect" onlyTop=false [(communityId)]="community.id"  [userMenuItems]=userMenuItems [menuItems]=menuItems
23
        [(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl"  [(cookieDomain)]="properties.cookieDomain" [(community)]=community [showMenu]=showMenu></navbar>
24

    
25
                   <div class="custom-main-content"   >
26
                      <main>
27
                       <router-outlet></router-outlet>
28
                     </main>
29
                    </div>
30
          <feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackmail]=properties.feedbackmail></feedback>
31
          <cookie-law *ngIf= "isClient" position="bottom">
32
              OpenAIRE uses cookies in order to function properly.<br>
33
              Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing experience possible.
34
              By using the OpenAIRE portal you accept our use of cookies. <a href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
35
              <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
36
              </span></a>
37
          </cookie-law>
38
           <bottom *ngIf= "isClient && showMenu && !community" [menuItems]=bottomMenuItems></bottom>
39
           <bottom *ngIf= "isClient && community" [showSocialButton] = "false" [showMenu]=true [showDnet] =false showOpenaire=true [(communityId)]="community.id" [(APIUrl)]="properties.adminToolsAPIURL" [menuItems]=bottomMenuItems ></bottom>
40

    
41
`
42

    
43
})
44
export class AppComponent {
45
   isClient:boolean = false;
46

    
47

    
48
   userMenuItems:MenuItem[] =[];
49

    
50

    
51
  menuItems:RootMenuItem []=[];
52
  bottomMenuItems:MenuItem[] =[];
53
  public community = null;
54
  properties:EnvProperties;
55
  showMenu:boolean = false;
56
  communities = null;
57
  //  community: {id:string, name:string, logoUrl:string};
58
   constructor(  private  route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, private _communitiesService:CommunitiesService ) {
59
   }
60

    
61
   ngOnInit() {
62
     this.propertiesService.loadEnvironment()
63
             .then(es => {
64
                 this.propertiesService.setEnvProperties(es);
65
                 this.properties = this.propertiesService.envSpecific;
66

    
67
     this.route.queryParams.subscribe(data => {
68
       var community = null;
69
       this.community = null;
70
       this.showMenu = false;
71

    
72
       this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe (
73
         communities => {
74
               this.userMenuItems =[ new MenuItem("","My profile","","",false,[],[],{}),
75
                  new MenuItem("","My claims","","/myclaims",false,[],["/myclaims"],{}),
76
                ];
77
                for(var com of communities){
78
                   if((data['communityId'] && data['communityId']!="" &&  com.communityId  == data['communityId'])
79
                   || (ConnectHelper.getCommunityFromDomain(document.location.hostname) ==  com.communityId )){
80
                    community = com;
81
                    this.community = {id: community.communityId, name: (community.shortTitle)?community.shortTitle:community.title, logoUrl:community.logoUrl};
82
                    this.menuItems= [
83
                      // {rootItem: new MenuItem("dashboard","Dashboard","","/",false,[],[],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
84
                      // items: []
85
                      // },
86
                      {rootItem: new MenuItem("search","Search","","",false,[],[],{}),
87
                        items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
88
                        new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
89
                        new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
90
                       new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
91
                       new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
92
                      ]},
93
                      {
94
                        rootItem: new MenuItem("monitor","Monitor","","/monitor",false,[],["/statistics"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
95
                        items: []
96
                      },
97
                      {
98
                      rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets"],{communityId:community.communityId}),
99
                      items: [new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],{communityId:community.communityId}),
100
                      new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],{communityId:community.communityId})]
101
                      },
102
                      {
103
                      rootItem: new MenuItem("link","Link","","/participate/claim",false,[],["/participate/claim"],{communityId:community.communityId}),
104
                      items: []
105
                      }
106
                  ];
107

    
108
                  }
109

    
110
                }
111
                if(community == null){
112
                  this.menuItems= [];
113
                  this.bottomMenuItems =[
114
                  new MenuItem("","About","https://beta.openaire.eu/project-factsheets","",false,[],[],{}),
115
                  new MenuItem("","News - Events","https://beta.openaire.eu/news-events","",false,[],[],{}),
116
                  new MenuItem("","Blog","https://blogs.openaire.eu/","",false,[],[],{}),
117
                  new MenuItem("","Contact us","https://beta.openaire.eu/contact-us","",false,[],[],{})
118
                ];
119
                if(this.properties.showContent){
120
                  this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
121
                }
122

    
123
              }else{
124
                this.bottomMenuItems = [
125
                  new MenuItem("","About","","/about",false,[],["/about"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
126
                  new MenuItem("","Organizations","","/organizations",false,[],["/organizations"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId})               
127
                ];
128
                if(this.properties.showContent){
129
                  this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
130
                }
131
              }
132
                this.showMenu = true;
133

    
134
         });
135

    
136

    
137
   });
138
     if (typeof document !== 'undefined') {
139
       try{
140
         this.isClient = true;
141
       }catch (e) {
142
       }
143
     }
144
   }, error => {
145
     console.log("App couldn't fetch properties");
146
       console.log(error);
147

    
148
   });
149
   }
150
}
(2-2/4)