Project

General

Profile

1
import {Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
2
import {Observable} from 'rxjs';
3
import {ActivatedRoute, NavigationStart, Router} 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

    
9
import {Session} from './openaireLibrary/login/utils/helper.class';
10
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
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" portal="explore" [properties]=properties [onlyTop]=false
21
            [communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems></navbar>
22
    <div class="custom-main-content">
23
      <main>
24
        <router-outlet></router-outlet>
25
      </main>
26
    </div>
27
    <feedback *ngIf="isClient && properties" portalName="Explore" [feedbackmail]=feedbackmail></feedback>
28
    <cookie-law *ngIf="isClient" position="bottom">
29
      OpenAIRE uses cookies in order to function properly.<br>
30
      Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
31
      experience possible.
32
      By using the OpenAIRE portal you accept our use of cookies. <a
33
      href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
34
              <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
35
                   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 && properties" [properties]="properties"></bottom>
39

    
40
  `
41

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

    
47
  userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {}),
48
    new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {})]
49

    
50

    
51
  menuItems: RootMenuItem [] = [];
52

    
53
  feedbackmail: string;
54
  properties: EnvProperties;
55

    
56
  constructor(private  route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
57
              private router: Router) {
58
    router.events.forEach((event) => {
59
      if (event instanceof NavigationStart) {
60
        HelperFunctions.scroll();
61
      }
62
    });
63
  }
64

    
65
  ngOnInit() {
66

    
67
    if (typeof document !== 'undefined') {
68
      try {
69
        this.isClient = true;
70

    
71
      } catch (e) {
72
      }
73

    
74
    }
75
    this.propertiesService.loadEnvironment()
76
      .then(es => {
77
        this.propertiesService.setEnvProperties(es);
78
        this.properties = this.propertiesService.envSpecific;
79
        this.feedbackmail = this.properties.feedbackmail;
80
        this.buildMenu();
81

    
82
        //console.log(this.properties.loginUrl);
83
      }, error => {
84
        console.log("App couldn't fetch properties");
85
        console.log(error);
86

    
87
      });
88
  }
89

    
90
  buildMenu() {
91

    
92
    this.menuItems = [
93
      {
94
        rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
95
        items: [new MenuItem("", "Publications", "", "/search/find/publications", false, ["publication"], ["/search/find/publications"], {}),
96
          new MenuItem("", "Research Data", "", "/search/find/datasets", false, ["dataset"], ["/search/find/datasets"], {}),
97
          new MenuItem("", "Software", "", "/search/find/software", false, ["software"], ["/search/find/software"], {}),
98
          new MenuItem("", "Other Research Products", "", "/search/find/other", false, ["orp"], ["/search/find/other"], {}),
99
          new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], {}),
100
          new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {}),
101
          new MenuItem("", "Organizations", "", "/search/find/organizations/", false, ["organization"], ["/search/find/organizations"], {})
102
        ]
103
      },
104
      {
105
        rootItem: new MenuItem("share", "Share", "", "", false, [], ["/participate/deposit-publications", "/participate/deposit-datasets"], {}),
106
        items: [new MenuItem("", "Publications", "", "/participate/deposit-publications", false, ["publication"], ["/participate/deposit-publications"], {}),
107
          new MenuItem("", "Research Data", "", "/participate/deposit-datasets", false, ["dataset"], ["/participate/deposit-datasets"], {})]
108
      },
109
      {
110
        rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}),
111
        items: [new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], {}),
112
          new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})]
113
      },
114
      {
115
        rootItem: new MenuItem("datasources", "Content Providers", "", "", false, ["datasource"], [], {}),
116
        items: [new MenuItem("", "Data Policies", "https://beta.openaire.eu/oa-policies-mandates", "", false, ["datasource"], [""], {}),
117
          new MenuItem("", "Repositories", "", "/search/content-providers", false, ["datasource"], ["/search/content-providers"], {}),
118
          new MenuItem("", "Journals", "", "/search/journals", false, ["datasource"], ["/search/journals"], {}),
119
          new MenuItem("", "Registries", "", "/search/entity-registries", false, ["datasource"], ["/search/entity-registries"], {}),
120
          new MenuItem("", "Browse all", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {})]
121
      }
122
    ];
123
    if (Session.isPortalAdministrator()) {
124
      this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
125
      this.userMenuItems.push(new MenuItem("", "Manage helptexts",
126
        ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
127

    
128
    } else if (Session.isClaimsCurator()) {
129
      this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
130

    
131
    }
132
    this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
133
  }
134
}
135

    
(2-2/4)