Starting update interface implementation

This commit is contained in:
Félix Aime
2021-02-18 22:17:29 +01:00
parent 5334f30edf
commit 9382a1fd9f
6 changed files with 261 additions and 103 deletions

View File

@ -1,19 +1,22 @@
<template>
<div class="controls">
<i class="off-icon" v-on:click="action('shutdown')" v-if="off_available && off_display"></i>
<i class="quit-icon" v-on:click="action('quit')" v-if="quit_available && quit_display"></i>
<div class="controls" v-if="display">
<i class="off-icon" v-on:click="action('shutdown')" v-if="off_available"></i>
<i class="quit-icon" v-on:click="action('quit')" v-if="quit_available"></i>
<i :class="[ update_available ? 'update-icon' :'no-update-icon' ]" v-if="update_possibe" @click="$router.push({ name: 'update' })"></i>
</div>
</template>
<script>
import axios from 'axios'
export default {
name: 'Controls',
data: function (){
return {
off_available : false,
off_display : false,
display: true,
update_available: false,
update_possible: true,
quit_available: false,
quit_display : false
off_available: false
}
},
methods: {
@ -25,6 +28,23 @@ export default {
})
.catch(error => { console.log(error) });
},
check_update: function() {
axios.get('/api/update/check', { timeout: 60000 })
.then(response => {
if(response.data.status) {
if(response.data.message == "A new version is available"){
this.update_available = true
this.update_possible = true
} else if(response.data.message == "This is the latest version"){
this.update_available = false
this.update_possible = true
}
} else {
this.update_possible = false
}
})
.catch(error => { console.log(error) });
},
load_config: function() {
axios.get(`/api/misc/config`, { timeout: 60000 })
.then(response => {
@ -36,17 +56,16 @@ export default {
},
watch: {
$route (){
if ( ["capture", "report"].includes(this.$router.currentRoute.name) || screen.height != window.innerHeight ){
this.off_display = false;
this.quit_display = false;
if ( ["capture", "report", "update", "loader"].includes(this.$router.currentRoute.name)){
this.display = false;
} else {
this.off_display = (this.off_available)? true : false;
this.quit_display = (this.quit_available)? true : false;
this.display = true;
}
}
},
created: function() {
this.load_config()
},
this.load_config();
this.check_update();
}
}
</script>