submitedstudent.preview.ts 2.58 KB
Newer Older
Open Source Developer's avatar
Open Source Developer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
import { Component, OnInit, ElementRef, ViewChild} from "@angular/core";
let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {IStudentDataFields, IStudentDataField} from '../../store/studentdatafields';
import {Http, Headers, RequestOptions} from '@angular/http';
import * as html2canvas from "html2canvas"
import {Removetags} from '../../pipes/removehtmltags';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';



@Component({
    selector: 'submited-person',
    template: `

    <h5 style="margin-top: 20px; line-height: 2em; ">Στοιχεία Μαθητή</h5>

        <div *ngFor="let userdata$ of submitedapplic$ | async; ">
        
            <ul class="list-group left-side-view" style="margin-bottom: 20px;">
                <li class="list-group-item active">
                    Μαθητής: {{userdata$.name}}
               </li>
            </ul>
        </div>
                  
   `
})

@Injectable() export default class SubmitedPerson implements OnInit {


    
    public html2canvas: any;
   
    private submitedapplic$: BehaviorSubject<any>;
    private submitedusers$: Subscription;
    public userid: number;
    public authToken : string ;
    
    constructor(private _hds: HelperDataService, 
                public http: Http,
                private _ngRedux: NgRedux<IAppState>,
                private activatedRoute: ActivatedRoute )
    {
       this.submitedapplic$ = new BehaviorSubject({});
    }



    ngOnInit() {
    

           
         this.activatedRoute.queryParams.subscribe((params: Params) => {
            if (params) {
                this.userid = 1;
                console.log("userid", this.userid, this.authToken);
            }
        });

        this.submitedusers$ = this._hds.getSubmittedPreviw(this.userid).subscribe(this.submitedapplic$);
        console.log("subscription", this.submitedusers$, "behavior", this.submitedapplic$);
        



    }


    createPdf()
    {

        html2canvas(document.getElementById("target")).then(function(canvas)
         {
        var img = canvas.toDataURL();
        var doc = new jsPDF('p', 'mm');
        doc.addImage(img, 'PNG', 10, 10);
        doc.save('applications.pdf');
     }
   
    );
    }
}