forked from mainsail-crew/mainsail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mmu.log to logfiles panel (mainsail-crew#1685)
- Loading branch information
Showing
4 changed files
with
178 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/components/panels/Machine/LogfilesPanel/LogfilesPanelGenericLog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<v-col v-if="exists" :class="classes"> | ||
<v-btn :href="href" block class="primary--text" @click="downloadLog"> | ||
<v-icon class="mr-2">{{ mdiDownload }}</v-icon> | ||
{{ name }} | ||
</v-btn> | ||
</v-col> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import Panel from '@/components/ui/Panel.vue' | ||
import { FileStateFile } from '@/store/files/types' | ||
import { mdiDownload } from '@mdi/js' | ||
@Component({ | ||
components: { Panel }, | ||
}) | ||
export default class LogfilesPanel extends Mixins(BaseMixin) { | ||
mdiDownload = mdiDownload | ||
@Prop({ type: String, required: true }) name!: string | ||
get logfiles() { | ||
return this.$store.getters['files/getDirectory']('logs')?.childrens ?? [] | ||
} | ||
get filename() { | ||
return this.name + '.log' | ||
} | ||
get exists(): boolean { | ||
if (['klippy', 'moonraker'].includes(this.name)) return true | ||
return this.logfiles.findIndex((log: FileStateFile) => log.filename === this.filename) !== -1 | ||
} | ||
get href() { | ||
let path = '/server/files/logs/' | ||
if (['klippy', 'moonraker'].includes(this.name)) path = '/server/files/' | ||
return this.apiUrl + path + this.filename | ||
} | ||
get classes() { | ||
const output = ['col-12', 'pt-0'] | ||
if (this.klipperState !== 'ready') { | ||
output.push('col-md-6') | ||
output.push('mt-md-3') | ||
} else { | ||
output.push('col-md-12') | ||
} | ||
return output | ||
} | ||
downloadLog(event: any) { | ||
event.preventDefault() | ||
let href = '' | ||
if ('href' in event.target.attributes) href = event.target.attributes.href.value | ||
if ('href' in event.target.parentElement.attributes) href = event.target.parentElement.attributes.href.value | ||
window.open(href) | ||
} | ||
} | ||
</script> |
94 changes: 94 additions & 0 deletions
94
src/components/panels/Machine/LogfilesPanel/LogfilesPanelRolloverDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<v-dialog :value="show" persistent width="400" :fullscreen="isMobile"> | ||
<panel | ||
:title="$t('Machine.LogfilesPanel.Rollover')" | ||
card-class="machine_rollover_logfiles-dialog" | ||
:icon="mdiFileSyncOutline" | ||
:margin-bottom="false"> | ||
<template #buttons> | ||
<v-btn icon tile @click="closeDialog"> | ||
<v-icon>{{ mdiCloseThick }}</v-icon> | ||
</v-btn> | ||
</template> | ||
<v-card-text> | ||
<v-row> | ||
<v-col> | ||
<p class="mb-0">{{ $t('Machine.LogfilesPanel.RolloverDescription') }}</p> | ||
</v-col> | ||
</v-row> | ||
<v-row class="mt-0"> | ||
<v-col> | ||
<v-checkbox | ||
v-for="log in rolloverLogfiles" | ||
:key="log" | ||
v-model="selectedRolloverLogs" | ||
:label="capitalize(log)" | ||
:value="log" | ||
hide-details | ||
class="mt-0" /> | ||
</v-col> | ||
</v-row> | ||
</v-card-text> | ||
<v-card-actions> | ||
<v-spacer /> | ||
<v-btn text @click="closeDialog"> | ||
{{ $t('Machine.LogfilesPanel.Cancel') }} | ||
</v-btn> | ||
<v-btn color="primary" text @click="btnRolloverLogs"> | ||
{{ $t('Machine.LogfilesPanel.Accept') }} | ||
</v-btn> | ||
</v-card-actions> | ||
</panel> | ||
</v-dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import Panel from '@/components/ui/Panel.vue' | ||
import { mdiCloseThick, mdiFileSyncOutline } from '@mdi/js' | ||
import { rolloverLogfiles } from '@/store/variables' | ||
import { capitalize } from '@/plugins/helpers' | ||
import LogfilesPanelGenericLog from '@/components/panels/Machine/LogfilesPanel/LogfilesPanelGenericLog.vue' | ||
@Component({ | ||
components: { LogfilesPanelGenericLog, Panel }, | ||
}) | ||
export default class LogfilesPanelRolloverDialog extends Mixins(BaseMixin) { | ||
mdiCloseThick = mdiCloseThick | ||
mdiFileSyncOutline = mdiFileSyncOutline | ||
rolloverLogfiles = rolloverLogfiles | ||
capitalize = capitalize | ||
@Prop({ type: Boolean, default: false }) show!: boolean | ||
selectedRolloverLogs: string[] = [] | ||
get loadingRolloverLogs() { | ||
return this.loadings.filter((log) => log.startsWith('rolloverLog_')).length > 0 | ||
} | ||
@Watch('loadingRolloverLogs') | ||
loadingRolloverLogsChanged(newVal: boolean) { | ||
if (newVal) this.closeDialog() | ||
} | ||
btnRolloverLogs() { | ||
if (this.selectedRolloverLogs.length === 0) return | ||
this.selectedRolloverLogs.forEach((name) => { | ||
this.$socket.emit( | ||
'server.logs.rollover', | ||
{ application: name }, | ||
{ loading: 'rolloverLog_' + name, action: 'files/rolloverLog' } | ||
) | ||
}) | ||
this.selectedRolloverLogs = [] | ||
} | ||
closeDialog() { | ||
this.$emit('close-dialog') | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters