]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add prune and purge actions to volume view page
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 21 Apr 2018 04:50:36 +0000 (06:50 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 21 Apr 2018 04:50:36 +0000 (06:50 +0200)
gui/baculum/protected/Web/Pages/VolumeView.page
gui/baculum/protected/Web/Pages/VolumeView.php

index 069e227ed06b04de01219d918f9d4117c501279c..34eff61796faeaba994231efe20469fa0799997d 100644 (file)
                <button id="btn_volume_config" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'volume_config');"><%[ Configure volume ]%></button>
        </div>
        <div class="w3-container tab_item" id="volume_actions">
+               <div class="w3-margin-left w3-margin-bottom">
+                       <com:TActiveLinkButton
+                               CssClass="w3-button w3-green"
+                               OnClick="prune"
+                               Attributes.onclick="document.getElementById('volume_action_log').style.display='block'"
+                       >
+                               <i class="fa fa-shower"></i> &nbsp;<%[ Prune ]%>
+                       </com:TActiveLinkButton>
+                       <com:TActiveLinkButton
+                               CssClass="w3-button w3-green"
+                               OnClick="purge"
+                               Attributes.onclick="document.getElementById('volume_action_log').style.display='block'"
+                       >
+                               <i class="fa fa-recycle"></i> &nbsp;<%[ Purge ]%>
+                       </com:TActiveLinkButton>
+               </div>
+               <div id="volume_action_log" class="w3-panel w3-card w3-light-grey" style="display: none;">
+                       <div class="w3-code notranslate">
+                               <pre><com:TActiveLabel ID="VolumeActionLog" /></pre>
+                       </div>
+               </div>
                <div class="w3-row">
                        <div class="w3-card w3-quarter w3-padding w3-margin-right" style="min-height: 200px">
                                <h4><%[ Limits ]%></h4>
                                <com:TActiveCheckBox ID="InChanger" AutoPostBack="false" CssClass="w3-check" />
                        </div>
                </div>
-               <div id="volume_log" class="w3-panel w3-card w3-light-grey" style="display: none">
+               <div id="volume_config_log" class="w3-panel w3-card w3-light-grey" style="display: none">
                        <div class="w3-code notranslate">
-                               <pre><com:TActiveLabel ID="VolumeLog" /></pre>
+                               <pre><com:TActiveLabel ID="VolumeConfigLog" /></pre>
                        </div>
                </div>
                <div class="w3-container w3-center">
                                OnClick="updateVolume"
                                ClientSide.OnLoading="$('#status_volume_loading').show();"
                                ClientSide.OnSuccess="$('#status_volume_loading').hide();"
-                               Attributes.onclick="document.getElementById('volume_log').style.display = '';"
+                               Attributes.onclick="document.getElementById('volume_config_log').style.display = '';"
                        >
                                <prop:Text>
                                        <i class="fa fa-save"></i> &nbsp;<%=Prado::localize('Save')%>
index 3872c2f4f0e78b7ef83ecda60edb843afae7da79..4d105e97ca81edd725382eba322e167e77fe8913 100644 (file)
@@ -188,9 +188,40 @@ class VolumeView extends BaculumWebPage {
                $volume['recycle'] = (integer)$this->Recycle->Checked;
                $volume['enabled'] = (integer)$this->Enabled->Checked;
                $volume['inchanger'] = (integer)$this->InChanger->Checked;
-               $result = $this->getModule('api')->set(array('volumes', $volume['mediaid']), $volume);
-               $this->VolumeLog->Text = implode(PHP_EOL, $result->output);
+               $result = $this->getModule('api')->set(
+                       array('volumes', $volume['mediaid']),
+                       $volume
+               );
+               if ($result->error === 0) {
+                       $this->VolumeConfigLog->Text = implode(PHP_EOL, $result->output);
+               } else {
+                       $this->VolumeConfigLog->Text = $result->output;
+               }
                $this->setVolume();
        }
+
+       public function prune($sender, $param) {
+               $result = $this->getModule('api')->set(
+                       array('volumes', $this->getMediaId(), 'prune'),
+                       array()
+               );
+               if ($result->error === 0) {
+                       $this->VolumeActionLog->Text = implode(PHP_EOL, $result->output);
+               } else {
+                       $this->VolumeActionLog->Text = $result->output;
+               }
+       }
+
+       public function purge($sender, $param) {
+               $result = $this->getModule('api')->set(
+                       array('volumes', $this->getMediaId(), 'purge'),
+                       array()
+               );
+               if ($result->error === 0) {
+                       $this->VolumeActionLog->Text = implode(PHP_EOL, $result->output);
+               } else {
+                       $this->VolumeActionLog->Text = $result->output;
+               }
+       }
 }
 ?>