feat: convert presets from V2.0.1 to V2.1.0 moonraker DB
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
2 files changed
+26
-3
No files matched your search
@@ -292,8 +292,8 @@ export default class SettingsPresetsTab extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
if (this.form.id !== null) {
|
||||
this.$store.dispatch('gui/presets/update', { id: this.form.id, values: preset} )
|
||||
} else this.$store.dispatch('gui/presets/store', { values: preset} )
|
||||
this.$store.dispatch('gui/presets/update', { id: this.form.id, values: preset } )
|
||||
} else this.$store.dispatch('gui/presets/store', { values: preset } )
|
||||
|
||||
this.clearForm()
|
||||
}
|
||||
|
||||
@@ -20,12 +20,35 @@ export const actions: ActionTree<GuiState, RootState> = {
|
||||
Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail' }, { action: 'gui/initStore'})
|
||||
},
|
||||
|
||||
initStore({ commit, dispatch, rootState }, payload) {
|
||||
async initStore({ commit, dispatch, rootGetters, rootState }, payload) {
|
||||
const baseUrl = rootGetters['socket/getUrl'] + '/server/database/item'
|
||||
const mainsailUrl = baseUrl + '?namespace=mainsail'
|
||||
|
||||
if ('remoteprinters' in payload.value) {
|
||||
if (!rootState.socket?.remoteMode) dispatch('remoteprinters/initStore', payload.value.remoteprinters.printers)
|
||||
delete payload.value.remoteprinters
|
||||
}
|
||||
|
||||
//update cooldownGcode from V2.0.1 to V2.1.0
|
||||
if ('cooldownGcode' in payload.value) {
|
||||
window.console.debug('update cooldownGcode to new namespace')
|
||||
dispatch('saveSetting', { name: 'presets.cooldownGcode', value: payload.value.cooldownGcode })
|
||||
|
||||
await fetch(mainsailUrl+'&key=cooldownGcode', { method: 'DELETE' })
|
||||
delete payload.value.cooldownGcode
|
||||
}
|
||||
|
||||
//update presets from V2.0.1 to V2.1.0
|
||||
if ('presets' in payload.value && Array.isArray(payload.value.presets)) {
|
||||
window.console.debug('update presets to new namespace')
|
||||
|
||||
payload.value.presets.forEach((preset: any) => {
|
||||
dispatch('presets/store', { values: preset })
|
||||
})
|
||||
|
||||
delete payload.value.presets
|
||||
}
|
||||
|
||||
commit('setData', payload.value)
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user