Commit c6dd9332 authored by Σταύρος Παπαδάκης's avatar Σταύρος Παπαδάκης
Browse files

Fix empty response; fix number issues; fix incorect responses

parent fed9bbc4
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer} from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer } from "@angular/core";
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings'; import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service'; import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable"; import { Observable } from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http'; import { Http, Headers, RequestOptions } from '@angular/http';
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store'; import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router'; import { Router, ActivatedRoute, Params } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from '../../store/logininfo/logininfo.types';
...@@ -217,7 +217,7 @@ import { ...@@ -217,7 +217,7 @@ import {
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private limitsSub: Subscription; private limitsSub: Subscription;
private limits$: BehaviorSubject<any>; private limits$: BehaviorSubject<any>;
private SchoolId ; private SchoolId;
private currentclass: Number; private currentclass: Number;
private saved: Array<number> = new Array(); private saved: Array<number> = new Array();
private limitdown = 0; private limitdown = 0;
...@@ -282,29 +282,29 @@ import { ...@@ -282,29 +282,29 @@ import {
ngOnInit() { ngOnInit() {
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => { this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x); this.School$.next(x);
console.log(x[0].type, "schoolid!"); console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type; this.SchoolId = x[0].type;
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){ if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ') {
this.selectiontype.next(false); this.selectiontype.next(false);
} }
}, },
error => { error => {
this.School$.next([{}]); this.School$.next([{}]);
console.log("Error Getting School"); console.log("Error Getting School");
}, },
() => console.log("Getting School ")); () => console.log("Getting School "));
} }
verifyclass(txop) { verifyclass(txop) {
this.limitdown = 0; this.limitdown = 0;
this.limitup = 5; this.limitup = 5;
console.log(this.SchoolId,"schoolida"); console.log(this.SchoolId, "schoolida");
this.pageno = 1; this.pageno = 1;
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
if (txop.value === "1") { if (txop.value === "1") {
...@@ -327,7 +327,7 @@ import { ...@@ -327,7 +327,7 @@ import {
} }
else if (txop.value === "3" || txop.value === "4") { else if (txop.value === "3" || txop.value === "4") {
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
if (this.formGroup.value.tomeas != '') { if (this.formGroup.value.tomeas != '') {
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(data => { this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(data => {
...@@ -355,7 +355,7 @@ import { ...@@ -355,7 +355,7 @@ import {
checkbclass(tmop, txop) { checkbclass(tmop, txop) {
console.log(this.SchoolId,"schoolidn"); console.log(this.SchoolId, "schoolidn");
this.pageno = 1; this.pageno = 1;
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
...@@ -376,95 +376,88 @@ import { ...@@ -376,95 +376,88 @@ import {
findstudent(txop, pageno) { findstudent(txop, pageno) {
let sectorint = +this.formGroup.value.tomeas;
var sectorint = +this.formGroup.value.tomeas;
this.currentclass = +txop.value; this.currentclass = +txop.value;
this.formGroup.get('pageno').setValue(this.pageno); this.formGroup.get('pageno').setValue(this.pageno);
if (this.pageno == 1) { if (this.pageno == 1) {
console.log("mphkepage = 1"); console.log("mphkepage = 1");
this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0).subscribe(x => { this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0)
this.StudentsSize$.next(x); .subscribe(x => {
this.totallimit = x.id; this.StudentsSize$.next(x);
this.totallimit = x.id;
this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => {
this.limits$.next(data); this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => {
console.log(this.totallimit, data[0].limitdown, "oria"); this.limits$.next(data);
this.tot_pages = x.id / 5; console.log(this.totallimit, data[0].limitdown, "oria");
if (x.id % 5 > 0) { this.tot_pages = Math.floor(x.id / 5);
this.tot_pages = (x.id - (x.id % 5)) / 5 + 1; if (x.id % 5 > 0) {
} // this.tot_pages = (x.id - (x.id % 5)) / 5 + 1;
console.log(this.tot_pages,"totpages") this.tot_pages += 1;
if (isNaN(this.tot_pages)){ }
this.retrievedStudent.next(false); console.log(this.tot_pages, "totpages")
this.tot_pages = 0; if (isNaN(this.tot_pages)) {
} this.retrievedStudent.next(false);
if ( (x.id < data[0].limitdown) || (isNaN(this.tot_pages))) this.tot_pages = 0;
{ }
console.log("mphkeprwto!") if ((x.id < parseInt(data[0].limitdown)) || (isNaN(this.tot_pages))) {
this.retrievedStudent.next(false); console.log("mphkeprwto!")
this.tot_pages = 0; this.retrievedStudent.next(false);
this.formGroup.get('maxpage').setValue(this.tot_pages); this.tot_pages = 0;
//this.outoflimits.next(true); this.formGroup.get('maxpage').setValue(this.tot_pages);
} //this.outoflimits.next(true);
else } else {
{ // this.outoflimits.next(false);
// this.outoflimits.next(false); this.formGroup.get('maxpage').setValue(this.tot_pages);
console.log(this.tot_pages, "mazeuw mathites");
this.formGroup.get('maxpage').setValue(this.tot_pages); this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup)
console.log(this.tot_pages,"mazeuw mathites"); .subscribe(data => {
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { this.StudentInfo$.next(data);
this.StudentInfo$.next(data); console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
this.retrievedStudent.next(true);
console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); },
this.retrievedStudent.next(true); error => {
this.StudentInfo$.next([{}]);
}, console.log("Error Getting Students");
error => { },
this.StudentInfo$.next([{}]); () => console.log("Getting Students")
console.log("Error Getting Students"); );
}, }
() => console.log("Getting Students")); },
error => {
this.limits$.next([{}]);
console.log("Error Getting limits");
} },
() => console.log("Getting limits")
}, );
error => {
this.limits$.next([{}]);
console.log("Error Getting limits");
},
() => console.log("Getting limits"));
}); });
} }
else{ else {
console.log("eisai edw", this.tot_pages); console.log("eisai edw", this.tot_pages);
if (this.tot_pages == 0 ){ if (this.tot_pages == 0) {
console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages); console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages);
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
} }
else else {
{ console.log(this.tot_pages, "mazeuw mathites");
console.log(this.tot_pages,"mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data); this.StudentInfo$.next(data);
console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
this.retrievedStudent.next(true); this.retrievedStudent.next(true);
}, },
error => { error => {
this.StudentInfo$.next([{}]); this.StudentInfo$.next([{}]);
console.log("Error Getting Students"); console.log("Error Getting Students");
}, },
() => console.log("Getting Students")); () => console.log("Getting Students"));
} }
} }
} }
...@@ -492,7 +485,7 @@ import { ...@@ -492,7 +485,7 @@ import {
confirmStudent(txop) { confirmStudent(txop) {
this.SavedStudentsSub = this._hds.saveConfirmStudents(this.saved, this.type).subscribe(data => { this.SavedStudentsSub = this._hds.saveConfirmStudents(this.saved, this.type).subscribe(data => {
this.SavedStudents$.next(data); this.SavedStudents$.next(data);
}, },
...@@ -501,9 +494,9 @@ import { ...@@ -501,9 +494,9 @@ import {
console.log("Error saving Students"); console.log("Error saving Students");
}, },
() => { () => {
console.log("saved Students"); console.log("saved Students");
this.findstudent(txop, this.pageno); this.findstudent(txop, this.pageno);
}); });
......
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