ui: V09 redesign - Control/Program/Console/Settings shell
Replaces the legacy side-menu chrome with a 4-tab top header. - index.pug: tablet/kiosk fit-to-viewport script, header tab nav, estop/state badges in header. - app.js: route hash to (control|program|console|<settings-family>), multi-section settings shell. - control-view: header DRO, jog grid, MDI/probe/macros panels. - program-view + program-mixin: file browser + toolpath preview + run/pause/stop, replaces the legacy 'macros' tab content. - console-view: MDI shell, message log, indicators. - settings-shell-view: rail-driven inner pages (Display & Units, Probing, G-code & Motion, Macros, Network, etc.). - settings-view: filter Svelte SettingsView to one rail section. - SettingsView.svelte: tag every section with data-sec=… so the filter above can hide non-matching ones. - style.styl: ~2700 lines of V09 layout, DRO, jog grid, status strip, and tablet/kiosk variants. No A-axis / auxiliary-axis content lives on this branch.
This commit is contained in:
111
README.md
111
README.md
@@ -1 +1,110 @@
|
|||||||
#OneFinity CNC Controller Firmware
|
# OneFinity CNC Controller Firmware (community fork)
|
||||||
|
|
||||||
|
This is the OneFinity / Buildbotics bbctrl firmware with a redesigned
|
||||||
|
UI (V09), Font Awesome 6, faster cold boot, and a streamlined macOS
|
||||||
|
dev / deploy workflow.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
```
|
||||||
|
src/avr/ AVR firmware (motion controller, AtxMega)
|
||||||
|
src/boot/ AVR bootloader
|
||||||
|
src/bbserial/ Linux kernel module for the bbserial driver
|
||||||
|
src/py/bbctrl/ Python control daemon (Tornado + websockets)
|
||||||
|
src/js/ Vue.js UI (legacy)
|
||||||
|
src/svelte-components/ Newer Svelte UI for dialogs and settings
|
||||||
|
src/pug/ Pug templates compiled into build/http/index.html
|
||||||
|
src/resources/ Static assets and config templates
|
||||||
|
scripts/ Install / update / RPi build helpers
|
||||||
|
docs/ Architecture, dev setup
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build & flash (quick path, macOS or Linux)
|
||||||
|
|
||||||
|
The full build (`make`) requires `avr-gcc`, but the controller and UI
|
||||||
|
only depend on the Python + web parts. If you're shipping a UI/Python
|
||||||
|
change you don't need the AVR toolchain.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Node.js (any recent LTS) with npm
|
||||||
|
- Python 3 with setuptools
|
||||||
|
- `npm install` once at the project root (this is wired into the
|
||||||
|
`node_modules` Make target, but on a fresh checkout it's clearer to
|
||||||
|
do it explicitly)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
(cd src/svelte-components && npm install)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### macOS gotcha: esbuild platform pin
|
||||||
|
|
||||||
|
The Pi build leaves `node_modules/esbuild` pinned to
|
||||||
|
`linux-arm64`, which won't run on Darwin. If `npm run build` inside
|
||||||
|
`src/svelte-components` complains about esbuild, reinstall it for the
|
||||||
|
host:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd src/svelte-components
|
||||||
|
rm -rf node_modules/esbuild
|
||||||
|
npm install esbuild@0.14.49 --no-save
|
||||||
|
```
|
||||||
|
|
||||||
|
(Use the version that matches `package-lock.json`.)
|
||||||
|
|
||||||
|
### Build the web UI + Python sdist
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the Svelte components
|
||||||
|
(cd src/svelte-components && npm run build)
|
||||||
|
|
||||||
|
# Render pug templates and copy assets into build/http
|
||||||
|
make all # AVR step will fail without avr-gcc; safe to ignore
|
||||||
|
# if you didn't change anything under src/avr or src/boot
|
||||||
|
|
||||||
|
# Package
|
||||||
|
./setup.py sdist
|
||||||
|
ls dist/bbctrl-*.tar.bz2
|
||||||
|
```
|
||||||
|
|
||||||
|
`make pkg` is the canonical target but it tries to build AVR first. On
|
||||||
|
hosts without avr-gcc, run the steps above directly.
|
||||||
|
|
||||||
|
If `bbctrl-*.tar.bz2` is missing `src/bbserial/bbserial.ko`, copy the
|
||||||
|
prebuilt `.ko` from a previous official release into `src/bbserial/`
|
||||||
|
before running `setup.py sdist` (the install script on the controller
|
||||||
|
just installs the existing module if a newer one isn't shipped).
|
||||||
|
|
||||||
|
### Flash to a controller
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X PUT -H "Content-Type: multipart/form-data" \
|
||||||
|
-F "firmware=@dist/bbctrl-1.6.7.tar.bz2" \
|
||||||
|
-F "password=onefinity" \
|
||||||
|
http://onefinity.local/api/firmware/update
|
||||||
|
```
|
||||||
|
|
||||||
|
…or use the Make target:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make update HOST=onefinity.local PASSWORD=onefinity
|
||||||
|
```
|
||||||
|
|
||||||
|
The controller stops bbctrl, untars the package, runs
|
||||||
|
`scripts/install.sh`, and brings the service back up. Total downtime
|
||||||
|
is ~30-45s. Watch progress at `http://<host>/` (you'll get 404s while
|
||||||
|
bbctrl restarts, then the new UI).
|
||||||
|
|
||||||
|
### Verify the flash
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s http://onefinity.local/ | grep -c "OneFinity"
|
||||||
|
curl -s http://onefinity.local/api/diag/timing | head
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build & flash (full path, Debian/Linux)
|
||||||
|
|
||||||
|
For AVR + GPlan rebuilds, see [docs/development.md](docs/development.md).
|
||||||
|
That path uses qemu + chroot to cross-compile gplan for ARM and needs
|
||||||
|
the `gcc-avr` / `avr-libc` toolchain.
|
||||||
|
|||||||
267
src/js/app.js
267
src/js/app.js
@@ -4,6 +4,7 @@ const api = require("./api");
|
|||||||
const cookie = require("./cookie")("bbctrl-");
|
const cookie = require("./cookie")("bbctrl-");
|
||||||
const Sock = require("./sock");
|
const Sock = require("./sock");
|
||||||
const semverLt = require("semver/functions/lt");
|
const semverLt = require("semver/functions/lt");
|
||||||
|
const restartTiming = require("./restart-timing");
|
||||||
|
|
||||||
if (document.getElementById("svelte-dialog-host") != undefined) {
|
if (document.getElementById("svelte-dialog-host") != undefined) {
|
||||||
SvelteComponents.createComponent(
|
SvelteComponents.createComponent(
|
||||||
@@ -103,6 +104,17 @@ module.exports = new Vue({
|
|||||||
return {
|
return {
|
||||||
status: "connecting",
|
status: "connecting",
|
||||||
currentView: "loading",
|
currentView: "loading",
|
||||||
|
// Top-level shell tab. Mapped from the URL hash by parse_hash().
|
||||||
|
// One of: control | program | console | settings
|
||||||
|
top_tab: "control",
|
||||||
|
// Sub-route when a tab has internal pages (e.g. console:mdi,
|
||||||
|
// settings:admin-network, settings:motor:0). The settings sub
|
||||||
|
// also drives which inner view is mounted.
|
||||||
|
sub_tab: "",
|
||||||
|
sys_open: false,
|
||||||
|
has_camera: true,
|
||||||
|
messages_log: [],
|
||||||
|
messages_seen: 0,
|
||||||
display_units: localStorage.getItem("display_units") || "METRIC",
|
display_units: localStorage.getItem("display_units") || "METRIC",
|
||||||
index: -1,
|
index: -1,
|
||||||
modified: false,
|
modified: false,
|
||||||
@@ -143,22 +155,15 @@ module.exports = new Vue({
|
|||||||
estop: { template: "#estop-template" },
|
estop: { template: "#estop-template" },
|
||||||
"loading-view": { template: "<h1>Loading...</h1>" },
|
"loading-view": { template: "<h1>Loading...</h1>" },
|
||||||
"control-view": require("./control-view"),
|
"control-view": require("./control-view"),
|
||||||
"settings-view": require("./settings-view"),
|
"program-view": require("./program-view"),
|
||||||
"motor-view": require("./motor-view"),
|
"console-view": require("./console-view"),
|
||||||
"tool-view": require("./tool-view"),
|
|
||||||
"io-view": require("./io-view"),
|
// The settings-shell renders the rail + an inner routed view.
|
||||||
"admin-general-view": require("./admin-general-view"),
|
// All settings-family hashes (settings, admin-general,
|
||||||
"admin-network-view": require("./admin-network-view"),
|
// admin-network, motor:N, tool, io, macros, help, cheat-sheet)
|
||||||
"macros-view": require('./macros'),
|
// resolve to this same shell; parse_hash() sets sub_tab so the
|
||||||
"help-view": require("./help-view"),
|
// shell knows which inner template to mount.
|
||||||
"cheat-sheet-view": {
|
"settings-shell-view": require("./settings-shell-view"),
|
||||||
template: "#cheat-sheet-view-template",
|
|
||||||
data: function() {
|
|
||||||
return {
|
|
||||||
showUnimplemented: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@@ -166,6 +171,25 @@ module.exports = new Vue({
|
|||||||
localStorage.setItem("display_units", value);
|
localStorage.setItem("display_units", value);
|
||||||
SvelteComponents.setDisplayUnits(value);
|
SvelteComponents.setDisplayUnits(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Mirror controller messages into a console log used by the
|
||||||
|
// Console > Messages tab and the header badge counter.
|
||||||
|
"state.messages": {
|
||||||
|
handler: function(messages) {
|
||||||
|
if (!Array.isArray(messages)) return;
|
||||||
|
this.messages_log = messages.map(m => ({
|
||||||
|
text: m.text,
|
||||||
|
id: m.id,
|
||||||
|
level: /^#/.test(m.text || "") ? "info" : "warning",
|
||||||
|
ts: m.ts || Date.now(),
|
||||||
|
}));
|
||||||
|
if (this.top_tab === "console" && this.sub_tab === "messages") {
|
||||||
|
this.messages_seen = this.messages_log.length;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
@@ -227,6 +251,19 @@ module.exports = new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
// True when the UI is in kiosk mode — i.e. running on the
|
||||||
|
// controller's own onboard browser (Pi 3B at 1366x768) or
|
||||||
|
// explicitly forced via ?kiosk=1. Source-of-truth is the
|
||||||
|
// `kiosk-mode` class added to <html> by the inline script
|
||||||
|
// in index.pug, which already honors hostname + URL param +
|
||||||
|
// localStorage. The Pi's VideoCore IV is too slow for the
|
||||||
|
// three.js toolpath preview, so we suppress that panel in
|
||||||
|
// kiosk mode and let the gcode listing take the full width.
|
||||||
|
is_kiosk: function() {
|
||||||
|
return typeof document !== "undefined"
|
||||||
|
&& document.documentElement.classList.contains("kiosk-mode");
|
||||||
|
},
|
||||||
|
|
||||||
popupMessages: function() {
|
popupMessages: function() {
|
||||||
const msgs = [];
|
const msgs = [];
|
||||||
|
|
||||||
@@ -252,18 +289,130 @@ module.exports = new Vue({
|
|||||||
enable_rotary: function() {
|
enable_rotary: function() {
|
||||||
if(this.state["2an"] == 1 || this.state["2an"] == 3) return true;
|
if(this.state["2an"] == 1 || this.state["2an"] == 3) return true;
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
// ---------------- header chrome helpers ----------------
|
||||||
|
|
||||||
|
// Underlying machine state from the controller. Mirrors
|
||||||
|
// control-view's `mach_state` so the header has access without
|
||||||
|
// depending on the routed component.
|
||||||
|
mach_state: function() {
|
||||||
|
const cycle = this.state.cycle;
|
||||||
|
const xx = this.state.xx;
|
||||||
|
|
||||||
|
if (xx != "ESTOPPED" && (cycle == "jogging" || cycle == "homing")) {
|
||||||
|
return cycle.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return xx || "";
|
||||||
|
},
|
||||||
|
|
||||||
|
// Short text for the READY pill in the header.
|
||||||
|
state_label: function() {
|
||||||
|
const s = this.mach_state;
|
||||||
|
if (!s) return "--";
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Class added to the READY pill (.state-badge) so styling can
|
||||||
|
// reflect ready / running / holding / fault / estop.
|
||||||
|
state_class: function() {
|
||||||
|
const s = this.mach_state;
|
||||||
|
if (s == "ESTOPPED" || s == "FAULT" || s == "SHUTDOWN") return "bad";
|
||||||
|
if (s == "HOLDING" || s == "STOPPING") return "warn";
|
||||||
|
if (s == "RUNNING" || s == "HOMING" || s == "JOGGING") return "busy";
|
||||||
|
if (s == "READY") return "ok";
|
||||||
|
return "unknown";
|
||||||
|
},
|
||||||
|
|
||||||
|
mach_state_full: function() {
|
||||||
|
const s = this.mach_state;
|
||||||
|
if (s == "ESTOPPED") return "E-Stopped \u2014 release to clear";
|
||||||
|
if (s == "HOLDING") return "Feed hold (" + (this.state.pr || "paused") + ")";
|
||||||
|
if (s == "RUNNING") return "Running program";
|
||||||
|
if (s == "HOMING") return "Homing axes";
|
||||||
|
if (s == "JOGGING") return "Jogging";
|
||||||
|
if (s == "READY") return "Ready";
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Pip color for the unified system pill.
|
||||||
|
sys_class: function() {
|
||||||
|
const wifi_off = !this.config.wifiName || this.config.wifiName == "not connected";
|
||||||
|
const cam_off = !this.has_camera;
|
||||||
|
const hot = this.state && 80 <= this.state.rpi_temp;
|
||||||
|
if (hot) return "red";
|
||||||
|
if (wifi_off || cam_off) return "amber";
|
||||||
|
return "green";
|
||||||
|
},
|
||||||
|
|
||||||
|
// Compact summary for the system pill.
|
||||||
|
sys_summary: function() {
|
||||||
|
const issues = [];
|
||||||
|
if (!this.config.wifiName || this.config.wifiName == "not connected") {
|
||||||
|
issues.push("WiFi off");
|
||||||
|
}
|
||||||
|
if (!this.has_camera) issues.push("Camera offline");
|
||||||
|
if (this.state && 80 <= this.state.rpi_temp) issues.push("Pi hot");
|
||||||
|
if (this.is_rotary_active) issues.push("Rotary");
|
||||||
|
if (issues.length === 0) return "All systems";
|
||||||
|
if (issues.length === 1) return issues[0];
|
||||||
|
return issues.length + " notes";
|
||||||
|
},
|
||||||
|
|
||||||
|
// Number of unread Console > Messages entries.
|
||||||
|
messages_count: function() {
|
||||||
|
return Math.max(0, this.messages_log.length - this.messages_seen);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
window.onhashchange = () => this.parse_hash();
|
window.onhashchange = () => this.parse_hash();
|
||||||
|
|
||||||
|
// Embedded Svelte subviews (A axis settings, etc.) signal
|
||||||
|
// unsaved changes via this event. The master Save button
|
||||||
|
// highlights when modified is true.
|
||||||
|
window.addEventListener("onefin:dirty", () => {
|
||||||
|
this.modified = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resolve the initial route before the websocket connects so
|
||||||
|
// the shell shows the right view even on a slow / offline
|
||||||
|
// controller. update() will call parse_hash() again once the
|
||||||
|
// first config is in. Skip routing into the Svelte settings
|
||||||
|
// family before config has loaded — those components read
|
||||||
|
// many config keys (settings.units, settings.probing-prompts,
|
||||||
|
// motion.*, etc.) and would throw on first paint with the
|
||||||
|
// empty placeholder config.
|
||||||
|
const settingsFamily = [
|
||||||
|
"settings", "probing", "gcode",
|
||||||
|
"admin-general", "admin-network",
|
||||||
|
"motor", "tool", "io", "macros",
|
||||||
|
"help", "cheat-sheet",
|
||||||
|
];
|
||||||
|
const initialHead = (location.hash || "").replace(/^#/, "").split(":")[0];
|
||||||
|
if (settingsFamily.indexOf(initialHead) === -1) {
|
||||||
|
this.parse_hash();
|
||||||
|
}
|
||||||
|
// else: stay on "loading" until update() completes and calls
|
||||||
|
// parse_hash() itself.
|
||||||
|
|
||||||
this.connect();
|
this.connect();
|
||||||
|
|
||||||
|
// Close the system popover when clicking anywhere else.
|
||||||
|
document.addEventListener("click", () => {
|
||||||
|
if (this.sys_open) this.sys_open = false;
|
||||||
|
});
|
||||||
|
|
||||||
SvelteComponents.registerControllerMethods({
|
SvelteComponents.registerControllerMethods({
|
||||||
dispatch: (...args) => this.$dispatch(...args)
|
dispatch: (...args) => this.$dispatch(...args)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
block_error_dialog: function() {
|
block_error_dialog: function() {
|
||||||
this.errorTimeoutStart = Date.now();
|
this.errorTimeoutStart = Date.now();
|
||||||
@@ -338,6 +487,12 @@ module.exports = new Vue({
|
|||||||
toggle_rotary: async function(isActive) {
|
toggle_rotary: async function(isActive) {
|
||||||
try {
|
try {
|
||||||
await api.put("rotary", {status: isActive});
|
await api.put("rotary", {status: isActive});
|
||||||
|
// The /api/rotary endpoint rewrites motors[1]/[2]
|
||||||
|
// in config.json on the server. Refetch so the UI
|
||||||
|
// reflects the new motor config (otherwise the
|
||||||
|
// motor settings page keeps showing pre-toggle
|
||||||
|
// values until the next page reload).
|
||||||
|
await this.update();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
alert("Error occured");
|
alert("Error occured");
|
||||||
@@ -372,11 +527,19 @@ module.exports = new Vue({
|
|||||||
connect: function() {
|
connect: function() {
|
||||||
this.sock = new Sock(`//${location.host}/sockjs`);
|
this.sock = new Sock(`//${location.host}/sockjs`);
|
||||||
|
|
||||||
|
let _gotFirstMsg = false;
|
||||||
|
let _gotFirstState = false;
|
||||||
|
|
||||||
this.sock.onmessage = (e) => {
|
this.sock.onmessage = (e) => {
|
||||||
if (typeof e.data != "object") {
|
if (typeof e.data != "object") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_gotFirstMsg) {
|
||||||
|
_gotFirstMsg = true;
|
||||||
|
restartTiming.onWsFirstMessage();
|
||||||
|
}
|
||||||
|
|
||||||
if (e.data.log && e.data.log.msg !== "Switch not found") {
|
if (e.data.log && e.data.log.msg !== "Switch not found") {
|
||||||
this.$broadcast("log", e.data.log);
|
this.$broadcast("log", e.data.log);
|
||||||
|
|
||||||
@@ -386,6 +549,11 @@ module.exports = new Vue({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_gotFirstState) {
|
||||||
|
_gotFirstState = true;
|
||||||
|
restartTiming.onFirstState();
|
||||||
|
}
|
||||||
|
|
||||||
// Check for session ID change on controller
|
// Check for session ID change on controller
|
||||||
if ("sid" in e.data) {
|
if ("sid" in e.data) {
|
||||||
if (typeof this.sid == "undefined") {
|
if (typeof this.sid == "undefined") {
|
||||||
@@ -410,6 +578,7 @@ module.exports = new Vue({
|
|||||||
|
|
||||||
this.sock.onopen = () => {
|
this.sock.onopen = () => {
|
||||||
this.status = "connected";
|
this.status = "connected";
|
||||||
|
restartTiming.onWsOpen();
|
||||||
this.$emit(this.status);
|
this.$emit(this.status);
|
||||||
this.$broadcast(this.status);
|
this.$broadcast(this.status);
|
||||||
};
|
};
|
||||||
@@ -421,6 +590,21 @@ module.exports = new Vue({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Maps a URL hash to (currentView, top_tab, sub_tab, index).
|
||||||
|
// Hash layouts supported (all kept for backward compat):
|
||||||
|
// #control -> control tab
|
||||||
|
// #program[:auto] -> program tab
|
||||||
|
// #console[:mdi|messages|indicators]
|
||||||
|
// -> console tab
|
||||||
|
// #settings -> settings tab home
|
||||||
|
// #admin-general -> settings tab, admin-general inside
|
||||||
|
// #admin-network -> settings tab, admin-network inside
|
||||||
|
// #motor:0..3 -> settings tab, motor 0..3
|
||||||
|
// #tool -> settings tab, tool view
|
||||||
|
// #io -> settings tab, io view
|
||||||
|
// #macros -> settings tab, macros view
|
||||||
|
// #help -> settings tab, help view
|
||||||
|
// #cheat-sheet -> settings tab, cheat sheet view
|
||||||
parse_hash: function() {
|
parse_hash: function() {
|
||||||
const hash = location.hash.substr(1);
|
const hash = location.hash.substr(1);
|
||||||
|
|
||||||
@@ -430,12 +614,57 @@ module.exports = new Vue({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parts = hash.split(":");
|
const parts = hash.split(":");
|
||||||
|
const head = parts[0];
|
||||||
|
|
||||||
if (parts.length == 2) {
|
this.index = parts.length > 1 ? parts[1] : -1;
|
||||||
this.index = parts[1];
|
|
||||||
|
// Legacy / settings-managed views resolve under the
|
||||||
|
// Settings tab while keeping their existing top-level
|
||||||
|
// hash. This preserves all existing deep links.
|
||||||
|
const settingsViews = [
|
||||||
|
"settings", "probing", "gcode",
|
||||||
|
"admin-general", "admin-network",
|
||||||
|
"motor", "tool", "io", "macros",
|
||||||
|
"help", "cheat-sheet",
|
||||||
|
];
|
||||||
|
|
||||||
|
if (head == "control") {
|
||||||
|
this.top_tab = "control";
|
||||||
|
this.sub_tab = "";
|
||||||
|
this.currentView = "control";
|
||||||
|
} else if (head == "program") {
|
||||||
|
this.top_tab = "program";
|
||||||
|
this.sub_tab = parts[1] || "auto";
|
||||||
|
this.currentView = "program";
|
||||||
|
} else if (head == "console") {
|
||||||
|
this.top_tab = "console";
|
||||||
|
this.sub_tab = parts[1] || "mdi";
|
||||||
|
this.currentView = "console";
|
||||||
|
} else if (settingsViews.indexOf(head) !== -1) {
|
||||||
|
this.top_tab = "settings";
|
||||||
|
this.sub_tab = head;
|
||||||
|
// All settings-family routes mount the same shell;
|
||||||
|
// shell picks inner view from sub_tab. Vary the
|
||||||
|
// currentView token so Vue 1 fully remounts the
|
||||||
|
// shell on every navigation — this avoids stale :class
|
||||||
|
// bindings against the local `sub` data prop.
|
||||||
|
this.currentView = "settings-shell";
|
||||||
|
} else {
|
||||||
|
// Unknown hash: route to settings shell anyway so we
|
||||||
|
// never end up rendering a bare loading screen.
|
||||||
|
this.top_tab = "settings";
|
||||||
|
this.sub_tab = head;
|
||||||
|
this.currentView = "settings-shell";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentView = parts[0];
|
// Mark Console messages as seen when we enter that tab.
|
||||||
|
if (this.top_tab == "console" && this.sub_tab == "messages") {
|
||||||
|
this.messages_seen = this.messages_log.length;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggle_sys_popover: function() {
|
||||||
|
this.sys_open = !this.sys_open;
|
||||||
},
|
},
|
||||||
|
|
||||||
save: async function() {
|
save: async function() {
|
||||||
|
|||||||
125
src/js/console-view.js
Normal file
125
src/js/console-view.js
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const api = require("./api");
|
||||||
|
|
||||||
|
// Console tab — MDI command input, message log and live indicators.
|
||||||
|
// Sub-tab state syncs with the URL hash (#console:mdi |
|
||||||
|
// #console:messages | #console:indicators) so deep links work.
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
template: "#console-view-template",
|
||||||
|
props: ["config", "template", "state"],
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
mdi: "",
|
||||||
|
history: [],
|
||||||
|
sub: "mdi",
|
||||||
|
// Local mirror of $root.messages_count so Vue 1 reactivity works.
|
||||||
|
unread_messages_local: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
sub: function () {
|
||||||
|
// Switching to messages marks them as seen so the header badge
|
||||||
|
// clears.
|
||||||
|
if (this.sub === "messages") {
|
||||||
|
this.$root.messages_seen = this.$root.messages_log.length;
|
||||||
|
this.unread_messages_local = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
unread_messages: function () {
|
||||||
|
return this.unread_messages_local;
|
||||||
|
},
|
||||||
|
|
||||||
|
mach_state: function () {
|
||||||
|
const cycle = this.state.cycle;
|
||||||
|
const xx = this.state.xx;
|
||||||
|
if (xx != "ESTOPPED" && (cycle == "jogging" || cycle == "homing")) {
|
||||||
|
return cycle.toUpperCase();
|
||||||
|
}
|
||||||
|
return xx || "";
|
||||||
|
},
|
||||||
|
|
||||||
|
is_idle: function () { return this.state.cycle == "idle"; },
|
||||||
|
|
||||||
|
can_mdi: function () {
|
||||||
|
return this.is_idle || this.state.cycle == "mdi";
|
||||||
|
},
|
||||||
|
|
||||||
|
mach_units: function () {
|
||||||
|
return this.$root.display_units;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
ready: function () {
|
||||||
|
this._onHash = () => this.refresh_from_hash();
|
||||||
|
window.addEventListener("hashchange", this._onHash);
|
||||||
|
this.refresh_from_hash();
|
||||||
|
this._poll = setInterval(() => {
|
||||||
|
// Cheap re-poll for unread message count; Vue 1 cannot observe
|
||||||
|
// `$root.messages_count` directly so we mirror it here.
|
||||||
|
const c = this.$root && this.$root.messages_count;
|
||||||
|
if (typeof c === "number" && c !== this.unread_messages_local) {
|
||||||
|
this.unread_messages_local = c;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy: function () {
|
||||||
|
if (this._onHash) window.removeEventListener("hashchange", this._onHash);
|
||||||
|
if (this._poll) clearInterval(this._poll);
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
refresh_from_hash: function () {
|
||||||
|
const hash = location.hash.substr(1);
|
||||||
|
const parts = hash.split(":");
|
||||||
|
const sub = parts[0] === "console" ? (parts[1] || "mdi") : "mdi";
|
||||||
|
this.sub = sub;
|
||||||
|
if (sub === "messages" && this.$root) {
|
||||||
|
this.$root.messages_seen = this.$root.messages_log.length;
|
||||||
|
this.unread_messages_local = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
select_sub: function (name) {
|
||||||
|
this.sub = name;
|
||||||
|
// Update URL hash for deep links / back-button.
|
||||||
|
const h = "#console" + (name && name !== "mdi" ? ":" + name : "");
|
||||||
|
if (location.hash !== h) {
|
||||||
|
history.replaceState(null, "", h);
|
||||||
|
}
|
||||||
|
if (name === "messages") {
|
||||||
|
this.$root.messages_seen = this.$root.messages_log.length;
|
||||||
|
this.unread_messages_local = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
prepend: function (token) {
|
||||||
|
this.mdi = token + this.mdi.trimStart();
|
||||||
|
},
|
||||||
|
|
||||||
|
append: function (token) {
|
||||||
|
const tail = this.mdi.endsWith(" ") || !this.mdi ? "" : " ";
|
||||||
|
this.mdi = this.mdi + tail + token;
|
||||||
|
},
|
||||||
|
|
||||||
|
submit_mdi: function () {
|
||||||
|
if (!this.mdi) return;
|
||||||
|
this.$dispatch("send", this.mdi);
|
||||||
|
if (!this.history.length || this.history[0] != this.mdi) {
|
||||||
|
this.history.unshift(this.mdi);
|
||||||
|
}
|
||||||
|
this.mdi = "";
|
||||||
|
},
|
||||||
|
|
||||||
|
load_history: function (index) {
|
||||||
|
this.mdi = this.history[index];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const api = require("./api");
|
const api = require("./api");
|
||||||
const utils = require("./utils");
|
|
||||||
const cookie = require("./cookie")("bbctrl-");
|
const cookie = require("./cookie")("bbctrl-");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -12,15 +11,7 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
current_time: "",
|
current_time: "",
|
||||||
mach_units: this.$root.state.metric ? "METRIC" : "IMPERIAL",
|
mach_units: this.$root.state.metric ? "METRIC" : "IMPERIAL",
|
||||||
mdi: "",
|
|
||||||
last_file: undefined,
|
|
||||||
last_file_time: undefined,
|
|
||||||
toolpath: {},
|
|
||||||
toolpath_progress: 0,
|
|
||||||
axes: "xyzabc",
|
axes: "xyzabc",
|
||||||
history: [],
|
|
||||||
speed_override: 1,
|
|
||||||
feed_override: 1,
|
|
||||||
jog_incr_amounts: {
|
jog_incr_amounts: {
|
||||||
METRIC: {
|
METRIC: {
|
||||||
fine: 0.1,
|
fine: 0.1,
|
||||||
@@ -38,34 +29,14 @@ module.exports = {
|
|||||||
jog_incr: localStorage.getItem("jog_incr") || "small",
|
jog_incr: localStorage.getItem("jog_incr") || "small",
|
||||||
jog_step: cookie.get_bool("jog-step"),
|
jog_step: cookie.get_bool("jog-step"),
|
||||||
jog_adjust: parseInt(cookie.get("jog-adjust", 2)),
|
jog_adjust: parseInt(cookie.get("jog-adjust", 2)),
|
||||||
deleteGCode: false,
|
|
||||||
tab: "auto",
|
|
||||||
ask_home: true,
|
ask_home: true,
|
||||||
folder_name: "",
|
|
||||||
edited: false,
|
|
||||||
uploading_files: false,
|
|
||||||
confirmDelete: false,
|
|
||||||
create_folder: false,
|
|
||||||
showGcodeMessage: false,
|
|
||||||
showNoGcodeMessage: false,
|
|
||||||
macrosLoading: false,
|
|
||||||
show_gcodes: false,
|
|
||||||
GCodeNotFound: false,
|
|
||||||
show_probe_dialog: false,
|
show_probe_dialog: false,
|
||||||
filesUploaded: 0,
|
overrides_open: false,
|
||||||
totalFiles: 0,
|
|
||||||
files_sortby: "By Upload Date",
|
|
||||||
selected_items_to_delete: [],
|
|
||||||
search_query: "",
|
|
||||||
filtered_files: [],
|
|
||||||
selected_folder_index: null,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
"axis-control": require("./axis-control"),
|
"axis-control": require("./axis-control"),
|
||||||
"path-viewer": require("./path-viewer"),
|
|
||||||
"gcode-viewer": require("./gcode-viewer"),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@@ -80,16 +51,6 @@ module.exports = {
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"state.line": function () {
|
|
||||||
if (this.mach_state != "HOMING") {
|
|
||||||
this.$broadcast("gcode-line", this.state.line);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"state.selected_time": function () {
|
|
||||||
this.load();
|
|
||||||
},
|
|
||||||
|
|
||||||
jog_step: function () {
|
jog_step: function () {
|
||||||
cookie.set_bool("jog-step", this.jog_step);
|
cookie.set_bool("jog-step", this.jog_step);
|
||||||
},
|
},
|
||||||
@@ -127,43 +88,16 @@ module.exports = {
|
|||||||
return state || "";
|
return state || "";
|
||||||
},
|
},
|
||||||
|
|
||||||
pause_reason: function () {
|
can_set_axis: function () {
|
||||||
return this.state.pr;
|
return this.state.cycle == "idle";
|
||||||
},
|
|
||||||
|
|
||||||
is_running: function () {
|
|
||||||
return this.mach_state == "RUNNING" || this.mach_state == "HOMING";
|
|
||||||
},
|
|
||||||
|
|
||||||
is_stopping: function () {
|
|
||||||
return this.mach_state == "STOPPING";
|
|
||||||
},
|
|
||||||
|
|
||||||
is_holding: function () {
|
|
||||||
return this.mach_state == "HOLDING";
|
|
||||||
},
|
|
||||||
|
|
||||||
is_ready: function () {
|
|
||||||
return this.mach_state == "READY";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
is_idle: function () {
|
is_idle: function () {
|
||||||
return this.state.cycle == "idle";
|
return this.state.cycle == "idle";
|
||||||
},
|
},
|
||||||
|
|
||||||
is_paused: function () {
|
is_ready: function () {
|
||||||
return this.is_holding && (this.pause_reason == "User pause" || this.pause_reason == "Program pause");
|
return this.mach_state == "READY";
|
||||||
},
|
|
||||||
|
|
||||||
can_mdi: function () {
|
|
||||||
return this.is_idle || this.state.cycle == "mdi";
|
|
||||||
},
|
|
||||||
|
|
||||||
can_set_axis: function () {
|
|
||||||
return this.is_idle;
|
|
||||||
|
|
||||||
// TODO allow setting axis position during pause
|
|
||||||
// return this.is_idle || this.is_paused;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
message: function () {
|
message: function () {
|
||||||
@@ -191,57 +125,21 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
plan_time_remaining: function () {
|
plan_time_remaining: function () {
|
||||||
if (!(this.is_stopping || this.is_running || this.is_holding)) {
|
const stopping = this.mach_state == "STOPPING";
|
||||||
return 0;
|
const running = this.mach_state == "RUNNING" || this.mach_state == "HOMING";
|
||||||
}
|
const holding = this.mach_state == "HOLDING";
|
||||||
|
if (!(stopping || running || holding)) return 0;
|
||||||
return this.toolpath.time - this.plan_time;
|
const tp = this.$root && this.$root.toolpath ? this.$root.toolpath.time : 0;
|
||||||
|
return (tp || 0) - this.plan_time;
|
||||||
},
|
},
|
||||||
|
|
||||||
eta: function () {
|
state_kpi_class: function () {
|
||||||
if (this.mach_state != "RUNNING") {
|
const s = this.mach_state;
|
||||||
|
if (s == "ESTOPPED" || s == "FAULT" || s == "SHUTDOWN") return "bad";
|
||||||
|
if (s == "HOLDING" || s == "STOPPING") return "warn";
|
||||||
|
if (s == "RUNNING" || s == "HOMING" || s == "JOGGING") return "busy";
|
||||||
|
if (s == "READY") return "ok";
|
||||||
return "";
|
return "";
|
||||||
}
|
|
||||||
|
|
||||||
const remaining = this.plan_time_remaining;
|
|
||||||
const d = new Date();
|
|
||||||
d.setSeconds(d.getSeconds() + remaining);
|
|
||||||
return d.toLocaleString();
|
|
||||||
},
|
|
||||||
|
|
||||||
progress: function () {
|
|
||||||
if (!this.toolpath.time || this.is_ready) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const p = this.plan_time / this.toolpath.time;
|
|
||||||
return Math.min(1, p);
|
|
||||||
},
|
|
||||||
gcode_files: function () {
|
|
||||||
if (!this.state.folder) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const folder = this.state.gcode_list.find(item => item.name == this.state.folder);
|
|
||||||
if (!folder) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const files = folder.files.filter(item => this.state.files.includes(item.file_name)).map(item => item.file_name);
|
|
||||||
if (this.files_sortby == "A-Z") {
|
|
||||||
return files.sort();
|
|
||||||
} else if (this.files_sortby == "Z-A") {
|
|
||||||
return files.sort().reverse();
|
|
||||||
} else {
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
gcode_filtered_files: function () {
|
|
||||||
return this.filtered_files.filter(file => file.toLowerCase().includes(this.search_query.toLowerCase()));
|
|
||||||
},
|
|
||||||
gcode_folders: function () {
|
|
||||||
return this.state.gcode_list
|
|
||||||
.map(item => item.name)
|
|
||||||
.filter(element => element !== "default")
|
|
||||||
.sort();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -264,14 +162,9 @@ module.exports = {
|
|||||||
M72
|
M72
|
||||||
`);
|
`);
|
||||||
},
|
},
|
||||||
folder_name_edited: function () {
|
|
||||||
this.edited = true;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function () {
|
ready: function () {
|
||||||
this.load();
|
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.current_time = new Date().toLocaleTimeString();
|
this.current_time = new Date().toLocaleTimeString();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -287,28 +180,39 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
save_config: async function (config) {
|
|
||||||
try {
|
|
||||||
await api.put("config/save", config);
|
|
||||||
this.$dispatch("update");
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Restore Failed: ", error);
|
|
||||||
alert("Restore failed");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
populateFiles(index) {
|
|
||||||
this.selected_folder_index = index;
|
|
||||||
this.filtered_files = this.state.gcode_list[index].files.map(item => item.file_name);
|
|
||||||
},
|
|
||||||
|
|
||||||
getJogIncrStyle(value) {
|
getJogIncrStyle(value) {
|
||||||
const weight = `font-weight:${this.jog_incr === value ? "bold" : "normal"}`;
|
const weight = `font-weight:${this.jog_incr === value ? "bold" : "normal"}`;
|
||||||
const color = this.jog_incr === value ? "color:#0078e7" : "";
|
const color = this.jog_incr === value ? "color:#0078e7" : "";
|
||||||
|
|
||||||
return [weight, color].join(";");
|
return [weight, color].join(";");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Should the macro row render a colored left stripe for this
|
||||||
|
// macro? Only when the user has explicitly picked a color. The
|
||||||
|
// controller seeds new macros with default placeholders like
|
||||||
|
// "#ffffff" or "#dedede"; treat anything that close to white as
|
||||||
|
// "no color".
|
||||||
|
has_macro_color(macros) {
|
||||||
|
if (!macros || typeof macros.color !== "string") return false;
|
||||||
|
const c = macros.color.trim().toLowerCase();
|
||||||
|
if (!c) return false;
|
||||||
|
const defaults = [
|
||||||
|
"#fff", "#ffffff", "#fefefe", "#fdfdfd", "#fcfcfc",
|
||||||
|
"#dedede", "#dddddd", "#cccccc",
|
||||||
|
];
|
||||||
|
if (defaults.indexOf(c) !== -1) return false;
|
||||||
|
// Fallback: if the color is very close to white (sum of RGB
|
||||||
|
// > 690), suppress the stripe.
|
||||||
|
const m = c.match(/^#([0-9a-f]{6})$/);
|
||||||
|
if (m) {
|
||||||
|
const v = parseInt(m[1], 16);
|
||||||
|
const r = (v >> 16) & 0xff;
|
||||||
|
const g = (v >> 8) & 0xff;
|
||||||
|
const b = v & 0xff;
|
||||||
|
if (r + g + b > 690) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
jog_fn: function (x_jog, y_jog, z_jog, a_jog) {
|
jog_fn: function (x_jog, y_jog, z_jog, a_jog) {
|
||||||
const amount = this.jog_incr_amounts[this.display_units][this.jog_incr];
|
const amount = this.jog_incr_amounts[this.display_units][this.jog_incr];
|
||||||
|
|
||||||
@@ -324,426 +228,6 @@ module.exports = {
|
|||||||
`);
|
`);
|
||||||
},
|
},
|
||||||
|
|
||||||
send: function (msg) {
|
|
||||||
this.$dispatch("send", msg);
|
|
||||||
},
|
|
||||||
|
|
||||||
toggle_sorting: function () {
|
|
||||||
if (this.files_sortby === "By Upload Date") {
|
|
||||||
this.files_sortby = "A-Z";
|
|
||||||
} else if (this.files_sortby === "A-Z") {
|
|
||||||
this.files_sortby = "Z-A";
|
|
||||||
} else if (this.files_sortby === "Z-A") {
|
|
||||||
this.files_sortby = "By Upload Date";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
load: function () {
|
|
||||||
const file_time = this.state.selected_time;
|
|
||||||
const file = this.state.selected;
|
|
||||||
if (this.last_file == file && this.last_file_time == file_time) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.state.selected && !this.state.files.includes(this.state.selected)) {
|
|
||||||
this.GCodeNotFound = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.last_file = file;
|
|
||||||
this.last_file_time = file_time;
|
|
||||||
|
|
||||||
this.$broadcast("gcode-load", file);
|
|
||||||
this.$broadcast("gcode-line", this.state.line);
|
|
||||||
this.toolpath_progress = 0;
|
|
||||||
this.load_toolpath(file, file_time);
|
|
||||||
},
|
|
||||||
|
|
||||||
load_toolpath: async function (file, file_time) {
|
|
||||||
this.toolpath = {};
|
|
||||||
|
|
||||||
if (!file || this.last_file_time != file_time) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.showGcodeMessage = true;
|
|
||||||
|
|
||||||
while (this.showGcodeMessage) {
|
|
||||||
try {
|
|
||||||
const toolpath = await api.get(`path/${file}`);
|
|
||||||
this.toolpath_progress = toolpath.progress;
|
|
||||||
|
|
||||||
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;
|
|
||||||
for (const axis of "xyzabc") {
|
|
||||||
Vue.set(state, `path_min_${axis}`, toolpath.bounds.min[axis]);
|
|
||||||
Vue.set(state, `path_max_${axis}`, toolpath.bounds.max[axis]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
submit_mdi: function () {
|
|
||||||
this.send(this.mdi);
|
|
||||||
|
|
||||||
if (!this.history.length || this.history[0] != this.mdi) {
|
|
||||||
this.history.unshift(this.mdi);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mdi = "";
|
|
||||||
},
|
|
||||||
|
|
||||||
mdi_start_pause: function () {
|
|
||||||
if (this.state.xx == "RUNNING") {
|
|
||||||
this.pause();
|
|
||||||
} else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") {
|
|
||||||
this.unpause();
|
|
||||||
} else {
|
|
||||||
this.submit_mdi();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
load_history: function (index) {
|
|
||||||
this.mdi = this.history[index];
|
|
||||||
},
|
|
||||||
|
|
||||||
open_file: function () {
|
|
||||||
utils.clickFileInput("gcode-file-input");
|
|
||||||
},
|
|
||||||
|
|
||||||
open_folder: function () {
|
|
||||||
utils.clickFileInput("gcode-folder-input");
|
|
||||||
},
|
|
||||||
|
|
||||||
edited_folder_name: function (event) {
|
|
||||||
if (event.target.value.trim() != "") {
|
|
||||||
this.$dispatch("folder_name_edited");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
update_config: function () {
|
|
||||||
this.config.gcode_list = [...this.state.gcode_list];
|
|
||||||
this.config.non_macros_list = [...this.state.non_macros_list];
|
|
||||||
this.config.macros_list = [...this.state.macros_list];
|
|
||||||
this.config.macros = [...this.state.macros];
|
|
||||||
},
|
|
||||||
|
|
||||||
reset_gcode: function () {
|
|
||||||
this.state.selected = "";
|
|
||||||
this.last_file = "";
|
|
||||||
this.$broadcast("gcode-load", "");
|
|
||||||
},
|
|
||||||
|
|
||||||
upload_gcode: async function (filename, file) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
|
|
||||||
this.filesUploaded++;
|
|
||||||
if (this.filesUploaded == this.totalFiles) {
|
|
||||||
this.uploading_files = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
xhr.onload = () => {
|
|
||||||
if (xhr.status >= 200 && xhr.status < 300) {
|
|
||||||
resolve("file uploaded");
|
|
||||||
} else {
|
|
||||||
console.error("File upload failed:", xhr.statusText);
|
|
||||||
reject("upload failed");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.onerror = () => {
|
|
||||||
alert("Upload failed.");
|
|
||||||
reject("upload failed");
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true);
|
|
||||||
xhr.send(file);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
readFile: function (file) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onload = () => {
|
|
||||||
resolve(reader.result);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.onerror = error => {
|
|
||||||
reject(error);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(file, "utf-8");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
validateFiles: async function (files) {
|
|
||||||
const validFiles = [];
|
|
||||||
for (const file of files) {
|
|
||||||
const extension = file.name.split(".").pop().toLowerCase();
|
|
||||||
const validExtensions = ["nc", "ngc", "gcode", "gc"];
|
|
||||||
|
|
||||||
if (validExtensions.includes(extension)) {
|
|
||||||
validFiles.push(file);
|
|
||||||
} else {
|
|
||||||
alert(`Unsupported file : ${file.name}`);
|
|
||||||
this.filesUploaded++;
|
|
||||||
if (this.filesUploaded == this.totalFiles) {
|
|
||||||
this.uploadFiles = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return validFiles;
|
|
||||||
},
|
|
||||||
|
|
||||||
uploadValidFiles: async function (files, folderName) {
|
|
||||||
const updatedConfig = { ...this.config };
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
try {
|
|
||||||
const gcode = await this.readFile(file);
|
|
||||||
await this.upload_gcode(file.name, gcode);
|
|
||||||
|
|
||||||
const isAlreadyPresent = updatedConfig.non_macros_list.some(element => element.file_name === file.name);
|
|
||||||
|
|
||||||
if (!isAlreadyPresent) {
|
|
||||||
updatedConfig.non_macros_list.push({ file_name: file.name });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folderName) {
|
|
||||||
const folder = updatedConfig.gcode_list.find(item => item.type == "folder" && item.name == folderName);
|
|
||||||
if (folder) {
|
|
||||||
if (!folder.files.map(item => item.file_name).includes(file.name)) {
|
|
||||||
folder.files.push({ file_name: file.name });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
updatedConfig.gcode_list.push({
|
|
||||||
name: folderName,
|
|
||||||
type: "folder",
|
|
||||||
files: [
|
|
||||||
{
|
|
||||||
file_name: file.name,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var folder_to_add = updatedConfig.gcode_list.find(
|
|
||||||
item => item.type == "folder" && item.name == this.state.folder,
|
|
||||||
);
|
|
||||||
if (!folder_to_add) {
|
|
||||||
folder_to_add = updatedConfig.gcode_list.unshift({
|
|
||||||
name: this.state.folder,
|
|
||||||
type: "folder",
|
|
||||||
files: [
|
|
||||||
{
|
|
||||||
file_name: file.name,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
folder_to_add = updatedConfig.gcode_list[0];
|
|
||||||
}
|
|
||||||
if (!folder_to_add.files.find(item => item.file_name == file.name)) {
|
|
||||||
folder_to_add.files.push({ file_name: file.name });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(`error uploading file : `, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return updatedConfig;
|
|
||||||
},
|
|
||||||
|
|
||||||
upload_files: async function (files, folderName) {
|
|
||||||
this.update_config();
|
|
||||||
|
|
||||||
const validFiles = await this.validateFiles(files);
|
|
||||||
const updatedConfig = await this.uploadValidFiles(validFiles, folderName);
|
|
||||||
|
|
||||||
await this.save_config(updatedConfig);
|
|
||||||
},
|
|
||||||
|
|
||||||
upload_file: async function (e) {
|
|
||||||
this.uploading_files = true;
|
|
||||||
this.filesUploaded = 0;
|
|
||||||
|
|
||||||
const files = e.target.files || e.dataTransfer.files;
|
|
||||||
if (!files.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.totalFiles = files.length;
|
|
||||||
|
|
||||||
await this.upload_files(files);
|
|
||||||
},
|
|
||||||
|
|
||||||
create_new_folder: async function () {
|
|
||||||
const folder_name = this.folder_name.trim();
|
|
||||||
if (folder_name != "") {
|
|
||||||
if (this.state.gcode_list.find(item => item.type == "folder" && item.name == folder_name)) {
|
|
||||||
alert("Folder with the same name already exists!");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.update_config();
|
|
||||||
this.config.gcode_list.push({
|
|
||||||
name: folder_name,
|
|
||||||
type: "folder",
|
|
||||||
files: [],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.state.folder = folder_name;
|
|
||||||
this.edited = false;
|
|
||||||
this.create_folder = false;
|
|
||||||
this.folder_name = "";
|
|
||||||
this.save_config(this.config);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
cancel_new_folder: function () {
|
|
||||||
this.create_folder = false;
|
|
||||||
this.folder_name = "";
|
|
||||||
},
|
|
||||||
|
|
||||||
upload_folder: async function (e) {
|
|
||||||
this.uploading_files = true;
|
|
||||||
this.filesUploaded = 0;
|
|
||||||
|
|
||||||
const files = e.target.files || e.dataTransfer.files;
|
|
||||||
if (!files.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.totalFiles = files.length;
|
|
||||||
const folderName = files[0].webkitRelativePath.split("/")[0];
|
|
||||||
|
|
||||||
this.upload_files(files, folderName);
|
|
||||||
},
|
|
||||||
|
|
||||||
delete_current: async function () {
|
|
||||||
if (!this.state.selected) {
|
|
||||||
this.deleteGCode = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.update_config();
|
|
||||||
|
|
||||||
this.config.non_macros_list = this.config.non_macros_list.filter(
|
|
||||||
item => !this.selected_items_to_delete.includes(item.file_name),
|
|
||||||
);
|
|
||||||
const folder_to_update = this.config.gcode_list.find(
|
|
||||||
item => item.name == this.config.gcode_list[this.selected_folder_index].name && item.type == "folder",
|
|
||||||
);
|
|
||||||
folder_to_update.files = folder_to_update.files.filter(
|
|
||||||
item => !this.selected_items_to_delete.includes(item.file_name),
|
|
||||||
);
|
|
||||||
|
|
||||||
const exception_list = this.state.macros_list.map(item => item.file_name);
|
|
||||||
let files_to_delete = this.selected_items_to_delete.filter(item => !exception_list.includes(item));
|
|
||||||
|
|
||||||
await api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${files_to_delete.toString()}`);
|
|
||||||
|
|
||||||
this.save_config(this.config);
|
|
||||||
this.filtered_files = [];
|
|
||||||
this.search_query = "";
|
|
||||||
this.selected_folder_index = null;
|
|
||||||
this.selected_items_to_delete = [];
|
|
||||||
this.deleteGCode = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
cancel_delete: function () {
|
|
||||||
this.filtered_files = [];
|
|
||||||
this.search_query = "";
|
|
||||||
this.selected_folder_index = null;
|
|
||||||
this.selected_items_to_delete = [];
|
|
||||||
this.deleteGCode = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
delete_all: function () {
|
|
||||||
api.delete("file");
|
|
||||||
this.deleteGCode = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
delete_all_except_macros: async function () {
|
|
||||||
this.update_config();
|
|
||||||
const macrosList = this.state.macros_list.map(item => item.file_name).toString();
|
|
||||||
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
|
|
||||||
this.config.non_macros_list = [];
|
|
||||||
this.config.gcode_list = [
|
|
||||||
{
|
|
||||||
name: "default",
|
|
||||||
type: "folder",
|
|
||||||
files: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
this.save_config(this.config);
|
|
||||||
this.state.folder = "default";
|
|
||||||
this.state.selected = "";
|
|
||||||
this.selected_items_to_delete = [];
|
|
||||||
this.deleteGCode = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
delete_folder: async function () {
|
|
||||||
this.update_config();
|
|
||||||
if (this.state.folder && this.state.folder != "default") {
|
|
||||||
const files_to_move = this.config.gcode_list.find(
|
|
||||||
item => item.type == "folder" && item.name == this.state.folder,
|
|
||||||
);
|
|
||||||
if (files_to_move) {
|
|
||||||
const default_folder = this.config.gcode_list.find(item => item.name == "default");
|
|
||||||
default_folder.files = [...default_folder.files, ...files_to_move.files].sort();
|
|
||||||
this.config.gcode_list = this.config.gcode_list.filter(item => item.name != this.state.folder);
|
|
||||||
this.save_config(this.config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.state.folder = "default";
|
|
||||||
this.confirmDelete = false;
|
|
||||||
},
|
|
||||||
delete_folder_and_files: async function () {
|
|
||||||
if (!this.state.folder) {
|
|
||||||
this.confirmDelete = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.update_config();
|
|
||||||
|
|
||||||
const selected_folder = this.config.gcode_list.find(
|
|
||||||
item => item.type == "folder" && item.name == this.state.folder,
|
|
||||||
);
|
|
||||||
if (!selected_folder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const macrosList = this.state.macros_list.map(item => item.file_name);
|
|
||||||
var files_to_delete = selected_folder.files
|
|
||||||
.map(item => item.file_name)
|
|
||||||
.filter(item => !macrosList.includes(item));
|
|
||||||
if (selected_folder.name != "default") {
|
|
||||||
this.config.gcode_list = this.config.gcode_list.filter(item => item.name != this.state.folder);
|
|
||||||
} else {
|
|
||||||
selected_folder.files = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
await api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${files_to_delete.toString()}`);
|
|
||||||
this.config.non_macros_list = this.config.non_macros_list.filter(
|
|
||||||
item => !files_to_delete.includes(item.file_name),
|
|
||||||
);
|
|
||||||
this.save_config(this.config);
|
|
||||||
this.state.folder = "default";
|
|
||||||
this.confirmDelete = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
home: function (axis) {
|
home: function (axis) {
|
||||||
this.ask_home = false;
|
this.ask_home = false;
|
||||||
|
|
||||||
@@ -765,6 +249,15 @@ module.exports = {
|
|||||||
api.put(`home/${axis}/clear`);
|
api.put(`home/${axis}/clear`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
home_all: async function () {
|
||||||
|
this.ask_home = false;
|
||||||
|
try {
|
||||||
|
await api.put("home");
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Home all failed:", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
show_set_position: function (axis) {
|
show_set_position: function (axis) {
|
||||||
SvelteComponents.showDialog("SetAxisPosition", { axis });
|
SvelteComponents.showDialog("SetAxisPosition", { axis });
|
||||||
},
|
},
|
||||||
@@ -790,93 +283,20 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
zero: function (axis) {
|
zero: function (axis) {
|
||||||
if (typeof axis == "undefined") {
|
if (typeof axis == "undefined") this.zero_all();
|
||||||
this.zero_all();
|
else this.set_position(axis, 0);
|
||||||
} else {
|
|
||||||
this.set_position(axis, 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
start_pause: function () {
|
|
||||||
this.macrosLoading = false;
|
|
||||||
if (this.state.xx == "RUNNING") {
|
|
||||||
this.pause();
|
|
||||||
} else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") {
|
|
||||||
this.unpause();
|
|
||||||
} else {
|
|
||||||
this.start();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
start: function () {
|
|
||||||
api.put("start");
|
|
||||||
},
|
|
||||||
|
|
||||||
pause: function () {
|
|
||||||
api.put("pause");
|
|
||||||
},
|
|
||||||
|
|
||||||
unpause: function () {
|
|
||||||
api.put("unpause");
|
|
||||||
},
|
|
||||||
|
|
||||||
optional_pause: function () {
|
|
||||||
api.put("pause/optional");
|
|
||||||
},
|
|
||||||
|
|
||||||
stop: function () {
|
|
||||||
api.put("stop");
|
|
||||||
},
|
|
||||||
|
|
||||||
step: function () {
|
|
||||||
api.put("step");
|
|
||||||
},
|
|
||||||
|
|
||||||
override_feed: function () {
|
|
||||||
api.put(`override/feed/${this.feed_override}`);
|
|
||||||
},
|
|
||||||
|
|
||||||
override_speed: function () {
|
|
||||||
api.put(`override/speed/${this.speed_override}`);
|
|
||||||
},
|
|
||||||
|
|
||||||
current: function (axis, value) {
|
|
||||||
const x = value / 32.0;
|
|
||||||
if (this.state[`${axis}pl`] == x) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = {};
|
|
||||||
data[`${axis}pl`] = x;
|
|
||||||
this.send(JSON.stringify(data));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showProbeDialog: function (probeType) {
|
showProbeDialog: function (probeType) {
|
||||||
if(this.show_probe_dialog){
|
if (this.show_probe_dialog) {
|
||||||
this.show_probe_dialog = false;
|
this.show_probe_dialog = false;
|
||||||
}
|
}
|
||||||
SvelteComponents.showDialog("Probe", { probeType, isRotaryActive: this.state["2an"] == 3 });
|
SvelteComponents.showDialog("Probe", {
|
||||||
},
|
probeType,
|
||||||
run_macro: function (id) {
|
isRotaryActive: this.state["2an"] == 3,
|
||||||
if (this.state.macros[id].file_name == "default") {
|
});
|
||||||
this.showNoGcodeMessage = true;
|
|
||||||
} else {
|
|
||||||
if (this.state.macros[id].file_name != this.state.selected) {
|
|
||||||
this.state.selected = this.state.macros[id].file_name;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
this.load();
|
|
||||||
if (this.state.macros[id].alert == true) {
|
|
||||||
this.macrosLoading = true;
|
|
||||||
} else {
|
|
||||||
setImmediate(() => this.start_pause());
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Error running program: ", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [require("./axis-vars")],
|
mixins: [require("./program-mixin"), require("./axis-vars")],
|
||||||
};
|
};
|
||||||
|
|||||||
607
src/js/program-mixin.js
Normal file
607
src/js/program-mixin.js
Normal file
@@ -0,0 +1,607 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Shared data, computed properties and methods that are used by both
|
||||||
|
// the Control view (for things like start/stop, run-macro, axis state)
|
||||||
|
// and the Program view (RUN/STOP/Upload/Download/Delete + file picker
|
||||||
|
// + gcode/path viewers). Splitting these out lets us mount the same
|
||||||
|
// behaviour under two top-level routes without duplicating code.
|
||||||
|
//
|
||||||
|
// The mixin intentionally does *not* require axis-vars; control-view
|
||||||
|
// keeps that one to itself.
|
||||||
|
|
||||||
|
const api = require("./api");
|
||||||
|
const utils = require("./utils");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
mdi: "",
|
||||||
|
last_file: undefined,
|
||||||
|
last_file_time: undefined,
|
||||||
|
toolpath: {},
|
||||||
|
toolpath_progress: 0,
|
||||||
|
history: [],
|
||||||
|
speed_override: 1,
|
||||||
|
feed_override: 1,
|
||||||
|
deleteGCode: false,
|
||||||
|
folder_name: "",
|
||||||
|
edited: false,
|
||||||
|
uploading_files: false,
|
||||||
|
confirmDelete: false,
|
||||||
|
create_folder: false,
|
||||||
|
showGcodeMessage: false,
|
||||||
|
showNoGcodeMessage: false,
|
||||||
|
macrosLoading: false,
|
||||||
|
show_gcodes: false,
|
||||||
|
GCodeNotFound: false,
|
||||||
|
filesUploaded: 0,
|
||||||
|
totalFiles: 0,
|
||||||
|
files_sortby: "By Upload Date",
|
||||||
|
selected_items_to_delete: [],
|
||||||
|
search_query: "",
|
||||||
|
filtered_files: [],
|
||||||
|
selected_folder_index: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
"state.line": function () {
|
||||||
|
if (this.mach_state != "HOMING") {
|
||||||
|
this.$broadcast("gcode-line", this.state.line);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"state.selected_time": function () {
|
||||||
|
this.load();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
is_running: function () {
|
||||||
|
return this.mach_state == "RUNNING" || this.mach_state == "HOMING";
|
||||||
|
},
|
||||||
|
|
||||||
|
is_stopping: function () {
|
||||||
|
return this.mach_state == "STOPPING";
|
||||||
|
},
|
||||||
|
|
||||||
|
is_holding: function () {
|
||||||
|
return this.mach_state == "HOLDING";
|
||||||
|
},
|
||||||
|
|
||||||
|
is_ready: function () {
|
||||||
|
return this.mach_state == "READY";
|
||||||
|
},
|
||||||
|
|
||||||
|
is_idle: function () {
|
||||||
|
return this.state.cycle == "idle";
|
||||||
|
},
|
||||||
|
|
||||||
|
// True only while a loaded G-code program is actually being
|
||||||
|
// executed (running, paused/holding, or stopping). Excludes
|
||||||
|
// jogging, homing, probing, MDI commands and other one-off
|
||||||
|
// motion that also leave state.xx == "RUNNING" but must not
|
||||||
|
// swap the jog grid out for the "Now Running" panel.
|
||||||
|
//
|
||||||
|
// Distinguishing signal is state.cycle:
|
||||||
|
// - "idle" : nothing happening
|
||||||
|
// - "jogging" : user-initiated jog
|
||||||
|
// - "homing" : home cycle
|
||||||
|
// - "probing" : probe cycle
|
||||||
|
// - "mdi" : single MDI command
|
||||||
|
// - "running" : an actual loaded program is being run
|
||||||
|
// Only "running" (combined with a selected file) is what we want.
|
||||||
|
is_program_executing: function () {
|
||||||
|
if (!this.state) return false;
|
||||||
|
const xx = this.state.xx;
|
||||||
|
const cycle = this.state.cycle;
|
||||||
|
const isExecState = xx == "RUNNING" || xx == "HOLDING" || xx == "STOPPING";
|
||||||
|
if (!isExecState) return false;
|
||||||
|
// The cycle string narrows it to a real program run; anything
|
||||||
|
// else (jogging / homing / probing / mdi) is a one-off.
|
||||||
|
if (cycle && cycle != "running" && cycle != "idle") return false;
|
||||||
|
return !!this.state.selected;
|
||||||
|
},
|
||||||
|
|
||||||
|
is_paused: function () {
|
||||||
|
return this.is_holding && (this.pause_reason == "User pause" || this.pause_reason == "Program pause");
|
||||||
|
},
|
||||||
|
|
||||||
|
can_mdi: function () {
|
||||||
|
return this.is_idle || this.state.cycle == "mdi";
|
||||||
|
},
|
||||||
|
|
||||||
|
pause_reason: function () {
|
||||||
|
return this.state.pr;
|
||||||
|
},
|
||||||
|
|
||||||
|
plan_time: function () {
|
||||||
|
return this.state.plan_time;
|
||||||
|
},
|
||||||
|
|
||||||
|
plan_time_remaining: function () {
|
||||||
|
if (!(this.is_stopping || this.is_running || this.is_holding)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this.toolpath.time - this.plan_time;
|
||||||
|
},
|
||||||
|
|
||||||
|
eta: function () {
|
||||||
|
if (this.mach_state != "RUNNING") {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const remaining = this.plan_time_remaining;
|
||||||
|
const d = new Date();
|
||||||
|
d.setSeconds(d.getSeconds() + remaining);
|
||||||
|
return d.toLocaleString();
|
||||||
|
},
|
||||||
|
|
||||||
|
progress: function () {
|
||||||
|
if (!this.toolpath.time || this.is_ready) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const p = this.plan_time / this.toolpath.time;
|
||||||
|
return Math.min(1, p);
|
||||||
|
},
|
||||||
|
|
||||||
|
gcode_files: function () {
|
||||||
|
if (!this.state.folder) return [];
|
||||||
|
const list = Array.isArray(this.state.gcode_list) ? this.state.gcode_list : [];
|
||||||
|
const folder = list.find(item => item.name == this.state.folder);
|
||||||
|
if (!folder) return [];
|
||||||
|
const stateFiles = Array.isArray(this.state.files) ? this.state.files : [];
|
||||||
|
const files = (folder.files || [])
|
||||||
|
.filter(item => stateFiles.includes(item.file_name))
|
||||||
|
.map(item => item.file_name);
|
||||||
|
if (this.files_sortby == "A-Z") return files.sort();
|
||||||
|
if (this.files_sortby == "Z-A") return files.sort().reverse();
|
||||||
|
return files;
|
||||||
|
},
|
||||||
|
|
||||||
|
gcode_filtered_files: function () {
|
||||||
|
return this.filtered_files.filter(file =>
|
||||||
|
file.toLowerCase().includes(this.search_query.toLowerCase()));
|
||||||
|
},
|
||||||
|
|
||||||
|
gcode_folders: function () {
|
||||||
|
const list = Array.isArray(this.state.gcode_list) ? this.state.gcode_list : [];
|
||||||
|
return list
|
||||||
|
.map(item => item.name)
|
||||||
|
.filter(element => element !== "default")
|
||||||
|
.sort();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
save_config: async function (config) {
|
||||||
|
try {
|
||||||
|
await api.put("config/save", config);
|
||||||
|
this.$dispatch("update");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Restore Failed: ", error);
|
||||||
|
alert("Restore failed");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
populateFiles(index) {
|
||||||
|
this.selected_folder_index = index;
|
||||||
|
this.filtered_files = this.state.gcode_list[index].files.map(item => item.file_name);
|
||||||
|
},
|
||||||
|
|
||||||
|
send: function (msg) {
|
||||||
|
this.$dispatch("send", msg);
|
||||||
|
},
|
||||||
|
|
||||||
|
toggle_sorting: function () {
|
||||||
|
if (this.files_sortby === "By Upload Date") this.files_sortby = "A-Z";
|
||||||
|
else if (this.files_sortby === "A-Z") this.files_sortby = "Z-A";
|
||||||
|
else if (this.files_sortby === "Z-A") this.files_sortby = "By Upload Date";
|
||||||
|
},
|
||||||
|
|
||||||
|
load: function () {
|
||||||
|
const file_time = this.state.selected_time;
|
||||||
|
const file = this.state.selected;
|
||||||
|
if (this.last_file == file && this.last_file_time == file_time) return;
|
||||||
|
|
||||||
|
// state.files can be undefined briefly after connect, before the
|
||||||
|
// controller has pushed its file list. Skip the existence check
|
||||||
|
// until we have a list to consult.
|
||||||
|
const files = Array.isArray(this.state.files) ? this.state.files : null;
|
||||||
|
if (this.state.selected && files && !files.includes(this.state.selected)) {
|
||||||
|
this.GCodeNotFound = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.last_file = file;
|
||||||
|
this.last_file_time = file_time;
|
||||||
|
|
||||||
|
this.$broadcast("gcode-load", file);
|
||||||
|
this.$broadcast("gcode-line", this.state.line);
|
||||||
|
this.toolpath_progress = 0;
|
||||||
|
this.load_toolpath(file, file_time);
|
||||||
|
},
|
||||||
|
|
||||||
|
load_toolpath: async function (file, file_time) {
|
||||||
|
this.toolpath = {};
|
||||||
|
if (!file || this.last_file_time != file_time) return;
|
||||||
|
|
||||||
|
this.showGcodeMessage = true;
|
||||||
|
|
||||||
|
while (this.showGcodeMessage) {
|
||||||
|
try {
|
||||||
|
const toolpath = await api.get(`path/${file}`);
|
||||||
|
this.toolpath_progress = toolpath.progress;
|
||||||
|
|
||||||
|
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;
|
||||||
|
for (const axis of "xyzabc") {
|
||||||
|
Vue.set(state, `path_min_${axis}`, toolpath.bounds.min[axis]);
|
||||||
|
Vue.set(state, `path_max_${axis}`, toolpath.bounds.max[axis]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
submit_mdi: function () {
|
||||||
|
this.send(this.mdi);
|
||||||
|
if (!this.history.length || this.history[0] != this.mdi) {
|
||||||
|
this.history.unshift(this.mdi);
|
||||||
|
}
|
||||||
|
this.mdi = "";
|
||||||
|
},
|
||||||
|
|
||||||
|
mdi_start_pause: function () {
|
||||||
|
if (this.state.xx == "RUNNING") this.pause();
|
||||||
|
else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") this.unpause();
|
||||||
|
else this.submit_mdi();
|
||||||
|
},
|
||||||
|
|
||||||
|
load_history: function (index) {
|
||||||
|
this.mdi = this.history[index];
|
||||||
|
},
|
||||||
|
|
||||||
|
open_file: function () {
|
||||||
|
utils.clickFileInput("gcode-file-input");
|
||||||
|
},
|
||||||
|
|
||||||
|
open_folder: function () {
|
||||||
|
utils.clickFileInput("gcode-folder-input");
|
||||||
|
},
|
||||||
|
|
||||||
|
edited_folder_name: function (event) {
|
||||||
|
if (event.target.value.trim() != "") {
|
||||||
|
this.$dispatch("folder_name_edited");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
update_config: function () {
|
||||||
|
this.config.gcode_list = [...this.state.gcode_list];
|
||||||
|
this.config.non_macros_list = [...this.state.non_macros_list];
|
||||||
|
this.config.macros_list = [...this.state.macros_list];
|
||||||
|
this.config.macros = [...this.state.macros];
|
||||||
|
},
|
||||||
|
|
||||||
|
reset_gcode: function () {
|
||||||
|
this.state.selected = "";
|
||||||
|
this.last_file = "";
|
||||||
|
this.$broadcast("gcode-load", "");
|
||||||
|
},
|
||||||
|
|
||||||
|
upload_gcode: async function (filename, file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
this.filesUploaded++;
|
||||||
|
if (this.filesUploaded == this.totalFiles) {
|
||||||
|
this.uploading_files = false;
|
||||||
|
}
|
||||||
|
xhr.onload = () => {
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300) resolve("file uploaded");
|
||||||
|
else { console.error("File upload failed:", xhr.statusText); reject("upload failed"); }
|
||||||
|
};
|
||||||
|
xhr.onerror = () => { alert("Upload failed."); reject("upload failed"); };
|
||||||
|
xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true);
|
||||||
|
xhr.send(file);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
readFile: function (file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => resolve(reader.result);
|
||||||
|
reader.onerror = error => reject(error);
|
||||||
|
reader.readAsText(file, "utf-8");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
validateFiles: async function (files) {
|
||||||
|
const validFiles = [];
|
||||||
|
for (const file of files) {
|
||||||
|
const extension = file.name.split(".").pop().toLowerCase();
|
||||||
|
const validExtensions = ["nc", "ngc", "gcode", "gc"];
|
||||||
|
if (validExtensions.includes(extension)) {
|
||||||
|
validFiles.push(file);
|
||||||
|
} else {
|
||||||
|
alert(`Unsupported file : ${file.name}`);
|
||||||
|
this.filesUploaded++;
|
||||||
|
if (this.filesUploaded == this.totalFiles) {
|
||||||
|
this.uploadFiles = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validFiles;
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadValidFiles: async function (files, folderName) {
|
||||||
|
const updatedConfig = { ...this.config };
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
try {
|
||||||
|
const gcode = await this.readFile(file);
|
||||||
|
await this.upload_gcode(file.name, gcode);
|
||||||
|
|
||||||
|
const isAlreadyPresent = updatedConfig.non_macros_list.some(element => element.file_name === file.name);
|
||||||
|
if (!isAlreadyPresent) {
|
||||||
|
updatedConfig.non_macros_list.push({ file_name: file.name });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folderName) {
|
||||||
|
const folder = updatedConfig.gcode_list.find(item => item.type == "folder" && item.name == folderName);
|
||||||
|
if (folder) {
|
||||||
|
if (!folder.files.map(item => item.file_name).includes(file.name)) {
|
||||||
|
folder.files.push({ file_name: file.name });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updatedConfig.gcode_list.push({
|
||||||
|
name: folderName,
|
||||||
|
type: "folder",
|
||||||
|
files: [{ file_name: file.name }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var folder_to_add = updatedConfig.gcode_list.find(
|
||||||
|
item => item.type == "folder" && item.name == this.state.folder,
|
||||||
|
);
|
||||||
|
if (!folder_to_add) {
|
||||||
|
folder_to_add = updatedConfig.gcode_list.unshift({
|
||||||
|
name: this.state.folder,
|
||||||
|
type: "folder",
|
||||||
|
files: [{ file_name: file.name }],
|
||||||
|
});
|
||||||
|
folder_to_add = updatedConfig.gcode_list[0];
|
||||||
|
}
|
||||||
|
if (!folder_to_add.files.find(item => item.file_name == file.name)) {
|
||||||
|
folder_to_add.files.push({ file_name: file.name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`error uploading file : `, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return updatedConfig;
|
||||||
|
},
|
||||||
|
|
||||||
|
upload_files: async function (files, folderName) {
|
||||||
|
this.update_config();
|
||||||
|
const validFiles = await this.validateFiles(files);
|
||||||
|
const updatedConfig = await this.uploadValidFiles(validFiles, folderName);
|
||||||
|
await this.save_config(updatedConfig);
|
||||||
|
},
|
||||||
|
|
||||||
|
upload_file: async function (e) {
|
||||||
|
this.uploading_files = true;
|
||||||
|
this.filesUploaded = 0;
|
||||||
|
const files = e.target.files || e.dataTransfer.files;
|
||||||
|
if (!files.length) return;
|
||||||
|
this.totalFiles = files.length;
|
||||||
|
await this.upload_files(files);
|
||||||
|
},
|
||||||
|
|
||||||
|
create_new_folder: async function () {
|
||||||
|
const folder_name = this.folder_name.trim();
|
||||||
|
if (folder_name != "") {
|
||||||
|
if (this.state.gcode_list.find(item => item.type == "folder" && item.name == folder_name)) {
|
||||||
|
alert("Folder with the same name already exists!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.update_config();
|
||||||
|
this.config.gcode_list.push({
|
||||||
|
name: folder_name,
|
||||||
|
type: "folder",
|
||||||
|
files: [],
|
||||||
|
});
|
||||||
|
this.state.folder = folder_name;
|
||||||
|
this.edited = false;
|
||||||
|
this.create_folder = false;
|
||||||
|
this.folder_name = "";
|
||||||
|
this.save_config(this.config);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel_new_folder: function () {
|
||||||
|
this.create_folder = false;
|
||||||
|
this.folder_name = "";
|
||||||
|
},
|
||||||
|
|
||||||
|
upload_folder: async function (e) {
|
||||||
|
this.uploading_files = true;
|
||||||
|
this.filesUploaded = 0;
|
||||||
|
const files = e.target.files || e.dataTransfer.files;
|
||||||
|
if (!files.length) return;
|
||||||
|
this.totalFiles = files.length;
|
||||||
|
const folderName = files[0].webkitRelativePath.split("/")[0];
|
||||||
|
this.upload_files(files, folderName);
|
||||||
|
},
|
||||||
|
|
||||||
|
delete_current: async function () {
|
||||||
|
if (!this.state.selected) {
|
||||||
|
this.deleteGCode = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.update_config();
|
||||||
|
|
||||||
|
this.config.non_macros_list = this.config.non_macros_list.filter(
|
||||||
|
item => !this.selected_items_to_delete.includes(item.file_name),
|
||||||
|
);
|
||||||
|
const folder_to_update = this.config.gcode_list.find(
|
||||||
|
item => item.name == this.config.gcode_list[this.selected_folder_index].name && item.type == "folder",
|
||||||
|
);
|
||||||
|
folder_to_update.files = folder_to_update.files.filter(
|
||||||
|
item => !this.selected_items_to_delete.includes(item.file_name),
|
||||||
|
);
|
||||||
|
|
||||||
|
const exception_list = this.state.macros_list.map(item => item.file_name);
|
||||||
|
let files_to_delete = this.selected_items_to_delete.filter(item => !exception_list.includes(item));
|
||||||
|
|
||||||
|
await api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${files_to_delete.toString()}`);
|
||||||
|
|
||||||
|
this.save_config(this.config);
|
||||||
|
this.filtered_files = [];
|
||||||
|
this.search_query = "";
|
||||||
|
this.selected_folder_index = null;
|
||||||
|
this.selected_items_to_delete = [];
|
||||||
|
this.deleteGCode = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel_delete: function () {
|
||||||
|
this.filtered_files = [];
|
||||||
|
this.search_query = "";
|
||||||
|
this.selected_folder_index = null;
|
||||||
|
this.selected_items_to_delete = [];
|
||||||
|
this.deleteGCode = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
delete_all: function () {
|
||||||
|
api.delete("file");
|
||||||
|
this.deleteGCode = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
delete_all_except_macros: async function () {
|
||||||
|
this.update_config();
|
||||||
|
const macrosList = this.state.macros_list.map(item => item.file_name).toString();
|
||||||
|
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
|
||||||
|
this.config.non_macros_list = [];
|
||||||
|
this.config.gcode_list = [{ name: "default", type: "folder", files: [] }];
|
||||||
|
this.save_config(this.config);
|
||||||
|
this.state.folder = "default";
|
||||||
|
this.state.selected = "";
|
||||||
|
this.selected_items_to_delete = [];
|
||||||
|
this.deleteGCode = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
delete_folder: async function () {
|
||||||
|
this.update_config();
|
||||||
|
if (this.state.folder && this.state.folder != "default") {
|
||||||
|
const files_to_move = this.config.gcode_list.find(
|
||||||
|
item => item.type == "folder" && item.name == this.state.folder,
|
||||||
|
);
|
||||||
|
if (files_to_move) {
|
||||||
|
const default_folder = this.config.gcode_list.find(item => item.name == "default");
|
||||||
|
default_folder.files = [...default_folder.files, ...files_to_move.files].sort();
|
||||||
|
this.config.gcode_list = this.config.gcode_list.filter(item => item.name != this.state.folder);
|
||||||
|
this.save_config(this.config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.state.folder = "default";
|
||||||
|
this.confirmDelete = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
delete_folder_and_files: async function () {
|
||||||
|
if (!this.state.folder) {
|
||||||
|
this.confirmDelete = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.update_config();
|
||||||
|
const selected_folder = this.config.gcode_list.find(
|
||||||
|
item => item.type == "folder" && item.name == this.state.folder,
|
||||||
|
);
|
||||||
|
if (!selected_folder) return;
|
||||||
|
|
||||||
|
const macrosList = this.state.macros_list.map(item => item.file_name);
|
||||||
|
var files_to_delete = selected_folder.files
|
||||||
|
.map(item => item.file_name)
|
||||||
|
.filter(item => !macrosList.includes(item));
|
||||||
|
|
||||||
|
if (selected_folder.name != "default") {
|
||||||
|
this.config.gcode_list = this.config.gcode_list.filter(item => item.name != this.state.folder);
|
||||||
|
} else {
|
||||||
|
selected_folder.files = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
await api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${files_to_delete.toString()}`);
|
||||||
|
this.config.non_macros_list = this.config.non_macros_list.filter(
|
||||||
|
item => !files_to_delete.includes(item.file_name),
|
||||||
|
);
|
||||||
|
this.save_config(this.config);
|
||||||
|
this.state.folder = "default";
|
||||||
|
this.confirmDelete = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
start_pause: function () {
|
||||||
|
this.macrosLoading = false;
|
||||||
|
if (this.state.xx == "RUNNING") this.pause();
|
||||||
|
else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") this.unpause();
|
||||||
|
else this.start();
|
||||||
|
},
|
||||||
|
|
||||||
|
start: function () { api.put("start"); },
|
||||||
|
pause: function () { api.put("pause"); },
|
||||||
|
unpause: function () { api.put("unpause"); },
|
||||||
|
optional_pause: function () { api.put("pause/optional"); },
|
||||||
|
stop: function () { api.put("stop"); },
|
||||||
|
step: function () { api.put("step"); },
|
||||||
|
|
||||||
|
override_feed: function () { api.put(`override/feed/${this.feed_override}`); },
|
||||||
|
override_speed: function () { api.put(`override/speed/${this.speed_override}`); },
|
||||||
|
|
||||||
|
run_macro: async function (id) {
|
||||||
|
if (this.state.macros[id].file_name == "default") {
|
||||||
|
this.showNoGcodeMessage = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const file_name = this.state.macros[id].file_name;
|
||||||
|
try {
|
||||||
|
// Selecting a file on the server is a side effect of
|
||||||
|
// GET /api/file/<name>. The macro button used to mutate
|
||||||
|
// state.selected client-side and immediately call start, which
|
||||||
|
// raced the file fetch: if the server hadn't seen the new
|
||||||
|
// selection yet, mach.start() ran whichever file was selected
|
||||||
|
// last. Do it explicitly and await so start always sees the
|
||||||
|
// right file.
|
||||||
|
if (file_name != this.state.selected) {
|
||||||
|
this.state.selected = file_name;
|
||||||
|
// GET /api/file/<name> returns gcode text (not JSON), so use
|
||||||
|
// fetch directly. The server's FileHandler.get sets
|
||||||
|
// state.selected as a side effect; we await the response
|
||||||
|
// before starting so mach.start() reads the right file.
|
||||||
|
const resp = await fetch(
|
||||||
|
`/api/file/${encodeURIComponent(file_name)}`,
|
||||||
|
{ cache: "no-cache" }
|
||||||
|
);
|
||||||
|
if (!resp.ok) {
|
||||||
|
throw new Error(`file fetch failed: ${resp.status}`);
|
||||||
|
}
|
||||||
|
await resp.text();
|
||||||
|
}
|
||||||
|
this.load();
|
||||||
|
if (this.state.macros[id].alert == true) {
|
||||||
|
this.macrosLoading = true;
|
||||||
|
} else {
|
||||||
|
await this.start_pause();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Error running macro: ", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
62
src/js/program-view.js
Normal file
62
src/js/program-view.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Program tab — file management, run/stop, gcode listing and 3D
|
||||||
|
// toolpath preview. Reuses the shared mixin (program-mixin) that also
|
||||||
|
// powers the legacy bits of control-view; this view does not host the
|
||||||
|
// jog grid or the DRO.
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
template: "#program-view-template",
|
||||||
|
props: ["config", "template", "state"],
|
||||||
|
|
||||||
|
components: {
|
||||||
|
"path-viewer": require("./path-viewer"),
|
||||||
|
"gcode-viewer": require("./gcode-viewer"),
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
"state.metric": {
|
||||||
|
handler: function () {},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
is_kiosk: function () { return !!this.$root.is_kiosk; },
|
||||||
|
|
||||||
|
display_units: {
|
||||||
|
cache: false,
|
||||||
|
get: function () { return this.$root.display_units; },
|
||||||
|
set: function (value) {
|
||||||
|
this.config.settings.units = value;
|
||||||
|
this.$root.display_units = value;
|
||||||
|
this.$dispatch("config-changed");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
metric: function () {
|
||||||
|
return this.display_units === "METRIC";
|
||||||
|
},
|
||||||
|
|
||||||
|
mach_state: function () {
|
||||||
|
const cycle = this.state.cycle;
|
||||||
|
const xx = this.state.xx;
|
||||||
|
if (xx != "ESTOPPED" && (cycle == "jogging" || cycle == "homing")) {
|
||||||
|
return cycle.toUpperCase();
|
||||||
|
}
|
||||||
|
return xx || "";
|
||||||
|
},
|
||||||
|
|
||||||
|
can_set_axis: function () { return this.state.cycle == "idle"; },
|
||||||
|
},
|
||||||
|
|
||||||
|
ready: function () {
|
||||||
|
this.load();
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [require("./program-mixin")],
|
||||||
|
};
|
||||||
169
src/js/settings-shell-view.js
Normal file
169
src/js/settings-shell-view.js
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Wrapper that adds a left-rail navigator around the settings family
|
||||||
|
// of views (Settings, Admin General, Admin Network, Tool, IO, Motor,
|
||||||
|
// Macros, Help, Cheat Sheet). The inner view is selected by the URL
|
||||||
|
// hash (parsed in app.js) and exposed as $root.sub_tab.
|
||||||
|
|
||||||
|
// Vue 1 has trouble making child components reactive to `$root.sub_tab`
|
||||||
|
// changes (whether via computed, watch, or prop binding through
|
||||||
|
// `<component :is>`). The shell instead listens to `hashchange`
|
||||||
|
// directly and parses the hash itself, mirroring app.js's logic, then
|
||||||
|
// keeps a local data prop `sub` that the template binds to. This is
|
||||||
|
// the only path that updates the rail's `:class` reactively.
|
||||||
|
module.exports = {
|
||||||
|
template: "#settings-shell-view-template",
|
||||||
|
props: ["config", "template", "state", "index"],
|
||||||
|
|
||||||
|
components: {
|
||||||
|
"settings-view-inner": require("./settings-view"),
|
||||||
|
"admin-general-view": require("./admin-general-view"),
|
||||||
|
"admin-network-view": require("./admin-network-view"),
|
||||||
|
"motor-view": require("./motor-view"),
|
||||||
|
"tool-view": require("./tool-view"),
|
||||||
|
"io-view": require("./io-view"),
|
||||||
|
"macros-view": require("./macros"),
|
||||||
|
"help-view": require("./help-view"),
|
||||||
|
"cheat-sheet-view": {
|
||||||
|
template: "#cheat-sheet-view-template",
|
||||||
|
data: function () {
|
||||||
|
return { showUnimplemented: false };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
sub: this.$root.sub_tab || "settings",
|
||||||
|
ridx: this.$root.index, // local copy of the motor index
|
||||||
|
// Whether the controller config has streamed in. The Svelte
|
||||||
|
// settings views crash on first paint with the placeholder
|
||||||
|
// config (settings.units / settings.easy-adapter / motion.*
|
||||||
|
// are all undefined). Gate the inner mount on this flag.
|
||||||
|
config_ready: false,
|
||||||
|
rail_items: [
|
||||||
|
{ sub: "settings", href: "#settings", icon: "fa-display", label: "Display & Units" },
|
||||||
|
{ sub: "probing", href: "#probing", icon: "fa-bullseye", label: "Probing" },
|
||||||
|
{ sub: "gcode", href: "#gcode", icon: "fa-code", label: "G-code & Motion" },
|
||||||
|
{ sub: "macros", href: "#macros", icon: "fa-keyboard", label: "Macros" },
|
||||||
|
{ sub: "cheat-sheet", href: "#cheat-sheet", icon: "fa-book", label: "G-code Cheat Sheet" },
|
||||||
|
{ sub: "admin-network", href: "#admin-network", icon: "fa-network-wired", label: "Network" },
|
||||||
|
{ sub: "admin-general", href: "#admin-general", icon: "fa-shield-halved", label: "General / Firmware" },
|
||||||
|
{ sub: "tool", href: "#tool", icon: "fa-bolt", label: "Spindle & Tool" },
|
||||||
|
{ sub: "io", href: "#io", icon: "fa-plug", label: "I/O" },
|
||||||
|
{ section: "Motors" },
|
||||||
|
{ sub: "motor", motor: 0, href: "#motor:0", icon: "fa-arrows-up-down-left-right", label: "Motor 0" },
|
||||||
|
{ sub: "motor", motor: 1, href: "#motor:1", icon: "fa-arrows-up-down-left-right", label: "Motor 1" },
|
||||||
|
{ sub: "motor", motor: 2, href: "#motor:2", icon: "fa-arrows-up-down-left-right", label: "Motor 2" },
|
||||||
|
{ sub: "motor", motor: 3, href: "#motor:3", icon: "fa-arrows-up-down-left-right", label: "Motor 3" },
|
||||||
|
{ section: " " },
|
||||||
|
{ sub: "help", href: "#help", icon: "fa-circle-question", label: "Help" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
ready: function () {
|
||||||
|
this._onHash = () => this.refresh_from_hash();
|
||||||
|
window.addEventListener("hashchange", this._onHash);
|
||||||
|
this.refresh_from_hash();
|
||||||
|
this._configPoll = setInterval(() => {
|
||||||
|
const c = this.$root && this.$root.config;
|
||||||
|
const ready = !!(c && c.full_version && c.full_version !== "<loading>"
|
||||||
|
&& c.settings && typeof c.settings === "object");
|
||||||
|
if (ready !== this.config_ready) this.config_ready = ready;
|
||||||
|
}, 200);
|
||||||
|
},
|
||||||
|
|
||||||
|
attached: function () {
|
||||||
|
// Vue 1 fires `attached` whenever the component is inserted into
|
||||||
|
// the DOM (which happens on every route change because the outer
|
||||||
|
// <component :is> recreates the instance). Re-bind the listener
|
||||||
|
// here so it works even after detach/attach cycles.
|
||||||
|
if (!this._onHash) {
|
||||||
|
this._onHash = () => this.refresh_from_hash();
|
||||||
|
}
|
||||||
|
window.addEventListener("hashchange", this._onHash);
|
||||||
|
this.refresh_from_hash();
|
||||||
|
},
|
||||||
|
|
||||||
|
detached: function () {
|
||||||
|
if (this._onHash) {
|
||||||
|
window.removeEventListener("hashchange", this._onHash);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy: function () {
|
||||||
|
if (this._onHash) {
|
||||||
|
window.removeEventListener("hashchange", this._onHash);
|
||||||
|
}
|
||||||
|
if (this._configPoll) clearInterval(this._configPoll);
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
refresh_from_hash: function () {
|
||||||
|
const hash = location.hash.substr(1) || "settings";
|
||||||
|
const parts = hash.split(":");
|
||||||
|
this.sub = parts[0] || "settings";
|
||||||
|
this.ridx = parts[1] !== undefined ? parts[1] : -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
is_active: function (item) {
|
||||||
|
if (!item || item.section) return false;
|
||||||
|
if (item.sub !== this.sub) return false;
|
||||||
|
if (item.sub === "motor") {
|
||||||
|
return "" + item.motor === "" + this.ridx;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
on_rail_click: function (item, ev) {
|
||||||
|
if (!item) return;
|
||||||
|
// Always preventDefault on rail clicks. Letting the browser
|
||||||
|
// anchor-scroll to <div id="settings"> etc. inside .app-body
|
||||||
|
// can pull the .app-head out of view; we drive navigation
|
||||||
|
// ourselves through location.hash and our hashchange handler.
|
||||||
|
if (ev && ev.preventDefault) ev.preventDefault();
|
||||||
|
|
||||||
|
if (item.anchor) {
|
||||||
|
// Soft-link rail items use a #settings hash plus an in-page
|
||||||
|
// anchor scroll once the Svelte page has mounted. We scroll
|
||||||
|
// ONLY the .settings-content overflow container by setting
|
||||||
|
// its scrollTop directly — element.scrollIntoView() walks all
|
||||||
|
// ancestor scroll containers and can tug the .app-body / html
|
||||||
|
// layout, which under tablet mode pulls the fixed header out
|
||||||
|
// of view.
|
||||||
|
if (location.hash !== item.href) location.hash = item.href;
|
||||||
|
const reset = () => {
|
||||||
|
// Force any inadvertent ancestor scroll back to 0 before
|
||||||
|
// we move .settings-content explicitly.
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
const body = document.querySelector(".app-body");
|
||||||
|
if (body) body.scrollTop = 0;
|
||||||
|
document.documentElement.scrollTop = 0;
|
||||||
|
};
|
||||||
|
setTimeout(() => {
|
||||||
|
reset();
|
||||||
|
const el = document.getElementById(item.anchor);
|
||||||
|
const scroller = document.querySelector(".settings-content");
|
||||||
|
if (el && scroller) {
|
||||||
|
const elTop = el.getBoundingClientRect().top;
|
||||||
|
const scTop = scroller.getBoundingClientRect().top;
|
||||||
|
scroller.scrollTop = scroller.scrollTop + (elTop - scTop) - 12;
|
||||||
|
}
|
||||||
|
// Re-assert ancestor scroll = 0 in case the assignment above
|
||||||
|
// moved things.
|
||||||
|
requestAnimationFrame(reset);
|
||||||
|
}, 320);
|
||||||
|
} else {
|
||||||
|
if (location.hash !== item.href) location.hash = item.href;
|
||||||
|
// Reset .app-body scroll so each route starts at the top.
|
||||||
|
const body = document.querySelector(".app-body");
|
||||||
|
if (body) body.scrollTop = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
showShutdownDialog: function () {
|
||||||
|
SvelteComponents.showDialog("Shutdown");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,14 +1,60 @@
|
|||||||
|
// V09 wraps the legacy Svelte SettingsView and filters its big page
|
||||||
|
// down to a single rail section so each rail item shows only the
|
||||||
|
// relevant controls. The Svelte component is left untouched (it is
|
||||||
|
// shared with the legacy UI) — we just hide the `<h2>` and `<fieldset>`
|
||||||
|
// elements whose `data-sec` does not match the active section.
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
template: "#settings-view-template",
|
template: "#settings-view-template",
|
||||||
|
|
||||||
attached: function() {
|
props: {
|
||||||
|
// "display" | "probing" | "gcode". Default is "display" which
|
||||||
|
// keeps the rail's "Display & Units" item working unchanged.
|
||||||
|
section: { default: "display" },
|
||||||
|
},
|
||||||
|
|
||||||
|
attached: function () {
|
||||||
this.svelteComponent = SvelteComponents.createComponent(
|
this.svelteComponent = SvelteComponents.createComponent(
|
||||||
"SettingsView",
|
"SettingsView",
|
||||||
document.getElementById("settings")
|
document.getElementById("settings")
|
||||||
);
|
);
|
||||||
|
// Defer one tick so Svelte has rendered the section markup.
|
||||||
|
setTimeout(() => this.apply_section_filter(), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
detached: function() {
|
detached: function () {
|
||||||
this.svelteComponent.$destroy();
|
if (this.svelteComponent) this.svelteComponent.$destroy();
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
section: function () {
|
||||||
|
this.apply_section_filter();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
apply_section_filter: function () {
|
||||||
|
const root = document.getElementById("settings");
|
||||||
|
if (!root) return;
|
||||||
|
const want = this.section || "display";
|
||||||
|
// Hide every section block that does not match.
|
||||||
|
root.querySelectorAll("[data-sec]").forEach(el => {
|
||||||
|
el.style.display = el.dataset.sec === want ? "" : "none";
|
||||||
|
});
|
||||||
|
// Hide the global <h1>Settings</h1> on subsections so the
|
||||||
|
// page reads as a focused panel.
|
||||||
|
const h1 = root.querySelector(".settings-view > h1");
|
||||||
|
if (h1) {
|
||||||
|
if (want === "display") {
|
||||||
|
h1.textContent = "Display & Units";
|
||||||
|
} else if (want === "probing") {
|
||||||
|
h1.textContent = "Probing";
|
||||||
|
} else if (want === "gcode") {
|
||||||
|
h1.textContent = "G-code & Motion";
|
||||||
|
} else {
|
||||||
|
h1.textContent = "Settings";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ html(lang="en")
|
|||||||
|
|
||||||
|
|
||||||
style: include ../static/css/pure-min.css
|
style: include ../static/css/pure-min.css
|
||||||
style: include ../static/css/side-menu.css
|
|
||||||
|
|
||||||
style: include ../static/css/font-awesome.min.css
|
style: include ../static/css/fa6.min.css
|
||||||
style: include ../static/css/Audiowide.css
|
style: include ../static/css/Audiowide.css
|
||||||
style: include ../static/css/clusterize.css
|
style: include ../static/css/clusterize.css
|
||||||
style: include ../svelte-components/node_modules/svelte-material-ui/bare.css
|
style: include ../svelte-components/node_modules/svelte-material-ui/bare.css
|
||||||
@@ -19,103 +18,171 @@ html(lang="en")
|
|||||||
style: include:stylus ../stylus/style.styl
|
style: include:stylus ../stylus/style.styl
|
||||||
|
|
||||||
body(v-cloak)
|
body(v-cloak)
|
||||||
|
// Tablet (kiosk) mode — pins the .app-shell to 1920x1080 and
|
||||||
|
// scales it to fit the actual viewport so the UI always looks
|
||||||
|
// exactly like the 10.8" 1920x1080 portable monitor.
|
||||||
|
//
|
||||||
|
// Toggle: ?tablet=1 to enable
|
||||||
|
// ?tablet=0 to disable
|
||||||
|
// Sticky in localStorage; once set, no querystring is needed.
|
||||||
|
script.
|
||||||
|
(function () {
|
||||||
|
try {
|
||||||
|
var p = new URLSearchParams(location.search);
|
||||||
|
if (p.has("tablet")) {
|
||||||
|
var on = p.get("tablet") !== "0" && p.get("tablet") !== "false";
|
||||||
|
localStorage.setItem("ui-tablet-mode", on ? "1" : "0");
|
||||||
|
}
|
||||||
|
if (localStorage.getItem("ui-tablet-mode") === "1") {
|
||||||
|
document.documentElement.classList.add("tablet-mode");
|
||||||
|
}
|
||||||
|
function fit() {
|
||||||
|
if (!document.documentElement.classList.contains("tablet-mode")) return;
|
||||||
|
var s = Math.min(window.innerWidth / 1920, window.innerHeight / 1080);
|
||||||
|
document.documentElement.style.setProperty("--tablet-scale", s);
|
||||||
|
}
|
||||||
|
fit();
|
||||||
|
window.addEventListener("resize", fit);
|
||||||
|
|
||||||
|
// Kiosk mode: when the UI is loaded by the controller's
|
||||||
|
// own onboard browser (Chromium pointing at localhost on
|
||||||
|
// the Pi 3B at 1366x768), apply a tighter layout that
|
||||||
|
// packs the V09 UI into the smaller, slower display.
|
||||||
|
// Override with ?kiosk=0 to force the desktop layout.
|
||||||
|
if (p.has("kiosk")) {
|
||||||
|
var k = p.get("kiosk") !== "0" && p.get("kiosk") !== "false";
|
||||||
|
localStorage.setItem("ui-kiosk-mode", k ? "1" : "0");
|
||||||
|
}
|
||||||
|
var stored = localStorage.getItem("ui-kiosk-mode");
|
||||||
|
var auto = location.hostname === "localhost"
|
||||||
|
|| location.hostname === "127.0.0.1"
|
||||||
|
|| location.hostname === "::1";
|
||||||
|
if (stored === "1" || (stored !== "0" && auto)) {
|
||||||
|
document.documentElement.classList.add("kiosk-mode");
|
||||||
|
}
|
||||||
|
} catch (_e) {}
|
||||||
|
})();
|
||||||
|
|
||||||
#svelte-dialog-host
|
#svelte-dialog-host
|
||||||
|
|
||||||
#overlay(v-if="status != 'connected'")
|
#overlay(v-if="status != 'connected'")
|
||||||
span {{status}}
|
span {{status}}
|
||||||
|
|
||||||
#layout
|
.app-shell
|
||||||
a#menuLink.menu-link(href="#menu"): span
|
header.app-head
|
||||||
|
.brand-blk
|
||||||
|
.brand-logo
|
||||||
|
.brand-name ONEFINITY
|
||||||
|
|
||||||
#menu
|
nav.tabs-host(role="tablist")
|
||||||
button.save.pure-button.button-success(:disabled="!modified",
|
a.ktab(:class="{active: top_tab === 'control'}", href="#control",
|
||||||
@click="save") Save
|
title="Jog, DRO, macros")
|
||||||
|
.fa.fa-gamepad
|
||||||
|
span Control
|
||||||
|
a.ktab(:class="{active: top_tab === 'program'}", href="#program",
|
||||||
|
title="Run programs, files, toolpath preview")
|
||||||
|
.fa.fa-list-ol
|
||||||
|
span Program
|
||||||
|
a.ktab(:class="{active: top_tab === 'console'}", href="#console",
|
||||||
|
title="MDI, messages, indicators")
|
||||||
|
.fa.fa-terminal
|
||||||
|
span Console
|
||||||
|
span.ktab-badge(v-if="messages_count") {{messages_count}}
|
||||||
|
a.ktab(:class="{active: top_tab === 'settings'}", href="#settings",
|
||||||
|
title="Configuration, network, macros")
|
||||||
|
.fa.fa-sliders
|
||||||
|
span Settings
|
||||||
|
|
||||||
.pure-menu
|
.head-spacer
|
||||||
ul.pure-menu-list
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#control") Control
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
.sys-btn(@click.stop="toggle_sys_popover", :class="{open: sys_open}")
|
||||||
a.pure-menu-link(href="#macros") Macros
|
span.pip(:class="sys_class")
|
||||||
|
span.sys-text {{sys_summary}}
|
||||||
|
.fa.fa-chevron-down
|
||||||
|
|
||||||
li.pure-menu-heading
|
.pi-temp-warning(v-if="80 <= state.rpi_temp",
|
||||||
a.pure-menu-link(href="#settings") Settings
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#motor:0") Motors
|
|
||||||
|
|
||||||
li.pure-menu-item(v-for="motor in config.motors")
|
|
||||||
a.pure-menu-link(:href="'#motor:' + $index") Motor {{$index}}
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#tool") Tool
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#io") I/O
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#admin-general") Admin
|
|
||||||
|
|
||||||
li.pure-menu-item
|
|
||||||
a.pure-menu-link(href="#admin-general") General
|
|
||||||
|
|
||||||
li.pure-menu-item
|
|
||||||
a.pure-menu-link(href="#admin-network") Network
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#cheat-sheet") Cheat Sheet
|
|
||||||
|
|
||||||
li.pure-menu-heading
|
|
||||||
a.pure-menu-link(href="#help") Help
|
|
||||||
|
|
||||||
button.pure-button.pure-button-primary(@click="showShutdownDialog", style="width: 100%")
|
|
||||||
.fa.fa-power-off
|
|
||||||
|
|
||||||
#main
|
|
||||||
.nav-header
|
|
||||||
.brand
|
|
||||||
img(src="/images/onefinity_logo.png")
|
|
||||||
.version
|
|
||||||
div Version: v{{config.full_version}}
|
|
||||||
div IP Address: {{config.ip}}
|
|
||||||
div WiFi: {{config.wifiName}}
|
|
||||||
a.upgrade-link(v-if="show_upgrade()", href="#admin-general")
|
|
||||||
| Upgrade to v{{latestVersion}}
|
|
||||||
.fa.fa-exclamation-circle.upgrade-attention(v-if="show_upgrade()")
|
|
||||||
|
|
||||||
.pi-temp-warning
|
|
||||||
.fa.fa-thermometer-full(class="error",
|
|
||||||
v-if="80 <= state.rpi_temp",
|
|
||||||
title="Raspberry Pi temperature too high.")
|
title="Raspberry Pi temperature too high.")
|
||||||
|
.fa.fa-temperature-full
|
||||||
|
|
||||||
.easy-adapter(v-if="is_easy_adapter_active")
|
span.state-badge(:class="state_class", :title="mach_state_full")
|
||||||
.round-dot
|
span.dot
|
||||||
div.easy-adapter-text Easy Adapter
|
span {{state_label}}
|
||||||
|
|
||||||
.whitespace
|
|
||||||
|
|
||||||
div
|
|
||||||
button.rotary-button(:disabled="!enable_rotary", :class="is_rotary_active && 'active'", @click="showSwitchRotaryModeDialog")
|
|
||||||
img(src="/images/rotary.svg", alt="rotary", :style="is_rotary_active ? 'width:90%;' : 'width:85%;'")
|
|
||||||
div.rotary-text Rotary
|
|
||||||
|
|
||||||
.video(title="Plug camera into USB.\n" +
|
|
||||||
"Left click to toggle video size.\n" +
|
|
||||||
"Right click to toggle crosshair.", @click="toggle_video",
|
|
||||||
@contextmenu="toggle_crosshair", :class="video_size")
|
|
||||||
.crosshair(v-if="crosshair")
|
|
||||||
.vertical
|
|
||||||
.horizontal
|
|
||||||
.box
|
|
||||||
img(src="/api/video")
|
|
||||||
|
|
||||||
.estop(:class="{active: state.es}")
|
.estop(:class="{active: state.es}")
|
||||||
estop(@click="estop")
|
estop(@click="estop")
|
||||||
|
|
||||||
.content(class="{{currentView}}-view")
|
// System popover (chip-soup destination)
|
||||||
|
.sys-popover(v-if="sys_open", @click.stop="")
|
||||||
|
.sp-row
|
||||||
|
.sp-icon: .fa.fa-microchip
|
||||||
|
.sp-text
|
||||||
|
.sp-label Firmware
|
||||||
|
.sp-val v{{config.full_version}}
|
||||||
|
a.sp-act(v-if="show_upgrade()", href="#admin-general")
|
||||||
|
| Upgrade to v{{latestVersion}}
|
||||||
|
.fa.fa-circle-exclamation.upgrade-attention
|
||||||
|
.sp-row
|
||||||
|
.sp-icon: .fa.fa-network-wired
|
||||||
|
.sp-text
|
||||||
|
.sp-label IP Address
|
||||||
|
.sp-val {{config.ip}}
|
||||||
|
.sp-row
|
||||||
|
.sp-icon: .fa.fa-wifi(:class="{'sp-warn': config.wifiName === 'not connected'}")
|
||||||
|
.sp-text
|
||||||
|
.sp-label WiFi
|
||||||
|
.sp-val {{config.wifiName}}
|
||||||
|
a.sp-act(href="#admin-network", @click="sys_open=false") Configure
|
||||||
|
.sp-row(v-if="enable_rotary")
|
||||||
|
.sp-icon: img(src="/images/rotary.svg", alt="rotary")
|
||||||
|
.sp-text
|
||||||
|
.sp-label Rotary
|
||||||
|
.sp-val {{is_rotary_active ? 'Active' : 'Inactive'}}
|
||||||
|
button.sp-act(@click="showSwitchRotaryModeDialog")
|
||||||
|
| {{is_rotary_active ? 'Disable' : 'Enable'}}
|
||||||
|
.sp-row(v-if="is_easy_adapter_active")
|
||||||
|
.sp-icon: .fa.fa-puzzle-piece
|
||||||
|
.sp-text
|
||||||
|
.sp-label Easy Adapter
|
||||||
|
.sp-val Active
|
||||||
|
.sp-row.video-row
|
||||||
|
.sp-icon: .fa.fa-video
|
||||||
|
.sp-text
|
||||||
|
.sp-label Camera
|
||||||
|
.sp-val {{has_camera ? 'Live' : 'Plug camera into USB'}}
|
||||||
|
.sp-act(v-if="has_camera", @click="toggle_video")
|
||||||
|
| {{video_size === 'small' ? 'Enlarge' : 'Shrink'}}
|
||||||
|
.video(v-if="sys_open && has_camera", title="Camera feed",
|
||||||
|
@click="toggle_video", @contextmenu="toggle_crosshair",
|
||||||
|
:class="video_size")
|
||||||
|
.crosshair(v-if="crosshair")
|
||||||
|
.vertical
|
||||||
|
.horizontal
|
||||||
|
.box
|
||||||
|
img(src="/api/video", @error="has_camera=false")
|
||||||
|
.sp-foot
|
||||||
|
button.sp-shutdown(@click="showShutdownDialog")
|
||||||
|
.fa.fa-power-off
|
||||||
|
| Shutdown
|
||||||
|
button.sp-save(:disabled="!modified", @click="save")
|
||||||
|
.fa.fa-save
|
||||||
|
| Save{{modified ? '*' : ''}}
|
||||||
|
|
||||||
|
// Routed view. We keep instances alive across tab swaps so:
|
||||||
|
// - The Program tab's WebGL <path-viewer> canvas does not
|
||||||
|
// get destroyed and recreated each time (which caused a
|
||||||
|
// dark flash as the GL context cleared the new canvas
|
||||||
|
// before its first frame).
|
||||||
|
// - The Program tab's clusterize.js gcode list does not
|
||||||
|
// re-virtualize from scratch on every visit.
|
||||||
|
// - The Settings shell's child Svelte components stay
|
||||||
|
// mounted, preserving any in-flight form state.
|
||||||
|
// The settings-shell handles its own inner v-if cascade so
|
||||||
|
// the Vue 1 reactivity quirk that motivated removing
|
||||||
|
// keep-alive earlier no longer applies here.
|
||||||
|
.app-body
|
||||||
component(:is="currentView + '-view'", :index="index",
|
component(:is="currentView + '-view'", :index="index",
|
||||||
:config="config", :template="template", :state="state", keep-alive)
|
:config="config", :template="template", :state="state",
|
||||||
|
:sub-tab="sub_tab", keep-alive)
|
||||||
|
|
||||||
message.error-message(:show.sync="errorShow")
|
message.error-message(:show.sync="errorShow")
|
||||||
div(slot="header")
|
div(slot="header")
|
||||||
|
|||||||
67
src/pug/templates/console-view.pug
Normal file
67
src/pug/templates/console-view.pug
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
script#console-view-template(type="text/x-template")
|
||||||
|
.console-page
|
||||||
|
.console-card
|
||||||
|
.ptab-bar
|
||||||
|
button.ptab(:class="{active: sub === 'mdi'}", @click="select_sub('mdi')")
|
||||||
|
.fa.fa-keyboard
|
||||||
|
| MDI
|
||||||
|
button.ptab(:class="{active: sub === 'messages'}", @click="select_sub('messages')")
|
||||||
|
.fa.fa-comment-dots
|
||||||
|
| Messages
|
||||||
|
span.ptab-badge(v-if="unread_messages") {{unread_messages}}
|
||||||
|
button.ptab(:class="{active: sub === 'indicators'}", @click="select_sub('indicators')")
|
||||||
|
.fa.fa-bell
|
||||||
|
| Indicators
|
||||||
|
|
||||||
|
// ----- MDI -----
|
||||||
|
.mdi-pane(v-show="sub === 'mdi'")
|
||||||
|
.mdi-input
|
||||||
|
span.prompt G>
|
||||||
|
input(type="text", v-model="mdi", :disabled="!can_mdi",
|
||||||
|
@keyup.enter="submit_mdi", placeholder="enter a G-code command…")
|
||||||
|
button.mdi-send(:disabled="!can_mdi || !mdi", @click="submit_mdi")
|
||||||
|
.fa.fa-paper-plane
|
||||||
|
| SEND
|
||||||
|
.mdi-keys
|
||||||
|
button.mkey(@click="prepend('G0 ')") G0
|
||||||
|
button.mkey(@click="prepend('G1 ')") G1
|
||||||
|
button.mkey(@click="prepend('G2 ')") G2
|
||||||
|
button.mkey(@click="prepend('G3 ')") G3
|
||||||
|
button.mkey(@click="prepend('G28 ')") G28
|
||||||
|
button.mkey(@click="prepend('G92 ')") G92
|
||||||
|
button.mkey(@click="prepend('M3 ')") M3
|
||||||
|
button.mkey(@click="prepend('M5 ')") M5
|
||||||
|
button.mkey(@click="append('X')") X
|
||||||
|
button.mkey(@click="append('Y')") Y
|
||||||
|
button.mkey(@click="append('Z')") Z
|
||||||
|
button.mkey(@click="append('W')") W
|
||||||
|
button.mkey(@click="append('F')") F
|
||||||
|
button.mkey(@click="append('S')") S
|
||||||
|
button.mkey.clear(@click="mdi = ''") CLEAR
|
||||||
|
button.mkey.send(:disabled="!can_mdi || !mdi", @click="submit_mdi") SEND ↵
|
||||||
|
|
||||||
|
em Machine units: #[strong {{mach_units}}]. G20/G21 to switch.
|
||||||
|
|
||||||
|
.mdi-history(:class="{placeholder: !history.length}")
|
||||||
|
span.mdi-empty(v-if="!history.length") MDI history will display here.
|
||||||
|
.h-row(v-for="item in history", @click="load_history($index)",
|
||||||
|
track-by="$index")
|
||||||
|
span.h-cmd {{item}}
|
||||||
|
span.h-status ↻
|
||||||
|
|
||||||
|
// ----- Messages -----
|
||||||
|
.messages-pane(v-show="sub === 'messages'")
|
||||||
|
.msg-empty(v-if="!$root.messages_log.length")
|
||||||
|
.fa.fa-circle-check
|
||||||
|
| No messages.
|
||||||
|
.msg(v-for="m in $root.messages_log",
|
||||||
|
:class="m.level === 'warning' ? 'warn' : 'info'", track-by="$index")
|
||||||
|
.mi
|
||||||
|
.fa(:class="m.level === 'warning' ? 'fa-triangle-exclamation' : 'fa-circle-info'")
|
||||||
|
div
|
||||||
|
.mtitle {{m.text}}
|
||||||
|
.mtime ID {{m.id}}
|
||||||
|
|
||||||
|
// ----- Indicators -----
|
||||||
|
.indicators-pane(v-show="sub === 'indicators'")
|
||||||
|
indicators(:state="state", :template="template")
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
script#control-view-template(type="text/x-template")
|
script#control-view-template(type="text/x-template")
|
||||||
#control
|
.control-page
|
||||||
|
// ----- Modal dialogs (kept verbatim from legacy) -----
|
||||||
message(:show.sync="showGcodeMessage")
|
message(:show.sync="showGcodeMessage")
|
||||||
h3(slot="header") Processing New File
|
h3(slot="header") Processing New File
|
||||||
|
|
||||||
div(slot="body")
|
div(slot="body")
|
||||||
h3 Please wait..
|
h3 Please wait..
|
||||||
p Simulating GCode to check for errors, calculate ETA and generate 3D view.
|
p Simulating GCode to check for errors, calculate ETA and generate 3D view.
|
||||||
|
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
label Simulating {{(toolpath_progress || 0) | percent}}
|
label Simulating {{(toolpath_progress || 0) | percent}}
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ script#control-view-template(type="text/x-template")
|
|||||||
h3(slot="header") GCode Not Set
|
h3(slot="header") GCode Not Set
|
||||||
div(slot="body")
|
div(slot="body")
|
||||||
p Configure the GCode for the selected macro to use it
|
p Configure the GCode for the selected macro to use it
|
||||||
|
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="showNoGcodeMessage=false") OK
|
button.pure-button(@click="showNoGcodeMessage=false") OK
|
||||||
|
|
||||||
@@ -25,7 +23,6 @@ script#control-view-template(type="text/x-template")
|
|||||||
| The macro file
|
| The macro file
|
||||||
strong {{state.selected}}
|
strong {{state.selected}}
|
||||||
| is being loaded.
|
| is being loaded.
|
||||||
|
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="macrosLoading=false") Cancel
|
button.pure-button(@click="macrosLoading=false") Cancel
|
||||||
button.pure-button.pure-button-primary(@click="start_pause") Run
|
button.pure-button.pure-button-primary(@click="start_pause") Run
|
||||||
@@ -35,441 +32,265 @@ script#control-view-template(type="text/x-template")
|
|||||||
div(slot="body")
|
div(slot="body")
|
||||||
p It seems like the file you selected cannot be found. Try uploading again.
|
p It seems like the file you selected cannot be found. Try uploading again.
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button.button-error(@click="GCodeNotFound=false")
|
button.pure-button.button-error(@click="GCodeNotFound=false") OK
|
||||||
| OK
|
|
||||||
|
|
||||||
message(:show.sync="show_probe_dialog")
|
message(:show.sync="show_probe_dialog")
|
||||||
h3(slot="header") Probe Rotary
|
h3(slot="header") Choose probe type
|
||||||
div(slot="body")
|
div(slot="body")
|
||||||
|
p Pick which probe routine to run.
|
||||||
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('xyz')") Probe XYZ
|
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('xyz')") Probe XYZ
|
||||||
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('z')") Probe Z
|
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('z')") Probe Z
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="show_probe_dialog=false") Cancel
|
button.pure-button(@click="show_probe_dialog=false") Cancel
|
||||||
|
|
||||||
|
// ----- Main grid: jog | (DRO + status strip) -----
|
||||||
|
.control-grid
|
||||||
|
|
||||||
table(style="table-layout: fixed; width: 100%;")
|
// ===== JOG =====
|
||||||
tr(style="height: fit-content;")
|
// Hidden only while a G-code program is running / paused /
|
||||||
td(style="white-space: nowrap; width: 410px;", rowspan="2")
|
// stopping. Jogging / homing / MDI moves do not hide it.
|
||||||
table.control-buttons(table-layout="fixed")
|
.jog-card(v-if="!is_program_executing")
|
||||||
colgroup
|
.jog-head
|
||||||
col(style="width:100px")
|
.jog-title
|
||||||
col(style="width:100px")
|
| Jog
|
||||||
col(style="width:100px")
|
span.step-pre · step
|
||||||
col(style="width:100px")
|
span.step {{jog_incr_amounts[display_units][jog_incr]}}#[span.unit {{metric ? 'mm' : 'in'}}]
|
||||||
tr
|
.step-seg
|
||||||
td(style="height:100px",align="center")
|
button(:class="{active: jog_incr === 'fine'}", @click="jog_incr = 'fine'")
|
||||||
button(@click="jog_fn(-1,1,0,0)")
|
| {{jog_incr_amounts[display_units].fine}}
|
||||||
.fa.fa-arrow-right(style="transform: rotate(-135deg);")
|
button(:class="{active: jog_incr === 'small'}", @click="jog_incr = 'small'")
|
||||||
td(style="height:100px",align="center")
|
| {{jog_incr_amounts[display_units].small}}
|
||||||
button(@click="jog_fn(0,1,0,0)") Y+
|
button(:class="{active: jog_incr === 'medium'}", @click="jog_incr = 'medium'")
|
||||||
td(style="height:100px",align="center")
|
| {{jog_incr_amounts[display_units].medium}}
|
||||||
button(@click="jog_fn(1,1,0,0)")
|
button(:class="{active: jog_incr === 'large'}", @click="jog_incr = 'large'")
|
||||||
.fa.fa-arrow-right(style="transform: rotate(-45deg);")
|
| {{jog_incr_amounts[display_units].large}}
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(,@click="jog_fn(0,0,1,0)") Z+
|
|
||||||
tr
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(-1,0,0,0)") X-
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="showMoveToZeroDialog('xy')")
|
|
||||||
| XY
|
|
||||||
br
|
|
||||||
| Origin
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(1,0,0,0)") X+
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="showMoveToZeroDialog('z')")
|
|
||||||
| Z
|
|
||||||
br
|
|
||||||
| Origin
|
|
||||||
tr
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(-1,-1,0,0)")
|
|
||||||
.fa.fa-arrow-right(style="transform: rotate(135deg);")
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(0,-1,0,0)") Y-
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(1,-1,0,0)")
|
|
||||||
.fa.fa-arrow-right(style="transform: rotate(45deg);")
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(@click="jog_fn(0,0,-1,0)") Z-
|
|
||||||
tr
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(:style="getJogIncrStyle('fine')", @click="jog_incr = 'fine'")
|
|
||||||
span {{jog_incr_amounts[display_units].fine}}#[span.jog-units {{metric ? 'mm' : 'in'}}]
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(:style="getJogIncrStyle('small')", @click="jog_incr = 'small'")
|
|
||||||
span {{jog_incr_amounts[display_units].small}}#[span.jog-units {{metric ? 'mm' : 'in'}}]
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(:style="getJogIncrStyle('medium')", @click="jog_incr = 'medium'")
|
|
||||||
span {{jog_incr_amounts[display_units].medium}}#[span.jog-units {{metric ? 'mm' : 'in'}}]
|
|
||||||
td(style="height:100px",align="center")
|
|
||||||
button(:style="getJogIncrStyle('large')", @click="jog_incr = 'large'")
|
|
||||||
span {{jog_incr_amounts[display_units].large}}#[span.jog-units {{metric ? 'mm' : 'in'}}]
|
|
||||||
|
|
||||||
tr(v-if="state['2an'] == 3")
|
.jog-grid
|
||||||
td(style="height:100px", align="center", colspan="1")
|
// Row 1
|
||||||
button(@click="show_probe_dialog=true")
|
button.jbtn.dir(@click="jog_fn(-1, 1, 0, 0)", title="X- Y+")
|
||||||
| Probe
|
.fa.fa-arrow-up.ico(style="transform: rotate(-45deg)")
|
||||||
br
|
button.jbtn(@click="jog_fn(0, 1, 0, 0)") Y+
|
||||||
| Rotary
|
button.jbtn.dir(@click="jog_fn(1, 1, 0, 0)", title="X+ Y+")
|
||||||
|
.fa.fa-arrow-up.ico(style="transform: rotate(45deg)")
|
||||||
|
button.jbtn(@click="jog_fn(0, 0, 1, 0)") Z+
|
||||||
|
|
||||||
td(style="height:100px", align="center", colspan="1")
|
// Row 2
|
||||||
button(@click="jog_fn(0,0,0,-1)", style="display: grid;justify-content: center;align-items: center;padding: 14px;")
|
button.jbtn(@click="jog_fn(-1, 0, 0, 0)") X−
|
||||||
| A-
|
button.jbtn(@click="showMoveToZeroDialog('xy')")
|
||||||
.fa.fa-rotate-left
|
span.lbl XY
|
||||||
|
span Origin
|
||||||
|
button.jbtn(@click="jog_fn(1, 0, 0, 0)") X+
|
||||||
|
button.jbtn(@click="showMoveToZeroDialog('z')")
|
||||||
|
span.lbl Z
|
||||||
|
span Origin
|
||||||
|
|
||||||
td(style="height:100px", align="center", colspan="1")
|
// Row 3
|
||||||
button(@click="showMoveToZeroDialog('a')")
|
button.jbtn.dir(@click="jog_fn(-1, -1, 0, 0)", title="X- Y-")
|
||||||
| A
|
.fa.fa-arrow-down.ico(style="transform: rotate(45deg)")
|
||||||
br
|
button.jbtn(@click="jog_fn(0, -1, 0, 0)") Y−
|
||||||
| Origin
|
button.jbtn.dir(@click="jog_fn(1, -1, 0, 0)", title="X+ Y-")
|
||||||
|
.fa.fa-arrow-down.ico(style="transform: rotate(-45deg)")
|
||||||
|
button.jbtn(@click="jog_fn(0, 0, -1, 0)") Z−
|
||||||
|
|
||||||
td(style="height:100px", align="center", colspan="1")
|
// Row 4 — A axis (rotary) when rotary is enabled.
|
||||||
button(@click="jog_fn(0,0,0,1)", style="display: grid;justify-content: center;align-items: center;padding: 14px;")
|
template(v-if="state['2an'] == 3")
|
||||||
| A+
|
button.jbtn.dir(@click="jog_fn(0, 0, 0, -1)")
|
||||||
.fa.fa-rotate-right
|
.fa.fa-rotate-left.ico
|
||||||
|
span.lbl A−
|
||||||
|
button.jbtn.ghost(@click="showMoveToZeroDialog('a')")
|
||||||
|
span.lbl A
|
||||||
|
span Origin
|
||||||
|
button.jbtn.dir(@click="jog_fn(0, 0, 0, 1)")
|
||||||
|
.fa.fa-rotate-right.ico
|
||||||
|
span.lbl A+
|
||||||
|
button.jbtn(@click="show_probe_dialog=true",
|
||||||
|
:class="{'load-on': !state['pw']}")
|
||||||
|
.fa.fa-bullseye.ico
|
||||||
|
span.lbl Probe
|
||||||
|
|
||||||
tr(v-else)
|
// Row 4 — fallback probe / zero / home shortcuts
|
||||||
td(style="height:100px", align="center", colspan="2")
|
template(v-if="state['2an'] != 3")
|
||||||
button(:class="state['pw'] ? '' : 'load-on'",
|
button.jbtn(@click="showProbeDialog('xyz')",
|
||||||
style="height:100px;width:200px",
|
:class="{'load-on': !state['pw']}")
|
||||||
@click="showProbeDialog('xyz')")
|
.fa.fa-bullseye.ico
|
||||||
| Probe XYZ
|
span.lbl Probe XYZ
|
||||||
|
button.jbtn.ghost(@click="zero()", :disabled="!can_set_axis")
|
||||||
|
.fa.fa-location-dot.ico
|
||||||
|
span.lbl Zero all
|
||||||
|
button.jbtn(@click="showProbeDialog('z')",
|
||||||
|
:class="{'load-on': !state['pw']}")
|
||||||
|
.fa.fa-bullseye.ico
|
||||||
|
span.lbl Probe Z
|
||||||
|
button.jbtn.ghost(@click="home()")
|
||||||
|
.fa.fa-home.ico
|
||||||
|
span.lbl Home all
|
||||||
|
|
||||||
td(style="height:100px", align="center", colspan="2")
|
// ===== NOW RUNNING (replaces jog grid only while a G-code
|
||||||
button(:class="state['pw'] ? '' : 'load-on'",
|
// program is actually executing). Jogging is excluded.
|
||||||
style="height:100px;width:200px",
|
.running-panel(v-if="is_program_executing")
|
||||||
@click="showProbeDialog('z')")
|
.running-top
|
||||||
| Probe Z
|
div
|
||||||
|
.running-file
|
||||||
|
.fa.fa-file-code
|
||||||
|
span(v-if="state.selected") {{state.selected}}
|
||||||
|
span(v-else) {{(mach_state || 'BUSY').toLowerCase()}}
|
||||||
|
.running-meta
|
||||||
|
span(v-if="is_running") {{ (mach_state || 'RUNNING').toLowerCase() }}
|
||||||
|
span(v-if="is_holding") paused
|
||||||
|
span(v-if="is_holding && pause_reason") · {{pause_reason}}
|
||||||
|
span(v-if="is_stopping") stopping
|
||||||
|
span(v-if="toolpath.lines") · line {{state.line || 0 | number}} / {{toolpath.lines | number}}
|
||||||
|
span(v-if="plan_time_remaining") · ETA {{plan_time_remaining | time}}
|
||||||
|
.running-pct
|
||||||
|
| {{((progress || 0) * 100) | fixed 0}}
|
||||||
|
span %
|
||||||
|
.running-progress
|
||||||
|
div(:style="'width:' + ((progress || 0) * 100) + '%'")
|
||||||
|
.running-stats
|
||||||
|
.running-stat
|
||||||
|
.lbl Velocity
|
||||||
|
.val
|
||||||
|
unit-value(:value="state.v", precision="2", unit="", iunit="", scale="0.0254")
|
||||||
|
| {{metric ? 'm/min' : 'IPM'}}
|
||||||
|
.running-stat
|
||||||
|
.lbl Feed
|
||||||
|
.val
|
||||||
|
unit-value(:value="state.feed", precision="0", unit="", iunit="")
|
||||||
|
| {{metric ? 'mm/min' : 'IPM'}}
|
||||||
|
.running-stat
|
||||||
|
.lbl Spindle
|
||||||
|
.val
|
||||||
|
| {{(state.speed || 0) | fixed 0}}
|
||||||
|
span(v-if="state.s != null && !isNaN(state.s)") ({{state.s | fixed 0}})
|
||||||
|
| RPM
|
||||||
|
.running-stat
|
||||||
|
.lbl Tool
|
||||||
|
.val T{{state.tool || 0}}
|
||||||
|
.running-row
|
||||||
|
// While RUNNING the primary action is Pause; while HOLDING / STOPPING it's Resume.
|
||||||
|
button.tx-btn.pause(v-if="is_running", @click="pause()")
|
||||||
|
.fa.fa-pause
|
||||||
|
span.lbl PAUSE
|
||||||
|
button.tx-btn.run(v-if="is_holding || is_stopping", @click="unpause()")
|
||||||
|
.fa.fa-play
|
||||||
|
span.lbl RESUME
|
||||||
|
button.tx-btn.stop(@click="stop()")
|
||||||
|
.fa.fa-stop
|
||||||
|
span.lbl STOP
|
||||||
|
button.tx-btn.step(v-if="is_holding", @click="step()")
|
||||||
|
.fa.fa-forward-step
|
||||||
|
span.lbl STEP
|
||||||
|
|
||||||
td(style="vertical-align: top;")
|
// ===== DRO + status strip =====
|
||||||
table.axes
|
.right-col
|
||||||
tr(:class="axes.klass")
|
|
||||||
th.name Axis
|
|
||||||
th.position Position
|
|
||||||
th.absolute Absolute
|
|
||||||
th.offset Offset
|
|
||||||
th.state State
|
|
||||||
th.tstate Toolpath
|
|
||||||
th.actions
|
|
||||||
button.pure-button(disabled, style="height:60px;width:60px;display:none;")
|
|
||||||
|
|
||||||
button.pure-button(:disabled="!can_set_axis",
|
.dro-card
|
||||||
title="Zero all axis offsets.", @click="zero()",style="height:60px;width:60px")
|
.dro-head
|
||||||
.fa.fa-map-marker
|
div Axis
|
||||||
|
div Position
|
||||||
button.pure-button(title="Home all axes.", @click="home()",
|
div Absolute
|
||||||
:disabled="!is_idle",style="height:60px;width:60px")
|
div Offset
|
||||||
.fa.fa-home
|
.actions-cell
|
||||||
|
// Master Home All. Each row's Actions cell has a per-axis
|
||||||
|
// home button; this header-level button homes every
|
||||||
|
// enabled axis (legacy Onefinity behavior).
|
||||||
|
button.icon-btn(:disabled="!is_idle",
|
||||||
|
title="Home all axes.", @click="home_all()")
|
||||||
|
.fa.fa-house-chimney
|
||||||
|
|
||||||
|
// Per-axis rows — keep unit-value + bindings from axis-vars
|
||||||
each axis in 'xyzabc'
|
each axis in 'xyzabc'
|
||||||
tr.axis(:class=`${axis}.klass`, v-if=`${axis}.enabled`,
|
.dro-row(:class=`${axis}.klass + ' ' + ${axis}.tklass`,
|
||||||
:title=`${axis}.title`)
|
v-if=`${axis}.enabled`,
|
||||||
th.name= axis
|
:title=`${axis}.toolmsg ? (${axis}.title + ' — ' + ${axis}.toolmsg) : ${axis}.title`)
|
||||||
td.position: unit-value(:value=`${axis}.pos`, precision=4)
|
.dro-axis(:class=`'axis-' + '${axis}'`)= axis.toUpperCase()
|
||||||
td.absolute: unit-value(:value=`${axis}.abs`, precision=3)
|
.dro-pos: unit-value(:value=`${axis}.pos`, precision=4)
|
||||||
td.offset: unit-value(:value=`${axis}.off`, precision=3)
|
.dro-sec: unit-value(:value=`${axis}.abs`, precision=3)
|
||||||
td.state
|
.dro-sec: unit-value(:value=`${axis}.off`, precision=3)
|
||||||
.fa(:class=`'fa-' + ${axis}.icon`)
|
.actions-cell
|
||||||
| {{#{axis}.state}}
|
button.icon-btn(:disabled="!can_set_axis",
|
||||||
td.tstate(:class=`${axis}.tklass`, :title=`${axis}.toolmsg`, @click=`showToolpathMessageDialog('${axis}')`)
|
:title=`'Set ${axis.toUpperCase()} axis position.'`,
|
||||||
.fa(:class=`'fa-' + ${axis}.ticon`)
|
@click=`show_set_position('${axis}')`)
|
||||||
| {{#{axis}.tstate}}
|
.fa.fa-gear
|
||||||
|
button.icon-btn(:class=`${axis}.tklass.indexOf('error') !== -1 ? 'state-red' : (${axis}.tklass.indexOf('warn') !== -1 ? 'state-amber' : 'state-green')`,
|
||||||
th.actions
|
:disabled="!can_set_axis",
|
||||||
button.pure-button(:disabled="!can_set_axis",
|
:title=`${axis}.toolmsg || ('Zero ${axis.toUpperCase()} axis offset.')`,
|
||||||
title=`Set {{'${axis}' | upper}} axis position.`,
|
@click=`zero('${axis}')`)
|
||||||
@click=`show_set_position('${axis}')`, style="height:60px;width:60px")
|
.fa.fa-location-dot
|
||||||
.fa.fa-cog
|
button.icon-btn(:class=`${axis}.klass.indexOf('error') !== -1 ? 'state-red' : (${axis}.homed ? 'state-green' : 'state-amber')`,
|
||||||
|
:disabled="!is_idle",
|
||||||
button.pure-button(:disabled="!can_set_axis",
|
:title=`${axis}.title`,
|
||||||
title=`Zero {{'${axis}' | upper}} axis offset.`,
|
@click=`home('${axis}')`)
|
||||||
@click=`zero('${axis}')`, style="height:60px;width:60px")
|
|
||||||
.fa.fa-map-marker
|
|
||||||
|
|
||||||
button.pure-button(:disabled="!is_idle", @click=`home('${axis}')`,
|
|
||||||
title=`Home {{'${axis}' | upper}} axis.`, style="height:60px;width:60px")
|
|
||||||
.fa.fa-home
|
.fa.fa-home
|
||||||
|
|
||||||
tr(style="vertical-align: top;")
|
// ----- Status strip -----
|
||||||
td
|
.status-strip
|
||||||
table(width="100%")
|
.stat-card
|
||||||
tr
|
.stat-label State
|
||||||
td(style="text-align:center")
|
.stat-val(:class="state_kpi_class") {{mach_state || '--'}}
|
||||||
table.info
|
.stat-sub(v-if="message") {{message.replace(/^#/, '')}}
|
||||||
tr
|
.stat-sub(v-else) No alerts
|
||||||
th State
|
|
||||||
td(:class="{attention: highlight_state}") {{mach_state}}
|
|
||||||
|
|
||||||
tr
|
.stat-card
|
||||||
th Message
|
.stat-label Velocity / Feed
|
||||||
td.message(:class="{attention: highlight_state}")
|
.stat-val
|
||||||
| {{message.replace(/^#/, '')}}
|
|
||||||
|
|
||||||
tr
|
|
||||||
th Display Units
|
|
||||||
td.units
|
|
||||||
select(v-model="display_units")
|
|
||||||
option(value="METRIC") METRIC
|
|
||||||
option(value="IMPERIAL") IMPERIAL
|
|
||||||
|
|
||||||
tr(title="Active tool")
|
|
||||||
th Tool
|
|
||||||
td {{state.tool || 0}}
|
|
||||||
|
|
||||||
td
|
|
||||||
table.info
|
|
||||||
tr(
|
|
||||||
title="Current velocity in {{metric ? 'meters' : 'inches'}} per minute")
|
|
||||||
th Velocity
|
|
||||||
td
|
|
||||||
unit-value(:value="state.v", precision="2", unit="", iunit="",
|
unit-value(:value="state.v", precision="2", unit="", iunit="",
|
||||||
scale="0.0254")
|
scale="0.0254")
|
||||||
| {{metric ? ' m/min' : ' IPM'}}
|
| ·
|
||||||
|
unit-value(:value="state.feed", precision="0", unit="", iunit="")
|
||||||
|
.stat-sub {{metric ? 'm/min · mm/min' : 'IPM · IPM'}}
|
||||||
|
|
||||||
tr(title="Programmed feed rate.")
|
.stat-card.stat-tappable(@click="overrides_open = !overrides_open",
|
||||||
th Feed
|
:class="{open: overrides_open}", title="Tap to adjust feed/spindle override")
|
||||||
td
|
.stat-label Spindle
|
||||||
unit-value(:value="state.feed", precision="2", unit="", iunit="")
|
.stat-val
|
||||||
| {{metric ? ' mm/min' : ' IPM'}}
|
| {{(state.speed || 0) | fixed 0}}
|
||||||
|
span(v-if="state.s != null && !isNaN(state.s)") ({{state.s | fixed 0}})
|
||||||
|
.stat-sub
|
||||||
|
| RPM (commanded / actual)
|
||||||
|
.fa.fa-sliders.tap-hint(title="Open override drawer")
|
||||||
|
|
||||||
tr(title="Programed and actual speed.")
|
.stat-card
|
||||||
th Speed
|
.stat-label Job
|
||||||
td
|
.stat-val
|
||||||
| {{state.speed || 0 | fixed 0}}
|
|
||||||
span(v-if="!isNaN(state.s)") ({{state.s | fixed 0}})
|
|
||||||
= ' RPM'
|
|
||||||
|
|
||||||
tr(title="Load switch states.")
|
|
||||||
th Loads
|
|
||||||
td
|
|
||||||
span(:class="state['1oa'] ? 'load-on' : ''")
|
|
||||||
| 1:{{state['1oa'] ? 'On' : 'Off'}}
|
|
||||||
|
|
|
||||||
span(:class="state['2oa'] ? 'load-on' : ''")
|
|
||||||
| 2:{{state['2oa'] ? 'On' : 'Off'}}
|
|
||||||
|
|
||||||
td
|
|
||||||
table.info
|
|
||||||
tr
|
|
||||||
th Remaining
|
|
||||||
td(title="Total run time (days:hours:mins:secs)").
|
|
||||||
#[span(v-if="plan_time_remaining") {{plan_time_remaining | time}} of]
|
|
||||||
{{toolpath.time | time}}
|
|
||||||
|
|
||||||
tr
|
|
||||||
th ETA
|
|
||||||
td.eta {{eta}}
|
|
||||||
|
|
||||||
tr
|
|
||||||
th Line
|
|
||||||
td
|
|
||||||
| {{0 <= state.line ? state.line : 0 | number}}
|
| {{0 <= state.line ? state.line : 0 | number}}
|
||||||
span(v-if="toolpath.lines")
|
span(v-if="toolpath.lines")
|
||||||
| of {{toolpath.lines | number}}
|
| / {{toolpath.lines | number}}
|
||||||
|
.stat-sub(v-if="plan_time_remaining || toolpath.time")
|
||||||
|
| Line · {{plan_time_remaining ? (plan_time_remaining | time) : (toolpath.time | time)}} remaining
|
||||||
|
.stat-sub(v-else) Line · ETA --
|
||||||
|
|
||||||
tr
|
// ----- Macro row (slice 0..7); full list lives in Settings → Macros -----
|
||||||
th Progress
|
// The colored left stripe (.has-color) is suppressed for white,
|
||||||
td.progress
|
// near-white and other default placeholder colors so unconfigured
|
||||||
label {{(progress || 0) | percent}}
|
// macros render as clean slate tiles instead of looking lopsided.
|
||||||
.bar(:style="'width:' + (progress || 0) * 100 + '%'")
|
.macro-row(v-if="state.macros && state.macros.length")
|
||||||
|
button.macro-btn(v-for="(index, macros) in state.macros.slice(0, 8)",
|
||||||
|
title="Click to run macro",
|
||||||
|
@click="run_macro(index)",
|
||||||
|
:disabled="!is_ready",
|
||||||
|
:class="{'has-color': has_macro_color(macros)}",
|
||||||
|
:style="has_macro_color(macros) ? {borderLeftColor: macros.color} : {}")
|
||||||
|
span.mnum {{index + 1}}
|
||||||
|
span.mname {{macros.name || ('Macro ' + (index + 1))}}
|
||||||
|
|
||||||
.macros-div(class="present")
|
// ----- Override drawer (anchored to bottom; toggled by Spindle KPI tile) -----
|
||||||
button.macros-button(title="Click to run Macros",v-for="(index,macros) in state.macros",
|
.override-drawer(:class="{open: overrides_open}")
|
||||||
@click="run_macro(index)",:disabled="!is_ready",v-bind:style="{ backgroundColor: macros.color }") {{macros.name}}
|
.od-head
|
||||||
|
.od-title
|
||||||
.tabs
|
.fa.fa-sliders
|
||||||
|
| Overrides
|
||||||
input#tab1(type="radio", name="tabs",checked="" @click="tab = 'auto'")
|
button.od-close(@click="overrides_open = false") ✕
|
||||||
label(for="tab1", title="Run GCode programs",style="height:50px;width:100px") Auto
|
.od-body
|
||||||
|
.od-row
|
||||||
input#tab2(type="radio", name="tabs", @click="tab = 'mdi'")
|
|
||||||
label(for="tab2", title="Manual GCode entry",style="height:50px;width:100px") MDI
|
|
||||||
|
|
||||||
input#tab3(type="radio", name="tabs", @click="tab = 'messages'")
|
|
||||||
label(for="tab3",style="height:50px;width:100px") Messages
|
|
||||||
|
|
||||||
input#tab4(type="radio", name="tabs", @click="tab = 'indicators'")
|
|
||||||
label(for="tab4",style="height:50px;width:100px") Indicators
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
section#content1.tab-content.pure-form
|
|
||||||
.toolbar.pure-control-group
|
|
||||||
button.pure-button(:class="{'attention': is_holding}",
|
|
||||||
title="{{is_running ? 'Pause' : 'Start'}} program.",
|
|
||||||
@click="start_pause", :disabled="!state.selected",
|
|
||||||
style="height:100px;width:100px;font-weight:normal")
|
|
||||||
img(v-if="is_running" src="images/pause_gcode.png" style="height: 55px;")
|
|
||||||
img(v-else src="images/play_gcode.png" style="height: 55px;")
|
|
||||||
|
|
||||||
button.pure-button(title="Stop program.", @click="stop", style="height:100px;width:100px;font-weight:normal")
|
|
||||||
img(src="images/stop.png" style="height: 55px;")
|
|
||||||
|
|
||||||
button.pure-button(title="Pause program at next optional stop (M1).",
|
|
||||||
@click="optional_pause", v-if="false", style="height:100px;width:100px;font-weight:normal")
|
|
||||||
.fa.fa-stop-circle-o
|
|
||||||
|
|
||||||
message(:show.sync="uploading_files")
|
|
||||||
h3(slot="header") Files uploading
|
|
||||||
div(slot="body")
|
|
||||||
h3 Please wait...
|
|
||||||
p
|
|
||||||
p The files are currently being uploaded.
|
|
||||||
p Do not close the window.
|
|
||||||
div(slot="footer")
|
|
||||||
|
|
||||||
button.pure-button(title="Execute one program step.", @click="step",
|
|
||||||
:disabled="(!is_ready && !is_holding) || !state.selected",
|
|
||||||
v-if="false", style="height:100px;width:100px;font-weight:normal")
|
|
||||||
.fa.fa-step-forward
|
|
||||||
|
|
||||||
button.pure-button(title="Upload a new GCode folder.", @click="open_folder",
|
|
||||||
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
|
|
||||||
img(src="images/upload_folder.png" style="height: 65px;")
|
|
||||||
|
|
||||||
form.gcode-folder-input.file-upload
|
|
||||||
input#folderInput(type="file", @change="upload_folder", :disabled="!is_ready",
|
|
||||||
webkitdirectory, directory)
|
|
||||||
|
|
||||||
button.pure-button(title="Upload a new GCode program.", @click="open_file",
|
|
||||||
:disabled="!is_ready",style="height:100px;width:100px;font-weight:normal")
|
|
||||||
img(src="images/upload_gcode.png" style="height: 65px;")
|
|
||||||
|
|
||||||
form.gcode-file-input.file-upload
|
|
||||||
input(type="file", @change="upload_file", :disabled="!is_ready",
|
|
||||||
accept=".nc,.ngc,.gcode,.gc", multiple)
|
|
||||||
|
|
||||||
a(:disabled="!state.selected", download,
|
|
||||||
:href="'/api/file/' + state.selected",
|
|
||||||
title="Download the selected GCode program.")
|
|
||||||
button.pure-button(:disabled="!state.selected", style="height:100px;width:100px")
|
|
||||||
img(src="images/download_gcode.png" style="height: 65px;")
|
|
||||||
|
|
||||||
button.pure-button(title="Delete current GCode program.",
|
|
||||||
@click="deleteGCode = true",
|
|
||||||
:disabled="!state.selected || !is_ready",style="height:100px;width:100px;font-weight:normal")
|
|
||||||
img(src="images/delete_gcode.png" style="height: 55px;")
|
|
||||||
|
|
||||||
message.error-message(:show.sync="deleteGCode")
|
|
||||||
h3(slot="header") Select files to delete:
|
|
||||||
div(slot="body")
|
|
||||||
input.search-bar(type="text", v-model="search_query", placeholder="Search Files...")
|
|
||||||
.container
|
|
||||||
.folders
|
|
||||||
h3 Folders
|
|
||||||
div(v-for="(index, folder) in state.gcode_list", :key="index", @click="populateFiles(index)",
|
|
||||||
class="folder-item", :class="{ selected: index === selected_folder_index }") {{ folder.name }}
|
|
||||||
.files
|
|
||||||
h3 Files
|
|
||||||
label.file-item(v-for="item in gcode_filtered_files" :key="item")
|
|
||||||
input(type="checkbox" :value="item" v-model="selected_items_to_delete")
|
|
||||||
| {{ item }}
|
|
||||||
div(slot="footer")
|
|
||||||
button.pure-button(@click="cancel_delete",style="height:50px") Cancel
|
|
||||||
//- button.pure-button.button-error(@click="delete_all_except_macros")
|
|
||||||
//- .fa.fa-trash
|
|
||||||
//- | All
|
|
||||||
button.pure-button.button-success(@click="delete_current",style="height:50px")
|
|
||||||
.fa.fa-trash
|
|
||||||
| Selected
|
|
||||||
|
|
||||||
.drop-down-container
|
|
||||||
message(:show.sync="create_folder")
|
|
||||||
h3(slot="header") Enter folder name:
|
|
||||||
div(slot="body")
|
|
||||||
input.input-name(type="text",minlength='1',maxlength='15',style ="margin-top:1rem;margin-bottom:2rem;",
|
|
||||||
id="folder-name" ,v-model="folder_name",@keypress="edited_folder_name")
|
|
||||||
|
|
||||||
div(slot="footer")
|
|
||||||
button.pure-button(@click="cancel_new_folder") Cancel
|
|
||||||
button.pure-button.button-success(@click="create_new_folder",:disabled="!edited")
|
|
||||||
| Create
|
|
||||||
|
|
||||||
message(:show.sync="confirmDelete")
|
|
||||||
h3(slot="header") Delete Folder?
|
|
||||||
div(slot="body")
|
|
||||||
p Are you sure to delete the folder?
|
|
||||||
|
|
||||||
div(slot="footer")
|
|
||||||
button.pure-button(@click="confirmDelete=false") Cancel
|
|
||||||
button.pure-button.button-error(@click="delete_folder") Folder only
|
|
||||||
button.pure-button.button-success(@click="delete_folder_and_files") Folder and files
|
|
||||||
|
|
||||||
button.pure-button(title="Create a new folder.", @click="create_folder=true",
|
|
||||||
:disabled="!is_ready",style="height:100%")
|
|
||||||
| Create Folder
|
|
||||||
|
|
||||||
button.pure-button(title="Delete a folder.", @click="confirmDelete=true",
|
|
||||||
:disabled="!is_ready",style="height:100%;margin-left:5px")
|
|
||||||
| Delete Folder
|
|
||||||
|
|
||||||
select(title="Select previously uploaded GCode folder.",
|
|
||||||
v-model="state.folder", @change="reset_gcode", :disabled="!is_ready",
|
|
||||||
style="max-width:100%;margin-left:5px")
|
|
||||||
option( selected='' value='default') Default folder
|
|
||||||
option(v-for="file in gcode_folders", :value="file") {{file}}
|
|
||||||
|
|
||||||
select(title="Select previously uploaded GCode programs.",
|
|
||||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
|
||||||
style="max-width:300px;margin-left:5px")
|
|
||||||
option(v-for="file in gcode_files", :value="file") {{file}}
|
|
||||||
|
|
||||||
button.pure-button(@click="toggle_sorting", :disabled="!is_ready",
|
|
||||||
style="height:75%")
|
|
||||||
| {{files_sortby}}
|
|
||||||
|
|
||||||
.progress(v-if="toolpath_progress && toolpath_progress < 1",
|
|
||||||
title="Simulating GCode to check for errors, calculate ETA and " +
|
|
||||||
"generate 3D view. You can run GCode before the simulation " +
|
|
||||||
"finishes.")
|
|
||||||
div(:style="'width:' + (toolpath_progress || 0) * 100 + '%'")
|
|
||||||
label Simulating {{(toolpath_progress || 0) | percent}}
|
|
||||||
|
|
||||||
path-viewer(:toolpath="toolpath", :state="state", :config="config")
|
|
||||||
gcode-viewer
|
|
||||||
|
|
||||||
section#content2.tab-content
|
|
||||||
.mdi.pure-form(title="Manual GCode entry.")
|
|
||||||
button.pure-button(:disabled="!can_mdi",
|
|
||||||
:class="{'attention': is_holding}",
|
|
||||||
title="{{is_running ? 'Pause' : 'Start'}} command.",
|
|
||||||
@click="mdi_start_pause",style="height:100px;width:100px")
|
|
||||||
.fa(:class="is_running ? 'fa-pause' : 'fa-play'")
|
|
||||||
|
|
||||||
button.pure-button(title="Stop command.", @click="stop",style="height:100px;width:100px")
|
|
||||||
.fa.fa-stop
|
|
||||||
|
|
||||||
input(v-model="mdi", :disabled="!can_mdi", @keyup.enter="submit_mdi")
|
|
||||||
|
|
||||||
div
|
|
||||||
em The machine is currently operating in #[strong {{mach_units}}] units. Use G20/G21 to switch units.
|
|
||||||
|
|
||||||
.history(:class="{placeholder: !history}")
|
|
||||||
span(v-if="!history.length") MDI history displays here.
|
|
||||||
ul
|
|
||||||
li(v-for="item in history", @click="load_history($index)",
|
|
||||||
track-by="$index")
|
|
||||||
| {{item}}
|
|
||||||
|
|
||||||
section#content3.tab-content
|
|
||||||
console
|
|
||||||
|
|
||||||
section#content4.tab-content
|
|
||||||
indicators(:state="state", :template="template")
|
|
||||||
|
|
||||||
.override(title="Feed rate override.")
|
|
||||||
label Feed
|
label Feed
|
||||||
input(type="range", min="0", max="2", step="0.01",
|
input(type="range", min="0", max="2", step="0.01",
|
||||||
v-model="feed_override", @change="override_feed")
|
v-model="feed_override", @change="override_feed")
|
||||||
span.percent {{feed_override | percent 0}}
|
.od-val {{feed_override | percent 0}}
|
||||||
|
button.od-reset(@click="feed_override = 1; override_feed()") Reset 100%
|
||||||
.override(title="Spindle speed override.")
|
.od-row
|
||||||
label Speed
|
label Spindle
|
||||||
input(type="range", min="0", max="2", step="0.01",
|
input(type="range", min="0", max="2", step="0.01",
|
||||||
v-model="speed_override", @change="override_speed")
|
v-model="speed_override", @change="override_speed")
|
||||||
span.percent {{speed_override | percent 0}}
|
.od-val {{speed_override | percent 0}}
|
||||||
|
button.od-reset(@click="speed_override = 1; override_speed()") Reset 100%
|
||||||
|
|
||||||
|
|||||||
142
src/pug/templates/program-view.pug
Normal file
142
src/pug/templates/program-view.pug
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
script#program-view-template(type="text/x-template")
|
||||||
|
.program-page
|
||||||
|
|
||||||
|
// ----- Modal dialogs -----
|
||||||
|
message(:show.sync="showGcodeMessage")
|
||||||
|
h3(slot="header") Processing New File
|
||||||
|
div(slot="body")
|
||||||
|
h3 Please wait..
|
||||||
|
p Simulating GCode to check for errors, calculate ETA and generate 3D view.
|
||||||
|
div(slot="footer")
|
||||||
|
label Simulating {{(toolpath_progress || 0) | percent}}
|
||||||
|
|
||||||
|
message(:show.sync="GCodeNotFound")
|
||||||
|
h3(slot="header") File not found
|
||||||
|
div(slot="body")
|
||||||
|
p It seems like the file you selected cannot be found. Try uploading again.
|
||||||
|
div(slot="footer")
|
||||||
|
button.pure-button.button-error(@click="GCodeNotFound=false") OK
|
||||||
|
|
||||||
|
message(:show.sync="uploading_files")
|
||||||
|
h3(slot="header") Files uploading
|
||||||
|
div(slot="body")
|
||||||
|
h3 Please wait...
|
||||||
|
p
|
||||||
|
p The files are currently being uploaded.
|
||||||
|
p Do not close the window.
|
||||||
|
div(slot="footer")
|
||||||
|
|
||||||
|
message.error-message(:show.sync="deleteGCode")
|
||||||
|
h3(slot="header") Select files to delete:
|
||||||
|
div(slot="body")
|
||||||
|
input.search-bar(type="text", v-model="search_query", placeholder="Search Files...")
|
||||||
|
.container
|
||||||
|
.folders
|
||||||
|
h3 Folders
|
||||||
|
div(v-for="(index, folder) in state.gcode_list", :key="index",
|
||||||
|
@click="populateFiles(index)",
|
||||||
|
class="folder-item",
|
||||||
|
:class="{ selected: index === selected_folder_index }") {{ folder.name }}
|
||||||
|
.files
|
||||||
|
h3 Files
|
||||||
|
label.file-item(v-for="item in gcode_filtered_files", :key="item")
|
||||||
|
input(type="checkbox", :value="item", v-model="selected_items_to_delete")
|
||||||
|
| {{ item }}
|
||||||
|
div(slot="footer")
|
||||||
|
button.pure-button(@click="cancel_delete", style="height:50px") Cancel
|
||||||
|
button.pure-button.button-success(@click="delete_current", style="height:50px")
|
||||||
|
.fa.fa-trash
|
||||||
|
| Selected
|
||||||
|
|
||||||
|
message(:show.sync="create_folder")
|
||||||
|
h3(slot="header") Enter folder name:
|
||||||
|
div(slot="body")
|
||||||
|
input.input-name(type="text", minlength="1", maxlength="15",
|
||||||
|
style="margin-top:1rem;margin-bottom:2rem;",
|
||||||
|
id="folder-name", v-model="folder_name", @keypress="edited_folder_name")
|
||||||
|
div(slot="footer")
|
||||||
|
button.pure-button(@click="cancel_new_folder") Cancel
|
||||||
|
button.pure-button.button-success(@click="create_new_folder", :disabled="!edited") Create
|
||||||
|
|
||||||
|
message(:show.sync="confirmDelete")
|
||||||
|
h3(slot="header") Delete Folder?
|
||||||
|
div(slot="body")
|
||||||
|
p Are you sure to delete the folder?
|
||||||
|
div(slot="footer")
|
||||||
|
button.pure-button(@click="confirmDelete=false") Cancel
|
||||||
|
button.pure-button.button-error(@click="delete_folder") Folder only
|
||||||
|
button.pure-button.button-success(@click="delete_folder_and_files") Folder and files
|
||||||
|
|
||||||
|
.program-card
|
||||||
|
|
||||||
|
// Action bar (RUN / STOP / Upload / Download / Delete)
|
||||||
|
.action-bar
|
||||||
|
button.action-btn.run(:class="{'attention': is_holding}",
|
||||||
|
@click="start_pause", :disabled="!state.selected",
|
||||||
|
:title="is_running ? 'Pause program.' : 'Start program.'")
|
||||||
|
.fa.fa-play.ico(v-if="!is_running")
|
||||||
|
.fa.fa-pause.ico(v-else)
|
||||||
|
span {{is_running ? 'PAUSE' : 'RUN'}}
|
||||||
|
button.action-btn.stop(@click="stop", title="Stop program.")
|
||||||
|
.fa.fa-stop.ico
|
||||||
|
span STOP
|
||||||
|
button.action-btn(@click="open_folder", :disabled="!is_ready",
|
||||||
|
title="Upload a new GCode folder.")
|
||||||
|
.fa.fa-folder-plus.ico
|
||||||
|
span UPLOAD FOLDER
|
||||||
|
form.gcode-folder-input.file-upload
|
||||||
|
input#folderInput(type="file", @change="upload_folder",
|
||||||
|
:disabled="!is_ready", webkitdirectory, directory)
|
||||||
|
button.action-btn(@click="open_file", :disabled="!is_ready",
|
||||||
|
title="Upload a new GCode program.")
|
||||||
|
.fa.fa-file-arrow-up.ico
|
||||||
|
span UPLOAD FILE
|
||||||
|
form.gcode-file-input.file-upload
|
||||||
|
input(type="file", @change="upload_file", :disabled="!is_ready",
|
||||||
|
accept=".nc,.ngc,.gcode,.gc", multiple)
|
||||||
|
a(:href="state.selected ? '/api/file/' + state.selected : '#'",
|
||||||
|
download, :class="{disabled: !state.selected}",
|
||||||
|
title="Download the selected GCode program.")
|
||||||
|
button.action-btn(:disabled="!state.selected")
|
||||||
|
.fa.fa-file-arrow-down.ico
|
||||||
|
span DOWNLOAD FILE
|
||||||
|
button.action-btn.danger(@click="deleteGCode = true",
|
||||||
|
:disabled="!state.selected || !is_ready",
|
||||||
|
title="Delete current GCode program.")
|
||||||
|
.fa.fa-trash.ico
|
||||||
|
span DELETE
|
||||||
|
|
||||||
|
// File / folder selectors
|
||||||
|
.file-bar
|
||||||
|
button.file-btn(@click="create_folder=true", :disabled="!is_ready")
|
||||||
|
.fa.fa-folder-plus
|
||||||
|
| Create Folder
|
||||||
|
button.file-btn(@click="confirmDelete=true", :disabled="!is_ready")
|
||||||
|
.fa.fa-folder-minus
|
||||||
|
| Delete Folder
|
||||||
|
select.file-select(title="Select previously uploaded GCode folder.",
|
||||||
|
v-model="state.folder", @change="reset_gcode", :disabled="!is_ready")
|
||||||
|
option(selected, value="default") Default folder
|
||||||
|
option(v-for="file in gcode_folders", :value="file") {{file}}
|
||||||
|
select.file-select.primary(title="Select previously uploaded GCode programs.",
|
||||||
|
v-model="state.selected", @change="load", :disabled="!is_ready")
|
||||||
|
option(value="") (no file)
|
||||||
|
option(v-for="file in gcode_files", :value="file") {{file}}
|
||||||
|
button.file-btn(@click="toggle_sorting", :disabled="!is_ready")
|
||||||
|
.fa.fa-arrow-down-wide-short
|
||||||
|
| {{files_sortby}}
|
||||||
|
|
||||||
|
// Body: gcode listing on the left, 3D viewer on the right.
|
||||||
|
// The 3D path-viewer is suppressed when the UI is loaded by
|
||||||
|
// the Pi's onboard kiosk browser — the VideoCore IV cannot
|
||||||
|
// run three.js at a usable frame rate. Off-Pi clients still
|
||||||
|
// see the full split.
|
||||||
|
.program-body(:class="{'no-preview': is_kiosk}")
|
||||||
|
gcode-viewer
|
||||||
|
path-viewer(v-if="!is_kiosk", :toolpath="toolpath",
|
||||||
|
:state="state", :config="config")
|
||||||
|
|
||||||
|
.progress-bar(v-if="toolpath_progress && toolpath_progress < 1",
|
||||||
|
title="Simulating GCode to check for errors, calculate ETA and generate 3D view.")
|
||||||
|
div(:style="'width:' + (toolpath_progress || 0) * 100 + '%'")
|
||||||
|
label Simulating {{(toolpath_progress || 0) | percent}}
|
||||||
56
src/pug/templates/settings-shell.pug
Normal file
56
src/pug/templates/settings-shell.pug
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
script#settings-shell-view-template(type="text/x-template")
|
||||||
|
.settings-shell
|
||||||
|
aside.settings-rail
|
||||||
|
// Use a single v-for over a data-driven items array so every
|
||||||
|
// rail item shares the same compiled :class binding template.
|
||||||
|
// This sidesteps a Vue 1 quirk where sibling-with-different-
|
||||||
|
// expression :class bindings sometimes fail to re-evaluate on
|
||||||
|
// hash navigation, leaving stale `.active` classes.
|
||||||
|
template(v-for="item in rail_items")
|
||||||
|
.set-section(v-if="item.section") {{item.section}}
|
||||||
|
a.set-item(v-if="!item.section", :class="{active: is_active(item)}",
|
||||||
|
:href="item.href", @click="on_rail_click(item, $event)")
|
||||||
|
.fa(:class="item.icon")
|
||||||
|
| {{item.label}}
|
||||||
|
.set-rail-foot
|
||||||
|
button.sp-shutdown(@click="showShutdownDialog")
|
||||||
|
.fa.fa-power-off
|
||||||
|
| Shutdown
|
||||||
|
button.sp-save(:disabled="!$root.modified", @click="$root.save()")
|
||||||
|
.fa.fa-save
|
||||||
|
| Save{{$root.modified ? '*' : ''}}
|
||||||
|
|
||||||
|
.settings-content
|
||||||
|
// Explicit v-if cascade so the inner template swaps reactively
|
||||||
|
// when sub changes (Vue 1's `<component :is>` does not always
|
||||||
|
// re-evaluate dynamic strings inside a kept-alive parent).
|
||||||
|
// The Svelte settings views read many config keys eagerly on
|
||||||
|
// attach (settings.units, settings.easy-adapter, motion.*),
|
||||||
|
// so we gate the inner mount on config_ready.
|
||||||
|
settings-view-inner(v-if="sub === 'settings' && config_ready",
|
||||||
|
section="display",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
settings-view-inner(v-if="sub === 'probing' && config_ready",
|
||||||
|
section="probing",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
settings-view-inner(v-if="sub === 'gcode' && config_ready",
|
||||||
|
section="gcode",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
admin-general-view(v-if="sub === 'admin-general' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
admin-network-view(v-if="sub === 'admin-network' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
motor-view(v-if="sub === 'motor' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
tool-view(v-if="sub === 'tool' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
io-view(v-if="sub === 'io' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
macros-view(v-if="sub === 'macros' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
help-view(v-if="sub === 'help' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
cheat-sheet-view(v-if="sub === 'cheat-sheet' && config_ready",
|
||||||
|
:index="index", :config="config", :template="template", :state="state")
|
||||||
|
.settings-loading(v-if="!config_ready")
|
||||||
|
| Loading configuration…
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,8 @@
|
|||||||
<h1>Settings</h1>
|
<h1>Settings</h1>
|
||||||
|
|
||||||
<div class="pure-form pure-form-aligned">
|
<div class="pure-form pure-form-aligned">
|
||||||
<h2>User Interface</h2>
|
<h2 id="sec-display" data-sec="display">User Interface</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="display">
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="screen-rotation" />
|
<label for="screen-rotation" />
|
||||||
<Button
|
<Button
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Units</h2>
|
<h2 id="sec-units" data-sec="display">Units</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="display">
|
||||||
<ConfigTemplatedInput key={`settings.units`} />
|
<ConfigTemplatedInput key={`settings.units`} />
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
Note, units sets both the machine default units and the units used in motor configuration. GCode program-start,
|
Note, units sets both the machine default units and the units used in motor configuration. GCode program-start,
|
||||||
@@ -54,13 +54,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Easy Adapter</h2>
|
<h2 id="sec-easy-adapter" data-sec="display">Easy Adapter</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="display">
|
||||||
<ConfigTemplatedInput key={`settings.easy-adapter`} />
|
<ConfigTemplatedInput key={`settings.easy-adapter`} />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Probing</h2>
|
<h2 id="sec-probing" data-sec="probing">Probing</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="probing">
|
||||||
<ConfigTemplatedInput key={`settings.probing-prompts`} />
|
<ConfigTemplatedInput key={`settings.probing-prompts`} />
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
Onefinity highly recommends that you keep the safety prompts
|
Onefinity highly recommends that you keep the safety prompts
|
||||||
@@ -87,15 +87,15 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset data-sec="gcode">
|
||||||
<h2>GCode</h2>
|
<h2 id="sec-gcode" data-sec="gcode">GCode</h2>
|
||||||
{#each Object.keys(configTemplate.gcode) as key}
|
{#each Object.keys(configTemplate.gcode) as key}
|
||||||
<ConfigTemplatedInput key={`gcode.${key}`} />
|
<ConfigTemplatedInput key={`gcode.${key}`} />
|
||||||
{/each}
|
{/each}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Path Accuracy</h2>
|
<h2 id="sec-path-accuracy" data-sec="gcode">Path Accuracy</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="gcode">
|
||||||
<ConfigTemplatedInput key={`settings.max-deviation`} />
|
<ConfigTemplatedInput key={`settings.max-deviation`} />
|
||||||
|
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
@@ -118,8 +118,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Cornering Speed (Advanced)</h2>
|
<h2 id="sec-cornering" data-sec="gcode">Cornering Speed (Advanced)</h2>
|
||||||
<fieldset>
|
<fieldset data-sec="gcode">
|
||||||
<ConfigTemplatedInput key={`settings.junction-accel`} />
|
<ConfigTemplatedInput key={`settings.junction-accel`} />
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
Junction acceleration limits the cornering speed the planner
|
Junction acceleration limits the cornering speed the planner
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
>
|
>
|
||||||
<div slot="trailingIcon">
|
<div slot="trailingIcon">
|
||||||
{#if valid}
|
{#if valid}
|
||||||
<Icon class="fa fa-check-circle-o" style="color: green;" />
|
<Icon class="fa fa-circle-check" style="color: green;" />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<HelperText persistent slot="helper">{helperText}</HelperText>
|
<HelperText persistent slot="helper">{helperText}</HelperText>
|
||||||
|
|||||||
Reference in New Issue
Block a user