Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
e-epal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
050610d3
Commit
050610d3
authored
Mar 09, 2017
by
Open Source Developer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userdata
parent
ed2b052e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
79 additions
and
46 deletions
+79
-46
drupal/modules/epal/epal.routing.yml
drupal/modules/epal/epal.routing.yml
+4
-2
drupal/modules/epal/src/Controller/CurrentUser.php
drupal/modules/epal/src/Controller/CurrentUser.php
+17
-17
source/actions/index.ts
source/actions/index.ts
+3
-1
source/components/home.ts
source/components/home.ts
+20
-4
source/components/navbar/navbar.component.html
source/components/navbar/navbar.component.html
+2
-2
source/components/navbar/navbar.component.ts
source/components/navbar/navbar.component.ts
+6
-11
source/constants.ts
source/constants.ts
+4
-0
source/services/helper-data-service.ts
source/services/helper-data-service.ts
+17
-7
source/store/logininfo/logininfo.reducer.ts
source/store/logininfo/logininfo.reducer.ts
+1
-1
source/store/logininfo/logininfo.transformers.ts
source/store/logininfo/logininfo.transformers.ts
+1
-1
source/store/logininfo/logininfo.types.ts
source/store/logininfo/logininfo.types.ts
+1
-0
source/store/store.ts
source/store/store.ts
+3
-0
No files found.
drupal/modules/epal/epal.routing.yml
View file @
050610d3
...
@@ -23,8 +23,10 @@ epal_auth_test:
...
@@ -23,8 +23,10 @@ epal_auth_test:
_permission
:
'
access
content'
_permission
:
'
access
content'
_user_is_logged_in
:
'
TRUE'
_user_is_logged_in
:
'
TRUE'
current_user
:
current_user
:
path
:
'
/epal/curuser'
path
:
'
/epal/curuser/{token_name}'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
defaults
:
_controller
:
'
\Drupal\epal\Controller\CurrentUser::content'
_controller
:
'
\Drupal\epal\Controller\CurrentUser::content'
requirements
:
requirements
:
_access
:
'
TRUE'
_user_is_logged_in
:
'
TRUE'
drupal/modules/epal/src/Controller/CurrentUser.php
View file @
050610d3
...
@@ -4,6 +4,10 @@
...
@@ -4,6 +4,10 @@
* Contains \Drupal\query_example\Controller\QueryExampleController.
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
*/
namespace
Drupal\epal\Controller
;
namespace
Drupal\epal\Controller
;
use
Drupal\Core\Entity\Query\QueryFactory
;
use
Drupal\Core\Entity\Query\QueryFactory
;
...
@@ -13,26 +17,22 @@ use Symfony\Component\HttpFoundation\JsonResponse;
...
@@ -13,26 +17,22 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Controller\ControllerBase
;
class
CurrentUser
extends
ControllerBase
{
class
CurrentUser
extends
ControllerBase
{
public
function
content
()
{
public
function
content
(
$token_name
)
{
$query
=
\
Drupal
::
database
()
->
select
(
'epal_users'
,
'nfd'
);
$query
->
fields
(
'nfd'
,
[
'name'
]);
// $name = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$query
->
condition
(
'nfd.authtoken'
,
$token_name
);
$name
=
"LALALA"
;
$field
=
$query
->
execute
()
->
fetchAssoc
();
$authToken
=
"no authToken"
;
$accessKey
=
"no accessKey"
;
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-AUTH-TOKEN'
))
{
$authToken
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-AUTH-TOKEN'
);
$response
=
new
JsonResponse
(
$field
);
}
if
(
\
Drupal
::
request
()
->
headers
->
has
(
'X-ACCESS-KEY'
))
{
$accessKey
=
\
Drupal
::
request
()
->
headers
->
get
(
'X-ACCESS-KEY'
);
}
$response
=
new
JsonResponse
([
$name
]);
$response
->
headers
->
set
(
'X-AUTH-TOKEN'
,
'HELLOTOKEN'
);
return
$response
;
return
$response
;
}
}
...
...
source/actions/index.ts
View file @
050610d3
...
@@ -8,8 +8,9 @@ import { AmkaFillsActions} from './amkafill.actions';
...
@@ -8,8 +8,9 @@ import { AmkaFillsActions} from './amkafill.actions';
import
{
LoginInfoActions
}
from
'
./logininfo.actions
'
;
import
{
LoginInfoActions
}
from
'
./logininfo.actions
'
;
import
{
CriteriaActions
}
from
'
./criteria.actions
'
;
import
{
CriteriaActions
}
from
'
./criteria.actions
'
;
const
ACTION_PROVIDERS
=
[
CourseFieldsActions
,
SectorFieldsActions
,
RegionSchoolsActions
,
SectorCoursesActions
,
StudentDataFieldsActions
,
const
ACTION_PROVIDERS
=
[
CourseFieldsActions
,
SectorFieldsActions
,
RegionSchoolsActions
,
SectorCoursesActions
,
StudentDataFieldsActions
,
EpalClassesActions
,
AmkaFillsActions
,
LoginInfoActions
,
CriteriaActions
];
EpalClassesActions
,
AmkaFillsActions
,
LoginInfoActions
,
CriteriaActions
];
export
{
export
{
CourseFieldsActions
,
CourseFieldsActions
,
...
@@ -21,5 +22,6 @@ export {
...
@@ -21,5 +22,6 @@ export {
AmkaFillsActions
,
AmkaFillsActions
,
LoginInfoActions
,
LoginInfoActions
,
CriteriaActions
,
CriteriaActions
,
ACTION_PROVIDERS
,
ACTION_PROVIDERS
,
};
};
source/components/home.ts
View file @
050610d3
...
@@ -5,6 +5,7 @@ import { ILoginInfo } from '../store/logininfo/logininfo.types';
...
@@ -5,6 +5,7 @@ import { ILoginInfo } from '../store/logininfo/logininfo.types';
import
{
NgRedux
,
select
}
from
'
ng2-redux
'
;
import
{
NgRedux
,
select
}
from
'
ng2-redux
'
;
import
{
Observable
}
from
'
rxjs/Rx
'
;
import
{
Observable
}
from
'
rxjs/Rx
'
;
import
{
IAppState
}
from
'
../store/store
'
;
import
{
IAppState
}
from
'
../store/store
'
;
import
{
HelperDataService
}
from
'
../services/helper-data-service
'
;
import
{
import
{
FormBuilder
,
FormBuilder
,
FormGroup
,
FormGroup
,
...
@@ -26,6 +27,9 @@ import { AppSettings } from '../app.settings';
...
@@ -26,6 +27,9 @@ import { AppSettings } from '../app.settings';
<div class="col-md-6">
<div class="col-md-6">
{{loginInfoToken$.auth_role}}
{{loginInfoToken$.auth_role}}
</div>
</div>
<div>
{{loginInfoToken$.cu_name}}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="row">
...
@@ -57,14 +61,17 @@ export default class Home implements OnInit {
...
@@ -57,14 +61,17 @@ export default class Home implements OnInit {
public
formGroup
:
FormGroup
;
public
formGroup
:
FormGroup
;
private
authToken
:
string
;
private
authToken
:
string
;
private
authRole
:
string
;
private
authRole
:
string
;
private
name
:
any
;
private
loginInfo$
:
Observable
<
ILoginInfo
>
;
private
loginInfo$
:
Observable
<
ILoginInfo
>
;
constructor
(
private
fb
:
FormBuilder
,
constructor
(
private
fb
:
FormBuilder
,
private
_ata
:
LoginInfoActions
,
private
_ata
:
LoginInfoActions
,
private
_ngRedux
:
NgRedux
<
IAppState
>
,
private
_ngRedux
:
NgRedux
<
IAppState
>
,
private
activatedRoute
:
ActivatedRoute
private
activatedRoute
:
ActivatedRoute
,
private
_hds
:
HelperDataService
,
)
{
)
{
this
.
authToken
=
''
;
this
.
authToken
=
''
;
this
.
authRole
=
''
;
this
.
authRole
=
''
;
this
.
name
=
''
;
this
.
formGroup
=
this
.
fb
.
group
({
this
.
formGroup
=
this
.
fb
.
group
({
Username
:
[],
Username
:
[],
Paswd
:
[]
Paswd
:
[]
...
@@ -77,19 +84,28 @@ export default class Home implements OnInit {
...
@@ -77,19 +84,28 @@ export default class Home implements OnInit {
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
name
=
loginInfoToken
.
cu_name
;
return
loginInfoToken
;
return
loginInfoToken
;
},
{});
},
{});
}
}
return
state
.
loginInfo
;
return
state
.
loginInfo
;
});
});
this
.
_hds
.
getCurrentUser
(
this
.
authToken
).
then
(
cu_name
=>
{
return
this
.
_ngRedux
.
dispatch
({
type
:
"
aaaaaa
"
,
payload
:
{
cu_name
}
});
});
// subscribe to router event
// subscribe to router event
this
.
activatedRoute
.
queryParams
.
subscribe
((
params
:
Params
)
=>
{
this
.
activatedRoute
.
queryParams
.
subscribe
((
params
:
Params
)
=>
{
this
.
authToken
=
params
[
'
auth_token
'
];
this
.
authToken
=
params
[
'
auth_token
'
];
this
.
authRole
=
params
[
'
auth_role
'
];
this
.
authRole
=
params
[
'
auth_role
'
];
if
(
this
.
authToken
&&
this
.
authRole
)
if
(
this
.
authToken
&&
this
.
authRole
)
this
.
_ata
.
saveLoginInfo
({
auth_token
:
this
.
authToken
,
auth_role
:
this
.
authRole
});
this
.
_ata
.
saveLoginInfo
({
auth_token
:
this
.
authToken
,
auth_role
:
this
.
authRole
,
cu_name
:
this
.
name
});
// console.log(this.authToken
);
// console.log(this.authToken,"token"
);
});
});
}
}
...
...
source/components/navbar/navbar.component.html
View file @
050610d3
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
</a>
</a>
<div
class=
"collapse navbar-collapse flex-row-reverse"
id=
"navbarNav"
>
<div
class=
"collapse navbar-collapse flex-row-reverse"
id=
"navbarNav"
>
<ul
class=
"navbar-nav"
>
<ul
class=
"navbar-nav"
>
<b>
Όνομα Χρήστη:
</b>
{{this.cuser}}
<!--
<!--
<li class="nav-item" [ngClass]="{active: path=='application-preview'}">
<li class="nav-item" [ngClass]="{active: path=='application-preview'}">
<a class="nav-link" [routerLink]="['/application-preview']" [routerLinkActive]="['active']">Προεπισκόπηση</a>
<a class="nav-link" [routerLink]="['/application-preview']" [routerLinkActive]="['active']">Προεπισκόπηση</a>
...
...
source/components/navbar/navbar.component.ts
View file @
050610d3
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
HelperDataService
}
from
'
../../services/helper-data-service
'
;
@
Component
({
@
Component
({
selector
:
'
reg-navbar
'
,
selector
:
'
reg-navbar
'
,
...
@@ -9,22 +12,14 @@ import { HelperDataService } from '../../services/helper-data-service';
...
@@ -9,22 +12,14 @@ import { HelperDataService } from '../../services/helper-data-service';
@
Injectable
()
export
default
class
NavbarComponent
implements
OnInit
{
@
Injectable
()
export
default
class
NavbarComponent
implements
OnInit
{
public
cuser
:
any
;
constructor
(
private
_hds
:
HelperDataService
)
{
};
ngOnInit
()
{
ngOnInit
()
{
this
.
_hds
.
getCurrentUser
().
then
(
cuser
=>
this
.
cuser
=
cuser
);
}
}
}
}
source/constants.ts
View file @
050610d3
...
@@ -18,6 +18,10 @@ export const EPALCLASSES_SAVE = 'EPALCLASSES_SAVE';
...
@@ -18,6 +18,10 @@ export const EPALCLASSES_SAVE = 'EPALCLASSES_SAVE';
export
const
AMKAFILL_SAVE
=
'
AMKAFILL_SAVE
'
;
export
const
AMKAFILL_SAVE
=
'
AMKAFILL_SAVE
'
;
export
const
LOGININFO_SAVE
=
'
LOGININFO_SAVE
'
;
export
const
LOGININFO_SAVE
=
'
LOGININFO_SAVE
'
;
export
const
LOGININFO_RECEIVED
=
'
LOGININFO_RECEIVED
'
;
export
const
USERINFOS_RECEIVED
=
'
USERINFOS_RECEIVED
'
;
export
const
USERINFO_SELECTED_SAVE
=
'
USERINFO_SELECTED_SAVE
'
;
export
const
CRITERIA_SAVE
=
'
CRITERIA_SAVE
'
;
export
const
CRITERIA_SAVE
=
'
CRITERIA_SAVE
'
;
...
...
source/services/helper-data-service.ts
View file @
050610d3
...
@@ -12,6 +12,7 @@ import { NgRedux, select } from 'ng2-redux';
...
@@ -12,6 +12,7 @@ import { NgRedux, select } from 'ng2-redux';
import
{
IAppState
}
from
'
../store/store
'
;
import
{
IAppState
}
from
'
../store/store
'
;
import
{
ILoginInfo
}
from
'
../store/logininfo/logininfo.types
'
;
import
{
ILoginInfo
}
from
'
../store/logininfo/logininfo.types
'
;
const
HEADER
=
{
headers
:
new
Headers
({
'
Content-Type
'
:
'
application/json
'
})
};
const
HEADER
=
{
headers
:
new
Headers
({
'
Content-Type
'
:
'
application/json
'
})
};
@
Injectable
()
@
Injectable
()
...
@@ -232,20 +233,29 @@ export class HelperDataService {
...
@@ -232,20 +233,29 @@ export class HelperDataService {
getCurrentUser
()
{
getCurrentUser
(
oauthtoken
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
oauthtoken
,
"
tokenlalalala
"
);
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/curuser`
)
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
http
.
get
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/curuser/
${
oauthtoken
}
`
)
.
map
(
response
=>
response
.
json
())
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
.
subscribe
(
data
=>
{
resolve
(
data
);
resolve
(
data
);
},
},
// put the data returned from the server in our variable
error
=>
{
error
=>
{
console
.
log
(
"
Error HTTP GET Service
"
);
console
.
log
(
"
Error HTTP GET Service
"
);
// in case of failure show this message
reject
(
"
Error HTTP GET Service
"
);
reject
(
"
Error HTTP GET Service
"
);
},
},
()
=>
console
.
log
(
"
Course
Fields Received
"
));
()
=>
console
.
log
(
"
Sector
Fields Received
"
));
});
});
};
}
...
...
source/store/logininfo/logininfo.reducer.ts
View file @
050610d3
...
@@ -10,7 +10,7 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
...
@@ -10,7 +10,7 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
LOGININFO_SAVE
:
case
LOGININFO_SAVE
:
let
loginInfoTokens
=
Array
<
ILoginInfoToken
>
();
let
loginInfoTokens
=
Array
<
ILoginInfoToken
>
();
loginInfoTokens
.
push
(
<
ILoginInfoToken
>
{
auth_token
:
action
.
payload
.
loginInfo
.
auth_token
,
auth_role
:
action
.
payload
.
loginInfo
.
auth_role
});
loginInfoTokens
.
push
(
<
ILoginInfoToken
>
{
auth_token
:
action
.
payload
.
loginInfo
.
auth_token
,
auth_role
:
action
.
payload
.
loginInfo
.
auth_role
,
cu_name
:
action
.
payload
.
loginInfo
.
cu_name
});
return
Seq
(
loginInfoTokens
).
map
(
n
=>
n
).
toList
();
return
Seq
(
loginInfoTokens
).
map
(
n
=>
n
).
toList
();
default
:
default
:
return
state
;
return
state
;
...
...
source/store/logininfo/logininfo.transformers.ts
View file @
050610d3
...
@@ -3,7 +3,7 @@ import { ILoginInfo, ILoginInfoToken } from './logininfo.types';
...
@@ -3,7 +3,7 @@ import { ILoginInfo, ILoginInfoToken } from './logininfo.types';
export
function
deimmutifyLoginInfo
(
state
:
ILoginInfo
):
ILoginInfoToken
[]
{
export
function
deimmutifyLoginInfo
(
state
:
ILoginInfo
):
ILoginInfoToken
[]
{
let
fetchedLoginInfoTokens
=
new
Array
();
let
fetchedLoginInfoTokens
=
new
Array
();
state
.
forEach
(
loginInfoToken
=>
{
state
.
forEach
(
loginInfoToken
=>
{
fetchedLoginInfoTokens
.
push
(
<
ILoginInfoToken
>
{
auth_token
:
loginInfoToken
.
auth_token
,
auth_role
:
loginInfoToken
.
auth_role
});
fetchedLoginInfoTokens
.
push
(
<
ILoginInfoToken
>
{
auth_token
:
loginInfoToken
.
auth_token
,
auth_role
:
loginInfoToken
.
auth_role
,
cu_name
:
loginInfoToken
.
cu_name
});
});
});
return
fetchedLoginInfoTokens
;
return
fetchedLoginInfoTokens
;
};
};
source/store/logininfo/logininfo.types.ts
View file @
050610d3
...
@@ -3,6 +3,7 @@ import { List } from 'immutable';
...
@@ -3,6 +3,7 @@ import { List } from 'immutable';
export
interface
ILoginInfoToken
{
export
interface
ILoginInfoToken
{
auth_token
:
string
;
auth_token
:
string
;
auth_role
:
string
;
auth_role
:
string
;
cu_name
:
string
;
}
}
export
type
ILoginInfo
=
List
<
ILoginInfoToken
>
;
export
type
ILoginInfo
=
List
<
ILoginInfoToken
>
;
source/store/store.ts
View file @
050610d3
...
@@ -23,6 +23,7 @@ export interface IAppState {
...
@@ -23,6 +23,7 @@ export interface IAppState {
amkafills
?:
amkafills
.
IAmkaFills
;
amkafills
?:
amkafills
.
IAmkaFills
;
loginInfo
?:
loginInfo
.
ILoginInfo
;
loginInfo
?:
loginInfo
.
ILoginInfo
;
criter
?:
criter
.
ICriter
;
criter
?:
criter
.
ICriter
;
};
};
export
const
rootReducer
=
combineReducers
<
IAppState
>
({
export
const
rootReducer
=
combineReducers
<
IAppState
>
({
...
@@ -35,6 +36,7 @@ export const rootReducer = combineReducers<IAppState>({
...
@@ -35,6 +36,7 @@ export const rootReducer = combineReducers<IAppState>({
amkafills
:
amkafills
.
amkafillReducer
,
amkafills
:
amkafills
.
amkafillReducer
,
loginInfo
:
loginInfo
.
loginInfoReducer
,
loginInfo
:
loginInfo
.
loginInfoReducer
,
criter
:
criter
.
criteriaReducer
,
criter
:
criter
.
criteriaReducer
,
});
});
export
function
deimmutify
(
state
:
IAppState
):
Object
{
export
function
deimmutify
(
state
:
IAppState
):
Object
{
...
@@ -48,6 +50,7 @@ export function deimmutify(state: IAppState): Object {
...
@@ -48,6 +50,7 @@ export function deimmutify(state: IAppState): Object {
amkafills
:
amkafills
.
deimmutifyAmkaFills
(
state
.
amkafills
),
amkafills
:
amkafills
.
deimmutifyAmkaFills
(
state
.
amkafills
),
loginInfo
:
loginInfo
.
deimmutifyLoginInfo
(
state
.
loginInfo
),
loginInfo
:
loginInfo
.
deimmutifyLoginInfo
(
state
.
loginInfo
),
criter
:
criter
.
deimmutifyCriteria
(
state
.
criter
),
criter
:
criter
.
deimmutifyCriteria
(
state
.
criter
),
};
};
}
}
...
...
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