From 97fabd600e983da9f3e988dee2f4edf9a8d177dd Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 9 Nov 2014 17:31:45 +0100 Subject: [PATCH] baculum: Lists loading optiomalization and replace server side sorting to client side sorting --- .../JavaScript/configuration-window.js | 3 +- .../protected/JavaScript/slide-window.js | 74 +++++++++++++++++++ gui/baculum/protected/Pages/Home.page | 13 ++-- gui/baculum/protected/Portlets/BButton.php | 4 +- .../Portlets/ClientConfiguration.tpl | 2 +- gui/baculum/protected/Portlets/ClientList.php | 20 +++-- gui/baculum/protected/Portlets/ClientList.tpl | 50 ++++--------- .../protected/Portlets/JobConfiguration.tpl | 2 +- gui/baculum/protected/Portlets/JobList.php | 19 +++-- gui/baculum/protected/Portlets/JobList.tpl | 46 ++++-------- .../Portlets/JobRunConfiguration.tpl | 2 +- gui/baculum/protected/Portlets/JobRunList.php | 18 +++-- gui/baculum/protected/Portlets/JobRunList.tpl | 47 ++++-------- .../protected/Portlets/PoolConfiguration.tpl | 2 +- gui/baculum/protected/Portlets/PoolList.php | 19 +++-- gui/baculum/protected/Portlets/PoolList.tpl | 46 ++++-------- .../protected/Portlets/SlideWindow.tpl | 1 + .../protected/Portlets/StorageList.php | 19 +++-- .../protected/Portlets/StorageList.tpl | 46 ++++-------- .../Portlets/VolumeConfiguration.tpl | 2 +- gui/baculum/protected/Portlets/VolumeList.php | 20 +++-- gui/baculum/protected/Portlets/VolumeList.tpl | 36 +++------ 22 files changed, 245 insertions(+), 246 deletions(-) diff --git a/gui/baculum/protected/JavaScript/configuration-window.js b/gui/baculum/protected/JavaScript/configuration-window.js index d6cd0847f6..6bd47ae082 100644 --- a/gui/baculum/protected/JavaScript/configuration-window.js +++ b/gui/baculum/protected/JavaScript/configuration-window.js @@ -36,13 +36,12 @@ var ConfigurationWindowClass = new Class.create({ is_progress: function() { return $(this.progress_id).getStyle('display') == 'block'; }, - openConfigurationWindow: function(request, slideWindowObj) { + openConfigurationWindow: function(slideWindowObj) { if(this.is_progress() === false) { this.progress(true); if(slideWindowObj.isFullSize() === true) { slideWindowObj.resetSize(); } - request.dispatch(); } } }); diff --git a/gui/baculum/protected/JavaScript/slide-window.js b/gui/baculum/protected/JavaScript/slide-window.js index 869d7c5234..9a485546d9 100644 --- a/gui/baculum/protected/JavaScript/slide-window.js +++ b/gui/baculum/protected/JavaScript/slide-window.js @@ -7,6 +7,10 @@ var SlideWindowClass = Class.create({ fullSizeEl : null, search: null, toolbar: null, + configurationObj: null, + loadRequest : null, + repeaterEl: null, + gridEl: null, size: { widthNormal : '437px', @@ -154,6 +158,39 @@ var SlideWindowClass = Class.create({ }.bind(this)); }, + setConfigurationObj: function(obj) { + this.configurationObj = obj; + }, + + setWindowElementsEvent: function(repeaterEl, gridEl, requestObj) { + this.repeaterEl = repeaterEl; + this.gridEl = gridEl; + this.loadRequest = requestObj; + this.setLoadRequest(); + }, + + setLoadRequest: function() { + var dataList = []; + if($(this.gridEl)) { + dataList = $(this.gridEl).select('tr'); + this.makeSortable(); + } else if ($(this.repeaterEl + '_Container')) { + dataList = $(this.repeaterEl + '_Container').select('div.slide-window-element'); + } + + dataList.each(function(tr) { + $(tr).observe('click', function() { + var el = $(tr).down('input') + if(el) { + var val = el.getValue(); + this.loadRequest.ActiveControl.CallbackParameter = val; + this.loadRequest.dispatch(); + this.configurationObj.openConfigurationWindow(this); + } + }.bind(this, tr)); + }.bind(this)); + }, + isConfigurationOpen: function() { var is_open = false; $$(this.elements.configurationWindows, this.elements.configurationProgress).each(function(el) { @@ -165,6 +202,43 @@ var SlideWindowClass = Class.create({ return is_open; }, + sortTable: function (col, reverse) { + var table = document.getElementById(this.gridEl); + var tb = table.tBodies[0], tr = Array.prototype.slice.call(tb.rows, 0), i; + reverse = -((+reverse) || -1); + tr = tr.sort(function (a, b) { + var val; + var val_a = a.cells[col].textContent.trim(); + var val_b = b.cells[col].textContent.trim(); + if (!isNaN(parseFloat(val_a)) && isFinite(val_a) && !isNaN(parseFloat(val_b)) && isFinite(val_b)) { + val = val_a - val_b + } else { + val = val_a.localeCompare(val_b); + } + return reverse * (val); + }); + for(i = 0; i < tr.length; ++i) tb.appendChild(tr[i]); + }, + + makeSortable: function () { + var self = this; + var table = document.getElementById(this.gridEl); + table.tHead.style.cursor = 'pointer'; + var th = table.tHead, i; + th && (th = th.rows[0]) && (th = th.cells); + if (th) { + i = th.length; + } else { + return; + } + while (--i >= 0) (function (i) { + var dir = 1; + th[i].addEventListener('click', function () { + self.sortTable(i, (dir = 1 - dir)); + }); + }(i)); + }, + setSearch: function() { var search_pattern = new RegExp(this.search.value) $$('div[id="' + this.windowId + this.elements.containerSuffix + '"] div.' + this.elements.contentItems).each(function(value){ diff --git a/gui/baculum/protected/Pages/Home.page b/gui/baculum/protected/Pages/Home.page index 8e7ca3221b..ea96fb0a44 100644 --- a/gui/baculum/protected/Pages/Home.page +++ b/gui/baculum/protected/Pages/Home.page @@ -6,12 +6,13 @@
diff --git a/gui/baculum/protected/Portlets/BButton.php b/gui/baculum/protected/Portlets/BButton.php index 7631a99579..4f5e8ef664 100644 --- a/gui/baculum/protected/Portlets/BButton.php +++ b/gui/baculum/protected/Portlets/BButton.php @@ -45,9 +45,9 @@ class BButton extends Portlets{ $this->Visible = $param; } - public function getVisible() { + public function getVisible($checkParents = true) { return $this->Visible; } } -?> \ No newline at end of file +?> diff --git a/gui/baculum/protected/Portlets/ClientConfiguration.tpl b/gui/baculum/protected/Portlets/ClientConfiguration.tpl index f0aed64fa2..f98b8bf45b 100644 --- a/gui/baculum/protected/Portlets/ClientConfiguration.tpl +++ b/gui/baculum/protected/Portlets/ClientConfiguration.tpl @@ -36,7 +36,7 @@
- + - - - <%=@$this->DataItem['name']%> + + <%=@$this->DataItem->name%> + - - - clientConfigurationWindow.show(); - clientConfigurationWindow.progress(false); - - - @@ -31,7 +21,7 @@ - <%=$this->getParent()->Data['name']%> - - - clientConfigurationWindow.show(); - clientConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->Data['name']%>
+
@@ -72,4 +51,7 @@
+ + + diff --git a/gui/baculum/protected/Portlets/JobConfiguration.tpl b/gui/baculum/protected/Portlets/JobConfiguration.tpl index cd8fd6e5dd..f1bd05b433 100644 --- a/gui/baculum/protected/Portlets/JobConfiguration.tpl +++ b/gui/baculum/protected/Portlets/JobConfiguration.tpl @@ -47,7 +47,7 @@ - + - [<%=@$this->DataItem->jobid%>] <%=@$this->DataItem->name%> + - - - jobConfigurationWindow.show(); - jobConfigurationWindow.progress(false); - - - @@ -31,7 +21,7 @@ - <%=$this->getParent()->Data['name']%> - - - jobConfigurationWindow.show(); - jobConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->Data['name']%>
+
@@ -83,4 +62,7 @@ />
+ + + diff --git a/gui/baculum/protected/Portlets/JobRunConfiguration.tpl b/gui/baculum/protected/Portlets/JobRunConfiguration.tpl index f58cb06db6..76c1bc902c 100644 --- a/gui/baculum/protected/Portlets/JobRunConfiguration.tpl +++ b/gui/baculum/protected/Portlets/JobRunConfiguration.tpl @@ -47,7 +47,7 @@ - + - <%=($this->getPage()->JobRunWindow->oldDirector != $this->DataItem['director']) ? '
Director: ' . $this->DataItem['director'] . '
': ''%> <%=@$this->DataItem['name']%> + + - - - jobRunConfigurationWindow.show(); - jobRunConfigurationWindow.progress(false); - - - <%=!($this->getPage()->JobRunWindow->oldDirector = $this->DataItem['director'])%>
@@ -33,7 +24,7 @@ - <%=$this->getParent()->DataItem['name']%> - - - jobRunConfigurationWindow.show(); - jobRunConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->DataItem['name']%>
+
+ + + diff --git a/gui/baculum/protected/Portlets/PoolConfiguration.tpl b/gui/baculum/protected/Portlets/PoolConfiguration.tpl index 5777174ca8..fea8b97880 100644 --- a/gui/baculum/protected/Portlets/PoolConfiguration.tpl +++ b/gui/baculum/protected/Portlets/PoolConfiguration.tpl @@ -80,7 +80,7 @@
- + - <%=@$this->DataItem->name%> + - - - poolConfigurationWindow.show(); - poolConfigurationWindow.progress(false); - - - @@ -32,7 +22,7 @@ - <%=$this->getParent()->Data['name']%> - - - poolConfigurationWindow.show(); - poolConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->Data['name']%>
+
+ + + diff --git a/gui/baculum/protected/Portlets/SlideWindow.tpl b/gui/baculum/protected/Portlets/SlideWindow.tpl index 875ab8bb21..73d618eddb 100644 --- a/gui/baculum/protected/Portlets/SlideWindow.tpl +++ b/gui/baculum/protected/Portlets/SlideWindow.tpl @@ -28,6 +28,7 @@ $('<%=$this->UniqueID%>-slide-window-progress').setStyle({'display': 'none'}); + <%=$this->ShowID%>SlideWindow.setLoadRequest();
- <%=@$this->DataItem->name%> + - - - storageConfigurationWindow.show(); - storageConfigurationWindow.progress(false); - - - @@ -31,7 +21,7 @@ - <%=$this->getParent()->Data['name']%> - - - storageConfigurationWindow.show(); - storageConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->Data['name']%>
+
@@ -62,4 +41,7 @@
+ + + diff --git a/gui/baculum/protected/Portlets/VolumeConfiguration.tpl b/gui/baculum/protected/Portlets/VolumeConfiguration.tpl index 70934be0ff..14e18eef5f 100644 --- a/gui/baculum/protected/Portlets/VolumeConfiguration.tpl +++ b/gui/baculum/protected/Portlets/VolumeConfiguration.tpl @@ -76,7 +76,7 @@
- + + <%=(isset($this->DataItem->pool->name) && $this->getPage()->VolumeWindow->oldPool != $this->DataItem->pool->name) ? '
Pool: ' . $this->DataItem->pool->name . '
': ''%> <%=@$this->DataItem->volumename%>
<%=isset($this->DataItem->volstatus) ? $this->DataItem->volstatus : ''%>
+
- - - volumeConfigurationWindow.show(); - volumeConfigurationWindow.progress(false); - - - <%=!(isset($this->DataItem->pool->name) ? ($this->getPage()->VolumeWindow->oldPool = $this->DataItem->pool->name) : false)%>
@@ -34,7 +24,7 @@ - <%=$this->getParent()->Data['volumename']%> - - - volumeConfigurationWindow.show(); - volumeConfigurationWindow.progress(false); - - - +
<%=$this->getParent()->Data['volumename']%>
+
+ + + -- 2.39.5