Skip to content

Commit

Permalink
- added "Manual Update" option to maintenance page
Browse files Browse the repository at this point in the history
- updates can now be installed from .tgz release files
  • Loading branch information
genemars committed May 15, 2016
1 parent b923c0d commit bd351ae
Show file tree
Hide file tree
Showing 12 changed files with 349 additions and 106 deletions.
2 changes: 1 addition & 1 deletion BaseFiles/Common/html/js/api/homegenie.automation.macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ HG.Automation.Macro = HG.Automation.Macro || new function(){ var $$ = this;
callback(data);
},
error: function(xhr, status, error) {
console.log('$$.GetDelay ERROR: '+xhr.status+':'+xhr.statusText);
console.log('HG.Automation.Macro.GetDelay ERROR: '+xhr.status+':'+xhr.statusText);
callback();
}
});
Expand Down
2 changes: 1 addition & 1 deletion BaseFiles/Common/html/js/api/homegenie.statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ HG.Statistics = HG.Statistics || new function(){ var $$ = this;
callback(data);
},
error: function(xhr, status, error) {
console.log('$$.ServiceCall ERROR: '+xhr.status+':'+xhr.statusText);
console.log('HG.Statistics.ServiceCall ERROR: '+xhr.status+':'+xhr.statusText);
callback();
}
});
Expand Down
2 changes: 1 addition & 1 deletion BaseFiles/Common/html/js/homegenie.api.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions BaseFiles/Common/html/js/homegenie.webapp.min.js

Large diffs are not rendered by default.

44 changes: 34 additions & 10 deletions BaseFiles/Common/html/pages/configure/maintenance/_maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ HG.WebApp.Maintenance = HG.WebApp.Maintenance || new function () { var $$ = this
$$.LoadUpdateCheckSettings();
});
});
$('#configure_system_updatemanager_manualbutton').on('click', function () {
//$('#configure_system_updatemanager_info').html('<strong>Updating from file...</strong>');
if ($('#updatemanager_updatefile_uploadfile').val() == "") {
alert('Select a .tgz release file to install first');
$('#updatemanager_updatefile_uploadfile').parent().stop().animate({borderColor: "#FF5050"}, 250)
.animate({borderColor: "#FFFFFF"}, 250)
.animate({borderColor: "#FF5050"}, 250)
.animate({borderColor: "#FFFFFF"}, 250);
} else {
$.mobile.loading('show');
$('#configure_system_updatemanager_manualbutton').addClass('ui-disabled');
$.mobile.loading('show', {
text: 'Processing release file, please wait...',
textVisible: true,
theme: 'a',
html: ''
});
$('#configure_system_updateinstall_log').html();
$('#systemsettings_updateinstall_popup').popup('open');
$('#updatemanager_updatefile_form').submit();
}
});
$('#updatemanager_updatefile_uploadframe').bind('load', function (evt) {
if ($('#updatemanager_updatefile_uploadfile').val() == "")
return;
$('#configure_system_updatemanager_manualbutton').removeClass('ui-disabled');
$.mobile.loading('hide');
$('#systemsettings_updateinstall_popup').popup('close');
});
$('#configure_system_updateinstall_button').bind('click', function () {
$('#configure_system_updateinstall_button').addClass('ui-disabled');
$('#configure_system_updatemanager_info').html('<strong>Installing updates...</strong>');
Expand All @@ -118,11 +147,9 @@ HG.WebApp.Maintenance = HG.WebApp.Maintenance || new function () { var $$ = this
setTimeout(function () {
window.location.replace("/");
}, 3000);
}
else if (res.ResponseValue == 'RESTART') {
} else if (res.ResponseValue == 'RESTART') {
$('#configure_system_updateinstall_status').html('Installing files... (HomeGenie service stopped)');
}
else if (res.ResponseValue == 'ERROR') {
} else if (res.ResponseValue == 'ERROR') {
$('#configure_system_updateinstall_status').html('Error during installation progress.');
//
$.mobile.loading('hide');
Expand Down Expand Up @@ -152,12 +179,10 @@ HG.WebApp.Maintenance = HG.WebApp.Maintenance || new function () { var $$ = this
if (res.ResponseValue == 'OK') {
$('#configure_system_updateinstall_status').html('Update files ready.');
$('#configure_system_updateinstall_button').removeClass('ui-disabled');
}
else if (res.ResponseValue == 'RESTART') {
} else if (res.ResponseValue == 'RESTART') {
$('#configure_system_updateinstall_status').html('Update files ready. HomeGenie will be restarted after updating.');
$('#configure_system_updateinstall_button').removeClass('ui-disabled');
}
else if (res.ResponseValue == 'ERROR') {
} else if (res.ResponseValue == 'ERROR') {
$('#configure_system_updateinstall_status').html('Error while downloading update files.');
$('#configure_system_updateinstall_button').addClass('ui-disabled');
}
Expand Down Expand Up @@ -216,8 +241,7 @@ HG.WebApp.Maintenance = HG.WebApp.Maintenance || new function () { var $$ = this
.animate({borderColor: "#FFFFFF"}, 250)
.animate({borderColor: "#FF5050"}, 250)
.animate({borderColor: "#FFFFFF"}, 250);
}
else {
} else {
$('#systemsettings_backuprestores1cancelbutton').removeClass('ui-disabled');
$('#systemsettings_backuprestores1confirmbutton').removeClass('ui-disabled');
$.mobile.loading('show', {
Expand Down
7 changes: 7 additions & 0 deletions BaseFiles/Common/html/pages/configure/maintenance/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ <h3><span data-locale-id="configure_system_options">System Options</span></h3>
<p id="configure_system_updatemanager_details"></p>
</div>
</div>
<div>
<form id="updatemanager_updatefile_form" target="uploadframe" enctype="multipart/form-data" method="post" action="../../api/HomeAutomation.HomeGenie/Config/System.Configure/UpdateManager.ManualUpdate" data-ajax="false">
<input id="updatemanager_updatefile_uploadfile" type="file" title="Manual update from '.tgz' release file." name="file" />
</form>
<iframe id="updatemanager_updatefile_uploadframe" name="uploadframe" src="blank.html" style="display:none;width:0;height:0;border:0"></iframe>
</div>
</div>
<div class="ui-block-b" style="float:right;width:150px">
<a id="configure_system_updatemanager_updatebutton" data-locale-id="configure_system_updatemanager_updatecheck" class="ui-btn ui-corner-all">Update Check</a>
<a id="configure_system_updatemanager_manualbutton" data-locale-id="configure_system_updatemanager_manualupdate" href="#" class="ui-btn ui-corner-all">Manual Update</a>
<a id="configure_system_updatemanager_installbutton" data-locale-id="configure_system_updatemanager_installupdate" class="ui-btn ui-corner-all" href="#systemsettings_updatewarning_popup" data-rel="popup">Install Update</a>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions BaseFiles/Common/html/pages/events/_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
switch (eventLog.Domain) {

case 'HomeGenie.System':
if (eventLog.Value == 'STARTED') {
$$.field('#configure_system_updateinstall_status', true).html('Update install complete. HomeGenie started.');
if (eventLog.Value == 'STARTED' || eventLog.Value == 'UPDATED') {
$$.field('#configure_system_updateinstall_status', true).html('Update install complete. HomeGenie ready.');
setTimeout(function () {
document.location.href = '/';
}, 3000);
Expand Down
4 changes: 4 additions & 0 deletions HISTORY.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
RELEASE HISTORY

15/05/2016 v1.1-beta.521
- Added "Manual Update" option to maintenance page
- Updates can now be installed from .tgz release files

14/05/2016 v1.1-beta.520
- Optimized general web UI performances (should fix #272)
- Migrated some generic widgets to new API model: camerainput, colorlight, dimmer, doorwindow, generic, light, sensor, siren, switch, template
Expand Down
94 changes: 93 additions & 1 deletion HomeGenie/Service/Handlers/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,98 @@ public void ProcessRequest(MigClientRequest request)
homegenie.UpdateChecker.Check();
request.ResponseData = new ResponseText("OK");
}
else if (migCommand.GetOption(0) == "UpdateManager.ManualUpdate")
{
homegenie.RaiseEvent(
Domains.HomeGenie_System,
Domains.HomeGenie_UpdateChecker,
SourceModule.Master,
"HomeGenie Manual Update",
Properties.InstallProgressMessage,
"Receiving update file"
);
bool success = false;
// file uploaded by user
Utility.FolderCleanUp(tempFolderPath);
string archivename = Path.Combine(tempFolderPath, "homegenie_update_file.tgz");
try
{
MIG.Gateways.WebServiceUtility.SaveFile(request.RequestData, archivename);
var files = Utility.UncompressTgz(archivename, tempFolderPath);
File.Delete(archivename);
string relInfo = Path.Combine(tempFolderPath, "homegenie", "release_info.xml");
if (File.Exists(relInfo))
{
var updateRelease = UpdateChecker.GetReleaseFile(relInfo);
var currentRelease = homegenie.UpdateChecker.GetCurrentRelease();
if (updateRelease.ReleaseDate >= currentRelease.ReleaseDate)
{
string installPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_update", "files");
Utility.FolderCleanUp(installPath);
Directory.Move(Path.Combine(tempFolderPath, "homegenie"), Path.Combine(installPath, "HomeGenie"));
var installStatus = homegenie.UpdateChecker.InstallFiles();
if (installStatus != UpdateChecker.InstallStatus.Error)
{
success = true;
if (installStatus == UpdateChecker.InstallStatus.RestartRequired)
{
homegenie.RaiseEvent(
Domains.HomeGenie_System,
Domains.HomeGenie_UpdateChecker,
SourceModule.Master,
"HomeGenie Manual Update",
Properties.InstallProgressMessage,
"HomeGenie will now restart."
);
Program.Quit(true);
}
else
{
homegenie.RaiseEvent(Domains.HomeGenie_System, Domains.HomeGenie_System, SourceModule.Master, "HomeGenie System", Properties.HomeGenieStatus, "UPDATED");
Thread.Sleep(3000);
}
}
}
else
{
homegenie.RaiseEvent(
Domains.HomeGenie_System,
Domains.HomeGenie_UpdateChecker,
SourceModule.Master,
"HomeGenie Manual Update",
Properties.InstallProgressMessage,
"ERROR: Installed release is newer than update file"
);
Thread.Sleep(3000);
}
}
else
{
homegenie.RaiseEvent(
Domains.HomeGenie_System,
Domains.HomeGenie_UpdateChecker,
SourceModule.Master,
"HomeGenie Manual Update",
Properties.InstallProgressMessage,
"ERROR: Invalid update file"
);
Thread.Sleep(3000);
}
}
catch (Exception e)
{
homegenie.RaiseEvent(
Domains.HomeGenie_System,
Domains.HomeGenie_UpdateChecker,
SourceModule.Master,
"HomeGenie Update Checker",
Properties.InstallProgressMessage,
"ERROR: Exception occurred ("+e.Message+")"
);
Thread.Sleep(3000);
}
request.ResponseData = new ResponseStatus(success ? Status.Ok : Status.Error);
}
else if (migCommand.GetOption(0) == "UpdateManager.DownloadUpdate")
{
var resultMessage = "ERROR";
Expand All @@ -240,7 +332,7 @@ public void ProcessRequest(MigClientRequest request)
{
string resultMessage = "OK";
homegenie.SaveData();
if (!homegenie.UpdateChecker.InstallFiles())
if (homegenie.UpdateChecker.InstallFiles() == UpdateChecker.InstallStatus.Error)
{
resultMessage = "ERROR";
}
Expand Down
Loading

0 comments on commit bd351ae

Please sign in to comment.