-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stefan Dej <[email protected]>
- Loading branch information
Showing
6 changed files
with
411 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
src/components/dialogs/HistoryListPanelDetailMaintenanceHistoryEntry.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<template> | ||
<v-timeline-item small> | ||
<v-row class="pt-1"> | ||
<v-col> | ||
<strong>{{ date }}</strong> | ||
<div> | ||
<span v-if="restFilamentText" class="mr-3"> | ||
<v-icon small>{{ mdiAdjust }}</v-icon> | ||
{{ restFilamentText }} | ||
</span> | ||
<span v-if="restPrinttimeText" class="mr-3"> | ||
<v-icon small left>{{ mdiAlarm }}</v-icon> | ||
{{ restPrinttimeText }} | ||
</span> | ||
<span v-if="restDaysText" class="mr-3"> | ||
<v-icon small left>{{ mdiCalendar }}</v-icon> | ||
{{ restDaysText }} | ||
</span> | ||
</div> | ||
</v-col> | ||
</v-row> | ||
</v-timeline-item> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import Panel from '@/components/ui/Panel.vue' | ||
import { mdiAdjust, mdiAlarm, mdiCalendar, mdiCloseThick } from '@mdi/js' | ||
import { GuiMaintenanceStateEntry } from '@/store/gui/maintenance/types' | ||
@Component({ | ||
components: { Panel }, | ||
}) | ||
export default class HistoryListPanelDetailMaintenanceHistoryEntry extends Mixins(BaseMixin) { | ||
mdiAdjust = mdiAdjust | ||
mdiAlarm = mdiAlarm | ||
mdiCalendar = mdiCalendar | ||
mdiCloseThick = mdiCloseThick | ||
@Prop({ type: Object, default: false }) readonly item!: GuiMaintenanceStateEntry | ||
get date() { | ||
return this.formatDate(this.item.start_time * 1000, false) | ||
} | ||
get restFilament() { | ||
const start = this.item?.start_filament ?? 0 | ||
const end = this.item.end_filament ?? 0 | ||
const current = this.$store.state.server.history.job_totals?.total_filament_used ?? 0 | ||
// calc filament since start | ||
// if end is not null, calc used filament until end | ||
let used = current - start | ||
if (end) used = end - start | ||
// convert to m | ||
used /= 1000 | ||
return used | ||
} | ||
get restFilamentText() { | ||
if (!this.item.reminder.filament.bool) return false | ||
const value = this.item.reminder.filament?.value ?? 0 | ||
return `${this.restFilament.toFixed(0)} / ${value} m` | ||
} | ||
get restFilamentClass() { | ||
const output = ['text-right'] | ||
if (!this.item.reminder.filament.bool) return output | ||
const value = this.item.reminder.filament?.value ?? 0 | ||
if (this.restFilament > value) return [...output, 'error--text'] | ||
return output | ||
} | ||
get restPrinttime() { | ||
const start = this.item.start_printtime ?? 0 | ||
const end = this.item.end_printtime ?? 0 | ||
const current = this.$store.state.server.history.job_totals?.total_print_time ?? 0 | ||
// calc filament since start | ||
// if end is not null, calc used filament until end | ||
let used = current - start | ||
if (end) used = end - start | ||
// convert to h | ||
used /= 3600 | ||
return used | ||
} | ||
get restPrinttimeText() { | ||
if (!this.item.reminder.printtime.bool) return false | ||
const value = this.item.reminder.printtime?.value ?? 0 | ||
return `${this.restPrinttime.toFixed(1)} / ${value} h` | ||
} | ||
get restPrinttimeClass() { | ||
const output = ['text-right'] | ||
if (!this.item.reminder.printtime.bool) return output | ||
const value = this.item.reminder.printtime?.value ?? 0 | ||
if (this.restPrinttime > value) return [...output, 'error--text'] | ||
return output | ||
} | ||
get restDays() { | ||
const start = this.item.start_time ?? 0 | ||
const end = this.item.end_time ?? 0 | ||
const current = new Date().getTime() / 1000 | ||
// calc days since start | ||
// if end is not null, calc used days until end | ||
let used = current - start | ||
if (end) used = end - start | ||
return used / (60 * 60 * 24) | ||
} | ||
get restDaysText() { | ||
if (!this.item.reminder.date.bool) return false | ||
const value = this.item.reminder.date?.value ?? 0 | ||
return `${this.restDays.toFixed(0)} / ${value} days` | ||
} | ||
get restDaysClass() { | ||
const output = ['text-right'] | ||
if (!this.item.reminder.date.bool) return output | ||
const value = this.item.reminder.date?.value ?? 0 | ||
if (this.restDays > value) return [...output, 'error--text'] | ||
return output | ||
} | ||
get showPerformButton() { | ||
if (this.item.end_time) return false | ||
return this.item.reminder?.type ?? false | ||
} | ||
get performButtonText() { | ||
if (this.item.reminder?.type === 'repeat') return this.$t('History.PerformedAndReschedule') | ||
return this.$t('History.Performed') | ||
} | ||
get allEntries() { | ||
return this.$store.getters['gui/maintenance/getEntries'] ?? [] | ||
} | ||
get history() { | ||
const array = [] | ||
let latest_entry_id = this.item.id | ||
while (latest_entry_id) { | ||
const entry = this.allEntries.find((entry: GuiMaintenanceStateEntry) => entry.id === latest_entry_id) | ||
if (!entry) break | ||
array.push(entry) | ||
latest_entry_id = entry.last_entry | ||
} | ||
window.console.log(array) | ||
return array | ||
} | ||
closeDialog() { | ||
this.$emit('close') | ||
} | ||
perform() { | ||
this.$store.dispatch('gui/maintenance/perform', { id: this.item.id }) | ||
} | ||
} | ||
</script> |
Oops, something went wrong.