]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Add listbox control and use it for base and device directives
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 3 Dec 2017 12:15:27 +0000 (13:15 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 9 Dec 2017 14:07:34 +0000 (15:07 +0100)
16 files changed:
gui/baculum/protected/Web/Data/data_desc.json
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl
gui/baculum/protected/Web/Portlets/DirectiveFileSet.php
gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl
gui/baculum/protected/Web/Portlets/DirectiveListBox.php [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveListBox.tpl [new file with mode: 0644]
gui/baculum/themes/Baculum-v1/bacula-config.css

index 74a331789994e82718b3069d898fbcd214e1d498..11a092d5b33bbed479959867cb7d8af9ebe7587c 100644 (file)
                        },
                        "Base": {
                                "Required": false,
-                               "ValueType": "alist_res",
+                               "ValueType": "res",
                                "DefaultValue": 0,
-                               "FieldType": "ComboBox",
+                               "FieldType": "ListBox",
                                "Resource": "Job"
                        }
                },
                        },
                        "Base": {
                                "Required": false,
-                               "ValueType": "alist_res",
+                               "ValueType": "res",
                                "DefaultValue": 0,
-                               "FieldType": "ComboBox",
+                               "FieldType": "ListBox",
                                "Resource": "Job"
                        }
                }
                        },
                        "Device": {
                                "Required": true,
-                               "ValueType": "alist_res",
+                               "ValueType": "res",
                                "DefaultValue": 0,
-                               "FieldType": "ComboBox"
+                               "FieldType": "ListBox",
+                               "Resource": "Device"
                        },
                        "ChangerDevice": {
                                "Required": true,
index 946847662181ac818b996c17453b58a0f08a6b5b..f168c481b8d5cfc7988254b852f79e34cda55259 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index c0c29fd9e1971f28f248770b5aa5918a7ed995e6..449e4784fbeeba0bf4a8cd898b3de8d89c0b8a96 100644 (file)
@@ -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"
index 1f7b5968773bf6d9f0507d7e18288969fcd254ee..83ed0465d90da5c0fbd0f6e9a7ae66d6a612e3d6 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 6ed67fd1b9828cf24465c6174f263a739caaf5e6..839ff03d9ebb9845e376ac28208f820412b86be9 100644 (file)
@@ -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"
index e37cc42c5999332de62465c088c219cbdb496bcc..63a02472f79b5a98d37ff4fffa205ec92c638103 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index 8dcc96ca93464e298063e8e444df0e1ce87a39e3..4dbdc288dc3bb94af9d5d3ca1ae9d96a0ec952fb 100644 (file)
@@ -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"
index efb09de1e6095fd02efb56e327a3e6b09312ed36..3e6565422009c0a4096b96c3a9eddce0e5adcf61 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index d2fd0176949fa72b967e044fb524698d73582092..842c7253ba05a13fbda66b308ef4b3f059552d77 100644 (file)
@@ -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"
index 32654259aa8138566a0609894df6aad69ff04415..e317e5fd30e05104e2b0aadce7d54e1e07e5652e 100644 (file)
@@ -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)) {
index d1ae5bf034fcff2eb6eced5aa2d3c48140f867d8..081fd49293dc5e5ffd78f3f51aae8ca36c5a0a8b 100644 (file)
                                                <com:Application.Web.Portlets.DirectiveComboBox />
                                        </prop:TrueTemplate>
                                </com:Application.Web.Portlets.BConditional>
+                               <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'ListBox')%>">
+                                       <prop:TrueTemplate>
+                                               <com:Application.Web.Portlets.DirectiveListBox />
+                                       </prop:TrueTemplate>
+                               </com:Application.Web.Portlets.BConditional>
                                <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'FileSet')%>">
                                        <prop:TrueTemplate>
                                                <com:Application.Web.Portlets.DirectiveFileSet />
index e0244e2be6adbc01998d2ccbc3bf3bc9dc81a80d..da4ec3d60c557a7f17e809a9bf7ecd4f9d7771d6 100644 (file)
@@ -36,6 +36,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                'DirectiveBoolean',
                'DirectiveText',
                'DirectiveComboBox',
+               'DirectiveListBox',
                'DirectiveInteger'
        );
 
index 548fbb0c8c298869b650d5bf72d4601dffdd21eb..788579dead7e595ea2622418c06f49f636f48878 100644 (file)
                                <com:Application.Web.Portlets.DirectiveInteger />
                        </prop:TrueTemplate>
                </com:Application.Web.Portlets.BConditional>
+               <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'ListBox')%>">
+                       <prop:TrueTemplate>
+                               <com:Application.Web.Portlets.DirectiveListBox />
+                       </prop:TrueTemplate>
+               </com:Application.Web.Portlets.BConditional>
        </prop:ItemTemplate>
        <prop:FooterTemplate>
        </fieldset>
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveListBox.php b/gui/baculum/protected/Web/Portlets/DirectiveListBox.php
new file mode 100644 (file)
index 0000000..356e488
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2017 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
+Prado::using('System.Web.UI.ActiveControls.TActiveListBox');
+Prado::using('Application.Web.Portlets.DirectiveTemplate');
+
+class DirectiveListBox extends DirectiveTemplate {
+
+       public function getValue() {
+               $value = array();
+               $values = $this->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 (file)
index 0000000..f102956
--- /dev/null
@@ -0,0 +1,25 @@
+<div class="line<%=!$this->display_directive ? ' hide' : '';%>">
+       <div class="text"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
+       <div class="field directive_value">
+               <com:TActiveListBox ID="Directive"
+                       SelectionMode="Multiple"
+                       OnSelectedIndexChanged="saveValue"
+                       CssClass="ftype_listbox"
+                       Visible="<%=$this->display_directive%>"
+                       AutoPostBack="false"
+                       ActiveControl.EnableUpdate="false"
+               /> <%=$this->getRequired() ? '*' : ''%>
+               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/switch.png" class="reset_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '<%=$this->getDefaultValue() === 0 ? '' : $this->getDefaultValue()%>';" alt="<%[ Reset to default value ]%>" title="<%[ Reset to default value ]%>" />
+               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" class="remove_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '';" alt="<%[ Remove directive ]%>" title="<%[ Remove directive ]%>" />
+               <com:TRequiredFieldValidator
+                       ID="DirectiveValidator"
+                       ValidationGroup="Directive"
+                       Display="Dynamic"
+                       ControlToValidate="Directive"
+                       FocusOnError="true"
+                       Text="Field required."
+                       Enabled="<%=$this->getRequired() && $this->getShow()%>"
+               />
+               <p class="smalldesc"><%[ Use Ctrl + Mouse Click to change selection ]%></p>
+       </div>
+</div>
index daad1260822b2b411d5c2b36e175caa42894f32f..3a2e76ceb315462c034ffc1fdc377620735b98f4 100644 (file)
@@ -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;
+}