Project

General

Profile

1
import { Component, Input, ViewChild } from '@angular/core';
2
import { Location } from '@angular/common';
3
import {ActivatedRoute} from '@angular/router';
4
import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
5

    
6
import {InviteService} from './invite.service';
7
import {Session} from '../../openaireLibrary/login/utils/helper.class';
8
@Component({
9
    selector: 'invite',
10
    template: `
11
    <form class="uk-form-stacked">
12
        <div>
13
            <label class="uk-form-label">Subject</label>
14
            <input type="text" placeholder="Subject" [(ngModel)]=subject name="subject">
15
        </div>
16
        <div>
17
            <div class="uk-form-label">Message</div>
18
            <textarea cols="" rows="6" placeholder="Email message..." [(ngModel)]=body name="body"></textarea>
19
         </div>
20
        <a class="uk-button uk-button-primary" (click)="invite()"> Invite</a>
21
    </form>
22

    
23
    `
24
})
25

    
26
export class InviteComponent {
27
  @Input() communityName:boolean;
28
  @Input() communityId:string;
29
  properties:EnvProperties;
30

    
31
  subject:string;
32
  body:string;
33
  recipients:string[] = [];
34

    
35
  constructor (private route: ActivatedRoute,
36
      private _inviteService: InviteService
37
    ) {
38
    }
39

    
40
    public ngOnInit() {
41
      this.route.data
42
          .subscribe((data: { envSpecific: EnvProperties }) => {
43
             this.properties = data.envSpecific;
44
             this.subject = "["+this.communityName+"] Invitation to join community";
45
             this.body = "Dear sir or madame, \n\nWe would like to invite you to join "+this.communityName +
46
             " OpenAIRE community (beta."+this.communityId+".openaire.eu)";
47
           });
48

    
49

    
50
    }
51

    
52
    invite(){
53
      var email = Session.getUserEmail();
54
      //TODO
55
        this._inviteService.inviteUsers(  this.properties.adminToolsAPIURL,this.subject, this.body, ["argirok@di.uoa.gr"]).subscribe (
56
          res => {
57
             console.log(res);
58

    
59
          });
60
      }
61

    
62

    
63
}
(1-1/5)