Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
safetcut-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
safetcut-app
Commits
897d2eda
Commit
897d2eda
authored
Sep 18, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get connected device from firebase, add modal, ...update
parent
5d90726b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
31 deletions
+176
-31
reduxStore/actions/timersAction.js
+33
-0
reduxStore/reducers/timersReducer.js
+4
-1
screens/Private/SmartMeterScreen/McbLinkScreen.js
+139
-30
No files found.
reduxStore/actions/timersAction.js
View file @
897d2eda
...
@@ -12,6 +12,7 @@ export const GET_EXISTED_MCBLINKS_DATA = 'GET_EXISTED_MCBLINKS_DATA';
...
@@ -12,6 +12,7 @@ export const GET_EXISTED_MCBLINKS_DATA = 'GET_EXISTED_MCBLINKS_DATA';
export
const
GET_EXISTED_SUBBREAKERS_DATA
=
'GET_EXISTED_SUBBREAKERS_DATA'
;
export
const
GET_EXISTED_SUBBREAKERS_DATA
=
'GET_EXISTED_SUBBREAKERS_DATA'
;
export
const
GET_SELECTED_TIMER_DATA
=
'GET_SELECTED_TIMER_DATA'
;
export
const
GET_SELECTED_TIMER_DATA
=
'GET_SELECTED_TIMER_DATA'
;
export
const
SET_EDIT_MODAL_VISIBLE
=
'SET_EDIT_MODAL_VISIBLE'
;
export
const
SET_EDIT_MODAL_VISIBLE
=
'SET_EDIT_MODAL_VISIBLE'
;
export
const
GET_EXISTED_CONNECTED_DEVICE
=
'GET_EXISTED_CONNECTED_DEVICE'
;
export
const
getTimersAction
=
allTimers
=>
({
export
const
getTimersAction
=
allTimers
=>
({
type
:
GET_TIMERS
,
type
:
GET_TIMERS
,
...
@@ -28,6 +29,11 @@ export const getExistedSubBreakersDataAction = existedSubBreakersData => ({
...
@@ -28,6 +29,11 @@ export const getExistedSubBreakersDataAction = existedSubBreakersData => ({
existedSubBreakersData
,
existedSubBreakersData
,
});
});
export
const
getExistedConnectedDeviceAction
=
existedConnectedDevice
=>
({
type
:
GET_EXISTED_CONNECTED_DEVICE
,
existedConnectedDevice
,
});
export
const
getSelectedTimerDataAction
=
selectedTimerData
=>
({
export
const
getSelectedTimerDataAction
=
selectedTimerData
=>
({
type
:
GET_SELECTED_TIMER_DATA
,
type
:
GET_SELECTED_TIMER_DATA
,
selectedTimerData
,
selectedTimerData
,
...
@@ -59,6 +65,7 @@ export const getTimers = () => async (dispatch, getState) => {
...
@@ -59,6 +65,7 @@ export const getTimers = () => async (dispatch, getState) => {
let
subBreakersTimers
=
[];
let
subBreakersTimers
=
[];
let
existedMcbLinks
=
[];
let
existedMcbLinks
=
[];
let
existedSubBreakers
=
[];
let
existedSubBreakers
=
[];
let
existedConnectedDevice
=
[];
//main device section
//main device section
/*-------------------------------------*/
/*-------------------------------------*/
...
@@ -126,6 +133,31 @@ export const getTimers = () => async (dispatch, getState) => {
...
@@ -126,6 +133,31 @@ export const getTimers = () => async (dispatch, getState) => {
})
})
)
)
);
);
await
Promise
.
all
(
selectedDeviceSubBreakersDetails
.
docs
.
map
(
async
subBreaker
=>
{
if
(
subBreaker
.
exists
)
{
//Electronic device section
/*-------------------------------------*/
const
connectedDevices
=
await
fireStore
.
collection
(
'device'
)
.
doc
(
selectedDeviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
mcbLink
.
id
)
.
collection
(
'subBreakers'
)
.
doc
(
subBreaker
.
id
)
.
collection
(
'electronicDevices'
)
.
get
();
existedConnectedDevice
.
push
(
connectedDevices
.
docs
.
map
(
connectedDevice
=>
Object
.
assign
(
connectedDevice
.
data
(),
{
connectedDeviceId
:
connectedDevice
.
id
,
})
)
);
}
})
);
await
Promise
.
all
(
await
Promise
.
all
(
selectedDeviceSubBreakersDetails
.
docs
.
map
(
async
subBreaker
=>
{
selectedDeviceSubBreakersDetails
.
docs
.
map
(
async
subBreaker
=>
{
...
@@ -163,6 +195,7 @@ export const getTimers = () => async (dispatch, getState) => {
...
@@ -163,6 +195,7 @@ export const getTimers = () => async (dispatch, getState) => {
dispatch
(
getExistedMcbLinksDataAction
(
existedMcbLinks
));
dispatch
(
getExistedMcbLinksDataAction
(
existedMcbLinks
));
dispatch
(
getExistedSubBreakersDataAction
(
existedSubBreakers
));
dispatch
(
getExistedSubBreakersDataAction
(
existedSubBreakers
));
dispatch
(
getExistedConnectedDeviceAction
(
existedConnectedDevice
));
allTimersData
=
[...
mainDeviceTimers
,
...
subBreakersTimers
];
allTimersData
=
[...
mainDeviceTimers
,
...
subBreakersTimers
];
dispatch
(
getTimersAction
(
allTimersData
));
dispatch
(
getTimersAction
(
allTimersData
));
...
...
reduxStore/reducers/timersReducer.js
View file @
897d2eda
...
@@ -6,12 +6,14 @@ import {
...
@@ -6,12 +6,14 @@ import {
GET_EXISTED_SUBBREAKERS_DATA
,
GET_EXISTED_SUBBREAKERS_DATA
,
GET_SELECTED_TIMER_DATA
,
GET_SELECTED_TIMER_DATA
,
SET_EDIT_MODAL_VISIBLE
,
SET_EDIT_MODAL_VISIBLE
,
GET_EXISTED_CONNECTED_DEVICE
,
}
from
'../actions/timersAction'
;
}
from
'../actions/timersAction'
;
const
initState
=
{
const
initState
=
{
allTimers
:
[],
allTimers
:
[],
existedMcbLinksData
:
[],
existedMcbLinksData
:
[],
existedSubBreakersData
:
[],
existedSubBreakersData
:
[],
existedConnectedDevice
:
[],
selectedTimerData
:
null
,
selectedTimerData
:
null
,
isEditVisible
:
false
,
isEditVisible
:
false
,
isLoading
:
true
,
isLoading
:
true
,
...
@@ -34,7 +36,8 @@ const timersReducer = (state = initState, action) => {
...
@@ -34,7 +36,8 @@ const timersReducer = (state = initState, action) => {
return
{
...
state
,
isLoading
:
action
.
isLoading
};
return
{
...
state
,
isLoading
:
action
.
isLoading
};
case
GET_TIMERS_ERROR
:
case
GET_TIMERS_ERROR
:
return
{
...
state
,
error
:
action
.
error
};
return
{
...
state
,
error
:
action
.
error
};
case
GET_EXISTED_CONNECTED_DEVICE
:
return
{
...
state
,
existedConnectedDevice
:
action
.
existedConnectedDevice
};
default
:
default
:
return
state
;
return
state
;
}
}
...
...
screens/Private/SmartMeterScreen/McbLinkScreen.js
View file @
897d2eda
This diff is collapsed.
Click to expand it.
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