Project

General

Profile

1
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {AlertModal} from '../../utils/modal/alert';
4

    
5
@Component({
6
    selector: 'search-download',
7
    template: `
8
    <div class= "searchDownload" *ngIf="totalResults > 0">
9
        <div class="text-right" *ngIf="totalResults <= 100000">
10
            <a (click)="download()">
11
                <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
12
                Download report (CSV)
13
            </a>
14
        </div>
15
        <div class="text-right" *ngIf="totalResults > 100000">
16
            <a (click)="denialOfDownload()">
17
                <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
18
                Download report (CSV)
19
            </a>
20
        </div>
21
    </div>
22
    <modal-alert></modal-alert>
23

    
24
    `
25
})
26

    
27
export class SearchDownloadComponent {
28
    @Input() totalResults:number = 0;
29
    @ViewChild(AlertModal) alertApplyAll;
30
    @Output() downloadClick  = new EventEmitter();
31

    
32
    constructor () {
33
     }
34

    
35
    ngOnInit() {
36

    
37
    }
38

    
39
    confirmClose(data){
40

    
41
    }
42
    download() {
43
        this.downloadClick.emit({
44
            value: true
45
        });
46
    }
47

    
48
    denialOfDownload() {
49
        this.alertApplyAll.isOpen = true;
50
        this.alertApplyAll.cancelButton = true;
51
        this.alertApplyAll.okButton = false;
52
        this.alertApplyAll.alertTitle = "Download Results in CSV";
53
        this.alertApplyAll.message = "Sorry, but the results are too many! Use the api instead!";
54
        this.alertApplyAll.cancelButtonText = "Ok";
55

    
56
        console.info("denial of Download");
57

    
58
    }
59
}
(3-3/10)