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 { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
import { Observable } from "rxjs/Observable";
import { Http, Headers, RequestOptions } from '@angular/http';
import { NgRedux, select } from 'ng2-redux';
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 { ILoginInfo } from '../../store/logininfo/logininfo.types';
......@@ -217,7 +217,7 @@ import {
private selectionCClass: BehaviorSubject<boolean>;
private limitsSub: Subscription;
private limits$: BehaviorSubject<any>;
private SchoolId ;
private SchoolId;
private currentclass: Number;
private saved: Array<number> = new Array();
private limitdown = 0;
......@@ -286,7 +286,7 @@ import {
this.School$.next(x);
console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type;
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ') {
this.selectiontype.next(false);
}
......@@ -304,7 +304,7 @@ import {
verifyclass(txop) {
this.limitdown = 0;
this.limitup = 5;
console.log(this.SchoolId,"schoolida");
console.log(this.SchoolId, "schoolida");
this.pageno = 1;
this.retrievedStudent.next(false);
if (txop.value === "1") {
......@@ -355,7 +355,7 @@ import {
checkbclass(tmop, txop) {
console.log(this.SchoolId,"schoolidn");
console.log(this.SchoolId, "schoolidn");
this.pageno = 1;
this.retrievedStudent.next(false);
var sectorint = +this.formGroup.value.tomeas;
......@@ -376,82 +376,75 @@ import {
findstudent(txop, pageno) {
var sectorint = +this.formGroup.value.tomeas;
let sectorint = +this.formGroup.value.tomeas;
this.currentclass = +txop.value;
this.formGroup.get('pageno').setValue(this.pageno);
if (this.pageno == 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)
.subscribe(x => {
this.StudentsSize$.next(x);
this.totallimit = x.id;
this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => {
this.limits$.next(data);
console.log(this.totallimit, data[0].limitdown, "oria");
this.tot_pages = x.id / 5;
this.tot_pages = Math.floor(x.id / 5);
if (x.id % 5 > 0) {
this.tot_pages = (x.id - (x.id % 5)) / 5 + 1;
// this.tot_pages = (x.id - (x.id % 5)) / 5 + 1;
this.tot_pages += 1;
}
console.log(this.tot_pages,"totpages")
if (isNaN(this.tot_pages)){
console.log(this.tot_pages, "totpages")
if (isNaN(this.tot_pages)) {
this.retrievedStudent.next(false);
this.tot_pages = 0;
}
if ( (x.id < data[0].limitdown) || (isNaN(this.tot_pages)))
{
if ((x.id < parseInt(data[0].limitdown)) || (isNaN(this.tot_pages))) {
console.log("mphkeprwto!")
this.retrievedStudent.next(false);
this.tot_pages = 0;
this.formGroup.get('maxpage').setValue(this.tot_pages);
//this.outoflimits.next(true);
}
else
{
} else {
// this.outoflimits.next(false);
this.formGroup.get('maxpage').setValue(this.tot_pages);
console.log(this.tot_pages,"mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
console.log(this.tot_pages, "mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup)
.subscribe(data => {
this.StudentInfo$.next(data);
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");
},
() => console.log("Getting Students"));
() => console.log("Getting Students")
);
}
},
error => {
this.limits$.next([{}]);
console.log("Error Getting limits");
},
() => console.log("Getting limits"));
() => console.log("Getting limits")
);
});
}
else{
else {
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);
this.retrievedStudent.next(false);
}
else
{
console.log(this.tot_pages,"mazeuw mathites");
else {
console.log(this.tot_pages, "mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data);
......
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