diff --git a/drupal/modules/casost/src/Controller/CASLogin.php b/drupal/modules/casost/src/Controller/CASLogin.php index 8d9b89d7b9e46b546f9bff1ef6bc7cdf42d596d1..5d932541201050b6fb6b1b7ef1e95da60ecc140d 100755 --- a/drupal/modules/casost/src/Controller/CASLogin.php +++ b/drupal/modules/casost/src/Controller/CASLogin.php @@ -93,7 +93,7 @@ class CASLogin extends ControllerBase } phpCAS::setDebug("/home/haris/devel/eepal/drupal/modules/casost/phpcas.log"); // Enable verbose error messages. Disable in production! -// phpCAS::setVerbose(true); + //phpCAS::setVerbose(true); phpCAS::client($this->serverVersion, $this->serverHostname, diff --git a/drupal/modules/epal/epal.routing.yml b/drupal/modules/epal/epal.routing.yml index cc8244e23cb9228a8de96a64ec2dd4676c337765..3a18abc4245f7182f8f30700cde8484c8de6b28c 100755 --- a/drupal/modules/epal/epal.routing.yml +++ b/drupal/modules/epal/epal.routing.yml @@ -156,3 +156,22 @@ epal.ministry.report1: _controller: '\Drupal\epal\Controller\ReportsCreator::makeReportCompleteness' requirements: _user_is_logged_in: 'TRUE' +regionview: + path: '/epal/ScoolperPerf/{perfectureId}' + options: + _auth: [ 'basic_auth' ] + defaults: + _controller: '\Drupal\epal\Controller\DirectorView::getSchoolsPerPerfetcure' + requirements: + _user_is_logged_in: 'TRUE' +coursesperschools: + path: '/epal/CoursesperSch/{schoolid}' + options: + _auth: [ 'basic_auth' ] + defaults: + _controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool' + requirements: + _user_is_logged_in: 'TRUE' + + + diff --git a/drupal/modules/epal/src/Controller/CurrentUser.php b/drupal/modules/epal/src/Controller/CurrentUser.php index 1289ca109f1ce6c60fbba9c3c2113f2d47091c15..14884396aa7f92e28d3dfc8dc860ba63a1a280da 100755 --- a/drupal/modules/epal/src/Controller/CurrentUser.php +++ b/drupal/modules/epal/src/Controller/CurrentUser.php @@ -34,7 +34,7 @@ class CurrentUser extends ControllerBase $container->get('entity_type.manager'), $container->get('database'), $container->get('logger.factory') - ); + ); } public function getLoginInfo(Request $request) @@ -51,14 +51,14 @@ class CurrentUser extends ControllerBase $userRoles = $user->getRoles(); foreach ($userRoles as $userRole) { - if ($userRole === 'epal') { + if (($userRole === 'epal') || ($userRole === 'regioneduadmin') || ($userRole === 'eduadmin')) { return $this->respondWithStatus([ 'name' => $user->mail->value, 'title' => $user->init->value, ], Response::HTTP_OK); } else if ($userRole === 'applicant') { break; - } + } } diff --git a/drupal/modules/epal/src/Controller/DirectorView.php b/drupal/modules/epal/src/Controller/DirectorView.php index 74d6d1f852f47f1f6cf8b87e6b7fc03dc172d248..832509f8d7caa49bb32c81d137af157cde944063 100755 --- a/drupal/modules/epal/src/Controller/DirectorView.php +++ b/drupal/modules/epal/src/Controller/DirectorView.php @@ -402,6 +402,126 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid + public function getSchoolsPerPerfetcure(Request $request, $perfectureId) + { + + $authToken = $request->headers->get('PHP_AUTH_USER'); + + $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); + $user = reset($users); + if ($user) + { + $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('region_edu_admin_id'=> $perfectureId )); + if ($schools) + { + $list = array(); + foreach ($schools as $object) { + $list[] = array( + 'id' =>$object -> id(), + 'name' => $object -> name ->value, + ); + + $i++; + } + return $this->respondWithStatus( + $list + , Response::HTTP_OK); + } + else + { + return $this->respondWithStatus([ + 'message' => t("Perfecture not found!"), + ], Response::HTTP_FORBIDDEN); + + } + } + else + { + + return $this->respondWithStatus([ + 'message' => t("User not found!"), + ], Response::HTTP_FORBIDDEN); + } + + } + + + public function getCoursesPerSchool(Request $request, $schoolid) + { + $authToken = $request->headers->get('PHP_AUTH_USER'); + + $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); + $user = reset($users); + if ($user) + { + $list= array(); + + + + $CourseA = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid )); + + if ($CourseA) + { + $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id'=> $schoolid, 'specialization_id' => -1, 'currentclass' => 1 )); + $list = array(); + foreach ($CourseA as $object) { + $list[] = array( + + 'name' => 'Α Λυκείου', + 'id' => sizeof($studentPerSchool), + ); + + + } } + + + + + $CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid )); + if ($CourseB) + { + foreach ($CourseB as $object) { + $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id'=> $schoolid, 'specialization_id' => 9, 'currentclass' => 2 )); + $list[] = array( + 'name' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value, + 'id' => sizeof($studentPerSchool), + + ); + } + } + $CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid )); + if ($CourseC) + { + foreach ($CourseC as $object) { + $list[] = array( + 'name' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value, + + ); + } + } + if ($CourseA || $CourseB || $CourseC){ + + return $this->respondWithStatus( + $list + , Response::HTTP_OK); + } + else + { + return $this->respondWithStatus([ + 'message' => t("Perfecture not found!"), + ], Response::HTTP_FORBIDDEN); + + } + } + else + { + + return $this->respondWithStatus([ + 'message' => t("User not found!"), + ], Response::HTTP_FORBIDDEN); + } + } + private function respondWithStatus($arr, $s) { $res = new JsonResponse($arr); $res->setStatusCode($s); diff --git a/source/app.settings.ts b/source/app.settings.ts index 50e3dd269356888bdcfed5836711540b794e2208..bf1ae4b75abd121a1846f39ce71109a2e59a73e3 100644 --- a/source/app.settings.ts +++ b/source/app.settings.ts @@ -1,3 +1,4 @@ + export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal'; export class AppSettings { public static get API_ENDPOINT(): string { diff --git a/source/app.ts b/source/app.ts index f30c3b5b86779f024d315fdc92819acdc47272a0..66620a91f1c1956877380252bf434e3d771e0372 100644 --- a/source/app.ts +++ b/source/app.ts @@ -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 {} diff --git a/source/components/infoviews/perfecture-view.ts b/source/components/infoviews/perfecture-view.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9de8ac49a406401f4b3334ac44d563ee01afd8f --- /dev/null +++ b/source/components/infoviews/perfecture-view.ts @@ -0,0 +1,113 @@ +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'; +import {Observable} from "rxjs/Observable"; +import {Http, Headers, RequestOptions} from '@angular/http'; +import { NgRedux, select } from 'ng2-redux'; +import { IAppState } from '../../store/store'; +import {Router, ActivatedRoute, Params} from '@angular/router'; +import { BehaviorSubject, Subscription } from 'rxjs/Rx'; +import { ILoginInfo } from '../../store/logininfo/logininfo.types'; + +import { + FormBuilder, + FormGroup, + FormControl, + FormArray, + Validators, +} from '@angular/forms'; +@Component({ + selector: 'perfecture-view', + template: ` + + + +
+ +
+ + + ` +}) + +@Injectable() export default class PerfectureView implements OnInit, OnDestroy { + + public formGroup: FormGroup; + private SchoolsPerPerf$: BehaviorSubject; + private SchoolPerPerfSub: Subscription; + private StudentsSize$: BehaviorSubject; + private StudentsSizeSub: Subscription; + public perfecture = 1; + private regionActive = -1; + + + constructor(private fb: FormBuilder, + private router: Router, + private _hds: HelperDataService, + ) { + this.SchoolsPerPerf$ = new BehaviorSubject([{}]); + this.StudentsSize$ = new BehaviorSubject({}); + this.formGroup = this.fb.group({ + }); + + } + + ngOnDestroy() { + } + + ngOnInit() { + + + this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(147).subscribe(data => { + this.SchoolsPerPerf$.next(data); + }, + error => { + this.SchoolsPerPerf$.next([{}]); + console.log("Error Getting Schools"); + }, + () => console.log("Getting Schools")); + + + + } + + + setActiveRegion(ind) { + console.log(ind,"ind"); + if (ind === this.regionActive) + ind = -1; + this.regionActive = ind; + } + + + navigateToApplication() + { + + var id: string= String(this.regionActive); + this.router.navigate(['', {ids:id}]); + + } + + + calccolor(id) + { + var newid = +id; + // this.StudentsSizeSub = this._hds.getStudentPerSchool(147, 1, 2, 0, 0).subscribe(this.StudentsSize$); + + if (id == 147) + return true; + if (id == 150) + return true; + + } + +} diff --git a/source/components/school.home.ts b/source/components/school.home.ts index 41e50f633870b2d6244ff6b038c6839144d65de7..f9eca680b124530745499696878efd47f40c4b62 100644 --- a/source/components/school.home.ts +++ b/source/components/school.home.ts @@ -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 = 'dide') + this.router.navigate(['/school/perfecture-view']); return loginInfoToken; }, {}); } diff --git a/source/containers/globalstyles.css b/source/containers/globalstyles.css index 63a7ec8c2b6226590d6285ca3f8b6273332c2e4d..2e544db4bc14631533ffc15fd970957d5c355a11 100644 --- a/source/containers/globalstyles.css +++ b/source/containers/globalstyles.css @@ -176,6 +176,11 @@ background-color: #fd9665; } +.changecolor +{ + background-color: cyan; +} + .roundedNumber{ width: 2em; background-color: coral; diff --git a/source/containers/main.routes.ts b/source/containers/main.routes.ts index 173b252bdb6e402e37ee5a87a0e304bfa98a1bc8..d58b4480c53995a1abbe6b33862ca8ed9b07801a 100644 --- a/source/containers/main.routes.ts +++ b/source/containers/main.routes.ts @@ -22,12 +22,14 @@ 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 InformStudents from '../components/minister/minister-informstudents'; 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 }, @@ -51,6 +53,7 @@ export const MainRoutes: Routes = [ { path: 'ministry/minister-view', component: MinisterView }, { path: 'ministry/minister-reports', component: MinisterReports }, { path: 'ministry/minister-informstudents', component: InformStudents }, + { path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] }, ]; export const MainDeclarations = [ @@ -76,5 +79,6 @@ export const MainDeclarations = [ DirectorClassCapacity, MinisterView, MinisterReports, - InformStudents + InformStudents, + PerfectureView, ]; diff --git a/source/guards/regionedu.auth.guard.ts b/source/guards/regionedu.auth.guard.ts new file mode 100644 index 0000000000000000000000000000000000000000..e90f00ec35a644624f0451ddc0c9e46be51feab8 --- /dev/null +++ b/source/guards/regionedu.auth.guard.ts @@ -0,0 +1,14 @@ +import { Injectable } from '@angular/core'; +import { CanActivate } from '@angular/router'; +import { AuthService } from '../services/auth.service'; +import { DIDE_ROLE } from '../constants'; + +@Injectable() +export default class RegionEduAuthGuard implements CanActivate { + + constructor(private authService: AuthService) {} + + canActivate() { + return this.authService.isLoggedIn(DIDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;}); + } +} diff --git a/source/services/auth.service.ts b/source/services/auth.service.ts index 646501d0ba1f76de603df6b869108d81667b85b7..6703c154616cab80c7103da809ffd90b6688a6c2 100644 --- a/source/services/auth.service.ts +++ b/source/services/auth.service.ts @@ -22,6 +22,7 @@ export class AuthService { }).subscribe(loginInfo => { if (loginInfo.size > 0) { loginInfo.reduce(({}, loginInfoToken) => { + console.log(loginInfoToken.auth_role,"aaaaaaa"); if (loginInfoToken.auth_token && loginInfoToken.auth_token.length > 0 && loginInfoToken.auth_role === role) { resolve(true); } diff --git a/source/services/helper-data-service.ts b/source/services/helper-data-service.ts index 3de2cb636c9890b992f3e3a38c32a1e0f5a82934..de6d01fc0fb3cf2a7ec512e0902e5c932ea7fd85 100644 --- a/source/services/helper-data-service.ts +++ b/source/services/helper-data-service.ts @@ -680,6 +680,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/CoursesperSch/` + PerfectureIdNew , options) + .map(response => response.json()); + } + + + + }