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
1824bfcf
Commit
1824bfcf
authored
Apr 14, 2017
by
Νίκος Κατσαούνος
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://git.minedu.gov.gr/itminedu/e-epal
into component_updates
parents
cdd54b2f
47574dda
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
446 additions
and
354 deletions
+446
-354
drupal/modules/epal/src/Controller/DirectorView.php
drupal/modules/epal/src/Controller/DirectorView.php
+2
-3
source/app.ts
source/app.ts
+6
-0
source/components/director/director-view.ts
source/components/director/director-view.ts
+122
-105
source/components/navbar/navbar.component.html
source/components/navbar/navbar.component.html
+2
-2
source/components/school.home.ts
source/components/school.home.ts
+1
-1
source/constants.ts
source/constants.ts
+3
-0
source/containers/main.routes.ts
source/containers/main.routes.ts
+17
-15
source/guards/school.auth.guard.ts
source/guards/school.auth.guard.ts
+14
-0
source/guards/student.auth.guard.ts
source/guards/student.auth.guard.ts
+14
-0
source/services/auth.service.ts
source/services/auth.service.ts
+44
-0
source/services/helper-data-service.ts
source/services/helper-data-service.ts
+221
-228
No files found.
drupal/modules/epal/src/Controller/DirectorView.php
View file @
1824bfcf
...
...
@@ -219,9 +219,8 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
,
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"No students found!!!"
),
],
Response
::
HTTP_OK
);
$list
=
array
();
return
$this
->
respondWithStatus
(
$list
,
Response
::
HTTP_OK
);
}
...
...
source/app.ts
View file @
1824bfcf
...
...
@@ -27,6 +27,9 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
/* Here we import services */
import
{
HelperDataService
}
from
'
./services/helper-data-service
'
;
import
{
LoaderService
}
from
'
./services/Spinner.service
'
;
import
{
AuthService
}
from
'
./services/auth.service
'
;
import
SchoolAuthGuard
from
'
./guards/school.auth.guard
'
;
import
StudentAuthGuard
from
'
./guards/student.auth.guard
'
;
import
{
ACTION_PROVIDERS
}
from
'
./actions
'
;
import
Home
from
'
./components/home
'
;
...
...
@@ -76,6 +79,9 @@ class MyLocalization extends NgLocalization {
//Service1, again services here
HelperDataService
,
LoaderService
,
AuthService
,
SchoolAuthGuard
,
StudentAuthGuard
]
})
class
AppModule
{}
...
...
source/components/director/director-view.ts
View file @
1824bfcf
import
{
Component
,
OnInit
,
OnDestroy
,
ElementRef
,
ViewChild
}
from
"
@angular/core
"
;
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
'
;
...
...
@@ -44,7 +44,7 @@ import {
Αναζήτηση
</button>
<div *ngIf="(retrievedStudent | async)">
<div *ngFor="let StudentDetails$ of StudentInfo$ | async">
<div *ngFor="let StudentDetails$ of StudentInfo$ | async
; let i=index
">
<br>
<br>
Όνομα: {{StudentDetails$.name}} <br>
...
...
@@ -58,7 +58,7 @@ import {
<strong>Επιβεβαίωση Εγγραφής: </strong>
<input #cb class="pull-right" type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
</div
>
<!-- </div> --
>
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()">
Επιβεβαίωση Εγγραφής
...
...
@@ -66,7 +66,7 @@ import {
`
})
@
Injectable
()
export
default
class
DirectorView
implements
OnInit
,
OnDestroy
{
@
Injectable
()
export
default
class
DirectorView
implements
OnInit
,
OnDestroy
{
public
formGroup
:
FormGroup
;
private
StudentSelected$
:
BehaviorSubject
<
any
>
;
...
...
@@ -78,32 +78,30 @@ import {
private
retrievedStudent
:
BehaviorSubject
<
boolean
>
;
private
selectionBClass
:
BehaviorSubject
<
boolean
>
;
private
selectionCClass
:
BehaviorSubject
<
boolean
>
;
private
SchoolId
=
147
;
private
SchoolId
=
147
;
private
currentclass
:
Number
;
private
saved
:
Array
<
number
>
=
new
Array
();
constructor
(
private
fb
:
FormBuilder
,
private
_hds
:
HelperDataService
,
private
activatedRoute
:
ActivatedRoute
,
private
router
:
Router
)
{
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
StudentInfo$
=
new
BehaviorSubject
([{}]);
this
.
retrievedStudent
=
new
BehaviorSubject
(
false
);
this
.
selectionBClass
=
new
BehaviorSubject
(
false
);
this
.
selectionCClass
=
new
BehaviorSubject
(
false
);
this
.
formGroup
=
this
.
fb
.
group
({
tomeas
:
[
''
,
[]],
taxi
:
[
''
,
[]],
specialit
:
[
''
,
[]],
});
private
saved
:
Array
<
number
>
=
new
Array
();
constructor
(
private
fb
:
FormBuilder
,
private
_hds
:
HelperDataService
,
private
activatedRoute
:
ActivatedRoute
,
private
router
:
Router
)
{
this
.
StudentSelected$
=
new
BehaviorSubject
([{}]);
this
.
StudentSelectedSpecial$
=
new
BehaviorSubject
([{}]);
this
.
StudentInfo$
=
new
BehaviorSubject
([{}]);
this
.
retrievedStudent
=
new
BehaviorSubject
(
false
);
this
.
selectionBClass
=
new
BehaviorSubject
(
false
);
this
.
selectionCClass
=
new
BehaviorSubject
(
false
);
this
.
formGroup
=
this
.
fb
.
group
({
tomeas
:
[
''
,
[]],
taxi
:
[
''
,
[]],
specialit
:
[
''
,
[]],
});
}
ngOnDestroy
()
{
ngOnDestroy
()
{
if
(
this
.
StudentSelectedSub
)
this
.
StudentSelectedSub
.
unsubscribe
();
if
(
this
.
StudentSelectedSpecialSub
)
...
...
@@ -112,7 +110,7 @@ import {
this
.
selectionBClass
.
unsubscribe
();
if
(
this
.
selectionCClass
)
this
.
selectionCClass
.
unsubscribe
();
if
(
this
.
retrievedStudent
)
if
(
this
.
retrievedStudent
)
this
.
retrievedStudent
.
unsubscribe
();
}
...
...
@@ -121,107 +119,126 @@ import {
}
verifyclass
(
txop
)
{
this
.
retrievedStudent
.
next
(
false
);
if
(
txop
.
value
===
"
1
"
)
{
this
.
selectionBClass
.
next
(
false
);
this
.
selectionCClass
.
next
(
false
);
verifyclass
(
txop
)
{
this
.
retrievedStudent
.
next
(
false
);
if
(
txop
.
value
===
"
1
"
)
{
this
.
selectionBClass
.
next
(
false
);
this
.
selectionCClass
.
next
(
false
);
}
else
if
(
txop
.
value
===
"
2
"
)
{
}
else
if
(
txop
.
value
===
"
2
"
)
{
this
.
StudentSelectedSub
=
this
.
_hds
.
getSectorPerSchool
(
this
.
SchoolId
).
subscribe
(
data
=>
{
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
false
);
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
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
this
.
StudentSelectedSpecial$
);
}
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
true
);
this
.
StudentSelectedSub
=
this
.
_hds
.
getSectorPerSchool
(
this
.
SchoolId
).
subscribe
(
this
.
StudentSelected$
);
this
.
StudentSelected$
.
next
(
data
);
},
error
=>
{
this
.
StudentSelected$
.
next
([{}]);
console
.
log
(
"
Error Getting StudentSelectedSpecial
"
);
},
()
=>
console
.
log
(
"
Getting StudentSelectedSpecial
"
));
}
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
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
data
=>
{
this
.
StudentSelectedSpecial$
.
next
(
data
);
},
error
=>
{
this
.
StudentSelectedSpecial$
.
next
([{}]);
console
.
log
(
"
Error Getting StudentSelectedSpecial
"
);
},
()
=>
console
.
log
(
"
Getting StudentSelectedSpecial
"
));
}
this
.
StudentSelectedSub
=
this
.
_hds
.
getSectorPerSchool
(
this
.
SchoolId
).
subscribe
(
data
=>
{
this
.
StudentSelected$
.
next
(
data
);
this
.
selectionBClass
.
next
(
true
);
this
.
selectionCClass
.
next
(
true
);
},
error
=>
{
this
.
StudentSelected$
.
next
([{}]);
console
.
log
(
"
Error Getting StudentSelected
"
);
},
()
=>
console
.
log
(
"
Getting StudentSelected
"
));
}
}
checkbclass
(
tmop
,
txop
)
{
checkbclass
(
tmop
,
txop
)
{
this
.
retrievedStudent
.
next
(
false
);
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$
);
console
.
log
(
sectorint
,
"
tomeas
"
);
if
(
txop
.
value
===
"
3
"
)
{
// this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this
.
StudentSelectedSpecialSub
=
this
.
_hds
.
getSpecialityPerSchool
(
this
.
SchoolId
,
sectorint
).
subscribe
(
data
=>
{
this
.
StudentSelectedSpecial$
.
next
(
data
);
},
error
=>
{
this
.
StudentSelectedSpecial$
.
next
([{}]);
console
.
log
(
"
Error Getting StudentSelectedSpecial
"
);
},
()
=>
console
.
log
(
"
Getting StudentSelectedSpecial
"
));
}
}
findstudent
(
txop
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
if
(
txop
.
value
===
"
1
"
)
{
this
.
currentclass
=
1
;
}
else
if
(
txop
.
value
===
"
2
"
)
{
this
.
currentclass
=
2
;
}
else
if
(
txop
.
value
===
"
3
"
)
{
this
.
currentclass
=
3
;
}
this
.
retrievedStudent
.
next
(
true
);
this
.
StudentInfo$
=
new
BehaviorSubject
(
false
);
this
.
StudentInfoSub
=
this
.
_hds
.
getStudentPerSchool
(
this
.
SchoolId
,
sectorint
,
this
.
currentclass
).
subscribe
(
this
.
StudentInfo$
);
findstudent
(
txop
)
{
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
if
(
txop
.
value
===
"
1
"
)
{
this
.
currentclass
=
1
;
}
else
if
(
txop
.
value
===
"
2
"
)
{
this
.
currentclass
=
2
;
}
else
if
(
txop
.
value
===
"
3
"
)
{
this
.
currentclass
=
3
;
}
// this.StudentInfo$ = new BehaviorSubject([{}]);
// this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(this.StudentInfo$);
this
.
StudentInfoSub
=
this
.
_hds
.
getStudentPerSchool
(
this
.
SchoolId
,
sectorint
,
this
.
currentclass
).
subscribe
(
data
=>
{
this
.
StudentInfo$
.
next
(
data
);
this
.
retrievedStudent
.
next
(
true
);
},
error
=>
{
this
.
StudentInfo$
.
next
([{}]);
console
.
log
(
"
Error Getting Students
"
);
},
()
=>
console
.
log
(
"
Getting Students
"
));
}
updateCheckedOptions
(
id
,
event
)
{
updateCheckedOptions
(
id
,
event
)
{
let
i
=
this
.
saved
.
length
;
let
i
=
this
.
saved
.
length
;
if
(
event
.
target
.
checked
===
false
)
{
var
count
=
this
.
saved
.
length
;
for
(
var
j
=
0
;
j
<
count
;
j
++
)
{
if
(
this
.
saved
[
j
]
===
id
)
{
this
.
saved
.
splice
(
j
,
1
);
if
(
event
.
target
.
checked
===
false
)
{
var
count
=
this
.
saved
.
length
;
for
(
var
j
=
0
;
j
<
count
;
j
++
)
{
if
(
this
.
saved
[
j
]
===
id
)
{
this
.
saved
.
splice
(
j
,
1
);
}
}
}
else
{
this
.
saved
[
i
]
=
id
;
}
}
}
else
{
this
.
saved
[
i
]
=
id
;
}
}
}
confirmStudent
()
{
this
.
_hds
.
saveConfirmStudents
(
this
.
saved
);
}
confirmStudent
()
{
this
.
_hds
.
saveConfirmStudents
(
this
.
saved
);
}
checkcclass
()
{
this
.
retrievedStudent
.
next
(
false
);
}
checkcclass
()
{
this
.
retrievedStudent
.
next
(
false
);
}
}
source/components/navbar/navbar.component.html
View file @
1824bfcf
...
...
@@ -22,8 +22,8 @@
<div
*ngIf=
"(loginInfo$ | async).size > 0"
class=
"pull-right"
class=
"nav-item"
[ngClass]=
"{active: path=='submited-preview'}"
>
<a
class=
"nav-link"
[routerLink]=
"['/submited-preview']"
[routerLinkActive]=
"['active']"
><b>
Υποβληθείσες αιτήσεις
</b></a>
<a
class=
"nav-link"
[routerLink]=
"['/director-view']"
[routerLinkActive]=
"['active']"
><b>
Επιλεχθέντες Μαθητές
</b></a>
<a
class=
"nav-link"
[routerLink]=
"['/director-classcapacity']"
[routerLinkActive]=
"['active']"
><b>
Δυναμική Σχολείου
</b></a>
<a
class=
"nav-link"
[routerLink]=
"['/
school/
director-view']"
[routerLinkActive]=
"['active']"
><b>
Επιλεχθέντες Μαθητές
</b></a>
<a
class=
"nav-link"
[routerLink]=
"['/
school/
director-classcapacity']"
[routerLinkActive]=
"['active']"
><b>
Δυναμική Σχολείου
</b></a>
</div>
</ul>
...
...
source/components/school.home.ts
View file @
1824bfcf
...
...
@@ -65,7 +65,7 @@ export default class SchoolHome implements OnInit {
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
if
(
this
.
authToken
&&
this
.
authToken
.
length
>
0
)
this
.
router
.
navigate
([
'
/director-view
'
]);
this
.
router
.
navigate
([
'
/
school/
director-view
'
]);
return
loginInfoToken
;
},
{});
}
...
...
source/constants.ts
View file @
1824bfcf
...
...
@@ -47,3 +47,6 @@ export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{
//DD-MM-YYYY
export
const
VALID_DATE_PATTERN
=
'
([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.](19|20)[0-9][0-9]
'
;
export
const
SCHOOL_ROLE
=
'
director
'
;
export
const
STUDENT_ROLE
=
'
student
'
;
source/containers/main.routes.ts
View file @
1824bfcf
...
...
@@ -22,25 +22,27 @@ import SubmitedPreview from '../components/student-application-form/submited.apl
import
SubmitedPerson
from
'
../components/student-application-form/submitedstudent.preview
'
;
import
DirectorView
from
'
../components/director/director-view
'
;
import
DirectorClassCapacity
from
'
../components/director/director-classcapacity
'
;
import
SchoolAuthGuard
from
'
../guards/school.auth.guard
'
;
import
StudentAuthGuard
from
'
../guards/student.auth.guard
'
;
export
const
MainRoutes
:
Routes
=
[
{
path
:
''
,
component
:
Home
},
{
path
:
'
school
'
,
component
:
SchoolHome
},
{
path
:
'
parent-form
'
,
component
:
ParentForm
},
{
path
:
'
student-application-form-main
'
,
component
:
StudentApplicationMain
},
{
path
:
'
students-list
'
,
component
:
StudentsList
},
{
path
:
'
course-fields-select
'
,
component
:
CourseFieldsSelect
},
{
path
:
'
epal-class-select
'
,
component
:
EpalClassesSelect
},
{
path
:
'
sector-fields-select
'
,
component
:
SectorFieldsSelect
},
{
path
:
'
region-schools-select
'
,
component
:
RegionSchoolsSelect
},
{
path
:
'
sectorcourses-fields-select
'
,
component
:
SectorCoursesSelect
},
{
path
:
'
application-preview
'
,
component
:
ApplicationPreview
},
{
path
:
'
schools-order-select
'
,
component
:
SchoolsOrderSelect
},
{
path
:
'
application-submit
'
,
component
:
ApplicationSubmit
},
{
path
:
'
submited-preview
'
,
component
:
SubmitedPreview
},
{
path
:
'
submited-person
'
,
component
:
SubmitedPerson
},
{
path
:
'
director-view
'
,
component
:
DirectorView
},
{
path
:
'
director-classcapacity
'
,
component
:
DirectorClassCapacity
},
{
path
:
'
parent-form
'
,
component
:
ParentForm
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
student-application-form-main
'
,
component
:
StudentApplicationMain
,
canActivate
:
[
StudentAuthGuard
]
},
//
{ path: 'students-list', component: StudentsList },
{
path
:
'
course-fields-select
'
,
component
:
CourseFieldsSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
epal-class-select
'
,
component
:
EpalClassesSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
sector-fields-select
'
,
component
:
SectorFieldsSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
region-schools-select
'
,
component
:
RegionSchoolsSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
sectorcourses-fields-select
'
,
component
:
SectorCoursesSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
application-preview
'
,
component
:
ApplicationPreview
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
schools-order-select
'
,
component
:
SchoolsOrderSelect
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
application-submit
'
,
component
:
ApplicationSubmit
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
submited-preview
'
,
component
:
SubmitedPreview
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
submited-person
'
,
component
:
SubmitedPerson
,
canActivate
:
[
StudentAuthGuard
]
},
{
path
:
'
school/director-view
'
,
component
:
DirectorView
,
canActivate
:
[
SchoolAuthGuard
]
},
{
path
:
'
school/director-classcapacity
'
,
component
:
DirectorClassCapacity
,
canActivate
:
[
SchoolAuthGuard
]
},
];
export
const
MainDeclarations
=
[
...
...
source/guards/school.auth.guard.ts
0 → 100644
View file @
1824bfcf
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
CanActivate
}
from
'
@angular/router
'
;
import
{
AuthService
}
from
'
../services/auth.service
'
;
import
{
SCHOOL_ROLE
}
from
'
../constants
'
;
@
Injectable
()
export
default
class
SchoolAuthGuard
implements
CanActivate
{
constructor
(
private
authService
:
AuthService
)
{}
canActivate
()
{
return
this
.
authService
.
isLoggedIn
(
SCHOOL_ROLE
).
then
(
loggedIn
=>
{
return
loggedIn
;}).
catch
(
err
=>
{
return
false
;});
}
}
source/guards/student.auth.guard.ts
0 → 100644
View file @
1824bfcf
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
CanActivate
}
from
'
@angular/router
'
;
import
{
AuthService
}
from
'
../services/auth.service
'
;
import
{
STUDENT_ROLE
}
from
'
../constants
'
;
@
Injectable
()
export
default
class
StudentAuthGuard
implements
CanActivate
{
constructor
(
private
authService
:
AuthService
)
{}
canActivate
()
{
return
this
.
authService
.
isLoggedIn
(
STUDENT_ROLE
).
then
(
loggedIn
=>
{
return
loggedIn
;}).
catch
(
err
=>
{
return
false
;});
}
}
source/services/auth.service.ts
0 → 100644
View file @
1824bfcf
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
BehaviorSubject
}
from
"
rxjs/Rx
"
;
import
'
rxjs/add/operator/map
'
;
import
{
AppSettings
}
from
'
../app.settings
'
;
import
{
NgRedux
,
select
}
from
'
ng2-redux
'
;
import
{
IAppState
}
from
'
../store/store
'
;
import
{
ILoginInfo
,
ILoginInfoToken
}
from
'
../store/logininfo/logininfo.types
'
;
import
{
LOGININFO_INITIAL_STATE
}
from
'
../store/logininfo/logininfo.initial-state
'
;
@
Injectable
()
export
class
AuthService
{
constructor
(
private
_ngRedux
:
NgRedux
<
IAppState
>
)
{
};
isLoggedIn
(
role
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
_ngRedux
.
select
(
state
=>
{
return
state
.
loginInfo
;
}).
subscribe
(
loginInfo
=>
{
if
(
loginInfo
.
size
>
0
)
{
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
if
(
loginInfoToken
.
auth_token
&&
loginInfoToken
.
auth_token
.
length
>
0
&&
loginInfoToken
.
auth_role
===
role
)
{
resolve
(
true
);
}
else
{
resolve
(
false
);
}
return
loginInfoToken
;
},
{});
}
else
resolve
(
false
);
},
error
=>
{
console
.
log
(
"
Error Sending Verification Code
"
);
reject
(
"
Error Getting Auth Data
"
);
},
()
=>
console
.
log
(
"
Getting Auth Data
"
));
});
}
}
source/services/helper-data-service.ts
View file @
1824bfcf
...
...
@@ -17,7 +17,7 @@ import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-st
const
HEADER
=
{
headers
:
new
Headers
({
'
Content-Type
'
:
'
application/json
'
})
};
@
Injectable
()
export
class
HelperDataService
implements
OnInit
,
OnDestroy
{
export
class
HelperDataService
implements
OnInit
,
OnDestroy
{
private
authToken
:
string
;
private
authRole
:
string
;
...
...
@@ -26,7 +26,7 @@ export class HelperDataService implements OnInit, OnDestroy{
constructor
(
private
http
:
Http
,
private
_ngRedux
:
NgRedux
<
IAppState
>
)
{
this
.
loginInfo$
=
new
BehaviorSubject
(
LOGININFO_INITIAL_STATE
);
this
.
loginInfo$
=
new
BehaviorSubject
(
LOGININFO_INITIAL_STATE
);
};
...
...
@@ -52,8 +52,8 @@ export class HelperDataService implements OnInit, OnDestroy{
getEpalUserData
()
{
this
.
loginInfo$
.
getValue
().
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
});
console
.
log
(
"
authToken=
"
+
this
.
authToken
);
console
.
log
(
"
authRole=
"
+
this
.
authRole
);
...
...
@@ -68,94 +68,94 @@ export class HelperDataService implements OnInit, OnDestroy{
sendVerificationCode
(
email
)
{
this
.
loginInfo$
.
getValue
().
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
});
console
.
log
(
"
authToken=
"
+
this
.
authToken
);
console
.
log
(
"
authRole=
"
+
this
.
authRole
);
let
headers
=
new
Headers
({
"
Content-Type
"
:
"
application/json
"
,
// "Accept": "*/*",
// "Access-Control-Allow-Credentials": "true",
"
Content-Type
"
:
"
application/json
"
,
// "Accept": "*/*",
// "Access-Control-Allow-Credentials": "true",
});
this
.
createAuthorizationHeader
(
headers
);
// let options = new RequestOptions({ headers: headers, withCredentials: true });
// let options = new RequestOptions({ headers: headers, withCredentials: true });
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/user/sendvercode`
,
{
userEmail
:
email
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
data
);
},
// put the data returned from the server in our variable
error
=>
{
console
.
log
(
"
Error Sending Verification Code
"
);
// in case of failure show this message
reject
(
"
Error Sending Verification Code
"
);
},
()
=>
console
.
log
(
"
Sending Verification Code
"
));
//run this code in all cases); */
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/user/sendvercode`
,
{
userEmail
:
email
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
data
);
},
// put the data returned from the server in our variable
error
=>
{
console
.
log
(
"
Error Sending Verification Code
"
);
// in case of failure show this message
reject
(
"
Error Sending Verification Code
"
);
},
()
=>
console
.
log
(
"
Sending Verification Code
"
));
//run this code in all cases); */
});
}
verifyVerificationCode
(
verificationCode
)
{
this
.
loginInfo$
.
getValue
().
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
});
console
.
log
(
"
authToken=
"
+
this
.
authToken
);
console
.
log
(
"
authRole=
"
+
this
.
authRole
);
let
headers
=
new
Headers
({
"
Content-Type
"
:
"
application/json
"
,
// "Accept": "*/*",
// "Access-Control-Allow-Credentials": "true",
"
Content-Type
"
:
"
application/json
"
,
// "Accept": "*/*",
// "Access-Control-Allow-Credentials": "true",
});
this
.
createAuthorizationHeader
(
headers
);
// let options = new RequestOptions({ headers: headers, withCredentials: true });
// let options = new RequestOptions({ headers: headers, withCredentials: true });
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
"
verificationCode=
"
+
verificationCode
);
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/user/verifyvercode`
,
{
verificationCode
:
verificationCode
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
<
any
>
data
);
},
// put the data returned from the server in our variable
error
=>
{
console
.
log
(
"
Error Verifying Verification Code
"
);
// in case of failure show this message
reject
(
"
Error Verifying Verification Code
"
);
},
()
=>
console
.
log
(
"
Verifying Verification Code
"
));
//run this code in all cases); */
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/user/verifyvercode`
,
{
verificationCode
:
verificationCode
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
<
any
>
data
);
},
// put the data returned from the server in our variable
error
=>
{
console
.
log
(
"
Error Verifying Verification Code
"
);
// in case of failure show this message
reject
(
"
Error Verifying Verification Code
"
);
},
()
=>
console
.
log
(
"
Verifying Verification Code
"
));
//run this code in all cases); */
});
}
saveProfile
(
userProfile
)
{
this
.
loginInfo$
.
getValue
().
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
this
.
authRole
=
loginInfoToken
.
auth_role
;
this
.
authToken
=
loginInfoToken
.
auth_token
;