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
24da0be3
Commit
24da0be3
authored
May 25, 2017
by
Χάρης Παπαδόπουλος
Browse files
Merge branch 'component_updates' into 'develop'
added MinisterSettings Component, updated Minister Controllers See merge request !100
parents
4e8a9459
ee2aa780
Changes
12
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
24da0be3
...
...
@@ -182,6 +182,22 @@ epal.ministry.massive_mail:
_controller
:
'
\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToStudents'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.retrievesettings
:
path
:
'
/ministry/retrieve-settings'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\MinisterSettings::retrieveSettings'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.storesettings
:
path
:
'
/ministry/store-settings/{capacityDisabled}/{directorViewDisabled}/{applicantsLoginDisabled}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\MinisterSettings::storeSettings'
requirements
:
_user_is_logged_in
:
'
TRUE'
regionview
:
path
:
'
/epal/ScoolperPerf/{perfectureId}'
options
:
...
...
drupal/modules/epal/src/Controller/Distribution.php
View file @
24da0be3
...
...
@@ -102,6 +102,29 @@ class Distribution extends ControllerBase {
],
Response
::
HTTP_FORBIDDEN
);
}
//check where distribution can be done now ($capacityDisabled / $directorViewDisabled settings)
$capacityDisabled
=
false
;
$directorViewDisabled
=
false
;
$config_storage
=
$this
->
entityTypeManager
->
getStorage
(
'epal_config'
);
$epalConfigs
=
$config_storage
->
loadByProperties
(
array
(
'id'
=>
1
));
$epalConfig
=
reset
(
$epalConfigs
);
if
(
!
$epalConfig
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EpalConfig Enity not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
else
{
$capacityDisabled
=
$epalConfig
->
lock_school_capacity
->
getString
();
$directorViewDisabled
=
$epalConfig
->
lock_school_students_view
->
getString
();
}
if
(
$capacityDisabled
===
"0"
or
$directorViewDisabled
===
"0"
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"capacityDisabled and / or directorViewDisabled settings are false"
),
],
Response
::
HTTP_FORBIDDEN
);
}
$transaction
=
$this
->
connection
->
startTransaction
();
...
...
drupal/modules/epal/src/Controller/MinisterSettings.php
0 → 100644
View file @
24da0be3
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace
Drupal\epal\Controller
;
use
Drupal\Core\Entity\Query\QueryFactory
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Drupal\Core\Controller\ControllerBase
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\Connection
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\Core\Logger\LoggerChannelFactoryInterface
;
class
MinisterSettings
extends
ControllerBase
{
protected
$entity_query
;
protected
$entityTypeManager
;
protected
$logger
;
protected
$connection
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
QueryFactory
$entity_query
,
Connection
$connection
,
LoggerChannelFactoryInterface
$loggerChannel
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
entity_query
=
$entity_query
;
$connection
=
Database
::
getConnection
();
$this
->
connection
=
$connection
;
$this
->
logger
=
$loggerChannel
->
get
(
'epal'
);
}
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity.query'
),
$container
->
get
(
'database'
),
$container
->
get
(
'logger.factory'
)
);
}
public
function
retrieveSettings
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'GET'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$users
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$authToken
));
$user
=
reset
(
$users
);
if
(
!
$user
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"User not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
//user role validation
$roles
=
$user
->
getRoles
();
$validRole
=
false
;
foreach
(
$roles
as
$role
)
if
(
$role
===
"ministry"
)
{
$validRole
=
true
;
break
;
}
if
(
!
$validRole
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"User Invalid Role"
),
],
Response
::
HTTP_FORBIDDEN
);
}
//minister settings retrieve
$config_storage
=
$this
->
entityTypeManager
->
getStorage
(
'epal_config'
);
$epalConfigs
=
$config_storage
->
loadByProperties
(
array
(
'id'
=>
1
));
$epalConfig
=
reset
(
$epalConfigs
);
if
(
!
$epalConfig
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EpalConfig Enity not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
else
{
$capacityDisabled
=
$epalConfig
->
lock_school_capacity
->
getString
();
$directorViewDisabled
=
$epalConfig
->
lock_school_students_view
->
getString
();
$applicantsLoginDisabled
=
$epalConfig
->
lock_application
->
getString
();
}
$config_storage
->
resetCache
();
return
$this
->
respondWithStatus
([
//'message' => t("post successful"),
'capacityDisabled'
=>
$capacityDisabled
,
'directorViewDisabled'
=>
$directorViewDisabled
,
'applicantsLoginDisabled'
=>
$applicantsLoginDisabled
,
],
Response
::
HTTP_OK
);
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured during retrieveSettings Method "
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
public
function
storeSettings
(
Request
$request
,
$capacityDisabled
,
$directorViewDisabled
,
$applicantsLoginDisabled
)
{
try
{
if
(
!
$request
->
isMethod
(
'GET'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$users
=
$this
->
entityTypeManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$authToken
));
$user
=
reset
(
$users
);
if
(
!
$user
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"User not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
//user role validation
$roles
=
$user
->
getRoles
();
$validRole
=
false
;
foreach
(
$roles
as
$role
)
if
(
$role
===
"ministry"
)
{
$validRole
=
true
;
break
;
}
if
(
!
$validRole
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"User Invalid Role"
),
],
Response
::
HTTP_FORBIDDEN
);
}
$config_storage
=
$this
->
entityTypeManager
->
getStorage
(
'epal_config'
);
$epalConfigs
=
$config_storage
->
loadByProperties
(
array
(
'id'
=>
1
));
$epalConfig
=
reset
(
$epalConfigs
);
if
(
!
$epalConfig
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EpalConfig Enity not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
else
{
$epalConfig
->
set
(
'lock_school_capacity'
,
$capacityDisabled
);
$epalConfig
->
set
(
'lock_school_students_view'
,
$directorViewDisabled
);
$epalConfig
->
set
(
'lock_application'
,
$applicantsLoginDisabled
);
$epalConfig
->
save
();
}
$config_storage
->
resetCache
();
return
$this
->
respondWithStatus
([
//'message' => t("post successful"),
'capacityDisabled'
=>
$capacityDisabled
,
'directorViewDisabled'
=>
$directorViewDisabled
,
'applicantsLoginDisabled'
=>
$applicantsLoginDisabled
,
],
Response
::
HTTP_OK
);
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured during storeSettings Method "
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
return
$res
;
}
}
drupal/modules/epal/src/Controller/ReportsCreator.php
View file @
24da0be3
...
...
@@ -514,7 +514,7 @@ class ReportsCreator extends ControllerBase {
array_push
(
$numClasses
,
$numClassCour
);
array_push
(
$numClasses
,
$numClassCour_D
);
if
(
$sectorId
===
"0"
&&
$courseId
===
0
)
{
if
(
$sectorId
===
"0"
&&
$courseId
===
"0"
)
{
$clidstart
=
1
;
$clidend
=
4
;
...
...
source/components/minister/minister-informstudents.ts
View file @
24da0be3
...
...
@@ -39,6 +39,7 @@ import { API_ENDPOINT } from '../../app.settings';
</div>
</div>
<h5> >Αποστολή ειδοποιήσεων <br></h5>
<br><br>
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents()" >
...
...
source/components/minister/minister-reports.ts
View file @
24da0be3
...
...
@@ -29,7 +29,7 @@ import { API_ENDPOINT } from '../../app.settings';
<div>
<h5>
<br>
>Επιλογή Αναφοράς<br><br></h5>
<h5> >Επιλογή Αναφοράς<br><br></h5>
<div class="col-md-1">
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide'" >
...
...
source/components/minister/minister-settings.ts
0 → 100644
View file @
24da0be3
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
{
LOGININFO_INITIAL_STATE
}
from
'
../../store/logininfo/logininfo.initial-state
'
;
import
{
FormBuilder
,
FormGroup
,
FormControl
,
FormArray
,
Validators
,
}
from
'
@angular/forms
'
;
@
Component
({
selector
:
'
minister-settings
'
,
template
:
`
<div
class = "loading" *ngIf="dataRetrieved == -1 " >
</div>
<div id="configNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header {{modalHeader | async}}" >
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i> {{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>{{ modalText | async }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div *ngIf="(loginInfo$ | async).size !== 0">
<form [formGroup]="formGroup" #form>
<h5> >Ρυθμίσεις <br><br></h5>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="capacityDisabled" formControlName="capacityDisabled"
(click)="toggleCapacityFilter()" >
</div>
<div class="col-md-9">
<label for="capacityDisabled">Απενεργοποίηση δυνατότητας τροποποίησης χωρητικότητας από τους Διευθυντές σχολείων</label>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="directorViewDisabled" formControlName="directorViewDisabled"
(click)="toggleDirectorView()" >
</div>
<div class="col-md-9">
<label for="directorViewDisabled">Απενεργοποίηση δυνατότητας προβολής κατανομής μαθητών από τους Διευθυντές σχολείων</label>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="applicantsLoginDisabled" formControlName="applicantsLoginDisabled"
(click)="toggleApplicantsLogin()" >
</div>
<div class="col-md-9">
<label for="applicantsLoginDisabled">Απενεργοποίηση δυνατότητας αίτησης μαθητών</label>
</div>
</div>
<br>
<button type="submit" class="btn btn-md pull-right" (click)="storeSettings()" >
Εφαρμογή
</button>
</form>
</div>
`
})
@
Injectable
()
export
default
class
MinisterSettings
implements
OnInit
,
OnDestroy
{
public
formGroup
:
FormGroup
;
loginInfo$
:
BehaviorSubject
<
ILoginInfo
>
;
private
modalTitle
:
BehaviorSubject
<
string
>
;
private
modalText
:
BehaviorSubject
<
string
>
;
private
modalHeader
:
BehaviorSubject
<
string
>
;
private
settings$
:
BehaviorSubject
<
any
>
;
loginInfoSub
:
Subscription
;
private
settingsSub
:
Subscription
;
//private data;
private
capacityDisabled
:
boolean
;
private
directorViewDisabled
:
boolean
;
private
applicantsLoginDisabled
:
boolean
;
private
dataRetrieved
:
number
;
private
minedu_userName
:
string
;
private
minedu_userPassword
:
string
;
constructor
(
private
fb
:
FormBuilder
,
private
_ngRedux
:
NgRedux
<
IAppState
>
,
private
_hds
:
HelperDataService
,
private
router
:
Router
)
{
this
.
formGroup
=
this
.
fb
.
group
({
capacityDisabled
:
[
''
,
[]],
directorViewDisabled
:
[
''
,
[]],
applicantsLoginDisabled
:
[
''
,
[]],
});
this
.
loginInfo$
=
new
BehaviorSubject
(
LOGININFO_INITIAL_STATE
);
this
.
settings$
=
new
BehaviorSubject
([{}]);
this
.
modalTitle
=
new
BehaviorSubject
(
""
);
this
.
modalText
=
new
BehaviorSubject
(
""
);
this
.
modalHeader
=
new
BehaviorSubject
(
""
);
}
public
showModal
():
void
{
console
.
log
(
"
about to show modal
"
);
(
<
any
>
$
(
'
#configNotice
'
)).
modal
(
'
show
'
);
}
public
hideModal
():
void
{
(
<
any
>
$
(
'
#configNotice
'
)).
modal
(
'
hide
'
);
}
public
onHidden
():
void
{
//this.isModalShown.next(false);
}
ngOnDestroy
()
{
(
<
any
>
$
(
'
#configNotice
'
)).
remove
();
if
(
this
.
loginInfoSub
)
this
.
loginInfoSub
.
unsubscribe
();
if
(
this
.
settingsSub
)
this
.
settingsSub
.
unsubscribe
();
}
ngOnInit
()
{
(
<
any
>
$
(
'
#configNotice
'
)).
appendTo
(
"
body
"
);
this
.
loginInfoSub
=
this
.
_ngRedux
.
select
(
state
=>
{
if
(
state
.
loginInfo
.
size
>
0
)
{
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
this
.
minedu_userName
=
loginInfoToken
.
minedu_username
;
this
.
minedu_userPassword
=
loginInfoToken
.
minedu_userpassword
;
return
loginInfoToken
;
},
{});
}
return
state
.
loginInfo
;
}).
subscribe
(
this
.
loginInfo$
);
this
.
retrieveSettings
();
}
retrieveSettings
()
{
this
.
dataRetrieved
=
-
1
;
this
.
settingsSub
=
this
.
_hds
.
retrieveAdminSettings
(
this
.
minedu_userName
,
this
.
minedu_userPassword
).
subscribe
(
data
=>
{
this
.
settings$
.
next
(
data
);
//this.data = data;
},
error
=>
{
this
.
settings$
.
next
([{}]);
this
.
dataRetrieved
=
0
;
console
.
log
(
"
Error Getting MinisterRetrieveSettings
"
);
},
()
=>
{
console
.
log
(
"
Success Getting MinisterRetrieveSettings
"
);
this
.
capacityDisabled
=
Boolean
(
Number
(
this
.
settings$
.
value
[
'
capacityDisabled
'
]));
this
.
directorViewDisabled
=
Boolean
(
Number
(
this
.
settings$
.
value
[
'
directorViewDisabled
'
]));
this
.
applicantsLoginDisabled
=
Boolean
(
Number
(
this
.
settings$
.
value
[
'
applicantsLoginDisabled
'
]));
this
.
dataRetrieved
=
1
;
}
)
}
storeSettings
()
{
this
.
dataRetrieved
=
-
1
;
this
.
settingsSub
=
this
.
_hds
.
storeAdminSettings
(
this
.
minedu_userName
,
this
.
minedu_userPassword
,
this
.
capacityDisabled
,
this
.
directorViewDisabled
,
this
.
applicantsLoginDisabled
)
.
subscribe
(
data
=>
{
this
.
settings$
.
next
(
data
);
//this.data = data;
},
error
=>
{
this
.
settings$
.
next
([{}]);
this
.
dataRetrieved
=
0
;
console
.
log
(
"
Error Getting MinisterStoreSettings
"
);
this
.
modalTitle
.
next
(
"
Ρύθμιση Παραμέτρων
"
);
this
.
modalText
.
next
(
"
ΑΠΟΤΥΧΙΑ εφαρμογής των νέων σας ρυθμίσεων.
"
);
this
.
modalHeader
.
next
(
"
modal-header-danger
"
);
this
.
showModal
();
},
()
=>
{
console
.
log
(
"
Success Getting MinisterStoreSettings
"
);
this
.
dataRetrieved
=
1
;
this
.
modalTitle
.
next
(
"
Ρύθμιση Παραμέτρων
"
);
this
.
modalText
.
next
(
"
Έγινε εφαρμογή των νέων σας ρυθμίσεων.
"
);
this
.
modalHeader
.
next
(
"
modal-header-success
"
);
this
.
showModal
();
//redundunt and has risk..Appear a modal!
//this.retrieveSettings();
}
)
}
toggleCapacityFilter
()
{
this
.
capacityDisabled
=
!
this
.
capacityDisabled
;
}
toggleDirectorView
()
{
this
.
directorViewDisabled
=
!
this
.
directorViewDisabled
;
}
toggleApplicantsLogin
()
{
this
.
applicantsLoginDisabled
=
!
this
.
applicantsLoginDisabled
;
}
}
source/components/minister/minister-view.ts
View file @
24da0be3
...
...
@@ -11,15 +11,6 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import
{
ILoginInfo
}
from
'
../../store/logininfo/logininfo.types
'
;
import
{
LOGININFO_INITIAL_STATE
}
from
'
../../store/logininfo/logininfo.initial-state
'
;
/*
import {
FormBuilder,
FormGroup,
FormControl,
FormArray,
Validators,
} from '@angular/forms';
*/
import
{
API_ENDPOINT
}
from
'
../../app.settings
'
;
...
...
@@ -27,26 +18,29 @@ import { API_ENDPOINT } from '../../app.settings';
selector
:
'
minister-view
'
,
template
:
`
<h5> >Κατανομή <br></h5>
<!--
<div class="row">
<breadcrumbs></breadcrumbs>
</div>
-->
<div
class = "loading" *ngIf=" distStatus === 'STARTED'" >
</div>
<div id="distribution
Completed
Notice" (onHidden)="onHidden(
'#distributionCompletedNotice'
)" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div id="distributionNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal
-h
eader
-success"
>
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>
Κατανομή μαθητών
</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal(
'#distributionCompletedNotice'
)">