From eb493afec6fe093e49a058a9d9aa871355b39aec Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 12 Oct 2019 17:33:04 -0700 Subject: [PATCH] Suppress message popup with (MSG,# No popup message), Show latest GCode message in Message field on CONTROL page, 'Reason' back to 'Message'. --- CHANGELOG.md | 3 ++- src/js/app.js | 14 ++++++++++++++ src/js/control-view.js | 6 ++++-- src/pug/index.pug | 4 ++-- src/pug/templates/control-view.pug | 13 ++++++++++--- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e2b04..35a6ada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ Buildbotics CNC Controller Firmware Changelog - Log GCode messages to "Messages" tab. - Acknowledging a message on one browser clears it for all. - Automatically reload Web view when file changes. - - Changed "Message" field to "Reason" in Web interface. - Added ``config-screen`` script. Web based screen config to come later. + - Suppress message popup with (MSG,# No popup message). + - Show latest GCode message in ``Message`` field on CONTROL page. ## v0.4.11 - Don't reset global offsets on M2. diff --git a/src/js/app.js b/src/js/app.js index 9c77215..df14c72 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -201,6 +201,20 @@ module.exports = new Vue({ }, + computed: { + popupMessages: function () { + var msgs = []; + + for (var i = 0; i < this.state.messages.length; i++) { + var text = this.state.messages[i].text; + if (!/^#/.test(text)) msgs.push(text); + } + + return msgs; + } + }, + + ready: function () { $(window).on('hashchange', this.parse_hash); this.connect(); diff --git a/src/js/control-view.js b/src/js/control-view.js index 5b777f1..ff6fc06 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -147,14 +147,16 @@ module.exports = { }, - reason: function () { + message: function () { if (this.mach_state == 'ESTOPPED') return this.state.er; if (this.mach_state == 'HOLDING') return this.state.pr; + if (this.state.messages.length) + return this.state.messages.slice(-1)[0].text; return ''; }, - highlight_reason: function () { + highlight_state: function () { return this.mach_state == 'ESTOPPED' || this.mach_state == 'HOLDING'; }, diff --git a/src/pug/index.pug b/src/pug/index.pug index 06a8430..04e7f87 100644 --- a/src/pug/index.pug +++ b/src/pug/index.pug @@ -182,12 +182,12 @@ html(lang="en") p Loss of power during an upgrade may damage the controller. div(slot="footer") - message(v-if="state.messages.length", :show="true") + message(v-if="popupMessages.length", :show="true") h3(slot="header") GCode message div(slot="body") ul - li(v-for="msg in state.messages", track-by="$index") {{msg.text}} + li(v-for="msg in popupMessages", track-by="$index") {{msg}} div(slot="footer") button.pure-button.button-success(v-if="state.xx != 'HOLDING'", diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index 232224b..a2fa810 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -114,16 +114,20 @@ script#control-view-template(type="text/x-template") table.info tr th State - td(:class="{attention: highlight_reason}") {{mach_state}} + td(:class="{attention: highlight_state}") {{mach_state}} + tr - th Reason - td.reason(:class="{attention: highlight_reason}") {{reason}} + th Message + td.message(:class="{attention: highlight_state}") + | {{message.replace(/^#/, '')}} + tr(title="Active machine units") th Units td.mach_units select(v-model="mach_units", :disabled="!is_idle") option(value="METRIC") METRIC option(value="IMPERIAL") IMPERIAL + tr(title="Active tool") th Tool td {{state.tool || 0}} @@ -136,17 +140,20 @@ script#control-view-template(type="text/x-template") unit-value(:value="state.v", precision="2", unit="", iunit="", scale="0.0254") | {{metric ? ' m/min' : ' IPM'}} + tr(title="Programmed feed rate.") th Feed td unit-value(:value="state.feed", precision="2", unit="", iunit="") | {{metric ? ' mm/min' : ' IPM'}} + tr(title="Programed and actual speed.") th Speed td | {{state.speed || 0 | fixed 0}} span(v-if="!isNaN(state.s)")  ({{state.s | fixed 0}}) = ' RPM' + tr(title="Load switch states.") th Loads td -- 2.27.0