Changeset - 6db3122e4d75
[Not reviewed]
default
0 5 0
Mads Kiilerich - 8 years ago 2017-09-14 02:08:06
mads@kiilerich.com
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.
5 files changed with 31 insertions and 49 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/repo_groups.py
Show inline comments
 
@@ -293,19 +293,18 @@ class RepoGroupsController(BaseControlle
 
    def show(self, group_name):
 
        c.active = 'settings'
 

	
 
        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')
 

	
 
    @HasRepoGroupPermissionLevelDecorator('admin')
 
    def edit(self, group_name):
 
        c.active = 'settings'
kallithea/controllers/home.py
Show inline comments
 
@@ -47,21 +47,20 @@ class HomeController(BaseController):
 

	
 
    def about(self):
 
        return render('/about.html')
 

	
 
    @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')
 

	
 
    @LoginRequired()
 
    @jsonify
 
    def repo_switcher_data(self):
kallithea/model/repo.py
Show inline comments
 
@@ -160,13 +160,14 @@ class RepoModel(object):
 
        template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
 

	
 
        tmpl = template.get_def(tmpl)
 
        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
 

	
 
        def repo_lnk(name, rtype, rstate, private, fork_of):
 
            return _render('repo_name', name, rtype, rstate, private, fork_of,
 
@@ -196,12 +197,20 @@ class RepoModel(object):
 
            return _render('repo_actions', repo_name, super_user_actions)
 

	
 
        def owner_actions(owner_id, username):
 
            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
 
                if not HasRepoPermissionLevel('read')(repo.repo_name, 'get_repos_as_dict check'):
 
                    continue
 
            cs_cache = repo.changeset_cache
kallithea/templates/data_table/_dt_elements.html
Show inline comments
 
@@ -122,12 +122,19 @@
 
        <i class="icon-minus-circled text-danger"></i> ${_('Delete')}
 
      </button>
 
    ${h.end_form()}
 
 </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">
 
      <i class="icon-pencil"></i> ${_('Edit')}
 
    </a>
 
 </div>
kallithea/templates/index_base.html
Show inline comments
 
@@ -36,67 +36,35 @@
 
                %if c.group and h.HasRepoGroupPermissionLevel('admin')(c.group.group_name):
 
                    <a href="${h.url('edit_repo_group',group_name=c.group.group_name)}" title="${_('You have admin right to this group, and can edit it')}" class="btn btn-default btn-xs"><i class="icon-pencil"></i> ${_('Edit Repository Group')}</a>
 
                %endif
 
              </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,
 
                columns: [
 
                    {data: "raw_name", visible: false, searchable: false},
 
                    {title: ${h.jshtml(_('Repository'))}, data: "name", orderData: [0,], render: {
 
                        filter: function(data, type, row, meta) {
 
                            return row.just_name;
 
                        }
 
                    }},
 
                    {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',
 
                pageLength: 100
 
            });
 
      </script>
0 comments (0 inline, 0 general)