Commit 1824bfcf authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

Merge branch 'develop' of https://git.minedu.gov.gr/itminedu/e-epal into component_updates

parents cdd54b2f 47574dda
...@@ -219,9 +219,8 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas ...@@ -219,9 +219,8 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
, Response::HTTP_OK); , Response::HTTP_OK);
} }
else { else {
return $this->respondWithStatus([ $list = array();
'message' => t("No students found!!!"), return $this->respondWithStatus($list, Response::HTTP_OK);
], Response::HTTP_OK);
} }
......
...@@ -27,6 +27,9 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes'; ...@@ -27,6 +27,9 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
/* Here we import services */ /* Here we import services */
import {HelperDataService} from './services/helper-data-service'; import {HelperDataService} from './services/helper-data-service';
import {LoaderService} from './services/Spinner.service'; import {LoaderService} from './services/Spinner.service';
import {AuthService} from './services/auth.service';
import SchoolAuthGuard from './guards/school.auth.guard';
import StudentAuthGuard from './guards/student.auth.guard';
import { ACTION_PROVIDERS } from './actions'; import { ACTION_PROVIDERS } from './actions';
import Home from './components/home'; import Home from './components/home';
...@@ -76,6 +79,9 @@ class MyLocalization extends NgLocalization { ...@@ -76,6 +79,9 @@ class MyLocalization extends NgLocalization {
//Service1, again services here //Service1, again services here
HelperDataService, HelperDataService,
LoaderService, LoaderService,
AuthService,
SchoolAuthGuard,
StudentAuthGuard
] ]
}) })
class AppModule {} class AppModule {}
......
import { Component, OnInit, OnDestroy,ElementRef, ViewChild} from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild} 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';
...@@ -44,7 +44,7 @@ import { ...@@ -44,7 +44,7 @@ import {
Αναζήτηση Αναζήτηση
</button> </button>
<div *ngIf="(retrievedStudent | async)"> <div *ngIf="(retrievedStudent | async)">
<div *ngFor="let StudentDetails$ of StudentInfo$ | async"> <div *ngFor="let StudentDetails$ of StudentInfo$ | async; let i=index">
<br> <br>
<br> <br>
Όνομα: {{StudentDetails$.name}} <br> Όνομα: {{StudentDetails$.name}} <br>
...@@ -58,7 +58,7 @@ import { ...@@ -58,7 +58,7 @@ import {
<strong>Επιβεβαίωση Εγγραφής: </strong> <strong>Επιβεβαίωση Εγγραφής: </strong>
<input #cb class="pull-right" type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" > <input #cb class="pull-right" type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
</div> <!-- </div> -->
</div> </div>
<button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()"> <button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()">
Επιβεβαίωση Εγγραφής Επιβεβαίωση Εγγραφής
...@@ -66,7 +66,7 @@ import { ...@@ -66,7 +66,7 @@ import {
` `
}) })
@Injectable() export default class DirectorView implements OnInit , OnDestroy{ @Injectable() export default class DirectorView implements OnInit, OnDestroy {
public formGroup: FormGroup; public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>; private StudentSelected$: BehaviorSubject<any>;
...@@ -78,32 +78,30 @@ import { ...@@ -78,32 +78,30 @@ import {
private retrievedStudent: BehaviorSubject<boolean>; private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>; private selectionBClass: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private SchoolId = 147 ; private SchoolId = 147;
private currentclass: Number; private currentclass: Number;
private saved :Array<number> = new Array(); private saved: Array<number> = new Array();
constructor( private fb: FormBuilder, constructor(private fb: FormBuilder,
private _hds: HelperDataService, private _hds: HelperDataService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router ) private router: Router) {
{ this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelected$ = new BehaviorSubject([{}]); this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]); this.StudentInfo$ = new BehaviorSubject([{}]);
this.StudentInfo$ = new BehaviorSubject([{}]); this.retrievedStudent = new BehaviorSubject(false);
this.retrievedStudent = new BehaviorSubject(false); this.selectionBClass = new BehaviorSubject(false);
this.selectionBClass = new BehaviorSubject(false); this.selectionCClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false); this.formGroup = this.fb.group({
this.formGroup = this.fb.group({ tomeas: ['', []],
tomeas: ['', []], taxi: ['', []],
taxi: ['', []], specialit: ['', []],
specialit: ['', []], });
});
} }
ngOnDestroy() ngOnDestroy() {
{
if (this.StudentSelectedSub) if (this.StudentSelectedSub)
this.StudentSelectedSub.unsubscribe(); this.StudentSelectedSub.unsubscribe();
if (this.StudentSelectedSpecialSub) if (this.StudentSelectedSpecialSub)
...@@ -112,7 +110,7 @@ import { ...@@ -112,7 +110,7 @@ import {
this.selectionBClass.unsubscribe(); this.selectionBClass.unsubscribe();
if (this.selectionCClass) if (this.selectionCClass)
this.selectionCClass.unsubscribe(); this.selectionCClass.unsubscribe();
if (this.retrievedStudent) if (this.retrievedStudent)
this.retrievedStudent.unsubscribe(); this.retrievedStudent.unsubscribe();
} }
...@@ -121,107 +119,126 @@ import { ...@@ -121,107 +119,126 @@ import {
} }
verifyclass(txop) verifyclass(txop) {
{ this.retrievedStudent.next(false);
this.retrievedStudent.next(false); if (txop.value === "1") {
if (txop.value === "1") this.selectionBClass.next(false);
{ this.selectionCClass.next(false);
this.selectionBClass.next(false);
this.selectionCClass.next(false);
} }
else if (txop.value === "2") else if (txop.value === "2") {
{ this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(data => {
this.selectionBClass.next(true); this.selectionBClass.next(true);
this.selectionCClass.next(false); this.selectionCClass.next(false);
this.StudentSelected$.next(data);
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
} },
else if (txop.value === "3") error => {
{ this.StudentSelected$.next([{}]);
var sectorint = +this.formGroup.value.tomeas; console.log("Error Getting StudentSelectedSpecial");
console.log(sectorint,"test"); },
if (this.formGroup.value.tomeas != '') () => console.log("Getting StudentSelectedSpecial"));
{ }
var sectorint = +this.formGroup.value.tomeas; else if (txop.value === "3") {
var sectorint = +this.formGroup.value.tomeas;
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$); console.log(sectorint, "test");
} if (this.formGroup.value.tomeas != '') {
this.selectionBClass.next(true); var sectorint = +this.formGroup.value.tomeas;
this.selectionCClass.next(true);
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$); this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(data => {
this.StudentSelectedSpecial$.next(data);
},
error => {
this.StudentSelectedSpecial$.next([{}]);
console.log("Error Getting StudentSelectedSpecial");
},
() => console.log("Getting StudentSelectedSpecial"));
} }
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(data => {
this.StudentSelected$.next(data);
this.selectionBClass.next(true);
this.selectionCClass.next(true);
},
error => {
this.StudentSelected$.next([{}]);
console.log("Error Getting StudentSelected");
},
() => console.log("Getting StudentSelected"));
}
} }
checkbclass(tmop,txop) checkbclass(tmop, txop) {
{
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
console.log(sectorint,"tomeas"); console.log(sectorint, "tomeas");
if (txop.value === "3") if (txop.value === "3") {
{ // this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]); this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(data => {
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$); this.StudentSelectedSpecial$.next(data);
},
error => {
this.StudentSelectedSpecial$.next([{}]);
console.log("Error Getting StudentSelectedSpecial");
},
() => console.log("Getting StudentSelectedSpecial"));
} }
} }
findstudent(txop) findstudent(txop) {
{
var sectorint = +this.formGroup.value.tomeas;
if (txop.value === "1")
{
this.currentclass = 1;
}
else if (txop.value === "2")
{
this.currentclass = 2;
}
else if (txop.value === "3")
{
this.currentclass = 3;
}
this.retrievedStudent.next(true);
this.StudentInfo$ = new BehaviorSubject(false);
this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(this.StudentInfo$);
var sectorint = +this.formGroup.value.tomeas;
if (txop.value === "1") {
this.currentclass = 1;
}
else if (txop.value === "2") {
this.currentclass = 2;
}
else if (txop.value === "3") {
this.currentclass = 3;
}
// this.StudentInfo$ = new BehaviorSubject([{}]);
// this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(this.StudentInfo$);
this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(data => {
this.StudentInfo$.next(data);
this.retrievedStudent.next(true);
},
error => {
this.StudentInfo$.next([{}]);
console.log("Error Getting Students");
},
() => console.log("Getting Students"));
} }
updateCheckedOptions(id, event) updateCheckedOptions(id, event) {
{
let i = this.saved.length; let i = this.saved.length;
if (event.target.checked === false) if (event.target.checked === false) {
{ var count = this.saved.length;
var count=this.saved.length; for (var j = 0; j < count; j++) {
for(var j=0;j<count;j++) if (this.saved[j] === id) {
{ this.saved.splice(j, 1);
if(this.saved[j]===id) }
{ }
this.saved.splice(j, 1); }
else {
this.saved[i] = id;
} }
}
}
else
{
this.saved[i] = id ;
}
} }
confirmStudent() confirmStudent() {
{ this._hds.saveConfirmStudents(this.saved);
this._hds.saveConfirmStudents(this.saved); }
}
checkcclass() checkcclass() {
{ this.retrievedStudent.next(false);
this.retrievedStudent.next(false); }
}
} }
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
<div *ngIf="(loginInfo$ | async).size > 0" class="pull-right" class="nav-item" [ngClass]="{active: path=='submited-preview'}"> <div *ngIf="(loginInfo$ | async).size > 0" class="pull-right" class="nav-item" [ngClass]="{active: path=='submited-preview'}">
<a class="nav-link" [routerLink]="['/submited-preview']" [routerLinkActive]="['active']"><b>Υποβληθείσες αιτήσεις</b></a> <a class="nav-link" [routerLink]="['/submited-preview']" [routerLinkActive]="['active']"><b>Υποβληθείσες αιτήσεις</b></a>
<a class="nav-link" [routerLink]="['/director-view']" [routerLinkActive]="['active']"><b>Επιλεχθέντες Μαθητές</b></a> <a class="nav-link" [routerLink]="['/school/director-view']" [routerLinkActive]="['active']"><b>Επιλεχθέντες Μαθητές</b></a>
<a class="nav-link" [routerLink]="['/director-classcapacity']" [routerLinkActive]="['active']"><b>Δυναμική Σχολείου</b></a> <a class="nav-link" [routerLink]="['/school/director-classcapacity']" [routerLinkActive]="['active']"><b>Δυναμική Σχολείου</b></a>
</div> </div>
</ul> </ul>
......
...@@ -65,7 +65,7 @@ export default class SchoolHome implements OnInit { ...@@ -65,7 +65,7 @@ export default class SchoolHome implements OnInit {
this.authToken = loginInfoToken.auth_token; this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role; this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0) if (this.authToken && this.authToken.length > 0)
this.router.navigate(['/director-view']); this.router.navigate(['/school/director-view']);
return loginInfoToken; return loginInfoToken;
}, {}); }, {});
} }
......
...@@ -47,3 +47,6 @@ export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{ ...@@ -47,3 +47,6 @@ export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{
//DD-MM-YYYY //DD-MM-YYYY
export const VALID_DATE_PATTERN = '([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.](19|20)[0-9][0-9]'; export const VALID_DATE_PATTERN = '([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.](19|20)[0-9][0-9]';
export const SCHOOL_ROLE = 'director';
export const STUDENT_ROLE = 'student';
...@@ -22,25 +22,27 @@ import SubmitedPreview from '../components/student-application-form/submited.apl ...@@ -22,25 +22,27 @@ import SubmitedPreview from '../components/student-application-form/submited.apl
import SubmitedPerson from '../components/student-application-form/submitedstudent.preview'; import SubmitedPerson from '../components/student-application-form/submitedstudent.preview';
import DirectorView from '../components/director/director-view'; import DirectorView from '../components/director/director-view';
import DirectorClassCapacity from '../components/director/director-classcapacity'; import DirectorClassCapacity from '../components/director/director-classcapacity';
import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard';
export const MainRoutes: Routes = [ export const MainRoutes: Routes = [
{ path: '', component: Home }, { path: '', component: Home },
{ path: 'school', component: SchoolHome }, { path: 'school', component: SchoolHome },
{ path: 'parent-form', component: ParentForm }, { path: 'parent-form', component: ParentForm, canActivate: [StudentAuthGuard] },
{ path: 'student-application-form-main', component: StudentApplicationMain }, { path: 'student-application-form-main', component: StudentApplicationMain, canActivate: [StudentAuthGuard] },
{ path: 'students-list', component: StudentsList }, // { path: 'students-list', component: StudentsList },
{ path: 'course-fields-select', component: CourseFieldsSelect }, { path: 'course-fields-select', component: CourseFieldsSelect, canActivate: [StudentAuthGuard] },
{ path: 'epal-class-select', component: EpalClassesSelect }, { path: 'epal-class-select', component: EpalClassesSelect, canActivate: [StudentAuthGuard] },
{ path: 'sector-fields-select', component: SectorFieldsSelect }, { path: 'sector-fields-select', component: SectorFieldsSelect, canActivate: [StudentAuthGuard] },
{ path: 'region-schools-select', component: RegionSchoolsSelect }, { path: 'region-schools-select', component: RegionSchoolsSelect, canActivate: [StudentAuthGuard] },
{ path: 'sectorcourses-fields-select', component: SectorCoursesSelect }, { path: 'sectorcourses-fields-select', component: SectorCoursesSelect, canActivate: [StudentAuthGuard] },
{ path: 'application-preview', component: ApplicationPreview }, { path: 'application-preview', component: ApplicationPreview, canActivate: [StudentAuthGuard] },
{ path: 'schools-order-select', component: SchoolsOrderSelect }, { path: 'schools-order-select', component: SchoolsOrderSelect, canActivate: [StudentAuthGuard] },
{ path: 'application-submit', component: ApplicationSubmit }, { path: 'application-submit', component: ApplicationSubmit, canActivate: [StudentAuthGuard] },
{ path: 'submited-preview', component: SubmitedPreview }, { path: 'submited-preview', component: SubmitedPreview, canActivate: [StudentAuthGuard] },
{ path: 'submited-person', component: SubmitedPerson }, { path: 'submited-person', component: SubmitedPerson, canActivate: [StudentAuthGuard] },
{ path: 'director-view', component: DirectorView }, { path: 'school/director-view', component: DirectorView, canActivate: [SchoolAuthGuard] },
{ path: 'director-classcapacity', component: DirectorClassCapacity }, { path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] },
]; ];
export const MainDeclarations = [ export const MainDeclarations = [
......
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { SCHOOL_ROLE } from '../constants';
@Injectable()
export default class SchoolAuthGuard implements CanActivate {
constructor(private authService: AuthService) {}
canActivate() {
return this.authService.isLoggedIn(SCHOOL_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;});
}
}
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { STUDENT_ROLE } from '../constants';
@Injectable()
export default class StudentAuthGuard implements CanActivate {
constructor(private authService: AuthService) {}
canActivate() {
return this.authService.isLoggedIn(STUDENT_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;});
}
}
import {Injectable} from '@angular/core';
import {BehaviorSubject} from "rxjs/Rx";
import 'rxjs/add/operator/map';
import { AppSettings } from '../app.settings';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../store/store';
import { ILoginInfo, ILoginInfoToken } from '../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-state';
@Injectable()
export class AuthService {
constructor(
private _ngRedux: NgRedux<IAppState>) {
};
isLoggedIn(role) {
return new Promise((resolve, reject) => {
this._ngRedux.select(state => {
return state.loginInfo;
}).subscribe(loginInfo => {
if (loginInfo.size > 0) {
loginInfo.reduce(({}, loginInfoToken) => {
if (loginInfoToken.auth_token && loginInfoToken.auth_token.length > 0 && loginInfoToken.auth_role === role) {
resolve(true);
}
else {
resolve(false);
}
return loginInfoToken;
}, {});
} else
resolve(false);
},
error => {
console.log("Error Sending Verification Code");
reject("Error Getting Auth Data");
},
() => console.log("Getting Auth Data"));
});
}
}
This diff is collapsed.
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