first implementation of print history
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
1 parent
b1e13bce28
commit
4224553710
18 files changed
+1126
-16
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div id="historyAllPrintStatus" style="height: 250px; width: 100%;"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
chart : null,
|
||||
chartOptions: {
|
||||
darkMode: true,
|
||||
animation: false,
|
||||
grid: {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
series: [{
|
||||
type: 'pie',
|
||||
data: [],
|
||||
radius: '50%',
|
||||
}]
|
||||
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
intervalChartUpdate: state => state.gui.tempchart.intervalChartUpdate,
|
||||
intervalDatasetUpdate: state => state.gui.tempchart.intervalDatasetUpdate,
|
||||
boolTempchart: state => state.gui.dashboard.boolTempchart,
|
||||
}),
|
||||
getAllPrintStatusArray: {
|
||||
get: function() {
|
||||
return this.$store.getters["server/history/getAllPrintStatusArray"]
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
createChart() {
|
||||
if (document.getElementById("historyAllPrintStatus") && this.chart === null) {
|
||||
this.chart = echarts.init(document.getElementById("historyAllPrintStatus"), null, { renderer: 'svg' })
|
||||
this.updateChart()
|
||||
window.console.log("create AllPrintStatus")
|
||||
} else
|
||||
setTimeout(() => {
|
||||
this.createChart()
|
||||
}, 500)
|
||||
},
|
||||
updateChart() {
|
||||
if (this.chart) {
|
||||
const chartOptions = { series: this.chartOptions.series }
|
||||
chartOptions.series[0].data = this.filamentUsageArray
|
||||
this.chart.setOption(chartOptions)
|
||||
this.chart.resize()
|
||||
window.console.log("update AllPrintStatus")
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (this.chart) this.chart.resize()
|
||||
})
|
||||
},
|
||||
mounted: function() {
|
||||
this.createChart()
|
||||
},
|
||||
watch: {
|
||||
getAllPrintStatusArray: {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.updateChart()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<div id="historyFilamentUsage" style="height: 175px; width: 100%;"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
chart : null,
|
||||
chartOptions: {
|
||||
darkMode: true,
|
||||
animation: false,
|
||||
grid: {
|
||||
top: 25,
|
||||
right: 40,
|
||||
bottom: 30,
|
||||
left: 40,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: 'rgba(0,0,0,0.9)',
|
||||
borderWidth: 0,
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontSize: '14px'
|
||||
},
|
||||
padding: 15,
|
||||
formatter: (datasets) => {
|
||||
let output = ""
|
||||
|
||||
if (datasets.length) {
|
||||
let outputTime = datasets[0]['axisValueLabel']
|
||||
outputTime = outputTime.substr(0, outputTime.indexOf(" ")+1)
|
||||
let outputValue = Math.round(datasets[0]['data'][1] * 10) / 10
|
||||
|
||||
output += outputTime+": "+outputValue+"m"
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
min: new Date().setHours(0,0,0) - 60*60*24*14*1000,
|
||||
max: new Date().setHours(0,0,0),
|
||||
minInterval: 60*60*24*1000,
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.06)',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
margin: 10,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
name: 'Filament [m]',
|
||||
type: 'value',
|
||||
minInterval: 10,
|
||||
maxInterval: 100,
|
||||
nameLocation: 'end',
|
||||
nameGap: 5,
|
||||
nameTextStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
align: 'left',
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.12)',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
formatter: '{value}',
|
||||
//rotate: 90,
|
||||
//showMaxLabel: false,
|
||||
showMinLabel: true,
|
||||
margin: 5,
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.12)',
|
||||
},
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
type: 'line',
|
||||
data: [],
|
||||
lineStyle: {
|
||||
color: '#000',
|
||||
},
|
||||
showSymbol: false
|
||||
}],
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
|
||||
}),
|
||||
filamentUsageArray: {
|
||||
get: function() {
|
||||
return this.$store.getters["server/history/getFilamentUsageArray"]
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
createChart() {
|
||||
if (document.getElementById("historyFilamentUsage") && this.chart === null) {
|
||||
this.chart = echarts.init(document.getElementById("historyFilamentUsage"), null, { renderer: 'canvas' })
|
||||
this.chart.setOption(this.chartOptions)
|
||||
this.updateChart()
|
||||
} else setTimeout(() => {
|
||||
this.createChart()
|
||||
}, 500)
|
||||
},
|
||||
updateChart() {
|
||||
if (this.chart) {
|
||||
const chartOptions = { series: this.chartOptions.series }
|
||||
chartOptions.series[0].data = this.filamentUsageArray
|
||||
chartOptions.series[0].lineStyle.color = this.getPrimaryColor()
|
||||
this.chart.setOption(chartOptions)
|
||||
this.chart.resize()
|
||||
}
|
||||
},
|
||||
getPrimaryColor() {
|
||||
if (this.$vuetify.theme.isDark) {
|
||||
return this.$vuetify.theme.themes.dark.primary
|
||||
} else {
|
||||
return this.$vuetify.theme.themes.light.primary
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (this.chart) this.chart.resize()
|
||||
})
|
||||
},
|
||||
mounted: function() {
|
||||
this.createChart()
|
||||
},
|
||||
watch: {
|
||||
filamentUsageArray: {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.updateChart()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div id="historyPrinttimeAvg" style="height: 175px; width: 100%;"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
chart : null,
|
||||
chartOptions: {
|
||||
darkMode: true,
|
||||
animation: false,
|
||||
grid: {
|
||||
top: 25,
|
||||
right: 40,
|
||||
bottom: 30,
|
||||
left: 40,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['0-2h', '2-6h', '6-12h', '12-24h', '>24h'],
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.06)',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
margin: 10,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
name: 'Prints',
|
||||
type: 'value',
|
||||
minInterval: 10,
|
||||
maxInterval: 100,
|
||||
nameLocation: 'end',
|
||||
nameGap: 5,
|
||||
nameTextStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
align: 'left',
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.12)',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(255, 255, 255, 0.24)',
|
||||
formatter: '{value}',
|
||||
//rotate: 90,
|
||||
//showMaxLabel: false,
|
||||
showMinLabel: true,
|
||||
margin: 5,
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: 'rgba(255, 255, 255, 0.12)',
|
||||
},
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
type: 'bar',
|
||||
data: [],
|
||||
itemStyle: {
|
||||
color: '#000'
|
||||
}
|
||||
}]
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
|
||||
}),
|
||||
printtimeAvgArray: {
|
||||
get: function() {
|
||||
return this.$store.getters["server/history/getPrinttimeAvgArray"]
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
createChart() {
|
||||
if (document.getElementById("historyPrinttimeAvg") && this.chart === null) {
|
||||
this.chart = echarts.init(document.getElementById("historyPrinttimeAvg"), null, { renderer: 'canvas' })
|
||||
this.chart.setOption(this.chartOptions)
|
||||
this.updateChart()
|
||||
} else setTimeout(() => {
|
||||
this.createChart()
|
||||
}, 500)
|
||||
},
|
||||
updateChart() {
|
||||
if (this.chart) {
|
||||
const chartOptions = { series: this.chartOptions.series }
|
||||
chartOptions.series[0].data = this.printtimeAvgArray
|
||||
chartOptions.series[0].itemStyle.color = this.getPrimaryColor()
|
||||
this.chart.setOption(chartOptions)
|
||||
}
|
||||
},
|
||||
getPrimaryColor() {
|
||||
if (this.$vuetify.theme.isDark) {
|
||||
return this.$vuetify.theme.themes.dark.primary
|
||||
} else {
|
||||
return this.$vuetify.theme.themes.light.primary
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (this.chart) this.chart.resize()
|
||||
})
|
||||
},
|
||||
mounted: function() {
|
||||
this.createChart()
|
||||
},
|
||||
watch: {
|
||||
filamentUsageArray: {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.updateChart()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
Print History
|
||||
<v-spacer class="d-none d-sm-block"></v-spacer>
|
||||
<v-item-group class="v-btn-toggle my-5 my-sm-0 col-12 col-sm-auto px-0 py-0" name="controllers">
|
||||
<v-btn title="Refresh History" class="flex-grow-1" @click="refreshHistory"><v-icon>mdi-refresh</v-icon></v-btn>
|
||||
<v-menu :offset-y="true" :close-on-content-click="false" title="Setup current list">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn class="flex-grow-1" v-bind="attrs" v-on="on"><v-icon class="">mdi-cog</v-icon></v-btn>
|
||||
</template>
|
||||
<v-list>
|
||||
<v-list-item class="minHeight36" v-for="header of configHeaders" v-bind:key="header.key">
|
||||
<v-checkbox class="mt-0" hide-details v-model="header.visible" @change="changeColumnVisible(header.value)" :label="header.text"></v-checkbox>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-item-group>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
append-icon="mdi-magnify"
|
||||
label="Search"
|
||||
single-line
|
||||
hide-details
|
||||
></v-text-field>
|
||||
</v-card-text>
|
||||
<v-data-table
|
||||
:items="jobs"
|
||||
class="files-table"
|
||||
:headers="filteredHeaders"
|
||||
:options="options"
|
||||
:custom-sort="sortFiles"
|
||||
:sort-by.sync="sortBy"
|
||||
:sort-desc.sync="sortDesc"
|
||||
:items-per-page.sync="countPerPage"
|
||||
:footer-props="{
|
||||
itemsPerPageText: 'Files'
|
||||
}"
|
||||
item-key="name"
|
||||
:search="search"
|
||||
:custom-filter="advancedSearch"
|
||||
mobile-breakpoint="0">
|
||||
|
||||
<template slot="items" slot-scope="props">
|
||||
<td v-for="header in filteredHeaders" v-bind:key="header.text">{{ props.item[header.value] }}</td>
|
||||
</template>
|
||||
|
||||
<template #no-data>
|
||||
<div class="text-center">empty</div>
|
||||
</template>
|
||||
|
||||
<template #item="{ item }">
|
||||
<tr
|
||||
v-longpress:600="(e) => showContextMenu(e, item)"
|
||||
@contextmenu="showContextMenu($event, item)"
|
||||
@click="clickRow(item)"
|
||||
class="file-list-cursor user-select-none"
|
||||
>
|
||||
<td class="pr-0 text-center" style="width: 32px;">
|
||||
<v-icon v-if="!(getSmallThumbnail(item))">mdi-file</v-icon>
|
||||
<v-tooltip v-if="getSmallThumbnail(item) && getBigThumbnail(item)" top>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<img :src="getSmallThumbnail(item)" width="32" height="32" v-bind="attrs" v-on="on" />
|
||||
</template>
|
||||
<span><img :src="getBigThumbnail(item)" width="250" /></span>
|
||||
</v-tooltip>
|
||||
<img v-if="getSmallThumbnail(item) && !getBigThumbnail(item)" :src="getSmallThumbnail(item)" width="32" height="32" />
|
||||
</td>
|
||||
<td class=" ">{{ item.filename }}</td>
|
||||
<td class=" ">
|
||||
<v-chip :color="getIconColor(item.status)" small>{{ item.status }}</v-chip>
|
||||
</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'size')[0].visible">{{ 'size' in item.metadata && item.metadata.size ? formatFilesize(item.metadata.size) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'modified')[0].visible">{{ 'modified' in item.metadata && item.metadata.modified ? formatDate(item.metadata.modified) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'start_time')[0].visible">{{ item.start_time > 0 ? formatDate(item.start_time) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'end_time')[0].visible">{{ item.end_time > 0 ? formatDate(item.end_time) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'estimated_time')[0].visible">{{ 'estimated_time' in item.metadata && item.metadata.estimated_time ? formatPrintTime(item.metadata.estimated_time) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'print_duration')[0].visible">{{ item.print_duration > 0 ? formatPrintTime(item.print_duration) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'total_duration')[0].visible">{{ item.total_duration > 0 ? formatPrintTime(item.total_duration) : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'filament_total')[0].visible">{{ 'filament_total' in item.metadata && item.metadata.filament_total ? item.metadata.filament_total+' mm' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'filament_used')[0].visible">{{ item.filament_used ? item.filament_used.toFixed()+' mm' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'first_layer_extr_temp')[0].visible">{{ 'first_layer_extr_temp' in item.metadata && item.metadata.first_layer_extr_temp ? item.metadata.first_layer_extr_temp+' °C' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'first_layer_bed_temp')[0].visible">{{ 'first_layer_bed_temp' in item.metadata && item.metadata.first_layer_bed_temp ? item.metadata.first_layer_bed_temp+' °C' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'first_layer_height')[0].visible">{{ 'first_layer_height' in item.metadata && item.metadata.first_layer_height ? item.metadata.first_layer_height+' mm' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'layer_height')[0].visible">{{ 'layer_height' in item.metadata && item.metadata.layer_height ? item.metadata.layer_height+' mm' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'object_height')[0].visible">{{ 'object_height' in item.metadata && item.metadata.object_height ? item.metadata.object_height+' mm' : '--' }}</td>
|
||||
<td class=" " v-if="headers.filter(header => header.value === 'slicer')[0].visible">
|
||||
{{ 'slicer' in item.metadata && item.metadata.slicer ? item.metadata.slicer : '--' }}
|
||||
<small v-if="'slicer_version' in item.metadata && item.metadata.slicer_version"><br />{{ item.metadata.slicer_version }}</small>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
<v-menu v-model="contextMenu.shown" :position-x="contextMenu.x" :position-y="contextMenu.y" absolute offset-y>
|
||||
<v-list>
|
||||
<v-list-item >
|
||||
<v-icon class="mr-1">mdi-play</v-icon> Print start
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
search: '',
|
||||
sortBy: 'start_time',
|
||||
sortDesc: true,
|
||||
selected: [],
|
||||
hideHeaderColums: [],
|
||||
headers: [
|
||||
{ text: '', value: '', align: 'left', configable: false, visible: true, filterable: false },
|
||||
{ text: 'Name', value: 'filename', align: 'left', configable: false, visible: true },
|
||||
{ text: 'Status', value: 'status', align: 'left', configable: false, visible: true },
|
||||
{ text: 'Filesize', value: 'size', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Last modified', value: 'modified', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Start Time', value: 'start_time', align: 'left', configable: true, visible: true },
|
||||
{ text: 'End Time', value: 'end_time', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Estimated Time', value: 'estimated_time', align: 'left', configable: true, visible: true },
|
||||
{ text: 'Print Time', value: 'print_duration', align: 'left', configable: true, visible: true },
|
||||
{ text: 'Total Time', value: 'total_duration', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Filament Calc', value: 'filament_total', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Filament Used', value: 'filament_used', align: 'left', configable: true, visible: true },
|
||||
{ text: 'Ext. Temp.', value: 'first_layer_extr_temp', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Bed Temp.', value: 'first_layer_bed_temp', align: 'left', configable: true, visible: false },
|
||||
{ text: 'First Layer Height', value: 'first_layer_height', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Layer Height', value: 'layer_height', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Object Height', value: 'object_height', align: 'left', configable: true, visible: false },
|
||||
{ text: 'Slicer', value: 'slicer', align: 'left', configable: true, visible: true },
|
||||
],
|
||||
options: {
|
||||
|
||||
},
|
||||
contextMenu: {
|
||||
shown: false,
|
||||
isDirectory: false,
|
||||
touchTimer: undefined,
|
||||
x: 0,
|
||||
y: 0,
|
||||
item: {}
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
jobs: state => state.server.history.jobs,
|
||||
}),
|
||||
configHeaders() {
|
||||
return this.headers.filter(header => header.configable === true)
|
||||
},
|
||||
filteredHeaders() {
|
||||
return this.headers.filter(header => header.visible === true)
|
||||
},
|
||||
baseUrl: {
|
||||
get: function() {
|
||||
return this.$store.getters["socket/getUrl"]
|
||||
}
|
||||
},
|
||||
countPerPage: {
|
||||
get: function() {
|
||||
return this.$store.state.gui.history.countPerPage
|
||||
},
|
||||
set: function(newVal) {
|
||||
return this.$store.dispatch("gui/setSettings", { history: { countPerPage: newVal } })
|
||||
}
|
||||
},
|
||||
hideColums: {
|
||||
get: function() {
|
||||
return this.$store.state.gui.history.hideColums
|
||||
},
|
||||
set: function(newVal) {
|
||||
return this.$store.dispatch("gui/setSettings", { history: { hideColums: newVal } })
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.hideColums.forEach((key) => {
|
||||
let headerElement = this.headers.find(element => element.value === key)
|
||||
if (headerElement) headerElement.visible = false
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
getIcon(status) {
|
||||
switch(status) {
|
||||
case 'in_progress': return 'mdi-cogs'
|
||||
case 'completed': return 'mdi-check-circle'
|
||||
case 'cancelled': return 'mdi-close-circle'
|
||||
|
||||
default: return 'mdi-progress-question'
|
||||
}
|
||||
},
|
||||
getIconColor(status) {
|
||||
switch(status) {
|
||||
case 'in_progress': return 'white'
|
||||
case 'completed': return 'green'
|
||||
case 'cancelled': return 'red'
|
||||
|
||||
default: return 'orange'
|
||||
}
|
||||
},
|
||||
refreshHistory: function() {
|
||||
this.$socket.sendObj('server.history.list', {}, 'server/history/getHistory')
|
||||
},
|
||||
formatDate(date) {
|
||||
let tmp2 = new Date(date*1000)
|
||||
|
||||
return tmp2.toLocaleString().replace(',', '')
|
||||
},
|
||||
formatFilesize(fileSizeInBytes) {
|
||||
let i = -1
|
||||
let byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
do {
|
||||
fileSizeInBytes = fileSizeInBytes / 1024
|
||||
i++
|
||||
} while (fileSizeInBytes > 1024)
|
||||
|
||||
return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i]
|
||||
},
|
||||
formatPrintTime(totalSeconds) {
|
||||
if (totalSeconds) {
|
||||
let output = ""
|
||||
|
||||
let days = Math.floor(totalSeconds / (3600 * 24))
|
||||
if (days) {
|
||||
totalSeconds %= (3600 * 24)
|
||||
output += days+"d"
|
||||
}
|
||||
|
||||
let hours = Math.floor(totalSeconds / 3600)
|
||||
totalSeconds %= 3600
|
||||
if (hours) output += " "+hours+"h"
|
||||
|
||||
let minutes = Math.floor(totalSeconds / 60)
|
||||
if (minutes) output += " "+minutes+"m"
|
||||
|
||||
let seconds = totalSeconds % 60
|
||||
if (seconds) output += " "+seconds.toFixed(0)+"s"
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
return '--'
|
||||
},
|
||||
showContextMenu (e, item) {
|
||||
if (!this.contextMenu.shown) {
|
||||
e?.preventDefault();
|
||||
this.contextMenu.shown = true
|
||||
this.contextMenu.x = e?.clientX || e?.pageX || window.screenX / 2;
|
||||
this.contextMenu.y = e?.clientY || e?.pageY || window.screenY / 2;
|
||||
this.contextMenu.item = item
|
||||
this.$nextTick(() => {
|
||||
this.contextMenu.shown = true
|
||||
})
|
||||
}
|
||||
},
|
||||
sortFiles(items, sortBy, sortDesc) {
|
||||
sortBy = sortBy.length ? sortBy[0] : 'filename';
|
||||
sortDesc = sortDesc[0];
|
||||
|
||||
if (items !== undefined) {
|
||||
// Sort by index
|
||||
items.sort(function(a, b) {
|
||||
if (a[sortBy] === b[sortBy]) {
|
||||
return 0;
|
||||
}
|
||||
if (a[sortBy] === null || a[sortBy] === undefined) {
|
||||
return -1;
|
||||
}
|
||||
if (b[sortBy] === null || b[sortBy] === undefined) {
|
||||
return 1;
|
||||
}
|
||||
if (a[sortBy].constructor === String && b[sortBy].constructor === String) {
|
||||
return a[sortBy].localeCompare(b[sortBy], undefined, { sensivity: 'base' });
|
||||
}
|
||||
if (a[sortBy] instanceof Array && b[sortBy] instanceof Array) {
|
||||
const reducedA = a[sortBy].length ? a.filament.reduce((a, b) => a + b) : 0;
|
||||
const reducedB = b[sortBy].length ? b.filament.reduce((a, b) => a + b) : 0;
|
||||
return reducedA - reducedB;
|
||||
}
|
||||
return a[sortBy] - b[sortBy];
|
||||
});
|
||||
|
||||
// Deal with descending order
|
||||
if (sortDesc) items.reverse()
|
||||
}
|
||||
return items;
|
||||
},
|
||||
advancedSearch: function(value, search) {
|
||||
return value != null &&
|
||||
search != null &&
|
||||
typeof value === 'string' &&
|
||||
value.toString().toLowerCase().indexOf(search.toLowerCase()) !== -1
|
||||
},
|
||||
changeColumnVisible: function(name) {
|
||||
if (this.headers.filter(header => header.value === name).length) {
|
||||
let value = this.headers.filter(header => header.value === name)[0].visible;
|
||||
|
||||
this.$store.dispatch("gui/setHistoryColumns", {name: name, value: value});
|
||||
}
|
||||
},
|
||||
getSmallThumbnail(item) {
|
||||
if (
|
||||
'metadata' in item &&
|
||||
'thumbnails' in item.metadata &&
|
||||
item.metadata.thumbnails.length
|
||||
) {
|
||||
const thumbnail = item.metadata.thumbnails.find(thumb =>
|
||||
thumb.width >= 32 && thumb.width <= 64 &&
|
||||
thumb.height >= 32 && thumb.height <= 64
|
||||
)
|
||||
|
||||
if (thumbnail && 'relative_path' in thumbnail) return this.baseUrl+"/server/files/gcodes/"+thumbnail.relative_path
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
getBigThumbnail(item) {
|
||||
if (
|
||||
'metadata' in item &&
|
||||
'thumbnails' in item.metadata &&
|
||||
item.metadata.thumbnails.length
|
||||
) {
|
||||
const thumbnail = item.metadata.thumbnails.find(thumb => thumb.width >= 300 && thumb.width <= 400)
|
||||
|
||||
if (thumbnail && 'relative_path' in thumbnail) return this.baseUrl+"/server/files/gcodes/"+thumbnail.relative_path
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
hideColums: function(newVal) {
|
||||
newVal.forEach((key) => {
|
||||
let headerElement = this.headers.find(element => element.value === key)
|
||||
if (headerElement) headerElement.visible = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -12,6 +12,7 @@ import WebcamPanel from "./WebcamPanel";
|
||||
import MiniconsolePanel from "./MiniconsolePanel";
|
||||
import Settings from "./Settings/";
|
||||
import PowerControlPanel from "./PowerControlPanel.vue";
|
||||
import HistoryListPanel from "./HistoryListPanel.vue";
|
||||
|
||||
Vue.component('status-panel', StatusPanel);
|
||||
Vue.component('klippy-state-panel', KlippyStatePanel);
|
||||
@@ -24,6 +25,7 @@ Vue.component('miscellaneous-panel', Miscellaneous);
|
||||
Vue.component('webcam-panel', WebcamPanel);
|
||||
Vue.component('miniconsole-panel', MiniconsolePanel);
|
||||
Vue.component('power-control-panel', PowerControlPanel);
|
||||
Vue.component('history-list-panel', HistoryListPanel);
|
||||
|
||||
export default {
|
||||
Settings
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-toolbar flat dense >
|
||||
<v-toolbar-title>
|
||||
<span class="subheading"><v-icon left>mdi-chart-areaspline</v-icon>Statistics</span>
|
||||
</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
<v-card-text class="pa-0">
|
||||
<v-row align="center">
|
||||
<v-col class="col-4">
|
||||
<v-simple-table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Total Printtime</td>
|
||||
<td class="text-right">{{ formatPrintTime(totalPrintTime) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Longest Printtime</td>
|
||||
<td class="text-right">{{ formatPrintTime(longestPrintTime) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Avg. Printtime</td>
|
||||
<td class="text-right">{{ formatPrintTime(avgPrintTime) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total Filament used</td>
|
||||
<td class="text-right">{{ Math.round(totalFilamentUsed / 100) / 10 }} m</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total Jobs</td>
|
||||
<td class="text-right">{{ totalTotalJobsCount }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-simple-table>
|
||||
</v-col>
|
||||
<v-col class="col-4">
|
||||
<history-all-print-status></history-all-print-status>
|
||||
</v-col>
|
||||
<v-col class="col-4">
|
||||
<history-filament-usage v-if="toggleChart === 'filament_usage'"></history-filament-usage>
|
||||
<history-printtime-avg v-if="toggleChart === 'printtime_avg'"></history-printtime-avg>
|
||||
<div class="text-center mt-3">
|
||||
<v-btn-toggle v-model="toggleChart" small>
|
||||
<v-btn small value="filament_usage">
|
||||
Filament usage
|
||||
</v-btn>
|
||||
<v-btn small value="printtime_avg">
|
||||
Printime AVG
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="mt-6">
|
||||
<v-col>
|
||||
<history-list-panel></history-list-panel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import HistoryAllPrintStatus from "@/components/charts/HistoryAllPrintStatus"
|
||||
import HistoryFilamentUsage from "@/components/charts/HistoryFilamentUsage"
|
||||
import HistoryPrinttimeAvg from "@/components/charts/HistoryPrinttimeAvg"
|
||||
import HistoryListPanel from "@/components/panels/HistoryListPanel"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HistoryAllPrintStatus,
|
||||
HistoryFilamentUsage,
|
||||
HistoryPrinttimeAvg,
|
||||
HistoryListPanel
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
totalPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalPrintTime"]
|
||||
}
|
||||
},
|
||||
longestPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getLongestPrintTime"]
|
||||
}
|
||||
},
|
||||
avgPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getAvgPrintTime"]
|
||||
}
|
||||
},
|
||||
totalFilamentUsed: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalFilamentUsed"]
|
||||
}
|
||||
},
|
||||
totalTotalJobsCount: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalJobsCount"]
|
||||
}
|
||||
},
|
||||
toggleChart: {
|
||||
get() {
|
||||
return this.$store.state.gui.history.toggleChartCol3
|
||||
},
|
||||
set: function(newVal) {
|
||||
return this.$store.dispatch("gui/setSettings", { history: { toggleChartCol3: newVal } })
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatPrintTime(totalSeconds) {
|
||||
if (totalSeconds) {
|
||||
let output = ""
|
||||
|
||||
let days = Math.floor(totalSeconds / (3600 * 24))
|
||||
if (days) {
|
||||
totalSeconds %= (3600 * 24)
|
||||
output += days+"d"
|
||||
}
|
||||
|
||||
let hours = Math.floor(totalSeconds / 3600)
|
||||
totalSeconds %= 3600
|
||||
if (hours) output += " "+hours+"h"
|
||||
|
||||
let minutes = Math.floor(totalSeconds / 60)
|
||||
if (minutes) output += " "+minutes+"m"
|
||||
|
||||
let seconds = totalSeconds % 60
|
||||
if (seconds) output += " "+seconds.toFixed(0)+"s"
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
return '--'
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+17
-14
@@ -11,22 +11,25 @@ Vue.use(VueToast, {
|
||||
})
|
||||
|
||||
Vue.use(Vuetify,{
|
||||
components: {
|
||||
VSnackbar,
|
||||
VBtn,
|
||||
VIcon,
|
||||
}
|
||||
options: {
|
||||
customProperties: true
|
||||
},
|
||||
components: {
|
||||
VSnackbar,
|
||||
VBtn,
|
||||
VIcon,
|
||||
}
|
||||
})
|
||||
|
||||
export default new Vuetify({
|
||||
theme: {
|
||||
themes: {
|
||||
dark: {
|
||||
theme: {
|
||||
themes: {
|
||||
dark: {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
iconfont: 'mdi',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
iconfont: 'mdi',
|
||||
},
|
||||
})
|
||||
@@ -4,6 +4,7 @@ import Farm from '../pages/Farm.vue'
|
||||
import Console from '../pages/Console.vue'
|
||||
import Heightmap from '../pages/Heightmap.vue'
|
||||
import Files from '../pages/Files.vue'
|
||||
import History from '../pages/History.vue'
|
||||
import Settings from '../pages/Settings.vue'
|
||||
import SettingsInterface from '../pages/settings/interface.vue'
|
||||
import SettingsMachine from '../pages/settings/machine.vue'
|
||||
@@ -56,6 +57,13 @@ const routes = [
|
||||
component: Files,
|
||||
alwaysShow: false,
|
||||
},
|
||||
{
|
||||
title: "History",
|
||||
path: '/history',
|
||||
icon: 'history',
|
||||
component: History,
|
||||
alwaysShow: false,
|
||||
},
|
||||
{
|
||||
title: "Settings",
|
||||
path: '/settings',
|
||||
|
||||
@@ -22,6 +22,7 @@ export default {
|
||||
item.isDirectory &&
|
||||
'filename' in item &&
|
||||
'dirs' in payload &&
|
||||
payload.dirs !== undefined &&
|
||||
payload.dirs.length > 0 &&
|
||||
payload.dirs.findIndex(element => element.dirname === item.filename) < 0
|
||||
) parent.splice(key, 1)
|
||||
|
||||
@@ -144,5 +144,13 @@ export default {
|
||||
dispatch('farm/readStoredPrinters', {}, { root: true })
|
||||
}
|
||||
dispatch('printer/init', null, { root: true })
|
||||
}
|
||||
},
|
||||
|
||||
setHistoryColumns({ commit, dispatch, state }, data) {
|
||||
commit('setHistoryColumns', data)
|
||||
dispatch('updateSettings', {
|
||||
keyName: 'history',
|
||||
newVal: state.history
|
||||
})
|
||||
},
|
||||
}
|
||||
@@ -59,6 +59,11 @@ export function getDefaultState() {
|
||||
showHiddenFiles: false,
|
||||
hideMetadataColums: []
|
||||
},
|
||||
history: {
|
||||
countPerPage: 10,
|
||||
toggleChartCol3: 'filament_usage',
|
||||
hideColums: []
|
||||
},
|
||||
settings: {
|
||||
configfiles: {
|
||||
countPerPage: 10,
|
||||
|
||||
@@ -88,5 +88,13 @@ export default {
|
||||
Vue.set(state.tempchart.datasetSettings[payload.name]['additionalSensors'], payload.sensor, {})
|
||||
|
||||
Vue.set(state.tempchart.datasetSettings[payload.name]['additionalSensors'][payload.sensor], 'boolList', payload.value)
|
||||
}
|
||||
},
|
||||
|
||||
setHistoryColumns(state, data) {
|
||||
if (data.value && state.history.hideColums.includes(data.name)) {
|
||||
state.history.hideColums.splice(state.history.hideColums.indexOf(data.name), 1)
|
||||
} else if (!data.value && !state.history.hideColums.includes(data.name)) {
|
||||
state.history.hideColums.push(data.name)
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -53,6 +53,9 @@ export default {
|
||||
|
||||
if (payload.plugins.includes("update_manager") !== false)
|
||||
Vue.prototype.$socket.sendObj('machine.update.status', {}, 'server/updateManager/getStatus')
|
||||
|
||||
if (payload.plugins.includes("history") !== false)
|
||||
Vue.prototype.$socket.sendObj('server.history.list', {}, 'server/history/getHistory')
|
||||
}
|
||||
|
||||
if (state.registered_directories.length === 0 && 'registered_directories' in payload) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export default {
|
||||
reset({ commit }) {
|
||||
commit('reset')
|
||||
},
|
||||
|
||||
getHistory({ commit, state }, payload) {
|
||||
commit('reset')
|
||||
|
||||
payload.jobs.forEach(job => {
|
||||
const index = state.jobs.findIndex(tmpJob => tmpJob.job_id === job.job_id)
|
||||
if (index === -1) {
|
||||
commit('addJob', job)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
export default {
|
||||
|
||||
getTotalPrintTime(state) {
|
||||
let output = 0
|
||||
|
||||
state.jobs.forEach(current => {
|
||||
output += current.print_duration
|
||||
})
|
||||
|
||||
return output
|
||||
},
|
||||
|
||||
getTotalCompletedPrintTime(state) {
|
||||
let output = 0
|
||||
|
||||
state.jobs.forEach(current => {
|
||||
if (current.status === "completed") output += current.print_duration
|
||||
})
|
||||
|
||||
return output
|
||||
},
|
||||
|
||||
getLongestPrintTime(state) {
|
||||
let output = 0
|
||||
|
||||
state.jobs.forEach(current => {
|
||||
if (current.print_duration > output) output = current.print_duration
|
||||
})
|
||||
|
||||
return output
|
||||
},
|
||||
|
||||
getTotalFilamentUsed(state) {
|
||||
let output = 0
|
||||
|
||||
state.jobs.forEach(current => {
|
||||
output += current.filament_used
|
||||
})
|
||||
|
||||
return output
|
||||
},
|
||||
|
||||
getTotalJobsCount(state) {
|
||||
return state.jobs.length
|
||||
},
|
||||
|
||||
getTotalCompletedJobsCount(state) {
|
||||
return state.jobs.filter(job => job.status === "completed").length
|
||||
},
|
||||
|
||||
getAvgPrintTime(state, getters) {
|
||||
const totalCompletedPrintTime = getters.getTotalCompletedPrintTime
|
||||
const totalCompletedJobsCount = getters.getTotalCompletedJobsCount
|
||||
|
||||
return totalCompletedPrintTime > 0 && totalCompletedJobsCount > 0 ? Math.round(totalCompletedPrintTime / totalCompletedJobsCount) : 0
|
||||
},
|
||||
|
||||
getAllPrintStatusArray(state) {
|
||||
let output = []
|
||||
|
||||
state.jobs.forEach(current => {
|
||||
const index = output.findIndex(element => element.name === current.status)
|
||||
if (index !== -1) output[index].value +=1
|
||||
else {
|
||||
let itemStyle = {
|
||||
opacity: 0.9,
|
||||
color: '#212121'
|
||||
}
|
||||
|
||||
switch (current.status) {
|
||||
case 'completed':
|
||||
itemStyle['color'] = '#BDBDBD'
|
||||
break
|
||||
|
||||
case 'in_progress':
|
||||
itemStyle['color'] = '#EEEEEE'
|
||||
break
|
||||
|
||||
case 'cancelled':
|
||||
itemStyle['color'] = '#424242'
|
||||
break
|
||||
}
|
||||
|
||||
output.push({
|
||||
name: current.status,
|
||||
value: 1,
|
||||
itemStyle: itemStyle
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return output
|
||||
},
|
||||
|
||||
getFilamentUsageArray(state) {
|
||||
let output = []
|
||||
const startDate = new Date(new Date().getDate() - 14)
|
||||
const jobsFiltered = state.jobs.filter(job => job.start_time * 1000 >= startDate && job.filament_used > 0)
|
||||
|
||||
if (jobsFiltered.length) {
|
||||
jobsFiltered.forEach(current => {
|
||||
const currentStartDate = new Date(current.start_time * 1000).setHours(0,0,0,0)
|
||||
const index = output.findIndex(element => element[0] === currentStartDate)
|
||||
if (index !== -1) output[index][1] += Math.round(current.filament_used) / 1000
|
||||
else
|
||||
output.push([
|
||||
currentStartDate,
|
||||
Math.round(current.filament_used) / 1000
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
return output.sort((a,b) => {
|
||||
return b[0] - a[0]
|
||||
})
|
||||
},
|
||||
|
||||
getPrinttimeAvgArray(state) {
|
||||
let output = [0,0,0,0,0]
|
||||
const startDate = new Date(new Date().getDate() - 14)
|
||||
const jobsFiltered = state.jobs.filter(job => job.start_time * 1000 >= startDate && job.status === 'completed')
|
||||
|
||||
if (jobsFiltered.length) {
|
||||
jobsFiltered.forEach(current => {
|
||||
if (current.print_duration > 0 && current.print_duration <= 60*60*2) output[0]++
|
||||
else if (current.print_duration > 60*60*2 && current.print_duration <= 60*60*6) output[1]++
|
||||
else if (current.print_duration > 60*60*6 && current.print_duration <= 60*60*12) output[2]++
|
||||
else if (current.print_duration > 60*60*12 && current.print_duration <= 60*60*24) output[3]++
|
||||
else if (current.print_duration > 60*60*24) output[4]++
|
||||
})
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import actions from './actions'
|
||||
import mutations from './mutations'
|
||||
import getters from './getters'
|
||||
|
||||
export function getDefaultState() {
|
||||
return {
|
||||
jobs: []
|
||||
}
|
||||
}
|
||||
|
||||
// initial state
|
||||
const state = getDefaultState()
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { getDefaultState } from './index'
|
||||
|
||||
export default {
|
||||
reset(state) {
|
||||
Object.assign(state, getDefaultState())
|
||||
},
|
||||
|
||||
addJob(state, payload) {
|
||||
state.jobs.push(payload)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import getters from './getters'
|
||||
// import modules
|
||||
import power from './power'
|
||||
import updateManager from './updateManager'
|
||||
import history from './history'
|
||||
|
||||
// create getDefaultState
|
||||
export function getDefaultState() {
|
||||
@@ -32,5 +33,6 @@ export default {
|
||||
modules: {
|
||||
power,
|
||||
updateManager,
|
||||
history,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user