updated components

parent c2652204
......@@ -326,7 +326,7 @@ import {AppSettings} from '../../app.settings';
navigateToApplication() {
//[disabled] = " ( (selectionLimitOptional | async) === false && (classNight | async) === false && (numSelected | async) < (selectionLimit | async) )
// || ( (numSelected | async) === 0)"
if ( (this.selectionLimitOptional.value === false && this.classNight.value === false && this.numSelected.value < this.selectionLimit.value )
if ( (this.selectionLimitOptional.value === false /*&& this.classNight.value === false */ && this.numSelected.value < this.selectionLimit.value )
|| (this.numSelected.value === 0) ) {
//this.modalHeader = "modal-header-success";
......
......@@ -13,10 +13,23 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas"
import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../../app.settings';
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray
} from '@angular/forms';
@Component({
selector: 'submited-preview',
template: `
<div class = "loading" *ngIf="(showLoader$ | async) === true"></div>
<div class="row">
<breadcrumbs></breadcrumbs>
......@@ -97,13 +110,26 @@ import * as html2canvas from "html2canvas"
</div>
</ul>
<br>
<button type="button" (click)="createPdf()">Εξαγωγή σε PDF</button>
<button type="button" (click)="createPdfServerSide()">Εξαγωγή σε PDF</button>
<!--
<form [formGroup]="formGroup" method = "POST" action="{{apiEndPoint}}/drupal-8.2.6/epal/pdf-application" #form>
<button type="submit" (click)="form.submit()">Εξαγωγή σε PDF - ΝΕΟ!</button>
</form>
-->
<!--<a href="{{apiEndPoint}}/drupal-8.2.6/epal/pdf-application">Download</a>-->
`
})
@Injectable() export default class SubmitedPreview implements OnInit , OnDestroy{
private apiEndPointParams = API_ENDPOINT_PARAMS;
public formGroup: FormGroup;
loginInfo$: BehaviorSubject<ILoginInfo>;
loginInfoSub: Subscription;
private SubmitedApplic$: BehaviorSubject<any>;
private SubmitedUsersSub: Subscription;
......@@ -119,15 +145,21 @@ import * as html2canvas from "html2canvas"
private CritirioChosenSub: Subscription;
private showLoader$: BehaviorSubject<boolean>;
private data;
private authToken: string;
private role: string;
public StudentId;
private userActive = <number>-1;
@ViewChild('target') element: ElementRef;
constructor(private _hds: HelperDataService,
constructor(private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
private router: Router ,
private fb: FormBuilder,
)
{
this.SubmitedApplic$ = new BehaviorSubject([{}]);
......@@ -136,6 +168,11 @@ import * as html2canvas from "html2canvas"
this.CritirioChosen$ = new BehaviorSubject([{}]);
this.incomeChosen$ = new BehaviorSubject([{}]);
this.showLoader$ = new BehaviorSubject(false);
this.formGroup = this.fb.group({
});
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
}
ngOnDestroy()
......@@ -151,6 +188,11 @@ import * as html2canvas from "html2canvas"
if (this.incomeChosenSub)
this.incomeChosenSub.unsubscribe();
if (this.loginInfoSub)
this.loginInfoSub.unsubscribe();
if (this.loginInfo$)
this.loginInfo$.unsubscribe();
this.SubmitedDetails$.unsubscribe();
this.EpalChosen$.unsubscribe();
this.SubmitedApplic$.unsubscribe();
......@@ -159,6 +201,20 @@ import * as html2canvas from "html2canvas"
ngOnInit() {
this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => {
this.authToken = loginInfoToken.auth_token;
this.role = loginInfoToken.auth_role;
console.log("....");
console.log(this.authToken);
return loginInfoToken;
}, {});
}
return state.loginInfo;
}).subscribe(this.loginInfo$);
this.showLoader$.next(true);
this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(
......@@ -244,7 +300,7 @@ import * as html2canvas from "html2canvas"
doc.addImage(img, 'PNG',0, 0, 210, 297);
console.log(img, doc, "ok2");
doc.save('applications.pdf');
}
......@@ -267,21 +323,58 @@ html2canvas(document.getElementById("target"), <Html2Canvas.Html2CanvasOptions>{
onrendered: function(canvas: HTMLCanvasElement) {
var img = canvas.toDataURL();
var doc = new jsPDF();
console.log("mphkaneo");
setTimeout(function(){
}, 100000);
doc.addImage(img, 'PNG',0, 0, 1000, 1000);
console.log("mphkaneoneo");
doc.save('applications.pdf');
}
}); }
createPdfServerSide()
{
/*
this.SubmitedDetailsSub = this._hds.createPdfServerSide().subscribe(data => {
this.data = data;
},
error => {
console.log("Error Getting createPdfServerSide");
},
() => {
console.log("Success Getting createPdfServerSide");
//$window.open(this.data);
//window.open("data:application/pdf," + encodeURI(this.data));
console.log("Test Now!");
console.log(this.data);
//window.open("https://www.w3schools.com");
}
);
*/
this._hds.createPdfServerSide(this.authToken, this.role)
.then(msg => {
//console.log("Nikos2");
})
.catch(err => {console.log(err);
//console.log("Nikos1");
console.log(err);
});
}
}
......@@ -86,7 +86,7 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
createPdf()
{
html2canvas(document.getElementById("target")).then(function(canvas)
{
var img = canvas.toDataURL();
......@@ -96,5 +96,23 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
});
}
createPdfServerSide()
{
//this.SubmitedDetailsSub = this._hds.createPdfServerSide().subscribe(this.SubmitedDetails$);
/*
this._hds.createPdfServerSide()
.then(msg => {
//console.log("Nikos2");
})
.catch(err => {console.log(err);
//console.log("Nikos1");
console.log(err);
});
*/
}
}
......@@ -15,6 +15,7 @@ import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-st
import { SCHOOL_ROLE, STUDENT_ROLE, PDE_ROLE, DIDE_ROLE, MINISTRY_ROLE } from '../constants';
import { CookieService } from 'ngx-cookie';
import * as FileSaver from 'file-saver';
const HEADER = { headers: new Headers({ 'Content-Type': 'application/json' }) };
......@@ -40,6 +41,7 @@ export class HelperDataService implements OnInit, OnDestroy {
this._ngRedux.select(state => {
if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => {
console.log("NAIIIIII!");
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
return loginInfoToken;
......@@ -446,6 +448,7 @@ export class HelperDataService implements OnInit, OnDestroy {
getStudentDetails(headerid) {
let headerIdNew = headerid.toString();
this.loginInfo$.getValue().forEach(loginInfoToken => {
console.log("Nai");
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
......@@ -542,8 +545,8 @@ export class HelperDataService implements OnInit, OnDestroy {
let options = new RequestOptions({ headers: headers });
return this.http.post(`${AppSettings.API_ENDPOINT}/epal/confirmstudent`, { students, type}, options)
.map(response => response.json());
}
......@@ -898,5 +901,47 @@ getlimitsofcourse(classid){
}
createPdfServerSide(auth_token, role) {
/*
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
console.log("Θα μπει;");
console.log(this.authToken);
});
*/
let headers = new Headers({
"Content-Type": "application/json",
});
this.authToken = auth_token;
this.authRole = role;
console.log(this.authToken);
console.log(this.authRole);
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
//return this.http.get(`${AppSettings.API_ENDPOINT}/epal/pdf-application/`, options)
// .map(response => response.json());
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}/epal/pdf-application`, options)
.map(response => response.json())
.subscribe(data => {
resolve(data);
console.log("Nik");
//console.log(data['_body']);
},
error => {
reject("Error POST in createPdfServerSide");
},
() => console.log("Nikos!!!"));
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment