Merge branch 'ent-5226-Update-Manager-Offline-mostrar-aviso' into 'develop'

Added warning in update manager offline

See merge request artica/pandorafms!2998
This commit is contained in:
Daniel Rodriguez 2020-01-22 11:10:02 +01:00
commit ec03f947fe
2 changed files with 57 additions and 4 deletions

View File

@ -46,6 +46,13 @@ if (! check_acl($config['id_user'], 0, 'PM')
$baseurl = ui_get_full_url(false, false, false, false);
$current_package = db_get_value(
'value',
'tconfig',
'token',
'current_package_enterprise'
);
?>
<!-- Add the stylesheet here cause somehow the 'ui_require_css_file'
@ -90,6 +97,8 @@ is not working on the metaconsole and there is no time to fix it -->
var text1_package_file = "<?php echo __('There is a new update available'); ?>\n";
var text2_package_file = "<?php echo __('There is a new update available to apply. Do you want to start the update process?'); ?>\n";
var text1_warning = "<?php echo __('WARNING'); ?>\n";
var text2_warning = "<?php echo __('This update does not correspond to the next version of Pandora'); ?>\n";
var applying_mr = "<?php echo __('Applying DB MR'); ?>\n";
var cancel_button = "<?php echo __('Cancel'); ?>\n";
var ok_button = "<?php echo __('Ok'); ?>\n";
@ -109,5 +118,5 @@ is not working on the metaconsole and there is no time to fix it -->
<script src="<?php echo $baseurl; ?>/include/javascript/update_manager.js"></script>
<script type="text/javascript">
form_upload("<?php echo $baseurl; ?>");
form_upload("<?php echo $baseurl; ?>", "<?php echo $current_package; ?>");
</script>

View File

@ -4,7 +4,7 @@
var correct_install_progress = true;
function form_upload(homeurl) {
function form_upload(homeurl, current_package) {
var home_url = typeof homeurl !== "undefined" ? homeurl + "/" : "";
//Thanks to: http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/
@ -164,7 +164,7 @@ function form_upload(homeurl) {
.change();
// Begin the installation
install_package(res.package, homeurl);
install_package(res.package, homeurl, current_package);
});
} else {
// Something has gone wrong!
@ -214,7 +214,7 @@ function formatFileSize(bytes) {
return (bytes / 1000).toFixed(2) + " KB";
}
function install_package(package, homeurl) {
function install_package(package, homeurl, current_package) {
var home_url = typeof homeurl !== "undefined" ? homeurl + "/" : "";
$(
@ -1235,6 +1235,50 @@ function install_package(package, homeurl) {
$("#pkg_apply_dialog").html(dialog_text);
$("#pkg_apply_dialog").dialog("open");
const number_update = package.match(/package_(\d+).oum/);
if (number_update === null || number_update[1] != current_package - 0 + 1) {
$(
"<div id='warning_pkg' class='dialog ui-dialog-content' title='" +
package_available +
"'></div>"
).dialog({
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
width: 600,
height: 250,
buttons: [
{
text: ok_button,
click: function() {
$(this).dialog("close");
}
}
]
});
var dialog_warning = "<div class='update_popup'>";
dialog_warning =
dialog_warning +
"<div class='update_text'><h3>" +
text1_warning +
"</h3>";
dialog_warning = dialog_warning + "<p>" + text2_warning + "</p></div>";
dialog_warning =
dialog_warning +
"<div class='update_icon'><img src='" +
home_url +
"images/icono_warning_mr.png'></div>";
dialog_warning = dialog_warning + "</div>";
$("#warning_pkg").html(dialog_warning);
}
}
function check_install_package(package, homeurl) {