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

Profile now is saved to store on updates. Various fixes. application.submit...

Profile now is saved to store on updates. Various fixes. application.submit restructured. Browser refresh handling
parent 3e2c4ae9
...@@ -84,7 +84,7 @@ class ApplicationSubmit extends ControllerBase { ...@@ -84,7 +84,7 @@ class ApplicationSubmit extends ControllerBase {
//'lastam' => $applicationForm[0][lastam], //'lastam' => $applicationForm[0][lastam],
'currentclass' => $applicationForm[0][currentclass], 'currentclass' => $applicationForm[0][currentclass],
'guardian_name' => $applicationForm[0][cu_name], 'guardian_name' => $applicationForm[0][cu_name],
'guardian_surnname' => $applicationForm[0][cu_surname], 'guardian_surname' => $applicationForm[0][cu_surname],
'guardian_fathername' => $applicationForm[0][cu_fathername], 'guardian_fathername' => $applicationForm[0][cu_fathername],
'guardian_mothername' => $applicationForm[0][cu_mothername], 'guardian_mothername' => $applicationForm[0][cu_mothername],
'agreement' => $applicationForm[0][disclaimer_checked], 'agreement' => $applicationForm[0][disclaimer_checked],
......
import { LOGININFO_SAVE, LOGININFO_RECEIVED } from '../constants'; import { LOGININFO_SAVE, PROFILE_SAVE, LOGININFO_RECEIVED } from '../constants';
import { LOGININFO_INIT } from '../constants'; import { LOGININFO_INIT } from '../constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux'; import { NgRedux } from 'ng2-redux';
...@@ -32,6 +32,15 @@ export class LoginInfoActions { ...@@ -32,6 +32,15 @@ export class LoginInfoActions {
}); });
}; };
saveProfile = (profile) => {
return this._ngRedux.dispatch({
type: PROFILE_SAVE,
payload: {
profile
}
});
};
initLoginInfo = () => { initLoginInfo = () => {
return this._ngRedux.dispatch({ return this._ngRedux.dispatch({
......
...@@ -33,6 +33,8 @@ import {AuthService} from './services/auth.service'; ...@@ -33,6 +33,8 @@ import {AuthService} from './services/auth.service';
import SchoolAuthGuard from './guards/school.auth.guard'; import SchoolAuthGuard from './guards/school.auth.guard';
import StudentAuthGuard from './guards/student.auth.guard'; import StudentAuthGuard from './guards/student.auth.guard';
import RegionEduAuthGuard from './guards/regionedu.auth.guard'; import RegionEduAuthGuard from './guards/regionedu.auth.guard';
import EduAdminAuthGuard from './guards/eduadmin.auth.guard';
import MinistryAuthGuard from './guards/ministry.auth.guard';
import { ACTION_PROVIDERS } from './actions'; import { ACTION_PROVIDERS } from './actions';
import Home from './components/home'; import Home from './components/home';
...@@ -83,7 +85,9 @@ class MyLocalization extends NgLocalization { ...@@ -83,7 +85,9 @@ class MyLocalization extends NgLocalization {
AuthService, AuthService,
SchoolAuthGuard, SchoolAuthGuard,
StudentAuthGuard, StudentAuthGuard,
RegionEduAuthGuard RegionEduAuthGuard,
EduAdminAuthGuard,
MinistryAuthGuard
] ]
}) })
......
<div class = "loading" *ngIf="(showLoader$ | async) === true"></div> <div class = "loading" *ngIf="(showLoader$ | async) === true"></div>
<div id="headerNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header {{modalHeader | async}}" >
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>{{ modalText | async }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div class="header-wrapper"> <div class="header-wrapper">
<header id="navbar" role="banner" class="navbar navbar-default"> <header id="navbar" role="banner" class="navbar navbar-default">
......
...@@ -28,6 +28,9 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -28,6 +28,9 @@ export default class HeaderComponent implements OnInit, OnDestroy {
private loginInfo$: BehaviorSubject<ILoginInfo>; private loginInfo$: BehaviorSubject<ILoginInfo>;
public cuser :any; public cuser :any;
private showLoader$: BehaviorSubject<boolean>; private showLoader$: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
constructor( private _ata: LoginInfoActions, constructor( private _ata: LoginInfoActions,
private _hds: HelperDataService, private _hds: HelperDataService,
...@@ -46,10 +49,14 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -46,10 +49,14 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this.cuName = ''; this.cuName = '';
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.showLoader$ = new BehaviorSubject(false); this.showLoader$ = new BehaviorSubject(false);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
}; };
ngOnInit() { ngOnInit() {
(<any>$('#headerNotice')).appendTo("body");
this._ngRedux.select(state => { this._ngRedux.select(state => {
if (state.loginInfo.size > 0) { if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => { state.loginInfo.reduce(({}, loginInfoToken) => {
...@@ -66,6 +73,7 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -66,6 +73,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
} }
ngOnDestroy() { ngOnDestroy() {
(<any>$('#headerNotice')).remove();
this.loginInfo$.unsubscribe(); this.loginInfo$.unsubscribe();
} }
...@@ -104,4 +112,12 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -104,4 +112,12 @@ export default class HeaderComponent implements OnInit, OnDestroy {
}); });
} }
public showModal():void {
(<any>$('#headerNotice')).modal('show');
}
public hideModal():void {
(<any>$('#headerNotice')).modal('hide');
}
} }
...@@ -32,6 +32,7 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings'; ...@@ -32,6 +32,7 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
</button> </button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
` `
......
...@@ -32,16 +32,16 @@ ...@@ -32,16 +32,16 @@
<div *ngFor="let loginInfoRow$ of loginInfo$ | async; let i=index;" style = "margin-bottom: 20px;" > <div *ngFor="let loginInfoRow$ of loginInfo$ | async; let i=index;" style = "margin-bottom: 20px;" >
<div class="row evenin" style="margin: 0px 5px 0px 5px;"> <div class="row evenin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-12" style="font-size: 1em; font-weight: bold; text-align: center;">Στοιχεία αιτούμενου κηδεμόνα</div> <div class="col-md-12" style="font-size: 1em; font-weight: bold; text-align: center;">Στοιχεία αιτούμενου</div>
</div> </div>
<div class="row oddin" style="margin: 0px 5px 0px 5px;"> <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-3" style="font-size: 0.8em;">Όνομα</div> <div class="col-md-3" style="font-size: 0.8em;">Όνομα</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_name }}</div> <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_name }}</div>
<div class="col-md-3" style="font-size: 0.8em;">Επώνυμο</div> <div class="col-md-3" style="font-size: 0.8em;">Επώνυμο</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_surname }}</div> <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_surname }}</div>
</div> </div>
<div class="row oddin" style="margin: 0px 5px 0px 5px;"> <div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-3" style="font-size: 0.8em;">Όνομα πατέρα</div> <div class="col-md-3" style="font-size: 0.8em;">Όνομα πατέρα</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_fathername }}</div> <div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_fathername }}</div>
<div class="col-md-3" style="font-size: 0.8em;">Όνομα μητέρας</div> <div class="col-md-3" style="font-size: 0.8em;">Όνομα μητέρας</div>
......
...@@ -117,8 +117,9 @@ import { ...@@ -117,8 +117,9 @@ import {
this.studentDataGroup.controls['regiontk'].setValue(studentDataField.regiontk); this.studentDataGroup.controls['regiontk'].setValue(studentDataField.regiontk);
this.studentDataGroup.controls['regionarea'].setValue(studentDataField.regionarea); this.studentDataGroup.controls['regionarea'].setValue(studentDataField.regionarea);
this.studentDataGroup.controls['certificatetype'].setValue(studentDataField.certificatetype); this.studentDataGroup.controls['certificatetype'].setValue(studentDataField.certificatetype);
this.studentDataGroup.controls['relationtostudent'].setValue(studentDataField.relationtostudent);
this.studentDataGroup.controls['telnum'].setValue(studentDataField.telnum); this.studentDataGroup.controls['telnum'].setValue(studentDataField.telnum);
this.studentDataGroup.setValue({studentbirthdate: this.populateDate(studentDataField.studentbirthdate)}); this.studentDataGroup.controls['studentbirthdate'].setValue(this.populateDate(studentDataField.studentbirthdate));
return studentDataField; return studentDataField;
}, {}); }, {});
} }
...@@ -192,6 +193,7 @@ import { ...@@ -192,6 +193,7 @@ import {
} }
populateDate(d) { populateDate(d) {
if (d && d.length > 0) {
return { return {
date: { date: {
year: d ? parseInt(d.substr(0,4)) : 0, year: d ? parseInt(d.substr(0,4)) : 0,
...@@ -199,6 +201,11 @@ import { ...@@ -199,6 +201,11 @@ import {
day: d ? parseInt(d.substr(8,10)) : 0 day: d ? parseInt(d.substr(8,10)) : 0
} }
}; };
} else {
return {
date: null
};
}
} }
setDate() { setDate() {
......
...@@ -55,8 +55,92 @@ import { HelperDataService } from '../../services/helper-data-service'; ...@@ -55,8 +55,92 @@ import { HelperDataService } from '../../services/helper-data-service';
<breadcrumbs></breadcrumbs> <breadcrumbs></breadcrumbs>
</div> </div>
<application-preview-select></application-preview-select> <!-- <application-preview-select></application-preview-select> -->
<button type="button button-lg pull-right" *ngIf="(studentDataFields$ | async).size > 0 && (criteria$ | async).size > 0 && (regions$ | async).size > 0 && (epalclasses$ | async).size > 0 && (loginInfo$ | async).size > 0" class="btn-primary btn-lg pull-right" (click)="submitNow()">Υποβολή</button>
<div *ngFor="let loginInfoRow$ of loginInfo$ | async; let i=index;" style = "margin-bottom: 20px;" >
<div class="row evenin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-12" style="font-size: 1em; font-weight: bold; text-align: center;">Στοιχεία αιτούμενου</div>
</div>
<div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-3" style="font-size: 0.8em;">Όνομα</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_name }}</div>
<div class="col-md-3" style="font-size: 0.8em;">Επώνυμο</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_surname }}</div>
</div>
<div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-3" style="font-size: 0.8em;">Όνομα πατέρα</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_fathername }}</div>
<div class="col-md-3" style="font-size: 0.8em;">Όνομα μητέρας</div>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{ loginInfoRow$.cu_mothername }}</div>
</div>
</div>
<div *ngFor="let studentDataField$ of studentDataFields$ | async;">
<ul class="list-group left-side-view" style="margin-bottom: 20px;">
<li class="list-group-item active">
Στοιχεία μαθητή
</li>
</ul>
<div><label for="name">Όνομα μαθητή</label> <p class="form-control" id="name" style="border:1px solid #eceeef;"> {{studentDataField$.name}} </p> </div>
<div><label for="studentsurname">Επώνυμο μαθητή</label> <p class="form-control" id = "studentsurname" style="border:1px solid #eceeef;"> {{studentDataField$.studentsurname}} </p></div>
<div><label for="fatherfirstname">Όνομα Πατέρα</label> <p class="form-control" id = "fatherfirstname" style="border:1px solid #eceeef;"> {{studentDataField$.fatherfirstname}} </p></div>
<div><label for="fathersurname">Επώνυμο Πατέρα</label> <p class="form-control" id = "fathersurname" style="border:1px solid #eceeef;"> {{studentDataField$.fathersurname}} </p></div>
<div><label for="motherfirstname">Όνομα Μητέρας</label> <p class="form-control" id = "motherfirstname" style="border:1px solid #eceeef;"> {{studentDataField$.motherfirstname}} </p></div>
<div><label for="mothersurname">Επώνυμο Μητέρας</label> <p class="form-control" id = "mothersurname" style="border:1px solid #eceeef;"> {{studentDataField$.mothersurname}} </p></div>
<div><label for="birthdate">Ημερομηνία Γέννησης</label> <p class="form-control" id = "birthdate" style="border:1px solid #eceeef;"> {{studentDataField$.studentbirthdate}} </p></div>
<table>
<tr>
<td>
<div class="form-group">
<label for="regionaddress">Διεύθυνση κατοικίας</label><p class="form-control" id = "regionaddress" style="border:1px solid #eceeef;"> {{studentDataField$.regionaddress}} </p>
</div>
</td>
<td>
<div class="form-group">
<label for="regiontk">TK </label><p class="form-control" id = "regiontk" style="border:1px solid #eceeef;"> {{studentDataField$.regiontk}} </p>
</div>
</td>
<td>
<div class="form-group">
<label for="regionarea">Πόλη/Περιοχή</label><p class="form-control" id = "regionarea" style="border:1px solid #eceeef;"> {{studentDataField$.regionarea}} </p>
</div>
</td>
</tr>
</table>
<div><label for="certificatetype">Τύπος απολυτηρίου</label> <p class="form-control" id = "certificatetype" style="border:1px solid #eceeef;"> {{studentDataField$.certificatetype}} </p></div>
<div><label for="telnum">Τηλέφωνο επικοινωνίας</label> <p class="form-control" id = "telnum" style="border:1px solid #eceeef;"> {{studentDataField$.telnum}} </p></div>
<div><label for="relationtostudent">Η αίτηση γίνεται από</label> <p class="form-control" id = "relationtostudent" style="border:1px solid #eceeef;"> {{studentDataField$.relationtostudent}} </p></div>
<ul class="list-group left-side-view" style="margin-bottom: 20px;">
<li class="list-group-item active">
<div *ngIf="currentUrl === '/application-submit'">
Κοινωνικά/Εισοδηματικά Κριτήρια
</div>
</li>
</ul>
</div>
<div *ngFor="let criteriaField$ of criteriaFields$ | async;">
<div *ngIf="criteriaField$.selected === true">
{{criteriaField$.name}}
</div>
</div>
<div class="row" style="margin-top: 20px; margin-bottom: 20px;" *ngIf="(criteria$ | async).size > 0">
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-left" (click)="navigateBack()">
<i class="fa fa-backward"></i>
</button>
</div>
<div class="col-md-6">
<button type="button" *ngIf="(studentDataFields$ | async).size > 0 && (criteria$ | async).size > 0 && (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()">
<span style="font-size: 0.9em; font-weight: bold;">Υποβολή&nbsp;&nbsp;&nbsp;</span><i class="fa fa-forward"></i>
</button>
</div>
</div>
` `
}) })
...@@ -342,4 +426,8 @@ import { HelperDataService } from '../../services/helper-data-service'; ...@@ -342,4 +426,8 @@ import { HelperDataService } from '../../services/helper-data-service';
this.router.navigate(['/post-submit']); this.router.navigate(['/post-submit']);
} }
navigateBack() {
this.router.navigate(['/student-application-form-main']);
}
} }
...@@ -3,6 +3,7 @@ import { Router } from '@angular/router'; ...@@ -3,6 +3,7 @@ import { Router } from '@angular/router';
import { BehaviorSubject, Subscription, Observable } from 'rxjs/Rx'; import { BehaviorSubject, Subscription, Observable } from 'rxjs/Rx';
import { VALID_EMAIL_PATTERN, VALID_NAMES_PATTERN } from '../../constants'; import { VALID_EMAIL_PATTERN, VALID_NAMES_PATTERN } from '../../constants';
import { HelperDataService } from '../../services/helper-data-service'; import { HelperDataService } from '../../services/helper-data-service';
import { LoginInfoActions } from '../../actions/logininfo.actions'
import { import {
FormBuilder, FormBuilder,
...@@ -37,6 +38,7 @@ import {AppSettings} from '../../app.settings'; ...@@ -37,6 +38,7 @@ import {AppSettings} from '../../app.settings';
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private router: Router, private router: Router,
private hds: HelperDataService, private hds: HelperDataService,
private _prfa: LoginInfoActions,
private rd: Renderer) { private rd: Renderer) {
this.verificationCodeSent = new BehaviorSubject(false); this.verificationCodeSent = new BehaviorSubject(false);
this.verificationCodeVerified = new BehaviorSubject(false); this.verificationCodeVerified = new BehaviorSubject(false);
...@@ -152,6 +154,7 @@ import {AppSettings} from '../../app.settings'; ...@@ -152,6 +154,7 @@ import {AppSettings} from '../../app.settings';
this.showLoader.next(true); this.showLoader.next(true);
this.hds.saveProfile(this.formGroup.value) this.hds.saveProfile(this.formGroup.value)
.then(res => { .then(res => {
this._prfa.saveProfile(this.formGroup.value);
this.showLoader.next(false); this.showLoader.next(false);
this.router.navigate(['/epal-class-select']);}) this.router.navigate(['/epal-class-select']);})
.catch(err => { .catch(err => {
......
...@@ -21,6 +21,7 @@ export const EPALCLASSES_SAVE = 'EPALCLASSES_SAVE'; ...@@ -21,6 +21,7 @@ export const EPALCLASSES_SAVE = 'EPALCLASSES_SAVE';
export const EPALCLASSES_INIT = 'EPALCLASSES_INIT'; export const EPALCLASSES_INIT = 'EPALCLASSES_INIT';
export const LOGININFO_SAVE = 'LOGININFO_SAVE'; export const LOGININFO_SAVE = 'LOGININFO_SAVE';
export const PROFILE_SAVE = 'PROFILE_SAVE';
export const LOGININFO_RECEIVED = 'LOGININFO_RECEIVED'; export const LOGININFO_RECEIVED = 'LOGININFO_RECEIVED';
......
...@@ -35,13 +35,17 @@ import InformStudents from '../components/minister/minister-informstudents'; ...@@ -35,13 +35,17 @@ import InformStudents from '../components/minister/minister-informstudents';
import SchoolAuthGuard from '../guards/school.auth.guard'; import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard'; import StudentAuthGuard from '../guards/student.auth.guard';
import RegionEduAuthGuard from '../guards/regionedu.auth.guard'; import RegionEduAuthGuard from '../guards/regionedu.auth.guard';
import MinistryAuthGuard from '../guards/ministry.auth.guard';
import Breadcrumbs from '../components/main/breadcrumbs'; import Breadcrumbs from '../components/main/breadcrumbs';
export const MainRoutes: Routes = [ export const MainRoutes: Routes = [
{ path: '', component: Home }, { path: '', component: Home },
{ path: 'logout', component: Home },
{ path: 'school', component: SchoolHome }, { path: 'school', component: SchoolHome },
{ path: 'school/logout', component: SchoolHome },
{ path: 'ministry', component: MinistryHome }, { path: 'ministry', component: MinistryHome },
{ path: 'breadcrumbs', component: Breadcrumbs }, { path: 'ministry/logout', component: MinistryHome },
// { path: 'breadcrumbs', component: Breadcrumbs },
{ path: 'parent-form', component: ParentForm, canActivate: [StudentAuthGuard] }, { path: 'parent-form', component: ParentForm, canActivate: [StudentAuthGuard] },
{ path: 'student-application-form-main', component: StudentApplicationMain, canActivate: [StudentAuthGuard] }, { path: 'student-application-form-main', component: StudentApplicationMain, canActivate: [StudentAuthGuard] },
// { path: 'students-list', component: StudentsList }, // { path: 'students-list', component: StudentsList },
...@@ -57,14 +61,14 @@ export const MainRoutes: Routes = [ ...@@ -57,14 +61,14 @@ export const MainRoutes: Routes = [
{ path: 'submited-person', component: SubmitedPerson, canActivate: [StudentAuthGuard] }, { path: 'submited-person', component: SubmitedPerson, canActivate: [StudentAuthGuard] },
{ path: 'post-submit', component: AfterSubmit, canActivate: [StudentAuthGuard] }, { path: 'post-submit', component: AfterSubmit, canActivate: [StudentAuthGuard] },
{ path: 'school/director-view', component: DirectorView, canActivate: [SchoolAuthGuard] }, { path: 'school/director-view', component: DirectorView, canActivate: [SchoolAuthGuard] },
{ path: 'school/director-buttons', component: DirectorButtons }, { path: 'school/director-buttons', component: DirectorButtons, canActivate: [SchoolAuthGuard] },
{ path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] }, { path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] },
{ path: 'ministry/minister-view', component: MinisterView }, { path: 'ministry/minister-view', component: MinisterView, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/minister-reports', component: MinisterReports }, { path: 'ministry/minister-reports', component: MinisterReports, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/report-all-stat/:reportId', component: ReportAllStat }, { path: 'ministry/report-all-stat/:reportId', component: ReportAllStat, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/report-general/:reportId', component: ReportGeneral }, { path: 'ministry/report-general/:reportId', component: ReportGeneral, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/report-no-capacity/:reportId', component: ReportNoCapacity }, { path: 'ministry/report-no-capacity/:reportId', component: ReportNoCapacity, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/minister-informstudents', component: InformStudents }, { path: 'ministry/minister-informstudents', component: InformStudents, canActivate: [MinistryAuthGuard] },
{ path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] }, { path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] },
]; ];
......
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { DIDE_ROLE } from '../constants';
import { Router } from '@angular/router';
@Injectable()
export default class EduAdminAuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {}
canActivate() {
return this.authService.isLoggedIn(DIDE_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(['/school/logout']);
}
return loggedIn;
}).catch(err => {
return false;
});
}
}
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { MINISTRY_ROLE } from '../constants';
import { Router } from '@angular/router';
@Injectable()
export default class MinistryAuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {}
canActivate() {
return this.authService.isLoggedIn(MINISTRY_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(['/ministry/logout']);
}
return loggedIn;
}).catch(err => {
return false;
});
}
}
...@@ -2,13 +2,21 @@ import { Injectable } from '@angular/core'; ...@@ -2,13 +2,21 @@ import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router'; import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service'; import { AuthService } from '../services/auth.service';
import { PDE_ROLE } from '../constants'; import { PDE_ROLE } from '../constants';
import { Router } from '@angular/router';
@Injectable() @Injectable()
export default class RegionEduAuthGuard implements CanActivate { export default class RegionEduAuthGuard implements CanActivate {
constructor(private authService: AuthService) {} constructor(private authService: AuthService, private router: Router) {}
canActivate() { canActivate() {
return this.authService.isLoggedIn(PDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;}); return this.authService.isLoggedIn(PDE_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(['/school/logout']);
}
return loggedIn;
}).catch(err => {
return false;
});
} }
} }
...@@ -2,13 +2,21 @@ import { Injectable } from '@angular/core'; ...@@ -2,13 +2,21 @@ import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router'; import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service'; import { AuthService } from '../services/auth.service';
import { SCHOOL_ROLE } from '../constants'; import { SCHOOL_ROLE } from '../constants';
import { Router } from '@angular/router';
@Injectable() @Injectable()
export default class SchoolAuthGuard implements CanActivate { export default class SchoolAuthGuard implements CanActivate {
constructor(private authService: AuthService) {} constructor(private authService: AuthService, private router: Router) {}
canActivate() { canActivate() {
return this.authService.isLoggedIn(SCHOOL_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;}); return this.authService.isLoggedIn(SCHOOL_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(['/school/logout']);
}