Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
4cello committed Apr 5, 2024
1 parent 8823fc0 commit 3da4b18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/components/TheConnectingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
}
get formatHostname() {
return parseInt(this.port) !== 80 && this.port !== '' ? this.hostname + ':' + this.port + this.path : this.hostname + this.path
return parseInt(this.port) !== 80 && this.port !== ''
? this.hostname + ':' + this.port + this.path
: this.hostname + this.path
}
get isConnecting() {
Expand Down
17 changes: 9 additions & 8 deletions src/components/TheSelectPrinterDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,15 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
port: printer.socket.port,
path: printer.socket.path,
})
let normPath = printer.socket.path.replaceAll(/(^\/*)|(\/*$)/g, "")
let url = this.protocol +
'://' +
printer.socket.hostname +
':' +
printer.socket.port +
(normPath.length > 0 ? `/${normPath}` : '') +
'/websocket'
const normPath = printer.socket.path.replaceAll(/(^\/*)|(\/*$)/g, '')
const url =
this.protocol +
'://' +
printer.socket.hostname +
':' +
printer.socket.port +
(normPath.length > 0 ? `/${normPath}` : '') +
'/websocket'
this.$socket.setUrl(url)
this.$socket.connect()
}
Expand Down
22 changes: 8 additions & 14 deletions src/store/farm/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'
// eslint-disable-next-line
export const getters: GetterTree<FarmPrinterState, any> = {
getSocketUrl: (state) => {
const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, "")
const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, '')
const path = normPath.length > 0 ? `/${normPath}` : ''
return (
state.socket.protocol +
'://' +
state.socket.hostname +
':' +
state.socket.port +
path +
'/websocket'
)
return state.socket.protocol + '://' + state.socket.hostname + ':' + state.socket.port + path + '/websocket'
},

getSocketData: (state) => {
Expand Down Expand Up @@ -138,7 +130,7 @@ export const getters: GetterTree<FarmPrinterState, any> = {
const dir = indexLastDir !== -1 ? state.current_file.filename.substring(0, indexLastDir) + '/' : ''
const thumbnail = state.current_file.thumbnails.find((thumb) => thumb.width >= thumbnailBigMin)

const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, "")
const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, '')
const path = normPath.length > 0 ? `/${normPath}` : ''
if (thumbnail && 'relative_path' in thumbnail)
return (
Expand All @@ -163,10 +155,12 @@ export const getters: GetterTree<FarmPrinterState, any> = {
acceptExtensions.includes(element.substr(element.lastIndexOf('.') + 1))
)

const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, "")
const normPath = state.socket.path.replaceAll(/(^\/*)|(\/*$)/g, '')
const path = normPath.length > 0 ? `/${normPath}` : ''

return file ? '//' + state.socket.hostname + ':' + state.socket.port + path + '/server/files/config/' + file : null
return file
? '//' + state.socket.hostname + ':' + state.socket.port + path + '/server/files/config/' + file
: null
},

getLogo: (state, getters) => {
Expand Down Expand Up @@ -284,7 +278,7 @@ export const getters: GetterTree<FarmPrinterState, any> = {
) {
return (
state.data.print_stats.print_duration /
(state.data.print_stats.filament_used / state.current_file.filament_total) -
(state.data.print_stats.filament_used / state.current_file.filament_total) -
state.data.print_stats.print_duration
).toFixed(0)
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/socket/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const actions: ActionTree<SocketState, RootState> = {
commit('setData', payload)

if ('$socket' in Vue.prototype) {
const normPath = payload.path.replaceAll(/(^\/*)|(\/*$)/g, "")
const normPath = payload.path.replaceAll(/(^\/*)|(\/*$)/g, '')
const path = normPath.length > 0 ? `/${normPath}` : ''
await Vue.prototype.$socket.close()
await Vue.prototype.$socket.setUrl(
Expand Down

0 comments on commit 3da4b18

Please sign in to comment.