From: Marcin Haba Date: Sun, 3 Dec 2017 12:15:27 +0000 (+0100) Subject: baculum: Add listbox control and use it for base and device directives X-Git-Tag: Release-9.0.7~12 X-Git-Url: https://git.sur5r.net/?p=bacula%2Fbacula;a=commitdiff_plain;h=be35638c45068a10cde922c75e606910e0bd05ce baculum: Add listbox control and use it for base and device directives --- diff --git a/gui/baculum/protected/Web/Data/data_desc.json b/gui/baculum/protected/Web/Data/data_desc.json index 74a3317899..11a092d5b3 100644 --- a/gui/baculum/protected/Web/Data/data_desc.json +++ b/gui/baculum/protected/Web/Data/data_desc.json @@ -843,9 +843,9 @@ }, "Base": { "Required": false, - "ValueType": "alist_res", + "ValueType": "res", "DefaultValue": 0, - "FieldType": "ComboBox", + "FieldType": "ListBox", "Resource": "Job" } }, @@ -2275,9 +2275,9 @@ }, "Base": { "Required": false, - "ValueType": "alist_res", + "ValueType": "res", "DefaultValue": 0, - "FieldType": "ComboBox", + "FieldType": "ListBox", "Resource": "Job" } } @@ -2932,9 +2932,10 @@ }, "Device": { "Required": true, - "ValueType": "alist_res", + "ValueType": "res", "DefaultValue": 0, - "FieldType": "ComboBox" + "FieldType": "ListBox", + "Resource": "Device" }, "ChangerDevice": { "Required": true, diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 9468476621..f168c481b8 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index c0c29fd9e1..449e4784fb 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -1501,3 +1501,6 @@ msgstr "Volume" msgid "During restore there will be used following volumes:" msgstr "During restore there will be used following volumes:" + +msgid "Use Ctrl + Mouse Click to change selection" +msgstr "Use Ctrl + Mouse Click to change selection" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 1f7b596877..83ed0465d9 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index 6ed67fd1b9..839ff03d9e 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -1252,3 +1252,6 @@ msgstr "Volume" msgid "During restore there will be used following volumes:" msgstr "During restore there will be used following volumes:" + +msgid "Use Ctrl + Mouse Click to change selection" +msgstr "Use Ctrl + Mouse Click to change selection" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index e37cc42c59..63a02472f7 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index 8dcc96ca93..4dbdc288dc 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -1508,3 +1508,6 @@ msgstr "Wolumen" msgid "During restore there will be used following volumes:" msgstr "Podczas zadania przywracania danych potrzebne będą następujące wolumeny:" + +msgid "Use Ctrl + Mouse Click to change selection" +msgstr "Aby zmienić wybór, użyj Ctrl + klik myszy" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index efb09de1e6..3e65654220 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index d2fd017694..842c7253ba 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -1516,3 +1516,6 @@ msgstr "Volume" msgid "During restore there will be used following volumes:" msgstr "During restore there will be used following volumes:" + +msgid "Use Ctrl + Mouse Click to change selection" +msgstr "Use Ctrl + Mouse Click to change selection" diff --git a/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php b/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php index 32654259aa..e317e5fd30 100644 --- a/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php +++ b/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php @@ -27,6 +27,7 @@ Prado::using('Application.Web.Portlets.DirectiveListTemplate'); Prado::using('Application.Web.Portlets.DirectiveBoolean'); Prado::using('Application.Web.Portlets.DirectiveComboBox'); Prado::using('Application.Web.Portlets.DirectiveInteger'); +Prado::using('Application.Web.Portlets.DirectiveListBox'); Prado::using('Application.Web.Portlets.DirectiveText'); Prado::using('Application.Web.Portlets.DirectiveTimePeriod'); Prado::using('Application.Web.Portlets.DirectiveRunscript'); @@ -45,6 +46,7 @@ class BaculaConfigDirectives extends DirectiveListTemplate { 'DirectiveBoolean', 'DirectiveComboBox', 'DirectiveInteger', + 'DirectiveListBox', 'DirectiveText', 'DirectiveTimePeriod' ); @@ -56,6 +58,10 @@ class BaculaConfigDirectives extends DirectiveListTemplate { 'DirectiveRunscript' ); + private $field_multple_values = array( + 'ListBox' + ); + private function getConfigData($host, array $parameters) { $default_params = array('config'); $params = array_merge($default_params, $parameters); @@ -133,7 +139,7 @@ class BaculaConfigDirectives extends DirectiveListTemplate { } } - if (!is_array($directive_value) && !is_object($directive_value)) { + if ((!is_array($directive_value) && !is_object($directive_value)) || in_array($field_type, $this->field_multple_values)) { $directive_value = array($directive_value); } if (is_object($directive_value)) { diff --git a/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl b/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl index d1ae5bf034..081fd49293 100644 --- a/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl +++ b/gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl @@ -30,6 +30,11 @@ + + + + + diff --git a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php index e0244e2be6..da4ec3d60c 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php +++ b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php @@ -36,6 +36,7 @@ class DirectiveFileSet extends DirectiveListTemplate { 'DirectiveBoolean', 'DirectiveText', 'DirectiveComboBox', + 'DirectiveListBox', 'DirectiveInteger' ); diff --git a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl index 548fbb0c8c..788579dead 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl +++ b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl @@ -29,6 +29,11 @@ + + + + + diff --git a/gui/baculum/protected/Web/Portlets/DirectiveListBox.php b/gui/baculum/protected/Web/Portlets/DirectiveListBox.php new file mode 100644 index 0000000000..356e488623 --- /dev/null +++ b/gui/baculum/protected/Web/Portlets/DirectiveListBox.php @@ -0,0 +1,81 @@ +Directive->getSelectedIndices(); + $items = $this->Directive->getItems(); + for ($i = 0; $i < count($values); $i++) { + $value[] = $items[$values[$i]]->getValue(); + } + return $value; + } + + public function createDirective() { + $this->Label->Text = $this->getLabel(); + $data = $this->getData(); + $resource_names = $this->getResourceNames(); + $directive_name = $this->getDirectiveName(); + $resource = $this->getResource(); + $in_config = $this->getInConfig(); + $items = array(); + if (is_array($data)) { + $items = $data; + } elseif (is_array($resource_names)) { + if (array_key_exists($directive_name, $resource_names)) { + $items = $resource_names[$directive_name]; + } elseif (array_key_exists($resource, $resource_names)) { + $items = $resource_names[$resource]; + } + } + $this->Directive->dataSource = array_combine($items, $items); + + $directive_value = $this->getDirectiveValue(); + $default_value = $this->getDefaultValue(); + if ($in_config === false) { + if ($default_value !== 0) { + $directive_value = $default_value; + } else { + $directive_value = array(); + } + } + $selected_indices = array(); + for ($i = 0; $i < count($items); $i++) { + if (in_array($items[$i], $directive_value)) { + $selected_indices[] = $i; + } + } + if (!empty($directive_value)) { + $this->Directive->setSelectedIndices($selected_indices); + } + $this->Directive->dataBind(); + $validate = $this->getRequired(); + $this->DirectiveValidator->setVisible($validate); + } +} +?> diff --git a/gui/baculum/protected/Web/Portlets/DirectiveListBox.tpl b/gui/baculum/protected/Web/Portlets/DirectiveListBox.tpl new file mode 100644 index 0000000000..f1029566ed --- /dev/null +++ b/gui/baculum/protected/Web/Portlets/DirectiveListBox.tpl @@ -0,0 +1,25 @@ +
+
:
+
+ <%=$this->getRequired() ? '*' : ''%> + <%[ Reset to default value ]%> + <%[ Remove directive ]%> + +

<%[ Use Ctrl + Mouse Click to change selection ]%>

+
+
diff --git a/gui/baculum/themes/Baculum-v1/bacula-config.css b/gui/baculum/themes/Baculum-v1/bacula-config.css index daad126082..3a2e76ceb3 100644 --- a/gui/baculum/themes/Baculum-v1/bacula-config.css +++ b/gui/baculum/themes/Baculum-v1/bacula-config.css @@ -93,7 +93,7 @@ div.directive_setting fieldset { margin-left: 64px; } -input.ftype_textbox, input.ftype_timeperiod, input.ftype_integer, select.ftype_combobox { +input.ftype_textbox, input.ftype_timeperiod, input.ftype_integer, select.ftype_combobox, select.ftype_listbox { font-size: 12px; } @@ -105,15 +105,22 @@ input.ftype_timeperiod { width: 161px; } +select.ftype_combobox, select.ftype_listbox { + min-width: 265px; +} + select.ftype_combobox { height: 29px; - min-width: 265px; } input.ftype_integer { width: 161px; } +select.ftype_listbox { + height: 100px; +} + table.host td:nth-of-type(1) { width: 205px; } @@ -146,6 +153,7 @@ div.config_new_resource, div.config_new_fileset, div.config_new_messages, div.co img.reset_btn, img.remove_btn { display: none; cursor: pointer; + vertical-align: middle; } div.directive_value { @@ -164,3 +172,8 @@ div.directive_value:hover img.reset_btn, div.directive_value:hover img.remove_bt #new_host { padding: 26px; } + +p.smalldesc { + margin: 0; + font-style: italic; +}