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

regionview

parent 3b25e4a0
...@@ -171,16 +171,4 @@ coursesperschools: ...@@ -171,16 +171,4 @@ coursesperschools:
defaults: defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool' _controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
limitpercateg: \ No newline at end of file
path: '/epal/LimitPerCateg/{categ}/{classId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getLimitPerCateg'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
...@@ -415,10 +415,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -415,10 +415,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
if ($schools) if ($schools)
{ {
$list = array(); $list = array();
foreach ($schools as $object) { foreach ($schools as $object) {
$status = $this->returnstatus(147);
$list[] = array( $list[] = array(
'id' =>$object -> id(), 'id' =>$object -> id(),
'name' => $object -> name ->value, 'name' => $object -> name ->value,
'status' => $status
); );
$i++; $i++;
...@@ -446,6 +449,9 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -446,6 +449,9 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
} }
public function getCoursesPerSchool(Request $request, $schoolid) public function getCoursesPerSchool(Request $request, $schoolid)
{ {
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
...@@ -465,7 +471,12 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -465,7 +471,12 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
if ($CourseA) if ($CourseA)
{ {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 1, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => -1, 'currentclass' => 1 )); $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => -1, 'currentclass' => 1 ));
$list = array(); $list = array();
foreach ($CourseA as $object) { foreach ($CourseA as $object) {
...@@ -474,7 +485,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -474,7 +485,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
'name' => 'Α Λυκείου', 'name' => 'Α Λυκείου',
'size' => sizeof($studentPerSchool), 'size' => sizeof($studentPerSchool),
'categ' => $categ, 'categ' => $categ,
'classes' => 1 'classes' => 1,
'limitdown' => $limit,
); );
} } } }
...@@ -483,6 +495,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -483,6 +495,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid )); $CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseB) if ($CourseB)
{ {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 2, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseB as $object) { foreach ($CourseB as $object) {
$sectorid = $object -> sector_id -> entity -> id(); $sectorid = $object -> sector_id -> entity -> id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $sectorid, 'currentclass' => 2 )); $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $sectorid, 'currentclass' => 2 ));
...@@ -491,7 +510,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -491,7 +510,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
'name' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value, 'name' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value,
'size' => sizeof($studentPerSchool), 'size' => sizeof($studentPerSchool),
'categ' => $categ, 'categ' => $categ,
'classes' => 2 'classes' => 2,
'limitdown' => $limit,
); );
} }
...@@ -499,6 +519,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -499,6 +519,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid )); $CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseC) if ($CourseC)
{ {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 3, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseC as $object) { foreach ($CourseC as $object) {
$specialityid = $object -> specialty_id -> entity -> id() ; $specialityid = $object -> specialty_id -> entity -> id() ;
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 3 )); $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 3 ));
...@@ -508,7 +535,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -508,7 +535,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
'name' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value, 'name' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'size' => sizeof($studentPerSchool), 'size' => sizeof($studentPerSchool),
'categ' => $categ, 'categ' => $categ,
'classes' => 3 'classes' => 3,
'limitdown' => $limit,
); );
} }
...@@ -538,47 +566,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid ...@@ -538,47 +566,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
} }
public function getLimitPerCateg(Request $request, $categ, $classId) public function returnstatus($id)
{ {
if ($id == 147)
$authToken = $request->headers->get('PHP_AUTH_USER'); return true ;
return false;
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users); }
if ($user)
{
$schools = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> $classId, 'category' => $categ ));
if ($schools)
{
$list = array();
foreach ($schools as $object) {
$list[] = array(
'limit_down' => $object -> limit_down ->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);
}
}
private function respondWithStatus($arr, $s) { private function respondWithStatus($arr, $s) {
......
export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
export class AppSettings {
public static get API_ENDPOINT(): string {
return 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
}
}
...@@ -20,18 +20,18 @@ import { ...@@ -20,18 +20,18 @@ import {
@Component({ @Component({
selector: 'perfecture-view', selector: 'perfecture-view',
template: ` template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<ul class="list-group main-view"> <ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" > <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 "> <li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === true" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<h5> {{SchoolNames$.name}}</h5> <h5> {{SchoolNames$.name}}</h5>
</li> </li>
<div *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)" [hidden]="SchoolNames$.id !== regionActive" >
<div> {{CoursesNames$.name}}</div> <div class= "aastyle"><strong>Αριθμός Μαθητών:</strong>{{CoursesNames$.size}} </div>
<div *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.id,CoursesNames$.categ,CoursesNames$.classes)" [hidden]="SchoolNames$.id !== regionActive" >
<div> {{CoursesNames$.name}} </div>
</div> </div>
</div>
</div>
</ul> </ul>
...@@ -121,25 +121,13 @@ import { ...@@ -121,25 +121,13 @@ import {
} }
calccolor(size, limit)
calccolor(id, categ, classes)
{ {
this.LimitPerCategSub = this._hds.getLimitPerCateg(categ, classes).subscribe(data => { if (size < limit)
this.LimitPerCateg$.next(data);
},
error => {
this.LimitPerCateg$.next([{}]);
console.log("Error Getting Limits");
},
() => console.log("Getting Limits"));
var newid = +id;
if (newid <= 5)
return true; return true;
else else
return false; return false;
} }
} }
...@@ -77,7 +77,7 @@ export default class SchoolHome implements OnInit { ...@@ -77,7 +77,7 @@ export default class SchoolHome implements OnInit {
if (this.authToken && this.authToken.length > 0) if (this.authToken && this.authToken.length > 0)
if (this.authRole = 'director') if (this.authRole = 'director')
this.router.navigate(['/school/director-view']); this.router.navigate(['/school/director-view']);
if (this.authRole = 'dide') if (this.authRole = 'pde')
this.router.navigate(['/school/perfecture-view']); this.router.navigate(['/school/perfecture-view']);
return loginInfoToken; return loginInfoToken;
}, {}); }, {});
......
...@@ -178,7 +178,16 @@ ...@@ -178,7 +178,16 @@
.changecolor .changecolor
{ {
background-color: cyan; color: red;
}
.changelistcolor
{
color:red!important ;
}
.aastyle{
color:black!important ;
} }
.roundedNumber{ .roundedNumber{
......
import { Injectable } from '@angular/core'; 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 { DIDE_ROLE } from '../constants'; import { PDE_ROLE } from '../constants';
@Injectable() @Injectable()
export default class RegionEduAuthGuard implements CanActivate { export default class RegionEduAuthGuard implements CanActivate {
...@@ -9,6 +9,6 @@ export default class RegionEduAuthGuard implements CanActivate { ...@@ -9,6 +9,6 @@ export default class RegionEduAuthGuard implements CanActivate {
constructor(private authService: AuthService) {} constructor(private authService: AuthService) {}
canActivate() { canActivate() {
return this.authService.isLoggedIn(DIDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;}); return this.authService.isLoggedIn(PDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;});
} }
} }
...@@ -725,28 +725,6 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -725,28 +725,6 @@ export class HelperDataService implements OnInit, OnDestroy {
} }
getLimitPerCateg(categ, classes){
console.log(categ,classes,"aaaa");
// let classesNew = classes.toString();
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
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/LimitPerCateg/` + categ + classes , 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