changeset 6876:6db3122e4d75

index: show repositories and repository groups in the same table Having two different tables with their own paging and search gave a bad UI. Instead, do like all other UIs that show directory content and show both "folders" and "files" in the same list. The rendering of repo groups is changed to use js data instead of a taking data from an html table. Repository groups are shoe-horned into the repository DataTable. The columns are no perfect match - some of the existing columns are thus given an empty default value.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 14 Sep 2017 02:08:06 +0200
parents e81332582fc9
children c5bff92d5084
files kallithea/controllers/admin/repo_groups.py kallithea/controllers/home.py kallithea/model/repo.py kallithea/templates/data_table/_dt_elements.html kallithea/templates/index_base.html
diffstat 5 files changed, 31 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/repo_groups.py	Thu Sep 14 02:08:06 2017 +0200
+++ b/kallithea/controllers/admin/repo_groups.py	Thu Sep 14 02:08:06 2017 +0200
@@ -296,13 +296,12 @@
         c.group = c.repo_group = RepoGroup.guess_instance(group_name)
 
         groups = RepoGroup.query(sorted=True).filter_by(parent_group=c.group).all()
-        c.groups = self.scm_model.get_repo_groups(groups)
+        repo_groups_list = self.scm_model.get_repo_groups(groups)
 
         repos_list = Repository.query(sorted=True).filter_by(group=c.group).all()
-        repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
-                                                   admin=False, short_name=True)
-        # data used to render the grid
-        c.data = repos_data
+        c.data = RepoModel().get_repos_as_dict(repos_list=repos_list,
+                                               repo_groups_list=repo_groups_list,
+                                               admin=False, short_name=True)
 
         return render('admin/repo_groups/repo_group_show.html')
 
--- a/kallithea/controllers/home.py	Thu Sep 14 02:08:06 2017 +0200
+++ b/kallithea/controllers/home.py	Thu Sep 14 02:08:06 2017 +0200
@@ -50,15 +50,14 @@
 
     @LoginRequired()
     def index(self):
-        c.groups = self.scm_model.get_repo_groups()
         c.group = None
 
+        repo_groups_list = self.scm_model.get_repo_groups()
         repos_list = Repository.query(sorted=True).filter_by(group=None).all()
 
-        repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
-                                                   admin=False, short_name=True)
-        # data used to render the grid
-        c.data = repos_data
+        c.data = RepoModel().get_repos_as_dict(repos_list=repos_list,
+                                               repo_groups_list=repo_groups_list,
+                                               admin=False, short_name=True)
 
         return render('/index.html')
 
--- a/kallithea/model/repo.py	Thu Sep 14 02:08:06 2017 +0200
+++ b/kallithea/model/repo.py	Thu Sep 14 02:08:06 2017 +0200
@@ -163,7 +163,8 @@
         kwargs.update(dict(_=_, h=h, c=c, request=request))
         return tmpl.render(*args, **kwargs)
 
-    def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True,
+    def get_repos_as_dict(self, repos_list=None, repo_groups_list=None,
+                          admin=False, perm_check=True,
                           super_user_actions=False, short_name=False):
         _render = self._render_datatable
         from tg import tmpl_context as c
@@ -199,6 +200,14 @@
             return _render('user_name', owner_id, username)
 
         repos_data = []
+
+        for gr in repo_groups_list or []:
+            repos_data.append(dict(
+                raw_name='\0' + gr.name, # sort before repositories
+                just_name=gr.name,
+                name=_render('group_name_html', group_name=gr.group_name, name=gr.name),
+                desc=gr.group_description))
+
         for repo in repos_list:
             if perm_check:
                 # check permission at this level
--- a/kallithea/templates/data_table/_dt_elements.html	Thu Sep 14 02:08:06 2017 +0200
+++ b/kallithea/templates/data_table/_dt_elements.html	Thu Sep 14 02:08:06 2017 +0200
@@ -125,6 +125,13 @@
  </div>
 </%def>
 
+<%def name="group_name_html(group_name,name)">
+  <div class="dt_repo">
+    <i class="icon-folder"></i>
+    <a href="${h.url('repos_group_home',group_name=group_name)}">${name}</a>
+  </div>
+</%def>
+
 <%def name="repo_group_actions(repo_group_id, repo_group_name, gr_count)">
  <div class="pull-left">
     <a href="${h.url('edit_repo_group',group_name=repo_group_name)}" title="${_('Edit')}" class="btn btn-default btn-xs">
--- a/kallithea/templates/index_base.html	Thu Sep 14 02:08:06 2017 +0200
+++ b/kallithea/templates/index_base.html	Thu Sep 14 02:08:06 2017 +0200
@@ -39,44 +39,12 @@
               </div>
             %endif
         </div>
-        %if c.groups:
-        <div class="panel-body">
-              <table id="groups_list" class="table" width="100%">
-                  <thead>
-                      <tr>
-                          <th class="left">${_('Repository Group')}</th>
-                          <th class="left">${_('Description')}</th>
-                          ##<th class="left">${_('Number of Repositories')}</th>
-                      </tr>
-                  </thead>
-                  % for gr in c.groups:
-                    <tr>
-                        <td>
-                            <div class="dt_repo">
-                                <i class="icon-folder"></i>
-                                <a href="${url('repos_group_home',group_name=gr.group_name)}">${gr.name}</a>
-                            </div>
-                        </td>
-                        <td>${h.urlify_text(gr.group_description, stylize=c.visual.stylify_metatags)}</td>
-                        ## this is commented out since for multi nested repos can be HEAVY!
-                        ## in number of executed queries during traversing uncomment at will
-                        ##<td><b>${gr.repositories_recursive_count}</b></td>
-                    </tr>
-                  % endfor
-              </table>
-        </div>
-        %endif
         <div class="panel-body">
             <table class="table" id="repos_list_wrap" width="100%"></table>
         </div>
     </div>
 
       <script>
-        $('#groups_list').DataTable({
-            dom: '<"dataTables_left"f><"dataTables_right"ilp>t',
-            pageLength: 100
-        });
-
         var data = ${h.js(c.data)},
             $dataTable = $("#repos_list_wrap").DataTable({
                 data: data.records,
@@ -88,12 +56,12 @@
                         }
                     }},
                     {data: "desc", title: ${h.jshtml(_('Description'))}, searchable: false},
-                    {data: "last_change_iso", visible: false, searchable: false},
-                    {data: "last_change", title: ${h.jshtml(_('Last Change'))}, orderData: [3,], searchable: false},
-                    {data: "last_rev_raw", visible: false, searchable: false},
-                    {data: "last_changeset", title: ${h.jshtml(_('Tip'))}, orderData: [5,], searchable: false},
-                    {data: "owner", title: ${h.jshtml(_('Owner'))}, searchable: false},
-                    {data: "atom", sortable: false}
+                    {data: "last_change_iso", defaultContent: '', visible: false, searchable: false},
+                    {data: "last_change", defaultContent: '', title: ${h.jshtml(_('Last Change'))}, orderData: [3,], searchable: false},
+                    {data: "last_rev_raw", defaultContent: '', visible: false, searchable: false},
+                    {data: "last_changeset", defaultContent: '', title: ${h.jshtml(_('Tip'))}, orderData: [5,], searchable: false},
+                    {data: "owner", defaultContent: '', title: ${h.jshtml(_('Owner'))}, searchable: false},
+                    {data: "atom", defaultContent: '', sortable: false}
                 ],
                 order: [[1, "asc"]],
                 dom: '<"dataTables_left"f><"dataTables_right"ilp>t',