Skip to content

Commit

Permalink
Showing 16 changed files with 1,035 additions and 1,039 deletions.
72 changes: 41 additions & 31 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This manual is outdated!

# Installation
This document provides a guide on how to install Moonraker & Mainsail on a Raspberry
Pi running Raspian/Rasperry Pi OS. Other SBCs and/or linux distributions
@@ -23,29 +21,47 @@ sudo apt install git dfu-util
```

## Install Klipper
Moonraker is still in alpha development, and thus some of its dependencies
in Klipper have yet to be merged. Until this has been done it will be
necessary to add a remote and work off a developmental branch of Klipper
to correctly run Moonraker.

In this step, we install klipper and change to the development branch of Klipper.
In this step, we install klipper.
```
cd ~
git clone https://github.com/KevinOConnor/klipper
cd ~/klipper
git remote add arksine https://github.com/arksine/klipper
git fetch arksine
git reset --hard arksine/dev-moonraker-testing
./scripts/install-octopi.sh
```

Note that you are now in a detached head state and you cannot pull. Any
time you want to update to the latest version of this branch you have to
`git fetch arksine` and `git reset --hard arksine/dev-moonraker-testing`.
After you install Klipper with its dependencies you have to change the location
of the `printer.cfg`. This is definied in the `/etc/default/klipper` file. To edit
this file type:
```
sudo nano /etc/default/klipper
```
and then change:
```
KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log"
```
to:
```
KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/klipper_config/printer.cfg -l /tmp/klippy.log"
```
Save the file with `STRG+O` and close the editor with `STRG+X`.

Now you can copy your `printer.cfg` in your home directory and restart klipper.
Please check the `klippy.log`, if Klipper starts correctly and then continue
the guide.
At least you have to create the config and the virtual_sdcard directory with:
```
mkdir ~/klipper_config
mkdir ~/sdcard
```
and copy your `printer.cfg` in the `~/klipper_config` directory and restart klipper with
`sudo service klipper restart`. Please check the `klippy.log`, if Klipper starts
correctly and then continue the guide.

and check if you have following lines in your `printer.cfg`:
```
[virtual_sdcard]
path: ~/sdcard
[pause_resume]
[display_status]
```

## Install Moonraker (API)
You can now install the Moonraker application:
@@ -69,24 +85,18 @@ All other configuration is sent to the server via Klippy, thus it is done
in printer.cfg. A basic configuration that authorizes clients on a range
from 192.168.1.1 - 192.168.1.254 is as follows.

Edit your printer.cfg with nano ~/printer.cfg and add the following lines:
Create the configfile with `nano ~/moonraker.conf` and add the following lines:
```
[moonraker]
[server]
host: 0.0.0.0
config_path: ~/klipper_config
[authorization]
enabled: true
trusted_clients:
192.168.1.0/24
```

We also need a `virtual_sdcard` for store the gcode files:
```
[virtual_sdcard]
path: /home/pi/sdcard
```

Finally, we create the virtual_sdcard directory:
```
mkdir ~/sdcard
```

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
@@ -233,7 +243,7 @@ Now we can install Mainsail (static httpdocs).
Now you can download the current mainsail static data
```
cd ~/mainsail
wget -q -O mainsail.zip https://github.com/meteyou/mainsail/releases/download/v0.1.2/mainsail-beta-0.1.2.zip && unzip mainsail.zip && rm mainsail.zip
wget -q -O mainsail.zip https://github.com/meteyou/mainsail/releases/download/v0.1.3/mainsail-beta-0.1.3.zip && unzip mainsail.zip && rm mainsail.zip
```
Now it should be possible to open the interface: `http://<printer-ip>/`.

2 changes: 1 addition & 1 deletion docs/macros.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ gcode:
M141 S0
M106 S0
CLEAR_PAUSE
RESET_SD
SDCARD_RESET_FILE
BASE_CANCEL_PRINT
[gcode_macro PAUSE]
4 changes: 1 addition & 3 deletions docs/update-0.1.x.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This manual is outdated!

# Update from 0.1.x to latest
Updates after 0.1.x are easier than 0.0.x to 0.1.x.

@@ -11,7 +9,7 @@ sudo service moonraker restart
```

create a new file ~/moonraker.conf
```editorconfig
```
[server]
host: 0.0.0.0
config_path: ~/klipper_config
1,779 changes: 902 additions & 877 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -18,18 +18,18 @@
"vue-context": "^6.0.0",
"vue-headful": "^2.1.0",
"vue-plotly": "^1.1.0",
"vue-prism-editor": "^1.0.1",
"vue-prism-editor": "^1.2.0",
"vue-resource": "^1.5.1",
"vue-simple-upload": "^0.1.6",
"vue-toast-notification": "^0.4.1",
"vuetify": "^2.3.4",
"vue-toast-notification": "^0.5.0",
"vuetify": "^2.3.8",
"vuex": "^3.5.1"
},
"devDependencies": {
"@mdi/font": "^5.3.45",
"@vue/cli-plugin-babel": "^4.4.6",
"@vue/cli-plugin-eslint": "^4.4.6",
"@vue/cli-service": "^4.4.6",
"@mdi/font": "^5.5.55",
"@vue/cli-plugin-babel": "^4.5.3",
"@vue/cli-plugin-eslint": "^4.5.3",
"@vue/cli-service": "^4.5.3",
"babel-eslint": "^10.1.0",
"css-loader": "^4.2.1",
"eslint": "^7.6.0",
@@ -38,7 +38,7 @@
"sass-loader": "^9.0.3",
"vue-cli-plugin-route": "0.0.7",
"vue-cli-plugin-vuetify": "^2.0.7",
"vue-router": "^3.4.1",
"vue-router": "^3.4.3",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.6.0"
},
10 changes: 5 additions & 5 deletions src/components/panels/ControlPanel.vue
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@

<template>
<v-card>
<v-row class="" v-if="!is_printing">
<v-row class="" v-if="['standby', 'complete'].includes(printer_state)">
<v-col class="col-12 pb-0 text-center">
<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>
<div class="d-inline-block mx-2 my-1" v-if="config.hasOwnProperty('z_tilt')"><v-btn @click="doZtilt" :loading="loadingZTilt" color="primary">Z Tilt</v-btn></div>
</v-col>
</v-row>
<v-row class="mt-3" v-if="!is_printing">
<v-row class="mt-3" v-if="['standby', 'complete'].includes(printer_state)">
<v-col class="col-12 py-0 px-6 text-center">
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
<v-btn @click="doSendMove('X-100')" cols="1" class="flex-grow-1 flex-shrink-0 d-none d-sm-flex"><v-icon left class="d-sm-flex">mdi-chevron-left</v-icon><span class="body-2">X-100</span></v-btn>
@@ -24,7 +24,7 @@
</v-btn-toggle>
</v-col>
</v-row>
<v-row class="mt-3" v-if="!is_printing">
<v-row class="mt-3" v-if="['standby', 'complete'].includes(printer_state)">
<v-col class="col-12 py-0 px-6 text-center">
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
<v-btn @click="doSendMove('Y-100')" cols="1" class="flex-grow-1 flex-shrink-0 d-none d-sm-flex"><v-icon left class="d-none d-sm-flex">mdi-chevron-left</v-icon><span class="body-2">Y-100</span></v-btn>
@@ -37,7 +37,7 @@
</v-btn-toggle>
</v-col>
</v-row>
<v-row class="mt-3" v-if="!is_printing">
<v-row class="mt-3" v-if="['standby', 'complete'].includes(printer_state)">
<v-col class="col-12 py-0 px-6 text-center">
<v-btn-toggle borderless no-gutters style="flex-wrap: nowrap; width: 100%;" >
<v-btn @click="doSendMove('Z-25')" cols="1" class="flex-grow-1 flex-shrink-0"><v-icon left class="d-none d-sm-flex">mdi-chevron-left</v-icon><span class="body-2">Z-25</span></v-btn>
@@ -83,10 +83,10 @@
homedAxes: state => state.printer.toolhead.homed_axes,
config: state => state.config,
loadings: state => state.loadings,
printer_state: state => state.printer.print_stats.state
}),
...mapGetters([
'getMacros',
'is_printing'
])
},
methods: {
7 changes: 2 additions & 5 deletions src/components/panels/ExtruderPanel.vue
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
</style>

<template>
<v-card v-if="!(printer_state === 'Printing' && printer_is_printing)">
<v-card v-if="(['standby', 'paused', 'complete'].includes(printer_state))">
<v-row class="px-3">
<v-col class="col-12 col-md-6">
<v-label>Feed amount in mm:</v-label>
@@ -56,14 +56,11 @@
...mapState({
config: state => state.config,
loadings: state => state.loadings,
printer_state: state => state.printer.idle_timeout.state,
printer_is_paused: state => state.printer.pause_resume.is_paused,
printer_is_printing: state => state.printer.virtual_sdcard.is_active,
printer_state: state => state.printer.print_stats.state,
}),
...mapGetters([
'getMacros',
'getCurrentExtruder',
'is_printing'
]),
extruder: {
get: function() {
11 changes: 7 additions & 4 deletions src/components/panels/Settings/ConfigFilesPanel.vue
Original file line number Diff line number Diff line change
@@ -170,6 +170,7 @@
// import highlighting library (you can use any library you want just return html string)
import { highlight, languages } from 'prismjs/components/prism-core';
import 'prismjs/components/prism-editorconfig';
import 'prismjs/components/prism-ini';
import 'prismjs/themes/prism-okaidia.css';
import axios from "axios"; // import syntax highlighting styles
@@ -241,7 +242,8 @@
},
methods: {
highlighter(code) {
return highlight(code, languages.editorconfig); //returns html
//return highlight(code, languages.editorconfig); //returns html
return highlight(code, languages.ini); //returns html
},
refreshFileList: function() {
window.console.log(this.currentPath.substring(1));
@@ -316,8 +318,8 @@
this.editor.sourcecode = "";
this.editor.item = item;
let url = 'http://'+this.hostname+':'+this.port+'/server/files'+this.currentPath+'/'+item.filename;
fetch(url).then(res => res.text()).then(file => {
let url = 'http://'+this.hostname+':'+this.port+'/server/files'+this.currentPath+'/'+item.filename+'?time='+Date.now();
fetch(url, { cache: "no-cache" }).then(res => res.text()).then(file => {
this.editor.sourcecode = file;
this.editor.show = true;
this.editor.showLoader = false;
@@ -346,10 +348,11 @@
headers: { 'Content-Type': 'multipart/form-data' }
}
).then(() => {
this.$toast.success("File '"+this.editor.item.filename+"' successfully saved.");
this.editor.show = false;
this.editor.sourcecode = "";
}).catch(() => {
window.console.error("Error save "+this.editor.item.filename);
this.$toast.error("Error save "+this.editor.item.filename);
});
},
showContextMenu (e, item) {
31 changes: 15 additions & 16 deletions src/components/panels/StatusPanel.vue
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
<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_is_paused ? "Pause" : printer_state }}{{ printer_is_printing || printer_is_paused ? " - "+current_file : "" }}</v-list-item-subtitle>
<v-list-item-subtitle class="mr-3">{{ printer_state !== "" ? printer_state.charAt(0).toUpperCase() + printer_state.slice(1) : "Unknown" }}{{ ['printing', 'paused', 'complete'].includes(printer_state) ? " - "+current_file : "" }}</v-list-item-subtitle>
</v-list-item-content>
<v-btn class="orange" v-if="printer_state === 'Printing' && printer_is_printing && !printer_is_paused" @click="btnPauseJob" :loading="btnStatusPause">pause job</v-btn>
<v-btn class="red" v-if="(is_printing && printer_is_paused)" :loading="btnStatusCancel" @click="btnCancelJob">cancel job</v-btn>
<v-btn class="orange ml-2" v-if="(is_printing && printer_is_paused)" :loading="btnStatusResume" @click="btnResumeJob">resume job</v-btn>
<v-btn class="orange" v-if="printer_state === 'printing'" @click="btnPauseJob" :loading="btnStatusPause">pause job</v-btn>
<v-btn class="red" v-if="(printer_state === 'paused')" :loading="btnStatusCancel" @click="btnCancelJob">cancel job</v-btn>
<v-btn class="orange ml-2" v-if="(printer_state === 'paused')" :loading="btnStatusResume" @click="btnResumeJob">resume job</v-btn>
</v-list-item>
<v-divider class="my-2" ></v-divider>
<v-card-text class="px-0 pt-0 pb-2 content">
@@ -48,8 +48,8 @@
</v-layout>
</v-flex>
</v-layout>
<v-divider class="my-2" v-if="is_printing"></v-divider>
<v-layout wrap class=" text-center" v-if="is_printing">
<v-divider class="my-2" v-if="['printing', 'paused', 'compleded'].includes(printer_state)"></v-divider>
<v-layout wrap class=" text-center" v-if="['printing', 'paused', 'compleded'].includes(printer_state)">
<v-flex col tag="strong" class="category-header">
Printstatus
</v-flex>
@@ -72,8 +72,8 @@
</v-layout>
</v-flex>
</v-layout>
<v-divider class="my-2" v-if="is_printing"></v-divider>
<v-layout wrap class=" text-center" v-if="is_printing">
<v-divider class="my-2" v-if="['printing', 'paused'].includes(printer_state)"></v-divider>
<v-layout wrap class=" text-center" v-if="['printing', 'paused'].includes(printer_state)">
<v-flex col tag="strong" class="category-header py-0">
Estimations<br />based on
</v-flex>
@@ -96,7 +96,7 @@
</v-layout>
</v-flex>
</v-layout>
<v-layout wrap class=" text-center" v-if="is_printing">
<v-layout wrap class=" text-center" v-if="['printing', 'paused'].includes(printer_state)">
<v-layout column class="mt-2" >
<v-progress-linear
:value="printProgress * 100"
@@ -127,14 +127,13 @@
estimated_print_time: state => state.printer.toolhead.estimated_print_time,
printProgress: state => state.printer.virtual_sdcard.progress,
print_time: state => state.printer.virtual_sdcard.print_duration,
print_time_total: state => state.printer.virtual_sdcard.total_duration,
filament_used: state => state.printer.virtual_sdcard.filament_used,
file_position: state => state.printer.virtual_sdcard.file_position,
current_file: state => state.printer.virtual_sdcard.filename,
printer_state: state => state.printer.idle_timeout.state,
printer_is_paused: state => state.printer.pause_resume.is_paused,
printer_is_printing: state => state.printer.virtual_sdcard.is_active,
print_time: state => state.printer.print_stats.print_duration,
print_time_total: state => state.printer.print_stats.total_duration,
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,
display_message: state => state.printer.display_status.message,
}),
6 changes: 2 additions & 4 deletions src/components/panels/ZOffsetPanel.vue
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
</style>

<template>
<v-card v-if="(printer_state === 'Printing' && printer_is_printing)">
<v-card v-if="(['printing', 'paused'].includes(printer_state))">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon class="mdi mdi-arrow-collapse-vertical" left></v-icon>Z Baby Stepping</span>
@@ -52,9 +52,7 @@
...mapState({
loadings: state => state.loadings,
base_zpos: state => state.printer.gcode.base_zpos,
printer_state: state => state.printer.idle_timeout.state,
printer_is_paused: state => state.printer.pause_resume.is_paused,
printer_is_printing: state => state.printer.virtual_sdcard.is_active,
printer_state: state => state.printer.print_stats.state,
homed_axis: state => state.printer.toolhead.homed_axes,
}),
},
14 changes: 0 additions & 14 deletions src/inputs/ToolSlider.vue
Original file line number Diff line number Diff line change
@@ -80,11 +80,6 @@
this.sendCmd();
},
checkExpand() {
window.console.log("checkExpand: "+this.attributeName);
window.console.log(this.value);
window.console.log(this.variableMax);
window.console.log(this.extenderSteps);
if (this.value > 0) {
if (this.value > this.variableMax) {
let tmpMulti = Math.ceil((this.value - this.variableMax) / this.extenderSteps);
@@ -104,15 +99,6 @@
this.checkExpand();
}, 1000);
}
/*value: function() {
if (this.value > 0) {
if (this.value > (this.variableMax - this.extenderSteps) && this.value < (this.variableMax + this.extenderSteps)) this.variableMax += this.extenderSteps;
else if (this.value > (this.variableMax - this.extenderSteps)) {
this.variableMax = (this.value / this.extenderSteps).toFixed(0) * this.extenderSteps;
if (this.variableMax < this.max) this.variableMax = this.max;
}
}
}*/
},
created: function() {
if (this.value > this.variableMax) {
19 changes: 10 additions & 9 deletions src/store/actions.js
Original file line number Diff line number Diff line change
@@ -39,23 +39,23 @@ export default {

case 'notify_filelist_changed':
switch(data.params[0].action) {
case 'added':
commit('setFileChangeAdded', data.params[0]);
case 'upload_file':
commit('setFileChangeUploadFile', data.params[0]);
break;

case 'removed':
commit('setFileChangeRemoved', data.params[0]);
case 'delete_file':
commit('setFileChangeDeleteFile', data.params[0]);
break;

case 'file_move':
commit('setFileChangeFileMove', data.params[0]);
case 'move_item':
commit('setFileChangeMoveItem', data.params[0]);
break;

case 'add_directory':
commit('setFileChangeAddDirectory', data.params[0]);
case 'create_dir':
commit('setFileChangeCreateDirectory', data.params[0]);
break;

case 'delete_directory':
case 'delete_dir':
commit('setFileChangeDeleteDirectory', data.params[0]);
break;

@@ -114,6 +114,7 @@ export default {
gcode: [],
toolhead: [],
virtual_sdcard: [],
print_stats: [],
heaters: [],
fan: [],
pause_resume: [],
6 changes: 3 additions & 3 deletions src/store/getters.js
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ export default {
},

current_file_size: state => {
if (state.printer.virtual_sdcard.filename === state.printer.current_file.filename) {
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
return state.printer.current_file.size;
}

@@ -114,15 +114,15 @@ export default {
},

current_file_estimated_time: state => {
if (state.printer.virtual_sdcard.filename === state.printer.current_file.filename) {
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
return state.printer.current_file.estimated_time;
}

return 0;
},

current_file_filament_total: state => {
if (state.printer.virtual_sdcard.filename === state.printer.current_file.filename) {
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
return state.printer.current_file.filament_total;
}

9 changes: 6 additions & 3 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -91,12 +91,16 @@ export default new Vuex.Store({
},
virtual_sdcard: {
progress: 0,
filename: "",
is_active: false,
filament_used: 0,
file_position: 0,
},
print_stats: {
print_duration: 0,
filament_used: 0,
total_duration: 0,
filename: "",
state: "",
message: ""
},
current_file: {

@@ -121,7 +125,6 @@ export default new Vuex.Store({
temperaturChart: {
labels: [],
datasets: [],
updateTicks: []
},
helplist: [],
filetree: [
86 changes: 31 additions & 55 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ export default {
setPrinterData(state, data) {
if (data.requestParams) delete data.requestParams;
let now = Date.now();
let updateTicks = false;

Object.entries(data).forEach(([key, value]) => {
Vue.set(state.printer, key, value);
@@ -57,20 +56,6 @@ export default {
else if (keySplit[0] === "temperature_sensor") key = keySplit[1];
else if (keySplit[0] === "temperature_probe") key = "probe";

// increment update ticks array only 1 time per setPrinterData with heaters/sensors
if (!updateTicks) {
for (let index in state.temperaturChart.updateTicks) {
state.temperaturChart.updateTicks[index] += 1;
}

updateTicks = true;
}

// add object to update ticks array if it doesn't exists
if (state.temperaturChart.updateTicks[key] === undefined) {
state.temperaturChart.updateTicks[key] = 1;
}

this.commit('addTemperatureChartValue', { name: key, value: value, time: now });
}
}
@@ -125,23 +110,11 @@ export default {
}
let index_target = state.temperaturChart.datasets.findIndex(element => element.label === payload.name+'_target');

let ticks = 1;

// find missing ticks in update ticks array and reset it
if (state.temperaturChart.updateTicks[payload.name] !== undefined) {
ticks = state.temperaturChart.updateTicks[payload.name];
state.temperaturChart.updateTicks[payload.name] = 0;
}

// update current temp in temperature chart
if (index >= 0) {
for (let i = 0; i < ticks; i++) state.temperaturChart.datasets[index].data.push(payload.value.temperature.toFixed(1));
}
if (index >= 0) state.temperaturChart.datasets[index].data.push(payload.value.temperature.toFixed(1));

// update target temp in temperature chart
if (index_target >= 0 && payload.value.target !== undefined) {
for (let i = 0; i < ticks; i++) state.temperaturChart.datasets[index_target].data.push(payload.value.target.toFixed(1));
}
if (index_target >= 0 && payload.value.target !== undefined) state.temperaturChart.datasets[index_target].data.push(payload.value.target.toFixed(1));

if (index >= 0 && state.temperaturChart.datasets[index].data.length > temperaturChartSampleLength) {
state.temperaturChart.datasets[index].data = state.temperaturChart.datasets[index].data.splice(state.temperaturChart.datasets[index].data.length - temperaturChartSampleLength)
@@ -215,19 +188,21 @@ export default {
if (data.configfile) Vue.set(state, 'config', data.configfile.config);
},

setFileChangeAdded(state, data) {
let filename = data.filename;
if (data.filename.lastIndexOf("/") >= 0) filename = data.filename.substr(data.filename.lastIndexOf("/")).replace("/", "");
let path = data.filename.substr(0, data.filename.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (data.root+"/"+path).split("/"));
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);

parent.push({
isDirectory: false,
filename: filename,
modified: new Date(),
size: 0,
modified: modified,
size: data.item.size,
metadataPulled: false,
});
}
@@ -238,51 +213,52 @@ export default {
}
},

setFileChangeRemoved(state, data) {
let currentPath = data.filename.substr(0, data.filename.lastIndexOf("/"));
let delPath = data.filename.substr(data.filename.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (data.root+"/"+currentPath).split("/"));
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);
},

setFileChangeFileMove(state, data) {
let oldPath = data.prev_file.substr(0, data.prev_file.lastIndexOf("/") + 1);
let newPath = data.filename.substr(0, data.filename.lastIndexOf("/") + 1);
let filenameOld = data.prev_file.substr(data.prev_file.lastIndexOf("/")+1);
let filenameNew = data.filename.substr(data.filename.lastIndexOf("/")+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.root+"/"+oldPath).split("/"));
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.root+"/"+newPath).split("/"));
newPath = findDirectory(state.filetree, (data.item.root+"/"+newPath).split("/"));
newPath.push(file);
}
},

setFileChangeAddDirectory(state, data) {
let filename = data.filename.substr(data.filename.lastIndexOf("/") + 1);
let path = data.filename.substr(0, data.filename.lastIndexOf("/"));
let parent = findDirectory(state.filetree, (data.root+"/"+path).split("/"));
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: filename,
filename: dirname,
modified: new Date(),
childrens: [],
});
}
},

setFileChangeDeleteDirectory(state, data) {
let currentPath = data.filename.substr(0, data.filename.lastIndexOf("/"));
let delPath = data.filename.substr(data.filename.lastIndexOf("/")+1);
currentPath = findDirectory(state.filetree, (data.root+"/"+currentPath).split("/"));
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);
2 changes: 1 addition & 1 deletion src/store/variables.js
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@ export const colorArray = [

export const colorHeaterBed = '#2196F3';
export const colorChamber = '#4CAF50';
export const temperaturChartSampleLength = 600;
export const temperaturChartSampleLength = 1200;

0 comments on commit 9bdcec0

Please sign in to comment.