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
d76df389
Commit
d76df389
authored
Oct 03, 2019
by
HaOuiha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8b082b3a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
reduxStore/actions/allMainDeviceAction.js
+14
-9
reduxStore/actions/currentSelectedAction.js
+4
-4
No files found.
reduxStore/actions/allMainDeviceAction.js
View file @
d76df389
...
...
@@ -88,17 +88,22 @@ export const getAllMainDeviceInfo = () => async (dispatch, getState) => {
const
getBreakerStatus
=
async
deviceId
=>
{
try
{
const
{
data
:
{
shadow
:
{
data
},
},
}
=
await
apolloQuery
(
READ_SHADOW
,
{
deviceid
:
deviceId
});
const
res
=
await
apolloQuery
(
QUERY_ONLINE_STATUS
,
{
deviceid
:
deviceId
});
const
onlineStatus
=
res
.
data
.
device
[
0
].
status
;
// const {
// data: {
// shadow: { data },
// },
// } = await apolloQuery(READ_SHADOW, { deviceid: deviceId });
const
res1
=
await
apolloQuery
(
READ_SHADOW
,
{
deviceid
:
deviceId
});
const
breakerStatusData
=
res1
.
data
.
shadow
.
data
;
// const response = await apolloQuery(READ_SHADOW, { deviceid: deviceId });
// console.log(response);
const
res2
=
await
apolloQuery
(
QUERY_ONLINE_STATUS
,
{
deviceid
:
deviceId
});
const
onlineStatus
=
res2
.
data
.
device
[
0
].
status
;
// console.log(onlineStatus);
const
tempBreakerStatus
=
_
.
pick
(
d
ata
,
[
'SM1'
]);
const
tempBreakerStatus
=
_
.
pick
(
breakerStatusD
ata
,
[
'SM1'
]);
const
breakerStatus
=
tempBreakerStatus
.
SM1
.
BK_S
;
return
{
breakerStatus
,
onlineStatus
};
}
catch
(
e
)
{
...
...
reduxStore/actions/currentSelectedAction.js
View file @
d76df389
...
...
@@ -217,7 +217,7 @@ export const updateDetail = (type, value) => async (dispatch, getState) => {
}
};
export
const
setMainStatus
=
settingValue
=>
(
dispatch
,
getState
)
=>
{
export
const
setMainStatus
=
settingValue
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
}
=
getState
();
const
{
currentSelectedData
,
breakerStatus
}
=
currentSelectedDeviceReducer
;
const
selectedDeviceId
=
currentSelectedData
.
deviceId
;
...
...
@@ -237,13 +237,13 @@ export const setMainStatus = settingValue => (dispatch, getState) => {
try
{
const
desiredBreakerStatus
=
{
...
breakerStatus
,
SM1
:
{
BK_S
:
settingValue
?
1
:
0
}
};
dispatch
(
getBreakersStatusAction
(
desiredBreakerStatus
));
apolloMutation
(
WRITE_SHADOW
,
{
deviceid
:
selectedDeviceId
,
data
:
writingCommand
});
a
wait
a
polloMutation
(
WRITE_SHADOW
,
{
deviceid
:
selectedDeviceId
,
data
:
writingCommand
});
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
export
const
setSubBreakerStatus
=
(
settingValue
,
MainIndex
,
SubIndex
)
=>
(
dispatch
,
getState
)
=>
{
export
const
setSubBreakerStatus
=
(
settingValue
,
MainIndex
,
SubIndex
)
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
}
=
getState
();
const
{
currentSelectedData
,
breakerStatus
}
=
currentSelectedDeviceReducer
;
const
selectedDeviceId
=
currentSelectedData
.
deviceId
;
...
...
@@ -267,7 +267,7 @@ export const setSubBreakerStatus = (settingValue, MainIndex, SubIndex) => (dispa
},
};
dispatch
(
getBreakersStatusAction
(
desiredBreakerStatus
));
apolloMutation
(
WRITE_SHADOW
,
{
deviceid
:
selectedDeviceId
,
data
:
writingCommand
});
a
wait
a
polloMutation
(
WRITE_SHADOW
,
{
deviceid
:
selectedDeviceId
,
data
:
writingCommand
});
}
catch
(
error
)
{
console
.
log
(
error
);
}
...
...
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