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

regionview

parent 3b25e4a0
......@@ -172,15 +172,3 @@ coursesperschools:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
limitpercateg:
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
if ($schools)
{
$list = array();
foreach ($schools as $object) {
$status = $this->returnstatus(147);
$list[] = array(
'id' =>$object -> id(),
'name' => $object -> name ->value,
'status' => $status
);
$i++;
......@@ -446,6 +449,9 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
public function getCoursesPerSchool(Request $request, $schoolid)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -465,7 +471,12 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
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 ));
$list = array();
foreach ($CourseA as $object) {
......@@ -474,7 +485,8 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
'name' => 'Α Λυκείου',
'size' => sizeof($studentPerSchool),
'categ' => $categ,
'classes' => 1
'classes' => 1,
'limitdown' => $limit,
);
} }
......@@ -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 ));
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) {
$sectorid = $object -> sector_id -> entity -> id();
$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
'name' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value,
'size' => sizeof($studentPerSchool),
'categ' => $categ,
'classes' => 2
'classes' => 2,
'limitdown' => $limit,
);
}
......@@ -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 ));
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) {
$specialityid = $object -> specialty_id -> entity -> id() ;
$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
'name' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'size' => sizeof($studentPerSchool),
'categ' => $categ,
'classes' => 3
'classes' => 3,
'limitdown' => $limit,
);
}
......@@ -538,47 +566,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
public function getLimitPerCateg(Request $request, $categ, $classId)
{
$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('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);
}
public function returnstatus($id)
{
if ($id == 147)
return true ;
return false;
}
}
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,17 +20,17 @@ import {
@Component({
selector: 'perfecture-view',
template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<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 ">
<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>
</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>
</ul>
......@@ -121,25 +121,13 @@ import {
}
calccolor(id, categ, classes)
calccolor(size, limit)
{
this.LimitPerCategSub = this._hds.getLimitPerCateg(categ, classes).subscribe(data => {
this.LimitPerCateg$.next(data);
},
error => {
this.LimitPerCateg$.next([{}]);
console.log("Error Getting Limits");
},
() => console.log("Getting Limits"));
var newid = +id;
if (newid <= 5)
if (size < limit)
return true;
else
return false;
}
}
......@@ -77,7 +77,7 @@ export default class SchoolHome implements OnInit {
if (this.authToken && this.authToken.length > 0)
if (this.authRole = 'director')
this.router.navigate(['/school/director-view']);
if (this.authRole = 'dide')
if (this.authRole = 'pde')
this.router.navigate(['/school/perfecture-view']);
return loginInfoToken;
}, {});
......
......@@ -178,7 +178,16 @@
.changecolor
{
background-color: cyan;
color: red;
}
.changelistcolor
{
color:red!important ;
}
.aastyle{
color:black!important ;
}
.roundedNumber{
......
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { DIDE_ROLE } from '../constants';
import { PDE_ROLE } from '../constants';
@Injectable()
export default class RegionEduAuthGuard implements CanActivate {
......@@ -9,6 +9,6 @@ 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;});
return this.authService.isLoggedIn(PDE_ROLE).then(loggedIn => {return loggedIn;}).catch(err => {return false;});
}
}
......@@ -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