diff --git a/src/components/widgets/filesystem/setupMonaco.ts b/src/components/widgets/filesystem/setupMonaco.ts index eb4e07c5e2..318bd33a18 100644 --- a/src/components/widgets/filesystem/setupMonaco.ts +++ b/src/components/widgets/filesystem/setupMonaco.ts @@ -93,13 +93,13 @@ async function setupMonaco () { const app = getVueApp() monaco.editor.registerCommand('fluidd_open_docs', (_, service: CodeLensSupportedService, hash: string) => { - const serviceKey = ( - service === 'klipper' - ? app.$store.getters['printer/getKlippyApp'] - : service - ).toLowerCase().replace(/-/g, '_') + const serviceKey = service.replace(/-/g, '_') + const klippyApp = app.$store.getters['printer/getKlippyApp'] - const url = app.$t(`app.file_system.url.${serviceKey}_config`, { hash }).toString() + const url = app.$t(`app.file_system.url.${serviceKey}_config`, { + hash, + klipperDomain: klippyApp.domain + }).toString() window.open(url) }) diff --git a/src/globals.ts b/src/globals.ts index 0b5f84946b..d16a5832fb 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -227,15 +227,18 @@ export const Globals = Object.freeze({ { filename: 'mooncord-webcam.json', service: 'webcamd', link: 'https://github.com/eliteSchwein/mooncord' }, { prefix: 'mooncord', service: 'MoonCord', link: 'https://github.com/eliteSchwein/mooncord' }, { filename: 'telegram.conf', service: 'moonraker-telegram-bot', link: 'https://github.com/nlef/moonraker-telegram-bot/wiki/Sample-config' }, - { - suffix: '.cfg', - service: 'klipper', - link: 'https://www.klipper3d.org/Config_Reference.html', - linkOverride: { - 'danger-klipper': 'https://dangerklipper.io/Config_Reference.html' + { suffix: '.cfg', service: 'klipper', link: '{klipperDomain}/Config_Reference.html' } + ], + SUPPORTED_SERVICES: { + klipper: { + klipper: { + domain: 'https://www.klipper3d.org' + }, + 'danger-klipper': { + domain: 'https://dangerklipper.io' } } - ], + }, FILE_DATA_TRANSFER_TYPES: { files: 'x-fluidd-files', jobs: 'x-fluidd-jobs' diff --git a/src/locales/en.yaml b/src/locales/en.yaml index 466fe59c34..f650a51363 100644 --- a/src/locales/en.yaml +++ b/src/locales/en.yaml @@ -110,8 +110,7 @@ app: items_count: '{count} item | {count} items' root_disabled: '{root} root is not available. Please check your logs.' url: - klipper_config: 'https://www.klipper3d.org/Config_Reference.html#%{hash}' - danger_klipper_config: 'https://dangerklipper.io/Config_Reference.html#%{hash}' + klipper_config: '%{klipperDomain}/Config_Reference.html#%{hash}' moonraker_config: 'https://moonraker.readthedocs.io/en/latest/configuration/#%{hash}' moonraker_telegram_bot_config: 'https://github.com/nlef/moonraker-telegram-bot/wiki/Sample-config#%{hash}' crowsnest_config: 'https://crowsnest.mainsail.xyz/configuration/%{hash}-section' @@ -499,6 +498,11 @@ app: standby: Standby title: printer_status: Printer Status + stepper_driver_overheating: Stepper driver '%{name}' is over-heating + msg: + possible_print_failure: This may lead to a failed print + url: + stepper_driver_overheating: '%{klipperDomain}/TMC_Drivers.html#tmc-reports-error-ot1overtemperror' setting: btn: add_camera: Add Camera diff --git a/src/store/helpers.ts b/src/store/helpers.ts index 8fd87b01ba..b020ff08af 100644 --- a/src/store/helpers.ts +++ b/src/store/helpers.ts @@ -2,8 +2,9 @@ import type { Commit, Dispatch } from 'vuex' import type { RootState } from './types' import { SocketActions } from '@/api/socketActions' import type { AppPushNotification } from './notifications/types' +import i18n from '@/plugins/i18n' -export const handleTrinamicDriversChange = (payload: any, state: RootState, dispatch: Dispatch) => { +export const handleTrinamicDriversChange = (payload: any, state: RootState, dispatch: Dispatch, getters: any) => { for (const item in payload) { const [type, nameFromSplit] = item.split(' ', 2) @@ -14,11 +15,13 @@ export const handleTrinamicDriversChange = (payload: any, state: RootState, disp ) { const name = nameFromSplit ?? item + const klippyApp = getters.getKlippyApp + const notification: AppPushNotification = { id: `${item}-otpw`, - title: `Stepper driver '${name}' is over-heating`, - description: 'This may lead to a failed print', - to: 'https://www.klipper3d.org/TMC_Drivers.html#tmc-reports-error-ot1overtemperror', + title: i18n.t('app.printer.title.stepper_driver_overheating', { name }).toString(), + description: i18n.t('app.printer.msg.possible_print_failure').toString(), + to: i18n.t('app.printer.url.stepper_driver_overheating', { klipperDomain: klippyApp.domain }).toString(), type: 'error', snackbar: true, merge: true, diff --git a/src/store/printer/actions.ts b/src/store/printer/actions.ts index 5a3c9a8d44..14534a68c4 100644 --- a/src/store/printer/actions.ts +++ b/src/store/printer/actions.ts @@ -150,7 +150,7 @@ export const actions: ActionTree = { handleExcludeObjectChange(payload, rootState, dispatch) handleSystemStatsChange(payload, rootState, commit) handleMcuStatsChange(payload, rootState, commit) - handleTrinamicDriversChange(payload, rootState, dispatch) + handleTrinamicDriversChange(payload, rootState, dispatch, getters) for (const key in payload) { const val = payload[key] diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index 71a9862fb8..455281f645 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -7,6 +7,8 @@ import getKlipperType from '@/util/get-klipper-type' import i18n from '@/plugins/i18n' import type { GcodeHelp } from '../console/types' import type { ServerInfo } from '../server/types' +import { Globals } from '@/globals' +import isKeyOf from '@/util/is-key-of' export const getters: GetterTree = { @@ -64,18 +66,16 @@ export const getters: GetterTree = { }, getKlippyApp: (state) => { - const supportedKlippyApps = [ - 'Klipper', - 'Danger-Klipper' - ] + const app = state.printer.info.app?.toLowerCase() - const app = state.printer.info.app + const klippyApp = isKeyOf(app, Globals.SUPPORTED_SERVICES.klipper) + ? app + : 'klipper' - if (supportedKlippyApps.includes(app)) { - return app + return { + name: klippyApp, + ...Globals.SUPPORTED_SERVICES.klipper[klippyApp] } - - return 'Klipper' }, /** diff --git a/src/store/server/getters.ts b/src/store/server/getters.ts index c7c2b0ee62..9676a1ec84 100644 --- a/src/store/server/getters.ts +++ b/src/store/server/getters.ts @@ -3,7 +3,6 @@ import type { ServerInfo, ServerConfig, ServerState, SystemInfo, ServerSystemSta import type { RootState } from '../types' import { Globals } from '@/globals' import { gte, valid } from 'semver' -import isKeyOf from '@/util/is-key-of' export const getters: GetterTree = { /** @@ -85,13 +84,11 @@ export const getters: GetterTree = { if ( item?.service === 'klipper' && - item.linkOverride + item.link ) { - const app = rootGetters['printer/getKlippyApp'].toLowerCase() + const klippyApp = rootGetters['printer/getKlippyApp'] - if (isKeyOf(app, item.linkOverride)) { - item.link = item.linkOverride[app] - } + item.link = item.link.replace('{klipperDomain}', klippyApp.domain) } if (item) {