Commit 728de15a authored by Χάρης Παπαδόπουλος's avatar Χάρης Παπαδόπουλος
Browse files

updated to latest versions. Fixing subscriptioning bug(WIP)

parent 8074c820
......@@ -4,7 +4,7 @@ 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 { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
......
......@@ -4,7 +4,7 @@ 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 { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
......
......@@ -4,7 +4,7 @@ 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 { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
......
......@@ -4,7 +4,7 @@ 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 { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
import { Router, ActivatedRoute, Params} from "@angular/router";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
......
......@@ -2,7 +2,7 @@ import { Router, Params} from '@angular/router';
import { OnInit, Component} from '@angular/core';
import { LoginInfoActions } from '../actions/logininfo.actions';
import { ILoginInfo } from '../store/logininfo/logininfo.types';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { Observable } from 'rxjs/Rx';
import { IAppState } from '../store/store';
import { HelperDataService } from '../services/helper-data-service';
......
......@@ -3,7 +3,7 @@ import {Router} from '@angular/router';
import { Injectable } from "@angular/core";
import { BehaviorSubject } from 'rxjs/Rx';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { ILoginInfo, ILoginInfoToken } from '../../store/logininfo/logininfo.types';
import { LoginInfoActions } from '../../actions/logininfo.actions';
......
......@@ -3,7 +3,7 @@ import { OnInit, OnDestroy, Component } from "@angular/core";
import { LoginInfoActions } from "../actions/logininfo.actions";
import { ILoginInfo } from "../store/logininfo/logininfo.types";
import { LOGININFO_INITIAL_STATE } from "../store/logininfo/logininfo.initial-state";
import { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { IAppState } from "../store/store";
import { HelperDataService } from "../services/helper-data-service";
......
......@@ -2,7 +2,7 @@ import {Router} from '@angular/router';
import {OnInit, OnDestroy, Component, Injectable} from '@angular/core';
import { HelperDataService } from '../../services/helper-data-service';
import { BehaviorSubject } from 'rxjs/Rx';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { ILoginInfo, ILoginInfoToken } from '../../store/logininfo/logininfo.types';
import { LoginInfoActions } from '../../actions/logininfo.actions';
......
......@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from "@angular/core";
import { BehaviorSubject, Subscription, Observable } from "rxjs/Rx";
import { Injectable } from "@angular/core";
import { Router } from "@angular/router";
import { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { StudentDataFieldsActions } from "../../actions/studentdatafields.actions";
import { IStudentDataFields } from "../../store/studentdatafields/studentdatafields.types";
import { CriteriaActions } from "../../actions/criteria.actions";
......
......@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { SectorFieldsActions } from '../../actions/sectorfields.actions';
import { SectorCoursesActions } from '../../actions/sectorcourses.actions';
......@@ -84,6 +84,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
private selectedSchools$: BehaviorSubject<Array<IRegionSchoolRecord>> = new BehaviorSubject(Array());
private sectorFields$: BehaviorSubject<ISectorFields>;
private epalclasses$: BehaviorSubject<IEpalClasses>;
private epalclassesSub: Subscription;
private sectorsSub: Subscription;
private regionsSub: Subscription;
private sectorFieldsSub: Subscription;
......@@ -153,7 +154,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
return state.sectorFields;
}).subscribe(this.sectorFields$);
this._ngRedux.select(state => {
this.epalclassesSub = this._ngRedux.select(state => {
state.epalclasses.reduce(({}, epalclass) => {
if (epalclass.name === "Α' Λυκείου")
this.classSelected = 1;
......@@ -179,16 +180,23 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
}
ngOnDestroy() {
if (this.regionsSub)
if (this.regionsSub) {
this.regionsSub.unsubscribe();
if (this.sectorsSub)
// this.regions$.unsubscribe();
}
if (this.sectorsSub) {
this.sectorsSub.unsubscribe();
if (this.sectorFieldsSub)
// this.sectors$.unsubscribe();
}
if (this.sectorFieldsSub) {
this.sectorFieldsSub.unsubscribe();
this.regions$.unsubscribe();
this.epalclasses$.unsubscribe();
this.sectors$.unsubscribe();
this.sectorFields$.unsubscribe();
// this.sectorFields$.unsubscribe();
}
if (this.epalclassesSub) {
this.epalclassesSub.unsubscribe();
// this.epalclasses$.unsubscribe();
}
}
}
......@@ -3,7 +3,7 @@ import { Router } from "@angular/router";
import { Http, Response, RequestOptions, Headers } from "@angular/http";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { Injectable } from "@angular/core";
import { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
import { IStudentDataFields } from "../../store/studentdatafields/studentdatafields.types";
import { IRegionRecord, IRegionRecords, IRegionSchoolRecord } from "../../store/regionschools/regionschools.types";
......@@ -106,7 +106,7 @@ import { HelperDataService } from "../../services/helper-data-service";
</button>
</div>
<div class="col-md-6">
<button type="button" *ngIf="(studentDataFields$ | async).size > 0 && (regions$ | async) && (regions$ | async).size > 0 && (epalclasses$ | async).size > 0 && (loginInfo$ | async).size > 0" class="btn-primary btn-lg pull-right isclickable" style="width: 9em;" (click)="submitNow()">
<button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 9em;" (click)="submitNow()">
<span style="font-size: 0.9em; font-weight: bold;">Υποβολή&nbsp;&nbsp;&nbsp;</span><i class="fa fa-forward"></i>
</button>
</div>
......@@ -177,6 +177,7 @@ import { HelperDataService } from "../../services/helper-data-service";
(<any>$("#studentFormSentNotice")).appendTo("body");
this.loginInfoSub = this._ngRedux.select(state => {
console.log("SELECTOR5");
if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({ }, loginInfoToken) => {
this.authToken = loginInfoToken.auth_token;
......@@ -194,6 +195,7 @@ import { HelperDataService } from "../../services/helper-data-service";
}).subscribe(this.loginInfo$);
this.epalclassesSub = this._ngRedux.select(state => {
console.log("SELECTOR4");
if (state.epalclasses.size > 0) {
state.epalclasses.reduce(({ }, epalclass) => {
this.classSelected = epalclass.name;
......@@ -208,6 +210,7 @@ import { HelperDataService } from "../../services/helper-data-service";
}).subscribe(this.studentDataFields$);
this.regionsSub = this._ngRedux.select(state => {
console.log("SELECTOR3");
state.regions.reduce((prevRegion, region) => {
region.epals.reduce((prevEpal, epal) => {
if (epal.selected === true) {
......@@ -222,6 +225,7 @@ import { HelperDataService } from "../../services/helper-data-service";
}).subscribe(this.regions$);
this.sectorsSub = this._ngRedux.select(state => {
console.log("SELECTOR2");
state.sectors.reduce((prevSector, sector) => {
sector.courses.reduce((prevCourse, course) => {
if (course.selected === true) {
......@@ -235,6 +239,7 @@ import { HelperDataService } from "../../services/helper-data-service";
}).subscribe(this.sectors$);
this.sectorFieldsSub = this._ngRedux.select(state => {
console.log("SELECTOR");
state.sectorFields.reduce(({ }, sectorField) => {
if (sectorField.selected === true) {
this.sectorSelected = sectorField.id;
......@@ -248,23 +253,39 @@ import { HelperDataService } from "../../services/helper-data-service";
ngOnDestroy() {
(<any>$("#studentFormSentNotice")).remove();
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
if (this.regionsSub) this.regionsSub.unsubscribe();
if (this.sectorsSub) this.sectorsSub.unsubscribe();
if (this.sectorFieldsSub) this.sectorFieldsSub.unsubscribe();
if (this.epalclassesSub) this.epalclassesSub.unsubscribe();
if (this.loginInfoSub) this.loginInfoSub.unsubscribe();
this.regions$.unsubscribe();
this.epalclasses$.unsubscribe();
this.sectors$.unsubscribe();
this.sectorFields$.unsubscribe();
this.studentDataFields$.unsubscribe();
this.loginInfo$.unsubscribe();
if (this.studentDataFieldsSub) {
this.studentDataFieldsSub.unsubscribe();
// this.studentDataFields$.unsubscribe();
}
if (this.regionsSub) {
this.regionsSub.unsubscribe();
// this.regions$.unsubscribe();
}
if (this.sectorsSub) {
this.sectorsSub.unsubscribe();
// this.sectors$.unsubscribe();
}
if (this.sectorFieldsSub) {
this.sectorFieldsSub.unsubscribe();
// this.sectorFields$.unsubscribe();
}
if (this.epalclassesSub) {
this.epalclassesSub.unsubscribe();
// this.epalclasses$.unsubscribe();
}
if (this.loginInfoSub) {
this.loginInfoSub.unsubscribe();
// this.loginInfo$.unsubscribe();
}
}
submitNow() {
// αποστολή στοιχείων μαθητή στο entity: epal_student
// let aitisiObj: Array<Student | StudentEpalChosen[] | StudentCriteriaChosen[] | StudentCourseChosen | StudentSectorChosen > = [];
if (this.studentDataFields$.getValue().size === 0 || this.regions$.getValue().size === 0 || this.epalclasses$.getValue().size === 0 || this.loginInfo$.getValue().size === 0)
return;
let aitisiObj: Array<any> = [];
let epalObj: Array<StudentEpalChosen> = [];
......@@ -358,14 +379,14 @@ import { HelperDataService } from "../../services/helper-data-service";
let mHeader = "";
switch (errorCode) {
case 0:
mTitle = "Υποβολή Δήλωσης Προτίμησης";
mText = "Η υποβολή της δήλωσής σας πραγματοποιήθηκε. Μπορείτε να τη δείτε και να την εκτυπώσετε από την επιλογή 'Εμφάνιση - Εκτύπωση Δήλωσης Προτίμησης'. Από την επιλογή 'Υποβληθείσες Δηλώσεις' θα μπορείτε να ενημερωθείτε όταν υπάρξει εξέλιξη σχετική με τη δήλωση σας. Επίσης, θα λάβετε και ενημερωτικό email.";
mHeader = "modal-header-success";
this._eca.initEpalClasses();
this._sfa.initSectorFields();
this._rsa.initRegionSchools();
this._csa.initSectorCourses();
this._sdfa.initStudentDataFields();
mTitle = "Υποβολή Δήλωσης Προτίμησης";
mText = "Η υποβολή της δήλωσής σας πραγματοποιήθηκε. Μπορείτε να τη δείτε και να την εκτυπώσετε από την επιλογή 'Εμφάνιση - Εκτύπωση Δήλωσης Προτίμησης'. Από την επιλογή 'Υποβληθείσες Δηλώσεις' θα μπορείτε να ενημερωθείτε όταν υπάρξει εξέλιξη σχετική με τη δήλωση σας. Επίσης, θα λάβετε και ενημερωτικό email.";
mHeader = "modal-header-success";
break;
case 1000:
mTitle = "Αποτυχία Υποβολής Δήλωσης Προτίμησης";
......@@ -457,6 +478,7 @@ import { HelperDataService } from "../../services/helper-data-service";
this.showModal();
(<any>$(".loading")).remove();
this.showLoader.next(false);
},
error => {
(<any>$(".loading")).remove();
......@@ -466,7 +488,8 @@ import { HelperDataService } from "../../services/helper-data-service";
this.showModal();
this.showLoader.next(false);
console.log("Error HTTP POST Service");
});
}
);
}
......
......@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { CourseFieldsActions } from '../../actions/coursefields.actions';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { ICourseFields } from '../../store/coursefields/coursefields.types';
import { IAppState } from '../../store/store';
......
......@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from "@angular/core";
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { Http, Headers, RequestOptions} from '@angular/http';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
......
......@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { Observable, BehaviorSubject } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { EpalClassesActions } from '../../actions/epalclass.actions';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IEpalClasses } from '../../store/epalclasses/epalclasses.types';
import { SectorFieldsActions } from '../../actions/sectorfields.actions';
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
......
......@@ -7,7 +7,7 @@ import { BehaviorSubject, Subscription, Observable } from 'rxjs/Rx';
import { HelperDataService } from '../../services/helper-data-service';
import { ILoginInfo, ILoginInfoToken } from "../../store/logininfo/logininfo.types";
import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
import { NgRedux, select } from "ng2-redux";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
import {
FormBuilder,
......
import { Component, OnInit, OnDestroy } from "@angular/core";
import { Injectable } from "@angular/core";
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
......
......@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IRegionRecord, IRegionRecords } from '../../store/regionschools/regionschools.types';
import { REGION_SCHOOLS_INITIAL_STATE } from '../../store/regionschools/regionschools.initial-state';
import { EPALCLASSES_INITIAL_STATE } from '../../store/epalclasses/epalclasses.initial-state';
......@@ -182,20 +182,21 @@ import {AppSettings} from '../../app.settings';
if (this.epalclassesSub) {
this.epalclassesSub.unsubscribe();
// this.epalclasses$.unsubscribe();
}
if (this.regionsSub) {
this.regionsSub.unsubscribe();
// this.regions$.unsubscribe();
}
if (this.sectorsSub) {
this.sectorsSub.unsubscribe();
// this.sectors$.unsubscribe();
}
if (this.sectorFieldsSub) {
this.sectorFieldsSub.unsubscribe();
// this.sectorFields$.unsubscribe();
}
if (this.sectorFields$) this.sectorFields$.unsubscribe();
if (this.sectors$) this.sectors$.unsubscribe();
if (this.regions$) this.regions$.unsubscribe();
if (this.epalclasses$) this.epalclasses$.unsubscribe();
}
public showModal():void {
......
......@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
import { IRegionRecord, IRegionRecords, IRegionSchoolRecord } from '../../store/regionschools/regionschools.types';
import { REGION_SCHOOLS_INITIAL_STATE } from '../../store/regionschools/regionschools.initial-state';
......
......@@ -5,7 +5,7 @@ import { Injectable } from "@angular/core";
import { SectorCoursesActions } from '../../actions/sectorcourses.actions';
import { ISectors } from '../../store/sectorcourses/sectorcourses.types';
import { SECTOR_COURSES_INITIAL_STATE } from '../../store/sectorcourses/sectorcourses.initial-state';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { IAppState } from '../../store/store';
import {RemoveSpaces} from '../../pipes/removespaces';
......
......@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { SectorFieldsActions } from '../../actions/sectorfields.actions';
import { NgRedux, select } from 'ng2-redux';
import { NgRedux, select } from '@angular-redux/store';
import { ISectorFields } from '../../store/sectorfields/sectorfields.types';
import { IAppState } from '../../store/store';
import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfields.initial-state';
......
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