Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
2679ba6d
Commit
2679ba6d
authored
Jun 01, 2017
by
Open Source Developer
Browse files
capacities view
parent
a0e66629
Changes
4
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
2679ba6d
...
...
@@ -79,7 +79,7 @@ epal.allocation:
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.sectorperschool
:
path
:
'
/epal/sectorper
S
chool'
path
:
'
/epal/sectorper
s
chool'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -87,7 +87,7 @@ epal.sectorperschool:
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.specialityperschool
:
path
:
'
/epal/specialityper
S
chool/{sectorId}'
path
:
'
/epal/specialityper
s
chool/{sectorId}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -103,7 +103,7 @@ epal.confirmstudents:
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.studentperschool
:
path
:
'
/epal/studentper
S
chool/{selectId}/{classId}/{limitdown}/{limitup}'
path
:
'
/epal/studentper
s
chool/{selectId}/{classId}/{limitdown}/{limitup}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -215,7 +215,7 @@ epal.perfectureschools:
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.coursesperschools
:
path
:
'
/epal/
C
oursesper
S
ch/{schoolid}'
path
:
'
/epal/
c
oursesper
s
ch/{schoolid}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -231,7 +231,7 @@ epal.critirioschosen:
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.findcapacity
:
path
:
'
/epal/find
C
apacity/{taxi}/{tomeas}/{specialit}'
path
:
'
/epal/find
c
apacity/{taxi}/{tomeas}/{specialit}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -254,11 +254,19 @@ epal.gettypeofschool:
_controller
:
'
\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements
:
_user_is_logged_in
:
'
TRUE'
getlimitspercourse
:
path
:
'
/epal/getlimitsper
C
ourse/{classid}'
epal.
getlimitspercourse
:
path
:
'
/epal/getlimitsper
c
ourse/{classid}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\DirectorView::getlimitsperCourse'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.findcapacityperschool
:
path
:
'
/epal/findcapacityperschool'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/DirectorView.php
View file @
2679ba6d
...
...
@@ -499,9 +499,6 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
}
public
function
getCoursesPerSchool
(
Request
$request
,
$schoolid
)
{
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
...
...
@@ -509,13 +506,31 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
$users
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$authToken
));
$user
=
reset
(
$users
);
if
(
$user
)
{
{
$newid
=
$user
->
init
->
value
;
$userRoles
=
$user
->
getRoles
();
$userRole
=
''
;
foreach
(
$userRoles
as
$tmpRole
)
{
if
((
$tmpRole
===
'regioneduadmin'
)
||
(
$tmpRole
===
'eduadmin'
))
{
$userRole
=
$tmpRole
;
}
}
if
(
$userRole
===
''
)
{
return
$this
->
respondWithStatus
([
'error_code'
=>
4003
,
],
Response
::
HTTP_FORBIDDEN
);
}
$list
=
array
();
else
if
(
$userRole
===
'regioneduadmin'
)
{
$SchoolCats
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
,
'region_edu_admin_id'
=>
$newid
));
}
else
if
(
$userRole
===
'eduadmin'
)
{
$SchoolCats
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
,
'edu_admin_id'
=>
$newid
));
}
$SchoolCats
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
$SchoolCat
=
reset
(
$SchoolCats
);
if
(
$SchoolCat
){
$list
=
array
();
$categ
=
$SchoolCat
->
metathesis_region
->
value
;
}
$CourseA
=
$this
->
entityTypeManager
->
getStorage
(
'epal_student'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
...
...
@@ -981,6 +996,110 @@ public function gettypeofschool(Request $request)
public
function
FindCapacityPerSchool
(
Request
$request
)
{
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$users
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$authToken
));
$user
=
reset
(
$users
);
if
(
$user
)
{
$schoolid
=
$user
->
init
->
value
;
$schools
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
$school
=
reset
(
$schools
);
if
(
!
$school
)
{
$this
->
logger
->
warning
(
"no access to this school="
.
$user
->
id
());
$response
=
new
Response
();
$response
->
setContent
(
'No access to this school'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
$list
=
array
();
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$list
[]
=
array
(
'class'
=>
1
,
'taxi'
=>
'Ά Λυκείου'
,
'capacity'
=>
$classcapacity
->
capacity_class_a
->
value
,
);
}
$CourseB
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_sectors_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
));
if
(
$CourseB
)
{
foreach
(
$CourseB
as
$object
)
{
$sectorid
=
$object
->
sector_id
->
entity
->
id
();
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_sectors_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'sector_id'
=>
$sectorid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$list
[]
=
array
(
'class'
=>
2
,
'taxi'
=>
'Β Λυκείου '
.
$object
->
sector_id
->
entity
->
get
(
'name'
)
->
value
,
'capacity'
=>
$classcapacity
->
capacity_class_sector
->
value
,
);
}
}
}
$CourseC
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
));
if
(
$CourseC
)
{
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
()
;
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialty_id'
=>
$specialityid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$list
[]
=
array
(
'class'
=>
3
,
'taxi'
=>
'Γ Λυκείου '
.
$object
->
specialty_id
->
entity
->
get
(
'name'
)
->
value
,
'capacity'
=>
$classcapacity
->
capacity_class_specialty
->
value
,
);
}
}
}
if
(
$CourseC
)
{
foreach
(
$CourseC
as
$object
)
{
$specialityid
=
$object
->
specialty_id
->
entity
->
id
()
;
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialty_id'
=>
$specialityid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$list
[]
=
array
(
'class'
=>
4
,
'taxi'
=>
'Δ Λυκείου '
.
$object
->
specialty_id
->
entity
->
get
(
'name'
)
->
value
,
'capacity'
=>
$classcapacity
->
capacity_class_specialty_d
->
value
,
);
}
}
}
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EPAL user not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
...
...
source/components/director/director-classcapacity.ts
View file @
2679ba6d
...
...
@@ -17,13 +17,14 @@ import {minValue} from '../../constants';
import
{
FormBuilder
,
FormGroup
,
FormControl
,
FormControl
,
FormArray
,
Validators
,
}
from
'
@angular/forms
'
;
@
Component
({
selector
:
'
director-classcapacity
'
,
template
:
`
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
...
...
@@ -68,8 +69,21 @@ import {
Αποθήκευση
</button>
</form>
<br>
<br>
<div class="row"> <b>Οι δηλώσεις σας </b></div>
<div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li *ngIf="(CapacityPerCourses$.class != 4)" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" >
<h5 >{{CapacityPerCourses$.taxi}} {{CapacityPerCourses$.capacity}} </h5>
</li>
</div>
</div>
<div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
...
...
@@ -131,6 +145,8 @@ import {
private
selectionCClass
:
BehaviorSubject
<
boolean
>
;
private
School$
:
BehaviorSubject
<
any
>
;
private
SchoolSub
:
Subscription
;
private
CapacityPerCourse$
:
BehaviorSubject
<
any
>
;
private
CapacityPerCourseSub
:
Subscription
;
private
SchoolId
;
private
currentclass
:
Number
;
private
classCapacity$
:
BehaviorSubject
<
any
>
;
...
...
@@ -139,6 +155,7 @@ import {
private
modalTitle
:
BehaviorSubject
<
string
>
;
private
modalText
:
BehaviorSubject
<
string
>
;
private
modalHeader
:
BehaviorSubject
<
string
>
;
private
showLoader
:
BehaviorSubject
<
boolean
>
;
...
...
@@ -150,6 +167,7 @@ import {
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
classCapacity$
=
new
BehaviorSubject
([{}]);
this
.
CapacityPerCourse$
=
new
BehaviorSubject
([{}]);
this
.
selectionBClass
=
new
BehaviorSubject
(
false
);
this
.
selectiontype
=
new
BehaviorSubject
(
true
);
this
.
selectionCClass
=
new
BehaviorSubject
(
false
);
...
...
@@ -158,6 +176,7 @@ import {
this
.
modalTitle
=
new
BehaviorSubject
(
""
);
this
.
modalText
=
new
BehaviorSubject
(
""
);
this
.
modalHeader
=
new
BehaviorSubject
(
""
);
this
.
showLoader
=
new
BehaviorSubject
(
false
);
this
.
formGroup
=
this
.
fb
.
group
({
tomeas
:
[
''
,
[]],
taxi
:
[
''
,
[]],
...
...
@@ -205,8 +224,9 @@ import {
(
<
any
>
$
(
'
#capacitysaved
'
)).
appendTo
(
"
body
"
);
(
<
any
>
$
(
'
#checksaved
'
)).
appendTo
(
"
body
"
);
this
.
retrievedStudent
.
next
(
false
);
this
.
SchoolSub
=
this
.
_hds
.
gettypeofschool
().
subscribe
(
x
=>
{
this
.
SchoolSub
=
this
.
_hds
.
gettypeofschool
().
subscribe
(
x
=>
{
this
.
School$
.
next
(
x
);
console
.
log
(
x
[
0
].
type
,
"
schoolid!
"
);
this
.
SchoolId
=
x
[
0
].
type
;
...
...
@@ -221,6 +241,20 @@ import {
},
()
=>
console
.
log
(
"
Getting School
"
));
this
.
CapacityPerCourseSub
=
this
.
_hds
.
FindCapacityPerSchool
().
subscribe
(
x
=>
{
this
.
CapacityPerCourse$
.
next
(
x
);
},
error
=>
{
this
.
CapacityPerCourse$
.
next
([{}]);
console
.
log
(
"
Error Getting Capacity perSchool
"
);
},
()
=>
console
.
log
(
"
Getting School
"
));
}
...
...
@@ -235,7 +269,9 @@ import {
capacity
:
''
,
});
console
.
log
(
"
a class
"
);
this
.
showLoader
.
next
(
true
);
this
.
classCapacitySub
=
this
.
_hds
.
getCapacityPerSchool
(
this
.
formGroup
.
value
.
taxi
,
0
,
0
).
subscribe
(
data
=>
{
this
.
showLoader
.
next
(
false
);
this
.
classCapacity$
.
next
(
data
);
this
.
retrievedStudent
.
next
(
true
);
this
.
formGroup
.
patchValue
({
...
...
@@ -294,9 +330,11 @@ import {
console
.
log
(
tmop
,
txop
,
"
tomeas!!!!
"
);
if
(
txop
.
value
===
"
2
"
)
{
console
.
log
(
"
b class
"
);
this
.
showLoader
.
next
(
true
);
this
.
classCapacitySub
=
this
.
_hds
.
getCapacityPerSchool
(
this
.
formGroup
.
value
.
taxi
,
sectorint
,
0
).
subscribe
(
data
=>
{
this
.
classCapacity$
.
next
(
data
);
this
.
retrievedStudent
.
next
(
true
);
this
.
showLoader
.
next
(
false
);
this
.
formGroup
.
patchValue
({
capacity
:
data
[
0
].
capacity
,
});
...
...
@@ -324,10 +362,11 @@ import {
if
(
txop
.
value
===
"
3
"
||
txop
.
value
===
"
4
"
)
{
console
.
log
(
"
c class
"
);
console
.
log
(
sectorint
,
specialint
,
"
cclass
"
)
this
.
showLoader
.
next
(
true
);
this
.
classCapacitySub
=
this
.
_hds
.
getCapacityPerSchool
(
this
.
formGroup
.
value
.
taxi
,
sectorint
,
specialint
).
subscribe
(
data
=>
{
this
.
classCapacity$
.
next
(
data
);
this
.
retrievedStudent
.
next
(
true
);
this
.
showLoader
.
next
(
false
);
this
.
formGroup
.
patchValue
({
capacity
:
data
[
0
].
capacity
,
});
...
...
@@ -359,8 +398,9 @@ import {
this
.
showModal
(
"
#checksaved
"
);
}
else
{
this
.
showLoader
.
next
(
true
);
this
.
saveCapacitySub
=
this
.
_hds
.
saveCapacity
(
this
.
formGroup
.
value
.
taxi
,
tomeas
,
specialit
,
this
.
formGroup
.
value
.
capacity
).
subscribe
(
data
=>
{
this
.
showLoader
.
next
(
false
);
},
error
=>
{
...
...
@@ -370,10 +410,20 @@ import {
console
.
log
(
"
Saved Capacity
"
);
this
.
showModal
(
"
#capacitysaved
"
);
});
}
this
.
CapacityPerCourseSub
=
this
.
_hds
.
FindCapacityPerSchool
().
subscribe
(
x
=>
{
this
.
CapacityPerCourse$
.
next
(
x
);
},
error
=>
{
this
.
CapacityPerCourse$
.
next
([{}]);
console
.
log
(
"
Error Getting Capacity perSchool
"
);
},
()
=>
console
.
log
(
"
Getting School
"
));
}
}
}
...
...
source/services/helper-data-service.ts
View file @
2679ba6d
...
...
@@ -486,7 +486,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/sectorper
S
chool/`
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/sectorper
s
chool/`
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
@@ -503,7 +503,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/specialityper
S
chool/`
+
SectorIdNew
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/specialityper
s
chool/`
+
SectorIdNew
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
@@ -524,7 +524,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/studentper
S
chool/`
+
SelectIdNew
+
'
/
'
+
classId
+
'
/
'
+
limitdown
+
'
/
'
+
limitup
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/studentper
s
chool/`
+
SelectIdNew
+
'
/
'
+
classId
+
'
/
'
+
limitdown
+
'
/
'
+
limitup
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
@@ -689,7 +689,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/
C
oursesper
S
ch/`
+
PerfectureIdNew
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/
c
oursesper
s
ch/`
+
PerfectureIdNew
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
@@ -845,7 +845,7 @@ getCapacityPerSchool(taxi, tomeas, specialit) {
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/find
C
apacity/`
+
taxi
+
'
/
'
+
tomeas
+
'
/
'
+
specialit
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/find
c
apacity/`
+
taxi
+
'
/
'
+
tomeas
+
'
/
'
+
specialit
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
@@ -893,7 +893,24 @@ getlimitsofcourse(classid){
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/getlimitsperCourse/`
+
classid
,
options
)
return
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/getlimitspercourse/`
+
classid
,
options
)
.
map
(
response
=>
response
.
json
());
}
FindCapacityPerSchool
(){
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/findcapacityperschool/`
,
options
)
.
map
(
response
=>
response
.
json
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment