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
, Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("No students found!!!"),
], Response::HTTP_OK);
$list = array();
return $this->respondWithStatus($list, Response::HTTP_OK);
}
......
......@@ -27,6 +27,9 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
/* Here we import services */
import {HelperDataService} from './services/helper-data-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 Home from './components/home';
......@@ -76,6 +79,9 @@ class MyLocalization extends NgLocalization {
//Service1, again services here
HelperDataService,
LoaderService,
AuthService,
SchoolAuthGuard,
StudentAuthGuard
]
})
class AppModule {}
......
This diff is collapsed.
......@@ -22,8 +22,8 @@
<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]="['/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-view']" [routerLinkActive]="['active']"><b>Επιλεχθέντες Μαθητές</b></a>
<a class="nav-link" [routerLink]="['/school/director-classcapacity']" [routerLinkActive]="['active']"><b>Δυναμική Σχολείου</b></a>
</div>
</ul>
......
......@@ -65,7 +65,7 @@ export default class SchoolHome implements OnInit {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0)
this.router.navigate(['/director-view']);
this.router.navigate(['/school/director-view']);
return loginInfoToken;
}, {});
}
......
......@@ -47,3 +47,6 @@ export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{
//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 SCHOOL_ROLE = 'director';
export const STUDENT_ROLE = 'student';
......@@ -22,25 +22,27 @@ import SubmitedPreview from '../components/student-application-form/submited.apl
import SubmitedPerson from '../components/student-application-form/submitedstudent.preview';
import DirectorView from '../components/director/director-view';
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 = [
{ path: '', component: Home },
{ path: 'school', component: SchoolHome },
{ path: 'parent-form', component: ParentForm },
{ path: 'student-application-form-main', component: StudentApplicationMain },
{ path: 'students-list', component: StudentsList },
{ path: 'course-fields-select', component: CourseFieldsSelect },
{ path: 'epal-class-select', component: EpalClassesSelect },
{ path: 'sector-fields-select', component: SectorFieldsSelect },
{ path: 'region-schools-select', component: RegionSchoolsSelect },
{ path: 'sectorcourses-fields-select', component: SectorCoursesSelect },
{ path: 'application-preview', component: ApplicationPreview },
{ path: 'schools-order-select', component: SchoolsOrderSelect },
{ path: 'application-submit', component: ApplicationSubmit },
{ path: 'submited-preview', component: SubmitedPreview },
{ path: 'submited-person', component: SubmitedPerson },
{ path: 'director-view', component: DirectorView },
{ path: 'director-classcapacity', component: DirectorClassCapacity },
{ path: 'parent-form', component: ParentForm, canActivate: [StudentAuthGuard] },
{ path: 'student-application-form-main', component: StudentApplicationMain, canActivate: [StudentAuthGuard] },
// { path: 'students-list', component: StudentsList },
{ path: 'course-fields-select', component: CourseFieldsSelect, canActivate: [StudentAuthGuard] },
{ path: 'epal-class-select', component: EpalClassesSelect, canActivate: [StudentAuthGuard] },
{ path: 'sector-fields-select', component: SectorFieldsSelect, canActivate: [StudentAuthGuard] },
{ path: 'region-schools-select', component: RegionSchoolsSelect, canActivate: [StudentAuthGuard] },
{ path: 'sectorcourses-fields-select', component: SectorCoursesSelect, canActivate: [StudentAuthGuard] },
{ path: 'application-preview', component: ApplicationPreview, canActivate: [StudentAuthGuard] },
{ path: 'schools-order-select', component: SchoolsOrderSelect, canActivate: [StudentAuthGuard] },
{ path: 'application-submit', component: ApplicationSubmit, canActivate: [StudentAuthGuard] },
{ path: 'submited-preview', component: SubmitedPreview, canActivate: [StudentAuthGuard] },
{ path: 'submited-person', component: SubmitedPerson, canActivate: [StudentAuthGuard] },
{ path: 'school/director-view', component: DirectorView, canActivate: [SchoolAuthGuard] },
{ path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] },
];
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