]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add component action (start/stop/restart) buttons to client and storage...
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 20 Apr 2021 04:52:00 +0000 (06:52 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Tue, 20 Apr 2021 04:52:00 +0000 (06:52 +0200)
gui/baculum/protected/Web/Pages/ClientView.page
gui/baculum/protected/Web/Pages/ClientView.php
gui/baculum/protected/Web/Pages/StorageView.page
gui/baculum/protected/Web/Pages/StorageView.php
gui/baculum/protected/Web/Portlets/ComponentActionsMenu.php
gui/baculum/protected/Web/Portlets/ComponentActionsMenu.tpl

index 4a1d24ea5cc322aa55520fe68e46ff5215192d5c..d6b79bf7751c5dfad1e38bc22f95adee54812ba9 100644 (file)
                >
                        <prop:Text><%=Prado::localize('Status client')%> &nbsp;<i class="fa fa-file-medical-alt"></i></prop:Text>
                </com:TActiveLinkButton>
+               <com:Application.Web.Portlets.ComponentActionsMenu
+                       ID="CompActions"
+                       BigButtons="true"
+               />
                <i id="status_client_loading" class="fa fa-sync w3-spin" style="display: none; vertical-align: super; margin-left: 6px;"></i> <span id="status_client_error" class="w3-text-red" style="display: none"></span>
                <div id="show_client_container">
                        <div class="w3-row" style="display: flex; flex-wrap: wrap;">
index bd627383e4cf5a09724bc08edd3d76200271a48c..087b8100e7f8e48a5776a63325d2a0e635950047 100644 (file)
@@ -103,6 +103,13 @@ class ClientView extends BaculumWebPage {
                        }
                }
                $this->setAPIHosts();
+
+               // Set component actions
+               $fd_api_host = $this->getFDAPIHost();
+               if ($fd_api_host) {
+                       $this->CompActions->setHost($fd_api_host);
+                       $this->CompActions->setComponentType('fd');
+               }
        }
 
        public function setDIRClientConfig($sender, $param) {
@@ -138,6 +145,15 @@ class ClientView extends BaculumWebPage {
                }
        }
 
+       private function getFDAPIHost() {
+               if (!$this->User->isUserAPIHost($this->UserAPIHosts->SelectedValue)) {
+                       // Validation error. Somebody manually modified select values
+                       return false;
+               }
+               return $this->UserAPIHosts->SelectedValue;
+       }
+
+
        private function getFDName() {
                $fdname = null;
                if (!$this->User->isUserAPIHost($this->UserAPIHosts->SelectedValue)) {
index f37824910919fca40eff8a02c2e74869a8a060ea..7589d00c0887163cad3a714765acbcb9164b93f3 100644 (file)
@@ -55,7 +55,7 @@
                        ClientSide.OnFailure="$('#status_storage_loading').hide();status_storage_show_error(parameter);"
                        Attributes.onclick="hide_first_tab_containers(event);"
                >
-                       <prop:Text><%=Prado::localize('Status storage')%> &nbsp;<i class="fa fa-file-medical-alt"></i></prop:Text>
+                       <prop:Text><i class="fa fa-file-medical-alt"></i> &nbsp;<%=Prado::localize('Status storage')%></prop:Text>
                </com:TActiveLinkButton>
                <com:TActiveLinkButton
                        ID="Mount"
@@ -65,7 +65,7 @@
                        CausesValidation="true"
                        ClientSide.OnLoading="oStorageActions.show_loader(true);"
                >
-                       <prop:Text><%=Prado::localize('Mount')%> &nbsp;<i class="fa fa-caret-down"></i></prop:Text>
+                       <prop:Text><i class="fa fa-caret-down"></i> &nbsp;<%=Prado::localize('Mount')%></prop:Text>
                </com:TActiveLinkButton>
                <com:TActiveLinkButton
                        ID="Release"
@@ -75,7 +75,7 @@
                        CausesValidation="true"
                        ClientSide.OnLoading="oStorageActions.show_loader(true);"
                >
-                       <prop:Text><%=Prado::localize('Release')%> &nbsp;<i class="fa fa-caret-right"></i></prop:Text>
+                       <prop:Text><i class="fa fa-caret-right"></i> &nbsp;<%=Prado::localize('Release')%></prop:Text>
                </com:TActiveLinkButton>
                <com:TActiveLinkButton
                        ID="Umount"
                        CausesValidation="true"
                        ClientSide.OnLoading="oStorageActions.show_loader(true);"
                >
-                       <prop:Text><%=Prado::localize('Umount')%> &nbsp;<i class="fa fa-caret-up"></i></prop:Text>
+                       <prop:Text><i class="fa fa-caret-up"></i> &nbsp;<%=Prado::localize('Umount')%></prop:Text>
                </com:TActiveLinkButton>
+               <com:Application.Web.Portlets.ComponentActionsMenu
+                       ID="CompActions"
+                       BigButtons="true"
+               />
                <com:TCallback ID="MountLoading" OnCallback="mountLoading" />
                <com:TCallback ID="ReleaseLoading" OnCallback="releaseLoading" />
                <com:TCallback ID="UmountLoading" OnCallback="umountLoading" />
index df39ab4d1a054b49b26c4673a36ef89e6a22a942..05eb71e74ac7b9a29730f112479bf1c5b90dde2b 100644 (file)
@@ -99,6 +99,13 @@ class StorageView extends BaculumWebPage {
                        }
                }
                $this->setAPIHosts();
+
+               // Set component actions
+               $sd_api_host = $this->getSDAPIHost();
+               if ($sd_api_host) {
+                       $this->CompActions->setHost($sd_api_host);
+                       $this->CompActions->setComponentType('sd');
+               }
        }
 
        private function setAPIHosts() {
index 68baf413d9a2981083798a921f08f4d0d4fb34d1..72b557d4d832d85ed4f424d36206c9a08e593179 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2021 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -33,6 +33,8 @@ Prado::using('Application.Web.Portlets.DirectiveListTemplate');
  */
 class ComponentActionsMenu extends DirectiveListTemplate {
 
+       const BIG_BUTTONS = 'BigButtons';
+
        /**
         * Allowed actions to do with components.
         */
@@ -61,4 +63,13 @@ class ComponentActionsMenu extends DirectiveListTemplate {
                        );
                }
        }
+
+       public function setBigButtons($big_buttons) {
+               $big_buttons = TPropertyValue::ensureBoolean($big_buttons);
+               $this->setViewState(self::BIG_BUTTONS, $big_buttons);
+       }
+
+       public function getBigButtons() {
+               return $this->getViewState(self::BIG_BUTTONS, false);
+       }
 }
index e5d8c5f8a98524d754ab0692b9331973a728420a..de5d302558bf48cf09a09e813155ec662babf6bb 100644 (file)
@@ -1,4 +1,6 @@
-<a href="javascript:void(0);" onmousedown="openElementOnCursor(event, '<%=$this->ClientID%>_component_actions', -80, 20);"><i class="fas fa-ellipsis-v fa-lg"></i></a>
+<a href="javascript:void(0);" onmousedown="openElementOnCursor(event, '<%=$this->ClientID%>_component_actions', -80, 20);" style="display: <%=$this->BigButtons ? 'none' : 'inline'%>">
+       <i class="fas fa-ellipsis-v fa-lg"></i>
+</a>
 <div id="<%=$this->ClientID%>_component_actions" class="w3-card w3-white w3-padding left" style="display: none">
        <i class="fa fa-times w3-right" onclick="$('#<%=$this->ClientID%>_component_actions').hide();" style="cursor: pointer"></i>
        <ul class="w3-ul new_element_menu">
                </li>
        </ul>
 </div>
+<span id="<%=$this->ClientID%>_big_buttons_component_actions" style="display: <%=$this->BigButtons ? 'inline' : 'none'%>">
+       <com:TActiveLinkButton
+               OnCommand="componentAction"
+               CommandParameter="start"
+               CssClass="w3-button w3-green w3-margin-bottom"
+               ClientSide.OnLoading="$('#<%=$this->ClientID%>_loader_component_actions').show();"
+               ClientSide.OnComplete="$('#<%=$this->ClientID%>_loader_component_actions').hide();"
+               >
+               <i class='fas fa-play'></i> &nbsp;<%[ Start ]%>
+       </com:TActiveLinkButton>
+       <com:TActiveLinkButton
+               OnCommand="componentAction"
+               CommandParameter="stop"
+               CssClass="w3-button w3-green w3-margin-bottom"
+               ClientSide.OnLoading="$('#<%=$this->ClientID%>_loader_component_actions').show();"
+               ClientSide.OnComplete="$('#<%=$this->ClientID%>_loader_component_actions').hide();"
+               >
+               <i class='fas fa-stop'></i> &nbsp;<%[ Stop ]%>
+       </com:TActiveLinkButton>
+       <com:TActiveLinkButton
+               OnCommand="componentAction"
+               CommandParameter="restart"
+               CssClass="w3-button w3-green w3-margin-bottom"
+               ClientSide.OnLoading="$('#<%=$this->ClientID%>_loader_component_actions').show();"
+               ClientSide.OnComplete="$('#<%=$this->ClientID%>_loader_component_actions').hide();"
+               >
+               <i class='fas fa-sync'></i> &nbsp;<%[ Restart ]%>
+       </com:TActiveLinkButton>
+       <i id="<%=$this->ClientID%>_loader_component_actions" class="fa fa-sync fa-spin" style="vertical-align: super;display: none;"></i>
+</span>
 <div id="<%=$this->ClientID%>_component_action_message_box" class="w3-modal" style="display: none">
        <div class="w3-modal-content w3-card-4 w3-animate-zoom" style="width:600px">
                <header class="w3-container w3-red marked">