Add update functionality to Domoboard
This commit is contained in:
parent
204b16542f
commit
9673bfe69b
|
|
@ -79,6 +79,8 @@ def gateway():
|
||||||
writeToConfig(idx, page, component, description, extra)
|
writeToConfig(idx, page, component, description, extra)
|
||||||
elif custom == 'indexPlugins':
|
elif custom == 'indexPlugins':
|
||||||
result = json.dumps(indexPlugins(request.args))
|
result = json.dumps(indexPlugins(request.args))
|
||||||
|
elif custom == "performUpgrade":
|
||||||
|
result = json.dumps(performUpgrade())
|
||||||
elif custom in apiDict:
|
elif custom in apiDict:
|
||||||
module = apiDict.get(custom)[0]
|
module = apiDict.get(custom)[0]
|
||||||
function = apiDict.get(custom)[1]
|
function = apiDict.get(custom)[1]
|
||||||
|
|
@ -163,6 +165,10 @@ def getPluginVersion(loc):
|
||||||
c += 1
|
c += 1
|
||||||
return float(_version)
|
return float(_version)
|
||||||
|
|
||||||
|
def performUpgrade():
|
||||||
|
git.cmd.Git('.').pull("https://github.com/wez3/domoboard.git")
|
||||||
|
return "Upgrade completed."
|
||||||
|
|
||||||
def indexPlugins(params={}):
|
def indexPlugins(params={}):
|
||||||
tmpFolder = 'static/tmp'
|
tmpFolder = 'static/tmp'
|
||||||
indexFolderPath = 'static/tmp/pluginsIndex/'
|
indexFolderPath = 'static/tmp/pluginsIndex/'
|
||||||
|
|
|
||||||
14
server.py
14
server.py
|
|
@ -45,7 +45,9 @@ def generatePage():
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
configValues = configValues,
|
configValues = configValues,
|
||||||
blockArray = blockArray,
|
blockArray = blockArray,
|
||||||
_csrf_token = session['_csrf_token'])
|
_csrf_token = session['_csrf_token'],
|
||||||
|
version = getVersion(),
|
||||||
|
debug = app.debug)
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
@ -128,6 +130,12 @@ def appendDefaultPages(config):
|
||||||
config['log'] = {'display_components': {'components': 'serverlog'}}
|
config['log'] = {'display_components': {'components': 'serverlog'}}
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def getVersion():
|
||||||
|
f = open('VERSION.md', 'r')
|
||||||
|
version = f.read().rstrip()
|
||||||
|
f.close()
|
||||||
|
return version
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-c", "--config", dest="configfile",
|
parser.add_argument("-c", "--config", dest="configfile",
|
||||||
|
|
@ -166,6 +174,6 @@ if __name__ == '__main__':
|
||||||
app.add_url_rule('/logout/', 'logout', logout_view, methods=['GET'])
|
app.add_url_rule('/logout/', 'logout', logout_view, methods=['GET'])
|
||||||
app.add_url_rule('/api', 'api', api.gateway, methods=['POST'])
|
app.add_url_rule('/api', 'api', api.gateway, methods=['POST'])
|
||||||
try:
|
try:
|
||||||
app.run(host=flask_server_location.split(":")[0],port=int(flask_server_location.split(":")[1]),threaded=True, extra_files=watchfiles, debug=args.debug)
|
app.run(host=flask_server_location.split(":")[0],port=int(flask_server_location.split(":")[1]), threaded=True, extra_files=watchfiles, debug=args.debug)
|
||||||
except socket.error, exc:
|
except socket.error, exc:
|
||||||
sys.exit("Error when starting the Flask server: %s" % exc)
|
sys.exit("Error when starting the Flask server: {}".format(exc))
|
||||||
|
|
|
||||||
|
|
@ -6383,12 +6383,17 @@ ul.notifications {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
#time-part {
|
#time-part {
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
}
|
}
|
||||||
#date-part {
|
#date-part {
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
#version_div {
|
||||||
|
float: right;
|
||||||
|
margin-top:15px;
|
||||||
|
margin-right:10px;
|
||||||
}
|
}
|
||||||
.show_date {
|
.show_date {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
@ -6396,3 +6401,9 @@ ul.notifications {
|
||||||
.hide_date {
|
.hide_date {
|
||||||
display: None;
|
display: None;
|
||||||
}
|
}
|
||||||
|
.show_update {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.hide_update {
|
||||||
|
display: None;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,3 +341,53 @@ function changeDown(idx, block) {
|
||||||
changeSetpoint(idx, newVal);
|
changeSetpoint(idx, newVal);
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update functions
|
||||||
|
function performUpgrade() {
|
||||||
|
requestAPI('/api?custom=performUpgrade');
|
||||||
|
$( "#version_div" ).removeClass("show_update");
|
||||||
|
$( "#version_div" ).addClass("hide_update");
|
||||||
|
$( "#updateView_available" ).removeClass("show_update");
|
||||||
|
$( "#updateView_available" ).addClass("hide_update");
|
||||||
|
$( "#updateView_not_available" ).removeClass("hide_update");
|
||||||
|
$( "#updateView_not_available" ).addClass("show_update");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkVersion() {
|
||||||
|
$.ajax({
|
||||||
|
url: "https://domoboard.nl/version.md",
|
||||||
|
cache: false,
|
||||||
|
success: function( data ) {
|
||||||
|
dataFloat = parseFloat(data);
|
||||||
|
versionFloat = parseFloat(version);
|
||||||
|
if (dataFloat > versionFloat) {
|
||||||
|
document.getElementById('curver').innerHTML = version;
|
||||||
|
document.getElementById('newver').innerHTML = data;
|
||||||
|
$( "#version_div" ).removeClass("hide_update");
|
||||||
|
$( "#version_div" ).addClass("show_update");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async:true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkVersionSettings() {
|
||||||
|
$.ajax({
|
||||||
|
url: "https://domoboard.nl/version.md",
|
||||||
|
cache: false,
|
||||||
|
success: function( data ) {
|
||||||
|
dataFloat = parseFloat(data);
|
||||||
|
versionFloat = parseFloat(version);
|
||||||
|
if (dataFloat > versionFloat) {
|
||||||
|
$( "#updateView_available" ).removeClass("hide_update");
|
||||||
|
$( "#updateView_available" ).addClass("show_update");
|
||||||
|
document.getElementById('curver_settings').innerHTML = version;
|
||||||
|
document.getElementById('newver_settings').innerHTML = data;
|
||||||
|
} else {
|
||||||
|
$( "#updateView_not_available" ).removeClass("hide_update");
|
||||||
|
$( "#updateView_not_available" ).addClass("show_update");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async:true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,12 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
setInterval(checkVersion, 43200000);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@
|
||||||
var flask_server = "{{ request.url_root[:-1] }}";
|
var flask_server = "{{ request.url_root[:-1] }}";
|
||||||
var csrf_token = "{{ _csrf_token }}";
|
var csrf_token = "{{ _csrf_token }}";
|
||||||
var googleMapEmbedKey = "{{ configValues["domoboard"].get("google_maps_api_key") }}"
|
var googleMapEmbedKey = "{{ configValues["domoboard"].get("google_maps_api_key") }}"
|
||||||
|
var version = "{{ version }}";
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="/static/js/domoboard.js"></script>
|
<script type="text/javascript" src="/static/js/domoboard.js"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="show_date" style="cursor: pointer; margin-left: -70px; min-height: 51px;" id="time-part"></div>
|
<div class="show_date" style="cursor: pointer; margin-left: -70px; min-height: 51px;" id="time-part"></div>
|
||||||
<div class="hide_date" style="cursor: pointer; padding-left: 2px;" id="date-part"></div>
|
<div class="hide_date" style="cursor: pointer; padding-left: 2px;" id="date-part"></div>
|
||||||
|
<div id="version_div" class="hide_update">
|
||||||
|
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#upgradeModal">
|
||||||
|
Update available
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -70,5 +75,36 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- /top navigation -->
|
<!-- /top navigation -->
|
||||||
|
|
||||||
|
<!-- Upgrade Modal -->
|
||||||
|
<div class="modal fade" id="upgradeModal" tabindex="-1" role="dialog" aria-labelledby="upgradeModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="upgradeModalLabel">Update available</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<h2>A new update is available for Domoboard.</h2><br />
|
||||||
|
The current version is <b><span id="curver"></span></b>.<br />
|
||||||
|
The new version available is: <b><span id="newver"></span></b>.<br />
|
||||||
|
<br />
|
||||||
|
{% if debug == True %}
|
||||||
|
<p><b>Install the new version by pressing the "Upgrade" button below.</b></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if debug == False %}
|
||||||
|
<p><b>Upgrading through Domoboard is only possible when running in debug mode (pass "-d" parameter to server.py). Manual upgrade is possible by performing a "git pull" command.</b></p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
||||||
|
{% if debug == True %}
|
||||||
|
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="javascript:performUpgrade()">Upgrade</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- page content -->
|
<!-- page content -->
|
||||||
<div class="right_col" role="main">
|
<div class="right_col" role="main">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<link href="static/css/settings.css" rel="stylesheet" type="text/css"/>
|
<link href="static/css/settings.css" rel="stylesheet" type="text/css"/>
|
||||||
<ul class="tab">
|
<ul class="tab">
|
||||||
|
<li><a href="javascript:void(0)" id="defaultOpen" class="tablinks"
|
||||||
|
onclick="openCat(event, 'updates')">Updates</a>
|
||||||
|
</li>
|
||||||
<li><a href="javascript:void(0)" id="defaultOpen" class="tablinks"
|
<li><a href="javascript:void(0)" id="defaultOpen" class="tablinks"
|
||||||
onclick="openCat(event, 'plugins')">Plugins</a>
|
onclick="openCat(event, 'plugins')">Plugins</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -7,7 +10,27 @@
|
||||||
onclick="openCat(event, 'settings')">Settings</a>
|
onclick="openCat(event, 'settings')">Settings</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div id="updates" class="tabcontent">
|
||||||
|
<div id="updateView_available" class="hide_update">
|
||||||
|
<h2>A new update is available for Domoboard.</h2><br />
|
||||||
|
The current version is <b><span id="curver_settings"></span></b><br />
|
||||||
|
The new version available is: <b><span id="newver_settings"></span></b><br />
|
||||||
|
<br />
|
||||||
|
{% if debug == True %}
|
||||||
|
<p><b>Install the new version by pressing the "Upgrade" button below.</b></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if debug == False %}
|
||||||
|
<p><b>Upgrading through Domoboard is only possible when running in debug mode (pass "-d" parameter to server.py). Manual upgrade is possible by performing a "git pull" command.</b></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if debug == True %}
|
||||||
|
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="javascript:performUpgrade()">Upgrade</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div id="updateView_not_available" class="hide_update">
|
||||||
|
<h2>Hurray!</h2><br />
|
||||||
|
There is no update available for Domoboard.<br /><br />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="plugins" class="tabcontent">
|
<div id="plugins" class="tabcontent">
|
||||||
<div id="pluginView">
|
<div id="pluginView">
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -147,8 +170,8 @@
|
||||||
document.getElementById("defaultOpen").click();
|
document.getElementById("defaultOpen").click();
|
||||||
setInterval(automaticIndex(), 9000);
|
setInterval(automaticIndex(), 9000);
|
||||||
$('.fullSummary').hide();
|
$('.fullSummary').hide();
|
||||||
|
checkVersionSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
retrieveAvailableDevices();
|
retrieveAvailableDevices();
|
||||||
selected_page_settings();
|
selected_page_settings();
|
||||||
selected_component_settings();
|
selected_component_settings();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue