Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add total/selectable print time and filament usage to gcode files panel #1416

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions src/components/panels/GcodefilesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,31 @@
</v-card-text>
<v-card-text>
<v-row>
<v-col class="col-12 py-2 d-flex align-center">
<v-col class="panel-info-bar col-12 py-2 d-flex align-center">
<span>
<b>{{ $t('Files.CurrentPath') }}:</b>
{{ currentPath || '/' }}
</span>
<v-spacer></v-spacer>
<span class="mr-6">
<b>{{ $t('Files.PrintTime') }}:</b>
{{ getColumnSum('estimated_time') }}
</span>
<template v-if="getColumnSum('filament_weight_total')">
<v-tooltip top>
<template #activator="{ on, attrs }">
<span class="filament-weight-sum mr-6" v-bind="attrs" v-on="on">
<b>{{ $t('Files.FilamentWeight') }}:</b>
{{ getColumnSum('filament_weight_total') }}
</span>
</template>
<span>
{{ $t('Files.FilamentWeight') }}: {{ getColumnSum('filament_weight_total') }}
<br />
{{ $t('Files.FilamentUsage') }}: {{ getColumnSum('filament_total') }}
</span>
</v-tooltip>
</template>
<template v-if="disk_usage !== null">
<v-tooltip top>
<template #activator="{ on, attrs }">
Expand Down Expand Up @@ -1091,6 +1110,21 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
return this.$store.getters['server/history/getPrintStatusIconColor'](status)
}

getColumnSum(columnValue: string) {
const col = this.tableColumns.find((c) => c.value == columnValue)
if (col && col.outputType) {
let files = this.files
if (this.selectedFiles && this.selectedFiles.length > 0) {
files = this.selectedFiles
}

const sum = files.reduce((sum: number, file: FileStateGcodefile) => {
return sum + (file[col.value] || 0)
}, 0)
return this.formatOutputValue(sum, col.outputType)
}
}

dragOverFilelist(e: any, row: any) {
e.preventDefault()

Expand Down Expand Up @@ -1472,9 +1506,12 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {

outputValue(col: any, item: FileStateGcodefile) {
const value = col.value in item ? item[col.value] : null
return this.formatOutputValue(value, col.outputType)
}

formatOutputValue(value: any, valueType: string) {
if (value !== null) {
switch (col.outputType) {
switch (valueType) {
case 'filesize':
return formatFilesize(value)

Expand Down Expand Up @@ -1552,4 +1589,18 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
.handle {
cursor: move;
}

/*noinspection CssUnusedSymbol*/
@media (max-width: 768px) {
.filament-weight-sum {
display: none;
}
}

/*noinspection CssUnusedSymbol*/
@media (max-width: 375px) {
.panel-info-bar b {
display: block;
}
}
</style>