Update to Moonraker .08-alpha

This commit is contained in:
Stefan Dej 2020-07-05 23:41:39 +02:00
parent e25c10c757
commit accde2227b
15 changed files with 61 additions and 59 deletions

View File

@ -129,7 +129,7 @@ export default {
methods: {
emergencyStop: function() {
this.$store.commit('setLoadingEmergencyStop', true);
this.$socket.sendObj('post_printer_gcode', {script: 'M112'}, 'setLoadingEmergencyStop');
this.$socket.sendObj('post_printer_gcode_script', {script: 'M112'}, 'setLoadingEmergencyStop');
},
drawFavicon(val) {
let favicon = document.getElementById('favicon');

View File

@ -94,27 +94,27 @@
doHome() {
this.$store.commit('addGcodeResponse', "G28");
this.$store.commit('setLoading', { name: 'controlHomeAll' });
this.$socket.sendObj('post_printer_gcode', { script: "G28" }, "responseHome");
this.$socket.sendObj('post_printer_gcode_script', { script: "G28" }, "responseHome");
},
doHomeX() {
this.$store.commit('addGcodeResponse', "G28 X");
this.$store.commit('setLoading', { name: 'controlHomeX' });
this.$socket.sendObj('post_printer_gcode', { script: "G28 X" }, "responseHomeX");
this.$socket.sendObj('post_printer_gcode_script', { script: "G28 X" }, "responseHomeX");
},
doHomeY() {
this.$store.commit('addGcodeResponse', "G28 Y");
this.$store.commit('setLoading', { name: 'controlHomeY' });
this.$socket.sendObj('post_printer_gcode', { script: "G28 Y" }, "responseHomeY");
this.$socket.sendObj('post_printer_gcode_script', { script: "G28 Y" }, "responseHomeY");
},
doHomeZ() {
this.$store.commit('addGcodeResponse', "G28 Z");
this.$store.commit('setLoading', { name: 'controlHomeZ' });
this.$socket.sendObj('post_printer_gcode', { script: "G28 Z" }, "responseHomeZ");
this.$socket.sendObj('post_printer_gcode_script', { script: "G28 Z" }, "responseHomeZ");
},
doQGL() {
this.$store.commit('addGcodeResponse', "QUAD_GANTRY_LEVEL");
this.$store.commit('setLoadingQGL', true);
this.$socket.sendObj('post_printer_gcode', { script: "QUAD_GANTRY_LEVEL" }, "responseQGL");
this.$socket.sendObj('post_printer_gcode_script', { script: "QUAD_GANTRY_LEVEL" }, "responseQGL");
},
doSendMove(gcode) {
gcode = "G91" + "\n" +
@ -125,7 +125,7 @@
},
doSend(gcode) {
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "sendGcode");
},
},
watch: {

View File

@ -82,13 +82,13 @@
let gcode = "M120\nM83\nG1 E-"+this.feedAmount+" F"+(this.feedrate * 60)+"\nM121";
this.$store.commit('setLoading', { name: 'extruderRetract' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeExtruderRetract");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeExtruderRetract");
},
sendDetract() {
let gcode = "M120\nM83\nG1 E"+this.feedAmount+" F"+(this.feedrate * 60)+"\nM121";
this.$store.commit('setLoading', { name: 'extruderDetract' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeExtruderDetract");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeExtruderDetract");
},
},
watch: {

View File

@ -53,7 +53,7 @@
methods: {
syncEndstops() {
this.$store.commit('setLoadingEndstopStatus', true);
this.$socket.sendObj('get_printer_endstops', { }, "responseEndstopStatus");
this.$socket.sendObj('get_printer_query_endstops_status', { }, "responseEndstopStatus");
}
},
watch: {

View File

@ -7,13 +7,13 @@
</v-list-item-content>
</v-list-item>
<v-divider class="my-2"></v-divider>
<v-card-text class="">
<div><v-btn :href="'http://'+hostname+':'+port+'/printer/klippy.log'" color="primary"><v-icon class="mr-sm-2">mdi-download</v-icon>Klipper Log</v-btn></div>
<div><v-btn :href="'http://'+hostname+':'+port+'/server/moonraker.log'" color="mt-3 primary"><v-icon class="mr-sm-2">mdi-download</v-icon>Moonraker Log</v-btn></div>
<v-card-text class=" text-center text-lg-left">
<div><v-btn :href="'http://'+hostname+':'+port+'/server/files/klippy.log'" color="primary"><v-icon class="mr-sm-2">mdi-download</v-icon>Klipper Log</v-btn></div>
<div><v-btn :href="'http://'+hostname+':'+port+'/server/files/moonraker.log'" color="mt-3 primary"><v-icon class="mr-sm-2">mdi-download</v-icon>Moonraker Log</v-btn></div>
<div><v-btn @click="doRestart" :loading="loadingRestart" color="error" class="mt-3"><v-icon class="mr-sm-2">mdi-cached</v-icon>Restart</v-btn></div>
<div><v-btn @click="doRestartFirmware" :loading="loadingRestartFirmware" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon><span class="d-none d-sm-block">FW Restart</span></v-btn></div>
<div><v-btn @click="doRebootHost" :loading="loadingRebootHost" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon><span class="d-none d-sm-block">Host Restart</span></v-btn></div>
<div><v-btn @click="doShutdownHost" :loading="loadingShutdownHost" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-power</v-icon><span class="d-none d-sm-block">Host Shutdown</span></v-btn></div>
<div><v-btn @click="doRestartFirmware" :loading="loadingRestartFirmware" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon>FW <span class="d-none d-sm-block">Restart</span></v-btn></div>
<div><v-btn @click="doRebootHost" :loading="loadingRebootHost" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-cached</v-icon>Host <span class="d-none d-sm-block">Restart</span></v-btn></div>
<div><v-btn @click="doShutdownHost" :loading="loadingShutdownHost" class="mt-3" color="error"><v-icon class="mr-sm-2">mdi-power</v-icon>Host <span class="d-none d-sm-block">Shutdown</span></v-btn></div>
</v-card-text>
</v-card>
</template>

View File

@ -54,13 +54,13 @@
let gcode = "SET_GCODE_OFFSET Z_ADJUST=-0.05 MOVE=1";
this.$store.commit('setLoading', { name: 'babySteppingDown' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeBabySteppingDown");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeBabySteppingDown");
},
sendBabySteppingUp() {
let gcode = "SET_GCODE_OFFSET Z_ADJUST=0.05 MOVE=1";
this.$store.commit('setLoading', { name: 'babySteppingUp' });
this.$store.commit('addGcodeResponse', gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeBabySteppingUp");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeBabySteppingUp");
},
},
watch: {

View File

@ -42,7 +42,7 @@
},
methods: {
changeSensor() {
this.$socket.sendObj('post_printer_gcode', { script: 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.enabled ? 0 : 1) });
this.$socket.sendObj('post_printer_gcode_script', { script: 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.enabled ? 0 : 1) });
}
},
watch: {

View File

@ -33,7 +33,7 @@
},
methods: {
setTemps() {
this.$socket.sendObj('post_printer_gcode', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value});
this.$socket.sendObj('post_printer_gcode_script', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value});
}
},
watch: {

View File

@ -69,7 +69,7 @@
},
methods: {
sendCmd() {
this.$socket.sendObj('post_printer_gcode', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) });
this.$socket.sendObj('post_printer_gcode_script', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) });
},
decrement() {
this.value--;

View File

@ -134,7 +134,7 @@
doSend() {
this.loadingSendGcode = true;
this.$store.commit('addGcodeResponse', this.gcode);
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode");
Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: this.gcode }, "sendGcode");
this.lastCommands.push(this.gcode);
this.gcode = "";
this.lastCommandNumber = null;

View File

@ -220,7 +220,7 @@
formData.append('file', file);
this.$store.commit('setLoadingGcodeUpload', true);
axios.post('http://' + this.hostname + ':' + this.port + '/printer/files/upload',
axios.post('http://' + this.hostname + ':' + this.port + '/server/files/upload',
formData, {
headers: { 'Content-Type': 'multipart/form-data' }
}
@ -238,7 +238,7 @@
},
refreshFileList: function() {
this.$store.commit('setLoadingGcodeRefresh', true);
this.$socket.sendObj('get_printer_files', {}, 'getFileList');
this.$socket.sendObj('get_file_list', {}, 'getFileList');
},
formatDate(date) {
let tmp2 = new Date(date);
@ -292,7 +292,7 @@
},
removeFile() {
axios.delete(
'http://'+ this.hostname + ':' + this.port +'/printer/files/'+this.contextMenu.item.filename
'http://'+ this.hostname + ':' + this.port +'/server/files/'+this.contextMenu.item.filename
).then((result) => {
this.$toast.success(result.data.result+" successfully deleted.");
}).catch(() => {

View File

@ -59,10 +59,14 @@ export default class WebSocketClient {
if (this.store) {
if (this.wsData.filter(item => item.id === data.id).length > 0 &&
this.wsData.filter(item => item.id === data.id)[0].action !== "") {
this.store.dispatch(
this.wsData.filter(item => item.id === data.id)[0].action,
data.result
)
if (data.error && data.error.message) {
window.console.error("Response Error: "+this.wsData.filter(item => item.id === data.id)[0].action+" > "+data.error.message);
} else {
this.store.dispatch(
this.wsData.filter(item => item.id === data.id)[0].action,
data.result
)
}
} else this.passToStore('socket_on_message', data)
}
};

View File

@ -7,25 +7,16 @@ import axios from "axios";
export default {
socket_on_open ({ commit }) {
commit('setConnected');
Vue.prototype.$socket.sendObj('get_printer_status', { }, 'getHelpData');
fetch('http://'+store.state.socket.hostname+':'+store.state.socket.port+'/printer/files/gui.json')
.then(res => res.json()).then(file => {
store.commit('setSettings', file);
}).catch(function() {
window.console.warn('No mainsail config file found.');
});
Vue.prototype.$socket.sendObj('get_printer_objects_status', { }, 'getHelpData');
Vue.prototype.$socket.sendObj('get_directory', { path: 'gcodes' }, 'getDirectoryRoot');
Vue.prototype.$socket.sendObj('get_printer_info', {}, 'getKlipperInfo');
},
socket_on_close ({ commit }, event) {
commit('setDisconnected');
if (event.wasClean) {
window.console.log('Socket closed clear')
} else {
window.console.error('Connection failure')
}
if (event.wasClean) window.console.log('Socket closed clear')
else window.console.error('Connection failure')
window.console.error('Code: ' + event.code)
},
@ -58,13 +49,20 @@ export default {
default:
if (data.result !== "ok") {
window.console.log("Default return");
if (data.error) window.console.error("JSON-RPC: " + data.error.message);
else window.console.log(data);
}
}
},
getDirectoryRoot({ commit }, data) {
if (data.files && data.files.filter((file) => file.filename === "gui.json")) {
fetch('http://'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/gcodes/gui.json')
.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');
@ -92,10 +90,10 @@ export default {
commit('setPrinterStatus', 'ready');
Vue.prototype.$socket.sendObj('get_printer_objects', {}, 'getObjectInfo');
Vue.prototype.$socket.sendObj('get_printer_status', { heaters: [] }, 'getHeatersInfo');
Vue.prototype.$socket.sendObj('get_printer_status', { configfile: ['config'] }, 'getPrinterConfig');
Vue.prototype.$socket.sendObj('post_printer_subscriptions', {
Vue.prototype.$socket.sendObj('get_printer_objects_list', {}, 'getObjectInfo');
Vue.prototype.$socket.sendObj('get_printer_objects_status', { heaters: [] }, 'getHeatersInfo');
Vue.prototype.$socket.sendObj('get_printer_objects_status', { configfile: ['config'] }, 'getPrinterConfig');
Vue.prototype.$socket.sendObj('post_printer_objects_subscription', {
gcode: [],
toolhead: [],
virtual_sdcard: [],
@ -105,7 +103,7 @@ export default {
idle_timeout: [],
display_status: [],
});
Vue.prototype.$socket.sendObj('get_printer_files', {}, 'getFileList');
Vue.prototype.$socket.sendObj('get_file_list', {}, 'getFileList');
Vue.prototype.$socket.sendObj('get_printer_gcode_help', {}, 'getHelpList');
} else {
commit('setPrinterStatus', 'disconnected');
@ -125,7 +123,7 @@ export default {
if (data.heaters.available_heaters.length) {
data.heaters.available_heaters.forEach(function(heater) {
Vue.prototype.$socket.sendObj('post_printer_subscriptions', { [heater]: [] });
Vue.prototype.$socket.sendObj('post_printer_objects_subscription', { [heater]: [] });
})
}

View File

@ -98,7 +98,7 @@ export default {
},
current_file_size: state => {
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename);
if (file.length) return file[0]['size'];
@ -106,7 +106,7 @@ export default {
},
current_file_metadata: state => {
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename);
if (file.length) return file[0];
@ -114,7 +114,7 @@ export default {
},
current_file_estimated_time: state => {
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename);
if (file.length) return file[0]['estimated_time'];
@ -122,7 +122,7 @@ export default {
},
current_file_filament_total: state => {
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename);
if (file.length) return file[0]['filament_total'];
@ -134,7 +134,7 @@ export default {
},
is_printing: state => {
return (state.printer.virtual_sdcard.current_file !== "");
return (state.printer.virtual_sdcard.filename !== "");
},
getMacros: state => {
@ -247,7 +247,7 @@ export default {
getTitle: state => {
if (state.socket.isConnected) {
if (state.printer.pause_resume.is_paused) return "Pause Print";
else if (state.printer.virtual_sdcard.is_active) return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.virtual_sdcard.current_file;
else if (state.printer.virtual_sdcard.is_active) return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.virtual_sdcard.filename;
return state.gui.general.printername ? state.gui.general.printername : state.printer.hostname;
} else return "Mainsail";

View File

@ -156,7 +156,7 @@ export default {
nameSplit[0] === "temperature_probe" ||
nameSplit[0] === "temperature_sensors" ||
nameSplit[0] === "filament_switch_sensor"
) Vue.prototype.$socket.sendObj('post_printer_subscriptions', { [key]: [] });
) Vue.prototype.$socket.sendObj('post_printer_objects_subscription', { [key]: [] });
}
},
@ -166,7 +166,7 @@ export default {
setFileList(state, data) {
state.files = [];
window.console.log(data);
//window.console.log(data);
let array = Object.entries(data);
for (let [key, file] of array) {