diff --git a/src/components/TheTopCornerMenu.vue b/src/components/TheTopCornerMenu.vue index 85f13005..0cdaaf03 100644 --- a/src/components/TheTopCornerMenu.vue +++ b/src/components/TheTopCornerMenu.vue @@ -15,13 +15,13 @@ @@ -59,13 +59,13 @@ {{ $t("App.TopCornerMenu.HostControl") }} - + {{ $t("App.TopCornerMenu.Reboot") }} mdi-power - + {{ $t("App.TopCornerMenu.Shutdown") }} mdi-power @@ -180,27 +180,25 @@ export default class TheTopCornerMenu extends Mixins(BaseMixin) { return null } - checkDialog(executableFunction: any, serviceName: string | null = null) { + checkDialog(executableFunction: any, serviceName: string, action: string) { if (this.printerIsPrinting) { - const functionName = (executableFunction.name ?? 'unknown').replace('bound ', '') - let action: string = 'Restart' - const actionTypes = ['Start', 'Restart', 'Stop', 'Reboot', 'Shutdown'] - - actionTypes.forEach((actionType: string) => { - if (functionName.endsWith(actionType)) action = actionType - }) - this.dialogConfirmation.executableFunction = executableFunction this.dialogConfirmation.serviceName = serviceName - const functionNameUppercase = functionName.trim().charAt(0).toUpperCase() + functionName.trim().slice(1) - this.dialogConfirmation.title = this.$t('App.TopCornerMenu.ConfirmationDialog.Title.' + functionNameUppercase)+'' + const actionUppercase = action.trim().charAt(0).toUpperCase() + action.trim().slice(1) - if (serviceName === 'klipper' && action === 'Stop') this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.KlipperStop')+'' - else if (serviceName === 'klipper' && action === 'Restart') this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.KlipperRestart')+'' - else this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.' + functionNameUppercase)+'' + if (serviceName === 'klipper' && ['stop', 'restart', 'firmwareRestart'].includes(action)){ + this.dialogConfirmation.title = this.$t('App.TopCornerMenu.ConfirmationDialog.Title.' + (action !== 'stop' ? 'Klipper' : 'Service') + actionUppercase).toString() + this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.Klipper' + actionUppercase).toString() + } else if (serviceName === 'host') { + this.dialogConfirmation.title = this.$t('App.TopCornerMenu.ConfirmationDialog.Title.Host' + actionUppercase).toString() + this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.Host' + actionUppercase).toString() + } else { + this.dialogConfirmation.title = this.$t('App.TopCornerMenu.ConfirmationDialog.Title.Service' + actionUppercase).toString() + this.dialogConfirmation.description = this.$t('App.TopCornerMenu.ConfirmationDialog.Description.Service' + actionUppercase).toString() + } - this.dialogConfirmation.actionButtonText = this.$t('App.TopCornerMenu.' + action.charAt(0).toUpperCase() + action.slice(1))+'' + this.dialogConfirmation.actionButtonText = this.$t('App.TopCornerMenu.' + actionUppercase).toString() this.dialogConfirmation.show = true } else executableFunction(serviceName) }