Commit 0b7b740d authored by Open Source Developer's avatar Open Source Developer

trans

parent 5538e078
......@@ -31,6 +31,7 @@ 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 RegionEduAuthGuard from './guards/regionedu.auth.guard';
import { ACTION_PROVIDERS } from './actions';
import Home from './components/home';
......@@ -83,7 +84,9 @@ class MyLocalization extends NgLocalization {
LoaderService,
AuthService,
SchoolAuthGuard,
StudentAuthGuard
StudentAuthGuard,
RegionEduAuthGuard
]
})
class AppModule {}
......
......@@ -75,7 +75,10 @@ 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(['/school/director-view']);
if (this.authRole = 'director')
this.router.navigate(['/school/director-view']);
if (this.authRole = 'pde')
this.router.navigate(['/school/perfecture-view']);
return loginInfoToken;
}, {});
}
......
......@@ -22,11 +22,13 @@ import ApplicationSubmit from '../components/student-application-form/applicatio
import SubmitedPreview from '../components/student-application-form/submited.aplication.preview';
import SubmitedPerson from '../components/student-application-form/submitedstudent.preview';
import DirectorView from '../components/director/director-view';
import PerfectureView from '../components/infoviews/perfecture-view';
import DirectorClassCapacity from '../components/director/director-classcapacity';
import MinisterView from '../components/minister/minister-view';
import MinisterReports from '../components/minister/minister-reports';
import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard';
import RegionEduAuthGuard from '../guards/regionedu.auth.guard';
export const MainRoutes: Routes = [
{ path: '', component: Home },
......@@ -49,6 +51,7 @@ export const MainRoutes: Routes = [
{ path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] },
{ path: 'ministry/minister-view', component: MinisterView },
{ path: 'ministry/minister-reports', component: MinisterReports },
{ path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] },
];
export const MainDeclarations = [
......@@ -73,5 +76,6 @@ export const MainDeclarations = [
DirectorView,
DirectorClassCapacity,
MinisterView,
MinisterReports
MinisterReports,
PerfectureView,
];
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { PDE_ROLE } from '../constants';
@Injectable()
export default class RegionEduAuthGuard implements CanActivate {
constructor(private authService: AuthService) {}
canActivate() {
return this.authService.isLoggedIn(PDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;});
}
}
......@@ -693,6 +693,31 @@ export class HelperDataService implements OnInit, OnDestroy {
}
getSchoolPerPerfecture(PerfectureId) {
console.log(PerfectureId,"a");
let PerfectureIdNew = PerfectureId.toString();
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/ScoolperPerf/` + PerfectureIdNew , options)
.map(response => response.json());
}
}
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