0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 17:27:57 +01:00

No retain option during update

This commit is contained in:
peteruithoven 2013-12-23 17:40:14 +01:00
parent 1f1b6c89dd
commit 136799e16c
2 changed files with 26 additions and 6 deletions

View File

@ -45,15 +45,21 @@ function UpdatePanel() {
this.wifiboxURL = wifiboxURL; this.wifiboxURL = wifiboxURL;
this.element = updatePanelElement; this.element = updatePanelElement;
this.noRetainCheckbox = this.element.find("#noRetain");
this.btnUpdate = this.element.find("#update"); this.btnUpdate = this.element.find("#update");
this.statusDisplay = this.element.find("#updateState"); this.statusDisplay = this.element.find("#updateState");
this.infoDisplay = this.element.find("#updateInfo"); this.infoDisplay = this.element.find("#updateInfo");
this.noRetainCheckbox.change(this.noRetainChanged);
this.btnUpdate.click(this.update); this.btnUpdate.click(this.update);
this.checkStatus(false); this.checkStatus(false);
} }
this.noRetainChanged = function(e) {
console.log("UpdatePanel:noRetainChanged");
self.setState(self.state,true);
}
this.update = function() { this.update = function() {
console.log("UpdatePanel:update"); console.log("UpdatePanel:update");
self.downloadUpdate(); self.downloadUpdate();
@ -75,10 +81,15 @@ function UpdatePanel() {
} }
this.installUpdate = function() { this.installUpdate = function() {
console.log("UpdatePanel:installUpdate"); console.log("UpdatePanel:installUpdate");
var noRetain = self.noRetainCheckbox.prop('checked');
self.stopCheckingStatus(); self.stopCheckingStatus();
postData = {no_retain:noRetain}
$.ajax({ $.ajax({
url: self.wifiboxURL + "/update/install", url: self.wifiboxURL + "/update/install",
type: "POST", type: "POST",
data: postData,
dataType: 'json', dataType: 'json',
success: function(response){ success: function(response){
console.log("UpdatePanel:installUpdate response: ",response); console.log("UpdatePanel:installUpdate response: ",response);
@ -158,20 +169,27 @@ function UpdatePanel() {
break; break;
} }
} }
this.setState = function(newState) { this.setState = function(newState,refresh) {
if(this.state == newState) return; console.log("UpdatePanel:setState");
console.log("UpdatePanel:setState: ",this.state," > ",newState,"(",this.stateText,") (networkMode: ",self.networkMode,") (newestVersion: ",self.newestVersion,")"); if(!refresh && this.state == newState) return;
console.log("UpdatePanel:setState: ",this.state," > ",newState,"(",this.stateText,") (networkMode: ",self.networkMode,") (newestVersion: ",self.newestVersion,") (refresh: ",refresh,")");
this.state = newState; this.state = newState;
var noRetain = self.noRetainCheckbox.prop('checked');
console.log(" noRetain", noRetain);
// download button // download button
// if there isn't newestVersion data something went wrong, // if there isn't newestVersion data something went wrong,
// probably accessing the internet // probably accessing the internet
console.log(" self.newestVersion: ",self.newestVersion);
if(self.newestVersion != undefined) { if(self.newestVersion != undefined) {
console.log(" this.state: ",this.state);
switch(this.state){ switch(this.state){
case UpdatePanel.NONE: case UpdatePanel.NONE:
case UpdatePanel.DOWNLOAD_FAILED: case UpdatePanel.DOWNLOAD_FAILED:
case UpdatePanel.INSTALL_FAILED: case UpdatePanel.INSTALL_FAILED:
if(self.canUpdate) { console.log(" self.canUpdate: ",self.canUpdate);
if(self.canUpdate || noRetain) {
self.btnUpdate.removeAttr("disabled"); self.btnUpdate.removeAttr("disabled");
} else { } else {
self.btnUpdate.attr("disabled", true); self.btnUpdate.attr("disabled", true);

View File

@ -162,6 +162,8 @@
<fieldset id="updatePanel"> <fieldset id="updatePanel">
<legend>Update</legend> <legend>Update</legend>
<label for="noRetain">Remove personal data:</label><input id="noRetain" type="checkbox" name="" value="noRetain">
<br/><br/>
<input type="button" name="update" value="Update" class="button" id="update"/> <input type="button" name="update" value="Update" class="button" id="update"/>
<span id="updateState"></span><br/> <span id="updateState"></span><br/>
<small id="updateInfo"></small> <small id="updateInfo"></small>