Skip to content

Commit

Permalink
Merge branch 'develop' into fix/camera-streamer-connections
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Sep 7, 2024
2 parents 05c1e26 + 6fd64df commit 33a55af
Show file tree
Hide file tree
Showing 44 changed files with 1,285 additions and 819 deletions.
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
"options": {
"tabWidth": 2
}
},
{
"files": "src/locales/*.json",
"options": {
"plugins": ["prettier-plugin-sort-json"],
"jsonRecursiveSort": true,
"jsonSortOrder": "{ \"placeThisFirst\": null, \"/^[a-zA-Z0-9]/\": \"caseInsensitiveNumeric\" }"
}
}
]
}
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"eslint-plugin-vue": "^9.0.0",
"postcss": "^8.4.31",
"postcss-nesting": "^12.0.1",
"prettier": "^3.0.0",
"prettier": "^3.3.3",
"prettier-plugin-sort-json": "^4.0.0",
"sass": "~1.32",
"start-server-and-test": "^2.0.5",
"typescript": "^4.5.5",
Expand Down
39 changes: 17 additions & 22 deletions src/components/TheConnectingDialog.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
<style scoped></style>

<template>
<v-dialog v-model="showDialog" persistent :width="400">
<v-card>
<v-toolbar flat dense>
<v-toolbar-title>
<span class="subheading">
<v-icon left>{{ mdiConnection }}</v-icon>
{{ titleText }}
</span>
</v-toolbar-title>
</v-toolbar>
<panel :title="titleText" :icon="mdiConnection" card-class="the-connection-dialog" :margin-bottom="false">
<v-card-text v-if="connectingFailed" class="pt-5">
<connection-status :moonraker="false"></connection-status>
<p class="text-center mt-3">{{ $t('ConnectionDialog.CannotConnectTo', { host: formatHostname }) }}</p>
<connection-status :moonraker="false" />
<p class="text-center mt-3 mb-0">
{{ $t('ConnectionDialog.CannotConnectTo', { host: formatHostname }) }}
</p>
<p v-if="connectionFailedMessage" class="text-center mt-1 red--text">
{{ $t('ConnectionDialog.ErrorMessage', { message: connectionFailedMessage }) }}
</p>
<template v-if="counter > 2">
<v-divider class="my-3"></v-divider>
<v-divider class="my-3" />
<p>{{ $t('ConnectionDialog.CheckMoonrakerLog') }}</p>
<ul>
<li>~/printer_data/logs/moonraker.log</li>
</ul>
<v-divider class="mt-4 mb-5"></v-divider>
<v-divider class="mt-4 mb-5" />
</template>
<div class="text-center">
<div class="text-center mt-3">
<v-btn class="primary--text" @click="reconnect">{{ $t('ConnectionDialog.TryAgain') }}</v-btn>
</div>
</v-card-text>
<v-card-text v-else class="pt-5">
<v-progress-linear :color="progressBarColor" indeterminate></v-progress-linear>
<v-progress-linear :color="progressBarColor" indeterminate />
</v-card-text>
</v-card>
</panel>
</v-dialog>
</template>

Expand All @@ -52,10 +47,6 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
counter = 0
get protocol() {
return this.$store.state.socket.protocol
}
get hostname() {
return this.$store.state.socket.hostname
}
Expand Down Expand Up @@ -94,6 +85,10 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
return this.formatHostname
}
get connectionFailedMessage() {
return this.$store.state.socket.connectionFailedMessage ?? null
}
reconnect() {
this.counter++
this.$store.dispatch('socket/setData', { connectingFailed: false })
Expand Down
141 changes: 133 additions & 8 deletions src/components/TheEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<v-icon small class="mr-1">{{ mdiHelp }}</v-icon>
{{ $t('Editor.ConfigReference') }}
</v-btn>
<v-btn v-if="configFileStructure" text tile class="d-none d-md-flex" @click="showFileStructure()">
<v-icon small class="mr-1">{{ mdiFormatListCheckbox }}</v-icon>
{{ $t('Editor.FileStructure') }}
</v-btn>
<v-btn
v-if="restartServiceNameExists"
color="primary"
Expand All @@ -48,17 +52,50 @@
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text class="pa-0">
<v-card-text class="pa-0 d-flex">
<codemirror-async
v-if="show"
ref="editor"
v-model="sourcecode"
:name="filename"
:file-extension="fileExtension" />
:file-extension="fileExtension"
class="codemirror"
@lineChange="lineChanges" />
<div v-if="fileStructureSidebar" class="d-none d-md-flex structure-sidebar">
<v-treeview
activatable
dense
:active="structureActive"
:open="structureOpen"
item-key="line"
:items="configFileStructure"
class="w-100"
@update:active="activeChanges">
<template #label="{ item }">
<div
class="cursor-pointer _structure-sidebar-item"
:class="item.type == 'item' ? 'ͼp' : 'ͼt'">
{{ item.name }}
</div>
</template>
<template v-if="restartServiceName === 'klipper'" #append="{ item }">
<v-btn
v-if="item.type == 'section'"
icon
small
plain
color="grey darken-2"
:href="klipperConfigReference + '#' + item.name.split(' ')[0]"
target="_blank">
<v-icon small class="mr-1">{{ mdiHelpCircle }}</v-icon>
</v-btn>
</template>
</v-treeview>
</div>
</v-card-text>
</panel>
</v-dialog>
<v-snackbar v-model="loaderBool" :timeout="-1" :value="true" fixed right bottom>
<v-snackbar v-model="loaderBool" :timeout="-1" fixed right bottom>
<div>
{{ snackbarHeadline }}
<br />
Expand Down Expand Up @@ -123,7 +160,7 @@
</template>

<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator'
import { Component, Mixins, Ref, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { capitalize, formatFilesize, windowBeforeUnloadFunction } from '@/plugins/helpers'
import Panel from '@/components/ui/Panel.vue'
Expand All @@ -139,16 +176,20 @@ import {
mdiHelpCircle,
mdiRestart,
mdiUsb,
mdiFormatListCheckbox,
} from '@mdi/js'
import type Codemirror from '@/components/inputs/Codemirror.vue'
import DevicesDialog from '@/components/dialogs/DevicesDialog.vue'
import { ConfigFileSection } from '@/store/files/types'
@Component({
components: { DevicesDialog, Panel, CodemirrorAsync },
})
export default class TheEditor extends Mixins(BaseMixin) {
dialogConfirmChange = false
dialogDevices = false
fileStructureSidebar = true
structureActive: number[] = []
structureOpen: number[] = []
formatFilesize = formatFilesize
Expand All @@ -164,10 +205,10 @@ export default class TheEditor extends Mixins(BaseMixin) {
mdiFileDocumentEditOutline = mdiFileDocumentEditOutline
mdiFileDocumentOutline = mdiFileDocumentOutline
mdiUsb = mdiUsb
mdiFormatListCheckbox = mdiFormatListCheckbox
declare $refs: {
editor: Codemirror
}
//@ts-ignore
@Ref('editor') editor!: CodemirrorAsync
get changed() {
return this.$store.state.editor.changed ?? false
Expand Down Expand Up @@ -305,6 +346,48 @@ export default class TheEditor extends Mixins(BaseMixin) {
return url
}
get configFileStructure() {
if (!['conf', 'cfg'].includes(this.fileExtension)) {
this.fileStructureSidebar = false
return null
}
const lines = this.sourcecode.split(/\n/gi)
const regex = /^[^#\S]*?(\[(?<section>.*?)]|(?<name>\w+)\s*?[:=])/gim
const structure: ConfigFileSection[] = []
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
const matches = [...line.matchAll(regex)]
// break if no matches were found
if (matches.length === 0) continue
const match = matches[0]
if (match['groups']['section']) {
structure.push({
name: match['groups']['section'],
type: 'section',
line: i + 1,
children: [],
})
continue
}
if (match['groups']['name']) {
structure[structure.length - 1]['children'].push({
name: match['groups']['name'],
type: 'item',
line: i + 1,
})
}
}
this.fileStructureSidebar = true
return structure
}
cancelDownload() {
this.$store.dispatch('editor/cancelLoad')
}
Expand Down Expand Up @@ -337,6 +420,29 @@ export default class TheEditor extends Mixins(BaseMixin) {
})
}
showFileStructure() {
this.fileStructureSidebar = !this.fileStructureSidebar
}
activeChanges(key: any) {
this.editor?.gotoLine(key)
}
lineChanges(line: number) {
this.configFileStructure?.map((item) => {
if (item.line == line) {
this.structureActive = [line]
} else {
item.children?.map((child) => {
if (child.line == line) {
this.structureActive = [line]
if (!this.structureOpen.includes(item.line)) this.structureOpen.push(item.line)
}
})
}
})
}
@Watch('changed')
changedChanged(newVal: boolean) {
if (!this.confirmUnsavedChanges) return
Expand Down Expand Up @@ -398,4 +504,23 @@ export default class TheEditor extends Mixins(BaseMixin) {
background-color: var(--color-primary);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E %3Cpath d='M15.88 8.29L10 14.17l-1.88-1.88a.996.996 0 1 0-1.41 1.41l2.59 2.59c.39.39 1.02.39 1.41 0L17.3 9.7a.996.996 0 0 0 0-1.41c-.39-.39-1.03-.39-1.42 0z' fill='%23fffff'/%3E %3C/svg%3E");
}
@media screen and (min-width: 960px) {
.codemirror {
width: calc(100% - 300px);
}
}
.structure-sidebar {
width: 300px;
overflow-y: auto;
}
._structure-sidebar-item {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
::v-deep .v-treeview-node__level + .v-treeview-node__level {
width: 12px;
}
</style>
12 changes: 11 additions & 1 deletion src/components/console/ConsoleTableEntry.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<template>
<v-row :class="entryStyle">
<v-col class="col-auto pr-0 text--disabled console-time">{{ entryFormatTime }}</v-col>
<v-col :class="messageClass" style="min-width: 0" @click.capture="commandClick" v-html="event.formatMessage" />
<v-col
v-if="!rawOutput"
:class="messageClass"
style="min-width: 0"
@click.capture="commandClick"
v-html="event.formatMessage" />
<v-col v-else :class="messageClass" style="min-width: 0" @click.capture="commandClick" v-text="event.message" />
</v-row>
</template>

Expand Down Expand Up @@ -38,6 +44,10 @@ export default class ConsoleTableEntry extends Mixins(BaseMixin) {
return classes
}
get rawOutput() {
return this.$store.state.gui.console.rawOutput ?? false
}
commandClick(event: Event) {
const eventTarget = event.target as Element
if (eventTarget.localName === 'a' && eventTarget.className.indexOf('command') !== -1) {
Expand Down
Loading

0 comments on commit 33a55af

Please sign in to comment.