update history to moonraker history totals
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
1 parent
f943c24086
commit
0b5188d187
5 files changed
+26
-9
No files matched your search
@@ -35,7 +35,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total Jobs</td>
|
||||
<td class="text-right">{{ totalTotalJobsCount }}</td>
|
||||
<td class="text-right">{{ totalJobsCount }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-simple-table>
|
||||
@@ -90,27 +90,29 @@
|
||||
computed: {
|
||||
totalPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalPrintTime"]
|
||||
return 'total_print_time' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_print_time : 0
|
||||
}
|
||||
},
|
||||
longestPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getLongestPrintTime"]
|
||||
return 'longest_print' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.longest_print : 0
|
||||
}
|
||||
},
|
||||
avgPrintTime: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getAvgPrintTime"]
|
||||
if (this.totalJobsCount > 0 && this.totalPrintTime > 0) return Math.round(this.totalPrintTime / this.totalJobsCount)
|
||||
|
||||
return 0
|
||||
}
|
||||
},
|
||||
totalFilamentUsed: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalFilamentUsed"]
|
||||
return 'total_filament_used' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_filament_used : 0
|
||||
}
|
||||
},
|
||||
totalTotalJobsCount: {
|
||||
totalJobsCount: {
|
||||
get() {
|
||||
return this.$store.getters["server/history/getTotalJobsCount"]
|
||||
return 'total_jobs' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_jobs : 0
|
||||
}
|
||||
},
|
||||
toggleChart: {
|
||||
|
||||
@@ -58,8 +58,10 @@ export default {
|
||||
if (components.includes("update_manager") !== false)
|
||||
Vue.prototype.$socket.sendObj('machine.update.status', {}, 'server/updateManager/getStatus')
|
||||
|
||||
if (payload.plugins.includes("history") !== false)
|
||||
if (payload.plugins.includes("history") !== false) {
|
||||
Vue.prototype.$socket.sendObj('server.history.list', {}, 'server/history/getHistory')
|
||||
Vue.prototype.$socket.sendObj('server.history.totals', {}, 'server/history/getTotals')
|
||||
}
|
||||
}
|
||||
|
||||
if (state.registered_directories.length === 0 && 'registered_directories' in payload) {
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import Vue from "vue";
|
||||
|
||||
export default {
|
||||
reset({ commit }) {
|
||||
commit('reset')
|
||||
},
|
||||
|
||||
getTotals({ commit }, payload) {
|
||||
commit('setTotals', payload.job_totals)
|
||||
},
|
||||
|
||||
getHistory({ commit }, payload) {
|
||||
commit('reset')
|
||||
|
||||
@@ -14,6 +20,8 @@ export default {
|
||||
getChanged({ commit }, payload) {
|
||||
if (payload.action === 'added') commit('addJob', payload.job)
|
||||
else if (payload.action === 'finished') commit('updateJob', payload.job)
|
||||
|
||||
Vue.prototype.$socket.sendObj('server.history.totals', {}, 'server/history/getTotals')
|
||||
},
|
||||
|
||||
getDeletedJobs({ commit }, payload) {
|
||||
|
||||
@@ -4,7 +4,8 @@ import getters from './getters'
|
||||
|
||||
export function getDefaultState() {
|
||||
return {
|
||||
jobs: []
|
||||
jobs: [],
|
||||
job_totals: {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ export default {
|
||||
Object.assign(state, getDefaultState())
|
||||
},
|
||||
|
||||
setTotals(state, payload) {
|
||||
Vue.set(state, 'job_totals', payload)
|
||||
},
|
||||
|
||||
addJob(state, payload) {
|
||||
state.jobs.push(payload)
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user