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
f4987505
Commit
f4987505
authored
Jul 25, 2017
by
Χάρης Παπαδόπουλος
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NgRedux.select() rewrite(WIP)
parent
44065f73
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
18 deletions
+52
-18
source/components/header/header.component.ts
source/components/header/header.component.ts
+6
-2
source/components/navbar/navbar.component.ts
source/components/navbar/navbar.component.ts
+5
-3
source/components/student-application-form/after.submit.ts
source/components/student-application-form/after.submit.ts
+5
-4
source/components/student-application-form/application.submit.ts
...components/student-application-form/application.submit.ts
+36
-9
No files found.
source/components/header/header.component.ts
View file @
f4987505
...
...
@@ -38,6 +38,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
private
TotalStudentsSub
:
Subscription
;
private
showLoader
:
BehaviorSubject
<
boolean
>
;
private
hasvalue
:
boolean
;
private
loginInfoSub
:
Subscription
;
constructor
(
private
_ata
:
LoginInfoActions
,
private
_hds
:
HelperDataService
,
...
...
@@ -67,7 +68,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
ngOnInit
()
{
(
<
any
>
$
(
"
#headerNotice
"
)).
appendTo
(
"
body
"
);
this
.
_ngRedux
.
select
(
state
=>
{
this
.
loginInfoSub
=
this
.
_ngRedux
.
select
(
state
=>
{
if
(
state
.
loginInfo
.
size
>
0
)
{
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
...
...
@@ -104,7 +105,10 @@ export default class HeaderComponent implements OnInit, OnDestroy {
ngOnDestroy
()
{
(
<
any
>
$
(
"
#headerNotice
"
)).
remove
();
this
.
loginInfo$
.
unsubscribe
();
if
(
this
.
loginInfoSub
)
{
this
.
loginInfoSub
.
unsubscribe
();
}
// this.loginInfo$.unsubscribe();
}
...
...
source/components/navbar/navbar.component.ts
View file @
f4987505
...
...
@@ -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
'
@angular-redux/store
'
;
import
{
IAppState
}
from
'
../../store/store
'
;
import
{
ILoginInfo
,
ILoginInfoToken
}
from
'
../../store/logininfo/logininfo.types
'
;
...
...
@@ -22,6 +22,7 @@ import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial
private
cuName
:
string
;
private
loginInfo$
:
BehaviorSubject
<
ILoginInfo
>
;
public
cuser
:
any
;
private
loginInfoSub
:
Subscription
;
constructor
(
private
_ngRedux
:
NgRedux
<
IAppState
>
)
{
...
...
@@ -36,7 +37,7 @@ import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial
};
ngOnInit
()
{
this
.
_ngRedux
.
select
(
state
=>
{
this
.
loginInfoSub
=
this
.
_ngRedux
.
select
(
state
=>
{
if
(
state
.
loginInfo
.
size
>
0
)
{
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
...
...
@@ -60,7 +61,8 @@ import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial
}
ngOnDestroy
()
{
this
.
loginInfo$
.
unsubscribe
();
if
(
this
.
loginInfoSub
)
this
.
loginInfoSub
.
unsubscribe
();
}
...
...
source/components/student-application-form/after.submit.ts
View file @
f4987505
import
{
Router
}
from
'
@angular/router
'
;
import
{
OnInit
,
OnDestroy
,
Component
,
Injectable
}
from
'
@angular/core
'
;
import
{
HelperDataService
}
from
'
../../services/helper-data-service
'
;
import
{
BehaviorSubject
}
from
'
rxjs/Rx
'
;
import
{
BehaviorSubject
,
Subscription
}
from
'
rxjs/Rx
'
;
import
{
NgRedux
,
select
}
from
'
@angular-redux/store
'
;
import
{
IAppState
}
from
'
../../store/store
'
;
import
{
ILoginInfo
,
ILoginInfoToken
}
from
'
../../store/logininfo/logininfo.types
'
;
...
...
@@ -41,6 +41,7 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action
private
loginInfo$
:
BehaviorSubject
<
ILoginInfo
>
;
public
cuser
:
any
;
private
showLoader$
:
BehaviorSubject
<
boolean
>
;
private
loginInfoSub
:
Subscription
;
constructor
(
private
_ata
:
LoginInfoActions
,
...
...
@@ -58,7 +59,7 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action
};
ngOnInit
()
{
this
.
_ngRedux
.
select
(
state
=>
{
this
.
loginInfoSub
=
this
.
_ngRedux
.
select
(
state
=>
{
if
(
state
.
loginInfo
.
size
>
0
)
{
state
.
loginInfo
.
reduce
(({},
loginInfoToken
)
=>
{
this
.
authToken
=
loginInfoToken
.
auth_token
;
...
...
@@ -73,8 +74,8 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action
}
ngOnDestroy
()
{
if
(
this
.
loginInfo
$
)
this
.
loginInfo
$
.
unsubscribe
();
if
(
this
.
loginInfo
Sub
)
this
.
loginInfo
Sub
.
unsubscribe
();
}
...
...
source/components/student-application-form/application.submit.ts
View file @
f4987505
...
...
@@ -29,7 +29,7 @@ import { HelperDataService } from "../../services/helper-data-service";
@
Component
({
selector
:
"
application-submit
"
,
template
:
`
<div class = "loading" *ngIf="(studentDataFields$ | async).size === 0 || (
regions$ | async).size
=== 0 || (epalclasses$ | async).size === 0 || (loginInfo$ | async).size === 0 || (showLoader | async) === true"></div>
<div class = "loading" *ngIf="(studentDataFields$ | async).size === 0 || (
epalSelected$ | async).length
=== 0 || (epalclasses$ | async).size === 0 || (loginInfo$ | async).size === 0 || (showLoader | async) === true"></div>
<div id="studentFormSentNotice" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
...
@@ -117,14 +117,13 @@ import { HelperDataService } from "../../services/helper-data-service";
@
Injectable
()
export
default
class
ApplicationSubmit
implements
OnInit
{
private
authToken
;
private
epalSelected
:
Array
<
number
>
=
new
Array
(
);
private
epalSelected
$
:
BehaviorSubject
<
Array
<
number
>>
=
new
BehaviorSubject
(
new
Array
()
);
private
epalSelectedOrder
:
Array
<
number
>
=
new
Array
();
private
courseSelected
;
private
sectorSelected
;
private
classSelected
;
private
totalPoints
=
<
number
>
0
;
private
studentDataFields$
:
BehaviorSubject
<
IStudentDataFields
>
;
private
regions$
:
BehaviorSubject
<
IRegionRecords
>
;
private
sectors$
:
BehaviorSubject
<
ISectors
>
;
private
sectorFields$
:
BehaviorSubject
<
ISectorFields
>
;
private
epalclasses$
:
BehaviorSubject
<
IEpalClasses
>
;
...
...
@@ -159,7 +158,7 @@ import { HelperDataService } from "../../services/helper-data-service";
private
http
:
Http
)
{
this
.
regions$
=
new
BehaviorSubject
(
REGION_SCHOOLS_INITIAL_STATE
);
//
this.regions$ = new BehaviorSubject(REGION_SCHOOLS_INITIAL_STATE);
this
.
epalclasses$
=
new
BehaviorSubject
(
EPALCLASSES_INITIAL_STATE
);
this
.
sectors$
=
new
BehaviorSubject
(
SECTOR_COURSES_INITIAL_STATE
);
this
.
sectorFields$
=
new
BehaviorSubject
(
SECTOR_FIELDS_INITIAL_STATE
);
...
...
@@ -209,7 +208,7 @@ import { HelperDataService } from "../../services/helper-data-service";
return
state
.
studentDataFields
;
}).
subscribe
(
this
.
studentDataFields$
);
this
.
regionsSub
=
this
.
_ngRedux
.
select
(
state
=>
{
/* this.regionsSub = this._ngRedux.select((state)
=> {
console.log("SELECTOR3");
state.regions.reduce((prevRegion, region) => {
region.epals.reduce((prevEpal, epal) => {
...
...
@@ -222,7 +221,34 @@ import { HelperDataService } from "../../services/helper-data-service";
return region;
}, {});
return state.regions;
}).
subscribe
(
this
.
regions$
);
}).subscribe(this.regions$); */
this
.
regionsSub
=
this
.
_ngRedux
.
select
(
'
regions
'
).
subscribe
(
regions
=>
{
console
.
log
(
"
SELECTOR: REGIONS
"
);
let
rgns
=
<
IRegionRecords
>
regions
;
let
prevSelected
:
Array
<
number
>
=
new
Array
();
rgns
.
reduce
((
prevRgn
,
rgn
)
=>
{
rgn
.
epals
.
reduce
((
prevSchool
,
school
)
=>
{
if
(
school
.
selected
===
true
)
{
prevSelected
=
this
.
epalSelected$
.
getValue
();
prevSelected
[
prevSelected
.
length
]
=
<
number
>
parseInt
(
school
.
epal_id
);
this
.
epalSelected$
.
next
(
prevSelected
);
this
.
epalSelectedOrder
.
push
(
school
.
order_id
);
}
return
school
;
},
{});
return
rgn
;
},
{});
// this.regions$.next(<IRegionRecords>regions);
},
error
=>
{
console
.
log
(
"
Error Selecting Regions
"
);
}
);
this
.
sectorsSub
=
this
.
_ngRedux
.
select
(
state
=>
{
console
.
log
(
"
SELECTOR2
"
);
...
...
@@ -283,7 +309,7 @@ import { HelperDataService } from "../../services/helper-data-service";
// αποστολή στοιχείων μαθητή στο entity: epal_student
// let aitisiObj: Array<Student | StudentEpalChosen[] | StudentCriteriaChosen[] | StudentCourseChosen | StudentSectorChosen > = [];
if
(
this
.
studentDataFields$
.
getValue
().
size
===
0
||
this
.
regions$
.
getValue
().
size
===
0
||
this
.
epalclasses$
.
getValue
().
size
===
0
||
this
.
loginInfo$
.
getValue
().
size
===
0
)
if
(
this
.
studentDataFields$
.
getValue
().
size
===
0
||
this
.
epalSelected$
.
getValue
().
length
===
0
||
this
.
epalclasses$
.
getValue
().
size
===
0
||
this
.
loginInfo$
.
getValue
().
size
===
0
)
return
;
let
aitisiObj
:
Array
<
any
>
=
[];
...
...
@@ -319,8 +345,9 @@ import { HelperDataService } from "../../services/helper-data-service";
aitisiObj
[
0
].
disclaimer_checked
=
this
.
disclaimer_checked
;
aitisiObj
[
0
].
currentclass
=
this
.
classSelected
;
for
(
let
i
=
0
;
i
<
this
.
epalSelected
.
length
;
i
++
)
{
epalObj
[
i
]
=
new
StudentEpalChosen
(
null
,
this
.
epalSelected
[
i
],
this
.
epalSelectedOrder
[
i
]);
let
epalSelected
=
this
.
epalSelected$
.
getValue
();
for
(
let
i
=
0
;
i
<
epalSelected
.
length
;
i
++
)
{
epalObj
[
i
]
=
new
StudentEpalChosen
(
null
,
epalSelected
[
i
],
this
.
epalSelectedOrder
[
i
]);
}
aitisiObj
[
"
1
"
]
=
epalObj
;
...
...
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