Changeset - fcbc35ecb024
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2011-11-29 08:55:30
marcin@python-works.com
personal Journal UI
- added my repos and watched repos with filtering
3 files changed with 153 insertions and 36 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/journal.py
Show inline comments
 
@@ -34,14 +34,16 @@ from paste.httpexceptions import HTTPBad
 
from pylons import request, tmpl_context as c, response, url
 
from pylons.i18n.translation import _
 

	
 
import rhodecode.lib.helpers as h
 
from rhodecode.lib.auth import LoginRequired, NotAnonymous
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.db import UserLog, UserFollowing
 
from rhodecode.model.db import UserLog, UserFollowing, Repository, User
 
from rhodecode.model.meta import Session
 
from sqlalchemy.sql.expression import func
 
from rhodecode.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class JournalController(BaseController):
 

	
 
@@ -56,12 +58,19 @@ class JournalController(BaseController):
 
    @LoginRequired()
 
    @NotAnonymous()
 
    def index(self):
 
        # Return a rendered template
 
        p = int(request.params.get('page', 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()
 

	
 
        journal = self._get_journal_data(c.following)
rhodecode/public/css/style.css
Show inline comments
 
@@ -755,12 +755,16 @@ div.options a {
 
	color: #fff;
 
	text-transform: uppercase;
 
	margin: 0;
 
	padding: 11px 0 11px 10px;
 
}
 
 
#content div.box div.title .link-white{
 
	color: #FFFFFF;
 
}
 
 
#content div.box div.title ul.links li {
 
	list-style: none;
 
	float: left;
 
	margin: 0;
 
	padding: 0;
 
}
rhodecode/templates/journal/journal.html
Show inline comments
 
@@ -24,46 +24,150 @@
 
		    YUD.setStyle(el.parentNode,'display','none');
 
		});
 
		}
 
		</script> 	    
 
	    <div id="journal">${c.journal_data}</div>
 
    </div>
 
    
 
    <div class="box box-right">
 
        <!-- box / title -->
 
        <div class="title">
 
            <h5>${_('Following')}</h5>
 
            <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 repositories')}</a> / <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a>
 
            </h5>
 
             %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
             <ul class="links">
 
               <li>
 
                 <span>${h.link_to(_('ADD REPOSITORY'),h.url('admin_settings_create_repository'))}</span>
 
               </li>          
 
             </ul>           
 
             %endif        
 
        </div>
 
        <!-- end box / title -->
 
        <div id="my" class="table">
 
            <table>
 
            <thead>
 
                <tr>
 
                <th class="left">${_('Name')}</th>
 
                <th class="left">${_('revision')}</th>
 
                <th colspan="2" class="left">${_('action')}</th>            
 
            </thead>
 
             <tbody>
 
             %if c.user_repos:
 
                 %for repo in c.user_repos:
 
                    <tr>
 
                        <td>
 
                         %if repo['dbrepo']['repo_type'] =='hg':
 
                           <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
 
                         %elif repo['dbrepo']['repo_type'] =='git':
 
                           <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
 
                         %else:
 
                           
 
                         %endif                     
 
                         %if repo['dbrepo']['private']:
 
                            <img class="icon" alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/>
 
                         %else:
 
                            <img class="icon" alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/>
 
                         %endif
 
                                                         
 
                        ${h.link_to(repo['name'], h.url('summary_home',repo_name=repo['name']),class_="repo_name")}
 
                        %if repo['dbrepo_fork']:
 
                            <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}">
 
                            <img class="icon" alt="${_('public')}"
 
                            title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" 
 
                            src="${h.url('/images/icons/arrow_divide.png')}"/></a>
 
                        %endif                  
 
                        </td> 
 
                        <td><span class="tooltip" title="${repo['last_change']}">${("r%s:%s") % (repo['rev'],h.short_id(repo['tip']))}</span></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
 
             %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-button-small")}
 
                %endif
 
                </div>
 
             %endif
 
             </tbody>
 
             </table>
 
        </div>
 
        <div>
 
		%if c.following:
 
		    %for entry in c.following:
 
		        <div class="currently_following">
 
		            %if entry.follows_user_id:
 
		              <img title="${_('following user')}" alt="${_('user')}" src="${h.url('/images/icons/user.png')}"/>
 
		              ${entry.follows_user.full_contact}
 
		            %endif
 
		            
 
		            %if entry.follows_repo_id:
 
		              
 
		              <div style="float:left;padding-right:5px">
 
                      <span id="follow_toggle_${entry.follows_repository.repo_id}" class="following" title="${_('Stop following this repository')}"
 
                            onclick="javascript:toggleFollowingRepo(this,${entry.follows_repository.repo_id},'${str(h.get_token())}')">
 
                      </span>		            
 
		              </div>
 
		              %if entry.follows_repository.private:
 
		                <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/>
 
		              %else:
 
		                <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
 
		              %endif
 
		              
 
		              ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',
 
		                repo_name=entry.follows_repository.repo_name))}
 
		              
 
		            %endif
 
		        </div>
 
		    %endfor
 
		%else:
 
		    ${_('You are not following any users or repositories')}
 
		%endif
 
        </div>
 
    </div>    
 
    
 
        <div id="watched" class="table" style="display:none">
 
          <table>
 
          <thead>
 
              <tr>
 
              <th class="left">${_('Name')}</th>
 
          </thead>
 
           <tbody>        
 
          %if c.following:
 
              %for entry in c.following:
 
              <tr>
 
                <td>
 
                      %if entry.follows_user_id:
 
                        <img title="${_('following user')}" alt="${_('user')}" src="${h.url('/images/icons/user.png')}"/>
 
                        ${entry.follows_user.full_contact}
 
                      %endif
 
                      
 
                      %if entry.follows_repo_id:
 
                        
 
                        <div style="float:right;padding-right:5px">
 
                        <span id="follow_toggle_${entry.follows_repository.repo_id}" class="following" title="${_('Stop following this repository')}"
 
                              onclick="javascript:toggleFollowingRepo(this,${entry.follows_repository.repo_id},'${str(h.get_token())}')">
 
                        </span>                   
 
                        </div>
 
                        
 
                         %if entry.follows_repository.repo_type == 'hg':
 
                           <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
 
                         %elif entry.follows_repository.repo_type == 'git':
 
                           <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
 
                         %endif                        
 
                        
 
                        %if entry.follows_repository.private:
 
                          <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/>
 
                        %else:
 
                          <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
 
                        %endif
 
                        <span class="watched_repo">
 
                            ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',repo_name=entry.follows_repository.repo_name))}
 
                        </span>
 
                      %endif
 
                </td>
 
              </tr>
 
              %endfor
 
          %else:
 
          </tbody>
 
              ${_('You are not following any users or repositories')}
 
          %endif   
 
          </table>     
 
        </div> 
 
    <script type="text/javascript">
 
    YUE.on('show_my','click',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;
 
        }
 
        q_filter(target,nodes,func);        
 
        YUE.preventDefault(e);
 
    })
 
    YUE.on('show_watched','click',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);        
 
    })
 
    </script>    
 
</%def>    
0 comments (0 inline, 0 general)