Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54aaf8d0c7 | ||
|
|
851c17a6d4 | ||
|
|
aa0780097c | ||
|
|
1ae7827f7e | ||
|
|
98950a2b9a | ||
|
|
3051c9a033 | ||
|
|
da7dc25b51 | ||
|
|
ea8d6cfb84 |
No files matched your search
@@ -1,24 +1,99 @@
|
||||
# kwc
|
||||
# Klipper Web Control
|
||||
KWC is a responsive web interface for [Klipper](https://github.com/KevinOConnor/klipper) 3D printer firmware. It communicates with the klipper-api from [Arksine](https://github.com/arksine).
|
||||
|
||||
## Project setup
|
||||
```
|
||||
npm install
|
||||
## Installation
|
||||
At first install Arksine klipper-api fork/branch -> [install manual](https://github.com/Arksine/klipper/tree/work-web_server-20200131/klippy/extras/web_server)
|
||||
|
||||
Download and install KWC:
|
||||
```bash
|
||||
mkdir -p ~/kwc
|
||||
cd ~/kwc
|
||||
wget -q -O kwc.zip https://github.com/meteyou/kwc/releases/download/v0.0.5/kwc-alpha-0.0.5.zip && unzip kwc.zip && rm kwc.zip
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
Configure web_server in printer.cfg:
|
||||
```
|
||||
npm run serve
|
||||
[web_server]
|
||||
port: 8080
|
||||
enable_cors: true
|
||||
trusted_clients:
|
||||
192.168.1.0/24
|
||||
127.0.0.1
|
||||
web_path: ~/kwc
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
Example Klipper macros:
|
||||
```
|
||||
npm run build
|
||||
[pause_resume]
|
||||
|
||||
[gcode_macro CANCEL]
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
M104 S0
|
||||
M140 S0
|
||||
M141 S0
|
||||
M106 S0
|
||||
CLEAR_PAUSE
|
||||
RESET_SD
|
||||
|
||||
[gcode_macro CANCEL_PRINT]
|
||||
gcode:
|
||||
CANCEL
|
||||
|
||||
[gcode_macro PAUSE]
|
||||
rename_existing: BASE_PAUSE
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
SAVE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_PAUSE
|
||||
G91
|
||||
G1 E-1.7 F2100
|
||||
G1 Z{Z}
|
||||
G90
|
||||
G1 X{X} Y{Y} F6000
|
||||
G91
|
||||
|
||||
[gcode_macro RESUME]
|
||||
rename_existing: BASE_RESUME
|
||||
gcode:
|
||||
G91
|
||||
G1 E1.7 F2100
|
||||
G91
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
|
||||
BASE_RESUME
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
## Installation haproxy
|
||||
haproxy is necessary to use port 80.
|
||||
|
||||
`sudo apt install haproxy`
|
||||
|
||||
add following lines at the end of `/etc/haproxy/haproxy.cfg`:
|
||||
```
|
||||
npm run lint
|
||||
frontend public
|
||||
bind :::80 v4v6
|
||||
# use_backend webcam if { path_beg /webcam/ }
|
||||
default_backend kwc
|
||||
|
||||
backend kwc
|
||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||
option forwardfor
|
||||
server kwc1 127.0.0.1:8080
|
||||
|
||||
#backend webcam
|
||||
# reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
|
||||
# server webcam1 127.0.0.1:8081
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
## Update KWC to V0.0.5
|
||||
```
|
||||
rm -R ~/kwc/*
|
||||
cd ~/kwc
|
||||
wget -q -O kwc.zip https://github.com/meteyou/kwc/releases/download/v0.0.5/kwc-alpha-0.0.5.zip && unzip kwc.zip && rm kwc.zip
|
||||
```
|
||||
and update your macros
|
||||
Generated
+2034
-1628
File diff suppressed because it is too large.
Load diff
+18
-18
@@ -10,37 +10,37 @@
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"chart.js": "^2.9.3",
|
||||
"core-js": "^3.1.2",
|
||||
"vue": "^2.6.10",
|
||||
"core-js": "^3.6.4",
|
||||
"vue": "^2.6.11",
|
||||
"vue-chartjs": "^3.5.0",
|
||||
"vue-context": "^5.0.0",
|
||||
"vue-headful": "^2.1.0",
|
||||
"vue-json-rpc-websocket": "^1.0.5",
|
||||
"vue-json-rpc-websocket": "^1.1.1",
|
||||
"vue-resource": "^1.5.1",
|
||||
"vue-simple-upload": "^0.1.6",
|
||||
"vue-toast-notification": "0.0.3",
|
||||
"vuetify": "^2.1.0",
|
||||
"vuetify": "^2.2.17",
|
||||
"vuetify-toast-snackbar": "^0.6.1",
|
||||
"vuex": "^3.1.1"
|
||||
"vuex": "^3.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.12.0",
|
||||
"@mdi/font": "^4.5.95",
|
||||
"@vue/cli-plugin-babel": "^4.0.0",
|
||||
"@vue/cli-plugin-eslint": "^4.0.0",
|
||||
"@vue/cli-service": "^4.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"css-loader": "^3.4.0",
|
||||
"@fortawesome/fontawesome-free": "^5.12.1",
|
||||
"@mdi/font": "^4.9.95",
|
||||
"@vue/cli-plugin-babel": "^4.2.3",
|
||||
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"css-loader": "^3.4.2",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"material-design-icons-iconfont": "^5.0.1",
|
||||
"sass": "^1.19.0",
|
||||
"sass-loader": "^8.0.0",
|
||||
"sass": "^1.26.3",
|
||||
"sass-loader": "^8.0.2",
|
||||
"vue-cli-plugin-route": "0.0.7",
|
||||
"vue-cli-plugin-vuetify": "^1.1.0",
|
||||
"vue-router": "^3.1.3",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"vuetify-loader": "^1.3.0"
|
||||
"vue-cli-plugin-vuetify": "^1.1.2",
|
||||
"vue-router": "^3.1.6",
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"vuetify-loader": "^1.4.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico" id="favicon" />
|
||||
<title>KlipperWebControl</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
|
||||
|
||||
+73
-4
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<v-app>
|
||||
<vue-headful
|
||||
:title="getTitle"
|
||||
/>
|
||||
<v-navigation-drawer
|
||||
class="sidebar-wrapper" persistent v-model="drawer" enable-resize-watcher fixed app
|
||||
:src="require('./assets/bg-navi.jpg')"
|
||||
@@ -46,16 +49,25 @@
|
||||
</v-scroll-y-transition>
|
||||
</v-content>
|
||||
|
||||
<v-dialog v-model="isConnecting" persistent width="300">
|
||||
<v-card color="primary" dark >
|
||||
<v-card-text class="pt-2">
|
||||
Connecting to Klipper
|
||||
<v-progress-linear indeterminate color="white" class="mb-0"></v-progress-linear>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-footer app class="d-block">
|
||||
<span v-if="version">{{ version }}</span>
|
||||
<span class="float-right">© 2019</span>
|
||||
<span class="float-right">© 2020</span>
|
||||
</v-footer>
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import routes from './routes';
|
||||
import { mapState } from 'vuex';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -75,11 +87,12 @@ export default {
|
||||
this.$socket.sendObj('get_printer_info', {}, 'getKlipperInfo');
|
||||
this.$socket.sendObj('get_printer_objects', {}, 'getObjectInfo');
|
||||
this.$socket.sendObj('get_printer_status', { heater: [] }, 'getObjectInfo');
|
||||
this.$socket.sendObj('get_printer_status', { configfile: ['config'] }, 'getPrinterConfig');
|
||||
this.$socket.sendObj('post_printer_subscriptions', {
|
||||
gcode: ["gcode_position", "speed", "speed_factor", "extrude_factor", "busy", "abs_extrude"],
|
||||
gcode: [],
|
||||
toolhead: [],
|
||||
virtual_sdcard: [],
|
||||
header: [],
|
||||
heater: [],
|
||||
heater_bed: [],
|
||||
extruder: ["temperature", "target"],
|
||||
fan: [],
|
||||
@@ -100,13 +113,69 @@ export default {
|
||||
version: state => state.printer.version,
|
||||
loadingEmergencyStop: state => state.socket.loadingEmergencyStop,
|
||||
isConnected: state => state.socket.isConnected,
|
||||
isConnecting: state => !state.socket.isConnected,
|
||||
progress: state => state.printer.virtual_sdcard.progress,
|
||||
}),
|
||||
...mapGetters([
|
||||
'getTitle'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
emergencyStop: function() {
|
||||
this.$store.commit('setLoadingEmergencyStop', true);
|
||||
this.$socket.sendObj('post_printer_gcode', {script: 'M112'}, 'setLoadingEmergencyStop');
|
||||
},
|
||||
drawFavicon(val) {
|
||||
let favicon = document.getElementById('favicon');
|
||||
if (val === 0) favicon.href = "/favicon.ico";
|
||||
else {
|
||||
let faviconSize = 64;
|
||||
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.width = faviconSize;
|
||||
canvas.height = faviconSize;
|
||||
let context = canvas.getContext('2d');
|
||||
let centerX = canvas.width / 2;
|
||||
let centerY = canvas.height / 2;
|
||||
let radius = 32;
|
||||
let percent = val * 100;
|
||||
|
||||
/* draw the grey circle */
|
||||
context.beginPath();
|
||||
context.moveTo(centerX, centerY);
|
||||
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
|
||||
context.closePath();
|
||||
context.fillStyle = "#ddd";
|
||||
context.fill();
|
||||
context.strokeStyle = "rgba(200, 208, 218, 0.66)";
|
||||
context.stroke();
|
||||
|
||||
/* draw the green circle based on percentage */
|
||||
let startAngle = 1.5 * Math.PI;
|
||||
let endAngle = 0;
|
||||
let unitValue = (Math.PI - 0.5 * Math.PI) / 25;
|
||||
if (percent >= 0 && percent <= 25) endAngle = startAngle + (percent * unitValue);
|
||||
else if (percent > 25 && percent <= 50) endAngle = startAngle + (percent * unitValue);
|
||||
else if (percent > 50 && percent <= 75) endAngle = startAngle + (percent * unitValue);
|
||||
else if (percent > 75 && percent <= 100) endAngle = startAngle + (percent * unitValue);
|
||||
|
||||
context.beginPath();
|
||||
context.moveTo(centerX, centerY);
|
||||
context.arc(centerX, centerY, radius, startAngle, endAngle, false);
|
||||
context.closePath();
|
||||
context.fillStyle = "#e41313";
|
||||
context.fill();
|
||||
|
||||
favicon.href = canvas.toDataURL('image/png');
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
progress: {
|
||||
handler: function(val) {
|
||||
this.drawFavicon(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -26,6 +26,17 @@ export default {
|
||||
fontFamily: 'Roboto,sans-serif'
|
||||
}
|
||||
},
|
||||
tooltips: {
|
||||
enabled: true,
|
||||
callbacks: {
|
||||
title: function (tooltipItem, data) {
|
||||
return data['labels'][tooltipItem[0]['index']];
|
||||
},
|
||||
label: function (tooltipItem, data) {
|
||||
return data['datasets'][0]['data'][tooltipItem['index']];
|
||||
},
|
||||
}
|
||||
},
|
||||
maintainAspectRatio: false,
|
||||
responsive: true,
|
||||
responsiveAnimationDuration: 0, // animation duration after a resize
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<v-card>
|
||||
<v-col xs12 md12>
|
||||
<v-row class="pl-3 pr-3 text-center">
|
||||
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
|
||||
<v-btn @click="doSend('X-100')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>X-100</span></v-btn>
|
||||
<v-btn @click="doSend('X-10')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>X-10</span></v-btn>
|
||||
<v-btn @click="doSend('X-1')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>X-1</span></v-btn>
|
||||
<v-btn @click="doHomeX" :color="homedAxes.includes('x') ? 'primary' : 'warning'" :loading="loadingHomeX"><v-icon class="mdi mdi-home"></v-icon></v-btn>
|
||||
<v-btn @click="doSend('X+1')" cols="1" class="flex-grow-1 flex-shrink-0"><span>X+1</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('X+10')" cols="1" class="flex-grow-1 flex-shrink-0"><span>X+10</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('X+100')" cols="1" class="flex-grow-1 flex-shrink-0"><span>X+100</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-row>
|
||||
<v-row class="pl-3 pr-3 mt-3 text-center">
|
||||
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
|
||||
<v-btn @click="doSend('Y-100')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Y-100</span></v-btn>
|
||||
<v-btn @click="doSend('Y-10')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Y-10</span></v-btn>
|
||||
<v-btn @click="doSend('Y-1')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Y-1</span></v-btn>
|
||||
<v-btn @click="doHomeY" :color="homedAxes.includes('y') ? 'primary' : 'warning'" :loading="loadingHomeY"><v-icon class="mdi mdi-home"></v-icon></v-btn>
|
||||
<v-btn @click="doSend('Y+1')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Y+1</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('Y+10')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Y+10</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('Y+100')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Y+100</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-row>
|
||||
<v-row class="pl-3 pr-3 mt-3 text-center">
|
||||
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
|
||||
<v-btn @click="doSend('Z-25')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Z-25</span></v-btn>
|
||||
<v-btn @click="doSend('Z-1')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Z-1</span></v-btn>
|
||||
<v-btn @click="doSend('Z-0.1')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left>mdi-chevron-left</v-icon><span>Z-0.1</span></v-btn>
|
||||
<v-btn @click="doHomeZ" :color="homedAxes.includes('z') ? 'primary' : 'warning'" :loading="loadingHomeZ"><v-icon class="mdi mdi-home"></v-icon></v-btn>
|
||||
<v-btn @click="doSend('Z+0.1')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Z+0.1</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('Z+1')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Z+1</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
<v-btn @click="doSend('Z+25')" cols="1" class="flex-grow-1 flex-shrink-0"><span>Z+25</span><v-icon right>mdi-chevron-right</v-icon></v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-row>
|
||||
<v-row class="px-3 mt-3">
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn @click="doHome" :loading="loadingHome" :color="homedAxes.includes('xyz') ? 'primary' : 'warning'"><v-icon left>mdi-home</v-icon>Home all</v-btn>
|
||||
<v-btn v-if="config.hasOwnProperty('quad_gantry_level')" @click="doQGL" :loading="loadingQGL" color="primary" class="ml-3">QGL</v-btn>
|
||||
<v-btn @click="doRestart" :loading="loadingRestart" color="error" class="ml-3"><v-icon left>mdi-cached</v-icon>Restart</v-btn>
|
||||
<v-btn @click="doRestartFirmware" :loading="loadingRestartFirmware" color="error" class="ml-3"><v-icon left>mdi-cached</v-icon>Firmware Restart</v-btn>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
loadingHome: state => state.socket.loadingHome,
|
||||
loadingHomeX: state => state.socket.loadingHomeX,
|
||||
loadingHomeY: state => state.socket.loadingHomeY,
|
||||
loadingHomeZ: state => state.socket.loadingHomeZ,
|
||||
loadingQGL: state => state.socket.loadingQGL,
|
||||
loadingRestart: state => state.socket.loadingRestart,
|
||||
loadingRestartFirmware: state => state.socket.loadingRestartFirmware,
|
||||
homedAxes: state => state.printer.toolhead.homed_axes,
|
||||
config: state => state.config,
|
||||
}),
|
||||
...mapMutations([
|
||||
'setLoadingHome',
|
||||
'setLoadingHomeX',
|
||||
'setLoadingHomeY',
|
||||
'setLoadingHomeZ',
|
||||
'setLoadingQGL',
|
||||
'setLoadingRestart',
|
||||
'setLoadingRestartFirmware',
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
doHome() {
|
||||
this.$store.commit('setLoadingHome', true);
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28" }, "responseHome");
|
||||
},
|
||||
doHomeX() {
|
||||
this.$store.commit('setLoadingHomeX', true);
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 X" }, "responseHomeX");
|
||||
},
|
||||
doHomeY() {
|
||||
this.$store.commit('setLoadingHomeY', true);
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 Y" }, "responseHomeY");
|
||||
},
|
||||
doHomeZ() {
|
||||
this.$store.commit('setLoadingHomeZ', true);
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 Z" }, "responseHomeZ");
|
||||
},
|
||||
doQGL() {
|
||||
this.$store.commit('setLoadingQGL', true);
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "quad_gantry_level" }, "responseQGL");
|
||||
},
|
||||
doSend(gcode) {
|
||||
gcode = "G91" + "\n" +
|
||||
"G1 " + gcode + " F6000" + "\n" +
|
||||
"G90";
|
||||
|
||||
this.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode");
|
||||
},
|
||||
doRestart() {
|
||||
this.$store.commit('setLoadingRestart', true);
|
||||
this.$socket.sendObj('post_printer_restart', { }, "responseRestart");
|
||||
},
|
||||
doRestartFirmware() {
|
||||
this.$store.commit('setLoadingRestartFirmware', true);
|
||||
this.$socket.sendObj('post_printer_firmware_restart', { }, "responseRestartFirmware");
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-thermometer-three-quarters</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Macros</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
{{ getMacros.length }} Macros
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<v-card-text class="px-0 pt-0 pb-2 content text-center">
|
||||
<div v-for="(macro, index) in getMacros" v-bind:key="index+99" style="display: inline-block;" class="mx-1 my-1">
|
||||
<v-btn color="primary" class="ml-3" @click="doSend(macro.name)">{{ macro.name }}</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters} from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'getMacros',
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
doSend(gcode) {
|
||||
this.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode");
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
<style>
|
||||
.icon-rotate {
|
||||
animation-name: spin;
|
||||
animation-duration: 1000ms;
|
||||
animation-iteration-count: infinite;
|
||||
animation-timing-function: linear;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
} to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<v-card class="mt-4" v-if="bool_fan">
|
||||
<v-toolbar flat dense >
|
||||
<v-toolbar-title>
|
||||
<span class="subheading"><v-icon :class="fan_speed > 0 ? 'mdi mdi-fan icon-rotate' : 'mdi mdi-fan'" left></v-icon>Tool Fan</span>
|
||||
</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
|
||||
<v-card-text class="pb-0">
|
||||
<tool-slider :target="fan_speed" :multi="100" command="M106" attribute-name="S" :attribute-scale="2.55" ></tool-slider>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card class="mt-4" v-if="is_printing">
|
||||
<v-toolbar flat dense >
|
||||
<v-toolbar-title>
|
||||
<span class="subheading"><v-icon class="mdi mdi-timer" left></v-icon>Speed Factor</span>
|
||||
</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
|
||||
<v-card-text class="pb-0">
|
||||
<tool-slider :target="speed_factor" :max="200" :multi="100" command="M220" attribute-name="S" ></tool-slider>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card class="mt-4" v-if="is_printing">
|
||||
<v-toolbar flat dense >
|
||||
<v-toolbar-title>
|
||||
<span class="subheading"><v-icon class="mdi mdi-texture" left></v-icon>Extrusion Factor</span>
|
||||
</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
|
||||
<v-card-text class="pb-0">
|
||||
<tool-slider :target="extrude_factor" :max="200" :multi="100" command="M221" attribute-name="S" ></tool-slider>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters, mapState} from 'vuex'
|
||||
import ToolSlider from '../../inputs/ToolSlider'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ToolSlider
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
fan_speed: state => state.printer.fan.speed,
|
||||
extrude_factor: state => state.printer.gcode.extrude_factor,
|
||||
speed_factor: state => state.printer.gcode.speed_factor,
|
||||
}),
|
||||
...mapGetters([
|
||||
'bool_fan',
|
||||
'is_printing'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
mounted () {
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -4,11 +4,11 @@
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-info</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Status</v-list-item-title>
|
||||
<v-list-item-subtitle>{{ toolhead !== null && 'status' in toolhead ? toolhead.status : "" }}</v-list-item-subtitle>
|
||||
<v-list-item-subtitle>{{ printer_state }}{{ printer_is_printing ? " - "+current_file : "" }}</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
<v-btn class="orange" v-if="toolhead && toolhead.status === 'Printing'" @click="btnPauseJob" :loading="btnStatusPause">pause job</v-btn>
|
||||
<v-btn class="red" v-if="(toolhead && toolhead.status === 'Ready') && is_paused" :loading="btnStatusCancel" @click="btnCancelJob">cancel job</v-btn>
|
||||
<v-btn class="orange ml-2" v-if="(toolhead && toolhead.status === 'Ready') && is_paused" :loading="btnStatusResume" @click="btnResumeJob">resume job</v-btn>
|
||||
<v-btn class="orange" v-if="printer_state === 'Printing' && printer_is_printing" @click="btnPauseJob" :loading="btnStatusPause">pause job</v-btn>
|
||||
<v-btn class="red" v-if="(is_printing && printer_is_paused)" :loading="btnStatusCancel" @click="btnCancelJob">cancel job</v-btn>
|
||||
<v-btn class="orange ml-2" v-if="(is_printing && printer_is_paused)" :loading="btnStatusResume" @click="btnResumeJob">resume job</v-btn>
|
||||
</v-list-item>
|
||||
<v-divider class="my-2" ></v-divider>
|
||||
<v-card-text class="px-0 pt-0 pb-2 content">
|
||||
@@ -35,31 +35,55 @@
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-divider class="my-2" v-if="(toolhead && toolhead.status === 'Printing') || is_paused"></v-divider>
|
||||
<v-layout wrap class=" text-center" v-if="(toolhead && toolhead.status === 'Printing') || is_paused">
|
||||
<v-divider class="my-2" v-if="is_printing"></v-divider>
|
||||
<v-layout wrap class=" text-center" v-if="is_printing">
|
||||
<v-flex col tag="strong" class="category-header">
|
||||
Printstatus
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">printing</v-flex>
|
||||
<v-flex tag="span">{{ formatTime(toolhead.printing_time) }}</v-flex>
|
||||
<v-flex tag="strong">Filament used</v-flex>
|
||||
<v-flex tag="span">{{ filament_used.toFixed(2) }}mm</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">estimated</v-flex>
|
||||
<v-flex tag="strong">Print Time</v-flex>
|
||||
<v-flex tag="span">{{ formatTime(print_time) }}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">total</v-flex>
|
||||
<v-flex tag="span">{{ formatTime(print_time + toolhead.printing_time) }}</v-flex>
|
||||
<v-flex tag="strong">Total Time</v-flex>
|
||||
<v-flex tag="span">{{ formatTime(print_time_total) }}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout wrap class=" text-center" v-if="(toolhead && toolhead.status === 'Printing') || is_paused">
|
||||
<v-divider class="my-2" v-if="is_printing"></v-divider>
|
||||
<v-layout wrap class=" text-center" v-if="is_printing">
|
||||
<v-flex col tag="strong" class="category-header py-0">
|
||||
Estimations<br />based on
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">Time</v-flex>
|
||||
<v-flex tag="span">{{ print_time > 0 && printProgress > 0 ? formatTime(print_time / printProgress - print_time) : '--' }}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">File Progress</v-flex>
|
||||
<v-flex tag="span">{{ print_time > 0 && file_position > 0 ? formatTime(print_time / (file_position / current_file_size) - print_time) : '--' }}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">Slicer</v-flex>
|
||||
<v-flex tag="span"><i>coming soon</i></v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout wrap class=" text-center" v-if="is_printing">
|
||||
<v-layout column class="mt-2" >
|
||||
<v-progress-linear
|
||||
:value="printProgress * 100"
|
||||
@@ -76,23 +100,39 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
progress: 0.15
|
||||
|
||||
|
||||
}),
|
||||
computed: {
|
||||
...mapState({
|
||||
toolhead: state => state.printer.toolhead,
|
||||
position: state => state.printer.toolhead.position,
|
||||
is_paused: state => state.printer.pause_resume.is_paused,
|
||||
btnStatusPause: state => state.socket.loadingPrintPause,
|
||||
btnStatusResume: state => state.socket.loadingPrintResume,
|
||||
btnStatusCancel: state => state.socket.loadingPrintCancel,
|
||||
|
||||
estimated_print_time: state => state.printer.toolhead.estimated_print_time,
|
||||
|
||||
printProgress: state => state.printer.virtual_sdcard.progress,
|
||||
print_time: state => state.printer.idle_timeout.printing_time,
|
||||
print_time: state => state.printer.virtual_sdcard.print_duration,
|
||||
print_time_total: state => state.printer.virtual_sdcard.total_duration,
|
||||
filament_used: state => state.printer.virtual_sdcard.filament_used,
|
||||
file_position: state => state.printer.virtual_sdcard.file_position,
|
||||
current_file: state => state.printer.virtual_sdcard.current_file,
|
||||
printer_state: state => state.printer.idle_timeout.state,
|
||||
printer_is_paused: state => state.printer.pause_resume.is_paused,
|
||||
printer_is_printing: state => state.printer.virtual_sdcard.is_active,
|
||||
}),
|
||||
|
||||
...mapGetters([
|
||||
'current_file_size',
|
||||
'current_file_metadata',
|
||||
'is_printing',
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
btnPauseJob() {
|
||||
@@ -112,7 +152,7 @@
|
||||
date.setSeconds(seconds);
|
||||
|
||||
return date.toISOString().substr(11,8);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
<style>
|
||||
#line-chart {
|
||||
height: 250px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-thermometer-three-quarters</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Temperature Chart</v-list-item-title>
|
||||
<v-list-item-subtitle>{{ heatersCount }} heaters</v-list-item-subtitle>
|
||||
<v-list-item-subtitle>
|
||||
<span>{{ heatersCount }} heaters</span>
|
||||
<span v-if="temperature_fans.length === 1">, {{ temperature_fans.length }} fan</span>
|
||||
<span v-if="temperature_fans.length > 1">, {{ temperature_fans.length }} fans</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
@@ -16,7 +26,7 @@
|
||||
|
||||
<script>
|
||||
import LineChart from '../../charts/LineChart.js'
|
||||
import {mapGetters, mapState} from 'vuex'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -37,7 +47,8 @@
|
||||
datasets: state => state.temperaturChart.datasets,
|
||||
}),
|
||||
...mapGetters([
|
||||
'heatersCount'
|
||||
'heatersCount',
|
||||
'temperature_fans'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-thermometer-three-quarters</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Heaters</v-list-item-title>
|
||||
<v-list-item-subtitle>{{ heatersCount }} heaters</v-list-item-subtitle>
|
||||
<v-list-item-subtitle>
|
||||
{{ heatersCount }} heaters
|
||||
<span v-if="temperature_fans.length === 1">, {{ temperature_fans.length }} fan</span>
|
||||
<span v-if="temperature_fans.length > 1">, {{ temperature_fans.length }} fans</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
@@ -29,7 +33,20 @@
|
||||
</v-col>
|
||||
<v-col class="text-center py-0 vertical_align_center"><span>{{ heater.temperature.toFixed(1) }}°C</span></v-col>
|
||||
<v-col class="text-center py-0 vertical_align_center">
|
||||
<toolInput :name="heater.name" :target="heater.target" ></toolInput>
|
||||
<toolInput :name="heater.name" :target="heater.target" command="SET_HEATER_TEMPERATURE" attribute-name="HEATER" ></toolInput>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
<div v-for="(fan, index) in temperature_fans" v-bind:key="index+99" >
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<v-row class="pl-3 pr-3 heater-row">
|
||||
<v-col class="text-center py-0">
|
||||
<b>{{ fan.name }}</b><br />
|
||||
<small>{{ fan.target > 0 && fan.speed > 0 ? (fan.speed * 100).toFixed(0)+"%" : (fan.target > 0 ? "standby" : "off") }}</small>
|
||||
</v-col>
|
||||
<v-col class="text-center py-0 vertical_align_center"><span>{{ fan.temperature.toFixed(1) }}°C</span></v-col>
|
||||
<v-col class="text-center py-0 vertical_align_center">
|
||||
<toolInput :name="fan.name" :target="fan.target" command="SET_TEMPERATURE_FAN_TARGET" attribute-name="temperature_fan" ></toolInput>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
@@ -41,7 +58,6 @@
|
||||
import { mapGetters } from 'vuex'
|
||||
import toolInput from '../../inputs/ToolInput'
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
toolInput
|
||||
@@ -54,7 +70,8 @@
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'heaters',
|
||||
'heatersCount'
|
||||
'heatersCount',
|
||||
'temperature_fans'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -3,10 +3,16 @@ import Vue from 'vue'
|
||||
import StatusPanel from './StatusPanel.vue'
|
||||
import ToolsPanel from './ToolsPanel.vue'
|
||||
import TempchartPanel from './TempchartPanel.vue'
|
||||
import ControlPanel from "./ControlPanel";
|
||||
import Peripherie from "./PeripheriePanel";
|
||||
import MacrosPanel from "./MacrosPanel";
|
||||
|
||||
Vue.component('status-panel', StatusPanel);
|
||||
Vue.component('tools-panel', ToolsPanel);
|
||||
Vue.component('tempchart-panel', TempchartPanel);
|
||||
Vue.component('control-panel', ControlPanel);
|
||||
Vue.component('peripherie-panel', Peripherie);
|
||||
Vue.component('macros-panel', MacrosPanel);
|
||||
|
||||
export default {
|
||||
StatusPanel,
|
||||
|
||||
@@ -25,13 +25,15 @@
|
||||
props: {
|
||||
name: String,
|
||||
target: Number,
|
||||
command: String,
|
||||
attributeName: String,
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
setTemps() {
|
||||
this.$socket.sendObj('post_printer_gcode', {script: 'SET_HEATER_TEMPERATURE HEATER='+this.name+' TARGET='+this.value});
|
||||
this.$socket.sendObj('post_printer_gcode', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<v-row>
|
||||
<v-col class="col-auto"><v-icon @click="decrement">mdi-minus</v-icon></v-col>
|
||||
<v-col class="col"><v-slider v-model="value" thumb-label="always" :min="min" :max="max" @change="sendCmd" hide-details></v-slider></v-col>
|
||||
<v-col class="col-auto"><v-icon @click="increment">mdi-plus</v-icon></v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: function() {
|
||||
return {
|
||||
value: this.target * this.multi
|
||||
}
|
||||
},
|
||||
props: {
|
||||
target: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
command: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
attributeName: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
attributeScale: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 1
|
||||
},
|
||||
min: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0
|
||||
},
|
||||
max: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 100
|
||||
},
|
||||
multi: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 1
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
sendCmd() {
|
||||
this.$socket.sendObj('post_printer_gcode', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) });
|
||||
},
|
||||
decrement() {
|
||||
this.value--;
|
||||
this.sendCmd();
|
||||
},
|
||||
increment() {
|
||||
this.value++;
|
||||
this.sendCmd();
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
target: function() {
|
||||
this.value = this.target * this.multi;
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
+7
-1
@@ -8,9 +8,13 @@ import store from './store'
|
||||
import router from './plugins/router'
|
||||
import { hostname } from './store/variables'
|
||||
import 'vue-toast-notification/dist/index.css';
|
||||
import vueHeadful from 'vue-headful';
|
||||
|
||||
Vue.use(JRPCWS, 'ws://' + hostname + '/websocket', {
|
||||
store: store
|
||||
store: store,
|
||||
reconnectEnabled: true,
|
||||
reconnectInterval: 3000,
|
||||
recconectAttempts: 1000,
|
||||
});
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
@@ -22,6 +26,8 @@ Vue.http.headers.common['Accept'] = 'application/json, text/plain, */*';
|
||||
Vue.http.headers.common['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, Authorization, Access-Control-Allow-Origin';
|
||||
Vue.http.headers.common['Access-Control-Allow-Methods'] = 'POST, GET, PUT, OPTIONS, DELETE, OPTIONS';
|
||||
|
||||
Vue.component('vue-headful', vueHeadful);
|
||||
|
||||
new Vue({
|
||||
vuetify,
|
||||
router,
|
||||
|
||||
+45
-4
@@ -28,13 +28,25 @@
|
||||
<div>
|
||||
<v-row>
|
||||
<v-col class="col">
|
||||
<v-text-field
|
||||
<v-combobox
|
||||
v-model="gcode"
|
||||
:items="items"
|
||||
label="Send code..."
|
||||
solo
|
||||
class="gcode-command-field"
|
||||
v-on:keyup.enter="doSend"
|
||||
v-on:keyup.up="onKeyUp"
|
||||
v-on:keyup.down="onKeyDown"
|
||||
></v-combobox>
|
||||
<!--<v-text-field
|
||||
v-model="gcode"
|
||||
label="Send code..."
|
||||
solo
|
||||
class="gcode-command-field"
|
||||
v-on:keyup.enter="doSend"
|
||||
></v-text-field>
|
||||
v-on:keyup.up="onKeyUp"
|
||||
v-on:keyup.down="onKeyDown"
|
||||
></v-text-field>-->
|
||||
</v-col>
|
||||
|
||||
<v-col class="col-auto align-content-center">
|
||||
@@ -76,7 +88,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
data () {
|
||||
@@ -99,13 +111,21 @@
|
||||
],
|
||||
options: {
|
||||
|
||||
}
|
||||
},
|
||||
lastCommands: [
|
||||
|
||||
],
|
||||
lastCommandNumber: null,
|
||||
items: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
events: state => state.events,
|
||||
}),
|
||||
...mapGetters([
|
||||
'getMacros'
|
||||
]),
|
||||
loadingSendGcode: {
|
||||
get() {
|
||||
return this.$store.state.socket.loadingSendGcode
|
||||
@@ -119,11 +139,32 @@
|
||||
doSend() {
|
||||
this.loadingSendGcode = true;
|
||||
this.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode");
|
||||
this.lastCommands.push(this.gcode);
|
||||
this.gcode = "";
|
||||
this.lastCommandNumber = null;
|
||||
},
|
||||
formatMessage(message) {
|
||||
message = message.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
||||
|
||||
return message;
|
||||
},
|
||||
onKeyUp() {
|
||||
if (this.lastCommandNumber === null && this.lastCommands.length) {
|
||||
this.lastCommandNumber = this.lastCommands.length - 1;
|
||||
this.gcode = this.lastCommands[this.lastCommandNumber];
|
||||
} else if (this.lastCommandNumber > 0) {
|
||||
this.lastCommandNumber--;
|
||||
this.gcode = this.lastCommands[this.lastCommandNumber];
|
||||
}
|
||||
},
|
||||
onKeyDown() {
|
||||
if (this.lastCommandNumber !== null && this.lastCommandNumber < (this.lastCommands.length - 1)) {
|
||||
this.lastCommandNumber++;
|
||||
this.gcode = this.lastCommands[this.lastCommandNumber];
|
||||
} else if (this.lastCommandNumber !== null && this.lastCommandNumber === (this.lastCommands.length - 1)) {
|
||||
this.lastCommandNumber = null;
|
||||
this.gcode = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<v-row>
|
||||
<v-col xs12 sm6 md4>
|
||||
<v-col class="col-sm-12 col-md-7">
|
||||
<status-panel></status-panel>
|
||||
<div class="mt-6">
|
||||
<tools-panel></tools-panel>
|
||||
</div>
|
||||
<control-panel class="mt-6"></control-panel>
|
||||
<macros-panel class="mt-6"></macros-panel>
|
||||
</v-col>
|
||||
<v-col xs12 sm6 md8>
|
||||
<tempchart-panel></tempchart-panel>
|
||||
<v-col class="col-sm-12 col-md-5">
|
||||
<tools-panel></tools-panel>
|
||||
<tempchart-panel class="mt-6"></tempchart-panel>
|
||||
<peripherie-panel></peripherie-panel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
+130
-28
@@ -10,21 +10,53 @@
|
||||
.v-data-table .file-list-cursor:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fileupload-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dragzone {
|
||||
display: table;
|
||||
position: absolute;
|
||||
top: 0; left: 0;
|
||||
width: 100%; height: 100%;
|
||||
z-index: 9999999999;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
transition: visibility 175ms, opacity 175ms;
|
||||
font: bold 42px Oswald, DejaVu Sans, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
.dragzone:before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
top: 15px; right: 15px; bottom: 15px; left: 15px;
|
||||
border: 3px dashed white;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.dragzone .textnode {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
transition: font-size 175ms;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<v-card>
|
||||
<v-card class="fileupload-card" @dragover="dragOver" @dragleave="dragLeave" @drop.prevent.stop="dragDrop">
|
||||
<v-card-title>
|
||||
G-Code Files
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn :loading="loadingRefresh" @click="refreshFileList"><v-icon class="mr-1">mdi-refresh</v-icon> Refresh</v-btn>
|
||||
<input type="file" ref="fileUpload" style="display: none" @change="uploadFile" />
|
||||
<v-btn color="primary ml-4 " v-if="printStatus == 'Ready'" :loading="loadingUpload" @click="clickUploadButton"><v-icon>mdi-upload</v-icon>Upload</v-btn>
|
||||
<v-btn color="primary ml-4 " v-if="!is_printing" :loading="loadingUpload" @click="clickUploadButton"><v-icon>mdi-upload</v-icon>Upload</v-btn>
|
||||
</v-card-title>
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:options="options"
|
||||
:custom-sort="sort"
|
||||
:sort-by.sync="sortBy"
|
||||
:sort-desc.sync="sortDesc"
|
||||
:items="files"
|
||||
@@ -49,6 +81,9 @@
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
<div class="dragzone" :style="'visibility: '+dropzone.visibility+'; opacity: '+dropzone.hidden">
|
||||
<div class="textnode">Drop files to add gcode.</div>
|
||||
</div>
|
||||
</v-card>
|
||||
<v-menu v-model="contextMenu.shown" :position-x="contextMenu.x" :position-y="contextMenu.y" absolute offset-y>
|
||||
<v-list>
|
||||
@@ -74,7 +109,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
import axios from 'axios';
|
||||
import { hostname } from '../store/variables';
|
||||
|
||||
@@ -114,6 +149,10 @@
|
||||
item: {}
|
||||
},
|
||||
hostname: hostname,
|
||||
dropzone: {
|
||||
visibility: 'hidden',
|
||||
opacity: 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -121,36 +160,40 @@
|
||||
files: state => state.files,
|
||||
loadingUpload: state => state.socket.loadingGcodeUpload,
|
||||
loadingRefresh: state => state.socket.loadingGcodeRefresh,
|
||||
printStatus: state => state.printer.toolhead.status,
|
||||
})
|
||||
}),
|
||||
...mapGetters([
|
||||
'is_printing'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
uploadFile: function() {
|
||||
if (this.$refs.fileUpload.files.length) {
|
||||
let toast = this.$toast;
|
||||
let file = this.$refs.fileUpload.files[0];
|
||||
let formData = new FormData();
|
||||
formData.append('file', file);
|
||||
this.$store.commit('setLoadingGcodeUpload', true);
|
||||
|
||||
axios.post('http://' + hostname + '/printer/files/upload',
|
||||
formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
}
|
||||
).then((result) => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.success("Upload of "+result.data.result+" successful!", {
|
||||
icon: 'fa-check'
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.error("Cannot upload the file!", {
|
||||
icon: 'fa-exclamation-triangle'
|
||||
});
|
||||
});
|
||||
this.doUploadFile(this.$refs.fileUpload.files[0]);
|
||||
}
|
||||
},
|
||||
doUploadFile: function(file) {
|
||||
let toast = this.$toast;
|
||||
let formData = new FormData();
|
||||
formData.append('file', file);
|
||||
this.$store.commit('setLoadingGcodeUpload', true);
|
||||
|
||||
axios.post('http://' + hostname + '/printer/files/upload',
|
||||
formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
}
|
||||
).then((result) => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.success("Upload of "+result.data.result+" successful!", {
|
||||
icon: 'fa-check'
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.error("Cannot upload the file!", {
|
||||
icon: 'fa-exclamation-triangle'
|
||||
});
|
||||
});
|
||||
},
|
||||
clickUploadButton: function() {
|
||||
this.$refs.fileUpload.click();
|
||||
},
|
||||
@@ -207,7 +250,66 @@
|
||||
startPrint(filename = "") {
|
||||
this.dialog.show = false;
|
||||
this.$socket.sendObj('post_printer_print_start', { filename: filename }, 'switchToDashboard');
|
||||
}
|
||||
},
|
||||
dragOver(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.dropzone.visibility = 'visible';
|
||||
this.dropzone.opacity = 1;
|
||||
},
|
||||
dragLeave(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.dropzone.visibility = 'hidden';
|
||||
this.dropzone.opacity = 0;
|
||||
},
|
||||
async dragDrop(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.dropzone.visibility = 'hidden';
|
||||
this.dropzone.opacity = 0;
|
||||
|
||||
if (!this.is_printing && e.dataTransfer.files.length) {
|
||||
await this.doUploadFile(e.dataTransfer.files[0]);
|
||||
}
|
||||
},
|
||||
sort(items, sortBy, sortDesc) {
|
||||
sortBy = sortBy.length ? sortBy[0] : 'name';
|
||||
sortDesc = sortDesc[0];
|
||||
|
||||
// Sort by index
|
||||
items.sort(function(a, b) {
|
||||
if (a[sortBy] === b[sortBy]) {
|
||||
return 0;
|
||||
}
|
||||
if (a[sortBy] === null || a[sortBy] === undefined) {
|
||||
return -1;
|
||||
}
|
||||
if (b[sortBy] === null || b[sortBy] === undefined) {
|
||||
return 1;
|
||||
}
|
||||
if (a[sortBy].constructor === String && b[sortBy].constructor === String) {
|
||||
return a[sortBy].localeCompare(b[sortBy], undefined, { sensivity: 'base' });
|
||||
}
|
||||
if (a[sortBy] instanceof Array && b[sortBy] instanceof Array) {
|
||||
const reducedA = a[sortBy].length ? a.filament.reduce((a, b) => a + b) : 0;
|
||||
const reducedB = b[sortBy].length ? b.filament.reduce((a, b) => a + b) : 0;
|
||||
return reducedA - reducedB;
|
||||
}
|
||||
return a[sortBy] - b[sortBy];
|
||||
});
|
||||
|
||||
// Deal with descending order
|
||||
if (sortDesc) {
|
||||
items.reverse();
|
||||
}
|
||||
|
||||
// Then make sure directories come first
|
||||
items.sort((a, b) => (a.isDirectory === b.isDirectory) ? 0 : (a.isDirectory ? -1 : 1));
|
||||
return items;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,151 @@
|
||||
import router from "../plugins/router";
|
||||
|
||||
|
||||
export default {
|
||||
socket_on_open ({ commit }) {
|
||||
commit('setConnected');
|
||||
window.console.log('Socket connected');
|
||||
},
|
||||
|
||||
socket_on_close ({ commit }, event) {
|
||||
commit('setDisconnected')
|
||||
if (event.wasClean) {
|
||||
window.console.log('Socket closed clear')
|
||||
} else {
|
||||
window.console.error('Connection failure')
|
||||
}
|
||||
window.console.error('Code: ' + event.code)
|
||||
},
|
||||
|
||||
socket_on_error ({ commit }, data) {
|
||||
commit('reportError', data);
|
||||
},
|
||||
|
||||
socket_on_message ({ commit, state }, data) {
|
||||
if (!state.socket.isConnected) commit('setConnected');
|
||||
switch(data.method) {
|
||||
case 'notify_status_update':
|
||||
commit('setPrinterData', data.params[0]);
|
||||
break;
|
||||
|
||||
case 'notify_gcode_response':
|
||||
commit('addGcodeResponse', data.params[0]);
|
||||
break;
|
||||
|
||||
case 'notify_printer_state_changed':
|
||||
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;
|
||||
|
||||
case 'notify_paused_state_changed':
|
||||
commit('setPausedState', data.params[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (data.result !== "ok") {
|
||||
window.console.log("Default return");
|
||||
if (data.error) window.console.error("JSON-RPC: " + data.error.message);
|
||||
else window.console.log(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
socket_reconnect ({ commit }, count) {
|
||||
commit('setConnected');
|
||||
window.console.log(count)
|
||||
},
|
||||
|
||||
socket_reconnect_error ({ commit }) {
|
||||
commit('setDisconnected');
|
||||
window.console.error('Socket disconnected')
|
||||
},
|
||||
|
||||
getKlipperInfo({ commit }, data) {
|
||||
commit('setPrinterData', {
|
||||
hostname: data.hostname,
|
||||
version: data.version
|
||||
});
|
||||
},
|
||||
|
||||
getObjectInfo({ commit }, data) {
|
||||
commit('setObjectData', data);
|
||||
},
|
||||
|
||||
getPrinterConfig({commit}, data) {
|
||||
commit('setPrinterConfig', data);
|
||||
},
|
||||
|
||||
addSubscription(state, data) {
|
||||
window.console.log(state);
|
||||
window.console.log(data);
|
||||
},
|
||||
|
||||
getFileList({ commit }, data) {
|
||||
commit('setFileList', data);
|
||||
commit('setLoadingGcodeRefresh', false);
|
||||
},
|
||||
|
||||
setLoadingSendGcode({commit}, value) {
|
||||
commit('setLoadingSendGcode', value);
|
||||
},
|
||||
|
||||
setLoadingEmergencyStop({commit}) {
|
||||
commit('setLoadingEmergencyStop', false);
|
||||
},
|
||||
|
||||
setLoadingPrintPause({commit}) {
|
||||
commit('setLoadingPrintPause', false);
|
||||
},
|
||||
|
||||
setLoadingPrintResume({commit}) {
|
||||
commit('setLoadingPrintResume', false);
|
||||
},
|
||||
|
||||
setLoadingPrintCancel({commit}) {
|
||||
commit('setLoadingPrintCancel', false);
|
||||
},
|
||||
|
||||
sendGcode({commit}, data) {
|
||||
commit('setLoadingSendGcode', false);
|
||||
commit('sendGcode', data);
|
||||
},
|
||||
|
||||
responseHome({commit}) {
|
||||
commit('setLoadingHome', false);
|
||||
},
|
||||
|
||||
responseHomeX({commit}) {
|
||||
commit('setLoadingHomeX', false);
|
||||
},
|
||||
|
||||
responseHomeY({commit}) {
|
||||
commit('setLoadingHomeY', false);
|
||||
},
|
||||
|
||||
responseHomeZ({commit}) {
|
||||
commit('setLoadingHomeZ', false);
|
||||
},
|
||||
|
||||
responseQGL({commit}) {
|
||||
commit('setLoadingQGL', false);
|
||||
},
|
||||
|
||||
responseRestart({commit}) {
|
||||
commit('setLoadingRestart', false);
|
||||
},
|
||||
|
||||
responseRestartFirmware({commit}) {
|
||||
commit('setLoadingRestartFirmware', false);
|
||||
},
|
||||
|
||||
switchToDashboard() {
|
||||
router.push("/");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
export default {
|
||||
toolhead(state) {
|
||||
return (state.socket.isConnected) ? state.printer.toolhead : null;
|
||||
},
|
||||
|
||||
heaters: state => {
|
||||
let heaters = [];
|
||||
|
||||
if (state.object.heater.available_heaters) {
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
if (state.object.heater.available_heaters.includes(key)) {
|
||||
heaters.push({
|
||||
name: key,
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return heaters.sort((a, b) => {
|
||||
let nameA = a.name.toUpperCase();
|
||||
let nameB = b.name.toUpperCase();
|
||||
|
||||
if (nameA < nameB) return -1;
|
||||
if (nameA > nameB) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
|
||||
heatersCount: (state, getters) => {
|
||||
return getters.heaters.length;
|
||||
},
|
||||
|
||||
temperature_fans: state => {
|
||||
let fans = [];
|
||||
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit[0] === "temperature_fan") {
|
||||
fans.push({
|
||||
name: nameSplit[1],
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
speed: value.speed,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return fans.sort((a, b) => {
|
||||
let nameA = a.name.toUpperCase();
|
||||
let nameB = b.name.toUpperCase();
|
||||
|
||||
if (nameA < nameB) return -1;
|
||||
if (nameA > nameB) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
|
||||
current_file_size: state => {
|
||||
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
|
||||
|
||||
if (file.length) return file[0]['size'];
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
current_file_metadata: state => {
|
||||
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
|
||||
|
||||
if (file.length) return file[0];
|
||||
|
||||
return []
|
||||
},
|
||||
|
||||
bool_fan: state => {
|
||||
return Object.entries(state.object).indexOf('fan');
|
||||
},
|
||||
|
||||
is_printing: state => {
|
||||
return (state.printer.virtual_sdcard.current_file !== "");
|
||||
},
|
||||
|
||||
getMacros: state => {
|
||||
let array = [];
|
||||
|
||||
for (let prop in state.config) {
|
||||
if (prop.startsWith('gcode_macro') && !state.config[prop].hasOwnProperty('rename_existing')) {
|
||||
array.push({
|
||||
'name': prop.replace('gcode_macro ', ''),
|
||||
'prop': state.config[prop]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
},
|
||||
|
||||
getTitle: state => {
|
||||
if (state.socket.isConnected) {
|
||||
if (state.printer.pause_resume.is_paused) return "Pause Print";
|
||||
else if (state.printer.virtual_sdcard.is_active) return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.virtual_sdcard.current_file;
|
||||
|
||||
return state.printer.hostname;
|
||||
} else return "KlipperWebControl";
|
||||
}
|
||||
}
|
||||
+33
-322
@@ -1,26 +1,13 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import VueToast from 'vue-toast-notification';
|
||||
import router from '../plugins/router'
|
||||
import actions from './actions'
|
||||
import mutations from './mutations'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex);
|
||||
Vue.use(VueToast);
|
||||
|
||||
let colorArray = [
|
||||
'#F44336',
|
||||
'#E91E63',
|
||||
'#9C27B0',
|
||||
'#673AB7',
|
||||
'#3F51B5',
|
||||
'#00BCD4',
|
||||
'#009688',
|
||||
];
|
||||
|
||||
const colorHeaterBed = '#2196F3';
|
||||
const colorChamber = '#4CAF50';
|
||||
const temperaturChartSampleInterval = 1000;
|
||||
const temperaturChartSampleLength = 600;
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
socket: {
|
||||
@@ -30,12 +17,20 @@ export default new Vuex.Store({
|
||||
loadingEmergencyStop: false,
|
||||
loadingPrintPause: false,
|
||||
loadingPrintResume: false,
|
||||
loadingHome: false,
|
||||
loadingHomeX: false,
|
||||
loadingHomeY: false,
|
||||
loadingHomeZ: false,
|
||||
loadingQGL: false,
|
||||
loadingRestart: false,
|
||||
loadingRestartFirmware: false,
|
||||
},
|
||||
printer: {
|
||||
hostname: '',
|
||||
version: '',
|
||||
toolhead: {
|
||||
position: [],
|
||||
homed_axes: [],
|
||||
status: "",
|
||||
print_time: 0,
|
||||
printing_time: 0,
|
||||
@@ -45,16 +40,33 @@ export default new Vuex.Store({
|
||||
is_paused: false
|
||||
},
|
||||
idle_timeout: {
|
||||
printing_time: 0
|
||||
printing_time: 0,
|
||||
state: "",
|
||||
},
|
||||
virtual_sdcard: {
|
||||
process: 0
|
||||
progress: 0,
|
||||
current_file: "",
|
||||
is_active: false,
|
||||
filament_used: 0,
|
||||
file_position: 0,
|
||||
print_duration: 0,
|
||||
total_duration: 0,
|
||||
},
|
||||
gcode: {
|
||||
extrude_factor: 1,
|
||||
speed_factor: 1,
|
||||
},
|
||||
fan: {
|
||||
speed: 0,
|
||||
}
|
||||
},
|
||||
object: {
|
||||
heater: {
|
||||
available_heaters: []
|
||||
}
|
||||
},
|
||||
config: {
|
||||
|
||||
},
|
||||
temperaturChart: {
|
||||
labels: [],
|
||||
@@ -64,308 +76,7 @@ export default new Vuex.Store({
|
||||
events: []
|
||||
},
|
||||
|
||||
getters: {
|
||||
toolhead(state) {
|
||||
return (state.socket.isConnected) ? state.printer.toolhead : null;
|
||||
},
|
||||
|
||||
heaters: state => {
|
||||
let heaters = [];
|
||||
|
||||
if (state.object.heater.available_heaters) {
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
if (state.object.heater.available_heaters.includes(key)) {
|
||||
heaters.push({
|
||||
name: key,
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return heaters.sort((a, b) => {
|
||||
let nameA = a.name.toUpperCase();
|
||||
let nameB = b.name.toUpperCase();
|
||||
|
||||
if (nameA < nameB) return -1;
|
||||
if (nameA > nameB) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
|
||||
heatersCount: (state, getters) => {
|
||||
return getters.heaters.length;
|
||||
}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
setConnected (state) {
|
||||
state.socket.isConnected = true;
|
||||
},
|
||||
|
||||
setDisconnected (state) {
|
||||
state.socket.isConnected = false
|
||||
},
|
||||
|
||||
setPrinterData(state, data) {
|
||||
Object.assign(state.printer, data);
|
||||
|
||||
if (state.object.heater.available_heaters.length) {
|
||||
let boolAddValues = false;
|
||||
let now = new Date();
|
||||
|
||||
if (state.temperaturChart.labels.length === 0 || now - state.temperaturChart.labels[state.temperaturChart.labels.length - 1] > temperaturChartSampleInterval) {
|
||||
for (let [key, value] of Object.entries(data)) {
|
||||
if (state.object.heater.available_heaters.includes(key)) {
|
||||
let index = state.temperaturChart.datasets.findIndex(element => element.label === key);
|
||||
|
||||
if (index >= 0) state.temperaturChart.datasets[index].data.push(value.temperature.toFixed(1));
|
||||
else {
|
||||
let color = '#f87979';
|
||||
|
||||
switch (key) {
|
||||
case 'heater_bed': color = colorHeaterBed; break;
|
||||
case 'chamber': color = colorChamber; break;
|
||||
default: color = colorArray[state.temperaturChart.datasets.length]; break;
|
||||
}
|
||||
|
||||
state.temperaturChart.datasets.push({
|
||||
label: key,
|
||||
data: [value.temperature.toFixed(1)],
|
||||
borderColor: color,
|
||||
backgroundColor: color,
|
||||
fill: false,
|
||||
borderDash: undefined,
|
||||
borderWidth: 2,
|
||||
pointRadius: 0,
|
||||
pointHitRadius: 0,
|
||||
showLine: true
|
||||
});
|
||||
}
|
||||
|
||||
boolAddValues = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (boolAddValues) {
|
||||
state.temperaturChart.labels.push(now);
|
||||
|
||||
if (state.temperaturChart.labels.length > temperaturChartSampleLength) {
|
||||
state.temperaturChart.labels.splice(0, state.temperaturChart.labels.length-temperaturChartSampleLength)
|
||||
}
|
||||
}
|
||||
|
||||
for (let [key, dataset] of Object.entries(state.temperaturChart.datasets)) {
|
||||
if (dataset.data.length > temperaturChartSampleLength) {
|
||||
state.temperaturChart.datasets[key].data.splice(0, dataset.data.length-temperaturChartSampleLength)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setObjectData(state, data) {
|
||||
Object.assign(state.object, data);
|
||||
},
|
||||
|
||||
setFileList(state, data) {
|
||||
state.files = data;
|
||||
},
|
||||
|
||||
addGcodeResponse(state, data) {
|
||||
state.events.push({
|
||||
date: new Date(),
|
||||
message: data
|
||||
});
|
||||
|
||||
if (data.substring(0,2) === "//") {
|
||||
data = data.replace("//", "");
|
||||
Vue.$toast.warning(data);
|
||||
} else if (data.substring(0,2) === "!!") {
|
||||
data = data.replace("!!", "");
|
||||
Vue.$toast.error(data);
|
||||
}
|
||||
},
|
||||
|
||||
setLoadingSendGcode(state, value) {
|
||||
state.socket.loadingSendGcode = value;
|
||||
},
|
||||
|
||||
sendGcode(state) {
|
||||
state.socket.loadingSendGcode = false;
|
||||
},
|
||||
|
||||
setPrinterStatus(state, value) {
|
||||
state.printer.toolhead.status = value;
|
||||
},
|
||||
|
||||
setLoadingGcodeUpload(state, value) {
|
||||
state.socket.loadingGcodeUpload = value;
|
||||
},
|
||||
|
||||
setLoadingGcodeRefresh(state, value) {
|
||||
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;
|
||||
},
|
||||
|
||||
setLoadingPrintCancel(state, value) {
|
||||
state.socket.loadingPrintCancel = value;
|
||||
},
|
||||
|
||||
reportError(state, data) {
|
||||
Vue.$toast.error(data.message);
|
||||
},
|
||||
|
||||
setPausedState(state, data) {
|
||||
switch (data) {
|
||||
case 'paused':
|
||||
state.printer.pause_resume.is_paused = true;
|
||||
break;
|
||||
|
||||
case 'resumed':
|
||||
state.printer.pause_resume.is_paused = false;
|
||||
break;
|
||||
|
||||
case 'cleared':
|
||||
state.printer.pause_resume.is_paused = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
window.console.log('setPausedState -> Default: '+data);
|
||||
}
|
||||
},
|
||||
|
||||
voidMutation() {
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
socket_on_open ({ commit }) {
|
||||
commit('setConnected');
|
||||
window.console.log('Socket connected');
|
||||
},
|
||||
|
||||
socket_on_close ({ commit }, event) {
|
||||
commit('setDisconnected')
|
||||
if (event.wasClean) {
|
||||
window.console.log('Socket closed clear')
|
||||
} else {
|
||||
window.console.error('Connection failure')
|
||||
}
|
||||
window.console.error('Code: ' + event.code)
|
||||
},
|
||||
|
||||
socket_on_error ({ commit }, data) {
|
||||
commit('reportError', data);
|
||||
},
|
||||
|
||||
socket_on_message ({ commit, state }, data) {
|
||||
if (!state.socket.isConnected) commit('setConnected');
|
||||
switch(data.method) {
|
||||
case 'notify_status_update':
|
||||
commit('setPrinterData', data.params[0]);
|
||||
break;
|
||||
|
||||
case 'notify_gcode_response':
|
||||
commit('addGcodeResponse', data.params[0]);
|
||||
break;
|
||||
|
||||
case 'notify_printer_state_changed':
|
||||
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;
|
||||
|
||||
case 'notify_paused_state_changed':
|
||||
commit('setPausedState', data.params[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
window.console.log("Default return");
|
||||
if (data.error) window.console.error("JSON-RPC: " + data.error.message);
|
||||
else window.console.log(data);
|
||||
}
|
||||
},
|
||||
|
||||
socket_reconnect ({ commit }, count) {
|
||||
commit('setConnected');
|
||||
window.console.log(count)
|
||||
},
|
||||
|
||||
socket_reconnect_error ({ commit }) {
|
||||
commit('setDisconnected');
|
||||
window.console.error('Socket disconnected')
|
||||
},
|
||||
|
||||
getKlipperInfo({ commit }, data) {
|
||||
commit('setPrinterData', {
|
||||
hostname: data.hostname,
|
||||
version: data.version
|
||||
});
|
||||
},
|
||||
|
||||
getObjectInfo({ commit }, data) {
|
||||
commit('setObjectData', data);
|
||||
},
|
||||
|
||||
addSubscription(state, data) {
|
||||
window.console.log(state);
|
||||
window.console.log(data);
|
||||
},
|
||||
|
||||
getFileList({ commit }, data) {
|
||||
commit('setFileList', data);
|
||||
commit('setLoadingGcodeRefresh', false);
|
||||
},
|
||||
|
||||
setLoadingSendGcode({commit}, value) {
|
||||
commit('setLoadingSendGcode', value);
|
||||
},
|
||||
|
||||
setLoadingEmergencyStop({commit}) {
|
||||
commit('setLoadingEmergencyStop', false);
|
||||
},
|
||||
|
||||
setLoadingPrintPause({commit}) {
|
||||
commit('setLoadingPrintPause', false);
|
||||
},
|
||||
|
||||
setLoadingPrintResume({commit}) {
|
||||
commit('setLoadingPrintResume', false);
|
||||
},
|
||||
|
||||
setLoadingPrintCancel({commit}) {
|
||||
commit('setLoadingPrintCancel', false);
|
||||
},
|
||||
|
||||
sendGcode({commit}, data) {
|
||||
commit('setLoadingSendGcode', false);
|
||||
commit('sendGcode', data);
|
||||
},
|
||||
|
||||
switchToDashboard() {
|
||||
router.push("/");
|
||||
}
|
||||
}
|
||||
getters: getters,
|
||||
mutations: mutations,
|
||||
actions: actions
|
||||
});
|
||||
@@ -0,0 +1,208 @@
|
||||
import Vue from "vue";
|
||||
import { colorArray, colorChamber, colorHeaterBed, temperaturChartSampleInterval, temperaturChartSampleLength } from './variables';
|
||||
|
||||
export default {
|
||||
setConnected (state) {
|
||||
state.socket.isConnected = true;
|
||||
},
|
||||
|
||||
setDisconnected (state) {
|
||||
state.socket.isConnected = false
|
||||
Vue.prototype.$socket.reconnect();
|
||||
},
|
||||
|
||||
setPrinterData(state, data) {
|
||||
Object.assign(state.printer, data);
|
||||
|
||||
if (Array.isArray(state.object.heater.available_heaters) && state.object.heater.available_heaters.length) {
|
||||
let boolAddValues = false;
|
||||
let now = new Date();
|
||||
|
||||
if (state.temperaturChart.labels.length === 0 || now - state.temperaturChart.labels[state.temperaturChart.labels.length - 1] > temperaturChartSampleInterval) {
|
||||
for (let [key, value] of Object.entries(data)) {
|
||||
let keySplit = key.split(" ");
|
||||
|
||||
if (state.object.heater.available_heaters.includes(key) || keySplit[0] === "temperature_fan") {
|
||||
if (keySplit[0] === "temperature_fan") key = keySplit[1];
|
||||
|
||||
let index = state.temperaturChart.datasets.findIndex(element => element.label === key);
|
||||
|
||||
if (index >= 0) state.temperaturChart.datasets[index].data.push(value.temperature.toFixed(1));
|
||||
else {
|
||||
let color = '#f87979';
|
||||
|
||||
switch (key) {
|
||||
case 'heater_bed': color = colorHeaterBed; break;
|
||||
case 'chamber': color = colorChamber; break;
|
||||
default: color = colorArray[state.temperaturChart.datasets.length]; break;
|
||||
}
|
||||
|
||||
state.temperaturChart.datasets.push({
|
||||
label: key,
|
||||
data: [value.temperature.toFixed(1)],
|
||||
borderColor: color,
|
||||
backgroundColor: color,
|
||||
fill: false,
|
||||
borderDash: undefined,
|
||||
borderWidth: 2,
|
||||
pointRadius: 0,
|
||||
pointHitRadius: 0,
|
||||
showLine: true
|
||||
});
|
||||
}
|
||||
|
||||
boolAddValues = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (boolAddValues) {
|
||||
state.temperaturChart.labels.push(now);
|
||||
|
||||
if (state.temperaturChart.labels.length > temperaturChartSampleLength) {
|
||||
state.temperaturChart.labels.splice(0, state.temperaturChart.labels.length-temperaturChartSampleLength)
|
||||
}
|
||||
}
|
||||
|
||||
for (let [key, dataset] of Object.entries(state.temperaturChart.datasets)) {
|
||||
if (dataset.data.length > temperaturChartSampleLength) {
|
||||
state.temperaturChart.datasets[key].data.splice(0, dataset.data.length-temperaturChartSampleLength)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setObjectData(state, data) {
|
||||
Object.assign(state.object, data);
|
||||
|
||||
for (let key of Object.keys(data)) {
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit[0] === "temperature_fan") {
|
||||
Vue.prototype.$socket.sendObj('post_printer_subscriptions', { [key]: [] });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setPrinterConfig(state, data) {
|
||||
Vue.set(state, 'config', data.configfile.config);
|
||||
},
|
||||
|
||||
setFileList(state, data) {
|
||||
state.files = [];
|
||||
|
||||
for (let [key, file] of Object.entries(data)) {
|
||||
state.files.push({
|
||||
number: key,
|
||||
filename: file.filename,
|
||||
modified: Date.parse(file.modified),
|
||||
size: file.size,
|
||||
});
|
||||
}
|
||||
//state.files = data;
|
||||
},
|
||||
|
||||
addGcodeResponse(state, data) {
|
||||
state.events.push({
|
||||
date: new Date(),
|
||||
message: data
|
||||
});
|
||||
|
||||
if (data.substring(0,2) === "!!") {
|
||||
Vue.$toast.error(data);
|
||||
}
|
||||
},
|
||||
|
||||
setLoadingSendGcode(state, value) {
|
||||
state.socket.loadingSendGcode = value;
|
||||
},
|
||||
|
||||
sendGcode(state) {
|
||||
state.socket.loadingSendGcode = false;
|
||||
},
|
||||
|
||||
setPrinterStatus(state, value) {
|
||||
state.printer.toolhead.status = value;
|
||||
},
|
||||
|
||||
setLoadingGcodeUpload(state, value) {
|
||||
state.socket.loadingGcodeUpload = value;
|
||||
},
|
||||
|
||||
setLoadingGcodeRefresh(state, value) {
|
||||
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;
|
||||
},
|
||||
|
||||
setLoadingPrintCancel(state, value) {
|
||||
state.socket.loadingPrintCancel = value;
|
||||
},
|
||||
|
||||
setLoadingHome(state, value) {
|
||||
state.socket.loadingHome = value;
|
||||
},
|
||||
|
||||
setLoadingHomeX(state, value) {
|
||||
state.socket.loadingHomeX = value;
|
||||
},
|
||||
|
||||
setLoadingHomeY(state, value) {
|
||||
state.socket.loadingHomeY = value;
|
||||
},
|
||||
|
||||
setLoadingHomeZ(state, value) {
|
||||
state.socket.loadingHomeZ = value;
|
||||
},
|
||||
|
||||
setLoadingQGL(state, value) {
|
||||
state.socket.loadingQGL = value;
|
||||
},
|
||||
|
||||
setLoadingRestart(state, value) {
|
||||
state.socket.loadingRestart = value;
|
||||
},
|
||||
|
||||
setLoadingRestartFirmware(state, value) {
|
||||
state.socket.loadingRestartFirmware = value;
|
||||
},
|
||||
|
||||
reportError(state, data) {
|
||||
//Vue.$toast.error(data.message);
|
||||
window.console.log(data);
|
||||
},
|
||||
|
||||
setPausedState(state, data) {
|
||||
switch (data) {
|
||||
case 'paused':
|
||||
state.printer.pause_resume.is_paused = true;
|
||||
break;
|
||||
|
||||
case 'resumed':
|
||||
state.printer.pause_resume.is_paused = false;
|
||||
break;
|
||||
|
||||
case 'cleared':
|
||||
state.printer.pause_resume.is_paused = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
window.console.log('setPausedState -> Default: '+data);
|
||||
}
|
||||
},
|
||||
|
||||
voidMutation() {
|
||||
|
||||
},
|
||||
}
|
||||
+17
-1
@@ -1,2 +1,18 @@
|
||||
export const hostname = window.location.host;
|
||||
//export const hostname = "kossel.local:8080";
|
||||
//export const hostname = "voron250.local:8080";
|
||||
//export const hostname = "kossel.local:8080";
|
||||
|
||||
export const colorArray = [
|
||||
'#F44336',
|
||||
'#E91E63',
|
||||
'#9C27B0',
|
||||
'#673AB7',
|
||||
'#3F51B5',
|
||||
'#00BCD4',
|
||||
'#009688',
|
||||
];
|
||||
|
||||
export const colorHeaterBed = '#2196F3';
|
||||
export const colorChamber = '#4CAF50';
|
||||
export const temperaturChartSampleInterval = 1000;
|
||||
export const temperaturChartSampleLength = 600;
|
||||
Reference in new issue
Block a user