Changeset - 301773d07012
[Not reviewed]
beta
0 4 1
Marcin Kuzminski - 13 years ago 2012-10-23 00:02:59
marcin@python-works.com
Lazy loading on my journal page
5 files changed with 100 insertions and 70 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -344,12 +344,14 @@ def make_map(config):
 
    #==========================================================================
 
    with rmap.submapper(path_prefix=ADMIN_PREFIX,
 
                        controller='api/api') as m:
 
        m.connect('api', '/api')
 

	
 
    #USER JOURNAL
 
    rmap.connect('journal_my_repos', '%s/journal_my_repos' % ADMIN_PREFIX,
 
                 controller='journal', action='index_my_repos')
 
    rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
 
                 controller='journal', action='index')
 
    rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
 
                 controller='journal', action='journal_rss')
 
    rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
 
                 controller='journal', action='journal_atom')
rhodecode/controllers/journal.py
Show inline comments
 
@@ -58,17 +58,12 @@ class JournalController(BaseController):
 
    @NotAnonymous()
 
    def index(self):
 
        # Return a rendered template
 
        p = safe_int(request.params.get('page', 1), 1)
 

	
 
        c.user = User.get(self.rhodecode_user.user_id)
 
        all_repos = self.sa.query(Repository)\
 
                     .filter(Repository.user_id == c.user.user_id)\
 
                     .order_by(func.lower(Repository.repo_name)).all()
 

	
 
        c.user_repos = ScmModel().get_repos(all_repos)
 

	
 
        c.following = self.sa.query(UserFollowing)\
 
            .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
 
            .options(joinedload(UserFollowing.follows_repository))\
 
            .all()
 

	
 
@@ -80,12 +75,22 @@ class JournalController(BaseController):
 

	
 
        c.journal_data = render('journal/journal_data.html')
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            return c.journal_data
 
        return render('journal/journal.html')
 

	
 
    @LoginRequired()
 
    @NotAnonymous()
 
    def index_my_repos(self):
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            all_repos = self.sa.query(Repository)\
 
                     .filter(Repository.user_id == c.user.user_id)\
 
                     .order_by(func.lower(Repository.repo_name)).all()
 
            c.user_repos = ScmModel().get_repos(all_repos)
 
            return render('journal/journal_page_repos.html')
 

	
 
    @LoginRequired(api_access=True)
 
    @NotAnonymous()
 
    def journal_atom(self):
 
        """
 
        Produce an atom-1.0 feed via feedgenerator module
 
        """
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -132,13 +132,13 @@ var show_my = function(e){
 
    YUD.setStyle('perms','display','none');
 
    YUD.setStyle('pullrequests','display','none');
 
    YUD.setStyle('my','display','');
 
    YUD.setStyle('q_filter','display','');
 

	
 

	
 
    var url = "${h.url('admin_settings_my_repos')}";
 
    var url = "${h.url('journal_my_repos')}";
 
    ypjax(url, 'my', function(){
 
        table_sort();
 
        filter_activate();
 
    });
 
}
 
YUE.on('show_my','click',function(e){
 
@@ -168,13 +168,12 @@ var tabs = {
 
    'pullrequests': show_pullrequests
 
}
 
var url = location.href.split('#');
 
if (url[1]) {
 
    //We have a hash
 
    var tabHash = url[1];
 
    console.log(tabs, tabHash)
 
    tabs[tabHash]();
 
}
 

	
 
// main table sorting
 
var myColumnDefs = [
 
    {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
rhodecode/templates/journal/journal.html
Show inline comments
 
@@ -35,74 +35,29 @@
 
    </div>
 
    <div class="box box-right">
 
        <!-- box / title -->
 
        <div class="title">
 
            <h5>
 
            <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
 
            <a id="show_my" class="link-white" href="#my">${_('My repos')}</a> / <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a>
 
            <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a> / <a id="show_my" class="link-white" href="#my">${_('My repos')}</a> 
 
            </h5>
 
             %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
             <ul class="links">
 
               <li>
 
                 <span>${h.link_to(_('ADD'),h.url('admin_settings_create_repository'))}</span>
 
               </li>
 
             </ul>
 
             %endif
 
        </div>
 
        <!-- end box / title -->
 
        <div id="my" class="table">
 
            %if c.user_repos:
 
            <div id='repos_list_wrap' class="yui-skin-sam">
 
            <table id="repos_list">
 
             <thead>
 
                  <tr>
 
                  <th></th>
 
                  <th class="left">${_('Name')}</th>
 
                  <th class="left">${_('Revision')}</th>
 
                  <th class="left">${_('Action')}</th>
 
                  <th class="left">${_('Action')}</th>
 
             </thead>
 
             <tbody>
 
                 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
 
                 %for repo in c.user_repos:
 
                    <tr>
 
                        ##QUICK MENU
 
                        <td class="quick_repo_menu">
 
                          ${dt.quick_menu(repo['name'])}
 
                        </td>
 
                        ##REPO NAME AND ICONS
 
                        <td class="reponame">
 
                          ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']))}
 
                        </td>
 
                        ##LAST REVISION
 
                        <td>
 
                            ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
 
                        </td>
 
                        ##
 
                        <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url('/images/icons/application_form_edit.png')}"/></a></td>
 
                        <td>
 
                          ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
 
                            ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository')+"');")}
 
                          ${h.end_form()}
 
                        </td>
 
                    </tr>
 
                 %endfor
 
             </tbody>
 
             </table>
 
             </div>
 
             %else:
 
                <div style="padding:5px 0px 10px 0px;">
 
                ${_('No repositories yet')}
 
                %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
                    ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")}
 
                %endif
 
                </div>
 
             %endif
 
        <div id="my" class="table" style="display:none">
 
        ## loaded via AJAX
 
        ${_('Loading...')}
 
        </div>
 

	
 
        <div id="watched" class="table" style="display:none">
 
        <div id="watched" class="table">
 
          %if c.following:
 
            <table>
 
            <thead>
 
                <tr>
 
                <th class="left">${_('Name')}</th>
 
            </thead>
 
@@ -148,35 +103,58 @@
 
              </div>
 
          %endif
 
        </div>
 
    </div>
 

	
 
    <script type="text/javascript">
 

	
 
    YUE.on('show_my','click',function(e){
 
    var show_my = function(e){
 
        YUD.setStyle('watched','display','none');
 
        YUD.setStyle('my','display','');
 
        var nodes = YUQ('#my tr td a.repo_name');
 
        var target = 'q_filter';
 
        var func = function(node){
 
            return node.parentNode.parentNode.parentNode.parentNode;
 
        }
 
        q_filter(target,nodes,func);
 
        YUE.preventDefault(e);
 

	
 
        var url = "${h.url('admin_settings_my_repos')}";
 
        ypjax(url, 'my', function(){
 
            tooltip_activate();
 
            quick_repo_menu();
 
            var nodes = YUQ('#my tr td a.repo_name');
 
            var func = function(node){
 
                return node.parentNode.parentNode.parentNode;
 
            }            
 
            q_filter('q_filter',nodes,func);
 
        });        
 
        
 
    }
 
    YUE.on('show_my','click',function(e){
 
        show_my(e);
 
    })
 
    YUE.on('show_watched','click',function(e){
 
        YUD.setStyle('my','display','none');
 
    var show_watched = function(e){
 
    	YUD.setStyle('my','display','none');
 
        YUD.setStyle('watched','display','');
 
        var nodes = YUQ('#watched .watched_repo a');
 
        var target = 'q_filter';
 
        var func = function(node){
 
            return node.parentNode.parentNode;
 
        }
 
        q_filter(target,nodes,func);
 
        YUE.preventDefault(e);
 
    }
 
    YUE.on('show_watched','click',function(e){
 
        show_watched(e);
 
    })
 
    //init watched
 
    show_watched();
 
    
 
    var tabs = {
 
        'watched': show_watched,
 
        'my': show_my,
 
    }
 
    var url = location.href.split('#');
 
    if (url[1]) {
 
        //We have a hash
 
        var tabHash = url[1];
 
        tabs[tabHash]();
 
    }    
 
    
 
    YUE.on('refresh','click',function(e){
 
        ypjax(e.currentTarget.href,"journal",function(){show_more_event();tooltip_activate();});
 
        YUE.preventDefault(e);
 
    });
 

	
 

	
 
@@ -221,9 +199,8 @@
 
        var func = function(node){
 
            return node.parentNode.parentNode.parentNode.parentNode;
 
        }
 
        q_filter('q_filter',YUQ('#my tr td a.repo_name'),func);
 
    });
 

	
 

	
 
    </script>
 
</%def>
rhodecode/templates/journal/journal_page_repos.html
Show inline comments
 
new file 100644
 
%if c.user_repos:
 
<div id='repos_list_wrap' class="yui-skin-sam">
 
<table id="repos_list">
 
 <thead>
 
      <tr>
 
      <th></th>
 
      <th class="left">${_('Name')}</th>
 
      <th class="left">${_('Revision')}</th>
 
      <th class="left">${_('Action')}</th>
 
      <th class="left">${_('Action')}</th>
 
 </thead>
 
 <tbody>
 
     <%namespace name="dt" file="/data_table/_dt_elements.html"/>
 
     %for repo in c.user_repos:
 
        <tr>
 
            ##QUICK MENU
 
            <td class="quick_repo_menu">
 
              ${dt.quick_menu(repo['name'])}
 
            </td>
 
            ##REPO NAME AND ICONS
 
            <td class="reponame">
 
              ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']))}
 
            </td>
 
            ##LAST REVISION
 
            <td>
 
                ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
 
            </td>
 
            ##
 
            <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url('/images/icons/application_form_edit.png')}"/></a></td>
 
            <td>
 
              ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
 
                ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository')+"');")}
 
              ${h.end_form()}
 
            </td>
 
        </tr>
 
     %endfor
 
 </tbody>
 
 </table>
 
 </div>
 
 %else:
 
    <div style="padding:5px 0px 10px 0px;">
 
    ${_('No repositories yet')}
 
    %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
        ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")}
 
    %endif
 
    </div>
 
 %endif
 
\ No newline at end of file
0 comments (0 inline, 0 general)