Skip to content

Commit

Permalink
Merge branch 'develop' into feat/hide-other-instances
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/settings/SettingsUiSettingsTab.vue
#	src/store/gui/index.ts
#	src/store/gui/types.ts
  • Loading branch information
meteyou committed Dec 1, 2024
2 parents fccc0bf + 33efe92 commit cb71ddf
Show file tree
Hide file tree
Showing 58 changed files with 1,922 additions and 1,340 deletions.
5 changes: 3 additions & 2 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
server {
listen 80;

listen [::]:80;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}

include /etc/nginx/extra-conf.d/*.conf;
}
}
13 changes: 12 additions & 1 deletion src/components/TheConnectingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<v-divider class="mt-4 mb-5" />
</template>
<div class="text-center mt-3">
<v-btn v-if="helpButtonUrl" class="text--disabled mr-3" :href="helpButtonUrl" target="_blank">
<v-icon left>{{ mdiHelp }}</v-icon>
{{ $t('ConnectionDialog.Help') }}
</v-btn>
<v-btn class="primary--text" @click="reconnect">{{ $t('ConnectionDialog.TryAgain') }}</v-btn>
</div>
</v-card-text>
Expand All @@ -35,7 +39,7 @@ import BaseMixin from '@/components/mixins/base'
import ThemeMixin from '@/components/mixins/theme'
import ConnectionStatus from '@/components/ui/ConnectionStatus.vue'
import { mdiConnection } from '@mdi/js'
import { mdiConnection, mdiHelp } from '@mdi/js'
@Component({
components: {
Expand All @@ -44,6 +48,7 @@ import { mdiConnection } from '@mdi/js'
})
export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
mdiConnection = mdiConnection
mdiHelp = mdiHelp
counter = 0
Expand Down Expand Up @@ -89,6 +94,12 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
return this.$store.state.socket.connectionFailedMessage ?? null
}
get helpButtonUrl() {
if (!this.$store.state.socket.connectionFailedMessage) return null
return `https://docs.mainsail.xyz/faq/mainsail_errors/connection-${this.connectionFailedMessage?.toLowerCase()}`
}
reconnect() {
this.counter++
this.$store.dispatch('socket/setData', { connectingFailed: false })
Expand Down
8 changes: 7 additions & 1 deletion src/components/TheEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ export default class TheEditor extends Mixins(BaseMixin) {
return this.$store.state.server.system_info?.available_services ?? []
}
get restartServiceName() {
get restartAllowedOrPossible() {
if (!this.isWriteable) return null
if (['printing', 'paused'].includes(this.printer_state)) return null
return true
}
get restartServiceName() {
// check for generic services <service>.conf (like moonraker.conf, crowsnest.conf, sonar.conf)
if (this.availableServices.includes(this.filenameWithoutExtension) && this.fileExtension === 'conf')
return this.filenameWithoutExtension
Expand All @@ -309,6 +313,8 @@ export default class TheEditor extends Mixins(BaseMixin) {
}
get restartServiceNameExists() {
if (!this.restartAllowedOrPossible) return false
// hide the button, if there is no service found
if (this.restartServiceName === null) return false
Expand Down
63 changes: 27 additions & 36 deletions src/components/charts/HistoryAllPrintStatusChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
:option="chartOptions"
:autoresize="true"
:init-options="{ renderer: 'svg' }"
style="height: 200px; width: 100%"></e-chart>
style="height: 200px; width: 100%" />
</template>

<script lang="ts">
import Component from 'vue-class-component'
import { Mixins, Watch } from 'vue-property-decorator'
import { Mixins, Prop, Ref, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import ThemeMixin from '@/components/mixins/theme'
import HistoryStatsMixin from '@/components/mixins/historyStats'
import VueECharts from 'vue-echarts'
import type { ECharts } from 'echarts/core'
import { ECBasicOption } from 'echarts/types/dist/shared.d'
import { ServerHistoryStateAllPrintStatusEntry } from '@/store/server/history/types'
import { formatPrintTime } from '@/plugins/helpers'
import { HistoryStatsValueNames } from '@/store/server/history/types'
@Component({
components: {},
})
export default class HistoryAllPrintStatusChart extends Mixins(BaseMixin, ThemeMixin) {
declare $refs: {
historyAllPrintStatus: any
}
export default class HistoryAllPrintStatusChart extends Mixins(BaseMixin, ThemeMixin, HistoryStatsMixin) {
@Prop({ type: String, default: 'jobs' }) valueName!: HistoryStatsValueNames
@Ref('historyAllPrintStatus') historyAllPrintStatus!: typeof VueECharts
get chartOptions(): ECBasicOption {
return {
Expand All @@ -37,12 +39,26 @@ export default class HistoryAllPrintStatusChart extends Mixins(BaseMixin, ThemeM
tooltip: {
trigger: 'item',
borderWidth: 0,
valueFormatter: (value: number) => {
if (this.valueName === 'filament') {
if (value > 1000) return Math.round(value / 1000).toString() + ' m'
return value.toString() + ' mm'
}
if (this.valueName === 'time') {
return formatPrintTime(value, false)
}
return value.toString()
},
},
series: [
{
type: 'pie',
data: this.printStatusArray,
data: this.groupedPrintStatusArray,
avoidLabelOverlap: false,
minAngle: 5,
radius: ['35%', '60%'],
emphasis: {
itemStyle: {
Expand All @@ -59,42 +75,17 @@ export default class HistoryAllPrintStatusChart extends Mixins(BaseMixin, ThemeM
}
}
get selectedJobs() {
return this.$store.getters['server/history/getSelectedJobs']
}
get allPrintStatusArray() {
return this.$store.getters['server/history/getAllPrintStatusArray']
}
get selectedPrintStatusArray() {
return this.$store.getters['server/history/getSelectedPrintStatusArray']
}
get printStatusArray() {
const output: ServerHistoryStateAllPrintStatusEntry[] = []
const orgArray = this.selectedJobs.length ? this.selectedPrintStatusArray : this.allPrintStatusArray
orgArray.forEach((status: ServerHistoryStateAllPrintStatusEntry) => {
const tmp = { ...status }
tmp.name = status.displayName
output.push(tmp)
})
return output
}
get chart(): ECharts | null {
return this.$refs.historyAllPrintStatus?.chart ?? null
return this.historyAllPrintStatus?.chart ?? null
}
beforeDestroy() {
if (typeof window === 'undefined') return
if (this.chart) this.chart.dispose()
}
@Watch('printStatusArray')
printStatusArrayChanged(newVal: any) {
@Watch('groupedPrintStatusArray')
groupedPrintStatusArrayChanged(newVal: any) {
this.chart?.setOption(
{
series: {
Expand Down
44 changes: 12 additions & 32 deletions src/components/charts/HistoryAllPrintStatusTable.vue
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
<template>
<v-simple-table>
<tbody>
<tr v-for="status in printStatusArray" :key="status.name">
<td>{{ status.displayName }}</td>
<td class="text-right">{{ status.value }}</td>
</tr>
<history-all-print-status-table-item
v-for="status in printStatusArray"
:key="status.name"
:item="status"
:value-name="valueName" />
</tbody>
</v-simple-table>
</template>

<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import { Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { ServerHistoryStateAllPrintStatusEntry } from '@/store/server/history/types'
import HistoryStatsMixin from '@/components/mixins/historyStats'
import HistoryAllPrintStatusTableItem from '@/components/charts/HistoryAllPrintStatusTableItem.vue'
import { HistoryStatsValueNames } from '@/store/server/history/types'
@Component({
components: {},
components: { HistoryAllPrintStatusTableItem },
})
export default class HistoryAllPrintStatusTable extends Mixins(BaseMixin) {
get selectedJobs() {
return this.$store.getters['server/history/getSelectedJobs']
}
get allPrintStatusArray() {
return this.$store.getters['server/history/getAllPrintStatusArrayAll']
}
get selectedPrintStatusArray() {
return this.$store.getters['server/history/getSelectedPrintStatusArray']
}
get printStatusArray() {
const output: ServerHistoryStateAllPrintStatusEntry[] = []
const orgArray = this.selectedJobs.length ? this.selectedPrintStatusArray : this.allPrintStatusArray
orgArray.forEach((status: ServerHistoryStateAllPrintStatusEntry) => {
const tmp = { ...status }
tmp.name = status.displayName
output.push(tmp)
})
return output
}
export default class HistoryAllPrintStatusTable extends Mixins(BaseMixin, HistoryStatsMixin) {
@Prop({ type: String, default: 'amount' }) valueName!: HistoryStatsValueNames
}
</script>
36 changes: 36 additions & 0 deletions src/components/charts/HistoryAllPrintStatusTableItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<tr>
<td>{{ item.displayName }}</td>
<td class="text-right">{{ value }}</td>
</tr>
</template>

<script lang="ts">
import Component from 'vue-class-component'
import { Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { HistoryStatsValueNames, ServerHistoryStateAllPrintStatusEntry } from '@/store/server/history/types'
import { formatPrintTime } from '@/plugins/helpers'
@Component({
components: {},
})
export default class HistoryAllPrintStatusTableItem extends Mixins(BaseMixin) {
@Prop({ type: Object }) item!: ServerHistoryStateAllPrintStatusEntry
@Prop({ type: String, default: 'amount' }) valueName!: HistoryStatsValueNames
get value() {
if (this.valueName === 'filament') {
if (this.item.value > 1000) return Math.round(this.item.value / 1000).toFixed(2) + ' m'
return this.item.value.toFixed(0) + ' mm'
}
if (this.valueName === 'time') {
return formatPrintTime(this.item.value, false)
}
return this.item.value.toString()
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,24 @@
<v-col>
<v-text-field
v-model="cmdListSearch"
label="Search"
:label="$t('Console.Search')"
outlined
hide-details
clearable
dense></v-text-field>
dense />
</v-col>
</v-row>
</v-card-title>
<v-divider></v-divider>
<v-divider />
<overlay-scrollbars class="command-help-content" :class="isMobile ? 'mobileHeight' : 'height300'">
<v-card-text class="pt-0">
<v-row>
<v-col>
<v-list>
<v-list-item
v-for="cmd of helplistFiltered"
:key="cmd.commandLow"
class="px-0"
two-line>
<v-list-item-content class="px-0">
<v-list-item-title
class="primary--text font-weight-bold cursor-pointer"
@click="
$emit('onCommand', cmd.command)
isOpen = false
">
{{ cmd.command }}
</v-list-item-title>
<v-list-item-subtitle class="text-wrap">
{{ cmd.description }}
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-col>
</v-row>
<v-list>
<command-help-modal-entry
v-for="command of helplistFiltered"
:key="command"
:command="command"
@click-on-command="onCommand" />
</v-list>
</v-card-text>
</overlay-scrollbars>
</panel>
Expand All @@ -77,15 +59,15 @@
</template>

<script lang="ts">
import BaseMixin from './mixins/base'
import { CommandHelp } from '@/store/printer/types'
import BaseMixin from '@/components/mixins/base'
import { Mixins, Prop, Watch } from 'vue-property-decorator'
import Component from 'vue-class-component'
import Panel from '@/components/ui/Panel.vue'
import { mdiHelp, mdiCloseThick } from '@mdi/js'
import CommandHelpModalEntry from '@/components/console/CommandHelpModalEntry.vue'
@Component({
components: { Panel },
components: { CommandHelpModalEntry, Panel },
})
export default class CommandHelpModal extends Mixins(BaseMixin) {
@Prop({ required: false, default: false }) declare isMini: boolean
Expand All @@ -101,25 +83,26 @@ export default class CommandHelpModal extends Mixins(BaseMixin) {
mdiHelp = mdiHelp
mdiCloseThick = mdiCloseThick
get helplist(): CommandHelp[] {
return this.$store.state.printer.helplist ?? []
get helplist(): string[] {
return Object.keys(this.$store.state.printer.gcode?.commands ?? {})
}
get helplistFiltered(): CommandHelp[] {
get helplistFiltered(): string[] {
return this.helplist
.filter(
(cmd) =>
typeof cmd.description === 'string' &&
(!this.cmdListSearch || cmd.commandLow.includes(this.cmdListSearch.toLowerCase()))
)
.sort((a, b) => a.commandLow.localeCompare(b.commandLow))
.filter((cmd) => cmd.includes(this.cmdListSearch.toUpperCase()))
.sort((a, b) => a.localeCompare(b))
}
onCommand(gcode: string): void {
this.$emit('onCommand', gcode)
this.isOpen = false
}
@Watch('isOpen')
onIsOpen(val: boolean): void {
if (!val) {
this.cmdListSearch = ''
}
if (val) return
this.cmdListSearch = ''
}
}
</script>
Expand Down
Loading

0 comments on commit cb71ddf

Please sign in to comment.