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
50b0ac48
Commit
50b0ac48
authored
Apr 07, 2017
by
Open Source Developer
Browse files
directorview
parent
265becb1
Changes
8
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
50b0ac48
...
...
@@ -114,5 +114,12 @@ studentperschool:
_controller
:
'
\Drupal\epal\Controller\DirectorView::getStudentPerSchool'
requirements
:
_user_is_logged_in
:
'
TRUE'
savecapacity
:
path
:
'
/epal/savecapacity/{taxi}/{tomeas}/{specialit}/{schoolid}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\DirectorView::SaveCapacity'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/DirectorView.php
View file @
50b0ac48
...
...
@@ -247,6 +247,90 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
public
function
SaveCapacity
(
Request
$request
,
$taxi
,
$tomeas
,
$specialit
,
$schoolid
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
if
(
$epalUser
)
{
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
$cap
=
$postData
->
capacity
;
if
((
$tomeas
==
0
)
||
(
$specialit
==
0
))
{
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_school'
)
->
loadByProperties
(
array
(
'id'
=>
$schoolid
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$classcapacity
->
set
(
'capacity_class_a'
,
$cap
);
$classcapacity
->
save
();
}
}
if
((
$tomeas
!=
0
)
||
(
$specialit
==
0
))
{
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_sectors_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'sector_id'
=>
$tomeas
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$classcapacity
->
set
(
'capacity_class_sector'
,
$cap
);
$classcapacity
->
save
();
}
}
if
((
$tomeas
!=
0
)
||
(
$specialit
!=
0
))
{
$CapacityPerClass
=
$this
->
entityTypeManager
->
getStorage
(
'eepal_specialties_in_epal'
)
->
loadByProperties
(
array
(
'epal_id'
=>
$schoolid
,
'specialty_id'
=>
$specialit
));
$classcapacity
=
reset
(
$CapacityPerClass
);
if
(
$classcapacity
)
{
$classcapacity
->
set
(
'capacity_class_specialty'
,
$cap
);
$classcapacity
->
save
();
}
}
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"saved"
),
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"post with no data"
),
],
Response
::
HTTP_BAD_REQUEST
);
}
}
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
);
...
...
drupal/modules/epalreadydata/src/Entity/EepalSchool.php
View file @
50b0ac48
...
...
@@ -356,7 +356,7 @@ class EepalSchool extends ContentEntityBase implements EepalSchoolInterface {
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'
e-
mail'
]
=
BaseFieldDefinition
::
create
(
'string'
)
$fields
[
'mail
e
'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'e-mail Σχολείου'
))
->
setDescription
(
t
(
'Δώσε το e-mail Σχολείου'
))
->
setSettings
(
array
(
...
...
source/components/director/director-classcapacity.ts
0 → 100644
View file @
50b0ac48
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
:
'
director-classcapacity
'
,
template
:
`
<form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
<div class="form-group">
<select #txoption class="form-control" (change)="verifyclass(txoption)" formControlName="taxi">
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
</select>
</div>
<div class="form-group">
<select #tmop class="form-control" *ngIf="(selectionBClass | async)" (change)="checkbclass(tmop,txoption)" formControlName="tomeas">
<option *ngFor="let SectorSelection$ of StudentSelected$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.sector_id}} </option>
</select>
</div>
<div class="form-group">
<select #spop class="form-control" *ngIf="(selectionCClass | async)" (change) ="checkcclass()" formControlName="specialit">
<option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
</select>
</div>
<strong>Δυναμική σε τμήματα:</strong>
<input type="number" formControlName="capacity" min="1" max="10">
<button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
Αποθήκευση
</button>
`
})
@
Injectable
()
export
default
class
DirectorClassCapacity
implements
OnInit
,
OnDestroy
{
public
formGroup
:
FormGroup
;
private
StudentSelected$
:
BehaviorSubject
<
any
>
;
private
StudentSelectedSub
:
Subscription
;
private
StudentSelectedSpecial$
:
BehaviorSubject
<
any
>
;
private
StudentSelectedSpecialSub
:
Subscription
;
private
selectionBClass
:
BehaviorSubject
<
boolean
>
;
private
selectionCClass
:
BehaviorSubject
<
boolean
>
;
private
SchoolId
=
147
;
private
currentclass
:
Number
;
constructor
(
private
fb
:
FormBuilder
,
private
_hds
:
HelperDataService
,
private
activatedRoute
:
ActivatedRoute
,
private
router
:
Router
)
{
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
selectionBClass
=
new
BehaviorSubject
(
false
);
this
.
selectionCClass
=
new
BehaviorSubject
(
false
);
this
.
formGroup
=
this
.
fb
.
group
({
tomeas
:
[
''
,
[]],
taxi
:
[
''
,
[]],
specialit
:
[
''
,
[]],
capacity
:
[
''
,
[]],
});
}
ngOnDestroy
()
{
if
(
this
.
StudentSelectedSub
)
this
.
StudentSelectedSub
.
unsubscribe
();
if
(
this
.
StudentSelectedSpecialSub
)
this
.
StudentSelectedSpecialSub
.
unsubscribe
();
if
(
this
.
selectionBClass
)
this
.
selectionBClass
.
unsubscribe
();
if
(
this
.
selectionCClass
)
this
.
selectionCClass
.
unsubscribe
();
}
ngOnInit
()
{
}
verifyclass
(
txop
)
{
if
(
txop
.
value
===
"
1
"
)
{
this
.
selectionBClass
.
next
(
false
);
this
.
selectionCClass
.
next
(
false
);
this
.
formGroup
.
patchValue
({
tomeas
:
''
,
specialit
:
''
,
});
}
else
if
(
txop
.
value
===
"
2
"
)
{
this
.
formGroup
.
patchValue
({
specialit
:
''
,
});
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
false
);
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSub
=
this
.
_hds
.
getSectorPerSchool
(
this
.
SchoolId
).
subscribe
(
this
.
StudentSelected$
);
}
else
if
(
txop
.
value
===
"
3
"
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
console
.
log
(
sectorint
,
"
test
"
);
if
(
this
.
formGroup
.
value
.
tomeas
!=
''
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
this
.
StudentSelectedSpecial$
);
}
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
true
);
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSub
=
this
.
_hds
.
getSectorPerSchool
(
this
.
SchoolId
).
subscribe
(
this
.
StudentSelected$
);
}
}
checkbclass
(
tmop
,
txop
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
console
.
log
(
sectorint
,
"
tomeas
"
);
if
(
txop
.
value
===
"
3
"
)
{
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
this
.
StudentSelectedSpecial$
);
}
}
saveCapacity
()
{
var
tomeas
=
+
this
.
formGroup
.
value
.
tomeas
;
var
specialit
=
+
this
.
formGroup
.
value
.
specialit
;
console
.
log
(
tomeas
,
specialit
);
this
.
_hds
.
saveCapacity
(
this
.
formGroup
.
value
.
taxi
,
tomeas
,
specialit
,
this
.
formGroup
.
value
.
capacity
,
this
.
SchoolId
);
}
}
\ No newline at end of file
source/components/director/director-view.ts
View file @
50b0ac48
...
...
@@ -45,6 +45,8 @@ import {
</button>
<div *ngIf="(retrievedStudent | async)">
<div *ngFor="let StudentDetails$ of StudentInfo$ | async">
<br>
<br>
Όνομα: {{StudentDetails$.name}} <br>
Επώνυμο: {{StudentDetails$.studentsurname}}<br>
Όνομα Πατέρα: {{StudentDetails$.fatherfirstname}}<br>
...
...
@@ -52,9 +54,10 @@ import {
Όνομα Μητέρας: {{StudentDetails$.motherfirstname}}<br>
Επώνυμο Μητέρας:{{StudentDetails$.mothersurname}}<br>
Ημερομηνία Γέννησης: {{StudentDetails$.birthdate}}<br>
<br>
<input #cb type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
<strong>Επιβεβαίωση Εγγραφής: </strong>
<input #cb class="pull-right" type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
</div>
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()">
...
...
@@ -109,6 +112,8 @@ import {
this
.
selectionBClass
.
unsubscribe
();
if
(
this
.
selectionCClass
)
this
.
selectionCClass
.
unsubscribe
();
if
(
this
.
retrievedStudent
)
this
.
retrievedStudent
.
unsubscribe
();
}
ngOnInit
()
{
...
...
@@ -134,6 +139,14 @@ import {
}
else
if
(
txop
.
value
===
"
3
"
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
console
.
log
(
sectorint
,
"
test
"
);
if
(
this
.
formGroup
.
value
.
tomeas
!=
''
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
this
.
StudentSelectedSpecial$
);
}
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
true
);
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
...
...
@@ -171,7 +184,7 @@ import {
this
.
currentclass
=
3
;
}
this
.
retrievedStudent
.
next
(
true
);
this
.
retrieved
Student
=
new
BehaviorSubject
(
false
);
this
.
Student
Info$
=
new
BehaviorSubject
(
false
);
this
.
StudentInfoSub
=
this
.
_hds
.
getStudentPerSchool
(
this
.
SchoolId
,
sectorint
,
this
.
currentclass
).
subscribe
(
this
.
StudentInfo$
);
...
...
source/components/navbar/navbar.component.html
View file @
50b0ac48
...
...
@@ -28,6 +28,10 @@
<a
class=
"nav-link"
[routerLink]=
"['/director-view']"
[routerLinkActive]=
"['active']"
><b>
Επιλεχθέντες Μαθητές
</b></a>
</div>
<div
class=
"pull-right"
class=
"nav-item"
[ngClass]=
"{active: path=='director-classcapacity'}"
>
<a
class=
"nav-link"
[routerLink]=
"['/director-classcapacity']"
[routerLinkActive]=
"['active']"
><b>
Δυναμική Σχολείου
</b></a>
</div>
</div>
...
...
source/containers/main.routes.ts
View file @
50b0ac48
...
...
@@ -20,6 +20,7 @@ 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
DirectorClassCapacity
from
'
../components/director/director-classcapacity
'
;
export
const
MainRoutes
:
Routes
=
[
{
path
:
''
,
component
:
Home
},
...
...
@@ -37,6 +38,7 @@ export const MainRoutes: Routes = [
{
path
:
'
submited-preview
'
,
component
:
SubmitedPreview
},
{
path
:
'
submited-person
'
,
component
:
SubmitedPerson
},
{
path
:
'
director-view
'
,
component
:
DirectorView
},
{
path
:
'
director-classcapacity
'
,
component
:
DirectorClassCapacity
},
];
export
const
MainDeclarations
=
[
...
...
@@ -56,5 +58,6 @@ export const MainDeclarations = [
ApplicationSubmit
,
SubmitedPreview
,
SubmitedPerson
,
DirectorView
DirectorView
,
DirectorClassCapacity
];
source/services/helper-data-service.ts
View file @
50b0ac48
...
...
@@ -537,4 +537,34 @@ export class HelperDataService {
saveCapacity
(
taxi
,
tomeas
,
specialit
,
capacity
,
schoolid
)
{
console
.
log
(
taxi
,
capacity
,
"
hds
"
);
this
.
loginInfo$
.
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
get
(
0
).
auth_token
;
});
let
headers
=
new
Headers
({
"
Content-Type
"
:
"
application/json
"
,
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/savecapacity/`
+
taxi
+
'
/
'
+
tomeas
+
'
/
'
+
specialit
+
'
/
'
+
schoolid
,
{
capacity
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
data
);
},
error
=>
{
console
.
log
(
"
Error Saving Capacity
"
);
reject
(
"
Error Saving Capacity
"
);
},
()
=>
console
.
log
(
"
Saving Capacity
"
));
});
}
}
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