Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: download button for crowsnest.log and sonar.log #991

Merged
merged 5 commits into from
Aug 1, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/components/panels/Machine/LogfilesPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<panel
:title="$t('Machine.LogfilesPanel.Logfiles')"
:title="$t('Machine.LogfilesPanel.Logfiles').toString()"
:icon="mdiFileDocumentEdit"
card-class="machine-logfiles-panel"
:collapsible="true">
Expand Down Expand Up @@ -28,6 +28,30 @@
Moonraker
</v-btn>
</v-col>
<v-col
v-if="existsCrowsnestLog"
:class="'col-12 pt-0 ' + (klipperState !== 'ready' ? 'col-md-6 mt-md-3 ' : 'col-md-12') + ''">
<v-btn
:href="apiUrl + '/server/files/logs/crowsnest.log'"
block
class="primary--text"
@click="downloadLog">
<v-icon class="mr-2">{{ mdiDownload }}</v-icon>
Crowsnest
</v-btn>
</v-col>
<v-col
v-if="existsSonarLog"
:class="'col-12 pt-0 ' + (klipperState !== 'ready' ? 'col-md-6 mt-md-3 ' : 'col-md-12') + ''">
<v-btn
:href="apiUrl + '/server/files/logs/sonar.log'"
block
class="primary--text"
@click="downloadLog">
<v-icon class="mr-2">{{ mdiDownload }}</v-icon>
Sonar
</v-btn>
</v-col>
</v-row>
</v-container>
</v-card-text>
Expand All @@ -38,6 +62,7 @@
import { Component, Mixins } from 'vue-property-decorator'
import BaseMixin from '../../mixins/base'
import Panel from '@/components/ui/Panel.vue'
import { FileStateFile } from '@/store/files/types'
import { mdiDownload, mdiFileDocumentEdit } from '@mdi/js'
@Component({
components: { Panel },
Expand All @@ -46,6 +71,20 @@ export default class LogfilesPanel extends Mixins(BaseMixin) {
mdiFileDocumentEdit = mdiFileDocumentEdit
mdiDownload = mdiDownload

get logfiles() {
return this.$store.getters['files/getDirectory']('logs').childrens
}

get existsCrowsnestLog(): boolean {
return this.logfiles.findIndex((log: FileStateFile) => log.filename === 'crowsnest.log') !== -1
}

get existsSonarLog(): boolean {
const sonarLog = this.logfiles.find((log: FileStateFile) => log.filename === 'sonar.log')

return sonarLog?.size > 0
}

downloadLog(event: any) {
event.preventDefault()
let href = ''
Expand Down