Merge branch 'master' into feature/history

This commit is contained in:
Stefan Dej 2021-03-19 19:55:35 +01:00
commit 4260192e9c
11 changed files with 84 additions and 104 deletions

View File

@ -4,17 +4,17 @@
<v-toolbar flat dense color="orange darken-2">
<v-toolbar-title>
<span class="subheading">
<v-icon class="mdi mdi-alert-circle" left></v-icon>Moonraker Failed Plugins
<v-icon class="mdi mdi-alert-circle" left></v-icon>Moonraker Failed Components
</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="px-0 pt-0 pb-2 content">
<v-layout wrap class=" text-center">
<v-flex col class="text-left">
<p class="orange--text">An error was detected while loading the moonraker plugins. Please check the logfile and fix the issue.</p>
<p class="orange--text">An error was detected while loading the moonraker components. Please check the logfile and fix the issue.</p>
<p class="mb-2 orange--text">Following plugin has an error:</p>
<ul class="mt-0 pt-0">
<li v-for="plugin in failedPlugins" v-bind:key="plugin" class="orange--text"><code>{{ plugin }}</code></li>
<li v-for="component in failedComponents" v-bind:key="component" class="orange--text"><code>{{ component }}</code></li>
</ul>
</v-flex>
</v-layout>
@ -35,7 +35,7 @@
}),
computed: {
...mapState({
failedPlugins: state => state.server.failed_plugins,
failedComponents: state => state.server.failed_components,
hostname: state => state.socket.hostname,
port: state => state.socket.port,
}),

View File

@ -80,24 +80,17 @@
<v-spacer></v-spacer>
<v-btn small class="minwidth-0" color="grey darken-3" @click="commitsOverlay.bool = false"><v-icon small>mdi-close-thick</v-icon></v-btn>
</v-toolbar>
<v-card-text class="py-5" v-if="commitsOverlay.loading">
<v-row class="pt-0">
<v-col>
<v-progress-linear color="primary" indeterminate></v-progress-linear>
</v-col>
</v-row>
</v-card-text>
<v-card-text class="py-0" v-if="!commitsOverlay.loading" style="max-height: 400px; overflow-y: scroll;">
<v-card-text class="py-0" style="max-height: 400px; overflow-y: scroll;">
<v-row>
<v-col class="pt-3 pl-0">
<v-timeline class="updateManager" align-top dense >
<v-timeline-item color="primary" small v-for="commit of commitsOverlay.outputs" v-bind:key="commit.sha">
<v-timeline-item color="primary" small v-for="commit of commitsOverlay.commits" v-bind:key="commit.sha">
<v-row class="pt-0">
<v-col>
<a class="font-weight-bold white--text" :href="commit.url" target="_blank">{{ commit.title }}</a><br />
<p v-if="commit.message" class="mb-0" v-html="commit.message.replace(/(?:\r\n|\r|\n)/g, '<br />')"></p>
<a class="font-weight-bold white--text" :href="'https://github.com/'+commitsOverlay.owner+'/'+commitsOverlay.modul+'/commit/'+commit.sha" target="_blank">{{ commit.subject }}</a><br />
<p v-if="commit.message" class="mb-0" v-html="convertCommitMessage(commit.message)"></p>
<div class="caption">
<strong>{{ commit.author }}</strong> committed at {{ commit.date.toLocaleString() }}
<strong>{{ commit.author }}</strong> committed at {{ new Date(commit.date * 1000).toLocaleString() }}
</div>
</v-col>
</v-row>
@ -114,7 +107,6 @@
<script>
import { mapState } from 'vuex'
import semver from 'semver'
import axios from 'axios'
export default {
components: {
@ -124,9 +116,9 @@
return {
commitsOverlay: {
bool: false,
loading: false,
response: [],
outputs: [],
owner: "",
modul: "",
commits: [],
}
}
},
@ -264,12 +256,8 @@
},
getVersionClickable(object) {
return (
'branch' in object &&
object.branch === "master" &&
'current_hash' in object &&
'remote_hash' in object &&
object.current_hash !== object.remote_hash &&
'owner' in object
'commits_behind' in object &&
object.commits_behind.length
)
},
updateModule(key) {
@ -281,58 +269,36 @@
},
openCommitsOverlay(key, object) {
if (
['klipper', 'moonraker'].includes(key) &&
this.getVersionClickable(object) &&
'owner' in object
'commits_behind' in object &&
'owner' in object &&
object.commits_behind.length
) {
this.commitsOverlay.owner = object.owner
this.commitsOverlay.modul = key
this.commitsOverlay.commits = object.commits_behind
this.commitsOverlay.bool = true
this.commitsOverlay.loading = true
const apiUrl = "https://api.github.com/repos/"+object.owner+"/"+key+"/commits"
if (apiUrl) {
axios
.get(apiUrl)
.then(response => {
this.commitsOverlay.response = response
this.commitsOverlay.outputs.splice(0, this.commitsOverlay.outputs.length)
const index = response.data.findIndex(commit => commit.sha === object.current_hash)
if (index !== -1) {
this.commitsOverlay.response = response.data.splice(0, index).sort((a,b) => {
const dataA = new Date(a.commit.author.date)
const dataB = new Date(b.commit.author.date)
return dataB - dataA
})
this.commitsOverlay.response.forEach(commit => {
const date = new Date(commit.commit.author.date)
const author = commit.commit.author.name
const firstIndex = commit.commit.message.indexOf('\n\n')
let lastIndex = commit.commit.message.lastIndexOf('\n\n')
if (firstIndex === lastIndex && commit.commit.message.lastIndexOf('\r') > firstIndex) {
lastIndex = commit.commit.message.lastIndexOf('\r')
}
this.commitsOverlay.outputs.push({
sha: commit.sha,
date: date,
author: author,
url: commit.html_url,
title: commit.commit.message.substr(0, firstIndex),
message: (firstIndex+2 < lastIndex-2) ? commit.commit.message.substr(firstIndex+2, lastIndex-firstIndex-2) : "",
firstIndex: firstIndex,
lastIndex: lastIndex,
})
})
}
this.commitsOverlay.loading = false
})
}
}
},
convertCommitMessage(message) {
const lastIndex = message.lastIndexOf('Signed-off-by:')
if (lastIndex !== -1) {
message = message.substr(0, lastIndex)
}
message = this.trimEndLineBreak(message)
message.replace(/(?:\r\n|\r|\n)/g, '<br />')
return message
},
trimEndLineBreak(message) {
if (['\n', '\r'].includes(message.substr(-1))) {
message = message.substr(0, message.length - 2)
this.trimEndLineBreak(message)
}
return message
}
}
}
</script>

View File

@ -3,7 +3,7 @@ import Vue from 'vue'
import StatusPanel from './StatusPanel.vue'
import KlippyStatePanel from './KlippyStatePanel.vue'
import MinSettingsPanel from './MinSettingsPanel.vue'
import MoonrakerFailedPluginsPanel from './MoonrakerFailedPluginsPanel.vue'
import MoonrakerFailedComponentsPanel from './MoonrakerFailedComponentsPanel.vue'
import ToolsPanel from './ToolsPanel.vue'
import ControlPanel from "./ControlPanel";
import ZOffsetPanel from "./ZOffsetPanel";
@ -17,7 +17,7 @@ import HistoryListPanel from "./HistoryListPanel.vue";
Vue.component('status-panel', StatusPanel);
Vue.component('klippy-state-panel', KlippyStatePanel);
Vue.component('min-settings-panel', MinSettingsPanel);
Vue.component('moonraker-failed-plugins-panel', MoonrakerFailedPluginsPanel);
Vue.component('moonraker-failed-components-panel', MoonrakerFailedComponentsPanel);
Vue.component('tools-panel', ToolsPanel);
Vue.component('control-panel', ControlPanel);
Vue.component('zoffset-panel', ZOffsetPanel);

View File

@ -2,7 +2,7 @@
<v-row>
<v-col class="col-sm-12 col-md-5">
<min-settings-panel v-if="klippy_state === 'ready' && existsPrinterConfig"></min-settings-panel>
<moonraker-failed-plugins-panel v-if="moonrakerFailedPlugins.length"></moonraker-failed-plugins-panel>
<moonraker-failed-components-panel v-if="moonrakerFailedComponents.length"></moonraker-failed-components-panel>
<klippy-state-panel v-if="socket_connected && klippy_state !== 'ready'"></klippy-state-panel>
<status-panel v-if="klippy_state === 'ready'"></status-panel>
<webcam-panel class="mt-6" v-if="showDashboardWebcam"></webcam-panel>
@ -31,7 +31,7 @@
socket_connected: state => state.socket.isConnected,
klippy_connected: state => state.server.klippy_connected,
klippy_state: state => state.server.klippy_state,
moonrakerFailedPlugins: state => state.server.failed_plugins,
moonrakerFailedComponents: state => state.server.failed_components,
showDashboardWebcam: state => state.gui.dashboard.boolWebcam,
showDashboardConsole: state => state.gui.dashboard.boolConsole,

View File

@ -34,7 +34,11 @@
}),
updateManager:{
get() {
return this.$store.state.server.plugins.includes('update_manager')
//reverse compatibility
if ('plugins' in this.$store.state.server)
return this.$store.state.server.plugins.includes('update_manager')
return this.$store.state.server.components.includes('update_manager')
}
}
},

View File

@ -76,9 +76,9 @@ export default {
},
getImage: state => {
if (
/*if (
'gui' in state.data &&
'webcam' in state.data.gui.webcam &&
'webcam' in state.data.gui &&
'url' in state.data.gui.webcam &&
state.data.gui.webcam.url !== "" &&
'bool' in state.data.gui.webcam &&
@ -88,13 +88,22 @@ export default {
state.data.gui.dashboard.boolWebcam
) {
return state.data.gui.webcam.url
} else if (
} else*/
if (
state.current_file &&
"filename" in state.current_file &&
"thumbnails" in state.current_file &&
state.current_file.thumbnails.find((element) => element.width === 400 && element.height === 300)
state.current_file.thumbnails.length
) {
return 'data:image/gif;base64,'+state.current_file.thumbnails.find((element) => element.width === 400 && element.height === 300).data
} else return "/img/sidebar-background.png"
const indexLastDir = state.current_file.filename.lastIndexOf('/')
const dir = (indexLastDir !== -1) ? state.current_file.filename.substr(0, indexLastDir) : ""
const thumbnail = state.current_file.thumbnails.find(thumb => thumb.width >= 300 && thumb.width <= 400)
if (thumbnail && 'relative_path' in thumbnail) return "//"+state.socket.hostname+":"+state.socket.port+'/server/files/gcodes/'+dir+'/'+thumbnail.relative_path
}
return "/img/sidebar-background.png"
},
getLogo: state => {

View File

@ -8,9 +8,6 @@ export default {
init() {
Vue.prototype.$socket.sendObj('printer.info', {}, 'printer/getInfo')
// only available with klipper is ready
//Vue.prototype.$socket.sendObj('server.files.get_directory', { path: 'gcodes' }, 'files/getDirectory')
},
getInfo({ commit }, payload) {

View File

@ -241,12 +241,12 @@ export default {
if (nameSplit[0].toLowerCase() === "output_pin") {
controllable = true
pwm = false
if ('settings' in state.configfile && key in state.configfile.settings) {
if ('pwm' in state.configfile.settings[key])
pwm = state.configfile.settings[key].pwm
if ('settings' in state.configfile && key.toLowerCase() in state.configfile.settings) {
if ('pwm' in state.configfile.settings[key.toLowerCase()])
pwm = state.configfile.settings[key.toLowerCase()].pwm
if ('scale' in state.configfile.settings[key])
scale = state.configfile.settings[key].scale
if ('scale' in state.configfile.settings[key.toLowerCase()])
scale = state.configfile.settings[key.toLowerCase()].scale
}
}
@ -262,12 +262,12 @@ export default {
config: state.configfile.settings[key]
}
if ('settings' in state.configfile && key in state.configfile.settings) {
if ('off_below' in state.configfile.settings[key])
tmp['off_below'] = state.configfile.settings[key].off_below
if ('settings' in state.configfile && key.toLowerCase() in state.configfile.settings) {
if ('off_below' in state.configfile.settings[key.toLowerCase()])
tmp['off_below'] = state.configfile.settings[key.toLowerCase()].off_below
if ('max_power' in state.configfile.settings[key])
tmp['max_power'] = state.configfile.settings[key].max_power
if ('max_power' in state.configfile.settings[key.toLowerCase()])
tmp['max_power'] = state.configfile.settings[key.toLowerCase()].max_power
}
output.push(tmp)

View File

@ -16,7 +16,7 @@ export default {
}
this.dispatch('socket/clearLoadings', null, { root: true })
if (this.state.server.plugins.includes("update_manager"))
if (this.state.server.components.includes("update_manager"))
Vue.prototype.$socket.sendObj('machine.update.status', { refresh: false }, 'server/updateManager/getStatus')
},

View File

@ -47,11 +47,15 @@ export default {
},
getInfo({ commit, state, rootState }, payload) {
if (state.plugins.length === 0) {
if (payload.plugins.includes("power") !== false)
if (state.components.length === 0) {
//reverse compatibility
let components = ('components' in payload) ? payload.components : []
if (components.length === 0 && 'plugins' in payload) components = payload.plugins
if (components.includes("power") !== false)
Vue.prototype.$socket.sendObj('machine.device_power.devices', {}, 'server/power/getDevices')
if (payload.plugins.includes("update_manager") !== false)
if (components.includes("update_manager") !== false)
Vue.prototype.$socket.sendObj('machine.update.status', {}, 'server/updateManager/getStatus')
if (payload.plugins.includes("history") !== false)

View File

@ -13,8 +13,8 @@ export function getDefaultState() {
klippy_connected: false,
klippy_state: "",
klippy_message: "",
plugins: [],
failed_plugins: [],
components: [],
failed_components: [],
registered_directories: [],
events: [],
config: {},