From ca8ec686ac9438ad7f7de1981892ce0d796c7750 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Mon, 20 Feb 2017 13:54:34 +0100 Subject: [PATCH] Fixed problems with upload images and show images in created visual consoles. Gitlab: #314 --- .../reporting/visual_console_builder.data.php | 98 +++++++++++-------- .../reporting/visual_console_builder.php | 2 +- 2 files changed, 59 insertions(+), 41 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php index aaf1249ae9..3fc747d266 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.data.php +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -95,12 +95,26 @@ if (defined('METACONSOLE')) { $table->align[1] = 'left'; } $table->class = 'databox filters'; +$table->size[0] = '20%'; +$table->size[1] = '20%'; +$table->size[1] = '50%'; $table->data = array (); $table->data[0][0] = __('Name:') . ui_print_help_tip(__("Use [ or ( as first character, for example '[*] Map name', to render this map name in main menu"), true); $table->data[0][1] = html_print_input_text('name', $visualConsoleName, '', 80, 100, true); + +$table->rowspan[0][2] = 6; +if ($action == 'new') { + $table->data[0][2] = ''; +} +else { + $table->data[0][2] = ''; +} + $table->data[1][0] = __('Group:'); $groups = users_get_groups ($config['id_user'], 'RW'); @@ -150,16 +164,6 @@ $table->data[5][1] .= ''; -if ($action == 'new') { - $table->data[5][2] = ''; -} -else { - $table->data[5][2] = ''; -} - -$table->data[0][3] = $table->data[0][4] = $table->data[0][5] = ''; if ($action == 'new') { $textButtonSubmit = __('Save'); $classButtonSubmit = 'sub wand'; @@ -185,46 +189,60 @@ echo ""; $(document).ready (function () { -$("#modsize").click(function(event){ - event.preventDefault(); + $("#modsize").click(function(event){ + event.preventDefault(); if($('.opt').css('visibility') == 'hidden'){ $('.opt').css('visibility','visible'); } - + + if ($('#imagen').attr('src') != '') { + $('input[name=width]').val($('#imagen').width()); + $('input[name=height]').val($('#imagen').height()); + } + }); + + $("#getsize").click(function(event){ + event.preventDefault(); $('input[name=width]').val($('#imagen').width()); $('input[name=height]').val($('#imagen').height()); - -}); + }); -$("#getsize").click(function(event){ - event.preventDefault(); + $("#background").change(function() { + $('#imagen').attr('src','images/console/background/'+$('#background').val()); + $('#imagen').width(230); + $('#imagen').show(); + }); + + $( "input[type=submit]" ).click(function( event ) { + if($( "#getsize" ).css('visibility')=='hidden'){ + $('input[name=width]').val($('#imagen').width()); + $('input[name=height]').val($('#imagen').height()); + } + }); + + + $("#file-background_image").change(function(){ + readURL(this); + }); -$('input[name=width]').val($('#imagen').width()); -$('input[name=height]').val($('#imagen').height()); - -}); - -$("#background").click(function(event){ - $('#imagen').attr('src','images/console/background/'+$('#background').val()); -}); - -$( "input[type=submit]" ).click(function( event ) { - - if($( "#getsize" ).css('visibility')=='hidden'){ - $('input[name=width]').val($('#imagen').width()); - $('input[name=height]').val($('#imagen').height()); + function readURL(input) { + if (input.files && input.files[0]) { + var reader = new FileReader(); + reader.onload = function (e) { + $('#imagen').attr('src', e.target.result); + $('#imagen').width(230); + $('#imagen').show(); + } + reader.readAsDataURL(input.files[0]); + } } - - -}); - -$("#file-background_image").change(function(event){ - $('#back').submit(); -}); - -$("#text-background_color").attachColorPicker(); + $("#imgInp").change(function(){ + readURL(this); + }); + + $("#text-background_color").attachColorPicker(); }); diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 4176229931..11b074070c 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -174,7 +174,7 @@ switch ($activeTab) { if ($uploadOK == 1) { if (move_uploaded_file($_FILES["background_image"]["tmp_name"], $target_file)) { - $background = $_FILES["background_image"]["name"]; + $background = $nameImage; $values['background'] = $background; $error2 = chmod($target_file, 0644); $uploadOK = $error2;