mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 22:48:45 +02:00
N°2249 - Supportability - Updater module (application upgrade)
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
{# @copyright Copyright (C) 2010-2019 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
function UpdateProgress(sMessage, iPercent) {
|
||||
$('#setup_msg').html(sMessage);
|
||||
$('#progress').progression({
|
||||
Current: iPercent,
|
||||
Maximum: 100,
|
||||
aBackgroundImg: "{{ sProgressImage }}",
|
||||
aTextColor: '#000000'
|
||||
});
|
||||
}
|
||||
|
||||
var oGetCurrentVersion = {
|
||||
method: "POST",
|
||||
url: "{{ sAjaxURL|raw }}",
|
||||
data: {
|
||||
"operation": "GetCurrentVersion"
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data)
|
||||
{
|
||||
var oCurrentVersion = $("#current-version");
|
||||
if (oCurrentVersion)
|
||||
{
|
||||
oCurrentVersion.html(data.sVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetAjaxRequest(sOperation)
|
||||
{
|
||||
oAjaxRequest = {
|
||||
method: "POST",
|
||||
url: "{{ sAjaxURL|raw }}",
|
||||
data: {
|
||||
"operation": sOperation,
|
||||
"authent": "{{ sSetupToken }}"
|
||||
},
|
||||
dataType: "json"
|
||||
};
|
||||
|
||||
if (sOperation === "Backup")
|
||||
{
|
||||
oAjaxRequest.success = function() {
|
||||
$("#do_backup_done").show();
|
||||
};
|
||||
}
|
||||
|
||||
if (sOperation === "FilesArchive")
|
||||
{
|
||||
oAjaxRequest.success = function() {
|
||||
$("#do_files_archive_done").show();
|
||||
};
|
||||
}
|
||||
|
||||
return oAjaxRequest;
|
||||
}
|
||||
|
||||
{% set aSteps = ['EnterMaintenance', 'Backup', 'FilesArchive', 'CopyFiles', 'Compile', 'ExitMaintenance', 'UpdateDone'] %}
|
||||
|
||||
aStepsName = [];
|
||||
|
||||
{% for sStep in aSteps %}
|
||||
aStepsName.push({{ ('iTopUpdate:UI:SetupMessage:' ~ sStep)|dict_s|json_encode|raw }});
|
||||
{% endfor %}
|
||||
|
||||
var sBackupStep;
|
||||
{% if bDoBackup %}
|
||||
sBackupStep = "Backup";
|
||||
{% endif %}
|
||||
|
||||
var sFilesArchiveStep;
|
||||
{% if bDoFilesArchive %}
|
||||
sFilesArchiveStep = "FilesArchive";
|
||||
{% endif %}
|
||||
|
||||
var aStepsAjaxOperation = ["EnterMaintenance", sBackupStep, sFilesArchiveStep, "CopyFiles", "Compile", "ExitMaintenance", null];
|
||||
|
||||
var iNextStep = 0;
|
||||
function ExecNextStep() {
|
||||
if (iNextStep < aStepsAjaxOperation.length)
|
||||
{
|
||||
var sAjaxOperation = aStepsAjaxOperation[iNextStep];
|
||||
var iPercent = (iNextStep + 1) * 100 / aStepsAjaxOperation.length;
|
||||
UpdateProgress(aStepsName[iNextStep], iPercent);
|
||||
iNextStep++;
|
||||
if (sAjaxOperation) {
|
||||
$.ajax(GetAjaxRequest(sAjaxOperation))
|
||||
.done(function () {
|
||||
setTimeout(ExecNextStep, 500);
|
||||
})
|
||||
.fail(function ( jqXHR) {
|
||||
$("#setup_continue").removeAttr("disabled");
|
||||
if (jqXHR && jqXHR.responseJSON) {
|
||||
$("#setup_error").html({{ 'iTopUpdate:Error:UpdateFailed'|dict_s|json_encode|raw }}+" "+jqXHR.responseJSON.sError);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#setup_error").html({{ 'iTopUpdate:Error:UpdateFailed'|dict_s|json_encode|raw }});
|
||||
}
|
||||
$('.progress').css("background-image", "none").css("background-color", "#fcc");
|
||||
$("#setup_error_outer").show();
|
||||
})
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(ExecNextStep, 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$.ajax(oGetCurrentVersion);
|
||||
$("#setup_continue").removeAttr("disabled");
|
||||
$("#current_version").removeClass("message_info").addClass("message_ok");
|
||||
$('.progress').css("background-image", "none").css("background-color", "#cfc");
|
||||
}
|
||||
}
|
||||
|
||||
ExecNextStep();
|
||||
|
||||
Reference in New Issue
Block a user