This commit is contained in:
Aleksander Barszczewski 2018-10-25 15:26:46 +02:00
parent eb29686a90
commit 8b983c7826
5 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,13 @@
module.exports.typeDefs = `
type Query {
Mcu: McuActions
}
`
module.exports.resolvers = {
Query: {
Mcu () {
return {}
}
}
}

View File

@ -0,0 +1,13 @@
module.exports.typeDefs = `
type McuActions {
reboot: EmptyOutput!
}
`
module.exports.resolvers = {
McuActions: {
reboot (root, args, { dispatch }) {
return dispatch('api/mcu/reboot')
}
}
}

View File

@ -0,0 +1,13 @@
module.exports.typeDefs = `
type McuActions {
shutdown: EmptyOutput!
}
`
module.exports.resolvers = {
McuActions: {
shutdown (root, args, { dispatch }) {
return dispatch('api/mcu/shutdown')
}
}
}

View File

@ -0,0 +1,7 @@
const { exec } = require('child_process')
module.exports = ({ define }) => {
define('reboot', async (payload, { knex, errors, utils }) => {
exec('shutdown -r now')
})
}

View File

@ -0,0 +1,7 @@
const { exec } = require('child_process')
module.exports = ({ define }) => {
define('shutdown', async (payload, { knex, errors, utils }) => {
exec('shutdown now')
})
}