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 96 insertions and 66 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -347,6 +347,8 @@ def make_map(config):
 
        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,
rhodecode/controllers/journal.py
Show inline comments
 
@@ -61,11 +61,6 @@ class JournalController(BaseController):
 
        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)\
 
@@ -83,6 +78,16 @@ class JournalController(BaseController):
 
            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):
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -135,7 +135,7 @@ var show_my = function(e){
 
    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();
 
@@ -171,7 +171,6 @@ var url = location.href.split('#');
 
if (url[1]) {
 
    //We have a hash
 
    var tabHash = url[1];
 
    console.log(tabs, tabHash)
 
    tabs[tabHash]();
 
}
 

	
rhodecode/templates/journal/journal.html
Show inline comments
 
@@ -38,7 +38,7 @@
 
        <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">
 
@@ -49,57 +49,12 @@
 
             %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>
 
@@ -151,19 +106,26 @@
 
    </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 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 target = 'q_filter';
 
        var func = function(node){
 
            return node.parentNode.parentNode.parentNode.parentNode;
 
                return node.parentNode.parentNode.parentNode;
 
        }
 
        q_filter(target,nodes,func);
 
        YUE.preventDefault(e);
 
            q_filter('q_filter',nodes,func);
 
        });        
 
        
 
    }
 
    YUE.on('show_my','click',function(e){
 
        show_my(e);
 
    })
 
    YUE.on('show_watched','click',function(e){
 
    var show_watched = function(e){
 
        YUD.setStyle('my','display','none');
 
        YUD.setStyle('watched','display','');
 
        var nodes = YUQ('#watched .watched_repo a');
 
@@ -172,8 +134,24 @@
 
            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);
 
@@ -224,6 +202,5 @@
 
        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)