Some changes for the GUI
This commit is contained in:
parent
6790b17f86
commit
8d64b3bc9a
@ -2,7 +2,7 @@
|
|||||||
<div class="controls" v-if="display">
|
<div class="controls" v-if="display">
|
||||||
<i class="off-icon" v-on:click="action('shutdown')" v-if="off_available"></i>
|
<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="quit-icon" v-on:click="action('quit')" v-if="quit_available"></i>
|
||||||
<i :class="[ update_available ? 'update-icon' :'no-update-icon' ]" @click="$router.push({ name: 'update' })"></i>
|
<i class="update-icon" v-if="update_available&&update_possible" @click="$router.push({ name: 'update' })"></i>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -14,7 +14,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
display: true,
|
display: true,
|
||||||
update_available: false,
|
update_available: false,
|
||||||
update_possible: true,
|
update_possible: false,
|
||||||
quit_available: false,
|
quit_available: false,
|
||||||
off_available: false
|
off_available: false
|
||||||
}
|
}
|
||||||
@ -33,11 +33,14 @@ export default {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
if(response.data.status) {
|
if(response.data.status) {
|
||||||
if(response.data.message == "A new version is available"){
|
if(response.data.message == "A new version is available"){
|
||||||
|
|
||||||
|
// Allow to show the warning chip.
|
||||||
this.update_available = true
|
this.update_available = true
|
||||||
this.update_possible = true
|
this.update_possible = true
|
||||||
} else if(response.data.message == "This is the latest version"){
|
|
||||||
this.update_available = false
|
// Pass the versions as "global vars" through window variable.
|
||||||
this.update_possible = true
|
window.current_version = response.data.current_version
|
||||||
|
window.next_version = response.data.next_version
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.update_possible = false
|
this.update_possible = false
|
||||||
|
@ -1,21 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<div v-if="update_possible">
|
<p><strong>TinyCheck needs to be updated from the version {{current_version}} to the version {{next_version}}.</strong><br />
|
||||||
<div v-if="update_available">
|
|
||||||
<p><span class="orange-strong">TinyCheck needs to be updated.</span><br />
|
|
||||||
<span v-if="!update_launched">Please click on the button below to update it.</span>
|
<span v-if="!update_launched">Please click on the button below to update it.</span>
|
||||||
<span v-else>The process can take few minutes, please wait...</span>
|
<span v-else>The process can take few minutes, please wait...</span>
|
||||||
</p>
|
</p>
|
||||||
<button class="btn btn-primary" :class="[ update_launched ? 'loading' : '' ]" v-on:click="launch_update()">Update it now</button>
|
<button class="btn btn-primary" :class="[ update_launched ? 'loading' : '' ]" v-on:click="launch_update()">Update it now</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
|
||||||
<p><span class="green-strong">Your TinyCheck instance is up-to-date!</span><br />You'll be redirected in few seconds.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p><strong>You dont have Internet or the rights to update Tinycheck.</strong><br />You'll be redirected in few seconds.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -26,30 +16,22 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
translation: {},
|
translation: {},
|
||||||
update_available: null,
|
|
||||||
update_possible: true,
|
|
||||||
update_launched: null,
|
update_launched: null,
|
||||||
check_interval: null
|
check_interval: null,
|
||||||
|
next_version: null,
|
||||||
|
current_version: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
check_update: function() {
|
check_update: function() {
|
||||||
axios.get('/api/update/check', { timeout: 60000 })
|
axios.get('/api/update/check-version', { timeout: 60000 })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response.data.status)
|
|
||||||
if(response.data.status) {
|
if(response.data.status) {
|
||||||
if(response.data.message == "A new version is available"){
|
if(response.data.current_version == window.next_version){
|
||||||
this.update_available = true
|
window.current_version = response.data.current_version
|
||||||
this.update_possible = true
|
|
||||||
} else if (response.data.message == "This is the latest version"){
|
|
||||||
this.update_available = false
|
|
||||||
this.update_possible = true
|
|
||||||
clearInterval(this.check_interval);
|
clearInterval(this.check_interval);
|
||||||
setTimeout(function () { window.location.href = "/"; }.bind(this), 3000);
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.update_possible = false
|
|
||||||
setTimeout(function () { window.location.href = "/"; }.bind(this), 3000);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => { console.log(error) });
|
.catch(error => { console.log(error) });
|
||||||
@ -68,7 +50,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
this.check_update();
|
if ('next_version' in window && 'current_version' in window){
|
||||||
|
if (window.current_version != window.next_version){
|
||||||
|
this.next_version = window.next_version
|
||||||
|
this.current_version = window.current_version
|
||||||
|
} else {
|
||||||
|
window.location.href = "/";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.location.href = "/";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -29,15 +29,16 @@ class Update(object):
|
|||||||
res = json.loads(res.content.decode("utf8"))
|
res = json.loads(res.content.decode("utf8"))
|
||||||
|
|
||||||
with open(os.path.join(self.app_path, "VERSION")) as f:
|
with open(os.path.join(self.app_path, "VERSION")) as f:
|
||||||
if f.read() != res[0]["name"]:
|
cv = f.read()
|
||||||
|
if cv != res[0]["name"]:
|
||||||
return {"status": True,
|
return {"status": True,
|
||||||
"message": "A new version is available",
|
"message": "A new version is available",
|
||||||
"current_version": f.read(),
|
"current_version": cv,
|
||||||
"next_version": res[0]["name"]}
|
"next_version": res[0]["name"]}
|
||||||
else:
|
else:
|
||||||
return {"status": True,
|
return {"status": True,
|
||||||
"message": "This is the latest version",
|
"message": "This is the latest version",
|
||||||
"current_version": f.read()}
|
"current_version": cv}
|
||||||
except:
|
except:
|
||||||
return {"status": False,
|
return {"status": False,
|
||||||
"message": "Something went wrong (no API access nor version file)"}
|
"message": "Something went wrong (no API access nor version file)"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user