Implement reboot, reset, and delete

This commit is contained in:
Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent 3786f71565
commit 8e128500d0
6 files changed
+218 -5

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
"use strict";
import m from "mithril";
import * as taskQueue from "../task-queue";
import * as notifications from "../notifications";
import * as store from "../store";
const component = {
view: vnode => {
const device = vnode.attrs.device;
const buttons = [];
buttons.push(
m(
"button.primary",
{
title: "Reboot device",
onclick: () => {
taskQueue.queueTask({
name: "reboot",
device: device["DeviceID.ID"].value[0]
});
}
},
"Reboot"
)
);
buttons.push(
m(
"button.critical",
{
title: "Factory reset device",
onclick: () => {
taskQueue.queueTask({
name: "factoryReset",
device: device["DeviceID.ID"].value[0]
});
}
},
"Reset"
)
);
buttons.push(
m(
"button.primary",
{
title: "Delete device",
onclick: () => {
if (!confirm("Deleting this device. Are you sure?")) return;
store
.deleteResource("devices", device["DeviceID.ID"].value[0])
.then(() => {
notifications.push("success", "Device deleted");
m.route.set("/devices");
})
.catch(err => {
notifications.push("error", err.message);
});
}
},
"Delete"
)
);
return m(".device-actions", buttons);
}
};
export default component;