]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add password field control and use it for password directives
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 21 May 2019 05:10:41 +0000 (07:10 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:50:02 +0000 (15:50 +0100)
gui/baculum/protected/Web/Data/data_desc.json
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php
gui/baculum/protected/Web/Portlets/DirectivePassword.php [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectivePassword.tpl [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveRenderer.php

index 192cb27f7570cb26dc1316224b298c6c1bf3038a..dac68c4d2094d9f58db0dfc39d5c1ef4f10fbdcb 100644 (file)
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "FdConnectTimeout": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Password": {
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "FdStorageAddress": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Password": {
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Device": {
                                "Required": true,
                                "Required": false,
                                "ValueType": "str",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Password": {
                                "Required": false,
                                "ValueType": "str",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "dbuser": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "JobAcl": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Monitor": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Address": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "Address": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "TlsAuthenticate": {
                                "Required": false,
                                "Required": true,
                                "ValueType": "password",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Password"
                        },
                        "TlsAuthenticate": {
                                "Required": false,
index be72e3c7bac00762b0c3de98985863c3fefbca61..233bd46e4e429ba0bc7f94ac76f5965c7d5f02b5 100644 (file)
@@ -29,6 +29,7 @@ Prado::using('Application.Web.Portlets.DirectiveCheckBox');
 Prado::using('Application.Web.Portlets.DirectiveComboBox');
 Prado::using('Application.Web.Portlets.DirectiveInteger');
 Prado::using('Application.Web.Portlets.DirectiveListBox');
+Prado::using('Application.Web.Portlets.DirectivePassword');
 Prado::using('Application.Web.Portlets.DirectiveSize');
 Prado::using('Application.Web.Portlets.DirectiveTextBox');
 Prado::using('Application.Web.Portlets.DirectiveMultiTextBox');
@@ -52,6 +53,7 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
                'DirectiveComboBox',
                'DirectiveInteger',
                'DirectiveListBox',
+               'DirectivePassword',
                'DirectiveTextBox',
                'DirectiveSize',
                'DirectiveTimePeriod'
diff --git a/gui/baculum/protected/Web/Portlets/DirectivePassword.php b/gui/baculum/protected/Web/Portlets/DirectivePassword.php
new file mode 100644 (file)
index 0000000..1e3cf88
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 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.TActiveTextBox');
+Prado::using('Application.Web.Portlets.DirectiveTemplate');
+
+class DirectivePassword extends DirectiveTemplate {
+
+       public function getValue() {
+               $value = $this->Directive->getText();
+               if (empty($value)) {
+                       $value = null;
+               }
+               return $value;
+       }
+
+       public function createDirective() {
+               $this->Label->Text = $this->getLabel();
+               $directive_value = $this->getDirectiveValue();
+               $default_value = $this->getDefaultValue();
+               if ($this->getInConfig() === false && empty($directive_value)) {
+                       if ($default_value !== 0) {
+                               $directive_value = $default_value;
+                       } else {
+                               $directive_value = '';
+                       }
+               }
+               $this->Directive->setText($directive_value);
+               $validate = $this->getRequired();
+               $this->DirectiveValidator->setVisible($validate);
+       }
+}
+?>
diff --git a/gui/baculum/protected/Web/Portlets/DirectivePassword.tpl b/gui/baculum/protected/Web/Portlets/DirectivePassword.tpl
new file mode 100644 (file)
index 0000000..259b4e3
--- /dev/null
@@ -0,0 +1,26 @@
+<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+       <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
+       <div class="w3-col w3-threequarter directive_value">
+               <com:TActiveTextBox ID="Directive"
+                       TextMode="Password"
+                       PersistPassword="true"
+                       OnTextChanged="saveValue"
+                       CssClass="w3-input w3-border w3-twothird"
+                       Visible="<%=$this->display_directive%>"
+                       ActiveControl.EnableUpdate="false"
+                       AutoTrim="true"
+               />
+                <%=$this->getRequired() ? '&nbsp;<i class="fa fa-asterisk w3-text-red" style="line-height: 40px"></i>' : ''%>
+               <a href="javascript:void(0)" onclick="var el = document.getElementById('<%=$this->Directive->ClientID%>'); el.type = el.type == 'text' ? 'password' : 'text'"><i class="fa fa-eye"></i></a>
+               <i class="fa fa-undo reset_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '<%=$this->getDefaultValue() === 0 ? '' : $this->getDefaultValue()%>';" alt="<%[ Reset to default value ]%>" title="<%[ Reset to default value ]%>"></i>
+               <i class="fa fa-trash-alt remove_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '';" alt="<%[ Remove directive ]%>" title="<%[ Remove directive ]%>"></i>
+               <com:TRequiredFieldValidator
+                       ID="DirectiveValidator"
+                       ValidationGroup="<%=$this->getValidationGroup()%>"
+                       Display="Dynamic"
+                       ControlToValidate="Directive"
+                       FocusOnError="true"
+                       Enabled="<%=$this->getRequired() && $this->getShow()%>"
+               ><%[ Field required. ]%></com:TRequiredFieldValidator>
+       </div>
+</div>
index b0f5f31ca8e21f3ad4136a85d9f48e525a25c56e..c9090a9f9c3af11b071ae3b6de5cbe8a9a676708 100644 (file)
@@ -29,6 +29,7 @@ Prado::using('Application.Web.Portlets.DirectiveCheckBox');
 Prado::using('Application.Web.Portlets.DirectiveComboBox');
 Prado::using('Application.Web.Portlets.DirectiveInteger');
 Prado::using('Application.Web.Portlets.DirectiveListBox');
+Prado::using('Application.Web.Portlets.DirectivePassword');
 Prado::using('Application.Web.Portlets.DirectiveSize');
 Prado::using('Application.Web.Portlets.DirectiveTextBox');
 Prado::using('Application.Web.Portlets.DirectiveMultiTextBox');
@@ -46,6 +47,7 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
                'DirectiveComboBox',
                'DirectiveInteger',
                'DirectiveListBox',
+               'DirectivePassword',
                'DirectiveTextBox',
                'DirectiveSize',
                'DirectiveTimePeriod'