[Kimchi-devel] [PATCH] [UI] Grid Enhancement - Show Message when Loading Data

Hongliang Wang hlwang at linux.vnet.ibm.com
Wed Mar 12 12:20:38 UTC 2014


Sometimes when we draw a grid, the data is not ready and it's a time-consuming
task for back-end, so the user will expect that the grid is drawn there, and a
"loading" message is on top of the grid while loading data.

  In this patch, we make this enhancement. Meanwhile, we introduce a "loading"
icon which is made based-on Kimchi logo.

Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
---
 ui/css/theme-default/grid.css              |  24 +++++++++++++++++++++++
 ui/images/theme-default/kimchi-loading.gif | Bin 0 -> 6181 bytes
 ui/js/src/kimchi.grid.js                   |  30 ++++++++++++++++++++++++++++-
 ui/pages/i18n.html.tmpl                    |   2 ++
 4 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 ui/images/theme-default/kimchi-loading.gif

diff --git a/ui/css/theme-default/grid.css b/ui/css/theme-default/grid.css
index 9f8f98e..761d32f 100644
--- a/ui/css/theme-default/grid.css
+++ b/ui/css/theme-default/grid.css
@@ -212,3 +212,27 @@
     width: 0;
     z-index: 4;
 }
+
+.grid-mask {
+    bottom: 0;
+    left: 0;
+    position: absolute;
+    right: 0;
+}
+
+.grid-loading {
+    bottom: 0;
+    height: 68px;
+    left: 0;
+    margin: auto;
+    right: 0;
+    text-align: center;
+    top: 0;
+    width: 49px;
+}
+
+.grid-loading-icon {
+    background: url("../images/theme-default/kimchi-loading.gif") no-repeat left top;
+    height: 48px;
+    width: 49px;
+}
diff --git a/ui/images/theme-default/kimchi-loading.gif b/ui/images/theme-default/kimchi-loading.gif
new file mode 100644
index 0000000000000000000000000000000000000000..af92bfdc0a44170c71fb7406d2c6bc359e176e91
GIT binary patch
literal 6181
zcmeI0c{r4N|A3z{gBeT4jC~z5gQ1aa$lffLu_jAVWErAt6_w;Y86)e+5+c-OtdVR<
z+N>elB$Y}<C`(;O>OF at RekRrHoVu>xd%b_1_j=EN^WSsL^S$r;`Fy at s)|Li_KH7j5
z at M;Ah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z{(Rv&dhc)7)PE=P=pE6fxFjmT)LWCDr|+U4`(5Q}G)4)y}oB1$6wy#_Cb9
z)tlME5O>|N6=+6LVgF;j$uJ}B%8)m52ek_0w at D_L*!}jV;?S}Xa{#|9e2(?7SUNH}
zS2y6nLdmB0iDTCy-%gfo_nQ?z7|WexkApAz*bpEB#kc8i;N at VM(k#lLzp5OhUH(=U
zX3&Bdf$JozM!Ug<9bypu21px-InqDt?Fk83p;j!3&^=}qKQ+dFA(;?ecSkiU8U!IJ
z7ogaxka2(kKf>bKU@&Dj{AG2ST3cN_zN{`n#gl?opXhgVpGDIK&7-Tx{rTJP at D!(b
zWs$6M!99*D>J6+JVS{Cl$=>{7x0w|DmS236RGQ#%oua86Ut7J$krVx<n2X>5orLN(
zfsHjRXSl=xj#Ga{)&MxmY_6)kLKA%x%W&AjujeaBD8I08hpABK!63cYuPG?*IIuOg
z`=r?4(EJEZ`F{+J2wiLRt*zn0C#x^3&OlttT@*u6GKaA>^k2(NZOP*I&l)mch)_iC
zO??(Kv2~xD++C<fqYFEA^RrQ;?3c65vKat-U>b>(lI)hwO#gLf7x?$t{U|)AL at gjF
zRDMa#cc8$%H^GDJ`N)-XTW{U`{BiN!-1EU(Yu7g3=0D&2umAbZ>n~Burke5gMC8WZ
VeND9!UFjIxpWWs~tzJ(W{~z1)DdhkF

literal 0
HcmV?d00001

diff --git a/ui/js/src/kimchi.grid.js b/ui/js/src/kimchi.grid.js
index 20cacc5..b6f6afb 100644
--- a/ui/js/src/kimchi.grid.js
+++ b/ui/js/src/kimchi.grid.js
@@ -54,6 +54,12 @@ kimchi.widget.Grid = function(params) {
           '<div class="grid-resizer hidden"></div>',
         '</div>',
         '<div class="grid-footer"></div>',
+        '<div class="grid-mask">',
+            '<div class="grid-loading">',
+                '<div class="grid-loading-icon"></div>',
+                '<div class="grid-loading-text"></div>',
+            '</div>',
+        '</div>',
       '</div>'
     ];
 
@@ -150,6 +156,9 @@ kimchi.widget.Grid = function(params) {
     var toolbarHeight = toolbarNode && $(toolbarNode).height() || 0;
     gridContentNode.css('top', (captionHeight + toolbarHeight) + 'px');
 
+    var maskNode = $('.grid-mask', gridNode);
+    maskNode.css('top', (captionHeight + toolbarHeight) + 'px');
+
     var fillBody = function(container, fields, data) {
         var tbody = ($('tbody', container).length && $('tbody', container))
             || $('<tbody></tbody>').appendTo(container);
@@ -263,7 +272,6 @@ kimchi.widget.Grid = function(params) {
         setBodyListeners();
     };
 
-    this.setData(params['data']);
     this.getSelected = function() {
         return selectedIndex >= 0
             ? this.data[selectedIndex]
@@ -374,4 +382,24 @@ kimchi.widget.Grid = function(params) {
         $('body').off('mousemove', positionResizer);
         $('body').off('mouseup', endResizing);
     };
+
+    var data = params['data'];
+    if(!data) {
+        return;
+    }
+
+    if($.isArray(data)) {
+        this.setData(data);
+        return;
+    }
+
+    if($.isFunction(data)) {
+        var self = this;
+        var loadData = data;
+        maskNode.removeClass('hidden');
+        loadData(function(data) {
+            self.setData(data);
+            maskNode.addClass('hidden');
+        });
+    }
 };
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index ba3a407..1a3a6d2 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -59,6 +59,8 @@ var i18n = {
     'KCHAPI6005M': "$_("Create")",
     'KCHAPI6006M': "$_("Warning")",
 
+    'KCHGRD6001M': "$_("Loading...")",
+
     'KCHTMPL6001W': "$_("No iso found")",
 
     'KCHTMPL6002E': "$_("This is not a valid ISO file.")",
-- 
1.8.1.4




More information about the Kimchi-devel mailing list