bugfix: tool input number buttons hidden

bugfix: UFP thumbnail (only 300px)
bugfix: moonraker > websocket subscription
bugfix: miniconsole > different line baseline
bugfix: new metadata push > redirect to current file
feature: show/hide colums in gcode-files
feature: show/hide hidden files/dir
feature: display missing config sections
feature: display klippy-state in settings > machinies

Signed-off-by: meteyou <meteyou@gmail.com>
This commit is contained in:
meteyou committed 2020-11-17 00:35:59 +01:00
1 parent 2bcf08e5ab
commit 49c79c9eae
61 files changed
+1619 -1272

No files matched your search

+18 -19
View File
@@ -80,6 +80,7 @@
<v-list-item link @click="doFirmwareRestart()">
<v-list-item-title><v-icon class="mr-3">mdi-sync</v-icon>FW Restart</v-list-item-title>
</v-list-item>
<v-divider></v-divider>
<v-list-item link @click="doHostReboot()">
<v-list-item-title><v-icon class="mr-3">mdi-power</v-icon>Reboot Host</v-list-item-title>
</v-list-item>
@@ -100,7 +101,7 @@
</v-scroll-y-transition>
</v-main>
<v-dialog v-model="isConnecting" persistent width="300">
<v-dialog v-model="overlayDisconnect" persistent width="300">
<v-card color="primary" dark >
<v-card-text class="pt-2">
Connecting...
@@ -129,6 +130,7 @@ export default {
},
data: () => ({
overlayDisconnect: true,
drawer: null,
activeClass: 'active',
routes: routes,
@@ -139,7 +141,6 @@ export default {
}),
created () {
this.$vuetify.theme.dark = true;
//this.is_ready = (this.klippy_state === "ready") ? true : false;
this.boolNaviHeightmap = (typeof(this.config.bed_mesh) !== "undefined");
},
computed: {
@@ -147,17 +148,16 @@ export default {
return this.$route.fullPath;
},
...mapState({
toolhead: state => state.printer.toolhead,
hostname: state => state.printer.hostname,
printername: state => state.gui.general.printername,
version: state => state.printer.software_version,
isConnected: state => state.socket.isConnected,
isConnecting: state => !state.socket.isConnected,
hostname: state => state.printer.hostname,
version: state => state.printer.software_version,
klippy_state: state => state.server.klippy_state,
toolhead: state => state.printer.toolhead,
printername: state => state.gui.general.printername,
virtual_sdcard: state => state.printer.virtual_sdcard,
current_file: state => state.printer.print_stats.filename,
boolNaviWebcam: state => state.gui.webcam.bool,
klippy_state: state => state.printer.webhooks.state,
loadings: state => state.loadings,
config: state => state.printer.configfile.config,
save_config_pending: state => state.printer.configfile.save_config_pending,
}),
@@ -168,22 +168,22 @@ export default {
},
methods: {
clickEmergencyStop: function() {
this.$store.commit('setLoading', { name: 'btnEmergencyStop' });
// TODO loading emergency stop
//this.$store.commit('setLoading', { name: 'btnEmergencyStop' });
this.$socket.sendObj('printer.emergency_stop', {});
},
clickSaveConfig: function() {
this.$store.commit('addGcodeResponse', "SAVE_CONFIG");
this.$store.commit('setLoading', { name: 'btnSaveConfig' });
this.$store.commit('server/addEvent', "SAVE_CONFIG");
// TODO loading save_config button
//this.$store.commit('setLoading', { name: 'btnSaveConfig' });
this.$socket.sendObj('printer.gcode.script', { script: "SAVE_CONFIG" });
},
doRestart: function() {
this.$store.commit('setPrinterData', { webhooks: { state: "restart", state_message: "Printer is restarting..."}});
this.$store.commit('addGcodeResponse', "RESTART");
this.$store.commit('server/addEvent', "RESTART");
this.$socket.sendObj('printer.gcode.script', { script: "RESTART" });
},
doFirmwareRestart: function() {
this.$store.commit('setPrinterData', { webhooks: { state: "restart", state_message: "Printer is restarting..."}});
this.$store.commit('addGcodeResponse', "FIRMWARE_RESTART");
this.$store.commit('server/addEvent', "FIRMWARE_RESTART");
this.$socket.sendObj('printer.gcode.script', { script: "FIRMWARE_RESTART" });
},
doHostReboot: function() {
@@ -258,9 +258,8 @@ export default {
config() {
this.boolNaviHeightmap = (typeof(this.config.bed_mesh) !== "undefined");
},
loadings: function(loadings) {
this.loadingEmergencyStop = loadings.includes('btnEmergencyStop');
this.loadingConfigChanged = loadings.includes('btnSaveConfig');
isConnected(newVal) {
this.overlayDisconnect = !newVal;
}
},
}
+6 -9
View File
@@ -53,7 +53,7 @@ export default {
meta_target.hidden = meta.hidden;
}
store.dispatch('setHeaterChartVisibility', { name: legendItem.text, hidden: meta.hidden });
store.dispatch('gui/setHeaterChartVisibility', { name: legendItem.text, hidden: meta.hidden });
ci.update();
}
@@ -129,10 +129,12 @@ export default {
}
},
created () {
this.timer = setInterval(this.update, 500);
/*this.timer = setInterval(function() {
this.update;
}, 2000);*/
},
mounted () {
this.renderChart(this.chartData, this.options);
//this.renderChart(this.chartData, this.options)
},
methods: {
update() {
@@ -143,11 +145,6 @@ export default {
}
},
watch: {
chartData: function(newData, oldData) {
window.console.log("watch chartData");
window.console.log(newData);
window.console.log(oldData);
this.$data._chart.reset();
}
}
}
+14 -14
View File
@@ -91,33 +91,33 @@
},
methods: {
doHome() {
this.$store.commit('addGcodeResponse', "G28");
this.$store.commit('setLoading', { name: 'controlHomeAll' });
this.$store.commit('server/addEvent', "G28");
//this.$store.commit('setLoading', { name: 'controlHomeAll' });
this.$socket.sendObj('printer.gcode.script', { script: "G28" }, "responseHome");
},
doHomeX() {
this.$store.commit('addGcodeResponse', "G28 X");
this.$store.commit('setLoading', { name: 'controlHomeX' });
this.$store.commit('server/addEvent', "G28 X");
//this.$store.commit('setLoading', { name: 'controlHomeX' });
this.$socket.sendObj('printer.gcode.script', { script: "G28 X" }, "responseHomeX");
},
doHomeY() {
this.$store.commit('addGcodeResponse', "G28 Y");
this.$store.commit('setLoading', { name: 'controlHomeY' });
this.$store.commit('server/addEvent', "G28 Y");
//this.$store.commit('setLoading', { name: 'controlHomeY' });
this.$socket.sendObj('printer.gcode.script', { script: "G28 Y" }, "responseHomeY");
},
doHomeZ() {
this.$store.commit('addGcodeResponse', "G28 Z");
this.$store.commit('setLoading', { name: 'controlHomeZ' });
this.$store.commit('server/addEvent', "G28 Z");
//this.$store.commit('setLoading', { name: 'controlHomeZ' });
this.$socket.sendObj('printer.gcode.script', { script: "G28 Z" }, "responseHomeZ");
},
doQGL() {
this.$store.commit('addGcodeResponse', "QUAD_GANTRY_LEVEL");
this.$store.commit('setLoading', { name: 'controlQGL' });
this.$store.commit('server/addEvent', "QUAD_GANTRY_LEVEL");
//this.$store.commit('setLoading', { name: 'controlQGL' });
this.$socket.sendObj('printer.gcode.script', { script: "QUAD_GANTRY_LEVEL" }, "responseQGL");
},
doZtilt() {
this.$store.commit('addGcodeResponse', "Z_TILT_ADJUST");
this.$store.commit('setLoading', { name: 'controlZTilt' });
this.$store.commit('server/addEvent', "Z_TILT_ADJUST");
//this.$store.commit('setLoading', { name: 'controlZTilt' });
this.$socket.sendObj('printer.gcode.script', { script: "Z_TILT_ADJUST" }, "responseZTilt");
},
doSendMove(gcode) {
@@ -128,8 +128,8 @@
this.doSend(gcode);
},
doSend(gcode) {
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode }, "sendGcode");
this.$store.commit('server/addEvent', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode }, "server/getGcodeRespond");
},
},
watch: {
+9 -12
View File
@@ -8,20 +8,20 @@
<v-col class="col-12 col-md-6">
<v-label>Feed amount in mm:</v-label>
<v-btn-toggle class="mt-2" no-gutters style="flex-wrap: nowrap; width: 100%;" >
<v-btn v-for="amount in feedAmounts" v-bind:key="amount" @click="setFeedAmount(amount)" cols="1" :class="(amount === feedAmount ? 'v-btn--active' : '') + ' flex-grow-1'">{{ amount }}</v-btn>
<v-btn v-for="amount in feedAmounts" v-bind:key="amount" @click="setFeedAmount(amount)" dense cols="1" :class="(amount === feedAmount ? 'v-btn--active' : '') + ' flex-grow-1 px-0 _btnFeedrate'">{{ amount }}</v-btn>
</v-btn-toggle>
</v-col>
<v-col class="col-12 col-md-6">
<v-label>Feedrate in mm/s:</v-label>
<v-btn-toggle class="mt-2" no-gutters style="flex-wrap: nowrap; width: 100%;" >
<v-btn v-for="rate in feedrates" v-bind:key="rate" @click="setFeedrate(rate)" cols="1" :class="(feedrate === rate ? 'v-btn--active' : '') + ' flex-grow-1'">{{ rate }}</v-btn>
<v-btn v-for="rate in feedrates" v-bind:key="rate" @click="setFeedrate(rate)" dense cols="1" :class="(feedrate === rate ? 'v-btn--active' : '') + ' flex-grow-1 px-0 _btnFeedrate'">{{ rate }}</v-btn>
</v-btn-toggle>
</v-col>
</v-row>
<v-row class="px-3">
<v-col class="col-12 text-center">
<v-btn @click="sendRetract()" class="mx-2" :loading="loadingRetract" :disabled="!(config !== undefined && Object.hasOwnProperty(config, 'extruder') && config.extruder !== null && (config.extruder.min_extrude_temp < extruder.temperature || !config.extruder.min_extrude_temp))"><v-icon>mdi-arrow-up-bold</v-icon> Retract</v-btn>
<v-btn @click="sendDetract()" class="mx-2" :loading="loadingDetract" :disabled="!(config !== undefined && Object.hasOwnProperty(config, 'extruder') && config.extruder !== null && (config.extruder.min_extrude_temp < extruder.temperature || !config.extruder.min_extrude_temp))"><v-icon>mdi-arrow-down-bold</v-icon> Extrude</v-btn>
<v-btn @click="sendRetract()" class="mx-2" :loading="loadingRetract" :disabled="!this['printer/getExtrudePossible']"><v-icon>mdi-arrow-up-bold</v-icon> Retract</v-btn>
<v-btn @click="sendDetract()" class="mx-2" :loading="loadingDetract" :disabled="!this['printer/getExtrudePossible']"><v-icon>mdi-arrow-down-bold</v-icon> Extrude</v-btn>
</v-col>
</v-row>
</v-card>
@@ -53,8 +53,7 @@
config: state => state.printer.configfile.config
}),
...mapGetters([
'getMacros',
'getCurrentExtruder',
'printer/getExtrudePossible',
]),
},
methods: {
@@ -66,15 +65,13 @@
},
sendRetract() {
let gcode = "M83\nG1 E-"+this.feedAmount+" F"+(this.feedrate * 60);
this.$store.commit('setLoading', { name: 'extruderRetract' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode }, "respondeExtruderRetract");
this.$store.commit('server/addEvent', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode });
},
sendDetract() {
let gcode = "M83\nG1 E"+this.feedAmount+" F"+(this.feedrate * 60);
this.$store.commit('setLoading', { name: 'extruderDetract' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode }, "respondeExtruderDetract");
this.$store.commit('server/addEvent', gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: gcode });
},
},
watch: {
+15 -46
View File
@@ -6,13 +6,13 @@
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title class="headline">Klippy-Status</v-list-item-title>
<v-list-item-title class="subtitle-1">{{ state }}</v-list-item-title>
<v-list-item-title class="subtitle-1">{{ klippy_state }}</v-list-item-title>
</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">
<v-layout wrap class=" text-center">
<v-flex col class="text-left" v-if="klippy_connected"><pre>{{ state_message }}</pre></v-flex>
<v-flex col class="text-left" v-if="klippy_connected"><pre>{{ klippy_message }}</pre></v-flex>
<v-flex col class="text-left" v-if="!klippy_connected">
<p>Moonraker can't connect to Klippy!<br />Please check if the Klipper service is running and an UDS (Unix Domain Socket) is configured.</p>
</v-flex>
@@ -20,66 +20,35 @@
</v-card-text>
<v-divider class="my-2" v-if="klippy_connected" ></v-divider>
<v-card-text class="px-4 pt-2 pb-4 content text-center text-lg-left" v-if="klippy_connected">
<v-btn @click="doRestart" :loading="loadingRestart" color="error" class=""><v-icon class="mr-sm-2">mdi-cached</v-icon>Restart</v-btn>
<v-btn @click="doRestartFirmware" :loading="loadingRestartFirmware" class="ml-4" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon>FIRMWARE_Restart</v-btn>
<v-btn @click="doRestart" color="error" class=""><v-icon class="mr-sm-2">mdi-cached</v-icon>Restart</v-btn>
<v-btn @click="doRestartFirmware" class="ml-4" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon>FIRMWARE_Restart</v-btn>
</v-card-text>
</v-card>
</template>
<script>
import {mapMutations, mapState} from 'vuex';
import { mapState } from 'vuex';
export default {
computed: {
...mapState({
state: state => state.printer.webhooks.state,
state_message: state => state.printer.webhooks.state_message,
loadingRestart: state => state.socket.loadingRestart,
loadingRestartFirmware: state => state.socket.loadingRestartFirmware,
klippy_connected: state => state.socket.klippy_connected,
klippy_connected: state => state.server.klippy_connected,
klippy_state: state => state.server.klippy_state,
klippy_message: state => state.server.klippy_message,
}),
...mapMutations([
'setLoadingRestart',
'setLoadingRestartFirmware',
]),
},
methods: {
doRestart() {
this.$store.commit('setLoadingRestart', true);
this.$socket.sendObj('printer.restart', { }, "responseRestart");
// TODO loading restart button
//this.$store.commit('setLoadingRestart', true);
this.$socket.sendObj('printer.restart', { });
},
doRestartFirmware() {
this.$store.commit('setLoadingRestartFirmware', true);
this.$socket.sendObj('printer.firmware_restart', { }, "responseRestartFirmware");
// TODO loading fw restart button
//this.$store.commit('setLoadingRestartFirmware', true);
this.$socket.sendObj('printer.firmware_restart', { });
},
},
}
</script>
<style scoped>
.equal-width {
flex-basis: 0;
}
.category-header {
flex: 0 0 100px;
}
a:not(:hover) {
color: inherit;
}
.content span,
.content strong {
padding-left: 8px;
padding-right: 8px;
white-space: pre-wrap;
}
.probe-span {
border-radius: 5px;
}
.probe-span:not(:last-child) {
margin-right: 8px;
}
</style>
</script>
+31 -27
View File
@@ -9,6 +9,10 @@
white-space: nowrap;
}
.miniConsole.v-data-table > .v-data-table__wrapper > table > tbody > tr > td {
height: auto;
}
.miniConsole .content-cell {
width: 100%;
}
@@ -24,33 +28,33 @@
</v-list-item>
<v-divider class="mt-2"></v-divider>
<v-card-text class="px-0 py-0 content">
<v-data-table
:headers="headers"
:options="options"
:items="events"
item-key="date"
hide-default-footer
hide-default-header
disable-pagination
class="minievent-table miniConsole"
:custom-sort="customSort"
sort-by="date"
>
<template #no-data>
<div class="text-center">empty</div>
</template>
<v-data-table
:headers="headers"
:options="options"
:items="events"
item-key="date"
hide-default-footer
hide-default-header
disable-pagination
class="minievent-table miniConsole"
:custom-sort="customSort"
sort-by="date"
>
<template #no-data>
<div class="text-center">empty</div>
</template>
<template #item="{ item }">
<tr>
<td class="log-cell title-cell py-2">
{{ formatTime(item.date)}}
</td>
<td class="log-cell content-cell pl-0 py-2" colspan="2" style="width:100%;">
<span v-if="item.message" class="message" v-html="formatMessage(item.message)"></span>
</td>
</tr>
</template>
</v-data-table>
<template #item="{ item }">
<tr>
<td class="log-cell title-cell py-2">
{{ formatTime(item.date)}}
</td>
<td class="log-cell content-cell pl-0 py-2" colspan="2" style="width:100%;">
<span v-if="item.message" class="message" v-html="formatMessage(item.message)"></span>
</td>
</tr>
</template>
</v-data-table>
</v-card-text>
</v-card>
</template>
@@ -85,7 +89,7 @@
},
computed: {
...mapState({
events: state => state.events,
events: state => state.server.events,
})
},
methods: {
+16 -34
View File
@@ -17,47 +17,38 @@
<template>
<div>
<v-card v-if="fan">
<v-card v-if="this['printer/getFans'].length">
<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>
<span class="subheading"><v-icon :class="'mdi mdi-fan '+(this['printer/getPartFanSpeed'] ? 'icon-rotate' : '')" left></v-icon>Fans</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="py-2">
<tool-slider :target="fan.speed" :multi="100" command="M106" attribute-name="S" :attribute-scale="2.55" ></tool-slider>
</v-card-text>
<div v-for="(fan, index) of this['printer/getFans']" v-bind:key="index">
<v-divider v-if="index"></v-divider>
<fan-slider :name="fan.name" :type="fan.type" :target="fan.speed" :controllable="fan.controllable" :multi="100" class="py-0" ></fan-slider>
</div>
</v-card>
<v-card class="mt-6" v-if="['printing', 'paused'].includes(printer_state)">
<v-card class="mt-6" v-if="['printing', 'paused'].includes(printer_state) || true">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon class="mdi mdi-printer-3d" left></v-icon>Print Settings</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="py-2">
<v-row>
<v-col class="py-0">
<tool-slider prependIcon="mdi-timer" :target="speed_factor" :max="200" :multi="100" command="M220" attribute-name="S" ></tool-slider>
</v-col>
</v-row>
<v-row>
<v-col class="py-0">
<tool-slider prependIcon="mdi-texture" :target="extrude_factor" :max="200" :multi="100" command="M221" attribute-name="S" ></tool-slider>
</v-col>
</v-row>
</v-card-text>
<tool-slider label="Speed factor" :target="speed_factor" :max="200" :multi="100" :step="1" command="M220" attribute-name="S" ></tool-slider>
<v-divider></v-divider>
<tool-slider label="Extrusion factor" :target="extrude_factor" :max="200" :multi="100" :step="5" command="M221" attribute-name="S" ></tool-slider>
</v-card>
</div>
</template>
<script>
import {mapGetters, mapState} from 'vuex'
import { mapState, mapGetters } from 'vuex'
import FanSlider from '../../inputs/FanSlider'
import ToolSlider from '../../inputs/ToolSlider'
export default {
components: {
FanSlider,
ToolSlider
},
data () {
@@ -72,18 +63,9 @@
printer_state: state => state.printer.print_stats.state,
}),
...mapGetters([
'fan',
'is_printing'
])
'printer/getFans',
'printer/getPartFanSpeed',
]),
},
methods: {
},
mounted () {
},
watch: {
}
}
</script>
@@ -231,9 +231,7 @@
},
computed: {
...mapState({
config_examples: state => state.filetree.config_examples,
config: state => state.filetree.config,
filetree: state => state.filetree,
filetree: state => state.files.filetree,
countPerPage: state => state.gui.settings.configfiles.countPerPage,
hostname: state => state.socket.hostname,
port: state => state.socket.port,
@@ -244,17 +242,17 @@
},
methods: {
highlighter(code) {
//return highlight(code, languages.editorconfig); //returns html
return highlight(code, languages.ini); //returns html
},
refreshFileList: function() {
window.console.log(this.currentPath.substring(1));
this.$store.commit('setLoading', { name: 'loadingConfigRefresh' });
// TODO loading refresh
//this.$store.commit('setLoading', { name: 'loadingConfigRefresh' });
if (this.currentPath === "") {
this.$socket.sendObj('server.files.get_directory', { path: 'config' }, 'getDirectory');
this.$socket.sendObj('server.files.get_directory', { path: 'config_examples' }, 'getDirectory');
} else this.$socket.sendObj('server.files.get_directory', { path: this.currentPath.substring(1) }, 'getDirectory');
this.$socket.sendObj('server.files.get_directory', { path: 'config' }, 'files/getDirectory');
this.$socket.sendObj('server.files.get_directory', { path: 'config_examples' }, 'files/getDirectory');
} else this.$socket.sendObj('server.files.get_directory', { path: this.currentPath.substring(1) }, 'files/getDirectory');
},
formatDate(date) {
let tmp2 = new Date(date);
@@ -385,7 +383,7 @@
this.$socket.sendObj('server.files.post_directory', {
path: this.currentPath.substring(1)+"/"+this.dialogCreateFolder.name
}, 'getPostDirectory');
}, 'files/getCreateDir');
},
createFile() {
this.dialogCreateFile.name = "";
@@ -420,7 +418,7 @@
this.$socket.sendObj('server.files.move', {
source: this.currentPath+"/"+this.dialogRenameFile.item.filename,
dest: this.currentPath+"/"+this.dialogRenameFile.newName
}, 'getPostFileMove');
}, 'files/getMove');
},
removeFile() {
let filename = (this.currentPath+"/"+this.contextMenu.item.filename);
@@ -433,7 +431,7 @@
});
},
deleteDirectoryAction: function() {
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'getDeleteDirectory');
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteDir');
},
},
watch: {
@@ -49,7 +49,7 @@
return this.$store.state.gui.dashboard.boolWebcam;
},
set(status) {
return this.$store.dispatch('setSettings', { gui: { dashboard: { boolWebcam: status } } });
return this.$store.dispatch('gui/setSettings', { dashboard: { boolWebcam: status } });
}
},
boolShowTempchartOnDashboard: {
@@ -57,7 +57,7 @@
return this.$store.state.gui.dashboard.boolTempchart;
},
set(status) {
return this.$store.dispatch('setSettings', { gui: { dashboard: { boolTempchart: status } } });
return this.$store.dispatch('gui/setSettings', { dashboard: { boolTempchart: status } });
}
},
boolShowConsoleOnDashboard: {
@@ -65,7 +65,7 @@
return this.$store.state.gui.dashboard.boolConsole;
},
set(status) {
return this.$store.dispatch('setSettings', { gui: { dashboard: { boolConsole: status } } });
return this.$store.dispatch('gui/setSettings', { dashboard: { boolConsole: status } });
}
},
},
@@ -41,12 +41,13 @@
},
data: function() {
return {
sortEndstops: {}
sortEndstops: {},
loading: false
}
},
computed: {
...mapState({
loading: state => state.socket.loadingEndstopStatus,
//loading: state => state.socket.loadingEndstopStatus,
endstops: state => state.printer.endstops,
})
},
@@ -55,8 +56,9 @@
},
methods: {
syncEndstops() {
this.$store.commit('setLoadingEndstopStatus', true);
this.$socket.sendObj('printer.query_endstops.status', { }, "responseEndstopStatus");
// TODO loading
//this.$store.commit('setLoadingEndstopStatus', true);
this.$socket.sendObj('printer.query_endstops.status', { }, "printer/getEndstopStatus");
},
getEndstops() {
this.sortEndstops = {};
+14 -17
View File
@@ -6,34 +6,31 @@
<v-list-item-title class="headline">Machine Limits</v-list-item-title>
</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">
<v-row class="px-6" >
<v-col sm-12>
<toolSlider label="VELOCITY" v-bind:target="current_velocity" v-bind:max="max_velocity" command="SET_VELOCITY_LIMIT" attribute-name="VELOCITY=" ></toolSlider>
<toolSlider label="ACCEL" v-bind:target="current_accel" v-bind:max="max_accel" command="SET_VELOCITY_LIMIT" attribute-name="ACCEL=" ></toolSlider>
<toolSlider label="DECEL" v-bind:target="current_accel_to_decel" v-bind:max="max_accel_to_decel" command="SET_VELOCITY_LIMIT" attribute-name="ACCEL_TO_DECEL=" ></toolSlider>
<toolSlider label="SCV" v-bind:target="current_square_corner_velocity" v-bind:max="max_square_corner_velocity" command="SET_VELOCITY_LIMIT" attribute-name="SQUARE_CORNER_VELOCITY=" ></toolSlider>
</v-col>
</v-row>
</v-card-text>
<v-divider class="mt-2"></v-divider>
<tool-slider label="Velocity" unit="mm/s" :target="current_velocity" :max="max_velocity" command="SET_VELOCITY_LIMIT" attribute-name="VELOCITY=" ></tool-slider>
<v-divider></v-divider>
<tool-slider label="Acceleration" unit="mm/s²" :target="current_accel" :max="max_accel" command="SET_VELOCITY_LIMIT" attribute-name="ACCEL=" ></tool-slider>
<v-divider></v-divider>
<tool-slider label="Deceleration" unit="mm/s²" :target="current_accel_to_decel" :max="max_accel_to_decel" command="SET_VELOCITY_LIMIT" attribute-name="ACCEL_TO_DECEL=" ></tool-slider>
<v-divider></v-divider>
<tool-slider label="Square corner velocity" unit="mm/s" :target="current_square_corner_velocity" :max="max_square_corner_velocity" command="SET_VELOCITY_LIMIT" attribute-name="SQUARE_CORNER_VELOCITY=" ></tool-slider>
</v-card>
</template>
<script>
import { mapState } from 'vuex'
import toolSlider from '../../../inputs/ToolSlider'
import ToolSlider from '../../../inputs/ToolSlider'
export default {
components: {
toolSlider
ToolSlider
},
data: function() {
return {
max_velocity: 200,
max_accel: 5000,
max_accel_to_decel: 2500,
max_square_corner_velocity: 10,
max_velocity: 0,
max_accel: 0,
max_accel_to_decel: 0,
max_square_corner_velocity: 0,
}
},
computed: {
@@ -36,7 +36,7 @@
...mapState({
hostname: state => state.socket.hostname,
port: state => state.socket.port,
klippy_state: state => state.printer.webhooks.state,
klippy_state: state => state.server.klippy_state,
}),
},
}
@@ -9,7 +9,7 @@
</v-list-item>
<v-divider class="my-2"></v-divider>
<v-card-text class="px-0 pb-3 pt-3 content">
<div v-for="(macro, index) in getAllMacros" v-bind:key="index">
<div v-for="(macro, index) in this['printer/getAllMacros']" v-bind:key="index">
<v-row>
<v-col class="px-10 py-0">
<settings-macro-switch :name="macro.name"></settings-macro-switch>
@@ -27,7 +27,6 @@
export default {
components: {
SettingsMacroSwitch
},
data: function() {
return {
@@ -39,7 +38,7 @@
hiddenMacros: state => state.gui.dashboard.hiddenMacros,
}),
...mapGetters([
'getAllMacros',
'printer/getAllMacros',
])
},
methods: {
@@ -54,7 +54,7 @@
return this.$store.state.gui.webcam.url;
},
set(url) {
return this.$store.dispatch('setSettings', { gui: { webcam: { url } } });
return this.$store.dispatch('gui/setSettings', { webcam: { url } });
}
},
flipX: {
@@ -62,7 +62,7 @@
return this.$store.state.gui.webcam.flipX;
},
set(flipX) {
return this.$store.dispatch('setSettings', { gui: { webcam: { flipX } } });
return this.$store.dispatch('gui/setSettings', { webcam: { flipX } });
}
},
flipY: {
@@ -70,7 +70,7 @@
return this.$store.state.gui.webcam.flipY;
},
set(flipY) {
return this.$store.dispatch('setSettings', { gui: { webcam: { flipY } } });
return this.$store.dispatch('gui/setSettings', { webcam: { flipY } });
}
},
rotate: {
@@ -78,7 +78,7 @@
return this.$store.state.gui.webcam.rotate;
},
set(rotate) {
return this.$store.dispatch('setSettings', { gui: { webcam: { rotate } } });
return this.$store.dispatch('gui/setSettings', { webcam: { rotate } });
}
},
rotateDegrees: {
@@ -86,7 +86,7 @@
return this.$store.state.gui.webcam.rotateDegrees;
},
set(rotateDegrees) {
return this.$store.dispatch('setSettings', { gui: { webcam: { rotateDegrees } } });
return this.$store.dispatch('gui/setSettings', { webcam: { rotateDegrees } });
}
},
boolNavi: {
@@ -94,7 +94,7 @@
return this.$store.state.gui.webcam.bool;
},
set(showNav) {
return this.$store.dispatch('setSettings', { gui: { webcam: { bool: showNav } } });
return this.$store.dispatch('gui/setSettings', { webcam: { bool: showNav } });
}
},
},
+12 -10
View File
@@ -157,7 +157,6 @@
...mapState({
toolhead: state => state.printer.toolhead,
position: state => state.printer.toolhead.position,
loadings: state => state.loadings,
estimated_print_time: state => state.printer.toolhead.estimated_print_time,
@@ -169,8 +168,6 @@
filament_used: state => state.printer.print_stats.filament_used,
current_file: state => state.printer.print_stats.filename,
printer_state: state => state.printer.print_stats.state,
klippy_state: state => state.printer.webhooks.state,
klippy_state_message: state => state.printer.webhooks.state_message,
display_message: state => state.printer.display_status.message,
}),
@@ -184,23 +181,28 @@
},
methods: {
btnPauseJob() {
this.$store.commit('setLoading', { name: 'statusPrintPause' });
// TODO loading button
//this.$store.commit('setLoading', { name: 'statusPrintPause' });
this.$socket.sendObj('printer.print.pause', { }, 'respondPrintPause');
},
btnResumeJob() {
this.$store.commit('setLoading', { name: 'statusPrintResume' });
// TODO loading button
//this.$store.commit('setLoading', { name: 'statusPrintResume' });
this.$socket.sendObj('printer.print.resume', { }, 'respondPrintResume');
},
btnCancelJob() {
this.$store.commit('setLoading', { name: 'statusPrintCancel' });
// TODO loading button
//this.$store.commit('setLoading', { name: 'statusPrintCancel' });
this.$socket.sendObj('printer.print.cancel', { }, 'respondPrintCancel');
},
btnClearJob() {
this.$store.commit('setLoading', {name: 'statusPrintClear'});
// TODO loading button
//this.$store.commit('setLoading', {name: 'statusPrintClear'});
this.$socket.sendObj('printer.gcode.script', {script: 'SDCARD_RESET_FILE'}, 'respondPrintClear');
},
btnReprintJob() {
this.$store.commit('setLoading', {name: 'statusPrintReprint'});
// TODO loading button
//this.$store.commit('setLoading', {name: 'statusPrintReprint'});
this.$socket.sendObj('printer.print.start', { filename: this.current_file }, 'respondPrintReprint');
},
formatTime(seconds) {
@@ -213,13 +215,13 @@
},
},
watch: {
loadings: function(loadings) {
/*loadings: function(loadings) {
this.loadingStatusCancel = loadings.includes('statusPrintCancel');
this.loadingStatusResume = loadings.includes('statusPrintResume');
this.loadingStatusPause = loadings.includes('statusPrintPause');
this.loadingStatusClear = loadings.includes('statusPrintClear');
this.loadingStatusReprint = loadings.includes('statusPrintReprint');
}
}*/
}
}
</script>
+1 -1
View File
@@ -99,7 +99,7 @@
},
computed: {
...mapState({
datasets: state => state.temperaturChart,
datasets: state => state.printer.tempHistory.datasets,
boolTempchart: state => state.gui.dashboard.boolTempchart,
}),
...mapGetters([
+109
View File
@@ -0,0 +1,109 @@
<style>
._fan-slider-subheader {
height: auto;
}
</style>
<template>
<v-row>
<v-col :class="controllable ? 'pb-1 pt-3' : 'py-2'">
<v-subheader class="_fan-slider-subheader">
<span>{{ convertName }}</span>
<v-spacer></v-spacer>
<span class="font-weight-bold">{{ Math.round(value) }} %</span>
</v-subheader>
<v-card-text class="py-0" v-if="controllable">
<v-slider
v-model="value"
:min="0"
:max="100"
@change="sendCmd"
hide-details>
<template v-slot:prepend>
<v-icon @click="decrement">mdi-minus</v-icon>
</template>
<template v-slot:append>
<v-icon @click="increment">mdi-plus</v-icon>
</template>
</v-slider>
</v-card-text>
</v-col>
</v-row>
</template>
<script>
export default {
data: function() {
return {
value: this.target * this.multi,
}
},
props: {
target: {
type: Number,
required: true,
},
name: {
type: String,
required: true,
default: ''
},
type: {
type: String,
required: false,
default: ''
},
controllable: {
type: Boolean,
required: false,
default: false
},
multi: {
type: Number,
required: false,
default: 1
},
},
computed: {
convertName() {
let tmp = this.name;
tmp = tmp.replaceAll("_", " ");
tmp = tmp.charAt(0).toUpperCase() + tmp.slice(1);
return tmp;
}
},
methods: {
sendCmd() {
let gcode = "";
if (this.type === "fan") gcode = "M106 S"+(this.value * 2.55).toFixed(0);
if (this.type === "fan_generic") gcode = "SET_FAN_SPEED FAN="+this.name+" SPEED="+(this.value/100);
if (gcode !== "") {
this.$store.commit('server/addEvent', gcode);
this.$socket.sendObj('printer.gcode.script', { script: gcode });
}
},
decrement() {
this.value = this.value > 0 ? (this.value - 1).toFixed(0) : 0;
this.sendCmd();
},
increment() {
this.value = this.value < 100 ? (this.value + 1).toFixed(0) : 100;
this.sendCmd();
}
},
watch: {
target: function(newVal) {
this.value = newVal * this.multi;
},
},
created: function() {
},
}
</script>
+6 -4
View File
@@ -30,17 +30,19 @@
setValue() {
if (this.value) {
let index = this.hiddenMacros.indexOf(this.name.toUpperCase());
if (index > -1) this.hiddenMacros.splice(index, 1);
} else this.hiddenMacros.push(this.name.toUpperCase());
if (index > -1) this.hiddenMacros.splice(index, 1)
} else this.hiddenMacros.push(this.name.toUpperCase())
this.$store.dispatch("gui/upload")
}
},
watch: {
hiddenMacros: function() {
this.value = !this.hiddenMacros.includes(this.name.toUpperCase());
this.value = !this.hiddenMacros.includes(this.name.toUpperCase())
}
},
created() {
this.value = !this.hiddenMacros.includes(this.name.toUpperCase());
this.value = !this.hiddenMacros.includes(this.name.toUpperCase())
}
}
</script>
+10 -1
View File
@@ -7,6 +7,15 @@
.tool-input .v-input__slot { margin-bottom: 0; }
.tool-input .v-text-field__details { display: none; }
.tool-input input {
-moz-appearance: textfield;
}
.tool-input input::-webkit-outer-spin-button,
.tool-input input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>
<template>
@@ -43,7 +52,7 @@
} else if (this.min_temp !== undefined && this.value < this.min_temp && parseFloat(this.value) !== 0) {
this.value = this.target;
Vue.$toast.error("Temperature too low for "+this.name+"! (min: "+this.min_temp+")");
} else this.$socket.sendObj('printer.gcode.script', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value});
} else this.$socket.sendObj('printer.gcode.script', { script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value });
}
},
watch: {
+42 -35
View File
@@ -1,31 +1,34 @@
<style>
._tool-slider-subheader {
height: auto;
}
</style>
<template>
<v-row>
<v-col class="py-1">
<v-slider
v-model="value"
:label="label"
:min="min"
:max="max"
@change="sendCmd"
:prepend-icon="prependIcon"
hide-details>
<v-col class="pb-1 pt-3">
<v-subheader class="_tool-slider-subheader">
<span>{{ label }}</span>
<v-spacer></v-spacer>
<span class="font-weight-bold">{{ value }} {{ unit }}</span>
</v-subheader>
<v-card-text class="py-0">
<v-slider
v-model="value"
:min="min"
:max="max"
@change="sendCmd"
hide-details>
<template v-slot:append>
<v-text-field
v-model="value"
class="mt-0 pt-0"
hide-details
single-line
type="number"
style="width: 80px"
@change="sendCmd"
></v-text-field>
</template>
</v-slider>
<template v-slot:prepend>
<v-icon @click="decrement">mdi-minus</v-icon>
</template>
<template v-slot:append>
<v-icon @click="increment">mdi-plus</v-icon>
</template>
</v-slider>
</v-card-text>
</v-col>
</v-row>
</template>
@@ -44,7 +47,6 @@
required: true,
},
command: {
type: String,
required: true,
},
attributeName: {
@@ -57,10 +59,10 @@
required: false,
default: ''
},
prependIcon: {
unit: {
type: String,
required: false,
default: ''
default: '%'
},
attributeScale: {
type: Number,
@@ -77,15 +79,10 @@
required: false,
default: 100
},
extenderSteps: {
step: {
type: Number,
required: false,
default: 100
},
extender: {
type: Boolean,
required: false,
default: false
default: 1
},
multi: {
type: Number,
@@ -98,12 +95,22 @@
},
methods: {
sendCmd() {
this.$socket.sendObj('printer.gcode.script', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) });
let gcode = this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0)
this.$store.commit('server/addEvent', gcode)
this.$socket.sendObj('printer.gcode.script', { script: gcode })
},
decrement() {
this.value = this.value > this.min ? (this.value - this.step).toFixed(0) : this.min
this.sendCmd();
},
increment() {
this.value = this.value < this.max ? (this.value + this.step).toFixed(0) : this.max
this.sendCmd();
}
},
watch: {
target: function() {
this.value = this.target * this.multi;
target: function(newVal) {
this.value = newVal * this.multi;
},
},
created: function() {
+1 -1
View File
@@ -22,7 +22,7 @@ Vue.component('vue-headful', vueHeadful);
fetch('/config.json')
.then(res => res.json())
.then(file => {
store.commit('setSettings', file);
store.commit('socket/setData', file);
const websocketProtocol = document.location.protocol === 'https:' ? 'wss://' : 'ws://';
const socketClient = new WebSocketClient(websocketProtocol + store.state.socket.hostname + ':' + store.state.socket.port + '/websocket', {
+6 -6
View File
@@ -117,8 +117,8 @@
},
computed: {
...mapState({
events: state => state.events,
helplist: state => state.helplist,
events: state => state.server.events,
helplist: state => state.printer.helplist,
loadings: state => state.loadings,
}),
...mapGetters([
@@ -127,9 +127,9 @@
},
methods: {
doSend() {
this.$store.commit('setLoading', { name: 'loadingSendGcode' });
this.$store.commit('addGcodeResponse', this.gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: this.gcode }, "sendGcode");
//this.$store.commit('setLoading', { name: 'loadingSendGcode' });
this.$store.commit('server/addEvent', this.gcode);
Vue.prototype.$socket.sendObj('printer.gcode.script', { script: this.gcode }, "server/getGcodeRespond");
this.lastCommands.push(this.gcode);
this.gcode = "";
this.lastCommandNumber = null;
@@ -168,7 +168,7 @@
let output = "";
commands.forEach(command => output += "<b>"+command.command+":</b> "+command.description+"<br />");
this.$store.commit('addGcodeResponse', output);
this.$store.commit('server/addEvent', output);
}
}
}
+14 -11
View File
@@ -3,14 +3,14 @@
<v-col class="col-sm-12 col-md-7">
<min-settings-panel v-if="klippy_state === 'ready' && configExists"></min-settings-panel>
<status-panel v-if="klippy_state === 'ready'"></status-panel>
<klippy-state-panel v-if="klippy_state !== 'ready'"></klippy-state-panel>
<klippy-state-panel v-if="socket_connected && klippy_state !== 'ready'"></klippy-state-panel>
<webcam-panel v-if="showDashboardWebcam" class="mt-6"></webcam-panel>
<z-offset-panel class="mt-6" v-if="klippy_state === 'ready'"></z-offset-panel>
<control-panel class="mt-6" v-if="klippy_state === 'ready'"></control-panel>
<extruder-panel class="mt-6" v-if="klippy_state === 'ready'"></extruder-panel>
</v-col>
<v-col class="col-sm-12 col-md-5">
<tools-panel></tools-panel>
<tools-panel v-if="socket_connected && klippy_connected"></tools-panel>
<peripherie-panel class="mt-6" v-if="klippy_state === 'ready'"></peripherie-panel>
<miniconsole-panel class="mt-6" v-if="klippy_state === 'ready' && showDashboardConsole"></miniconsole-panel>
<power-control-panel class="mt-6" v-if="powerDevicesCount > 0"></power-control-panel>
@@ -23,24 +23,27 @@
import ZOffsetPanel from "../components/panels/ZOffsetPanel";
export default {
components: {ZOffsetPanel},
components: { ZOffsetPanel },
data: () => ({
configExists: false
}),
computed: {
...mapState({
socket_connected: state => state.socket.isConnected,
klippy_connected: state => state.server.klippy_connected,
klippy_state: state => state.server.klippy_state,
showDashboardConsole: state => state.gui.dashboard.boolConsole,
klippy_state: state => state.printer.webhooks.state,
config: state => state.printer.configfile.config
config: state => state.printer.configfile.config,
}),
...mapGetters([
'showDashboardWebcam',
'powerDevicesCount',
'existPrinterConfig'
])
...mapGetters({
showDashboardWebcam: 'showDashboardWebcam',
powerDevicesCount: 'server/powerDevices/count',
existPrinterConfig: 'existPrinterConfig'
})
},
created() {
//this.is_ready = (this.klippy_state === "ready") ? true : false;
},
watch: {
config: {
+22 -17
View File
@@ -127,7 +127,7 @@
@dragover="dragOverFilelist($event, item)" @dragleave="dragLeaveFilelist" @drop.prevent.stop="dragDropFilelist($event, item)"
:data-name="item.filename"
>
<td class=" ">
<td class=" " style="width: 32px;">
<v-icon v-if="item.isDirectory">mdi-folder</v-icon>
<v-icon v-if="!item.isDirectory && !(item.thumbnails && item.thumbnails.length > 0)">mdi-file</v-icon>
<img v-if="!item.isDirectory && item.thumbnails && item.thumbnails.length > 0" :src="'data:image/gif;base64,'+(item.thumbnails.length ? item.thumbnails[0].data : '--')" />
@@ -172,9 +172,10 @@
<v-dialog v-model="dialogPrintFile.show" max-width="400">
<v-card>
<v-img
v-if="dialogPrintFile.item.thumbnails && dialogPrintFile.item.thumbnails.find(element => element.width === 400)"
:src="'data:image/gif;base64,'+(dialogPrintFile.item.thumbnails ? dialogPrintFile.item.thumbnails.find(element => element.width === 400).data : '')"
:height="(dialogPrintFile.item.thumbnails ? dialogPrintFile.item.thumbnails.find(element => element.width === 400).height : '')+'px'"
contain
v-if="dialogPrintFile.item.thumbnails && dialogPrintFile.item.thumbnails.find(element => element.width === 300 || element.width === 400)"
:src="'data:image/gif;base64,'+(dialogPrintFile.item.thumbnails ? dialogPrintFile.item.thumbnails.find(element => element.width === 300 || element.width === 400).data : '')"
:height="(dialogPrintFile.item.thumbnails ? dialogPrintFile.item.thumbnails.find(element => element.width === 400 || element.width === 300).height : '')+'px'"
></v-img>
<v-card-title class="headline">Start Job</v-card-title>
<v-card-text>Do you want to start {{ dialogPrintFile.item.filename }}?</v-card-text>
@@ -203,7 +204,7 @@
<v-card>
<v-card-title class="headline">Rename File</v-card-title>
<v-card-text>
<v-text-field label="Name" required v-model="dialogRenameFile.newName"></v-text-field>
<v-text-field label="Name" required v-model="dialogRenameFile.newName" ref="inputFieldNewName"></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
@@ -300,7 +301,7 @@
},
computed: {
...mapState({
filetree: state => state.filetree,
filetree: state => state.files.filetree,
countPerPage: state => state.gui.gcodefiles.countPerPage,
hostname: state => state.socket.hostname,
port: state => state.socket.port,
@@ -344,18 +345,21 @@
let filename = file.name.replace(" ", "_");
formData.append('file', file, (this.currentPath+"/"+filename).substring(7));
this.$store.commit('setLoading', { name: 'loadingGcodeUpload' });
// TODO loading upload
//this.$store.commit('setLoading', { name: 'loadingGcodeUpload' });
return axios.post('//' + this.hostname + ':' + this.port + '/server/files/upload',
formData, {
headers: { 'Content-Type': 'multipart/form-data' }
}
).then((result) => {
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
// TODO loading upload
//this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
toast.success("Upload of "+result.data.result+" successful!");
})
.catch(() => {
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
// TODO loading upload
//this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
toast.error("Cannot upload the file!");
});
},
@@ -363,8 +367,9 @@
this.$refs.fileUpload.click();
},
refreshFileList: function() {
this.$store.commit('setLoading', { name: 'loadingGcodeRefresh' });
this.$socket.sendObj('server.files.get_directory', { path: this.currentPath }, 'getDirectory');
// TODO loading button
//this.$store.commit('setLoading', { name: 'loadingGcodeRefresh' });
this.$socket.sendObj('server.files.get_directory', { path: this.currentPath }, 'files/getDirectory');
},
formatDate(date) {
let tmp2 = new Date(date);
@@ -435,7 +440,7 @@
this.$socket.sendObj('server.files.move', {
source: this.currentPath+"/"+this.dialogRenameFile.item.filename,
dest: this.currentPath+"/"+this.dialogRenameFile.newName
}, 'getPostFileMove');
}, 'files/getMove');
},
renameDirectory(item) {
this.dialogRenameDirectory.item = item;
@@ -447,7 +452,7 @@
this.$socket.sendObj('server.files.move', {
source: this.currentPath+"/"+this.dialogRenameDirectory.item.filename,
dest: this.currentPath+"/"+this.dialogRenameDirectory.newName
}, 'getPostFileMove');
}, 'files/getFileMove');
},
removeFile() {
let filename = (this.currentPath+"/"+this.contextMenu.item.filename);
@@ -466,11 +471,11 @@
createDirectoryAction: function() {
if (this.dialogCreateDirectory.name.length && this.dialogCreateDirectory.name.indexOf(" ") === -1) {
this.dialogCreateDirectory.show = false;
this.$socket.sendObj('server.files.post_directory', { path: this.currentPath+"/"+this.dialogCreateDirectory.name }, 'getPostDirectory');
this.$socket.sendObj('server.files.post_directory', { path: this.currentPath+"/"+this.dialogCreateDirectory.name }, 'files/getCreateDir');
}
},
deleteDirectoryAction: function() {
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'getDeleteDirectory');
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteDir');
},
clickRow: function(item) {
if (!item.isDirectory) {
@@ -485,7 +490,7 @@
this.currentPath = this.currentPath.substr(0, this.currentPath.lastIndexOf("/"));
},
loadPath: function() {
this.$socket.sendObj('server.files.get_directory', { path: this.currentPath }, 'getDirectory');
this.$socket.sendObj('server.files.get_directory', { path: this.currentPath }, 'files/getDirectory');
let dirArray = this.currentPath.split("/");
this.files = findDirectory(this.filetree, dirArray);
if (!this.showHiddenFiles) {
@@ -611,7 +616,7 @@
for (let i = data.pageStart; i < data.pageStop; i++) {
if (items[i] && !items[i].isDirectory && !items[i].metadataPulled) {
let filename = (this.currentPath+"/"+items[i].filename).substring(7);
this.$socket.sendObj("server.files.metadata", { filename: filename }, "getMetadata");
this.$socket.sendObj("server.files.metadata", { filename: filename }, "files/getMetadata");
}
}
+2 -7
View File
@@ -12,11 +12,6 @@
<settings-macros-panel></settings-macros-panel>
</v-col>
</v-row>
<v-fab-transition>
<v-btn fab fixed large bottom right :loading="loadingUpload" @click="saveGuiSettings">
<v-icon>mdi-check</v-icon>
</v-btn>
</v-fab-transition>
</div>
</template>
<script>
@@ -25,12 +20,12 @@
export default {
computed: {
...mapState({
loadingUpload: state => state.socket.loadingSaveGuiConfig,
}),
},
methods: {
...mapActions([
'saveGuiSettings'
]),
}
}
+1 -1
View File
@@ -39,7 +39,7 @@
}),
computed: {
...mapState({
klippy_state: state => state.printer.webhooks.state,
klippy_state: state => state.server.klippy_state,
}),
},
created() {
+1 -1
View File
@@ -1,5 +1,5 @@
export function findDirectory (folder, dirArray) {
if (dirArray.length) {
if (folder !== undefined && dirArray.length) {
if (folder.childrens) folder = folder.childrens;
let parent = folder.find(element => (element.isDirectory && element.filename === dirArray[0]));
+4 -4
View File
@@ -31,7 +31,7 @@ export default class WebSocketClient {
}
passToStore (eventName, event) {
if (!eventName.startsWith('socket_')) { return }
if (!eventName.startsWith('socket/')) { return }
let method = 'dispatch'
let target = eventName
let msg = event
@@ -45,12 +45,12 @@ export default class WebSocketClient {
this.instance = new WebSocket(this.url);
this.instance.onopen = () => {
if (this.store) this.passToStore('socket_on_open', event);
if (this.store) this.passToStore('socket/onOpen', event);
};
this.instance.onclose = (e) => {
window.console.log("Websocket Closed, reconnecting in "+this.reconnectInterval+"ms: ", e.reason);
this.passToStore('socket_on_close', e);
this.passToStore('socket/onClose', e);
setTimeout(() => {
this.connect();
@@ -87,7 +87,7 @@ export default class WebSocketClient {
Object.assign({requestParams: this.wsData.filter(item => item.id === data.id)[0].params }, result)
)
}
} else this.passToStore('socket_on_message', data)
} else this.passToStore('socket/onMessage', data)
}
};
}
-268
View File
@@ -1,263 +1,9 @@
import Vue from 'vue'
import router from "../plugins/router";
import store from "./index";
import axios from "axios";
export default {
socket_on_open ({ commit, dispatch }) {
commit('setConnected');
dispatch('initServer');
},
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_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_klippy_disconnected':
commit('setKlippyDisconnected');
break;
case 'notify_filelist_changed':
switch(data.params[0].action) {
case 'upload_file':
commit('setFileChangeUploadFile', data.params[0]);
break;
case 'delete_file':
commit('setFileChangeDeleteFile', data.params[0]);
break;
case 'move_item':
commit('setFileChangeMoveItem', data.params[0]);
break;
case 'create_dir':
commit('setFileChangeCreateDirectory', data.params[0]);
break;
case 'delete_dir':
commit('setFileChangeDeleteDirectory', data.params[0]);
break;
default:
window.console.error("Unknown filelist_changed action: "+data.params[0].action);
break;
}
break;
case 'notify_metadata_update':
commit('setMetadata', data.params[0]);
break;
default:
if (data.result !== "ok") {
if (
data.error &&
data.error.message !== "Klippy Request Timed Out" &&
data.error.message !== "Klippy Disconnected"
) window.console.error("JSON-RPC: " + data.error.message);
else if (!data.error) window.console.log(data);
}
}
},
initServer() {
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: '/config' }, 'getDirectoryRoot');
Vue.prototype.$socket.sendObj('server.info', {}, 'getServerInfo');
Vue.prototype.$socket.sendObj('server.gcode_store', {}, 'getGcodeStore');
},
initPrinter() {
Vue.prototype.$socket.sendObj('printer.info', {}, 'getKlipperInfo');
// only available with klipper is ready
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'gcodes' }, 'getDirectory');
},
getDirectoryRoot({ commit }, data) {
if (data.files && data.files.filter((file) => file.filename === "gui.json").length) {
fetch('//'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/config/gui.json?time='+Date.now())
.then(res => res.json()).then(file => {
commit('setSettings', file);
});
}
},
saveGuiSettings({ commit, state }) {
commit('setLoadingSaveGuiConfige', true);
let file = new File([JSON.stringify({ webcam: state.webcam, gui: state.gui })], 'gui.json');
let formData = new FormData();
formData.append('file', file);
formData.append('root', 'config');
axios.post('//' + state.socket.hostname + ':' + state.socket.port + '/server/files/upload',
formData, {
headers: { 'Content-Type': 'multipart/form-data' }
}
).then(() => {
commit('setLoadingSaveGuiConfige', false);
}).catch(() => {
window.console.error("Error save gui.json!");
});
},
getServerInfo({ commit, dispatch }, data) {
commit('setServerInfo', {
klippy_connected: data.klippy_connected,
})
if (data.klippy_connected) {
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'config' }, 'getDirectory');
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'config_examples' }, 'getDirectory');
//load plug data
if (data.plugins.includes("power") !== false) Vue.prototype.$socket.sendObj('machine.gpio_power.devices', {}, 'getPowerDevices');
dispatch('initPrinter');
} else {
setTimeout(function(){
Vue.prototype.$socket.sendObj('server.info', {}, 'getServerInfo');
}, 1000);
}
},
getGcodeStore({ commit }, data) {
commit('setGcodeStore', data);
},
getKlipperInfo({ commit }, data) {
commit('setPrinterData', {
hostname: data.hostname,
software_version: data.software_version,
cpu_info: data.cpu_info,
webhooks: {
state: data.state,
state_message: data.state_message,
}
});
Vue.prototype.$socket.sendObj('printer.objects.list', {}, 'getObjectsList');
Vue.prototype.$socket.sendObj('printer.gcode.help', {}, 'getHelpList');
},
getObjectsList({ commit }, data) {
commit('setObjectData', data.objects);
let subscripts = {}
for (let key of data.objects) {
let nameSplit = key.split(" ");
if (
nameSplit[0] !== "gcode_macro" &&
nameSplit[0] !== "menu"
) subscripts = {...subscripts, [key]: null }
}
if (subscripts !== {}) Vue.prototype.$socket.sendObj('printer.objects.subscribe', { objects: subscripts }, "getPrinterData");
Vue.prototype.$socket.sendObj("server.temperature_store", {}, "getHeatersHistory");
},
getPrinterData({ commit }, data) {
if (data.status) commit('setPrinterData', data.status);
},
getHeatersHistory({ commit }, data) {
commit('setHeaterHistory', data);
},
getDirectory({ commit }, data) {
commit('setDirectory', data);
commit('removeLoading', { name: 'loadingGcodeRefresh' });
},
getMetadata({ commit }, data) {
commit('setMetadata', data);
},
getMetadataCurrentFile({ commit }, data) {
commit('setMetadataCurrentFile', data);
},
getPostDirectory({ commit }, data) {
if (data.error) {
Vue.$toast.error(data.error.message);
} else if (data.result === "ok") {
let newPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
Vue.$toast.success("Successfully created "+newPath);
commit('voidMutation');
}
},
getDeleteDirectory({ commit }, data) {
if (data.error) {
Vue.$toast.error(data.error.message);
} else if (data.result === "ok") {
let delPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
Vue.$toast.success("Successfully deleted "+delPath);
commit('voidMutation');
}
},
getPostFileMove({ commit }, data) {
if (data.error) {
Vue.$toast.error(data.error.message);
} else if (data.result === "ok") {
let filename = data.requestParams.dest.substr(data.requestParams.dest.lastIndexOf("/")).replace("/", "");
let sourceDir = data.requestParams.dest.substr(0, data.requestParams.dest.lastIndexOf("/"));
let destDir = data.requestParams.dest.substr(0, data.requestParams.dest.lastIndexOf("/"));
if (sourceDir === destDir) Vue.$toast.success("Successfully renamed "+filename);
else Vue.$toast.success("Successfully moved "+filename);
commit('voidMutation');
}
},
getHelpList({ commit }, data) {
commit('setHelpList', data);
},
getPowerDevices({ commit }, data) {
if (data.error) {
if (data.error.code !== -32601) {
Vue.$toast.error(data.error.message);
}
} else {
commit('setPowerDevices', data.devices);
Vue.prototype.$socket.sendObj('machine.gpio_power.status', {}, 'getPowerDevicesStatus');
}
},
getPowerDevicesStatus({ commit }, data) {
if (data.error) {
if (data.error.code !== -32601) {
Vue.$toast.error(data.error.message);
}
} else {
commit('setPowerDevicesStatus', data);
}
},
setHeaterChartVisibility({ commit, dispatch }, data) {
commit('setHeaterChartVisibility', data);
@@ -294,11 +40,6 @@ export default {
commit('removeLoading', { name: 'statusPrintReprint' });
},
sendGcode({commit}, data) {
commit('removeLoading', { name: 'loadingSendGcode' });
commit('addGcodeResponse', data);
},
responseHome({commit}) {
commit('removeLoading', { name: 'controlHomeAll' });
},
@@ -331,11 +72,6 @@ export default {
commit('setLoadingRestartFirmware', false);
},
responseEndstopStatus({ commit }, data) {
commit('setLoadingEndstopStatus', false);
commit('setEndstopStatus', data);
},
respondeExtruderRetract({commit}) {
commit('removeLoading', { name: 'extruderRetract' });
},
@@ -387,8 +123,4 @@ export default {
switchToDashboard() {
router.push("/");
},
setSettings({ commit }, data) {
commit('setSettings', data);
},
}
+65
View File
@@ -0,0 +1,65 @@
import Vue from 'vue'
export default {
reset({ commit }) {
commit('reset')
},
getDirectory({ commit }, payload) {
commit('setDirectory', payload)
//TODO refresh reload
//commit('removeLoading', { name: 'loadingGcodeRefresh' })
},
getMetadata({ commit, rootState }, payload) {
if (payload !== undefined && payload.filename !== "") {
if (payload.filename === rootState.printer.print_stats.filename) {
this.commit('getMetadataCurrentFile', payload);
}
commit('setMetadata', payload);
}
},
getMetadataCurrentFile({ commit }, payload) {
commit('printer/clearCurrentFile', null, { root: true });
commit('printer/setData', { current_file: payload }, { root: true });
},
getMove({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else if (payload.result === "ok") {
let filename = payload.requestParams.dest.substr(payload.requestParams.dest.lastIndexOf("/")).replace("/", "");
let sourceDir = payload.requestParams.dest.substr(0, payload.requestParams.dest.lastIndexOf("/"));
let destDir = payload.requestParams.dest.substr(0, payload.requestParams.dest.lastIndexOf("/"));
if (sourceDir === destDir) Vue.$toast.success("Successfully renamed "+filename);
else Vue.$toast.success("Successfully moved "+filename);
commit('void', null, { root: true });
}
},
getCreateDir({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else if (payload.result === "ok") {
let newPath = payload.requestParams.path.substr(payload.requestParams.path.lastIndexOf("/")+1);
Vue.$toast.success("Successfully created "+newPath);
commit('void', null, { root: true });
}
},
getDeleteDir({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else if (payload.result === "ok") {
let delPath = payload.requestParams.path.substr(payload.requestParams.path.lastIndexOf("/")+1);
Vue.$toast.success("Successfully deleted "+delPath);
commit('void', null, { root: true });
}
},
}
+3
View File
@@ -0,0 +1,3 @@
export default {
}
+39
View File
@@ -0,0 +1,39 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
const getDefaultState = () => {
return {
filetree: [
{
isDirectory: true,
filename: 'gcodes',
modified: new Date(),
childrens: []
},
{
isDirectory: true,
filename: 'config_examples',
modified: new Date(),
childrens: []
},
{
isDirectory: true,
filename: 'config',
modified: new Date(),
childrens: []
}
],
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
+170
View File
@@ -0,0 +1,170 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
import { findDirectory } from "@/plugins/helpers"
import store from "@/store";
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setDirectory(state, payload) {
let parent = undefined;
if (payload && payload.requestParams && payload.requestParams.path) {
let arrayPath = payload.requestParams.path.split("/")
parent = findDirectory(state.filetree, arrayPath)
}
if (parent === undefined) parent = state.filetree
if (Array.isArray(parent) && parent.length) {
for (const [key, item] of Object.entries(parent)) {
if (
item.isDirectory &&
payload.dirs !== undefined &&
payload.dirs.length > 0 &&
payload.dirs.findIndex(element => element.dirname === item.filename) < 0
) parent.splice(key, 1)
else if (!item.isDirectory && payload.files.findIndex(element => element.filename === item.filename) < 0) parent.splice(key, 1)
}
}
if (payload.dirs && payload.dirs.length) {
for (let dir of payload.dirs) {
if (!parent.find(element => (element.isDirectory === true && element.filename === dir.dirname))) {
parent.push({
isDirectory: true,
filename: dir.dirname,
modified: new Date(dir.modified * 1000),
childrens: [],
})
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: payload.requestParams.path+'/'+dir.dirname }, 'files/getDirectory');
}
}
}
if (payload.files && payload.files.length) {
for (let file of payload.files) {
if (!parent.find(element => (element.isDirectory === false && element.filename === file.filename))) {
parent.push({
isDirectory: false,
filename: file.filename,
modified: new Date(file.modified * 1000),
size: parseInt(file.size),
metadataPulled: false,
})
}
if (file.filename === "gui.json" && payload.requestParams.path === "config") {
fetch('//'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/config/gui.json?time='+Date.now())
.then(res => res.json()).then(file => {
this.commit('gui/setData', file, { root: true });
})
}
}
}
},
setMetadata(state, payload) {
let filename = "gcodes/"+payload.filename;
let dirArray = filename.split("/");
filename = dirArray[dirArray.length-1];
let path = findDirectory(state.filetree, dirArray);
let index = path.findIndex(element => element.filename === filename);
if (index >= 0 && path[index]) {
const safeDefault = (value, def = undefined) => value ? value : def;
let newData = {
estimated_time: safeDefault(payload.estimated_time),
filament_total: safeDefault(payload.filament_total),
first_layer_height: safeDefault(payload.first_layer_height),
first_layer_bed_temp: safeDefault(payload.first_layer_bed_temp),
first_layer_extr_temp: safeDefault(payload.first_layer_extr_temp),
layer_height: safeDefault(payload.layer_height),
object_height: safeDefault(payload.object_height),
slicer: safeDefault(payload.slicer),
slicer_version: safeDefault(payload.slicer_version),
thumbnails: safeDefault(payload.thumbnails),
metapayloadPulled: true,
modified: new Date(payload.modified * 1000),
size: parseInt(payload.size),
};
let newObject = Object.assign(path[index], newData);
Vue.set(path, index, newObject);
}
},
setUploadFile(state, payload) {
let filename = payload.item.path;
if (payload.item.path.lastIndexOf("/") >= 0) filename = payload.item.path.substr(payload.item.path.lastIndexOf("/")).replace("/", "");
let path = payload.item.path.substr(0, payload.item.path.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (payload.item.root+"/"+path).split("/"));
if (parent) {
if (parent.findIndex(element => (!element.isDirectory && element.filename === filename)) < 0) {
let modified = new Date(payload.item.modified * 1000);
parent.push({
isDirectory: false,
filename: filename,
modified: modified,
size: payload.item.size,
metadataPulled: false,
});
}
}
},
setMoveItem(state, payload) {
let filenameOld = payload.source_item.path.substr(payload.source_item.path.lastIndexOf("/")+1);
let oldPath = payload.source_item.path.substr(0, payload.source_item.path.lastIndexOf("/") + 1);
let filenameNew = payload.item.path.substr(payload.item.path.lastIndexOf("/")+1);
let newPath = payload.item.path.substr(0, payload.item.path.lastIndexOf("/") + 1);
oldPath = findDirectory(state.filetree, (payload.source_item.root+"/"+oldPath).split("/"));
let indexFile = oldPath.findIndex(element => element.filename === filenameOld);
if (indexFile >= 0 && oldPath[indexFile]) {
let file = oldPath.splice(indexFile, 1)[0];
file.filename = filenameNew;
newPath = findDirectory(state.filetree, (payload.item.root+"/"+newPath).split("/"));
newPath.push(file);
}
},
setDeleteFile(state, payload) {
let currentPath = payload.item.path.substr(0, payload.item.path.lastIndexOf("/"));
let delPath = payload.item.path.substr(payload.item.path.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (payload.item.root+"/"+currentPath).split("/"));
let index = currentPath.findIndex(element => element.filename === delPath);
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
},
setCreateDir(state, payload) {
let dirname = payload.item.path.substr(payload.item.path.lastIndexOf("/") + 1);
let path = payload.item.path.substr(0, payload.item.path.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (payload.item.root+"/"+path).split("/"));
if (parent) {
parent.push({
isDirectory: true,
filename: dirname,
modified: new Date(),
childrens: [],
});
}
},
setDeleteDir(state, payload) {
let currentPath = payload.item.path.substr(0, payload.item.path.lastIndexOf("/"));
let delPath = payload.item.path.substr(payload.item.path.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (payload.item.root+"/"+currentPath).split("/"));
let index = currentPath.findIndex(element => element.filename === delPath);
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
},
}
+3 -29
View File
@@ -118,10 +118,6 @@ export default {
return 0;
},
fan: state => {
return Object.entries(state.printer).indexOf("fan") ? state.printer.fan : false;
},
is_printing: state => {
return (["printing", "paused"].includes(state.printer.print_stats.state));
},
@@ -148,22 +144,6 @@ export default {
return array.sort(caseInsensitiveNameSort);
},
getAllMacros: state => {
let array = [];
for (let prop in state.printer.configfile.config) {
if (prop.startsWith("gcode_macro") &&
!Object.hasOwnProperty.call(state.printer.configfile.config[prop], "rename_existing")) {
array.push({
"name": prop.replace("gcode_macro ", ""),
"prop": state.printer.configfile.config[prop]
});
}
}
return array.sort(caseInsensitiveNameSort);
},
getFilamentSwitchSensors: state => {
let sensors = [];
@@ -206,7 +186,7 @@ export default {
getTitle: state => {
if (state.socket.isConnected) {
if (state.printer.webhooks.state !== "ready") return "ERROR";
if (state.server.klippy_state !== "ready") return "ERROR";
else if (state.printer.print_stats.state === "paused") return "Pause Print";
else if (state.printer.print_stats.state === "printing") return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.print_stats.filename;
else if (state.printer.print_stats.state === "complete") return "Complete - "+state.printer.print_stats.filename;
@@ -250,6 +230,8 @@ export default {
return false;
},
checkConfigVirtualSdcard: state => {
return 'virtual_sdcard' in state.printer.configfile.config;
},
@@ -273,12 +255,4 @@ export default {
checkConfigMacroCancel: state => {
return Object.keys(state.printer.configfile.config).findIndex(key => key.toLowerCase() === 'gcode_macro cancel_print') !== -1;
},
powerDevices: state => {
return state.power.devices;
},
powerDevicesCount: (state, getters) => {
return getters.powerDevices.length;
},
}
+34
View File
@@ -0,0 +1,34 @@
import axios from "axios";
export default {
reset({ commit }) {
commit('reset')
},
getData({ commit }, payload) {
commit('setData', payload)
},
setSettings({ commit, dispatch }, payload) {
commit('setSettings', payload)
dispatch('upload')
},
upload({ state, rootState }) {
let file = new File([JSON.stringify({ state })], 'gui.json');
let formData = new FormData();
formData.append('file', file);
formData.append('root', 'config');
axios.post('//' + rootState.socket.hostname + ':' + rootState.socket.port + '/server/files/upload',
formData, {
headers: { 'Content-Type': 'multipart/form-data' }
}
).then(() => {
window.console.info("gui.json successfully uploaded")
}).catch(() => {
window.console.error("Error save gui.json!")
});
},
}
+3
View File
@@ -0,0 +1,3 @@
export default {
}
+55
View File
@@ -0,0 +1,55 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
const getDefaultState = () => {
return {
general: {
printername: "",
},
dashboard: {
boolWebcam: true,
boolTempchart: true,
boolConsole: false,
hiddenMacros: [],
hiddenTempChart: [],
},
webcam: {
url: "",
rotate: false,
rotateDegrees: 90,
flipX: false,
flipY: false,
bool: false,
},
gcodefiles: {
countPerPage: 10,
showHiddenFiles: true,
showMetadata: {
size: true,
modified: true,
object_height: true,
layer_height: true,
filament_total: true,
estimated_time: true,
slicer: true,
}
},
settings: {
configfiles: {
countPerPage: 10,
}
}
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
+31
View File
@@ -0,0 +1,31 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
const objectAssignDeep = require(`object-assign-deep`);
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setData(state, payload) {
if ("state" in payload) payload = payload.state
if ("gui" in payload) payload = payload.gui
Object.entries(payload).forEach(([key, value]) => {
Vue.set(state, key, value)
})
},
// override special setting
setSettings(state, data) {
state = objectAssignDeep(state, data)
},
setHeaterChartVisibility(state, payload) {
let index = state.dashboard.hiddenTempChart.indexOf(payload.name.toUpperCase())
if (payload.hidden && index === -1) state.dashboard.hiddenTempChart.push(payload.name.toUpperCase())
else if (payload.hidden !== true && index > -1) state.dashboard.hiddenTempChart.splice(index, 1)
},
}
+13 -82
View File
@@ -4,7 +4,13 @@ import VueToast from 'vue-toast-notification';
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
// load modules
import socket from './socket'
import server from './server'
import printer from './printer'
import files from './files'
import gui from './gui'
Vue.use(Vuex);
Vue.use(VueToast);
@@ -12,89 +18,14 @@ Vue.use(VueToast);
export default new Vuex.Store({
state: {
packageVersion: process.env.PACKAGE_VERSION || '0.0.0',
socket: {
hostname: window.location.hostname,
port: window.location.port,
reconnectInterval: 3000,
isConnected: false,
klippy_conntected: null,
loadingRestart: false,
loadingRestartFirmware: false,
loadingRebootHost: false,
loadingShutdownHost: false,
loadingSaveGuiConfig: false,
loadingEndstopStatus: false,
},
gui: {
general: {
printername: "",
},
dashboard: {
boolWebcam: true,
boolTempchart: true,
boolConsole: false,
hiddenMacros: [],
hiddenTempChart: [],
},
webcam: {
url: "",
rotate: false,
rotateDegrees: 90,
flipX: false,
flipY: false,
bool: false,
},
gcodefiles: {
countPerPage: 10,
showHiddenFiles: true,
showMetadata: {
size: true,
modified: true,
object_height: true,
layer_height: true,
filament_total: true,
estimated_time: true,
slicer: true,
}
},
settings: {
configfiles: {
countPerPage: 10,
}
}
},
loadings: [],
printer: printer,
object: [],
temperaturChart: [],
power: {
devices: []
},
helplist: [],
filetree: [
{
isDirectory: true,
filename: 'gcodes',
modified: new Date(),
childrens: []
},
{
isDirectory: true,
filename: 'config_examples',
modified: new Date(),
childrens: []
},
{
isDirectory: true,
filename: 'config',
modified: new Date(),
childrens: []
}
],
events: []
},
modules: {
socket,
server,
printer,
files,
gui,
},
getters: getters,
mutations: mutations,
actions: actions
+5 -523
View File
@@ -1,483 +1,9 @@
import Vue from "vue";
const objectAssignDeep = require(`object-assign-deep`);
import { findDirectory } from '../plugins/helpers';
import { colorArray, colorChamber, colorHeaterBed/*, temperaturChartSampleLength*/ } from './variables';
import defaultPrinter from './printer';
export default {
setConnected (state) {
state.socket.isConnected = true;
//TODO reset store
},
setDisconnected (state) {
state.socket.isConnected = false;
},
setKlippyDisconnected(state) {
Vue.set(state.printer.configfile, 'config', {});
Vue.set(state, '', {
webhooks: {
state: 'disconnected',
state_message: 'Disconnected...'
}
});
},
resetPrinter(state) {
//TODO check reset in storage
let printer = { ...defaultPrinter };
Object.assign(printer, { webhooks: state.printer.webhooks });
Vue.set(state, "printer", printer);
Vue.set(state, "helplist", []);
Vue.set(state, "loadings", []);
this.dispatch("initPrinter");
},
setServerInfo(state, data) {
Object.entries(data).forEach(([key, value]) => {
Vue.set(state.socket, key, value);
});
},
setPrinterData(state, data) {
if (data.requestParams) delete data.requestParams;
let now = Date.now();
Object.entries(data).forEach(([key, value]) => {
//update/restart printer state
if (
key === "webhooks" &&
state.printer.webhooks.state !== "ready" &&
state.printer.webhooks.state !== "" &&
value.state === "ready"
) this.commit("resetPrinter");
//update printer state
if (typeof(value) === "object") {
Vue.set(state.printer, key, {
...state.printer[key],
...value
});
} else Vue.set(state.printer, key, value);
//update heaters
if (
Array.isArray(state.printer.heaters.available_heaters) &&
state.printer.heaters.available_heaters.length
) {
let keySplit = key.split(" ");
if (
state.printer.heaters.available_heaters.includes(key) ||
keySplit[0] === "temperature_fan" ||
keySplit[0] === "temperature_sensor" ||
keySplit[0] === "temperature_probe") {
if (keySplit[0] === "temperature_fan") key = keySplit[1];
else if (keySplit[0] === "temperature_sensor") key = keySplit[1];
else if (keySplit[0] === "heater_generic") key = keySplit[1];
else if (keySplit[0] === "temperature_probe") key = "probe";
this.commit('addTemperatureChartValue', { name: key, value: value, time: now });
}
}
});
},
setHeaterHistory(state, data) {
let now = new Date();
if (data !== undefined) {
Object.entries(data).sort().forEach(([key, datasets]) => {
let keySplit = key.split(" ");
if (keySplit.length > 1) key = keySplit[1];
if (keySplit[0] === "temperature_probe") key = "probe";
if (datasets.temperatures) {
let max = datasets.temperatures.length;
for (let i = 0; i < max; i++) {
let time = new Date(now.getTime() - 1000 * (max - i));
this.commit('addTemperatureChartValue', {
name: key,
value: {
temperature: datasets.temperatures[i],
target: datasets.targets[i],
},
type: keySplit[0],
time: time
});
}
}
});
}
},
addTemperatureChartValue(state, payload) {
// definations for delete old entries
let timeOld = new Date().getTime() - (1000 * 60 * 10);
let minResolution = 1000; // value in ms
let deletedIndex;
let index = state.temperaturChart.findIndex(element => element.label === payload.name);
if (index < 0) {
this.commit('addTemperatureChartHeater', {
name: payload.name,
type: payload.type,
});
index = state.temperaturChart.findIndex(element => element.label === payload.name);
}
let index_target = state.temperaturChart.findIndex(element => element.label === payload.name+'_target');
// update current temp in temperature chart
if (index >= 0) {
let temperature = 0;
if (payload.value.temperature !== undefined) temperature = payload.value.temperature.toFixed(1);
else if (state.temperaturChart[index].data.length) temperature = state.temperaturChart[index].data[state.temperaturChart[index].data.length - 1].y;
if (
(state.temperaturChart[index].data.length && (
(
state.temperaturChart[index].data[state.temperaturChart[index].data.length - 1].y !== temperature ||
payload.time-state.temperaturChart[index].data[state.temperaturChart[index].data.length - 1].x > minResolution
) && state.temperaturChart[index].data[state.temperaturChart[index].data.length - 1].x < payload.time
)) || state.temperaturChart[index].data.length === 0
) {
state.temperaturChart[index].data.push({
x: payload.time,
y: temperature
});
}
// delete old entries
while ((deletedIndex = state.temperaturChart[index].data.findIndex(item => item.x < timeOld)) > -1) {
state.temperaturChart[index].data.splice(deletedIndex, 1);
}
}
// update target temp in temperature chart
if (index_target >= 0) {
let target = 0;
if (payload.value.target !== undefined) target = payload.value.target.toFixed(1);
else if (state.temperaturChart[index_target].data.length) target = state.temperaturChart[index_target].data[state.temperaturChart[index_target].data.length - 1].y;
if (
(state.temperaturChart[index_target].data.length && (
(
state.temperaturChart[index_target].data[state.temperaturChart[index_target].data.length - 1].y !== target ||
payload.time-state.temperaturChart[index_target].data[state.temperaturChart[index_target].data.length - 1].x > minResolution
) && state.temperaturChart[index_target].data[state.temperaturChart[index_target].data.length - 1].x < payload.time
)) || state.temperaturChart[index_target].data.length === 0
) {
state.temperaturChart[index_target].data.push({
x: payload.time,
y: target
});
}
// delete old entries
while ((deletedIndex = state.temperaturChart[index_target].data.findIndex(item => item.x < timeOld)) > -1) {
state.temperaturChart[index_target].data.splice(deletedIndex, 1);
}
}
},
addTemperatureChartHeater(state, payload) {
let color = '';
switch (payload.name) {
case 'heater_bed': color = colorHeaterBed; break;
case 'chamber': color = colorChamber; break;
default: color = colorArray[state.temperaturChart.filter(element => !element.label.endsWith("_target") && element.label !== "heater_bed" && element.label !== "chamber").length]; break;
}
let hidden = state.gui.dashboard.hiddenTempChart.indexOf(payload.name.toUpperCase()) >= 0 ? true : null;
state.temperaturChart.push({
label: payload.name,
data: [],
borderColor: color,
backgroundColor: color,
pointBackgroundColor: color,
fill: false,
borderWidth: 2,
hidden: hidden,
});
if (payload.type !== "temperature_sensor") {
state.temperaturChart.push({
label: payload.name+"_target",
data: [],
borderColor: color,
backgroundColor: color+'20',
pointBackgroundColor: color,
fill: true,
borderWidth: 0,
hidden: hidden,
});
}
},
setHeaterChartVisibility(state, data) {
let index = state.gui.dashboard.hiddenTempChart.indexOf(data.name.toUpperCase());
if (data.hidden && index === -1) state.gui.dashboard.hiddenTempChart.push(data.name.toUpperCase())
else if (data.hidden !== true && index > -1) state.gui.dashboard.hiddenTempChart.splice(index, 1);
},
setSettings(state, data) {
state = objectAssignDeep(state, data);
},
setObjectData(state, data) {
Object.assign(state.object, data);
},
setFileChangeUploadFile(state, data) {
let filename = data.item.path;
if (data.item.path.lastIndexOf("/") >= 0) filename = data.item.path.substr(data.item.path.lastIndexOf("/")).replace("/", "");
let path = data.item.path.substr(0, data.item.path.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (data.item.root+"/"+path).split("/"));
if (parent) {
if (parent.findIndex(element => (!element.isDirectory && element.filename === filename)) < 0) {
let modified = new Date(data.item.modified * 1000);
parent.push({
isDirectory: false,
filename: filename,
modified: modified,
size: data.item.size,
metadataPulled: false,
});
}
}
},
setFileChangeDeleteFile(state, data) {
let currentPath = data.item.path.substr(0, data.item.path.lastIndexOf("/"));
let delPath = data.item.path.substr(data.item.path.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (data.item.root+"/"+currentPath).split("/"));
let index = currentPath.findIndex(element => element.filename === delPath);
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
},
setFileChangeMoveItem(state, data) {
let filenameOld = data.source_item.path.substr(data.source_item.path.lastIndexOf("/")+1);
let oldPath = data.source_item.path.substr(0, data.source_item.path.lastIndexOf("/") + 1);
let filenameNew = data.item.path.substr(data.item.path.lastIndexOf("/")+1);
let newPath = data.item.path.substr(0, data.item.path.lastIndexOf("/") + 1);
oldPath = findDirectory(state.filetree, (data.source_item.root+"/"+oldPath).split("/"));
let indexFile = oldPath.findIndex(element => element.filename === filenameOld);
if (indexFile >= 0 && oldPath[indexFile]) {
let file = oldPath.splice(indexFile, 1)[0];
file.filename = filenameNew;
newPath = findDirectory(state.filetree, (data.item.root+"/"+newPath).split("/"));
newPath.push(file);
}
},
setFileChangeCreateDirectory(state, data) {
let dirname = data.item.path.substr(data.item.path.lastIndexOf("/") + 1);
let path = data.item.path.substr(0, data.item.path.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (data.item.root+"/"+path).split("/"));
if (parent) {
parent.push({
isDirectory: true,
filename: dirname,
modified: new Date(),
childrens: [],
});
}
},
setFileChangeDeleteDirectory(state, data) {
let currentPath = data.item.path.substr(0, data.item.path.lastIndexOf("/"));
let delPath = data.item.path.substr(data.item.path.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (data.item.root+"/"+currentPath).split("/"));
let index = currentPath.findIndex(element => element.filename === delPath);
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
},
setDirectory(state, data) {
let parent = undefined;
//let parentPath = "";
if (data && data.requestParams && data.requestParams.path) {
let arrayPath = data.requestParams.path.split("/");
parent = findDirectory(state.filetree, arrayPath);
//parentPath = data.requestParams.path;
}
if (parent === undefined) parent = state.filetree;
if (Array.isArray(parent) && parent.length) {
for (const [key, item] of Object.entries(parent)) {
if (
item.isDirectory &&
data.dirs !== undefined &&
data.dirs.length > 0 &&
data.dirs.findIndex(element => element.dirname === item.filename) < 0
) parent.splice(key, 1);
else if (!item.isDirectory && data.files.findIndex(element => element.filename === item.filename) < 0) parent.splice(key, 1);
}
}
if (data.dirs && data.dirs.length) {
for (let dir of data.dirs) {
if (!parent.find(element => (element.isDirectory === true && element.filename === dir.dirname))) {
parent.push({
isDirectory: true,
filename: dir.dirname,
modified: new Date(dir.modified * 1000),
childrens: [],
});
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: data.requestParams.path+'/'+dir.dirname }, 'getDirectory');
}
}
}
if (data.files && data.files.length) {
for (let file of data.files) {
if (file.filename === "gui.json") continue;
if (!parent.find(element => (element.isDirectory === false && element.filename === file.filename))) {
parent.push({
isDirectory: false,
filename: file.filename,
modified: new Date(file.modified * 1000),
size: parseInt(file.size),
metadataPulled: false,
});
}
}
}
},
setMetadata(state, data) {
if (data !== undefined && data.filename !== "") {
if (data.filename === state.printer.print_stats.filename) {
this.commit('setMetadataCurrentFile', data );
}
let filename = "gcodes/"+data.filename;
let dirArray = filename.split("/");
filename = dirArray[dirArray.length-1];
let path = findDirectory(state.filetree, dirArray);
let index = path.findIndex(element => element.filename === filename);
if (index >= 0 && path[index]) {
const safeDefault = (value, def = undefined) => value ? value : def;
let newData = {
estimated_time: safeDefault(data.estimated_time),
filament_total: safeDefault(data.filament_total),
first_layer_height: safeDefault(data.first_layer_height),
first_layer_bed_temp: safeDefault(data.first_layer_bed_temp),
first_layer_extr_temp: safeDefault(data.first_layer_extr_temp),
layer_height: safeDefault(data.layer_height),
object_height: safeDefault(data.object_height),
slicer: safeDefault(data.slicer),
slicer_version: safeDefault(data.slicer_version),
thumbnails: safeDefault(data.thumbnails),
metadataPulled: true,
modified: new Date(data.modified * 1000),
size: parseInt(data.size),
};
let newObject = Object.assign(path[index], newData);
Vue.set(path, index, newObject);
}
}
},
setMetadataCurrentFile(state, data) {
if (data !== undefined && data.filename !== "") {
state.printer.current_file.thumbnails = [];
Vue.set(state.printer, 'current_file', data);
}
},
renameMetadataFilename(state, data) {
let sourceDirArray = data.source.split("/");
let sourceFilename = sourceDirArray[sourceDirArray.length-1];
sourceDirArray.splice(-1,1);
let sourcePath = findDirectory(state.filetree, sourceDirArray);
let destDirArray = data.dest.split("/");
let destFilename = destDirArray[destDirArray.length-1];
let index = sourcePath.findIndex(element => element.filename === sourceFilename);
if (destFilename === sourceFilename) {
destDirArray.splice(-1,1);
if (destDirArray[destDirArray.length-1] === "..") destDirArray.splice(-2,2);
let destPath = findDirectory(state.filetree, destDirArray);
destPath.push(sourcePath[index]);
sourcePath.splice(index, 1);
} else if (index >= 0 && sourcePath[index]) {
let newObject = Object.assign(sourcePath[index], { filename: destFilename });
Vue.set(sourcePath, index, newObject);
}
},
setHelpList(state, data) {
state.helplist = [];
for (let [command, description] of Object.entries(data)) {
state.helplist.push({
'commandLow': command.toLowerCase(),
'command': command,
'description': description,
});
}
},
setGcodeStore(state, data) {
data.gcode_store.forEach(message => {
state.events.push({
date: new Date(message.time * 1000),
message: message.message
});
});
},
addGcodeResponse(state, data) {
let message = data;
if (message.result !== undefined) message = message.result;
else if (message.error !== undefined) message = message.error.message;
state.events.push({
date: new Date(),
message: message
});
},
setEndstopStatus(state, data) {
delete data.requestParams;
Vue.set(state.printer, 'endstops', data);
},
setLoading(state, data) {
/*setLoading(state, data) {
if (!state.loadings.includes(data.name)) {
state.loadings.push(data.name);
}
@@ -485,28 +11,9 @@ export default {
removeLoading(state, data) {
state.loadings = state.loadings.filter(function(ele){ return ele !== data.name; });
},
},*/
setPrinterStatusDetails(state, data) {
if (data !== undefined && data.is_ready !== undefined) {
state.socket.error_detected = data.error_detected;
state.socket.is_ready = data.is_ready;
state.socket.klippy_message = data.message;
}
},
setPowerDevices(state, data) {
Vue.set(state.power, 'devices', data);
},
setPowerDevicesStatus(state, data) {
for (let key in data) {
let devIdx = state.power.devices.findIndex(device => device.id === key);
if (devIdx >= 0) {
Vue.set(state.power.devices[devIdx], 'status', data[key] === 'off' ? 0 : 1);
}
}
},
setGuiGcodefilesMetadata(state, data) {
Vue.set(state.gui.gcodefiles.showMetadata, data.name, data.value);
@@ -517,36 +24,11 @@ export default {
Vue.set(state.gui.gcodefiles, "showHiddenFiles", value);
},
setLoadingRestart(state, value) {
state.socket.loadingRestart = value;
reportError(state, payload) {
window.console.log(payload);
},
setLoadingRestartFirmware(state, value) {
state.socket.loadingRestartFirmware = value;
},
setLoadingRebootHost(state, value) {
state.socket.loadingRebootHost = value;
},
setLoadingShutdownHost(state, value) {
state.socket.loadingShutdownHost = value;
},
setLoadingSaveGuiConfige(state, value) {
state.socket.loadingSaveGuiConfig = value;
},
setLoadingEndstopStatus(state, value) {
state.socket.loadingEndstopStatus = value;
},
reportError(state, data) {
//Vue.$toast.error(data.message);
window.console.log(data);
},
voidMutation() {
void() {
},
}
-65
View File
@@ -1,65 +0,0 @@
export default {
software_version: '',
hostname: '',
cpu_info: '',
webhooks: {
state: '',
state_message: '',
},
heaters: {
available_heaters: [],
},
toolhead: {
position: [],
homed_axes: "",
extruder: "",
status: "",
print_time: 0,
printing_time: 0,
estimated_print_time: 0,
max_velocity: 0,
max_accel: 0,
max_accel_to_decel: 0,
square_corner_velocity: 0,
},
pause_resume: {
is_paused: false
},
idle_timeout: {
printing_time: 0,
state: "",
},
display_status: {
message: null,
progress: 0,
},
virtual_sdcard: {
progress: 0,
is_active: false,
file_position: 0,
},
print_stats: {
print_duration: 0,
filament_used: 0,
total_duration: 0,
filename: "",
state: "",
message: ""
},
current_file: {
},
gcode_move: {
extrude_factor: 1,
speed_factor: 1,
homing_origin: [0,0,0,0],
absolute_coordinates: true,
absolute_extrude: true,
speed: 0,
},
endstops: {},
configfile: {
config: {},
config_changed: false,
}
}
+62
View File
@@ -0,0 +1,62 @@
import Vue from 'vue'
export default {
reset({ commit }) {
commit('reset')
},
init() {
Vue.prototype.$socket.sendObj('printer.info', {}, 'printer/getInfo')
// only available with klipper is ready
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'gcodes' }, 'files/getDirectory')
},
getInfo({ commit }, preload) {
commit('server/setData', {
klippy_state: preload.state,
klippy_message: preload.state_message,
}, { root: true })
commit('setData', {
hostname: preload.hostname,
software_version: preload.software_version,
cpu_info: preload.cpu_info,
})
Vue.prototype.$socket.sendObj('printer.objects.list', {}, 'printer/getObjectsList')
Vue.prototype.$socket.sendObj('printer.gcode.help', {}, 'printer/getHelpList')
},
getObjectsList({ commit }, payload) {
let subscripts = {}
const blocklist = [
"gcode_macro",
"menu",
];
for (let key of payload.objects) {
let nameSplit = key.split(" ");
if (!blocklist.includes(nameSplit[0])) subscripts = {...subscripts, [key]: null }
}
if (subscripts !== {}) Vue.prototype.$socket.sendObj('printer.objects.subscribe', { objects: subscripts }, "printer/getData");
Vue.prototype.$socket.sendObj("server.temperature_store", {}, "printer/tempHistory/getHistory");
commit('void', null, { root: true })
},
getData({ commit }, payload) {
commit('setData', payload)
},
getHelpList({ commit }, payload) {
commit('setHelplist', payload)
},
getEndstopStatus({ commit }, payload) {
//commit('setLoadingEndstopStatus', false);
commit('setEndstopStatus', payload);
},
}
+90
View File
@@ -0,0 +1,90 @@
export default {
getPartFanSpeed: state => {
return "fan" in state ? state.fan.speed : 0;
},
getFans: state => {
let fans = [];
const supportedFans = [
'temperature_fan',
'controller_fan',
'heater_fan',
'fan_generic',
'fan',
]
const controllableFans = [
'fan_generic',
'fan',
]
for (const [key, value] of Object.entries(state)) {
let nameSplit = key.split(" ")
if (supportedFans.includes(nameSplit[0])) {
let name = nameSplit.length > 1 ? nameSplit[1] : nameSplit[0]
fans.push({
name: name,
type: nameSplit[0],
speed: 'speed' in value ? value.speed : 0,
controllable: controllableFans.includes(nameSplit[0]),
})
}
}
return fans.sort((a, b) => {
if (a.controllable < b.controllable) return 1;
if (a.controllable > b.controllable) return -1;
let nameA = a.name.toUpperCase();
let nameB = b.name.toUpperCase();
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
})
},
getAllMacros: state => {
let array = []
for (let prop in state.configfile.config) {
if (prop.startsWith("gcode_macro") &&
!prop.startsWith("gcode_macro _") &&
!Object.hasOwnProperty.call(state.configfile.config[prop], "rename_existing")) {
array.push({
"name": prop.replace("gcode_macro ", ""),
"prop": state.configfile.config[prop]
})
}
}
return array.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;
})
},
getExtrudePossible: state => {
if ("toolhead" in state) {
let extruderName = state.toolhead.extruder;
if (extruderName in state && extruderName in state.configfile.config) {
let extruder = state[extruderName];
let extruderConfig = state.configfile.config[extruderName];
return ("min_extrude_temp" in extruderConfig && extruderConfig["min_extrude_temp"] <= extruder["temperature"])
}
}
return true;
},
}
+85
View File
@@ -0,0 +1,85 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
// import modules
import tempHistory from './tempHistory'
const getDefaultState = () => {
return {
software_version: '',
hostname: '',
cpu_info: '',
heaters: {
available_heaters: [],
},
toolhead: {
position: [],
homed_axes: "",
extruder: "",
status: "",
print_time: 0,
printing_time: 0,
estimated_print_time: 0,
max_velocity: 0,
max_accel: 0,
max_accel_to_decel: 0,
square_corner_velocity: 0,
},
pause_resume: {
is_paused: false
},
idle_timeout: {
printing_time: 0,
state: "",
},
display_status: {
message: null,
progress: 0,
},
virtual_sdcard: {
progress: 0,
is_active: false,
file_position: 0,
},
print_stats: {
print_duration: 0,
filament_used: 0,
total_duration: 0,
filename: "",
state: "",
message: ""
},
current_file: {
},
gcode_move: {
extrude_factor: 1,
speed_factor: 1,
homing_origin: [0,0,0,0],
absolute_coordinates: true,
absolute_extrude: true,
speed: 0,
},
endstops: {},
configfile: {
config: {},
config_changed: false,
},
helplist: [],
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations,
modules: {
tempHistory
}
}
+73
View File
@@ -0,0 +1,73 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
export default {
reset(state) {
window.console.log("printer/reset");
Object.assign(state, getDefaultStore)
},
setData(state, payload) {
if ("status" in payload) payload = payload.status;
if ("requestParams" in payload) delete payload.requestParams
let now = Date.now();
Object.entries(payload).forEach(([key, value]) => {
if (key === "webhooks") {
this.dispatch("server/getData", { klippy_state: value.state, klippy_message: value.state_message }, { root: true })
} else {
//update printer data
if (typeof (value) === "object") {
Vue.set(state, key, {
...state[key],
...value
})
} else Vue.set(state, key, value)
//update heaters
if (
Array.isArray(state.heaters.available_heaters) &&
state.heaters.available_heaters.length
) {
let keySplit = key.split(" ");
if (
state.heaters.available_heaters.includes(key) ||
keySplit[0] === "temperature_fan" ||
keySplit[0] === "temperature_sensor") {
if (keySplit[0] === "temperature_fan") key = keySplit[1];
else if (keySplit[0] === "temperature_sensor") key = keySplit[1];
else if (keySplit[0] === "heater_generic") key = keySplit[1];
this.commit('printer/tempHistory/addValue', { name: key, value: value, time: now });
}
}
}
})
},
setHelplist(state, payload) {
let helplist = [];
for (let [command, description] of Object.entries(payload)) {
helplist.push({
'commandLow': command.toLowerCase(),
'command': command,
'description': description,
})
}
Vue.set(state, "helplist", helplist)
},
clearCurrentFile(state) {
Object.assign(state.current_file, {})
},
setEndstopStatus(state, payload) {
delete payload.requestParams;
Vue.set(state, 'endstops', payload);
},
}
+9
View File
@@ -0,0 +1,9 @@
export default {
reset({ commit }) {
commit('reset')
},
getHistory({ commit }, payload) {
commit('setHistory', payload);
},
}
+3
View File
@@ -0,0 +1,3 @@
export default {
}
+20
View File
@@ -0,0 +1,20 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
const getDefaultState = () => {
return {
datasets: [],
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
+142
View File
@@ -0,0 +1,142 @@
import { getDefaultStore } from './index'
import {colorArray, colorChamber, colorHeaterBed} from "@/store/variables";
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setHistory(state, payload) {
let now = new Date();
if (payload !== undefined) {
Object.entries(payload).sort().forEach(([key, datasets]) => {
let keySplit = key.split(" ");
if (keySplit.length > 1) key = keySplit[1];
if (datasets.temperatures) {
let max = datasets.temperatures.length;
for (let i = 0; i < max; i++) {
let time = new Date(now.getTime() - 1000 * (max - i));
this.commit('printer/tempHistory/addValue', {
name: key,
value: {
temperature: datasets.temperatures[i],
target: datasets.targets[i],
},
type: keySplit[0],
time: time
}, { root: true});
}
}
});
}
},
addHeater( state, payload) {
let color = '';
switch (payload.name) {
case 'heater_bed': color = colorHeaterBed; break;
case 'chamber': color = colorChamber; break;
default: color = colorArray[state.datasets.filter(element => !element.label.endsWith("_target") && element.label !== "heater_bed" && element.label !== "chamber").length]; break;
}
let hidden = this.state.gui.dashboard.hiddenTempChart.indexOf(payload.name.toUpperCase()) >= 0 ? true : null;
state.datasets.push({
label: payload.name,
data: [],
borderColor: color,
backgroundColor: color,
pointBackgroundColor: color,
fill: false,
borderWidth: 2,
hidden: hidden,
});
if (payload.type !== "temperature_sensor") {
state.datasets.push({
label: payload.name+"_target",
data: [],
borderColor: color,
backgroundColor: color+'20',
pointBackgroundColor: color,
fill: true,
borderWidth: 0,
hidden: hidden,
});
}
},
addValue(state, payload) {
// definations for delete old entries
let timeOld = new Date().getTime() - (1000 * 60 * 10);
let minResolution = 1000; // value in ms
let deletedIndex;
let index = state.datasets.findIndex(element => element.label === payload.name);
if (index < 0) {
this.commit('printer/tempHistory/addHeater', {
name: payload.name,
type: payload.type,
}, { root: true });
index = state.datasets.findIndex(element => element.label === payload.name);
}
let index_target = state.datasets.findIndex(element => element.label === payload.name+'_target');
// update current temp in temperature chart
if (index >= 0) {
let temperature = 0;
if (payload.value.temperature !== undefined) temperature = payload.value.temperature.toFixed(1);
else if (state.datasets[index].data.length) temperature = state.datasets[index].data[state.datasets[index].data.length - 1].y;
if (
(state.datasets[index].data.length && (
(
state.datasets[index].data[state.datasets[index].data.length - 1].y !== temperature ||
payload.time-state.datasets[index].data[state.datasets[index].data.length - 1].x > minResolution
) && state.datasets[index].data[state.datasets[index].data.length - 1].x < payload.time
)) || state.datasets[index].data.length === 0
) {
state.datasets[index].data.push({
x: payload.time,
y: temperature
});
}
// delete old entries
while ((deletedIndex = state.datasets[index].data.findIndex(item => item.x < timeOld)) > -1) {
state.datasets[index].data.splice(deletedIndex, 1);
}
}
// update target temp in temperature chart
if (index_target >= 0) {
let target = 0;
if (payload.value.target !== undefined) target = payload.value.target.toFixed(1);
else if (state.datasets[index_target].data.length) target = state.datasets[index_target].data[state.datasets[index_target].data.length - 1].y;
if (
(state.datasets[index_target].data.length && (
(
state.datasets[index_target].data[state.datasets[index_target].data.length - 1].y !== target ||
payload.time-state.datasets[index_target].data[state.datasets[index_target].data.length - 1].x > minResolution
) && state.datasets[index_target].data[state.datasets[index_target].data.length - 1].x < payload.time
)) || state.datasets[index_target].data.length === 0
) {
state.datasets[index_target].data.push({
x: payload.time,
y: target
});
}
// delete old entries
while ((deletedIndex = state.datasets[index_target].data.findIndex(item => item.x < timeOld)) > -1) {
state.datasets[index_target].data.splice(deletedIndex, 1);
}
}
},
}
+45
View File
@@ -0,0 +1,45 @@
import Vue from 'vue'
export default {
reset({ commit }) {
commit('reset')
},
init() {
Vue.prototype.$socket.sendObj('server.info', {}, 'server/getInfo')
Vue.prototype.$socket.sendObj('server.gcode_store', {}, 'server/getGcodeStore')
//Vue.prototype.$socket.sendObj('server.files.get_directory', { path: '/config' }, 'getDirectoryRoot')
},
getInfo({ commit, dispatch }, payload) {
commit('setData', payload)
if (payload.klippy_connected) {
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'config' }, 'files/getDirectory');
Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'config_examples' }, 'files/getDirectory');
//TODO load power plugin
//load plug data
//if (data.plugins.includes("power") !== false) Vue.prototype.$socket.sendObj('machine.gpio_power.devices', {}, 'getPowerDevices');
dispatch('printer/init', null, { root: true });
} else {
setTimeout(function(){
Vue.prototype.$socket.sendObj('server.info', {}, 'server/getInfo');
}, 1000);
}
},
getData({ commit }, payload){
commit('setData', payload)
},
getGcodeStore({ commit }, payload) {
commit('setGcodeStore', payload)
},
getGcodeRespond({commit}, data) {
//commit('removeLoading', { name: 'loadingSendGcode' });
commit('addEvent', data);
},
}
+3
View File
@@ -0,0 +1,3 @@
export default {
}
+30
View File
@@ -0,0 +1,30 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
// import modules
import powerDevices from './powerDevices'
const getDefaultState = () => {
return {
klippy_connected: false,
klippy_state: "",
klippy_message: "",
plugins: [],
events: [],
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations,
modules: {
powerDevices
}
}
+51
View File
@@ -0,0 +1,51 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setKlippyReady() {
this.dispatch('printer/reset', null, { root: true })
this.dispatch('printer/init', null, { root: true })
},
setKlippyDisconnected(state) {
Vue.set(state, 'klippy_state', 'disconnected')
Vue.set(state, 'klippy_message', 'Disconnected...')
Vue.prototype.$socket.sendObj('server.info', {}, 'server/getInfo');
},
setData(state, payload) {
if ("requestParams" in payload) delete payload.requestParams
Object.entries(payload).forEach(([key, value]) => {
Vue.set(state, key, value)
});
},
setGcodeStore(state, payload) {
if ("gcode_store" in payload && Array.isArray(payload.gcode_store)) {
payload.gcode_store.forEach(message => {
state.events.push({
date: new Date(message.time * 1000),
message: message.message
})
})
}
},
addEvent(state, payload) {
let message = payload
if (message.result !== undefined) message = message.result
else if (message.error !== undefined) message = message.error.message
state.events.push({
date: new Date(),
message: message
})
},
}
+23
View File
@@ -0,0 +1,23 @@
import Vue from 'vue'
export default {
reset({ commit }) {
commit('reset')
},
getDevices({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else {
commit('setDevices', payload.devices);
Vue.prototype.$socket.sendObj('machine.gpio_power.status', {}, 'server.powerDevices.getStatus');
}
},
getStatus({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else commit('setStatus', payload);
},
}
+9
View File
@@ -0,0 +1,9 @@
export default {
devices: state => {
return state.devices;
},
count: (state, getters) => {
return getters.devices.length;
},
}
+20
View File
@@ -0,0 +1,20 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
const getDefaultState = () => {
return {
devices: []
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
@@ -0,0 +1,19 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setDevices(state, payload) {
Vue.set(state, 'devices', payload)
},
setPStatus(state, payload) {
for (let key in payload) {
let devIdx = state.devices.findIndex(device => device.id === key)
if (devIdx >= 0) Vue.set(state.devices[devIdx], 'status', payload[key] === 'off' ? 0 : 1)
}
},
}
+81
View File
@@ -0,0 +1,81 @@
export default {
reset({ commit }) {
commit('reset')
},
onOpen ({ commit, dispatch }) {
commit('setConnected')
dispatch('server/init', null, { root: true })
},
onClose ({ commit }, event) {
commit('setDisconnected');
if (event.wasClean) window.console.log('Socket closed clear')
else window.console.error('Connection failure')
},
onMessage ({ commit, state }, payload) {
if (!state.isConnected) commit('setConnected')
switch(payload.method) {
case 'notify_status_update':
commit('printer/setData', payload.params[0], { root: true })
break
case 'notify_gcode_response':
commit('server/addEvent', payload.params[0], { root: true })
break
case 'notify_klippy_ready':
commit('server/setKlippyReady', null, { root: true })
break
case 'notify_klippy_disconnected':
commit('server/setKlippyDisconnected', null, { root: true })
break
case 'notify_filelist_changed':
switch(payload.params[0].action) {
case 'upload_file':
commit('files/setUploadFile', payload.params[0], { root: true })
break
case 'delete_file':
commit('files/setDeleteFile', payload.params[0], { root: true })
break
case 'move_item':
commit('files/setMoveItem', payload.params[0], { root: true })
break
case 'create_dir':
commit('files/setCreateDir', payload.params[0], { root: true })
break
case 'delete_dir':
commit('files/setDeleteDir', payload.params[0], { root: true })
break
default:
window.console.error("Unknown filelist_changed action: "+payload.params[0].action)
break
}
break;
case 'notify_metadata_update':
commit('files/setMetadata', payload.params[0], { root: true })
break
default:
if (payload.result !== "ok") {
if (
payload.error &&
payload.error.message !== "Klippy Request Timed Out" &&
payload.error.message !== "Klippy Disconnected"
) window.console.error("JSON-RPC: " + payload.error.message)
else if (!payload.error) window.console.log(payload)
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
export default {
}
+25
View File
@@ -0,0 +1,25 @@
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
const getDefaultState = () => {
return {
hostname: window.location.hostname,
port: window.location.port,
reconnectInterval: 5000,
isConnected: false,
loadings: []
}
}
// initial state
const state = getDefaultState()
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
+24
View File
@@ -0,0 +1,24 @@
import Vue from 'vue'
import { getDefaultStore } from './index'
export default {
reset(state) {
Object.assign(state, getDefaultStore)
},
setConnected (state) {
state.isConnected = true;
},
setDisconnected (state) {
state.isConnected = false;
},
setData(state, payload) {
if ("socket" in payload) payload = payload.socket
Object.entries(payload).forEach(([key, value]) => {
Vue.set(state, key, value)
});
}
}