Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import { Router } from '@angular/router';
4
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
5

    
6
import {SearchOrganizationsService} from '../services/searchOrganizations.service';
7

    
8
@Component({
9
    selector: 'deposit',
10
    template: `
11
        <div class="container uk-margin-top">
12
            <div class="page-header" >
13
                <h2>Deposit {{requestFor}}</h2>
14
            </div>
15

    
16
            <div>
17
                <p>
18
                    <i>
19
                        Are you a grant recipient from the following: H2020; FP7 with SC39; or ERC?
20
                    </i>
21
                    Then you are required to publish in
22
                    <a href="{{openAccess}}" target="_blank">open access ( <i class="uk-icon-external-link"></i> )</a>.
23
                    One way to do this is to deposit your {{requestFor}} into an
24
                    <a href="{{openAccessRepo}}" target="_blank">open access repository ( <i class="uk-icon-external-link"></i> )</a>.
25
                </p>
26
                <p>
27
                    Click the following to find more information:
28
                    <a href="{{fp7Guidlines}}" target="_blank">FP7 guidelines ( <i class="uk-icon-external-link"></i> )</a>,
29
                    <a href="{{h2020Guidlines}}" target="_blank">H2020 guidelines ( <i class="uk-icon-external-link"></i> )</a>,
30
                    <a href="{{ercGuidlines}}" target="_blank">ERC guidelines ( <i class="uk-icon-external-link"></i> )</a> OR
31
                    <a href="{{helpdesk}}" target="_blank">ask a question ( <i class="uk-icon-external-link"></i> )</a> to OpenAIRE’s national representative.
32
                </p>
33

    
34
                <h3>Locate data provider via your institution</h3>
35

    
36
                <form class= "uk-form uk-form-row">
37
                    <entities-autocomplete (click)="warningMessage = ''" [entityType]="'organization'" [depositType]=compatibility   [selectedValue]=selectedId [showSelected]=true
38
                      [placeHolderMessage] = "'Search for Organizations'" [title] = "'Organizations'"  [multipleSelections]=false
39
                      (selectedValueChanged)="valueChanged($event)">
40
                    </entities-autocomplete>
41
                    <button class="uk-button"  type="submit" (click)="organizationSelected(selectedId)" >
42
                        Locate
43
                    </button>
44
                    <div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
45
                </form>
46
            </div>
47
        </div>
48
    `
49
})
50

    
51
export class DepositComponent {
52
    @Input() keyword: string='';
53
    public openAccess: string;
54
    public openAccessRepo: string;
55
    public fp7Guidlines: string;
56
    public h2020Guidlines: string;
57
    public ercGuidlines: string;
58
    public helpdesk: string;
59
    @Input() compatibility: string = '';
60
    @Input() requestFor: string = "Publications";
61

    
62
    public status: number;
63
    public errorCodes:ErrorCodes = new ErrorCodes();
64
    public selectedId: string = "";
65
    public warningMessage: string = "";
66

    
67
    constructor (private _router: Router, private _searchOrganizationsService: SearchOrganizationsService) {
68

    
69
        this.openAccess = OpenaireProperties.getOpenAccess();
70
        this.openAccessRepo = OpenaireProperties.getOpenAccessRepo();
71
        this.fp7Guidlines = OpenaireProperties.getFP7Guidlines();
72
        this.h2020Guidlines = OpenaireProperties.getH2020Guidlines();
73
        this.ercGuidlines = OpenaireProperties.getERCGuidlines();
74
        this.helpdesk = OpenaireProperties.getHelpdesk();
75
    }
76

    
77

    
78

    
79
    organizationSelected(id: string) {
80
        console.info("organization selected");
81
        if(id && id.length > 0){
82
            if(this.requestFor == "Publications") {
83
                this._router.navigate( ['deposit-publications-result'], { queryParams: { "organizationId": id } } );
84
            } else if(this.requestFor == "Research Data") {
85
                this._router.navigate( ['deposit-datasets-result'], { queryParams: { "organizationId": id } } );
86
            }
87
        } else {
88
            this.warningMessage = "No organization selected";
89
        }
90
    }
91

    
92
    valueChanged($event){
93
      this.selectedId = $event.value;
94
    }
95
}
(2-2/8)