diff --git a/src/components/TheSettingsMenu.vue b/src/components/TheSettingsMenu.vue index f989aae96..e285244a3 100644 --- a/src/components/TheSettingsMenu.vue +++ b/src/components/TheSettingsMenu.vue @@ -81,6 +81,7 @@ import SettingsGCodeViewerTab from '@/components/settings/SettingsGCodeViewerTab import SettingsEditorTab from '@/components/settings/SettingsEditorTab.vue' import SettingsTimelapseTab from '@/components/settings/SettingsTimelapseTab.vue' import SettingsNavigationTab from '@/components/settings/SettingsNavigationTab.vue' +import SettingsAliasTab from '@/components/settings/SettingsAliasTab.vue' import Panel from '@/components/ui/Panel.vue' import { @@ -101,6 +102,7 @@ import { mdiDipSwitch, mdiMenu, mdiGrid, + mdiRenameOutline, } from '@mdi/js' import SettingsMiscellaneousTab from '@/components/settings/SettingsMiscellaneousTab.vue' import SettingsHeightmapTab from '@/components/settings/SettingsHeightmapTab.vue' @@ -123,6 +125,7 @@ import SettingsHeightmapTab from '@/components/settings/SettingsHeightmapTab.vue SettingsMiscellaneousTab, SettingsNavigationTab, SettingsHeightmapTab, + SettingsAliasTab, }, }) export default class TheSettingsMenu extends Mixins(BaseMixin) { @@ -211,6 +214,11 @@ export default class TheSettingsMenu extends Mixins(BaseMixin) { name: 'heightmap', title: this.$t('Settings.HeightmapTab.Heightmap'), }, + { + icon: mdiRenameOutline, + name: 'alias', + title: this.$t('Settings.AliasTab.AliasName'), + }, ] if (this.moonrakerComponents.includes('timelapse')) { diff --git a/src/components/charts/TempChart.vue b/src/components/charts/TempChart.vue index 2fe69636a..956505218 100644 --- a/src/components/charts/TempChart.vue +++ b/src/components/charts/TempChart.vue @@ -302,7 +302,7 @@ export default class TempChart extends Mixins(BaseMixin, ThemeMixin) { mainDatasets.forEach((dataset: any) => { const baseSeriesName = dataset.seriesName.substring(0, dataset.seriesName.lastIndexOf('-')) - let displayName = baseSeriesName + let displayName = this.aliasName(baseSeriesName) if (displayName.indexOf(' ') !== -1) { displayName = displayName.substring(displayName.indexOf(' ') + 1) } diff --git a/src/components/inputs/FilamentSensor.vue b/src/components/inputs/FilamentSensor.vue index 82b53085a..70c1df2b6 100644 --- a/src/components/inputs/FilamentSensor.vue +++ b/src/components/inputs/FilamentSensor.vue @@ -4,7 +4,7 @@ {{ mdiPrinter3dNozzleAlert }} - {{ convertName(name) }} + {{ aliasName(name) }} {{ statusText }} diff --git a/src/components/inputs/MiscellaneousLight.vue b/src/components/inputs/MiscellaneousLight.vue index 57eee47b1..2ea784716 100644 --- a/src/components/inputs/MiscellaneousLight.vue +++ b/src/components/inputs/MiscellaneousLight.vue @@ -175,7 +175,7 @@ export default class MiscellaneousLight extends Mixins(BaseMixin) { get name() { if (this.group) return convertName(this.group.name) - return convertName(this.object.name) + return this.aliasName(this.object.name) } get colorPickerOptions() { diff --git a/src/components/inputs/MiscellaneousSlider.vue b/src/components/inputs/MiscellaneousSlider.vue index fd70a0a5d..b9a4308c9 100644 --- a/src/components/inputs/MiscellaneousSlider.vue +++ b/src/components/inputs/MiscellaneousSlider.vue @@ -15,7 +15,7 @@ {{ mdiLightbulbOutline }} {{ mdiFan }} - {{ convertName(name) }} + {{ aliasName(name) }} {{ Math.round(rpm ?? 0) }} RPM diff --git a/src/components/mixins/base.ts b/src/components/mixins/base.ts index 4aabadbc8..7c45dabec 100644 --- a/src/components/mixins/base.ts +++ b/src/components/mixins/base.ts @@ -2,6 +2,7 @@ import Vue from 'vue' import Component from 'vue-class-component' import { DateTimeFormatOptions } from 'vue-i18n' import { ServerPowerStateDevice } from '@/store/server/power/types' +import { convertName } from '@/plugins/helpers' @Component export default class BaseMixin extends Vue { @@ -224,4 +225,10 @@ export default class BaseMixin extends Vue { return `${date} ${time}` } + + aliasName(name: string): string { + const aliasNames = this.$store.state.gui.aliasNames + if (aliasNames[name] !== undefined) return aliasNames[name] + return convertName(name) + } } diff --git a/src/components/panels/MacrogroupPanel.vue b/src/components/panels/MacrogroupPanel.vue index a7e7471f6..185c9157a 100644 --- a/src/components/panels/MacrogroupPanel.vue +++ b/src/components/panels/MacrogroupPanel.vue @@ -14,6 +14,7 @@ v-for="(macro, index) in macros" :key="'macroparam_' + index" :macro="macro" + :alias="macroAliasNames[macro.name]" :color="getColor(macro)" class="mx-1 my-1" /> @@ -38,6 +39,10 @@ export default class MacrogroupPanel extends Mixins(BaseMixin) { @Prop({ required: true }) declare panelId: string + get macroAliasNames() { + return this.$store.state.gui.macroAliasNames + } + get macrogroup() { return this.$store.getters['gui/macros/getMacrogroup'](this.panelId) } diff --git a/src/components/panels/Temperature/TemperaturePanelListItem.vue b/src/components/panels/Temperature/TemperaturePanelListItem.vue index 311e7b140..f8850d087 100644 --- a/src/components/panels/Temperature/TemperaturePanelListItem.vue +++ b/src/components/panels/Temperature/TemperaturePanelListItem.vue @@ -107,7 +107,7 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) { } get formatName() { - return convertName(this.name) + return this.aliasName(this.objectName) } get icon() { diff --git a/src/components/settings/SettingsAliasTab.vue b/src/components/settings/SettingsAliasTab.vue new file mode 100644 index 000000000..6ccb5f14f --- /dev/null +++ b/src/components/settings/SettingsAliasTab.vue @@ -0,0 +1,140 @@ + + + diff --git a/src/components/settings/SettingsMacrosTabExpert.vue b/src/components/settings/SettingsMacrosTabExpert.vue index eb4b5313d..42819fa2a 100644 --- a/src/components/settings/SettingsMacrosTabExpert.vue +++ b/src/components/settings/SettingsMacrosTabExpert.vue @@ -152,7 +152,7 @@ {{ $t('Settings.MacrosTab.ChangeMacroColor') }} + + + {{ $t('Settings.MacrosTab.MacroAliasName') }} + @@ -299,6 +329,7 @@ import SettingsRow from '@/components/settings/SettingsRow.vue' import { Debounce } from 'vue-debounce-decorator' import { PrinterStateMacro } from '@/store/printer/types' import { GuiMacrosStateMacrogroup, GuiMacrosStateMacrogroupMacro } from '@/store/gui/macros/types' +import _ from 'lodash' import { mdiDelete, mdiSleep, @@ -308,12 +339,15 @@ import { mdiDragVertical, mdiPalette, mdiPencil, + mdiRename, } from '@mdi/js' @Component({ components: { SettingsRow, draggable }, }) export default class SettingsMacrosTabExpert extends Mixins(BaseMixin, ThemeMixin) { + private macroAliasNames = {} + /** * Icons */ @@ -325,6 +359,7 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin, ThemeMixi mdiPlus = mdiPlus mdiDragVertical = mdiDragVertical mdiPalette = mdiPalette + mdiRename = mdiRename private rules = { required: (value: string) => value !== '' || 'required', @@ -333,6 +368,18 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin, ThemeMixi private boolFormEdit = false private editGroupId: string | null = '' + private macroAliasNameDialog = false + private editMacro: GuiMacrosStateMacrogroupMacro | null = null + + @Watch('macroAliasNames', { deep: true }) + onMacroAliasNames(val: any) { + val = _.omitBy(val, (value) => value == null || false || _.isEmpty(value)) + this.$store.dispatch('gui/saveSetting', { name: 'macroAliasNames', value: val }) + } + + mounted(): void { + this.macroAliasNames = this.$store.state.gui.macroAliasNames + } get groupColors() { return [ @@ -495,6 +542,12 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin, ThemeMixi ) } + getMacroName(macroname: string) { + const aliasMacroName = this.macroAliasNames[macroname] + if (aliasMacroName) return aliasMacroName + ' (' + macroname + ')' + return macroname + } + getMacroDescription(macroname: string) { const macro = this.allMacros.find((m: PrinterStateMacro) => m.name.toLowerCase() === macroname.toLowerCase()) if (!macro) return this.$t('Settings.MacrosTab.DeletedMacro') @@ -547,5 +600,10 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin, ThemeMixi this.boolFormEdit = false this.$emit('scrollToTop') } + + editMacroAliasName(macro: GuiMacrosStateMacrogroupMacro) { + this.editMacro = macro + this.macroAliasNameDialog = true + } } diff --git a/src/locales/en.json b/src/locales/en.json index 5c403574b..f2d43034d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -878,6 +878,9 @@ "YouCanFindMore": "You can find more details at" }, "Settings": { + "AliasTab": { + "AliasName": "Alias Name" + }, "Cancel": "Cancel", "Close": "Close", "ConsoleTab": { @@ -1036,6 +1039,7 @@ "General": "General", "Group": "Group", "GroupMacros": "Group Macros", + "MacroAliasName": "Macro Alias Name", "Macrogroups": "Groups", "Macros": "Macros", "Management": "Management", diff --git a/src/locales/zh.json b/src/locales/zh.json index 9ff1fadbf..48c36ce19 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -874,6 +874,9 @@ "YouCanFindMore": "你可以从这里查看更多信息:" }, "Settings": { + "AliasTab": { + "AliasName": "别名" + }, "Cancel": "取消", "Close": "关闭", "ConsoleTab": { @@ -1032,6 +1035,7 @@ "General": "常规设置", "Group": "分组", "GroupMacros": "宏分组", + "MacroAliasName": "宏别名", "Macrogroups": "分组", "Macros": "宏", "Management": "管理", diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 6f94a5344..18f28d33f 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -289,6 +289,8 @@ export const getDefaultState = (): GuiState => { }, }, }, + aliasNames: {}, + macroAliasNames: {}, } } diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index a1bef68e2..3a4ef0317 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -207,6 +207,12 @@ export interface GuiState { } } } + aliasNames: { + [index: string]: string + } + macroAliasNames: { + [index: string]: string + } } export interface GuiStateLayoutoption {