Skip to content

Commit

Permalink
Merge branch 'develop' into slo_translation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamas committed Jun 18, 2024
2 parents 505011c + c6ae687 commit 24a52b2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/components/widgets/filesystem/setupMonaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
17 changes: 10 additions & 7 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 6 additions & 2 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/store/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/store/printer/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const actions: ActionTree<PrinterState, RootState> = {
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]
Expand Down
18 changes: 9 additions & 9 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrinterState, RootState> = {

Expand Down Expand Up @@ -64,18 +66,16 @@ export const getters: GetterTree<PrinterState, RootState> = {
},

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'
},

/**
Expand Down
9 changes: 3 additions & 6 deletions src/store/server/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerState, RootState> = {
/**
Expand Down Expand Up @@ -85,13 +84,11 @@ export const getters: GetterTree<ServerState, RootState> = {

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) {
Expand Down

0 comments on commit 24a52b2

Please sign in to comment.