diff --git a/src/graphql/graphqlModules/Mcu/Mcu.js b/src/graphql/graphqlModules/Mcu/Mcu.js new file mode 100644 index 0000000..dad3cdc --- /dev/null +++ b/src/graphql/graphqlModules/Mcu/Mcu.js @@ -0,0 +1,13 @@ +module.exports.typeDefs = ` + type Query { + Mcu: McuActions + } +` + +module.exports.resolvers = { + Query: { + Mcu () { + return {} + } + } +} diff --git a/src/graphql/graphqlModules/Mcu/McuReboot.js b/src/graphql/graphqlModules/Mcu/McuReboot.js new file mode 100644 index 0000000..ac1ac87 --- /dev/null +++ b/src/graphql/graphqlModules/Mcu/McuReboot.js @@ -0,0 +1,13 @@ +module.exports.typeDefs = ` + type McuActions { + reboot: EmptyOutput! + } +` + +module.exports.resolvers = { + McuActions: { + reboot (root, args, { dispatch }) { + return dispatch('api/mcu/reboot') + } + } +} diff --git a/src/graphql/graphqlModules/Mcu/McuShutdown.js b/src/graphql/graphqlModules/Mcu/McuShutdown.js new file mode 100644 index 0000000..2cf2b7d --- /dev/null +++ b/src/graphql/graphqlModules/Mcu/McuShutdown.js @@ -0,0 +1,13 @@ +module.exports.typeDefs = ` + type McuActions { + shutdown: EmptyOutput! + } +` + +module.exports.resolvers = { + McuActions: { + shutdown (root, args, { dispatch }) { + return dispatch('api/mcu/shutdown') + } + } +} diff --git a/src/store/api/mcu/mcuReboot.js b/src/store/api/mcu/mcuReboot.js new file mode 100644 index 0000000..a6acc46 --- /dev/null +++ b/src/store/api/mcu/mcuReboot.js @@ -0,0 +1,7 @@ +const { exec } = require('child_process') + +module.exports = ({ define }) => { + define('reboot', async (payload, { knex, errors, utils }) => { + exec('shutdown -r now') + }) +} diff --git a/src/store/api/mcu/mcuShutdown.js b/src/store/api/mcu/mcuShutdown.js new file mode 100644 index 0000000..d348527 --- /dev/null +++ b/src/store/api/mcu/mcuShutdown.js @@ -0,0 +1,7 @@ +const { exec } = require('child_process') + +module.exports = ({ define }) => { + define('shutdown', async (payload, { knex, errors, utils }) => { + exec('shutdown now') + }) +}