Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
706515bc84 | ||
|
|
efc70ca5aa | ||
|
|
544d5e2db5 | ||
|
|
70e8ce5687 |
No files matched your search
@@ -1,30 +1,171 @@
|
||||
# Klipper Web Control
|
||||
KWC is a responsive web interface for [Klipper](https://github.com/KevinOConnor/klipper) 3D printer firmware. It communicates with the klipper-api from [Arksine](https://github.com/arksine).
|
||||
# Mainsail
|
||||
Mainsail is a responsive web interface for [Klipper](https://github.com/KevinOConnor/klipper) 3D printer firmware. It communicates with the klipper-api from [Arksine](https://github.com/arksine).
|
||||
|
||||
## Installation
|
||||
At first install Arksine klipper-api fork/branch -> [install manual](https://github.com/Arksine/klipper/tree/work-web_server-20200131/klippy/extras/web_server)
|
||||
## Requirement
|
||||
You need a full working Klipper-instance. Install Klipper with the official Installation documentaion and check the Logfile if klipper (/tmp/klippy.log) works.
|
||||
|
||||
## Installtion of Mainsail
|
||||
The installation is split into several sections
|
||||
|
||||
- [Change branch for Klipper-API](#change-brunch-for-klipper-api)
|
||||
- [configure Klipper-API](#configure-klipper-api)
|
||||
- [install webserver & reverse proxy (nginx)](#install-webserver--reverse-proxy-nginx)
|
||||
- [install & configure Mainsail](#install--configure-mainsail)
|
||||
|
||||
### Change brunch for Klipper-API
|
||||
The Klipper-API isn't merged in Klipper at the moment, so you have to change the Repository to [Arksine's Fork](https://github.com/Arksine/klipper/tree/work-web_server-20200131/klippy/extras/remote_api) with the Klipper-API.
|
||||
|
||||
Download and install KWC:
|
||||
```bash
|
||||
mkdir -p ~/sdcard
|
||||
mkdir -p ~/kwc
|
||||
cd ~/kwc
|
||||
wget -q -O kwc.zip https://github.com/meteyou/kwc/releases/download/v0.0.7/kwc-alpha-0.0.7.zip && unzip kwc.zip && rm kwc.zip
|
||||
cd ~/klipper
|
||||
git fetch arksine
|
||||
git checkout arksine/work-web_server-20200131
|
||||
```
|
||||
and install the python package "tornado"
|
||||
```bash
|
||||
~/klippy-env/bin/pip install tornado
|
||||
```
|
||||
|
||||
Configure web_server in printer.cfg:
|
||||
### configure Klipper-API
|
||||
edit your `printer.cfg` with `nano ~/printer.cfg` and add following lines:
|
||||
```
|
||||
[web_server]
|
||||
port: 8080
|
||||
enable_cors: true
|
||||
trusted_clients:
|
||||
192.168.1.0/24
|
||||
127.0.0.1
|
||||
allow_file_ops_when_printing: true
|
||||
|
||||
[virtual_sdcard]
|
||||
path: /home/pi/sdcard
|
||||
|
||||
[remote_api]
|
||||
trusted_clients:
|
||||
192.168.0.0/24
|
||||
127.0.0.0/24
|
||||
```
|
||||
edit the first line of trusted_clients (192.168.0.0/24) to your network. The second line (127.0.0.0/24) is for reverse proxy later.
|
||||
|
||||
at last, we create the virtual_sdcard directory:
|
||||
```
|
||||
mkdir ~/sdcard
|
||||
```
|
||||
now restart klipper (`sudo service klipper restart`) and check your klippy-log if klipper is starting correct again.
|
||||
|
||||
when klipper is running, open the url `http://<printer-ip>:7125/printer/info` in your browser. if you see a content like this
|
||||
```
|
||||
{"result": {"hostname": "voron250", "error_detected": false, "version": "v0.8.0-479-gd586fb06", "is_ready": true, "message": "Printer is ready", "cpu": "4 core ARMv7 Processor rev 4 (v7l)"}}
|
||||
```
|
||||
your API is working!
|
||||
|
||||
### install webserver & reverse proxy (nginx)
|
||||
nginx is important to mount all components on port 80 and host the static files from Mainsail.
|
||||
|
||||
If you have installed lighttpd & haproxy before you have to stop & disable it:
|
||||
```bash
|
||||
sudo service haproxy stop
|
||||
sudo update-rc.d -f haproxy remove
|
||||
sudo service lighttpd stop
|
||||
sudo update-rc.d -f lighttpd remove
|
||||
```
|
||||
|
||||
After disable all other webserver you can install nginx now:
|
||||
```bash
|
||||
sudo apt install nginx
|
||||
```
|
||||
now we create the config file with
|
||||
```bash
|
||||
sudo nano /etc/nginx/sites-available/mainsail
|
||||
```
|
||||
and fill it with the following content:
|
||||
```
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream apiserver {
|
||||
#edit your api port here
|
||||
ip_hash;
|
||||
server 127.0.0.1:7125;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
access_log /var/log/nginx/kwc-access.log;
|
||||
error_log /var/log/nginx/kwc-error.log;
|
||||
|
||||
#web_path from mainsail static files
|
||||
root /home/pi/mainsail;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes
|
||||
client_max_body_size 200M;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /printer {
|
||||
proxy_pass http://apiserver/printer;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://apiserver/api;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /access {
|
||||
proxy_pass http://apiserver/access;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_pass http://apiserver/websocket;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
location /machine {
|
||||
proxy_pass http://apiserver/machine;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
create directory for static files and active nginx config:
|
||||
```bash
|
||||
mkdir ~/mainsail
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/
|
||||
sudo service nginx restart
|
||||
```
|
||||
now you can check again the API if it works with the reverse proxy. Open the url `http://<printer-ip>/printer/info` in your browser. if you see a content like this:
|
||||
```
|
||||
{"result": {"hostname": "voron250", "error_detected": false, "version": "v0.8.0-479-gd586fb06", "is_ready": true, "message": "Printer is ready", "cpu": "4 core ARMv7 Processor rev 4 (v7l)"}}
|
||||
```
|
||||
now we can install Mainsail.
|
||||
|
||||
### install & configure Mainsail
|
||||
now you can download the current mainsail static data
|
||||
```bash
|
||||
cd ~/mainsail
|
||||
wget -q -O mainsail.zip https://github.com/meteyou/mainsail/releases/download/v0.0.9/mailsail-alpha-0.0.9.zip && unzip mainsail.zip && rm mainsail.zip
|
||||
```
|
||||
|
||||
|
||||
Example Klipper macros:
|
||||
```
|
||||
@@ -71,128 +212,10 @@ gcode:
|
||||
BASE_RESUME
|
||||
```
|
||||
|
||||
## Installation lighttpd & haproxy (out-dated)
|
||||
```bash
|
||||
sudo apt install lighttpd haproxy
|
||||
## Update Mainsail to V0.0.9
|
||||
```
|
||||
edit configfile `/etc/lighttpd/lighttpd.conf` and edit following lines:
|
||||
```
|
||||
server.document-root = "/home/pi/kwc"
|
||||
server.bind = "127.0.0.1"
|
||||
server.port = 81
|
||||
```
|
||||
|
||||
```bash
|
||||
sudo usermod -a -G www-data pi
|
||||
```
|
||||
|
||||
add following lines at the end of `/etc/haproxy/haproxy.cfg`:
|
||||
```
|
||||
frontend public
|
||||
bind :::80 v4v6
|
||||
default_backend lighttpd
|
||||
use_backend printer if { path_beg /printer/ }
|
||||
# use_backend webcam if { path_beg /webcam1/ }
|
||||
|
||||
acl is_websocket path_beg /websocket
|
||||
acl is_websocket hdr(Upgrade) -i WebSocket
|
||||
acl is_websocket hdr_beg(Host) -i ws
|
||||
use_backend websocket if is_websocket
|
||||
|
||||
backend lighttpd
|
||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||
option forwardfor
|
||||
server lighttpd1 127.0.0.1:81
|
||||
|
||||
backend printer
|
||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||
option forwardfor
|
||||
server printer1 127.0.0.1:8080
|
||||
|
||||
backend websocket
|
||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||
option forwardfor
|
||||
server websocket1 127.0.0.1:8080
|
||||
|
||||
#backend webcam
|
||||
# reqrep ^([^\ :]*)\ /webcam1/(.*) \1\ /\2
|
||||
# server webcam1 127.0.0.1:8081
|
||||
```
|
||||
|
||||
all comments are for webcam support. You can install MJPEG-Streamer with this [tutorial](https://github.com/cncjs/cncjs/wiki/Setup-Guide:-Raspberry-Pi-%7C-MJPEG-Streamer-Install-&-Setup-&-FFMpeg-Recording).
|
||||
|
||||
## Installation nginx
|
||||
|
||||
If you have installed lighttpd & haproxy before:
|
||||
```bash
|
||||
sudo service haproxy stop
|
||||
sudo update-rc.d -f haproxy remove
|
||||
sudo service lighttpd stop
|
||||
sudo update-rc.d -f lighttpd remove
|
||||
```
|
||||
|
||||
and now install nginx:
|
||||
```bash
|
||||
sudo apt install nginx
|
||||
```
|
||||
create configfile `/etc/nginx/sites-available/kwc`:
|
||||
```
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream apiserver {
|
||||
#edit your api port here
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
access_log /var/log/nginx/kwc-access.log;
|
||||
error_log /var/log/nginx/kwc-error.log;
|
||||
|
||||
#web_path from kwc static files
|
||||
root /home/pi/kwc;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes
|
||||
client_max_body_size 128M;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /printer {
|
||||
proxy_pass http://apiserver/printer;
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_pass http://apiserver/websocket;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
change api port & root path.
|
||||
|
||||
```bash
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
sudo ln -s /etc/nginx/sites-available/kwc /etc/nginx/sites-enabled/
|
||||
sudo service nginx restart
|
||||
```
|
||||
|
||||
## Update KWC to V0.0.7
|
||||
```
|
||||
rm -R ~/kwc/*
|
||||
cd ~/kwc
|
||||
wget -q -O kwc.zip https://github.com/meteyou/kwc/releases/download/v0.0.7/kwc-alpha-0.0.7.zip && unzip kwc.zip && rm kwc.zip
|
||||
rm -R ~/mainsail/*
|
||||
cd ~/mainsail
|
||||
wget -q -O kwc.zip https://github.com/meteyou/kwc/releases/download/v0.0.8/kwc-alpha-0.0.8.zip && unzip kwc.zip && rm kwc.zip
|
||||
```
|
||||
and update your macros & nginx config.
|
||||
Generated
+1282
-415
File diff suppressed because it is too large.
Load diff
+13
-17
@@ -10,35 +10,31 @@
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"chart.js": "^2.9.3",
|
||||
"core-js": "^3.6.4",
|
||||
"core-js": "^3.6.5",
|
||||
"object-assign-deep": "^0.4.0",
|
||||
"vue": "^2.6.11",
|
||||
"vue-chartjs": "^3.5.0",
|
||||
"vue-context": "^5.0.0",
|
||||
"vue-context": "^5.1.0",
|
||||
"vue-headful": "^2.1.0",
|
||||
"vue-json-rpc-websocket": "^1.1.1",
|
||||
"vue-resource": "^1.5.1",
|
||||
"vue-simple-upload": "^0.1.6",
|
||||
"vue-toast-notification": "0.0.3",
|
||||
"vuetify": "^2.2.17",
|
||||
"vuetify-toast-snackbar": "^0.6.1",
|
||||
"vuex": "^3.1.3"
|
||||
"vue-toast-notification": "^0.2.0",
|
||||
"vuetify": "^2.2.22",
|
||||
"vuex": "^3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.12.1",
|
||||
"@mdi/font": "^4.9.95",
|
||||
"@vue/cli-plugin-babel": "^4.2.3",
|
||||
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"@mdi/font": "^5.1.45",
|
||||
"@vue/cli-plugin-babel": "^4.3.1",
|
||||
"@vue/cli-plugin-eslint": "^4.3.1",
|
||||
"@vue/cli-service": "^4.3.1",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"css-loader": "^3.4.2",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"material-design-icons-iconfont": "^5.0.1",
|
||||
"css-loader": "^3.5.2",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"sass": "^1.26.3",
|
||||
"sass-loader": "^8.0.2",
|
||||
"vue-cli-plugin-route": "0.0.7",
|
||||
"vue-cli-plugin-vuetify": "^1.1.2",
|
||||
"vue-cli-plugin-vuetify": "^2.0.5",
|
||||
"vue-router": "^3.1.6",
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"vuetify-loader": "^1.4.3"
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"socket": {
|
||||
"hostname": "kossel.local",
|
||||
"reconnectInterval": 5000,
|
||||
"reconnectAttempts": 1000
|
||||
"hostname": "voron250.local",
|
||||
"port": 8080,
|
||||
"reconnectInterval": 3000
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@@ -6,8 +6,6 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico" id="favicon" />
|
||||
<title>KlipperWebControl</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
||||
+7
-5
@@ -1,3 +1,7 @@
|
||||
<style>
|
||||
@import './assets/styles/fonts.css';
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<v-app>
|
||||
<vue-headful
|
||||
@@ -62,7 +66,7 @@
|
||||
|
||||
<v-footer app class="d-block">
|
||||
<span v-if="version">{{ version }}</span>
|
||||
<span class="float-right">© 2020</span>
|
||||
<span class="float-right">Made with <img src="/img/heard.png" height="15" title="love" alt="heard" /> by <a href="http://www.vorondesign.com/" target="_blank"><img src="/img/voron.png" height="15" title="VoronDesign" alt="Logo - VoronDesign" /></a></span>
|
||||
</v-footer>
|
||||
</v-app>
|
||||
</template>
|
||||
@@ -85,9 +89,7 @@ export default {
|
||||
}),
|
||||
created () {
|
||||
this.$vuetify.theme.dark = true;
|
||||
this.$socket.onOpen = () => {
|
||||
|
||||
}
|
||||
//this.$webSocketsConnect();
|
||||
},
|
||||
computed: {
|
||||
currentPage: function() {
|
||||
@@ -110,7 +112,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: 'M112'}, 'setLoadingEmergencyStop');
|
||||
},
|
||||
drawFavicon(val) {
|
||||
let favicon = document.getElementById('favicon');
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 100;
|
||||
src: local('Roboto Thin'), local('Roboto-Thin'), url(/fonts/roboto-thin.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: local('Roboto Light'), local('Roboto-Light'), url(/fonts/roboto-light.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Roboto'), local('Roboto-Regular'), url(/fonts/roboto-regular.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: local('Roboto Medium'), local('Roboto-Medium'), url(/fonts/roboto-medium.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Roboto Bold'), local('Roboto-Bold'), url(/fonts/roboto-bold.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
src: local('Roboto Black'), local('Roboto-Black'), url(/fonts/roboto-black.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<v-card>
|
||||
<v-row class="">
|
||||
<v-col class="col-12 pb-0 text-center">
|
||||
<div class="d-inline-block mx-2 my-1"><v-btn @click="doHome" :loading="loadingHome" :color="homedAxes.includes('xyz') ? 'primary' : 'warning'" class=""><v-icon class="mr-1">mdi-home</v-icon><span class="d-none d-sm-inline">Home </span>all</v-btn></div>
|
||||
<div class="d-inline-block mx-2 my-1"><v-btn @click="doHome" :loading="loadingHomeAll" :color="homedAxes.includes('xyz') ? 'primary' : 'warning'" class=""><v-icon class="mr-1">mdi-home</v-icon><span class="d-none d-sm-inline">Home </span>all</v-btn></div>
|
||||
<div class="d-inline-block mx-2 my-1" v-if="config.hasOwnProperty('quad_gantry_level')"><v-btn @click="doQGL" :loading="loadingQGL" color="primary">QGL</v-btn></div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
<script>
|
||||
import { mapState, mapGetters, mapMutations } from 'vuex'
|
||||
import Vue from "vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -68,24 +69,20 @@
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
|
||||
loadingHomeAll: false,
|
||||
loadingHomeX: false,
|
||||
loadingHomeY: false,
|
||||
loadingHomeZ: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
loadingHome: state => state.socket.loadingHome,
|
||||
loadingHomeX: state => state.socket.loadingHomeX,
|
||||
loadingHomeY: state => state.socket.loadingHomeY,
|
||||
loadingHomeZ: state => state.socket.loadingHomeZ,
|
||||
loadingQGL: state => state.socket.loadingQGL,
|
||||
homedAxes: state => state.printer.toolhead.homed_axes,
|
||||
config: state => state.config,
|
||||
loadings: state => state.loadings,
|
||||
}),
|
||||
...mapMutations([
|
||||
'setLoadingHome',
|
||||
'setLoadingHomeX',
|
||||
'setLoadingHomeY',
|
||||
'setLoadingHomeZ',
|
||||
'setLoadingQGL',
|
||||
]),
|
||||
...mapGetters([
|
||||
@@ -94,19 +91,19 @@
|
||||
},
|
||||
methods: {
|
||||
doHome() {
|
||||
this.$store.commit('setLoadingHome', true);
|
||||
this.$store.commit('setLoading', { name: 'controlHomeAll' });
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28" }, "responseHome");
|
||||
},
|
||||
doHomeX() {
|
||||
this.$store.commit('setLoadingHomeX', true);
|
||||
this.$store.commit('setLoading', { name: 'controlHomeX' });
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 X" }, "responseHomeX");
|
||||
},
|
||||
doHomeY() {
|
||||
this.$store.commit('setLoadingHomeY', true);
|
||||
this.$store.commit('setLoading', { name: 'controlHomeY' });
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 Y" }, "responseHomeY");
|
||||
},
|
||||
doHomeZ() {
|
||||
this.$store.commit('setLoadingHomeZ', true);
|
||||
this.$store.commit('setLoading', { name: 'controlHomeZ' });
|
||||
this.$socket.sendObj('post_printer_gcode', { script: "G28 Z" }, "responseHomeZ");
|
||||
},
|
||||
doQGL() {
|
||||
@@ -121,8 +118,16 @@
|
||||
this.doSend(gcode);
|
||||
},
|
||||
doSend(gcode) {
|
||||
this.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode");
|
||||
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode");
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
loadings: function(loadings) {
|
||||
this.loadingHomeAll = loadings.includes('controlHomeAll');
|
||||
this.loadingHomeX = loadings.includes('controlHomeX');
|
||||
this.loadingHomeY = loadings.includes('controlHomeY');
|
||||
this.loadingHomeZ = loadings.includes('controlHomeZ');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-exclamation</v-icon></v-list-item-avatar>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>mdi-exclamation-thick</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Machinelimits</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<div><v-btn :href="'http://'+hostname+':'+port+'/printer/log'" color="primary"><v-icon class="mr-sm-2">mdi-download</v-icon>Download 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>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
@@ -33,6 +35,8 @@
|
||||
port: state => state.socket.port,
|
||||
loadingRestart: state => state.socket.loadingRestart,
|
||||
loadingRestartFirmware: state => state.socket.loadingRestartFirmware,
|
||||
loadingRebootHost: state => state.socket.loadingRebootHost,
|
||||
loadingShutdownHost: state => state.socket.loadingShutdownHost,
|
||||
}),
|
||||
...mapMutations([
|
||||
'setLoadingRestart',
|
||||
@@ -48,6 +52,14 @@
|
||||
this.$store.commit('setLoadingRestartFirmware', true);
|
||||
this.$socket.sendObj('post_printer_firmware_restart', { }, "responseRestartFirmware");
|
||||
},
|
||||
doRebootHost() {
|
||||
this.$store.commit('setLoadingRebootHost', true);
|
||||
this.$socket.sendObj('post_machine_reboot', { });
|
||||
},
|
||||
doShutdownHost() {
|
||||
this.$store.commit('setLoadingShutdownHost', true);
|
||||
this.$socket.sendObj('post_machine_shutdown', { });
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-info</v-icon></v-list-item-avatar>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>mdi-information-variant</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Status</v-list-item-title>
|
||||
<v-list-item-subtitle class="mr-3">{{ printer_state }}{{ printer_is_printing ? " - "+current_file : "" }}</v-list-item-subtitle>
|
||||
@@ -73,13 +73,13 @@
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">Filament</v-flex>
|
||||
<v-flex tag="span">{{ filament_used > 0 && current_file_filament_used > 0 ? formatTime(print_time / (filament_used / current_file_filament_used) - print_time) : '--' }}</v-flex>
|
||||
<v-flex tag="span">{{ (filament_used > 0 && current_file_filament_total > filament_used) ? formatTime(print_time / (filament_used / current_file_filament_total) - print_time) : '--' }}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex grow class="equal-width">
|
||||
<v-layout column>
|
||||
<v-flex tag="strong">Slicer</v-flex>
|
||||
<v-flex tag="span">{{ current_file_estimated_time > print_time ? formatTime(current_file_estimated_time - print_time) : formatTime(0) }}</v-flex>
|
||||
<v-flex tag="span">{{ current_file_estimated_time > print_time ? formatTime(current_file_estimated_time - print_time) : '--'}}</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
@@ -132,7 +132,7 @@
|
||||
'current_file_size',
|
||||
'current_file_metadata',
|
||||
'current_file_estimated_time',
|
||||
'current_file_filament_used',
|
||||
'current_file_filament_total',
|
||||
'is_printing',
|
||||
]),
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-thermometer-three-quarters</v-icon></v-list-item-avatar>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>mdi-thermometer</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Temperature Chart</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>fa-thermometer-three-quarters</v-icon></v-list-item-avatar>
|
||||
<v-list-item-avatar color="grey"><v-icon dark>mdi-thermometer</v-icon></v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="headline">Heaters</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
|
||||
+14
-12
@@ -1,12 +1,11 @@
|
||||
import Vue from 'vue'
|
||||
import JRPCWS from './plugins/json-rpc-websocket'
|
||||
import WebSocketClient from './plugins/wsClient'
|
||||
import App from './App.vue'
|
||||
import vuetify from './plugins/vuetify'
|
||||
import VueResource from 'vue-resource'
|
||||
import './components'
|
||||
import store from './store'
|
||||
import router from './plugins/router'
|
||||
import 'vue-toast-notification/dist/index.css';
|
||||
import vueHeadful from 'vue-headful';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
@@ -20,15 +19,18 @@ Vue.http.headers.common['Access-Control-Allow-Methods'] = 'POST, GET, PUT, OPTIO
|
||||
|
||||
Vue.component('vue-headful', vueHeadful);
|
||||
|
||||
fetch('/config.json').then(res => res.json())
|
||||
.then(file => {
|
||||
fetch('/config.json')
|
||||
.then(res => res.json())
|
||||
.then(file => {
|
||||
store.commit('setSettings', file);
|
||||
Vue.use(JRPCWS, 'ws://' + store.state.socket.hostname + ':' + store.state.socket.port + '/websocket', {
|
||||
store: store,
|
||||
reconnectEnabled: true,
|
||||
reconnectInterval: store.state.socket.reconnectInterval,
|
||||
reconnectAttempts: store.state.socket.reconnectAttempts,
|
||||
|
||||
const socketClient = new WebSocketClient('ws://' + store.state.socket.hostname + ':' + store.state.socket.port + '/websocket', {
|
||||
store: store,
|
||||
reconnectEnabled: true,
|
||||
reconnectInterval: store.state.socket.reconnectInterval,
|
||||
});
|
||||
socketClient.connect();
|
||||
Vue.prototype.$socket = socketClient;
|
||||
|
||||
new Vue({
|
||||
vuetify,
|
||||
@@ -36,11 +38,11 @@ fetch('/config.json').then(res => res.json())
|
||||
store,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
})
|
||||
.catch((error) => {
|
||||
})
|
||||
.catch((error) => {
|
||||
let p = document.createElement("p");
|
||||
let content = document.createTextNode("config.json not found or cannot be decoded!");
|
||||
p.appendChild(content);
|
||||
document.getElementById('app').append(p);
|
||||
window.console.error('Error:', error);
|
||||
});
|
||||
});
|
||||
@@ -82,6 +82,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
import Vue from "vue";
|
||||
|
||||
export default {
|
||||
data () {
|
||||
@@ -132,7 +133,7 @@
|
||||
methods: {
|
||||
doSend() {
|
||||
this.loadingSendGcode = true;
|
||||
this.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode");
|
||||
Vue.prototype.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode");
|
||||
this.lastCommands.push(this.gcode);
|
||||
this.gcode = "";
|
||||
this.lastCommandNumber = null;
|
||||
|
||||
+5
-13
@@ -225,15 +225,11 @@
|
||||
}
|
||||
).then((result) => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.success("Upload of "+result.data.result+" successful!", {
|
||||
icon: 'fa-check'
|
||||
});
|
||||
toast.success("Upload of "+result.data.result+" successful!");
|
||||
})
|
||||
.catch(() => {
|
||||
this.$store.commit('setLoadingGcodeUpload', false);
|
||||
toast.error("Cannot upload the file!", {
|
||||
icon: 'fa-exclamation-triangle'
|
||||
});
|
||||
toast.error("Cannot upload the file!");
|
||||
});
|
||||
},
|
||||
clickUploadButton: function() {
|
||||
@@ -296,14 +292,10 @@
|
||||
removeFile() {
|
||||
axios.delete(
|
||||
'http://'+ this.hostname + ':' + this.port +'/printer/files/'+this.contextMenu.item.filename
|
||||
).then(() => {
|
||||
this.$toast(this.contextMenu.item.filename+" successfully deleted.", {
|
||||
icon: 'fa-trash'
|
||||
});
|
||||
).then((result) => {
|
||||
this.$toast.success(result.data.result+" successfully deleted.");
|
||||
}).catch(() => {
|
||||
this.$toast.error("Error! Cannot delete file.", {
|
||||
icon: 'fa-warning'
|
||||
});
|
||||
this.$toast.error("Error! Cannot delete file.");
|
||||
});
|
||||
},
|
||||
startPrint(filename = "") {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import WebSocketClient from './wsClient'
|
||||
|
||||
export default {
|
||||
install (Vue, url, options) {
|
||||
const socketClient = new WebSocketClient(url, options)
|
||||
socketClient.connect()
|
||||
Vue.prototype.$socket = socketClient
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
export default class WebSocketClient {
|
||||
constructor (url, options) {
|
||||
this.instance = null
|
||||
this.url = url
|
||||
this.options = options || this.defaultOptions()
|
||||
if (this.options) {
|
||||
if (options.reconnectEnabled) {
|
||||
this.reconnectEnabled = options.reconnectEnabled
|
||||
if (this.reconnectEnabled) {
|
||||
this.reconnectInterval = options.reconnectInterval
|
||||
this.reconnectAttempts = options.recconectAttempts
|
||||
this.reconnectCount = 1
|
||||
}
|
||||
}
|
||||
if (options.store) {
|
||||
this.store = options.store
|
||||
}
|
||||
}
|
||||
|
||||
this.wsData = []
|
||||
|
||||
this.onOpen = null
|
||||
this.onMessage = null
|
||||
this.onClose = null
|
||||
this.onError = null
|
||||
}
|
||||
|
||||
createMessage (method, params, id) {
|
||||
let msg = {
|
||||
jsonrpc: '2.0', method: method, params: params, id: id
|
||||
};
|
||||
return JSON.stringify(msg)
|
||||
}
|
||||
|
||||
defaultOptions () {
|
||||
return {
|
||||
reconnectEnabled: false,
|
||||
reconnectInterval: 0,
|
||||
recconectAttempts: 0,
|
||||
store: undefined
|
||||
}
|
||||
}
|
||||
|
||||
passToStore (eventName, event) {
|
||||
if (!eventName.startsWith('socket_')) { return }
|
||||
let method = 'dispatch'
|
||||
let target = eventName
|
||||
let msg = event
|
||||
if (event.data) {
|
||||
msg = JSON.parse(event.data)
|
||||
}
|
||||
this.store[method](target, msg)
|
||||
}
|
||||
|
||||
connect () {
|
||||
this.instance = new WebSocket(this.url);
|
||||
|
||||
this.instance.onopen = () => {
|
||||
if (this.reconnectEnabled) this.reconnectCount = 1;
|
||||
if (typeof this.onOpen === 'function') this.onOpen();
|
||||
if (this.store) this.passToStore('socket_on_open', event);
|
||||
};
|
||||
|
||||
this.instance.onmessage = (msg) => {
|
||||
let data = JSON.parse(msg.data);
|
||||
if (typeof this.onMessage === 'function') {
|
||||
this.onMessage(data)
|
||||
} else if (this.store) {
|
||||
if ('error' in data) {
|
||||
this.passToStore('socket_on_error', data.error)
|
||||
} else 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
|
||||
)
|
||||
} else this.passToStore('socket_on_message', data)
|
||||
}
|
||||
}
|
||||
|
||||
this.instance.onclose = (e) => {
|
||||
if (typeof this.onClose === 'function') {
|
||||
this.onClose(e)
|
||||
} else if (this.store) {
|
||||
this.passToStore('socket_on_close', e)
|
||||
}
|
||||
if (!e.wasClean && this.reconnectEnabled) {
|
||||
this.reconnect()
|
||||
}
|
||||
}
|
||||
|
||||
this.instance.onerror = (e) => {
|
||||
if (typeof this.onError === 'function') {
|
||||
this.onError(e)
|
||||
} else if (this.store) {
|
||||
this.passToStore('socket_on_error', e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reconnect () {
|
||||
if (this.reconnectCount <= this.reconnectAttempts) {
|
||||
this.reconnectCount++
|
||||
delete this.instance
|
||||
setTimeout(() => {
|
||||
this.connect()
|
||||
if (this.store) { this.passToStore('socket_reconnect', this.reconnectCount) }
|
||||
}, this.reconnectInterval)
|
||||
} else {
|
||||
if (this.store) { this.passToStore('socket_reconnect_error', true) }
|
||||
}
|
||||
}
|
||||
|
||||
sendObj (method, params, action = '') {
|
||||
let id = Math.floor(Math.random() * 10000) + 1
|
||||
this.wsData.push({
|
||||
id: id,
|
||||
action: action
|
||||
})
|
||||
this.instance.send(this.createMessage(method, params, id))
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,7 +1,14 @@
|
||||
import '@fortawesome/fontawesome-free/css/all.css'
|
||||
import '@mdi/font/css/materialdesignicons.css'
|
||||
import Vue from 'vue';
|
||||
import Vuetify, { VSnackbar, VBtn, VIcon } from 'vuetify/lib';
|
||||
import VuetifyToast from 'vuetify-toast-snackbar'
|
||||
|
||||
//vue-toast-notification
|
||||
import VueToast from 'vue-toast-notification';
|
||||
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||
|
||||
Vue.use(VueToast, {
|
||||
duration: 3000,
|
||||
});
|
||||
|
||||
|
||||
Vue.use(Vuetify,{
|
||||
@@ -12,15 +19,8 @@ Vue.use(Vuetify,{
|
||||
}
|
||||
});
|
||||
|
||||
Vue.use(VuetifyToast, {
|
||||
x: 'right',
|
||||
y: 'bottom',
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
export default new Vuetify({
|
||||
|
||||
icons: {
|
||||
iconfont: 'fa',
|
||||
iconfont: 'mdi',
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
export default class WebSocketClient {
|
||||
|
||||
constructor (url, options) {
|
||||
this.instance = null;
|
||||
this.url = url;
|
||||
this.reconnectInterval = options.reconnectInterval;
|
||||
this.store = options.store;
|
||||
this.wsData = [];
|
||||
this.timerId = 0;
|
||||
this.keepAliveTimeout = 1000;
|
||||
|
||||
this.onOpen = null;
|
||||
this.onMessage = null;
|
||||
this.onClose = null;
|
||||
this.onError = null;
|
||||
}
|
||||
|
||||
createMessage (method, params, id) {
|
||||
let msg = {
|
||||
jsonrpc: '2.0', method: method, params: params, id: id
|
||||
};
|
||||
return JSON.stringify(msg)
|
||||
}
|
||||
|
||||
passToStore (eventName, event) {
|
||||
if (!eventName.startsWith('socket_')) { return }
|
||||
let method = 'dispatch'
|
||||
let target = eventName
|
||||
let msg = event
|
||||
if (event && event.data) {
|
||||
msg = JSON.parse(event.data)
|
||||
}
|
||||
this.store[method](target, msg)
|
||||
}
|
||||
|
||||
connect () {
|
||||
this.instance = new WebSocket(this.url);
|
||||
|
||||
this.instance.onopen = () => {
|
||||
if (this.store) this.passToStore('socket_on_open', event);
|
||||
};
|
||||
|
||||
this.instance.onclose = (e) => {
|
||||
window.console.log("Websocket Closed, reconnecting in "+this.reconnectInterval+"ms: ", e.reason);
|
||||
this.passToStore('socket_on_close', e);
|
||||
|
||||
setTimeout(() => {
|
||||
this.connect();
|
||||
}, this.reconnectInterval);
|
||||
};
|
||||
|
||||
this.instance.onerror = (err) => {
|
||||
console.log("Websocket Error: ", err);
|
||||
this.instance.close();
|
||||
};
|
||||
|
||||
this.instance.onmessage = (msg) => {
|
||||
let data = JSON.parse(msg.data);
|
||||
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
|
||||
)
|
||||
} else this.passToStore('socket_on_message', data)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
sendObj (method, params, action = '') {
|
||||
let id = Math.floor(Math.random() * 10000) + 1
|
||||
this.wsData.push({
|
||||
id: id,
|
||||
action: action
|
||||
})
|
||||
this.instance.send(this.createMessage(method, params, id))
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -41,20 +41,20 @@ const routes = [
|
||||
{
|
||||
title: "Settings",
|
||||
path: '/settings',
|
||||
redirect: '/settings/interface',
|
||||
redirect: '/settings/machine',
|
||||
icon: 'wrench',
|
||||
component: Settings,
|
||||
children: [
|
||||
{
|
||||
title: 'Interface',
|
||||
path: '/settings/interface',
|
||||
component: SettingsInterface
|
||||
},
|
||||
{
|
||||
title: 'Machine',
|
||||
path: '/settings/machine',
|
||||
component: SettingsMachine
|
||||
},
|
||||
{
|
||||
title: 'Interface',
|
||||
path: '/settings/interface',
|
||||
component: SettingsInterface
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
+5
-37
@@ -46,10 +46,6 @@ export default {
|
||||
window.console.error('Code: ' + event.code)
|
||||
},
|
||||
|
||||
socket_on_error ({ commit }, data) {
|
||||
commit('reportError', data);
|
||||
},
|
||||
|
||||
socket_on_message ({ commit, state }, data) {
|
||||
if (!state.socket.isConnected) commit('setConnected');
|
||||
switch(data.method) {
|
||||
@@ -86,30 +82,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
socket_reconnect ({ commit }, count) {
|
||||
commit('setConnected');
|
||||
window.console.log(count);
|
||||
Vue.prototype.$socket.sendObj('get_printer_status', { heater: [] }, 'getObjectInfo');
|
||||
Vue.prototype.$socket.sendObj('get_printer_status', { configfile: ['config'] }, 'getPrinterConfig');
|
||||
Vue.prototype.$socket.sendObj('post_printer_subscriptions', {
|
||||
gcode: [],
|
||||
toolhead: [],
|
||||
virtual_sdcard: [],
|
||||
heater: [],
|
||||
heater_bed: [],
|
||||
extruder: ["temperature", "target"],
|
||||
fan: [],
|
||||
pause_resume: [],
|
||||
idle_timeout: [],
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
socket_reconnect_error ({ commit }) {
|
||||
commit('setDisconnected');
|
||||
window.console.error('Socket disconnected')
|
||||
},
|
||||
|
||||
saveGuiSettings({ commit, state }) {
|
||||
commit('setLoadingSaveGuiConfige', true);
|
||||
let file = new File([JSON.stringify({ webcam: state.webcam, gui: state.gui })], 'gui.json');
|
||||
@@ -143,11 +115,6 @@ export default {
|
||||
commit('setPrinterConfig', data);
|
||||
},
|
||||
|
||||
addSubscription(state, data) {
|
||||
window.console.log(state);
|
||||
window.console.log(data);
|
||||
},
|
||||
|
||||
getFileList({ commit }, data) {
|
||||
commit('setFileList', data);
|
||||
commit('setLoadingGcodeRefresh', false);
|
||||
@@ -180,22 +147,23 @@ export default {
|
||||
sendGcode({commit}, data) {
|
||||
commit('setLoadingSendGcode', false);
|
||||
commit('sendGcode', data);
|
||||
commit('addGcodeResponse', data);
|
||||
},
|
||||
|
||||
responseHome({commit}) {
|
||||
commit('setLoadingHome', false);
|
||||
commit('removeLoading', { name: 'controlHomeAll' });
|
||||
},
|
||||
|
||||
responseHomeX({commit}) {
|
||||
commit('setLoadingHomeX', false);
|
||||
commit('removeLoading', { name: 'controlHomeX' });
|
||||
},
|
||||
|
||||
responseHomeY({commit}) {
|
||||
commit('setLoadingHomeY', false);
|
||||
commit('removeLoading', { name: 'controlHomeY' });
|
||||
},
|
||||
|
||||
responseHomeZ({commit}) {
|
||||
commit('setLoadingHomeZ', false);
|
||||
commit('removeLoading', { name: 'controlHomeZ' });
|
||||
},
|
||||
|
||||
responseQGL({commit}) {
|
||||
|
||||
@@ -84,10 +84,10 @@ export default {
|
||||
return 0;
|
||||
},
|
||||
|
||||
current_file_filament_used: state => {
|
||||
current_file_filament_total: state => {
|
||||
let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file);
|
||||
|
||||
if (file.length) return file[0]['filament_used'];
|
||||
if (file.length) return file[0]['filament_total'];
|
||||
|
||||
return 0;
|
||||
},
|
||||
@@ -109,7 +109,7 @@ export default {
|
||||
|
||||
for (let prop in state.config) {
|
||||
if (prop.startsWith('gcode_macro') &&
|
||||
!state.config[prop].hasOwnProperty('rename_existing') &&
|
||||
!Object.hasOwnProperty.call(state.config[prop], 'rename_existing') &&
|
||||
!(hiddenMacros.indexOf(prop.replace('gcode_macro ', '').toLowerCase()) > -1)
|
||||
) {
|
||||
array.push({
|
||||
@@ -134,7 +134,8 @@ export default {
|
||||
let array = [];
|
||||
|
||||
for (let prop in state.config) {
|
||||
if (prop.startsWith('gcode_macro') && !state.config[prop].hasOwnProperty('rename_existing')) {
|
||||
if (prop.startsWith('gcode_macro') &&
|
||||
!Object.hasOwnProperty.call(state.config[prop], 'rename_existing')) {
|
||||
array.push({
|
||||
'name': prop.replace('gcode_macro ', ''),
|
||||
'prop': state.config[prop]
|
||||
|
||||
+3
-5
@@ -14,20 +14,17 @@ export default new Vuex.Store({
|
||||
hostname: window.location.hostname,
|
||||
port: window.location.port,
|
||||
reconnectInterval: 3000,
|
||||
reconnectAttempts: 1000,
|
||||
isConnected: false,
|
||||
loadingGcodeUpload: false,
|
||||
loadingGcodeRefresh: false,
|
||||
loadingEmergencyStop: false,
|
||||
loadingPrintPause: false,
|
||||
loadingPrintResume: false,
|
||||
loadingHome: false,
|
||||
loadingHomeX: false,
|
||||
loadingHomeY: false,
|
||||
loadingHomeZ: false,
|
||||
loadingQGL: false,
|
||||
loadingRestart: false,
|
||||
loadingRestartFirmware: false,
|
||||
loadingRebootHost: false,
|
||||
loadingShutdownHost: false,
|
||||
loadingSaveGuiConfig: false,
|
||||
loadingEndstopStatus: false,
|
||||
},
|
||||
@@ -48,6 +45,7 @@ export default new Vuex.Store({
|
||||
countPerPage: 10,
|
||||
}
|
||||
},
|
||||
loadings: [],
|
||||
config: {
|
||||
|
||||
},
|
||||
|
||||
+21
-20
@@ -3,15 +3,14 @@ const objectAssignDeep = require(`object-assign-deep`);
|
||||
import { colorArray, colorChamber, colorHeaterBed, temperaturChartSampleInterval, temperaturChartSampleLength } from './variables';
|
||||
|
||||
export default {
|
||||
|
||||
setConnected (state) {
|
||||
state.socket.isConnected = true;
|
||||
|
||||
Vue.prototype.$socket
|
||||
},
|
||||
|
||||
setDisconnected (state) {
|
||||
state.socket.isConnected = false;
|
||||
Vue.prototype.$socket.reconnect();
|
||||
//Vue.prototype.$socket.reconnect();
|
||||
},
|
||||
|
||||
setPrinterData(state, data) {
|
||||
@@ -128,7 +127,7 @@ export default {
|
||||
modified: Date.parse(file.modified),
|
||||
size: file.size,
|
||||
slicer: file.slicer,
|
||||
filament_used: file.filament_used,
|
||||
filament_total: file.filament_total,
|
||||
estimated_time: file.estimated_time,
|
||||
layer_height: file.layer_height,
|
||||
first_layer_height: file.first_layer_height,
|
||||
@@ -174,6 +173,16 @@ export default {
|
||||
state.socket.loadingSendGcode = false;
|
||||
},
|
||||
|
||||
setLoading(state, data) {
|
||||
if (!state.loadings.includes(data.name)) {
|
||||
state.loadings.push(data.name);
|
||||
}
|
||||
},
|
||||
|
||||
removeLoading(state, data) {
|
||||
state.loadings = state.loadings.filter(function(ele){ return ele !== data.name; });
|
||||
},
|
||||
|
||||
setPrinterStatus(state, value) {
|
||||
state.printer.toolhead.status = value;
|
||||
},
|
||||
@@ -202,22 +211,6 @@ export default {
|
||||
state.socket.loadingPrintCancel = value;
|
||||
},
|
||||
|
||||
setLoadingHome(state, value) {
|
||||
state.socket.loadingHome = value;
|
||||
},
|
||||
|
||||
setLoadingHomeX(state, value) {
|
||||
state.socket.loadingHomeX = value;
|
||||
},
|
||||
|
||||
setLoadingHomeY(state, value) {
|
||||
state.socket.loadingHomeY = value;
|
||||
},
|
||||
|
||||
setLoadingHomeZ(state, value) {
|
||||
state.socket.loadingHomeZ = value;
|
||||
},
|
||||
|
||||
setLoadingQGL(state, value) {
|
||||
state.socket.loadingQGL = value;
|
||||
},
|
||||
@@ -230,6 +223,14 @@ export default {
|
||||
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;
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user