Commit ebfb4503 authored by Open Source Developer's avatar Open Source Developer

trans

parents a18ff2f1 63e47e3a
......@@ -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,
......
......@@ -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'
......@@ -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;
}
}
}
......
......@@ -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);
......
export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
export class AppSettings {
public static get API_ENDPOINT(): string {
......
......@@ -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 {}
......
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: `
<ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id ">
<h5> {{SchoolNames$.name}}</h5>
</li>
</div>
</ul>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" >
<i class="fa fa-forward"></i>
</button>
</div>
`
})
@Injectable() export default class PerfectureView implements OnInit, OnDestroy {
public formGroup: FormGroup;
private SchoolsPerPerf$: BehaviorSubject<any>;
private SchoolPerPerfSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
private StudentsSizeSub: Subscription;
public perfecture = 1;
private regionActive = <number>-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;
}
}
......@@ -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;
}, {});
}
......
......@@ -176,6 +176,11 @@
background-color: #fd9665;
}
.changecolor
{
background-color: cyan;
}
.roundedNumber{
width: 2em;
background-color: coral;
......
......@@ -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,
];
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;});
}
}
......@@ -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);
}
......
......@@ -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());
}
}
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