[PATCH] stats: fix display when no data ready yet

Andrew Shadura andrew at shadura.me
Sat Mar 21 11:08:41 EDT 2015


# HG changeset patch
# User Andrew Shadura <andrew at shadura.me>
# Date 1426950496 -3600
#      Sat Mar 21 16:08:16 2015 +0100
# Node ID 91b44cf9fbb38b11cbb8779a7d0f2d603e68f6d0
# Parent  2c740f252808c6e8742fe1bb293fca816a889381
stats: fix display when no data ready yet

 * jQ uses .append(), not .appendChild()
 * when no data ready, display a nice message
 * rephrase the message, the data isn't ready, not hasn't loaded yet

diff --git a/kallithea/controllers/summary.py b/kallithea/controllers/summary.py
--- a/kallithea/controllers/summary.py
+++ b/kallithea/controllers/summary.py
@@ -172,7 +172,7 @@ class SummaryController(BaseRepoControll
             )
         else:
             c.no_data = True
-            c.trending_languages = json.dumps({})
+            c.trending_languages = json.dumps([])
 
         c.enable_downloads = c.db_repo.enable_downloads
         c.readme_data, c.readme_file = \
@@ -196,7 +196,7 @@ class SummaryController(BaseRepoControll
     def statistics(self, repo_name):
         if c.db_repo.enable_statistics:
             c.show_stats = True
-            c.no_data_msg = _('No data loaded yet')
+            c.no_data_msg = _('No data ready yet')
         else:
             c.show_stats = False
             c.no_data_msg = _('Statistics are disabled for this repository')
diff --git a/kallithea/templates/summary/summary.html b/kallithea/templates/summary/summary.html
--- a/kallithea/templates/summary/summary.html
+++ b/kallithea/templates/summary/summary.html
@@ -383,8 +383,11 @@ summary = lambda n:{False:'summary-short
         }
 
     }
+    if (data.length == 0) {
+        tbl.innerHTML = "<tr><td>${_('No data ready yet')}</td></tr>";
+    }
 
-    $('#lang_stats').appendChild(tbl);
+    $('#lang_stats').append(tbl);
     $('#code_status_show_more').click(function(){
         $('.stats_hidden').show();
         $('#code_status_show_more').hide();


More information about the kallithea-general mailing list