feat: translate job status in history (#713)

This commit is contained in:
Stefan Dej authored and GitHub committed 2022-03-13 21:31:52 +01:00
1 parent 7bf5fe77cf
commit adf922c048
9 files changed
+98 -27

No files matched your search

@@ -12,6 +12,8 @@ import Component from 'vue-class-component'
import { Mixins, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import type { ECharts } from 'echarts/core'
import { ECBasicOption } from 'echarts/types/dist/shared'
import { ServerHistoryStateAllPrintStatusEntry } from '@/store/server/history/types'
@Component({
components: {},
@@ -21,7 +23,7 @@ export default class HistoryAllPrintStatus extends Mixins(BaseMixin) {
historyAllPrintStatus: any
}
private chartOptions: any = {
private chartOptions: ECBasicOption = {
darkMode: true,
animation: false,
grid: {
@@ -64,12 +66,20 @@ export default class HistoryAllPrintStatus extends Mixins(BaseMixin) {
}
get printStatusArray() {
return this.selectedJobs.length ? this.selectedPrintStatusArray : this.allPrintStatusArray
const output: ServerHistoryStateAllPrintStatusEntry[] = []
const orgArray = this.selectedJobs.length ? this.selectedPrintStatusArray : this.allPrintStatusArray
orgArray.forEach((status: ServerHistoryStateAllPrintStatusEntry) => {
const tmp = { ...status }
tmp.name = status.displayName
output.push(tmp)
})
return output
}
get chart(): ECharts | null {
const historyAllPrintStatus = this.$refs.historyAllPrintStatus
return historyAllPrintStatus?.inst ?? null
return this.$refs.historyAllPrintStatus ?? null
}
mounted() {
@@ -90,11 +100,15 @@ export default class HistoryAllPrintStatus extends Mixins(BaseMixin) {
@Watch('printStatusArray')
printStatusArrayChanged(newVal: any) {
this.chart?.setOption({
series: {
data: newVal,
this.chart?.setOption(
{
series: {
data: newVal,
},
},
})
false,
true
)
}
visibilityChanged(isVisible: boolean) {
@@ -109,8 +109,7 @@ export default class HistoryPrinttimeAvg extends Mixins(BaseMixin) {
}
get chart(): ECharts | null {
const historyFilamentUsage = this.$refs.historyFilamentUsage
return historyFilamentUsage?.inst ?? null
return this.$refs.historyFilamentUsage ?? null
}
mounted() {
@@ -131,11 +130,15 @@ export default class HistoryPrinttimeAvg extends Mixins(BaseMixin) {
@Watch('filamentUsageArray')
filamentUsageArrayChanged(newVal: any) {
this.chart?.setOption({
series: {
data: newVal,
this.chart?.setOption(
{
series: {
data: newVal,
},
},
})
false,
true
)
}
visibilityChanged(isVisible: boolean) {
@@ -95,8 +95,7 @@ export default class HistoryPrinttimeAvg extends Mixins(BaseMixin) {
}
get chart(): ECharts | null {
const historyPrinttimeAvg = this.$refs.historyPrinttimeAvg
return historyPrinttimeAvg?.inst ?? null
return this.$refs.historyPrinttimeAvg ?? null
}
mounted() {
@@ -117,11 +116,15 @@ export default class HistoryPrinttimeAvg extends Mixins(BaseMixin) {
@Watch('printtimeAvgArray')
printtimeAvgArrayChanged(newVal: any) {
this.chart?.setOption({
series: {
data: newVal,
this.chart?.setOption(
{
series: {
data: newVal,
},
},
})
false,
true
)
}
visibilityChanged(isVisible: boolean) {
+7
View File
@@ -0,0 +1,7 @@
$t('History.StatusValues.cancelled')
$t('History.StatusValues.completed')
$t('History.StatusValues.error')
$t('History.StatusValues.in_progress')
$t('History.StatusValues.klippy_disconnect')
$t('History.StatusValues.klippy_shutdown')
$t('History.StatusValues.server_exit')
+15 -5
View File
@@ -69,9 +69,7 @@
class="mt-0"
hide-details
:input-value="status.showInTable"
:label="
$t('History.ShowStatusName', { name: status.name, count: status.value })
"
:label="`${status.displayName} (${status.value})`"
@change="changeStatusVisible(status)"></v-checkbox>
</v-list-item>
<v-divider></v-divider>
@@ -183,7 +181,13 @@
</v-icon>
</span>
</template>
<span>{{ item.status.replace(/_/g, ' ') }}</span>
<span>
{{
$te(`History.StatusValues.${item.status}`, 'en')
? $t(`History.StatusValues.${item.status}`)
: item.status.replace(/_/g, ' ')
}}
</span>
</v-tooltip>
</td>
<td
@@ -260,7 +264,13 @@
<v-divider class="my-3"></v-divider>
<v-row>
<v-col>{{ $t('History.Status') }}</v-col>
<v-col class="text-right">{{ detailsDialog.item.status }}</v-col>
<v-col class="text-right">
{{
$te(`History.StatusValues.${detailsDialog.item.status}`, 'en')
? $t(`History.StatusValues.${detailsDialog.item.status}`)
: detailsDialog.item.status
}}
</v-col>
</v-row>
<v-divider class="my-3"></v-divider>
<v-row>
+15 -1
View File
@@ -251,7 +251,9 @@
"History": {
"AllJobs": "Alle",
"AvgPrinttime": "Druckzeit - Ø",
"Cancel": "abbrechen",
"Delete": "Löschen",
"DeleteSelectedQuestion": "Sollen wirklich {count} ausgewählte Jobs gelöscht werden?",
"Details": "Details",
"Empty": "leer",
"EndTime": "Endzeit",
@@ -280,12 +282,24 @@
"PrinttimeAvg": "Druckzeit - Ø",
"Reprint": "Erneut drucken",
"Search": "Suchen",
"ShowStatusName": "Zeige \"{name}\" ({count})",
"SelectedFilamentUsed": "Ausg. Filamentverbrauch",
"SelectedJobs": "Ausg. Drucke",
"SelectedPrinttime": "Ausg. Druckzeit",
"Slicer": "Slicer",
"SlicerVersion": "Slicer Version",
"StartTime": "Startzeit",
"Statistics": "Statistik",
"Status": "Status",
"StatusValues": {
"cancelled": "Abgebrochen",
"completed": "Abgeschlossen",
"error": "Fehler",
"in_progress": "In Arbeit",
"klippy_disconnect": "Klippy getrennt",
"klippy_shutdown": "Klippy heruntergefahren",
"server_exit": "Server-Exit"
},
"TitleExportHistory": "Historie exportieren",
"TitleRefreshHistory": "Historie aktualisieren",
"TitleSettings": "Einstellungen",
"TotalDuration": "Gesamtdauer",
+9
View File
@@ -287,6 +287,15 @@
"StartTime": "Start Time",
"Statistics": "Statistics",
"Status": "Status",
"StatusValues": {
"cancelled": "Cancelled",
"completed": "Completed",
"error": "Error",
"in_progress": "In progress",
"klippy_disconnect": "Klippy disconnect",
"klippy_shutdown": "Klippy shutdown",
"server_exit": "Server exit"
},
"TitleExportHistory": "Export History",
"TitleRefreshHistory": "Refresh History",
"TitleSettings": "Settings",
+11 -1
View File
@@ -11,6 +11,7 @@ import {
mdiCloseCircleOutline,
mdiProgressClock,
} from '@mdi/js'
import i18n from '@/plugins/i18n'
// eslint-disable-next-line
export const getters: GetterTree<ServerHistoryState, any> = {
@@ -78,6 +79,10 @@ export const getters: GetterTree<ServerHistoryState, any> = {
const index = output.findIndex((element) => element.name === current.status)
if (index !== -1) output[index].value += 1
else {
const displayName = i18n.te(`History.StatusValues.${current.status}`, 'en')
? i18n.t(`History.StatusValues.${current.status}`).toString()
: current.status
const itemStyle = {
opacity: 0.9,
color: '#424242',
@@ -102,8 +107,9 @@ export const getters: GetterTree<ServerHistoryState, any> = {
output.push({
name: current.status,
displayName,
value: 1,
itemStyle: itemStyle,
itemStyle,
showInTable: !rootState.gui?.view.history.hidePrintStatus.includes(current.status),
label: {
color: '#fff',
@@ -122,6 +128,9 @@ export const getters: GetterTree<ServerHistoryState, any> = {
const index = output.findIndex((element) => element.name === current.status)
if (index !== -1) output[index].value += 1
else {
const displayName = i18n.te(`History.StatusValues.${current.status}`, 'en')
? i18n.t(`History.StatusValues.${current.status}`).toString()
: current.status
const itemStyle = {
opacity: 0.9,
color: '#424242',
@@ -146,6 +155,7 @@ export const getters: GetterTree<ServerHistoryState, any> = {
output.push({
name: current.status,
displayName,
value: 1,
itemStyle: itemStyle,
showInTable: !rootState.gui?.view.history.hidePrintStatus.includes(current.status),
+1
View File
@@ -26,6 +26,7 @@ export interface ServerHistoryStateJob {
export interface ServerHistoryStateAllPrintStatusEntry {
name: string
displayName: string
value: number
showInTable: boolean
itemStyle: {