Skip to content

Commit 32aef48

Browse files
committed
feat(action): implement IPC & methods for action buttons
1 parent 8717390 commit 32aef48

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exorcist",
3-
"version": "0.0.5",
3+
"version": "0.1.0",
44
"description": "Got rogue daemons in your system?",
55
"main": "src/index.js",
66
"scripts": {
@@ -50,7 +50,6 @@
5050
},
5151
"build": {
5252
"appId": "io.debs.code.exorcist",
53-
"compression": "store",
5453
"files": [
5554
"src/**/*",
5655
"!src/app",

src/app/components/app.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
{{ props.row.description }}
1313
</b-table-column>
1414
<b-table-column field="action" label="Dispel">
15-
<button class="button is-light is-small">disable</button>
15+
<button
16+
@click.stop="dispel"
17+
:data-daemon="props.row.daemon"
18+
class="button is-light is-small">
19+
disable
20+
</button>
1621
</b-table-column>
1722
</template>
1823
</b-table>
@@ -28,10 +33,21 @@ export default {
2833
data () {
2934
return { daemons: [] }
3035
},
36+
methods: {
37+
dispel: (event) => {
38+
let message = event.target.dataset.daemon
39+
ipcRenderer.send('action', message)
40+
}
41+
},
3142
created () {
3243
let self = this
3344
ipcRenderer.on('loaded', (event, data) => {
3445
self.daemons = data
46+
47+
ipcRenderer.on('dispelled', (e, d) => {
48+
let button = '[data-daemon="' + d + '"]'
49+
document.querySelector(button).disabled = true
50+
})
3551
})
3652
}
3753
}

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Application entrypoint
22

3-
const { app, BrowserWindow } = require('electron')
3+
const { app, BrowserWindow, ipcMain } = require('electron')
44
const exec = require('child_process').exec
55

66
const config = require('./config.json')
@@ -22,6 +22,12 @@ const createWindow = () => {
2222
})
2323
})
2424

25+
ipcMain.on('action', (event, arg) => {
26+
exec('systemctl disable ' + arg, (e, out, err) => {
27+
if(!e) window.webContents.send('dispelled', arg)
28+
})
29+
})
30+
2531
// Avoids flash of white background
2632
window.on('ready-to-show', () => {
2733
window.show()

0 commit comments

Comments
 (0)