Project

General

Profile

1 56645 k.triantaf
import {Component, Input, OnInit} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
3 53695 sofia.balt
4 56645 k.triantaf
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
5 60969 k.triantaf
import {User} from '../../../openaireLibrary/login/utils/helper.class';
6 56645 k.triantaf
import {HelperService} from "../../../openaireLibrary/utils/helper/helper.service";
7 56841 konstantin
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 57061 k.triantaf
import {UserManagementService} from "../../../openaireLibrary/services/user-management.service";
11 58574 konstantin
import {Breadcrumb} from "../../../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
12 59826 argiro.kok
import {Subscriber, Subscription} from "rxjs";
13 59141 konstantin
import {properties} from "../../../../environments/environment";
14 53695 sofia.balt
15 60969 k.triantaf
declare var UIkit;
16
17 53695 sofia.balt
@Component({
18 56645 k.triantaf
  selector: 'invite',
19
  templateUrl: './invite.component.html',
20 53695 sofia.balt
})
21
export class InviteComponent implements OnInit {
22
  @Input() longView: boolean = true;
23 53923 sofia.balt
  @Input() communityId = null;
24 60969 k.triantaf
  public properties: EnvProperties = properties;
25 56841 konstantin
  public pageTitle: string = "Invite";
26 60969 k.triantaf
  public user: User;
27
  public url: string;
28
  public pageContents;
29
  public divContents
30 58574 konstantin
  public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'invite'}];
31 60969 k.triantaf
  private subs: Subscription[] = [];
32
33 56645 k.triantaf
  constructor(
34
    private route: ActivatedRoute,
35
    private _router: Router,
36 60969 k.triantaf
    private _meta: Meta,
37 56841 konstantin
    private helper: HelperService,
38
    private _title: Title,
39
    private seoService: SEOService,
40 57061 k.triantaf
    private _piwikService: PiwikService,
41
    private userManageService: UserManagementService) {
42 56645 k.triantaf
  }
43 60969 k.triantaf
44 53695 sofia.balt
  public ngOnInit() {
45 60969 k.triantaf
    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 60985 konstantin
    if(this.longView) {
52
      this.seoService.createLinkForCanonicalURL(this.url);
53
      this.updateUrl(this.url);
54
      this.updateTitle(this.pageTitle);
55
      this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
56
    }
57 57546 k.triantaf
  }
58 60969 k.triantaf
59 57546 k.triantaf
  ngOnDestroy() {
60 59141 konstantin
    for (let sub of this.subs) {
61 59826 argiro.kok
      if (sub instanceof Subscriber) {
62
        sub.unsubscribe();
63
      }
64 57546 k.triantaf
    }
65
  }
66 60969 k.triantaf
67 56645 k.triantaf
  private getPageContents() {
68 59141 konstantin
    this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
69 56645 k.triantaf
      this.pageContents = contents;
70 59141 konstantin
    }));
71 56645 k.triantaf
  }
72 60969 k.triantaf
73 56645 k.triantaf
  private getDivContents() {
74 59141 konstantin
    this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
75 56645 k.triantaf
      this.divContents = contents;
76 59141 konstantin
    }));
77 56645 k.triantaf
  }
78 60927 k.triantaf
79 56841 konstantin
  private updateDescription(description: string) {
80
    this._meta.updateTag({content: description}, "name='description'");
81
    this._meta.updateTag({content: description}, "property='og:description'");
82
  }
83 60969 k.triantaf
84 56841 konstantin
  private updateTitle(title: string) {
85
    var _title = ((title.length > 50) ? title.substring(0, 50) : title);
86
    this._title.setTitle(_title);
87
    this._meta.updateTag({content: _title}, "property='og:title'");
88
  }
89 60969 k.triantaf
90 56841 konstantin
  private updateUrl(url: string) {
91
    this._meta.updateTag({content: url}, "property='og:url'");
92
  }
93 60969 k.triantaf
94
  close(element) {
95
    UIkit.dropdown(element).hide();
96
    this
97
  }
98 53695 sofia.balt
}