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
a5b45a86
Commit
a5b45a86
authored
Jun 23, 2017
by
Χάρης Παπαδόπουλος
Browse files
Merge branch 'pde-dde-views' into 'develop'
counter See merge request !211
parents
fcca2a68
6651c207
Changes
5
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
a5b45a86
...
...
@@ -308,5 +308,13 @@ epal.applicant.showresults:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\SubmitedApplications::getResults'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.totalstudents
:
path
:
'
/epal/totalstudent'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\HelpDesk::findTotalStudents'
requirements
:
_user_is_logged_in
:
'
TRUE'
\ No newline at end of file
drupal/modules/epal/src/Controller/HelpDesk.php
View file @
a5b45a86
...
...
@@ -24,28 +24,32 @@ use Drupal\Core\Language\LanguageManagerInterface;
class
HelpDesk
extends
ControllerBase
{
protected
$entityTypeManager
;
protected
$entity_query
;
protected
$entityTypeManager
;
protected
$logger
;
protected
$connection
;
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
LoggerChannelFactoryInterface
$loggerChannel
,
Connection
$connection
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
logger
=
$loggerChannel
->
get
(
'epal-school'
);
$this
->
connection
=
$connection
;
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
(
'
logger.facto
ry'
),
$container
->
get
(
'database'
)
$container
->
get
(
'
entity.que
ry'
),
$container
->
get
(
'database'
)
,
$container
->
get
(
'logger.factory'
)
);
}
...
...
@@ -109,6 +113,50 @@ class HelpDesk extends ControllerBase {
return
;
}
public
function
findTotalStudents
(
Request
$request
)
{
$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
===
"applicant"
)
{
$validRole
=
true
;
break
;
}
}
if
(
!
$validRole
)
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"User Invalid Role"
),
],
Response
::
HTTP_FORBIDDEN
);
}
$list
=
array
();
$sCon
=
$this
->
connection
->
select
(
'epal_student'
,
'eStudent'
)
->
fields
(
'eStudent'
,
array
(
'id'
));
$numApplications
=
$sCon
->
countQuery
()
->
execute
()
->
fetchField
();
array_push
(
$list
,
(
object
)
array
(
'name'
=>
"Αριθμός Αιτήσεων (συνολικά)"
,
'numStudents'
=>
$numApplications
));
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
}
source/components/header/header.component.html
View file @
a5b45a86
...
...
@@ -31,8 +31,16 @@
<div
class=
"col-md-2"
>
<span
*ngIf=
"loginInfoRow$.auth_role===studentRole"
class=
"signout isclickable"
(click)=
"gohelpDesk()"
style=
"color:#CC3300;"
>
Επικοινωνία
</span>
</div>
<div
class=
"col-md-4"
>
<span
*ngIf=
"loginInfoRow$.auth_role===studentRole"
class=
"signout"
style=
"color:#CC3300;"
>
<div
*ngFor=
"let TotalStudent$ of TotalStudents$ | async;"
>
Σύνολο Αιτήσεων:{{TotalStudent$.numStudents}}
</div>
</span>
</div>
<div
class=
"col-md-4"
>
</div>
<div
class=
"col-md-4"
style=
"text-align: right"
>
<span
class=
"username"
style=
"text-align: right"
>
{{ cuName }}
</span>
<span
class=
"signout isclickable"
style=
"text-align: right"
(click)=
"signOut()"
style=
"color:#CC3300;"
>
Αποσύνδεση
</span>
...
...
source/components/header/header.component.ts
View file @
a5b45a86
...
...
@@ -2,7 +2,7 @@ import {Component, OnInit, OnDestroy} from "@angular/core";
import
{
Router
}
from
"
@angular/router
"
;
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
BehaviorSubject
}
from
"
rxjs/Rx
"
;
import
{
BehaviorSubject
,
Subscription
}
from
'
rxjs/Rx
'
;
import
{
NgRedux
,
select
}
from
"
ng2-redux
"
;
import
{
IAppState
}
from
"
../../store/store
"
;
import
{
ILoginInfo
,
ILoginInfoToken
}
from
"
../../store/logininfo/logininfo.types
"
;
...
...
@@ -17,6 +17,7 @@ import { SectorCoursesActions } from "../../actions/sectorcourses.actions";
import
{
CriteriaActions
}
from
"
../../actions/criteria.actions
"
;
import
{
StudentDataFieldsActions
}
from
"
../../actions/studentdatafields.actions
"
;
@
Component
({
selector
:
"
reg-header
"
,
templateUrl
:
"
header.component.html
"
...
...
@@ -33,6 +34,10 @@ export default class HeaderComponent implements OnInit, OnDestroy {
private
modalText
:
BehaviorSubject
<
string
>
;
private
modalHeader
:
BehaviorSubject
<
string
>
;
private
TotalStudents$
:
BehaviorSubject
<
any
>
;
private
TotalStudentsSub
:
Subscription
;
private
showLoader
:
BehaviorSubject
<
boolean
>
;
constructor
(
private
_ata
:
LoginInfoActions
,
private
_hds
:
HelperDataService
,
private
_csa
:
SectorCoursesActions
,
...
...
@@ -53,6 +58,8 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this
.
modalTitle
=
new
BehaviorSubject
(
""
);
this
.
modalText
=
new
BehaviorSubject
(
""
);
this
.
modalHeader
=
new
BehaviorSubject
(
""
);
this
.
TotalStudents$
=
new
BehaviorSubject
([{}]);
this
.
showLoader
=
new
BehaviorSubject
(
false
);
};
...
...
@@ -66,11 +73,29 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this
.
cuName
=
loginInfoToken
.
cu_name
;
return
loginInfoToken
;
},
{});
this
.
showLoader
.
next
(
true
);
this
.
TotalStudentsSub
=
this
.
_hds
.
findTotalStudents
().
subscribe
(
x
=>
{
this
.
TotalStudents$
.
next
(
x
);
this
.
showLoader
.
next
(
false
);
},
error
=>
{
this
.
TotalStudents$
.
next
([{}]);
console
.
log
(
"
Error Getting courses perSchool
"
);
this
.
showLoader
.
next
(
false
);
});
}
return
state
.
loginInfo
;
}).
subscribe
(
this
.
loginInfo$
);
}
ngOnDestroy
()
{
...
...
source/services/helper-data-service.ts
View file @
a5b45a86
...
...
@@ -1010,4 +1010,22 @@ export class HelperDataService implements OnInit, OnDestroy {
}
findTotalStudents
()
{
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/totalstudent`
,
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