Skip to content

Commit

Permalink
feat: adds "interrupted" job status support
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Jan 4, 2024
1 parent fd6757e commit 45ebd1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
40 changes: 22 additions & 18 deletions src/components/widgets/history/JobHistoryItemStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Component, Mixins, Prop } from 'vue-property-decorator'
import FilesMixin from '@/mixins/files'
import type { HistoryItem } from '@/store/history/types'
type JobHistoryItemState = 'error' | 'warning' | 'success'
@Component({})
export default class JobHistoryItemStatus extends Mixins(FilesMixin) {
@Prop({ type: Object, required: true })
Expand All @@ -37,12 +39,13 @@ export default class JobHistoryItemStatus extends Mixins(FilesMixin) {
// }
get icon () {
const iconMap: { [index: string]: string } = {
const iconMap: Record<string, string> = {
completed: '$checkedCircle',
printing: '$inProgress',
in_progress: '$inProgress',
standby: '$inProgress',
cancelled: '$cancelled'
cancelled: '$cancelled',
interrupted: '$cancelled'
}
const icon = iconMap[this.job.status]
Expand All @@ -51,25 +54,26 @@ export default class JobHistoryItemStatus extends Mixins(FilesMixin) {
return icon || '$warning'
}
get state () {
if (
this.job.status === 'cancelled' ||
this.job.status === 'error' ||
this.job.status === 'server_exit'
) return 'error'
get state (): JobHistoryItemState {
switch (this.job.status) {
case 'cancelled':
case 'error':
case 'interrupted':
case 'server_exit':
return 'error'
if (
this.job.status === 'printing' ||
this.job.status === 'completed' ||
this.job.status === 'in_progress'
) return 'success'
case 'klippy_shutdown':
case 'klippy_disconnect':
return 'warning'
if (
this.job.status === 'klippy_shutdown' ||
this.job.status === 'klippy_disconnect'
) return 'warning'
case 'completed':
case 'in_progress':
case 'printing':
return 'success'
return 'success'
default:
return 'success'
}
}
get inError () {
Expand Down
2 changes: 1 addition & 1 deletion src/store/history/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export interface HistoryRollUp {
longest_print: number;
}

export type HistoryItemStatus = 'completed' | 'cancelled' | 'error' | 'printing' | 'in_progress' | 'server_exit' | 'klippy_shutdown' | 'klippy_disconnect'
export type HistoryItemStatus = 'completed' | 'cancelled' | 'error' | 'printing' | 'in_progress' | 'server_exit' | 'klippy_shutdown' | 'klippy_disconnect' | 'interrupted'

0 comments on commit 45ebd1b

Please sign in to comment.