]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Stop using hidden fields to store item identifiers
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 21 Nov 2017 20:28:20 +0000 (21:28 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 9 Dec 2017 10:59:49 +0000 (11:59 +0100)
gui/baculum/protected/API/endpoints.xml
gui/baculum/protected/Web/JavaScript/slide-window.js
gui/baculum/protected/Web/Portlets/ClientList.tpl
gui/baculum/protected/Web/Portlets/JobList.tpl
gui/baculum/protected/Web/Portlets/JobRunList.tpl
gui/baculum/protected/Web/Portlets/PoolList.tpl
gui/baculum/protected/Web/Portlets/StorageList.tpl
gui/baculum/protected/Web/Portlets/VolumeList.php
gui/baculum/protected/Web/Portlets/VolumeList.tpl

index cc5c656d450bea3b83b1addeb89447746afa8796..6a9146e75fc1a862d7b30b95bbfec50c99fbe498 100644 (file)
@@ -37,8 +37,6 @@
        <!-- volumes (media) endpoints-->
        <url ServiceParameter="API.Volumes" pattern="api/volumes/" />
        <url ServiceParameter="API.Volumes" pattern="api/volumes/limit/{limit}/" parameters.limit="\d+" />
-       <url ServiceParameter="API.Volumes" pattern="api/volumes/withpools/" />
-       <url ServiceParameter="API.Volumes" pattern="api/volumes/withpools/limit/{limit}/" parameters.limit="\d+" />
        <url ServiceParameter="API.Volume" pattern="api/volumes/{id}/" parameters.id="\d+" />
        <url ServiceParameter="API.VolumePrune" pattern="api/volumes/prune/{id}/" parameters.id="\d+" />
        <url ServiceParameter="API.VolumePurge" pattern="api/volumes/purge/{id}/" parameters.id="\d+" />
index ce24cf7fd0934261d38465ffe095cd4d764c041e..442fcf505063dfae3503a8bce8bd49aa59ca33f8 100644 (file)
@@ -146,9 +146,9 @@ var SlideWindowClass = jQuery.klass({
                        if (actions_btn.length === 1) {
                                actions_btn[0].addEventListener('mouseup', function(e) {
                                        var row = self.getGridRowUnderCursor(e);
-                                       var el = $(row).find('input[type=hidden]');
+                                       var el = $(row).find('div[data-type="item_value"]');
                                        if(el.length === 1) {
-                                               self.actionsRequest.setCallbackParameter(el[0].value);
+                                               self.actionsRequest.setCallbackParameter(el[0].getAttribute('rel'));
                                                self.actionsRequest.dispatch();
                                        }
                                });
@@ -276,9 +276,16 @@ var SlideWindowClass = jQuery.klass({
                }
 
                var set_callback_parameter = function(element) {
-                       var el = $(element).find('input[type=hidden]')
-                       if(el.length === 1) {
-                               var val = el[0].value;
+                       var val;
+                       if ($('#' + this.gridEl).length === 1) {
+                               var el = $(element).find('div[data-type="item_value"]')
+                               if (el.length === 1) {
+                                       val = el[0].getAttribute('rel');
+                               }
+                       } else if ($('#' + this.repeaterEl).length === 1) {
+                               val = element.getAttribute('rel');
+                       }
+                       if (val) {
                                this.openConfigurationById(val);
                        }
                }.bind(this);
@@ -295,7 +302,9 @@ var SlideWindowClass = jQuery.klass({
                        });
                }.bind(this));
                Formatters.set_formatters();
-               this.revertSortingFromCookie();
+               if (grid.length === 1) {
+                       this.revertSortingFromCookie();
+               }
        },
 
        openConfigurationById: function(id) {
@@ -447,7 +456,7 @@ var SlideWindowClass = jQuery.klass({
        },
        setActions: function() {
                var checkboxes = this.getCheckboxes();
-               checkboxes.each(function(index, el) {
+               $(checkboxes).each(function(index, el) {
                        $(el).on('change', function() {
                                var is_checked = this.isAnyChecked(checkboxes);
                                if(is_checked === true && !this.areActionsOpen()) {
index 9c05a1db5892da80e66213301e468fb9fa86e1fe..eaf1d8ac8f3280eadc86ce5a9ee94b9aab47ea32 100644 (file)
@@ -3,10 +3,9 @@
        <com:TActivePanel ID="RepeaterShow">
                <com:TActiveRepeater ID="Repeater">
                        <prop:ItemTemplate>
-                               <com:TPanel ID="ClientElement" CssClass="slide-window-element" ToolTip="<%=@$this->DataItem->uname%>">
-                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/client-icon.png" alt="" /><%=@$this->DataItem->name%>
-                                       <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem->clientid) ? $this->DataItem->clientid : ''%>" />
-                               </com:TPanel>
+                               <div data-type="item_value" rel="<%#$this->DataItem->clientid%>" class="slide-window-element" title="<%=@$this->DataItem->uname%>">
+                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/client-icon.png" alt="" /><%#$this->DataItem->name%>
+                               </div>
                        </prop:ItemTemplate>
                </com:TActiveRepeater>
        </com:TActivePanel>
@@ -23,8 +22,7 @@
                >
                        <com:TActiveTemplateColumn HeaderText="<%[ Client name ]%>" SortExpression="name">
                                <prop:ItemTemplate>
-                                       <div><%=$this->getParent()->Data['name']%></div>
-                                       <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['clientid']%>" />
+                                       <div data-type="item_value" rel="<%=$this->getParent()->Data['clientid']%>"><%=$this->getParent()->Data['name']%></div>
                                </prop:ItemTemplate>
                        </com:TActiveTemplateColumn>
                        <com:TActiveTemplateColumn ItemStyle.HorizontalAlign="Center" HeaderText="AutoPrune" SortExpression="autoprune">
index 51c816a6b7503e8eabc282a68446104ab8fb9b7f..3108d1984851cea04f6301f8bc933dbfeee4b501 100644 (file)
@@ -3,10 +3,9 @@
        <com:TActivePanel ID="RepeaterShow" EnableViewState="false">
        <com:TActiveRepeater ID="Repeater" EnableViewState="false">
                <prop:ItemTemplate>
-                       <com:TPanel ID="JobElement" CssClass="slide-window-element">
-                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/job-icon.png" alt="" /> [<%=@$this->DataItem->jobid%>] <%=@$this->DataItem->name%>
-                               <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem->jobid) ? $this->DataItem->jobid : ''%>" />
-                       </com:TPanel>
+                       <div data-type="item_value" rel="<%#$this->DataItem->jobid%>" class="slide-window-element">
+                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/job-icon.png" alt="" /> [<%#$this->DataItem->jobid%>] <%#$this->DataItem->name%>
+                       </div>
                </prop:ItemTemplate>
        </com:TActiveRepeater>
        </com:TActivePanel>
@@ -35,8 +34,7 @@
                />
                <com:TActiveTemplateColumn HeaderText="<%[ Job name ]%>" SortExpression="name">
                        <prop:ItemTemplate>
-                               <div title="<%=$this->getParent()->Data['name']%>"><%=$this->getPage()->JobWindow->formatJobName($this->getParent()->Data['name'])%></div>
-                                <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['jobid']%>" />
+                               <div data-type="item_value" rel="<%=$this->getParent()->Data['jobid']%>" title="<%=$this->getParent()->Data['name']%>"><%=$this->getPage()->JobWindow->formatJobName($this->getParent()->Data['name'])%></div>
                        </prop:ItemTemplate>
                </com:TActiveTemplateColumn>
                <com:TActiveTemplateColumn ItemTemplate="<%=isset($this->getPage()->JobWindow->jobTypes[$this->getParent()->Data['type']]) ? $this->getPage()->JobWindow->jobTypes[$this->getParent()->Data['type']] : ''%>" SortExpression="type">
index 823f578f849c54860016e83b02bb2ea143e994f7..2e158762f851d172bc48d9c8c425b01ecf3dbb63 100644 (file)
@@ -4,11 +4,9 @@
        <com:TActiveRepeater ID="Repeater">
                <prop:ItemTemplate>
                        <%=($this->getPage()->JobRunWindow->oldDirector != $this->DataItem['director']) ? '<div class="window-section"><span>' . Prado::localize('Director:') . ' ' . $this->DataItem['director']  . '<span></div>': ''%>
-                       <com:TPanel ID="JobRunElement" CssClass="slide-window-element" >
-                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/job-icon.png" alt="" /> <%=@$this->DataItem['name']%>
-                               <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem['name']) ? $this->DataItem['name'] : ''%>" />
-
-                       </com:TPanel>
+                       <div data-type="item_value" rel="<%#$this->DataItem['name']%>" class="slide-window-element">
+                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/job-icon.png" alt="" /> <%#$this->DataItem['name']%>
+                       </div>
                        <%=!($this->getPage()->JobRunWindow->oldDirector = $this->DataItem['director'])%>
                </prop:ItemTemplate>
        </com:TActiveRepeater>
@@ -26,8 +24,7 @@
        >
                <com:TActiveTemplateColumn HeaderText="<%[ Job name ]%>" SortExpression="name">
                        <prop:ItemTemplate>
-                               <div><%=$this->getParent()->DataItem['name']%></div>
-                                <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->DataItem['name']%>" />
+                               <div data-type="item_value" rel="<%=$this->getParent()->DataItem['name']%>"><%=$this->getParent()->DataItem['name']%></div>
                        </prop:ItemTemplate>
                </com:TActiveTemplateColumn>
                <com:TActiveBoundColumn
index ae06ee37c14cff8f4868817ed9f1b189575104f6..4ee65e2f6141be4664827079df768ed8dc9db56a 100644 (file)
@@ -3,10 +3,9 @@
        <com:TActivePanel ID="RepeaterShow">
                <com:TActiveRepeater ID="Repeater">
                        <prop:ItemTemplate>
-                               <com:TPanel ID="PoolElement" CssClass="slide-window-element">
-                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/pool.png" alt="" /><%=@$this->DataItem->name%>
-                                       <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem->poolid) ? $this->DataItem->poolid : ''%>" />
-                               </com:TPanel>
+                               <div data-type="item_value" rel="<%#$this->DataItem->poolid%>" class="slide-window-element">
+                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/pool.png" alt="" /><%#$this->DataItem->name%>
+                               </div>
                        </prop:ItemTemplate>
                </com:TActiveRepeater>
        </com:TActivePanel>
@@ -24,8 +23,7 @@
                >
                        <com:TActiveTemplateColumn HeaderText="Pool name" SortExpression="name">
                                <prop:ItemTemplate>
-                                       <div><%=$this->getParent()->Data['name']%></div>
-                                       <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['poolid']%>" />
+                                       <div data-type="item_value" rel="<%=$this->getParent()->Data['poolid']%>"><%=$this->getParent()->Data['name']%></div>
                                </prop:ItemTemplate>
                        </com:TActiveTemplateColumn>
                        <com:TActiveBoundColumn
index df410afb2b69d99ad681ded761417cef4492c2b7..ffbb6a99bfe8f364a722efd2379e03fa1783a4ca 100644 (file)
@@ -3,10 +3,9 @@
        <com:TActivePanel ID="RepeaterShow">
                <com:TActiveRepeater ID="Repeater">
                        <prop:ItemTemplate>
-                               <com:TPanel ID="StorageElement" CssClass="slide-window-element">
-                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/server-storage-icon.png" alt="" /><%=@$this->DataItem->name%>
-                                       <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem->storageid) ? $this->DataItem->storageid : ''%>" />
-                               </com:TPanel>
+                               <div data-type="item_value" rel="<%#$this->DataItem->storageid%>" class="slide-window-element">
+                                       <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/server-storage-icon.png" alt="" /><%#$this->DataItem->name%>
+                               </div>
                        </prop:ItemTemplate>
                </com:TActiveRepeater>
        </com:TActivePanel>
@@ -23,8 +22,7 @@
                >
                        <com:TActiveTemplateColumn HeaderText="<%[ Storage name ]%>" SortExpression="name">
                                <prop:ItemTemplate>
-                                       <div><%=$this->getParent()->Data['name']%></div>
-                                       <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['storageid']%>" />
+                                       <div data-type="item_value" rel="<%=$this->getParent()->Data['storageid']%>"><%=$this->getParent()->Data['name']%></div>
                                </prop:ItemTemplate>
                        </com:TActiveTemplateColumn>
                        <com:TActiveTemplateColumn HeaderText="<%[ Autochanger ]%>" SortExpression="autochanger" ItemStyle.HorizontalAlign="Center">
index b723837d3b85e6db19746ca37d08173ae18dd6ae..cd9ecf27f0c0d4c9da822baa3820547f9730248a 100644 (file)
@@ -34,8 +34,6 @@ class VolumeList extends Portlets implements ISlideWindow {
        public $ID;
        public $buttonID;
        public $windowTitle;
-       public $pools;
-       public $oldPool;
        public $view;
 
        public function setID($id) {
@@ -63,7 +61,7 @@ class VolumeList extends Portlets implements ISlideWindow {
        }
 
        public function prepareData($sender, $param) {
-               $params = $this->getUrlParams(array('volumes', 'withpools'), $this->getPage()->VolumeWindow->ID);
+               $params = $this->getUrlParams(array('volumes'), $this->getPage()->VolumeWindow->ID);
                $volumes = $this->Application->getModule('api')->get($params);
                $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details';
                if($isDetailView === true) {
@@ -101,7 +99,7 @@ class VolumeList extends Portlets implements ISlideWindow {
        }
 
        public function sortDataGrid($sender, $param) {
-               $params = $this->getUrlParams(array('volumes', 'withpools'), $this->getPage()->VolumeWindow->ID);
+               $params = $this->getUrlParams(array('volumes'), $this->getPage()->VolumeWindow->ID);
                $data = $this->Application->getModule('api')->get($params)->output;
                $data = $this->Application->getModule('misc')->objectToArray($data);
                $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
index 6fa0345c398d0abb704e00b7ae5bab642ab85443..7e138d28bb4ebd852ebe5425eb3d4e5d72dddec3 100644 (file)
@@ -3,13 +3,10 @@
        <com:TActivePanel ID="RepeaterShow">
        <com:TActiveRepeater ID="Repeater">
                <prop:ItemTemplate>
-                       <%=(isset($this->DataItem->pool->name) && $this->getPage()->VolumeWindow->oldPool != $this->DataItem->pool->name) ? '<div class="window-section"><span>' . Prado::localize('Pool:') . ' ' . $this->DataItem->pool->name  . '<span></div>': ''%>
-                       <com:TPanel ID="VolumeElement" CssClass="slide-window-element" ToolTip="<%=(isset($this->DataItem->recycle) && $this->DataItem->recycle == 1 && !empty($this->DataItem->lastwritten) && in_array($this->DataItem->volstatus, array('Full', 'Used'))) ? Prado::localize('When expire:') . date( 'Y-m-d H:i:s', (strtotime($this->DataItem->lastwritten) + $this->DataItem->volretention)) : ''%> <%=Prado::localize('Last written:')%> <%=!empty($this->DataItem->lastwritten) ? $this->DataItem->lastwritten : Prado::localize('never written')%>">
-                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/media-icon.png" alt="" /><%=@$this->DataItem->volumename%>
-                               <div id="<%=isset($this->DataItem->volumename) ? $this->DataItem->volumename : ''%>_sizebar" class="status-bar-<%=isset($this->DataItem->volstatus) ? strtolower($this->DataItem->volstatus) : ''%>"><%=isset($this->DataItem->volstatus) ? $this->DataItem->volstatus : ''%></div>
-                               <input type="hidden" name="<%=$this->ClientID%>" value="<%=isset($this->DataItem->mediaid) ? $this->DataItem->mediaid : ''%>" />
-                       </com:TPanel>
-                       <%=!(isset($this->DataItem->pool->name) ? ($this->getPage()->VolumeWindow->oldPool = $this->DataItem->pool->name) : false)%>
+                       <div data-type="item_value" rel="<%#$this->DataItem->mediaid%>" class="slide-window-element" title="<%#($this->DataItem->recycle == 1 && !empty($this->DataItem->lastwritten) && in_array($this->DataItem->volstatus, array('Full', 'Used'))) ? Prado::localize('When expire:') . date( ' Y-m-d H:i:s', (strtotime($this->DataItem->lastwritten) + $this->DataItem->volretention)) : ''%> <%=Prado::localize('Last written:')%> <%=!empty($this->DataItem->lastwritten) ? $this->DataItem->lastwritten : Prado::localize('never written')%>">
+                               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/media-icon.png" alt="" /><%#$this->DataItem->volumename%>
+                               <div id="<%#$this->DataItem->volumename%>_sizebar" class="status-bar-<%#strtolower($this->DataItem->volstatus)%>"><%#$this->DataItem->volstatus%></div>
+                       </div>
                </prop:ItemTemplate>
        </com:TActiveRepeater>
        </com:TActivePanel>
@@ -31,8 +28,7 @@
                 </com:TTemplateColumn>
                <com:TActiveTemplateColumn HeaderText="<%[ Volume name ]%>" SortExpression="volumename">
                        <prop:ItemTemplate>
-                               <div title="<%=$this->getParent()->Data['volumename']%>"><%=$this->getPage()->VolumeWindow->formatVolumeField($this->getParent()->Data['volumename'])%></div>
-                               <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['mediaid']%>" />
+                               <div data-type="item_value" rel="<%=$this->getParent()->Data['mediaid']%>" title="<%=$this->getParent()->Data['volumename']%>"><%=$this->getPage()->VolumeWindow->formatVolumeField($this->getParent()->Data['volumename'])%></div>
                        </prop:ItemTemplate>
                </com:TActiveTemplateColumn>
                <com:TActiveBoundColumn