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
aed2015c
Commit
aed2015c
authored
Apr 26, 2017
by
Χάρης Παπαδόπουλος
Browse files
Merge branch 'component_updates' into 'develop'
Component updates See merge request !62
parents
1bbf8690
56c4bfb5
Changes
11
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
aed2015c
...
...
@@ -78,10 +78,12 @@ epal.demo_data:
_access
:
'
TRUE'
epal.allocation
:
path
:
'
/epal/distribution'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\Distribution::createDistribution'
requirements
:
_access
:
'
TRUE'
_user_is_logged_in
:
'
TRUE'
sectorperschool
:
path
:
'
/epal/sectorperSchool/{epalId}'
options
:
...
...
@@ -130,3 +132,19 @@ epal.ministry.log_in_go:
_controller
:
'
\Drupal\epal\Controller\MinistryLogin::loginGo'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.log_out_go
:
path
:
'
/ministry/logout'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\MinistryLogin::logoutGo'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.ministry.general_report
:
path
:
'
/ministry/general-report'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\Distribution::makegGeneralReport'
requirements
:
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/Distribution.php
View file @
aed2015c
...
...
@@ -73,15 +73,37 @@ class Distribution extends ControllerBase {
$numDistributions
=
3
;
$sizeOfBlock
=
100000
;
/
*
/
/POST method is checked
if
(
!
$request
->
isMethod
(
'POST'
))
{
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
);
}
//clearDistributionResults();
$transaction
=
$this
->
connection
->
startTransaction
();
...
...
@@ -91,18 +113,18 @@ class Distribution extends ControllerBase {
$this
->
connection
->
delete
(
'epal_student_class'
)
->
execute
();
$limitUp_class
=
$this
->
retrieveCapacityLimitUp
(
"Α"
);
print_r
(
"<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: "
.
$limitUp_class
);
//
print_r("<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: " . $limitUp_class);
while
(
$this
->
choice_id
<=
$numDistributions
)
{
print_r
(
"<br>ΠΕΡΑΣΜΑ: "
.
$this
->
choice_id
);
//
print_r("<br>ΠΕΡΑΣΜΑ: " . $this->choice_id);
//υπολογισμός πλήθους non-finalized αιτήσεων για να καθοριστεί ο αριθμός των fetches που θα κάνουμε με συγκεκριμένο sizeOfBlock
if
(
$this
->
choice_id
===
1
)
{
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$numData
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
print_r
(
"<br>numData: "
.
$numData
);
//
print_r("<br>numData: " . $numData);
}
$j
=
1
;
...
...
@@ -110,7 +132,7 @@ class Distribution extends ControllerBase {
if
(
$this
->
choice_id
===
1
)
{
while
(
$num
<=
$numData
)
{
print_r
(
"<br>FETCH: "
.
$j
);
//
print_r("<br>FETCH: " . $j);
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
,
'name'
,
'currentclass'
,
'currentepal'
,
'points'
))
->
condition
(
'eStudent.id'
,
1
+
$sizeOfBlock
*
(
$j
-
1
),
'>='
)
...
...
@@ -131,9 +153,6 @@ class Distribution extends ControllerBase {
->
condition
(
'eStudent.id'
,
$this
->
pendingStudents
,
'IN'
);
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
//foreach ($epalStudents as $x)
// print_r("<br> TEST:" . $x->id . " ");
$this
->
locateStudent
(
$this
->
choice_id
,
$epalStudents
);
}
else
{
//αν δεν υπάρχουν εκκρεμότητες, μην συνεχίζεις με άλλο πέρασμα
...
...
@@ -177,6 +196,7 @@ class Distribution extends ControllerBase {
}
//end while
}
//end try
catch
(
\
Exception
$e
)
{
...
...
@@ -187,9 +207,26 @@ class Distribution extends ControllerBase {
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
//return new RedirectResponse($this->redirectUrl . '?auth_token=' . $epalToken.'&auth_role=director', 302, []);
//return new RedirectResponse("../eepal/dist/#/minister/minister-view");
/*
return $this->respondWithStatus([
"message" => t("Distribution has made successfully")
], Response::HTTP_OK);
*/
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
return
$this
->
respondWithStatus
([
'message'
=>
"Distribution has made successfu"
,
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"post with no data"
),
],
Response
::
HTTP_BAD_REQUEST
);
}
}
...
...
@@ -204,8 +241,8 @@ class Distribution extends ControllerBase {
try
{
foreach
(
$epalStudents
as
$epalStudent
)
{
print_r
(
"<br>ΚΑΤΑΝΟΜΗ ΜΑΘΗΤΩΝ ΝΟ: "
.
$choice_id
);
print_r
(
"<br>ΜΑΘΗΤΗΣ: "
.
$epalStudent
->
id
);
//
print_r("<br>ΚΑΤΑΝΟΜΗ ΜΑΘΗΤΩΝ ΝΟ: " . $choice_id);
//
print_r("<br>ΜΑΘΗΤΗΣ: " . $epalStudent->id);
$clCon
=
$this
->
connection
->
select
(
'epal_student_epal_chosen'
,
'epals'
)
->
fields
(
'epals'
,
array
(
'student_id'
,
'epal_id'
,
'choice_no'
))
...
...
@@ -215,7 +252,7 @@ class Distribution extends ControllerBase {
if
(
sizeof
(
$epalSchoolsChosen
)
!==
0
)
{
$epalSchoolChos
=
reset
(
$epalSchoolsChosen
);
print_r
(
" SCHOOL_ID:"
.
$epalSchoolChos
->
epal_id
.
" STUDENT_ID "
.
$epalStudent
->
id
);
//
print_r(" SCHOOL_ID:" . $epalSchoolChos->epal_id . " STUDENT_ID " . $epalStudent->id);
$epal_dist_id
=
$epalSchoolChos
->
epal_id
;
if
(
$epalStudent
->
currentclass
===
"2"
)
{
...
...
@@ -316,7 +353,7 @@ class Distribution extends ControllerBase {
->
condition
(
'studentClass.specialization_id'
,
$secCourId
,
'='
);
$epalStudentClass
=
$clCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
print_r
(
"<br> ΣΧΟΛΕΙΟ: "
.
$epalId
.
" ΤΑΞΗ: "
.
$classId
.
" ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: "
.
$secCourId
.
" ΧΩΡΗΤΙΚΟΤΗΤΑ: "
.
sizeof
(
$epalStudentClass
));
//
print_r("<br> ΣΧΟΛΕΙΟ: " . $epalId . " ΤΑΞΗ: " . $classId . " ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: " . $secCourId . " ΧΩΡΗΤΙΚΟΤΗΤΑ: " . sizeof($epalStudentClass));
//ΕΠΙΠΛΕΟΝ ΕΠΙΠΕΔΟ ΑΣΦΑΛΕΙΑΣ: αν δεν υπάρχει ο συγκεκριμένος τομέας/ειδικότητα στο σχολείο
//ο μαθητής που τοποθετήθηκε με την locateStudent να διαγραφεί
...
...
@@ -337,7 +374,7 @@ class Distribution extends ControllerBase {
$limit
=
$limitup
*
$capacity
;
if
(
sizeof
(
$epalStudentClass
)
>
$limit
)
{
print_r
(
"<br>ΥΠΕΡΧΕΙΛΙΣΗ!"
);
//
print_r("<br>ΥΠΕΡΧΕΙΛΙΣΗ!");
foreach
(
$epalStudentClass
as
$epalStudCl
)
{
//Υπολογισμός μορίων του μαθητή και (πιθανή) αποθήκευσή τους
//ΣΗΜΕΙΩΣΗ: Ο υπoλογισμός γίνεται στο front-end
...
...
@@ -395,7 +432,7 @@ class Distribution extends ControllerBase {
foreach
(
$students
as
$student
)
{
$student
->
student_id
;
print_r
(
"<br>STUDENT_ID:"
.
$student
->
student_id
);
//
print_r("<br>STUDENT_ID:" . $student->student_id);
}
//εύρεση αριθμού μαθητών που ήδη φοιτούσαν στο σχολείο
...
...
@@ -408,11 +445,11 @@ class Distribution extends ControllerBase {
$this
->
removeFromPendingStudents
(
$student
->
student_id
);
}
}
print_r
(
"<br>#ΕΓΓΡΑΦΩΝ ΠΟΥ ΟΙ ΜΑΘΗΤΕΣ ΦΟΙΤΟΥΣΑΝ ΗΔΗ:"
.
$cnt
);
//
print_r("<br>#ΕΓΓΡΑΦΩΝ ΠΟΥ ΟΙ ΜΑΘΗΤΕΣ ΦΟΙΤΟΥΣΑΝ ΗΔΗ:" . $cnt);
$newlimit
=
$limit
-
$cnt
;
print_r
(
"<br>ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ:"
.
$limit
);
print_r
(
"<br>#ΜΑΘΗΤΩΝ ΓΙΑ ΝΑ ΕΠΙΛΕΓΟΥΝ ΜΕ ΜΟΡΙΑ:"
.
$newlimit
);
//
print_r("<br>ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ:" . $limit);
//
print_r("<br>#ΜΑΘΗΤΩΝ ΓΙΑ ΝΑ ΕΠΙΛΕΓΟΥΝ ΜΕ ΜΟΡΙΑ:" . $newlimit);
$points_arr
=
[];
foreach
(
$students
as
$student
)
{
...
...
@@ -421,17 +458,17 @@ class Distribution extends ControllerBase {
}
rsort
(
$points_arr
);
for
(
$i
=
0
;
$i
<
sizeof
(
$points_arr
);
$i
++
)
print_r
(
"<br>ΜΟΡΙΑ ΜΕΤΑ ΤΗΝ ΤΑΞΙΝΟΜΙΣΗ: "
.
$points_arr
[
$i
]);
//
for ($i=0; $i < sizeof($points_arr); $i++)
//
print_r("<br>ΜΟΡΙΑ ΜΕΤΑ ΤΗΝ ΤΑΞΙΝΟΜΙΣΗ: " . $points_arr[$i]);
print_r
(
"<br>ΟΡΙΟ ΜΟΡΙΩΝ: "
.
$points_arr
[
$newlimit
-
1
]);
//
print_r("<br>ΟΡΙΟ ΜΟΡΙΩΝ: " . $points_arr[$newlimit-1]);
$transaction
=
$this
->
connection
->
startTransaction
();
foreach
(
$students
as
$student
)
{
if
(
$student
->
currentepal
!==
$student
->
epal_id
)
{
if
(
$student
->
points
<
$points_arr
[
$newlimit
-
1
])
{
print_r
(
"<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: "
.
$student
->
student_id
);
//
print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id);
//βάλε τον μαθητή στον πίνακα εκκρεμοτήτων και διέγραψέ τον από τον προσωρινό πίνακα αποτελεσμάτων
array_push
(
$this
->
pendingStudents
,
$student
->
student_id
);
try
{
...
...
@@ -476,4 +513,91 @@ class Distribution extends ControllerBase {
public
function
makegGeneralReport
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'GET'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$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
//$user = \Drupal\user\Entity\User::load($user->id());
$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
);
}
//υπολογισμός αριθμού αιτήσεων
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$numTotal
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
//υπολογισμός αριθμού αιτήσεων που ικανοποιήθηκαν στην i προτίμηση
$numData
=
array
();
for
(
$i
=
0
;
$i
<
3
;
$i
++
)
{
$sCon
=
$this
->
connection
->
select
(
'epal_student_class'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
,
'distribution_id'
))
->
condition
(
'eStudent.distribution_id'
,
$i
+
1
,
'='
);
array_push
(
$numData
,
$sCon
->
countQuery
()
->
execute
()
->
fetchField
());
}
// υπολογισμός αριθμού αιτήσεων που ΔΕΝ ικανοποιήθηκαν
//Σημείωση: υπολογισμός με queries στη βάση
$sCon
=
$this
->
connection
->
select
(
'epal_student_class'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$epalStudents
=
$sCon
->
execute
()
->
fetchAll
(
\
PDO
::
FETCH_OBJ
);
$studentIds
=
array
();
foreach
(
$epalStudents
as
$epalStudent
)
array_push
(
$studentIds
,
$epalStudent
->
id
);
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
))
->
condition
(
'eStudent.id'
,
$studentIds
,
'NOT IN'
);
$numNoAllocated
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
$list
[]
=
array
(
'num_applications'
=>
$numTotal
,
'numchoice1'
=>
$numData
[
0
],
'numchoice2'
=>
$numData
[
1
],
'numchoice3'
=>
$numData
[
2
],
'num_noallocated'
=>
$numNoAllocated
,
);
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"An unexpected problem occured during DELETE proccess in makeSelectionOfStudents Method of Distribution"
)
],
Response
::
HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
drupal/modules/epal/src/Controller/MinistryLogin.php
View file @
aed2015c
...
...
@@ -46,14 +46,15 @@ class MinistryLogin extends ControllerBase
public
function
loginGo
(
Request
$request
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
try
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
...
...
@@ -110,6 +111,65 @@ class MinistryLogin extends ControllerBase
}
public
function
logoutGo
(
Request
$request
)
{
try
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
//user validation
//Note: $authToken = $postData->username
$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
//$user = \Drupal\user\Entity\User::load($user->id());
/*
$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);
}
*/
session_unset
();
session_destroy
();
$response
=
new
Response
();
$response
->
setContent
(
'logout successful'
);
$response
->
setStatusCode
(
Response
::
HTTP_OK
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
//end try
catch
(
\
Exception
$e
)
{
$this
->
logger
->
warning
(
$e
->
getMessage
());
$response
=
new
Response
();
$response
->
setContent
(
'forbidden'
);
$response
->
setStatusCode
(
Response
::
HTTP_FORBIDDEN
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
...
...
source/app.settings.ts
View file @
aed2015c
export
const
API_ENDPOINT
=
'
http://eduslim2.minedu.gov.gr/drupal
'
;
export
const
API_ENDPOINT
=
'
http://eduslim2.minedu.gov.gr/drupal
-8.2.6
'
;
// 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/drupal
'
;
return
'
http://eduslim2.minedu.gov.gr/drupal
-8.2.6
'
;
// return 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
}
}
source/components/minister/minister-reports.ts
0 → 100644
View file @
aed2015c
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
'
;
import
{
API_ENDPOINT
}
from
'
../../app.settings
'
;
@
Component
({
selector
:
'
minister-reports
'
,
template
:
`
<div>
<form [formGroup]="formGroup" #form>
<!--<button type="submit" class="btn-primary btn-md" (click)="form.submit()" >-->
<button type="submit" class="btn btn-default btn-block" (click)="reportGeneral()" >
Συγκεντρωτικά Αποτελέσματα Κατανομής
</button>
<div *ngFor="let generalReports$ of generalReport$ | async; let i=index">
<div *ngIf="showMessage">
<br>
Αριθμός Αιτήσεων: {{generalReports$.num_applications}}<br>
Αριθμός μαθητών που τοποθετήθηκαν στην πρώτη τους προτίμηση: {{generalReports$.numchoice1}}<br>
Αριθμός μαθητών που τοποθετήθηκαν στη δεύτερή τους προτίμηση: {{generalReports$.numchoice2}}<br>
Αριθμός μαθητών που τοποθετήθηκαν στην τρίτη τους προτίμηση: {{generalReports$.numchoice3}}<br>
Αριθμός μαθητών που δεν τοποθετήθηκαν σε καμμία τους προτίμηση: {{generalReports$.num_noallocated}}<br>
</div>
</div>
</form>
</div>
`
})
@
Injectable
()
export
default
class
MinisterReports
implements
OnInit
,
OnDestroy
{
public
formGroup
:
FormGroup
;
loginInfo$
:
BehaviorSubject
<
ILoginInfo
>
;
loginInfoSub
:
Subscription
;
private
generalReport$
:
BehaviorSubject
<
any
>
;
private
generalReportSub
:
Subscription
;
private
apiEndPoint
=
API_ENDPOINT
;
private
minedu_userName
:
string
;
private
minedu_userPassword
:
string
;
private
distStatus
=
"
READY
"
;
private
data
:
string
;
private
showMessage
:
boolean
;
constructor
(
private
fb
:
FormBuilder
,
private
_ngRedux
:
NgRedux
<
IAppState
>
,
private
_hds
:
HelperDataService
,
private
activatedRoute
:
ActivatedRoute
,
private
router
:
Router
)
{
this
.
formGroup
=
this
.
fb
.
group
({
});
this
.
loginInfo$
=
new
BehaviorSubject
(
LOGININFO_INITIAL_STATE
);
this
.
generalReport$
=
new
BehaviorSubject
([{}]);
this
.
showMessage
=
false
;
}
ngOnDestroy
()
{
if
(
this
.
loginInfoSub
)
this
.
loginInfoSub
.
unsubscribe
();
this
.
loginInfo$
.
unsubscribe
();
if
(
this
.
generalReportSub
)
this
.
generalReportSub
.
unsubscribe
();
this
.
generalReport$
.
unsubscribe
();
}
ngOnInit
()
{
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$
);
}
reportGeneral
()
{
this
.
generalReportSub
=
this
.
_hds
.
makeGeneralReport
(
this
.
minedu_userName
,
this
.
minedu_userPassword
).
subscribe
(
data
=>
{
this
.
generalReport$
.
next
(
data
);
this
.
data
=
data
;
},
error
=>
{
this
.
generalReport$
.
next
([{}]);
console
.
log
(
"
Error Getting generalReport
"
);
},
()
=>
{
console
.
log
(
"
Getting generalReport
"
);
/*this.numChoice1 = this.data['numchoice1'];
console.log(this.numChoice1);*/
this
.
showMessage
=
true
;
}
)
}
}
source/components/minister/minister-view.ts
View file @
aed2015c
...
...
@@ -2,13 +2,15 @@ import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/cor
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
{
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
{
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
,
...
...
@@ -24,9 +26,27 @@ import { API_ENDPOINT } from '../../app.settings';
selector
:
'
minister-view
'
,
template
:
`
<div>
<div
class = "loading" *ngIf=" distStatus === 'STARTED'" >
</div>
<div class="alert alert-info" *ngIf="distStatus === 'STARTED'">
Παρακαλώ περιμένετε...Η εκτέλεση της κατανομής ενδέχεται να διαρκέσει μερικά λεπτά. Παρακαλώ μην εκτελείται οποιαδήποτε ενέργεια μετακίνησης στον φυλλομετρητή σας, μέχρι να ολοκληρωθεί η κατανομή.
</div>
<div class="alert alert-info" *ngIf="distStatus === 'FINISHED'">
Η κατανομή ολοκληρώθηκε με επιτυχία!
</div>
<div class="alert alert-info" *ngIf="distStatus === 'ERROR'">
Αποτυχία κατανομής!
</div>
<div>
<!--
<form [formGroup]="formGroup" method = "POST" action="{{apiEndPoint}}/epal/distribution" #form>
<button type="submit" class="btn-primary btn-md" (click)="form.submit()" [disabled]="true">
-->
<form [formGroup]="formGroup" #form>
<!--<div *ngFor="let loginInfoToken$ of loginInfo$ | async; let i=index"></div>-->
<!--<button type="submit" class="btn-primary btn-md" (click)="form.submit()" >-->