Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop' into reminder-panel
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou committed Apr 27, 2024
2 parents 9ee61d8 + a196c41 commit 141442c
Show file tree
Hide file tree
Showing 24 changed files with 1,024 additions and 675 deletions.
3 changes: 3 additions & 0 deletions .env.development.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ VUE_APP_HOSTNAME=printer.local
# port from the moonraker instance
VUE_APP_PORT=7125

# route_prefix from the moonraker instance
VUE_APP_PATH="/"

# reconnect interval in ms
VUE_APP_RECONNECT_INTERVAL=5000

Expand Down
25 changes: 13 additions & 12 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details.
For a timely review/response, please avoid force-pushing additional
commits if your PR already received reviews or comments.
commits if your Pull Request already received reviews or comments.
We use squash-merge to merge PRs, so the commit history is clean, but we use the PR title as the commit message.
So we recommend you to use the PR title with conventional commits type prefixes. We use the following prefixes for the PR title:
For a clean commit history, we squash-merge Pull Requests. The Pull Request title then becomes the commit message.
Therefore, we advise to have the PR title in form of the Conventional Commits specification.
We use the following prefixes for the PR title:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- docs: Changes that only affect documentation
- style: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
- locale: Changes to the translations
You can found more information about Conventional Commits here: https://www.conventionalcommits.org/en/v1.0.0/.
You can find more information about Conventional Commits here: https://www.conventionalcommits.org/en/v1.0.0/.
Before submitting a Pull Request, please ensure you've done the following:
- 📖 Read the Mainsail Contributing Guidelines: https://github.com/mainsail-crew/mainsail/blob/HEAD/CONTRIBUTING.md#-submitting-a-pull-request-pr.
- 📖 Read the Mainsail Code of Conduct: https://github.com/mainsail-crew/mainsail/blob/HEAD/.github/CODE_OF_CONDUCT.md.
- 👷‍♀️ Create small PRs. In most cases, this will be possible.
- ✅ Provide tests for your changes.
- 📝 Use descriptive commit messages.
- 📗 Update any related documentation and include any relevant screenshots.
- 📖 Read the Mainsail Contributing Guidelines: https://github.com/mainsail-crew/mainsail/blob/HEAD/CONTRIBUTING.md#-submitting-a-pull-request-pr
- 📖 Read the Mainsail Code of Conduct: https://github.com/mainsail-crew/mainsail/blob/HEAD/.github/CODE_OF_CONDUCT.md
- 👷‍♀️ Create small Pull Requests that only address one issue or feature
- ✅ Provide tests for your changes
- 📝 Use descriptive commit messages
- 📗 Update any related documentation and include any relevant screenshots
-->

## Description
Expand All @@ -44,7 +45,7 @@ https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-git

## Mobile & Desktop Screenshots/Recordings

<!-- Visual changes require screenshots -->
<!-- Visual changes require screenshots showing the before and after -->

## [optional] Are there any post-deployment tasks we need to perform?

Expand Down
1 change: 1 addition & 0 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"defaultTheme": "dark",
"hostname": null,
"port": null,
"path": null,
"instancesDB": "moonraker",
"instances": []
}
8 changes: 7 additions & 1 deletion src/components/TheConnectingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
return this.$store.state.socket.port
}
get path() {
return this.$store.state.socket.path
}
get formatHostname() {
return parseInt(this.port) !== 80 && this.port !== '' ? this.hostname + ':' + this.port : this.hostname
return parseInt(this.port) !== 80 && this.port !== ''
? this.hostname + ':' + this.port + this.path
: this.hostname + this.path
}
get isConnecting() {
Expand Down
143 changes: 126 additions & 17 deletions src/components/TheSelectPrinterDialog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<style scoped></style>

<template>
<v-dialog v-model="showDialog" persistent :width="400">
<panel
Expand Down Expand Up @@ -34,7 +32,7 @@
</template>
<template v-if="isConnecting || (isConnected && !guiIsReady)">
<v-card-text>
<v-progress-linear color="primary" indeterminate></v-progress-linear>
<v-progress-linear color="primary" indeterminate />
</v-card-text>
</template>
<template v-else-if="connectingFailed">
Expand Down Expand Up @@ -70,7 +68,7 @@
required
outlined
hide-details="auto"
dense></v-text-field>
dense />
</v-col>
<v-col class="col-4">
<v-text-field
Expand All @@ -80,12 +78,38 @@
hide-details="auto"
required
outlined
dense></v-text-field>
dense />
</v-col>
</v-row>
<v-row v-if="showOptionalSettings">
<v-col :cols="6">
<v-text-field
v-model="dialogAddPrinter.path"
:rules="[(v) => !v || v.startsWith('/') || 'Path must start with /']"
:label="$t('SelectPrinterDialog.Path')"
hide-details="auto"
outlined
dense />
</v-col>
<v-col :cols="6">
<v-text-field
v-model="dialogAddPrinter.name"
:label="$t('SelectPrinterDialog.Name')"
outlined
hide-details="auto"
dense />
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-checkbox
v-model="showOptionalSettings"
class="ml-2"
:on-icon="mdiShowOptional"
:off-icon="mdiHideOptional"
:true-value="false"
:false-value="true" />
<v-spacer />
<v-btn color="primary" text class="middle" type="submit" :disabled="!addPrinterValid">
{{ $t('SelectPrinterDialog.AddPrinter') }}
</v-btn>
Expand All @@ -108,7 +132,7 @@
required
outlined
dense
hide-details="auto"></v-text-field>
hide-details="auto" />
</v-col>
<v-col class="col-4">
<v-text-field
Expand All @@ -118,15 +142,41 @@
required
outlined
dense
hide-details="auto"></v-text-field>
hide-details="auto" />
</v-col>
</v-row>
<v-row v-if="showOptionalSettings">
<v-col :cols="6">
<v-text-field
v-model="dialogEditPrinter.path"
:rules="[(v) => !v || v.startsWith('/') || 'Path must start with /']"
:label="$t('SelectPrinterDialog.Path')"
hide-details="auto"
outlined
dense />
</v-col>
<v-col :cols="6">
<v-text-field
v-model="dialogEditPrinter.name"
:label="$t('SelectPrinterDialog.Name')"
outlined
hide-details="auto"
dense />
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-btn color="red" icon tile class="minwidth-0 rounded" @click="delPrinter">
<v-icon small>{{ mdiDelete }}</v-icon>
</v-btn>
<v-spacer></v-spacer>
<v-checkbox
v-model="showOptionalSettings"
class="ml-2"
:on-icon="mdiShowOptional"
:off-icon="mdiHideOptional"
:true-value="false"
:false-value="true" />
<v-spacer />
<v-btn color="primary" text type="submit" :disabled="!editPrinterValid">
{{ $t('SelectPrinterDialog.UpdatePrinter') }}
</v-btn>
Expand All @@ -149,7 +199,7 @@
indeterminate
color="primary"
size="24"
width="2.5"></v-progress-circular>
width="2.5" />
<v-icon
v-if="!printer.socket.isConnecting"
:color="printer.socket.isConnected ? 'green' : 'red'">
Expand Down Expand Up @@ -223,6 +273,8 @@ import {
mdiCancel,
mdiCheckboxMarkedCircle,
mdiCloseThick,
mdiCog,
mdiCogOff,
mdiConnection,
mdiDelete,
mdiPencil,
Expand All @@ -233,19 +285,24 @@ import {
components: { Panel },
})
export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
private addPrinterValid = false
private dialogAddPrinter = {
addPrinterValid = false
dialogAddPrinter = {
bool: false,
hostname: '',
port: 7125,
path: '/',
name: '',
}
private editPrinterValid = false
private dialogEditPrinter = {
editPrinterValid = false
dialogEditPrinter = {
bool: false,
id: '',
hostname: '',
port: 0,
path: '/',
name: '',
}
showOptionalSettings = false
/**
* Icons
Expand All @@ -257,6 +314,8 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
mdiPencil = mdiPencil
mdiCheckboxMarkedCircle = mdiCheckboxMarkedCircle
mdiCancel = mdiCancel
mdiShowOptional = mdiCog
mdiHideOptional = mdiCogOff
get printers() {
return this.$store.getters['gui/remoteprinters/getRemoteprinters'] ?? []
Expand All @@ -282,8 +341,16 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
return this.$store.state.socket.port
}
get path() {
return this.$store.state.socket.path
}
get name() {
return this.$store.state.printer
}
get formatHostname() {
return parseInt(this.port) !== 80 && this.port !== '' ? this.hostname + ':' + this.port : this.hostname
return this.hostname + (this.port !== '' ? ':' + this.port : '') + (this.path !== '' ? this.path : '')
}
get isConnected() {
Expand Down Expand Up @@ -345,24 +412,35 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
const values = {
hostname: this.dialogAddPrinter.hostname,
port: this.dialogAddPrinter.port,
path: this.dialogAddPrinter.path,
name: this.dialogAddPrinter.name,
}
this.$store.dispatch('gui/remoteprinters/store', { values })
this.dialogAddPrinter.hostname = ''
this.dialogAddPrinter.bool = false
this.dialogAddPrinter.path = '/'
this.dialogAddPrinter.name = ''
}
editPrinter(printer: GuiRemoteprintersStatePrinter) {
this.dialogEditPrinter.hostname = printer.hostname
this.dialogEditPrinter.port = printer.port
this.dialogEditPrinter.id = printer.id ?? ''
this.dialogEditPrinter.path = printer.path ?? '/'
this.dialogEditPrinter.name = printer.name ?? ''
this.dialogEditPrinter.bool = true
this.showOptionalSettings = printer.name ? printer.name.length > 0 : false
}
updatePrinter() {
const values = {
hostname: this.dialogEditPrinter.hostname,
port: this.dialogEditPrinter.port,
path: this.dialogEditPrinter.path,
id: this.dialogEditPrinter.id,
name: this.dialogEditPrinter.name,
}
this.$store.dispatch('gui/remoteprinters/update', {
id: this.dialogEditPrinter.id,
Expand All @@ -381,8 +459,18 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
this.$store.dispatch('socket/setData', {
hostname: printer.socket.hostname,
port: printer.socket.port,
path: printer.socket.path,
})
this.$socket.setUrl(this.protocol + '://' + printer.socket.hostname + ':' + printer.socket.port + '/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 All @@ -404,7 +492,28 @@ export default class TheSelectPrinterDialog extends Mixins(BaseMixin) {
}
mounted() {
this.$store.dispatch('gui/remoteprinters/initFromLocalstorage')
this.$store.dispatch('gui/remoteprinters/initFromLocalstorage').then(() => {
if (!('printer' in this.$route.query)) return
let name = this.$route.query.printer.toString().toLowerCase()
let matching = this.printers.filter(
(printer: GuiRemoteprintersStatePrinter) => printer.name?.toLowerCase() === name
)
// no printers found with this name
if (matching.length == 0) {
window.console.error(`No printer with given name '${name}' found. Showing selection dialog instead.`)
return
}
// multiple printers found with this name
if (matching.length > 1) {
window.console.error(`Multiple printers with name '${name}' found. Showing selection dialog instead.`)
return
}
this.connect(matching[0])
})
}
}
</script>
Loading

0 comments on commit 141442c

Please sign in to comment.