diff --git a/drupal/modules/epal/src/Controller/DirectorView.php b/drupal/modules/epal/src/Controller/DirectorView.php
index 01785814c434221cd1b86b0d3c0cf552ff77d414..bb866b4e3c51ab77b5d277713e90e3cf21cf2f26 100644
--- a/drupal/modules/epal/src/Controller/DirectorView.php
+++ b/drupal/modules/epal/src/Controller/DirectorView.php
@@ -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);
}
diff --git a/source/app.ts b/source/app.ts
index 27e8e8e958bcdbe8275dde4d629758534c738e3e..d475f40013db78e0ab11567c73e2329636ab4e6a 100644
--- a/source/app.ts
+++ b/source/app.ts
@@ -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 {}
diff --git a/source/components/director/director-view.ts b/source/components/director/director-view.ts
index 4c6f446106a879f61ce5257aa88dc516035fcfe7..7de9643afd0ec3c3e7c5ea6cf2515971099ae4fb 100644
--- a/source/components/director/director-view.ts
+++ b/source/components/director/director-view.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, OnDestroy,ElementRef, ViewChild} from "@angular/core";
+import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
@@ -44,7 +44,7 @@ import {
Αναζήτηση
-
+
Όνομα: {{StudentDetails$.name}}
@@ -58,7 +58,7 @@ import {
Επιβεβαίωση Εγγραφής:
-
+
diff --git a/source/components/school.home.ts b/source/components/school.home.ts
index e165e4cff3d2900347a90c19956fd340c1c4ee94..ed57e3e13561001f9f74de2a14cee9ef1c77c116 100644
--- a/source/components/school.home.ts
+++ b/source/components/school.home.ts
@@ -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;
}, {});
}
diff --git a/source/constants.ts b/source/constants.ts
index cbdb99a4354cdf0b8702f4476e0b3854c70f52ad..914ea8d6dae9b0117410a8c9f3f67829199df3e7 100644
--- a/source/constants.ts
+++ b/source/constants.ts
@@ -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';
diff --git a/source/containers/main.routes.ts b/source/containers/main.routes.ts
index bce23509b8994206aa35a6ad0ee17bc3d4f5dba7..b44e9a304e85b8c1a0b4776304058d7bc3d8c33f 100644
--- a/source/containers/main.routes.ts
+++ b/source/containers/main.routes.ts
@@ -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 = [
diff --git a/source/guards/school.auth.guard.ts b/source/guards/school.auth.guard.ts
new file mode 100644
index 0000000000000000000000000000000000000000..474a72d7e2f5437fd41a2f41ca69c0183a619903
--- /dev/null
+++ b/source/guards/school.auth.guard.ts
@@ -0,0 +1,14 @@
+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;});
+ }
+}
diff --git a/source/guards/student.auth.guard.ts b/source/guards/student.auth.guard.ts
new file mode 100644
index 0000000000000000000000000000000000000000..16517a43c6e6885492fcb12cfb58ec34901c7053
--- /dev/null
+++ b/source/guards/student.auth.guard.ts
@@ -0,0 +1,14 @@
+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;});
+ }
+}
diff --git a/source/services/auth.service.ts b/source/services/auth.service.ts
new file mode 100644
index 0000000000000000000000000000000000000000..82336864239ded5ac44c80062fb56f5c8004bc04
--- /dev/null
+++ b/source/services/auth.service.ts
@@ -0,0 +1,44 @@
+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) {
+
+ };
+
+ 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"));
+ });
+ }
+
+}
diff --git a/source/services/helper-data-service.ts b/source/services/helper-data-service.ts
index 86d441fa10108d2e884e4dd020d05e473f2363c6..21a6d90f7295aa9f758656c851a7289c2dbb9e5c 100644
--- a/source/services/helper-data-service.ts
+++ b/source/services/helper-data-service.ts
@@ -17,7 +17,7 @@ import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-st
const HEADER = { headers: new Headers({ 'Content-Type': 'application/json' }) };
@Injectable()
-export class HelperDataService implements OnInit, OnDestroy{
+export class HelperDataService implements OnInit, OnDestroy {
private authToken: string;
private authRole: string;
@@ -26,7 +26,7 @@ export class HelperDataService implements OnInit, OnDestroy{
constructor(
private http: Http,
private _ngRedux: NgRedux) {
- this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
+ this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
};
@@ -52,8 +52,8 @@ export class HelperDataService implements OnInit, OnDestroy{
getEpalUserData() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -68,94 +68,94 @@ export class HelperDataService implements OnInit, OnDestroy{
sendVerificationCode(email) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
-// "Accept": "*/*",
-// "Access-Control-Allow-Credentials": "true",
+ "Content-Type": "application/json",
+ // "Accept": "*/*",
+ // "Access-Control-Allow-Credentials": "true",
});
this.createAuthorizationHeader(headers);
-// let options = new RequestOptions({ headers: headers, withCredentials: true });
+ // let options = new RequestOptions({ headers: headers, withCredentials: true });
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
- this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/sendvercode`, {userEmail: email}, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error Sending Verification Code"); // in case of failure show this message
- reject("Error Sending Verification Code");
- },
- () => console.log("Sending Verification Code"));//run this code in all cases); */
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/sendvercode`, { userEmail: email }, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error Sending Verification Code"); // in case of failure show this message
+ reject("Error Sending Verification Code");
+ },
+ () => console.log("Sending Verification Code"));//run this code in all cases); */
});
}
verifyVerificationCode(verificationCode) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
-// "Accept": "*/*",
-// "Access-Control-Allow-Credentials": "true",
+ "Content-Type": "application/json",
+ // "Accept": "*/*",
+ // "Access-Control-Allow-Credentials": "true",
});
this.createAuthorizationHeader(headers);
-// let options = new RequestOptions({ headers: headers, withCredentials: true });
+ // let options = new RequestOptions({ headers: headers, withCredentials: true });
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
console.log("verificationCode=" + verificationCode);
- this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/verifyvercode`, {verificationCode: verificationCode}, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error Verifying Verification Code"); // in case of failure show this message
- reject("Error Verifying Verification Code");
- },
- () => console.log("Verifying Verification Code"));//run this code in all cases); */
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/verifyvercode`, { verificationCode: verificationCode }, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error Verifying Verification Code"); // in case of failure show this message
+ reject("Error Verifying Verification Code");
+ },
+ () => console.log("Verifying Verification Code"));//run this code in all cases); */
});
}
saveProfile(userProfile) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
+ "Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
- this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/save`, {userProfile: userProfile}, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- },
- error => {
- console.log("Error Saving Profile");
- reject("Error Saving Profile");
- },
- () => console.log("Saving Profile"));
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/user/save`, { userProfile: userProfile }, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ },
+ error => {
+ console.log("Error Saving Profile");
+ reject("Error Saving Profile");
+ },
+ () => console.log("Saving Profile"));
});
}
getCourseFields() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -168,29 +168,29 @@ export class HelperDataService implements OnInit, OnDestroy{
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "EHu964c7gN7M399UfHiHHv06x1Tx5cl-P-9ZyMdmGbw",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}/coursefields/list`, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error HTTP GET Service"); // in case of failure show this message
- reject("Error HTTP GET Service");
- },
- () => console.log("Course Fields Received"));//run this code in all cases); */
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error HTTP GET Service"); // in case of failure show this message
+ reject("Error HTTP GET Service");
+ },
+ () => console.log("Course Fields Received"));//run this code in all cases); */
});
};
getSectorFields() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -202,29 +202,29 @@ export class HelperDataService implements OnInit, OnDestroy{
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}/sectorfields/list`, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error HTTP GET Service"); // in case of failure show this message
- reject("Error HTTP GET Service");
- },
- () => console.log("Sector Fields Received"));//run this code in all cases); */
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error HTTP GET Service"); // in case of failure show this message
+ reject("Error HTTP GET Service");
+ },
+ () => console.log("Sector Fields Received"));//run this code in all cases); */
});
};
- getRegionsWithSchools(classActive,courseActive) {
+ getRegionsWithSchools(classActive, courseActive) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -236,8 +236,8 @@ export class HelperDataService implements OnInit, OnDestroy{
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
@@ -246,11 +246,11 @@ export class HelperDataService implements OnInit, OnDestroy{
//if (courseActive === -1)
if (classActive === 1)
- getConnectionString = `${AppSettings.API_ENDPOINT}/regions/list`;
- else if (classActive === 2)
- getConnectionString = `${AppSettings.API_ENDPOINT}/sectorsperschool/list?sector_id=${courseActive}`;
+ getConnectionString = `${AppSettings.API_ENDPOINT}/regions/list`;
+ else if (classActive === 2)
+ getConnectionString = `${AppSettings.API_ENDPOINT}/sectorsperschool/list?sector_id=${courseActive}`;
else if (classActive === 3)
- getConnectionString = `${AppSettings.API_ENDPOINT}/coursesperschool/list?course_id=${courseActive}`;
+ getConnectionString = `${AppSettings.API_ENDPOINT}/coursesperschool/list?course_id=${courseActive}`;
this.http.get(getConnectionString, options)
.map(response => response.json())
@@ -267,8 +267,8 @@ export class HelperDataService implements OnInit, OnDestroy{
getSectorsWithCourses() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -280,22 +280,22 @@ export class HelperDataService implements OnInit, OnDestroy{
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}/coursesectorfields/list`, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(this.transformSectorCoursesSchema(data));
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error HTTP GET Service"); // in case of failure show this message
- reject("Error HTTP GET Service");
- },
- () => console.log("region schools service"));//run this code in all cases); */
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(this.transformSectorCoursesSchema(data));
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error HTTP GET Service"); // in case of failure show this message
+ reject("Error HTTP GET Service");
+ },
+ () => console.log("region schools service"));//run this code in all cases); */
});
};
@@ -307,14 +307,14 @@ export class HelperDataService implements OnInit, OnDestroy{
trackRegionId = "";
trackIndex = -1;
- let j=0;
+ let j = 0;
regionSchools.forEach(regionSchool => {
if (trackRegionId !== regionSchool.region_id) {
trackIndex++;
- rsa.push({'region_id': regionSchool.region_id, 'region_name': regionSchool.region_name, 'epals': Array()});
+ rsa.push({ 'region_id': regionSchool.region_id, 'region_name': regionSchool.region_name, 'epals': Array() });
trackRegionId = regionSchool.region_id;
}
- rsa[trackIndex].epals.push({'epal_id': regionSchool.epal_id, 'epal_name': regionSchool.epal_name, 'epal_special_case': regionSchool.epal_special_case, 'globalIndex': j, 'selected': false, 'order_id': 0});
+ rsa[trackIndex].epals.push({ 'epal_id': regionSchool.epal_id, 'epal_name': regionSchool.epal_name, 'epal_special_case': regionSchool.epal_special_case, 'globalIndex': j, 'selected': false, 'order_id': 0 });
j++;
});
return rsa;
@@ -328,14 +328,14 @@ export class HelperDataService implements OnInit, OnDestroy{
trackSectorId = "";
trackIndex = -1;
- let j=0;
+ let j = 0;
sectorCourses.forEach(sectorCourse => {
if (trackSectorId !== sectorCourse.sector_id) {
trackIndex++;
- rsa.push({'sector_id': sectorCourse.sector_id, 'sector_name': sectorCourse.sector_name, 'sector_selected': false, 'courses': Array()});
+ rsa.push({ 'sector_id': sectorCourse.sector_id, 'sector_name': sectorCourse.sector_name, 'sector_selected': false, 'courses': Array() });
trackSectorId = sectorCourse.sector_id;
}
- rsa[trackIndex].courses.push({'course_id': sectorCourse.course_id, 'course_name': sectorCourse.course_name, 'globalIndex': j, 'selected': false});
+ rsa[trackIndex].courses.push({ 'course_id': sectorCourse.course_id, 'course_name': sectorCourse.course_name, 'globalIndex': j, 'selected': false });
j++;
});
return rsa;
@@ -344,8 +344,8 @@ export class HelperDataService implements OnInit, OnDestroy{
getCriteria() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -357,16 +357,16 @@ export class HelperDataService implements OnInit, OnDestroy{
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}/criteria/list`, options)
- //this.http.get(`${AppSettings.API_ENDPOINT}/criteria/list?category=${category}`, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error HTTP GET Service"); // in case of failure show this message
- reject("Error HTTP GET Service");
- },
- () => console.log("Sector Fields Received"));//run this code in all cases); */
+ //this.http.get(`${AppSettings.API_ENDPOINT}/criteria/list?category=${category}`, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error HTTP GET Service"); // in case of failure show this message
+ reject("Error HTTP GET Service");
+ },
+ () => console.log("Sector Fields Received"));//run this code in all cases); */
});
};
@@ -382,38 +382,38 @@ export class HelperDataService implements OnInit, OnDestroy{
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
- return new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}/epal/curuser`, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(this.transformUserSchema(data, oauthtoken, oauthrole));
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error HTTP GET Service"); // in case of failure show this message
- reject("Error HTTP GET Service");
- },
- () => console.log("UserName Received"));
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(this.transformUserSchema(data, oauthtoken, oauthrole));
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error HTTP GET Service"); // in case of failure show this message
+ reject("Error HTTP GET Service");
+ },
+ () => console.log("UserName Received"));
});
-}
+ }
- transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
+ transformUserSchema(userlogin: any, oauthtoken: string, oauthrole: string) {
let rsa = Array();
- rsa.push({'auth_token': oauthtoken, 'auth_role': oauthrole, 'cu_name':userlogin.name});
+ rsa.push({ 'auth_token': oauthtoken, 'auth_role': oauthrole, 'cu_name': userlogin.name });
return rsa;
- }
+ }
signOut() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ this.authToken = loginInfoToken.auth_token;
+ this.authRole = loginInfoToken.auth_role;
});
console.log("authToken=" + this.authToken);
console.log("authRole=" + this.authRole);
@@ -422,15 +422,15 @@ export class HelperDataService implements OnInit, OnDestroy{
// "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
- "Content-Type": "application/json",
+ "Content-Type": "application/json",
"Accept": "*/*",
"Access-Control-Allow-Credentials": "true",
// "Content-Type": "text/plain", // try to skip preflight
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "EoAZ0APpIbbewK5MNzRrCFkvEeZZoGQsBslWFTrZ8bI",
-// "X-oauth-enabled": "true",
-// "X-Auth-Token": this.authToken
+ // "X-oauth-enabled": "true",
+ // "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers, withCredentials: true });
@@ -441,15 +441,15 @@ export class HelperDataService implements OnInit, OnDestroy{
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}${logoutRoute}`, {}, options)
- .map(response => response)
- .subscribe(data => {
- resolve(data);
- }, // put the data returned from the server in our variable
- error => {
- console.log("Error Logout"); // in case of failure show this message
- reject("Error Logout");
- },
- () => console.log("Logging out"));//run this code in all cases); */
+ .map(response => response)
+ .subscribe(data => {
+ resolve(data);
+ }, // put the data returned from the server in our variable
+ error => {
+ console.log("Error Logout"); // in case of failure show this message
+ reject("Error Logout");
+ },
+ () => console.log("Logging out"));//run this code in all cases); */
});
}
@@ -460,111 +460,106 @@ export class HelperDataService implements OnInit, OnDestroy{
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
- "id": ""
+ "id": ""
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
- return this.http.get(`${AppSettings.API_ENDPOINT}/epal/subapplic`, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/subapplic`, options)
.map(response => response.json());
}
- getStudentDetails(headerid)
- {
- let headerIdNew = headerid.toString();
- this.loginInfo$.getValue().forEach(loginInfoToken => {
+ getStudentDetails(headerid) {
+ let headerIdNew = headerid.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);
+ });
+ 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/student/`+headerIdNew, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/student/` + headerIdNew, options)
.map(response => response.json());
- }
+ }
- getEpalchosen(headerid)
- {
- let headerIdNew = headerid.toString();
- this.loginInfo$.getValue().forEach(loginInfoToken => {
+ getEpalchosen(headerid) {
+ let headerIdNew = headerid.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);
+ });
+ 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/epalchosen/`+headerIdNew, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/epalchosen/` + headerIdNew, options)
.map(response => response.json());
- }
+ }
- getSectorPerSchool(SchoolId)
- {
- let SchoolIdNew = SchoolId.toString();
- this.loginInfo$.getValue().forEach(loginInfoToken => {
+ getSectorPerSchool(SchoolId) {
+ let SchoolIdNew = SchoolId.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);
+ });
+ 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/sectorperSchool/`+SchoolIdNew, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/sectorperSchool/` + SchoolIdNew, options)
.map(response => response.json());
- }
+ }
- getSpecialityPerSchool(SchoolId, SectorId)
- {
- let SchoolIdNew = SchoolId.toString();
- let SectorIdNew = SectorId.toString();
- this.loginInfo$.getValue().forEach(loginInfoToken => {
+ getSpecialityPerSchool(SchoolId, SectorId) {
+ let SchoolIdNew = SchoolId.toString();
+ let SectorIdNew = SectorId.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);
+ });
+ 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/specialityperSchool/`+SchoolIdNew+'/'+SectorIdNew, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/specialityperSchool/` + SchoolIdNew + '/' + SectorIdNew, options)
.map(response => response.json());
- }
+ }
- getStudentPerSchool(SchoolId, SelectId, classId)
- {
- let SchoolIdNew = SchoolId.toString();
- let SelectIdNew = SelectId.toString();
+ getStudentPerSchool(SchoolId, SelectId, classId) {
+ let SchoolIdNew = SchoolId.toString();
+ let SelectIdNew = SelectId.toString();
- this.loginInfo$.getValue().forEach(loginInfoToken => {
+ 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);
+ });
+ console.log("authToken=" + this.authToken);
+ console.log("authRole=" + this.authRole);
let headers = new Headers({
@@ -572,69 +567,67 @@ export class HelperDataService implements OnInit, OnDestroy{
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
- return this.http.get(`${AppSettings.API_ENDPOINT}/epal/studentperSchool/`+SchoolIdNew+'/'+SelectIdNew+'/'+classId, options )
+ return this.http.get(`${AppSettings.API_ENDPOINT}/epal/studentperSchool/` + SchoolIdNew + '/' + SelectIdNew + '/' + classId, options)
.map(response => response.json());
- }
+ }
- saveConfirmStudents(students)
- {
- console.log(students,"hds");
+ saveConfirmStudents(students) {
+ console.log(students, "hds");
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
+ "Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
- this.http.post(`${AppSettings.API_ENDPOINT}/epal/confirmstudent`, {students}, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- },
- error => {
- console.log("Error Saving Profile");
- reject("Error Saving Profile");
- },
- () => console.log("Saving Profile"));
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/confirmstudent`, { students }, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ },
+ error => {
+ console.log("Error Saving Profile");
+ reject("Error Saving Profile");
+ },
+ () => console.log("Saving Profile"));
});
}
- saveCapacity(taxi,tomeas, specialit, capacity, schoolid)
- {
+ saveCapacity(taxi, tomeas, specialit, capacity, schoolid) {
- console.log(taxi, capacity,"hds");
+ console.log(taxi, capacity, "hds");
this.loginInfo$.getValue().forEach(loginInfoToken => {
- this.authToken = loginInfoToken.auth_token;
- this.authRole = loginInfoToken.auth_role;
+ 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",
+ "Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
- this.http.post(`${AppSettings.API_ENDPOINT}/epal/savecapacity/`+taxi+'/'+tomeas+'/'+specialit+'/'+schoolid, {capacity}, options)
- .map(response => response.json())
- .subscribe(data => {
- resolve(data);
- },
- error => {
- console.log("Error Saving Capacity");
- reject("Error Saving Capacity");
- },
- () => console.log("Saving Capacity"));
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/savecapacity/` + taxi + '/' + tomeas + '/' + specialit + '/' + schoolid, { capacity }, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ },
+ error => {
+ console.log("Error Saving Capacity");
+ reject("Error Saving Capacity");
+ },
+ () => console.log("Saving Capacity"));
});
}