Made it far less likely for the UI to lock up
This commit is contained in:
@@ -493,18 +493,19 @@ module.exports = {
|
||||
const toolpath = await api.get(`path/${file}`);
|
||||
this.toolpath_progress = toolpath.progress;
|
||||
|
||||
if (typeof toolpath.progress == 'undefined') {
|
||||
if (toolpath.progress === 1 || typeof toolpath.progress == 'undefined') {
|
||||
this.showGcodeMessage = false
|
||||
|
||||
if (toolpath.bounds) {
|
||||
toolpath.filename = file;
|
||||
this.toolpath_progress = 1;
|
||||
this.toolpath = toolpath;
|
||||
|
||||
const state = this.$root.state;
|
||||
const bounds = toolpath.bounds;
|
||||
for (let axis of 'xyzabc') {
|
||||
Vue.set(state, 'path_min_' + axis, bounds.min[axis]);
|
||||
Vue.set(state, 'path_max_' + axis, bounds.max[axis]);
|
||||
Vue.set(state, 'path_min_' + axis, toolpath.bounds.min[axis]);
|
||||
Vue.set(state, 'path_max_' + axis, toolpath.bounds.max[axis]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,29 +541,47 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
upload: function (e) {
|
||||
var files = e.target.files || e.dataTransfer.files;
|
||||
if (!files.length) return;
|
||||
upload: async function (e) {
|
||||
const files = e.target.files || e.dataTransfer.files;
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var file = files[0];
|
||||
var fd = new FormData();
|
||||
const file = files[0];
|
||||
|
||||
const extension = file.name.split(".").pop();
|
||||
switch (extension.toLowerCase()) {
|
||||
case "nc":
|
||||
case "ngc":
|
||||
case "gcode":
|
||||
case "gc":
|
||||
break;
|
||||
|
||||
default:
|
||||
alert(`Unsupported file type: ${extension}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const fd = new FormData();
|
||||
|
||||
fd.append('gcode', file);
|
||||
|
||||
api.upload('file', fd)
|
||||
.done(function () {
|
||||
try {
|
||||
await api.upload('file', fd);
|
||||
|
||||
this.last_file_time = undefined; // Force reload
|
||||
this.$broadcast('gcode-reload', file.name);
|
||||
|
||||
}.bind(this)).fail(function (error) {
|
||||
api.alert('Upload failed', error)
|
||||
}.bind(this));
|
||||
} catch (err) {
|
||||
api.alert('Upload failed', err)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
delete_current: function () {
|
||||
if (this.state.selected)
|
||||
if (this.state.selected) {
|
||||
api.delete('file/' + this.state.selected);
|
||||
}
|
||||
|
||||
this.deleteGCode = false;
|
||||
},
|
||||
|
||||
|
||||
@@ -36,14 +36,8 @@ script#console-template(type="text/x-template")
|
||||
table
|
||||
tr
|
||||
th Level
|
||||
th Source
|
||||
th Location
|
||||
th Repeat
|
||||
th Message
|
||||
|
||||
tr(v-for="msg in messages", class="log-{{msg.level || 'info'}}")
|
||||
td {{msg.level || 'info'}}
|
||||
td {{msg.source || ''}}
|
||||
td {{msg.where || ''}}
|
||||
td {{msg.repeat}}
|
||||
td.message {{msg.msg}}
|
||||
|
||||
@@ -413,7 +413,7 @@ script#control-view-template(type="text/x-template")
|
||||
|
||||
form.gcode-file-input.file-upload
|
||||
input(type="file", @change="upload", :disabled="!is_ready",
|
||||
accept="text/*,.nc,.gcode,.gc,.ngc,.txt,.tap,.cnc")
|
||||
accept=".nc,.ngc,.gcode,.gc")
|
||||
|
||||
a(:disabled="!state.selected", download,
|
||||
:href="'/api/file/' + state.selected",
|
||||
|
||||
@@ -128,7 +128,7 @@ class AVREmu(object):
|
||||
|
||||
except Exception:
|
||||
self.close()
|
||||
self.log.exception('Failed to start bbemu')
|
||||
self.log.exception('Internal error: Failed to start bbemu')
|
||||
|
||||
|
||||
def set_handlers(self, read_cb, write_cb):
|
||||
|
||||
@@ -429,7 +429,7 @@ class Camera(object):
|
||||
self._close_dev()
|
||||
self.log.info('Closed camera')
|
||||
|
||||
except: self.log.exception('Exception while closing camera')
|
||||
except: self.log.exception('Internal error: Exception while closing camera')
|
||||
finally: self.dev = None
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class CommandQueue():
|
||||
try:
|
||||
if cb is not None: cb(*args, **kwargs)
|
||||
except Exception:
|
||||
self.log.exception('During command queue callback')
|
||||
self.log.exception('Internal error: Command queue callback error')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class Config(object):
|
||||
encoding = 'utf-8') as f:
|
||||
self.template = json.load(f)
|
||||
|
||||
except Exception: self.log.exception()
|
||||
except Exception: self.log.exception('Internal error: Failed to load config template')
|
||||
|
||||
|
||||
def get(self, name, default = None):
|
||||
@@ -73,7 +73,7 @@ class Config(object):
|
||||
|
||||
try:
|
||||
self.upgrade(config)
|
||||
except Exception: self.log.exception()
|
||||
except Exception: self.log.exception('Internal error: Failed to upgrade config')
|
||||
|
||||
except Exception as e:
|
||||
self.log.warning('%s', e)
|
||||
|
||||
@@ -67,7 +67,7 @@ class Ctrl(object):
|
||||
|
||||
os.environ['GCODE_SCRIPT_PATH'] = self.get_upload()
|
||||
|
||||
except Exception: self.log.get('Ctrl').exception()
|
||||
except Exception: self.log.get('Ctrl').exception('Internal error: Control initialization failed')
|
||||
|
||||
|
||||
def __del__(self): print('Ctrl deleted')
|
||||
|
||||
@@ -79,7 +79,11 @@ class FileHandler(bbctrl.APIHandler):
|
||||
if not filename: raise HTTPError(400, 'Missing filename')
|
||||
filename = os.path.basename(filename)
|
||||
|
||||
try:
|
||||
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
|
||||
self.write(f.read())
|
||||
except Exception:
|
||||
self.get_ctrl().state.select_file('')
|
||||
raise HTTPError(400, "Unable to read file - doesn't appear to be GCode.")
|
||||
|
||||
self.get_ctrl().state.select_file(filename)
|
||||
|
||||
@@ -101,8 +101,8 @@ class Logger(object):
|
||||
def exception(self, *args, **kwargs):
|
||||
msg = traceback.format_exc()
|
||||
if len(args): msg = args[0] % args[1:] + '\n' + msg
|
||||
self._log(ERROR, msg, **kwargs)
|
||||
|
||||
self._log(INFO, msg, **kwargs)
|
||||
self._log(ERROR, *args, **kwargs)
|
||||
|
||||
class Log(object):
|
||||
def __init__(self, args, ioloop, path):
|
||||
|
||||
@@ -99,6 +99,6 @@ class MonitorTemp(object):
|
||||
self.update_camera(temp)
|
||||
self.log_warnings(temp)
|
||||
|
||||
except: self.log.exception()
|
||||
except: self.log.exception('Internal error: Temperature status')
|
||||
|
||||
self.ioloop.call_later(5, self.callback)
|
||||
|
||||
@@ -357,7 +357,7 @@ class Planner():
|
||||
self.cmdq.clear()
|
||||
|
||||
except:
|
||||
self.log.exception()
|
||||
self.log.exception('Internal error: Planner stop')
|
||||
self.reset()
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ class Planner():
|
||||
self.planner.restart(id, position)
|
||||
|
||||
except:
|
||||
self.log.exception()
|
||||
self.log.exception('Internal error: Planner restart')
|
||||
self.stop()
|
||||
|
||||
|
||||
@@ -391,5 +391,5 @@ class Planner():
|
||||
self.stop()
|
||||
|
||||
except:
|
||||
self.log.exception()
|
||||
self.log.exception('Internal error: Planner next')
|
||||
self.stop()
|
||||
|
||||
@@ -134,7 +134,7 @@ class Plan(object):
|
||||
return meta, positions, speeds
|
||||
|
||||
except:
|
||||
self.preplanner.log.exception()
|
||||
self.preplanner.log.exception('Internal error: Preplanner read')
|
||||
|
||||
# Clean
|
||||
for path in self.files:
|
||||
@@ -203,8 +203,7 @@ class Plan(object):
|
||||
self.future.set_result(self._read())
|
||||
|
||||
except:
|
||||
self.preplanner.log.exception()
|
||||
|
||||
self.preplanner.log.exception("Failed to load file - doesn't appear to be GCode.")
|
||||
|
||||
|
||||
class Preplanner(object):
|
||||
|
||||
Reference in New Issue
Block a user