Project

General

Profile

1
import {Component, Input, OnInit} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
3

    
4
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
5
import {User} from '../../../openaireLibrary/login/utils/helper.class';
6
import {HelperService} from "../../../openaireLibrary/utils/helper/helper.service";
7
import {Meta, Title} from "@angular/platform-browser";
8
import {SEOService} from "../../../openaireLibrary/sharedComponents/SEO/SEO.service";
9
import {PiwikService} from "../../../openaireLibrary/utils/piwik/piwik.service";
10
import {UserManagementService} from "../../../openaireLibrary/services/user-management.service";
11
import {Breadcrumb} from "../../../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
12
import {Subscriber, Subscription} from "rxjs";
13
import {properties} from "../../../../environments/environment";
14

    
15
declare var UIkit;
16

    
17
@Component({
18
  selector: 'invite',
19
  templateUrl: './invite.component.html',
20
})
21
export class InviteComponent implements OnInit {
22
  @Input() longView: boolean = true;
23
  @Input() communityId = null;
24
  public properties: EnvProperties = properties;
25
  public pageTitle: string = "Invite";
26
  public user: User;
27
  public url: string;
28
  public pageContents;
29
  public divContents
30
  public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'invite'}];
31
  private subs: Subscription[] = [];
32
  
33
  constructor(
34
    private route: ActivatedRoute,
35
    private _router: Router,
36
    private _meta: Meta,
37
    private helper: HelperService,
38
    private _title: Title,
39
    private seoService: SEOService,
40
    private _piwikService: PiwikService,
41
    private userManageService: UserManagementService) {
42
  }
43
  
44
  public ngOnInit() {
45
    this.subs.push(this.userManageService.getUserInfo().subscribe(
46
      user => {
47
        this.user = user;
48
    }));
49
    this.getPageContents();
50
    this.url = this.properties.domain + this._router.url;
51
    this.seoService.createLinkForCanonicalURL(this.url);
52
    this.updateUrl(this.url );
53
    this.updateTitle(this.pageTitle);
54
    this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
55
  }
56
  
57
  ngOnDestroy() {
58
    for (let sub of this.subs) {
59
      if (sub instanceof Subscriber) {
60
        sub.unsubscribe();
61
      }
62
    }
63
  }
64
  
65
  private getPageContents() {
66
    this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
67
      this.pageContents = contents;
68
    }));
69
  }
70
  
71
  private getDivContents() {
72
    this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
73
      this.divContents = contents;
74
    }));
75
  }
76
  
77
  private updateDescription(description: string) {
78
    this._meta.updateTag({content: description}, "name='description'");
79
    this._meta.updateTag({content: description}, "property='og:description'");
80
  }
81
  
82
  private updateTitle(title: string) {
83
    var _title = ((title.length > 50) ? title.substring(0, 50) : title);
84
    this._title.setTitle(_title);
85
    this._meta.updateTag({content: _title}, "property='og:title'");
86
  }
87
  
88
  private updateUrl(url: string) {
89
    this._meta.updateTag({content: url}, "property='og:url'");
90
  }
91
  
92
  close(element) {
93
    UIkit.dropdown(element).hide();
94
    this
95
  }
96
}
(3-3/5)