diff --git a/src/App.vue b/src/App.vue index 7fce635c..a8145ae5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -32,7 +32,7 @@ elevate-on-scroll> - Emergency Stop + Emergency Stop @@ -81,7 +81,11 @@ export default { header: [], heater_bed: [], extruder: ["temperature", "target"], - fan: []}); + fan: [], + pause_resume: [], + idle_timeout: [], + + }); this.$socket.sendObj('get_printer_files', {}, 'getFileList'); } }, @@ -93,7 +97,14 @@ export default { toolhead: state => state.printer.toolhead, hostname: state => state.printer.hostname, version: state => state.printer.version, + loadingEmergencyStop: state => state.socket.loadingEmergencyStop, }), + }, + methods: { + emergencyStop: function() { + this.$store.commit('setLoadingEmergencyStop', true); + this.$socket.sendObj('post_printer_gcode', {script: 'M112'}, 'setLoadingEmergencyStop'); + }, } } diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index d304660b..931e07c2 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -6,6 +6,9 @@ Status {{ toolhead !== null && 'status' in toolhead ? toolhead.status : "" }} + pause job + resume job + cancel job @@ -110,14 +113,23 @@ export default { computed: { ...mapState({ - position: state => state.printer.toolhead.position + position: state => state.printer.toolhead.position, + btnStatusPause: state => state.socket.loadingPrintPause, + btnStatusResume: state => state.socket.loadingPrintResume, }), ...mapGetters([ 'toolhead' ]) }, methods: { - + btnPauseJob() { + this.$store.commit('setLoadingPrintPause', true); + this.$socket.sendObj('post_printer_print_pause', { }, 'setLoadingPrintPause'); + }, + btnResumeJob() { + this.$store.commit('setLoadingPrintResume', true); + this.$socket.sendObj('post_printer_print_resume', { }, 'setLoadingPrintResume'); + } }, } diff --git a/src/main.js b/src/main.js index b9c2b44f..a476912b 100644 --- a/src/main.js +++ b/src/main.js @@ -7,8 +7,9 @@ import routes from './routes' import VueResource from 'vue-resource' import './components' import store from './store' +import { hostname } from './store/variables' -Vue.use(JRPCWS, 'ws://'+window.location.host+'/websocket', { +Vue.use(JRPCWS, 'ws://' + hostname + '/websocket', { store: store }); diff --git a/src/pages/Files.vue b/src/pages/Files.vue index e5989d04..d460a708 100644 --- a/src/pages/Files.vue +++ b/src/pages/Files.vue @@ -22,7 +22,7 @@ \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index f1c651bd..509db25e 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -1,9 +1,9 @@ import Dashboard from '../pages/Dashboard.vue' -import Status from '../pages/Status.vue' +//import Status from '../pages/Status.vue' import Console from '../pages/Console.vue' import Files from '../pages/Files.vue' -import SettingsGeneral from '../pages/settings/general.vue' -import SettingsMachine from '../pages/settings/machine.vue' +//import SettingsGeneral from '../pages/settings/general.vue' +//import SettingsMachine from '../pages/settings/machine.vue' const routes = [ { @@ -13,24 +13,24 @@ const routes = [ component: Dashboard }, { + title: "Console", + path: '/console', + icon: 'code-tags', + component: Console + }, + /*{ title: "Current Job", path: '/status', icon: 'printer-3d-nozzle', component: Status - }, + },*/ { title: "G-Code Files", path: '/files', icon: 'printer-3d-nozzle', component: Files }, - { - title: "Console", - path: '/console', - icon: 'code-tags', - component: Console - }, - { + /*{ title: "Settings", path: '/settings', icon: 'wrench', @@ -48,7 +48,7 @@ const routes = [ component: SettingsMachine }, ] - }, + },*/ ]; diff --git a/src/store/index.js b/src/store/index.js index 000919da..32d57612 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -24,6 +24,9 @@ export default new Vuex.Store({ isConnected: false, loadingGcodeUpload: false, loadingGcodeRefresh: false, + loadingEmergencyStop: false, + loadingPrintPause: false, + loadingPrintResume: false, }, printer: { hostname: '', @@ -160,8 +163,7 @@ export default new Vuex.Store({ state.socket.loadingSendGcode = value; }, - sendGcode(state, data) { - window.console.log(data); + sendGcode(state) { state.socket.loadingSendGcode = false; }, @@ -177,6 +179,22 @@ export default new Vuex.Store({ state.socket.loadingGcodeRefresh = value; }, + setLoadingEmergencyStop(state, value) { + state.socket.loadingEmergencyStop = value; + }, + + setLoadingPrintPause(state, value) { + state.socket.loadingPrintPause = value; + }, + + setLoadingPrintResume(state, value) { + state.socket.loadingPrintResume = value; + }, + + reportError: (data) => { + this.$toast(data.message) + }, + voidMutation() { }, @@ -199,11 +217,7 @@ export default new Vuex.Store({ }, socket_on_error ({ commit }, data) { - commit('voidMutation'); - window.console.error('Socket Error: ' + data.message); - window.console.log(data); - - //this.$toast.error(data.message) + commit('reportError', data); }, socket_on_message ({ commit, state }, data) { @@ -221,6 +235,10 @@ export default new Vuex.Store({ commit('setPrinterStatus', data.params[0]); break; + /*case 'notify_klippy_state_changed': + commit('setPrinterStatus', data.params[0]); + break;*/ + case 'notify_filelist_changed': commit('setFileList', data.params[0].filelist); break; @@ -267,9 +285,26 @@ export default new Vuex.Store({ commit('setLoadingSendGcode', value); }, + setLoadingEmergencyStop({commit}) { + commit('setLoadingEmergencyStop', false); + }, + + setLoadingPrintPause({commit}) { + commit('setLoadingPrintPause', false); + }, + + setLoadingPrintResume({commit}) { + commit('setLoadingPrintResume', false); + }, + sendGcode({commit}, data) { commit('setLoadingSendGcode', false); commit('sendGcode', data); + }, + + switchToDashboard(state) { + window.console.log(state); + } } }); \ No newline at end of file diff --git a/src/store/variables.js b/src/store/variables.js new file mode 100644 index 00000000..677251f0 --- /dev/null +++ b/src/store/variables.js @@ -0,0 +1,2 @@ +//export const hostname = window.location.host; +export const hostname = "kossel.local:8080"; \ No newline at end of file