From d22348cde245c27f8e77f59fd72a09a548a63cd5 Mon Sep 17 00:00:00 2001 From: mrcrankhank Date: Tue, 10 Nov 2015 12:29:09 +0100 Subject: [PATCH] Improve configure target settings menu --- README.md | 1 - app/controllers/targets.php | 19 ++------ app/views/targets/settings_table.php | 70 +++++++++++++--------------- public/js/pages/target/settings.js | 22 ++++++--- 4 files changed, 51 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index f61693d..bb2012c 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ In version 0.7: - [ ] Display input validation with bootstrap css Validation states (http://formvalidation.io/validators/integer/) - [ ] Bootstrap-table Table Select Checkbox - [ ] Awesome checkboxes (https://github.com/designmodo/Flat-UI) - - [ ] Improve configure target settings menu - [ ] Improve nested table row handling - [ ] Add target and lvm name to url - [ ] Overview/Logical volumes VG selector diff --git a/app/controllers/targets.php b/app/controllers/targets.php index 49a98d6..d78b9ba 100755 --- a/app/controllers/targets.php +++ b/app/controllers/targets.php @@ -198,23 +198,12 @@ public function configure($param1 = false, $param2 = false) { } } else if ($param1 == 'settings') { if (isset($_POST['option'], $_POST['newvalue'], $_POST['iqn'])) { - $iqn = filter_input(INPUT_POST, 'iqn', FILTER_SANITIZE_STRING); - $option = filter_input(INPUT_POST, 'option', FILTER_SANITIZE_STRING); - $newvalue = filter_input(INPUT_POST, 'newvalue', FILTER_SANITIZE_STRING); - - $target = $this->model('target\Target', $iqn); - $target->add_setting($option, $newvalue); + $target = $this->model('target\Target', filter_input(INPUT_POST, 'iqn', FILTER_SANITIZE_STRING)); + $target->add_setting($option = filter_input(INPUT_POST, 'option', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'newvalue', FILTER_SANITIZE_STRING)); echo json_encode($target->logging->get_action_result()); } else if (isset($_POST['iqn'])) { - $iqn = filter_input(INPUT_POST, 'iqn', FILTER_SANITIZE_STRING); - - $target = $this->model('target\Target', $iqn); - $data = $target->get_all_settings(); - // cut array in two pieces - $len = count($data); - $view_data[0] = array_slice($data, 0, $len / 2); - $view_data[1] = array_slice($data, $len / 2); - $this->view('targets/settings_table', $view_data); + $target = $this->model('target\Target', filter_input(INPUT_POST, 'iqn', FILTER_SANITIZE_STRING)); + $this->view('targets/settings_table', $target->get_all_settings()); } } else if ($param1 == 'addrule') { if (isset($_POST['iqn'], $_POST['type'], $_POST['id'])) { diff --git a/app/views/targets/settings_table.php b/app/views/targets/settings_table.php index ff064d6..4451cd7 100755 --- a/app/views/targets/settings_table.php +++ b/app/views/targets/settings_table.php @@ -6,44 +6,38 @@
  • Configure
  • Settings
  • -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    SaveOptionValue
    type="number" value=""> - -
    -
    -
    - +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    SaveOptionValue
    value=""> + +
    diff --git a/public/js/pages/target/settings.js b/public/js/pages/target/settings.js index f6fe470..72c27a2 100755 --- a/public/js/pages/target/settings.js +++ b/public/js/pages/target/settings.js @@ -1,9 +1,18 @@ -define(['jquery', 'mylibs', 'sweetalert', 'qtip', 'once'], function ($, mylibs, swal, qtip, once) { +define(['jquery', 'mylibs', 'sweetalert', 'once', 'touchspin'], function ($, mylibs, swal, once, touchspin) { var methods; return methods = { add_event_handler_settings_table_checkbox: function () { - $('.value').once('input', function () { + var value = $('.value'); + + value.TouchSpin({ + verticalbuttons: true, + verticalupclass: 'glyphicon glyphicon-plus', + verticaldownclass: 'glyphicon glyphicon-minus', + max: 10000000 + }); + + value.once('input', function () { var $this = $(this); var $this_row = $this.closest('tr'); var oldvalue = $this_row.find('.default_value_before_change').val(); @@ -19,12 +28,11 @@ define(['jquery', 'mylibs', 'sweetalert', 'qtip', 'once'], function ($, mylibs, }, add_event_handler_save_value: function () { $('.savevalueinput').once('click', function () { - var this_row = $(this).closest('tr'); - - var newvalue; - var type; + var this_row = $(this).closest('tr'), + newvalue, + type, + oldvalue = this_row.find('.default_value_before_change').val(); - var oldvalue = this_row.find('.default_value_before_change').val(); newvalue = this_row.find('.value').val(); // If value is not defined