add devel device export
This commit is contained in:
parent
4022922c25
commit
03f3211abe
2 changed files with 48 additions and 0 deletions
23
mods/devel/kiri.js
Normal file
23
mods/devel/kiri.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// provides a device export to local disk option
|
||||
self.kiri.load(api => {
|
||||
api.event.on('load-done', () => {
|
||||
let deviceExport = api.device.export;
|
||||
api.device.export = (exp, name, opt = {}) => {
|
||||
const { event, record } = opt;
|
||||
if (event && event.shiftKey & api.const.LOCAL) {
|
||||
const { code, process, profiles } = record;
|
||||
fetch("/api/postDevice", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ device: code, process, profiles })
|
||||
})
|
||||
.then(r => r.text())
|
||||
.then(t => {
|
||||
// console.log({server_said: t});
|
||||
api.show.alert('profile saved to server');
|
||||
});
|
||||
} else {
|
||||
deviceExport(exp, name);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue