##// END OF EJS Templates
Use common function for generation of grid data...
marcink -
r3154:0226b6d6 beta
parent child Browse files
Show More
@@ -359,8 +359,6 b' def make_map(config):'
359 359 m.connect('api', '/api')
360 360
361 361 #USER JOURNAL
362 rmap.connect('journal_my_repos', '%s/journal_my_repos' % ADMIN_PREFIX,
363 controller='journal', action='index_my_repos')
364 362 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
365 363 controller='journal', action='index')
366 364 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
@@ -135,40 +135,10 b' class ReposController(BaseController):'
135 135 .order_by(func.lower(Repository.repo_name))\
136 136 .all()
137 137
138 repos_data = []
139 total_records = len(c.repos_list)
140
141 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
142 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
143
144 quick_menu = lambda repo_name: (template.get_def("quick_menu")
145 .render(repo_name, _=_, h=h, c=c))
146 repo_lnk = lambda name, rtype, private, fork_of: (
147 template.get_def("repo_name")
148 .render(name, rtype, private, fork_of, short_name=False,
149 admin=True, _=_, h=h, c=c))
150
151 repo_actions = lambda repo_name: (template.get_def("repo_actions")
152 .render(repo_name, _=_, h=h, c=c))
153
154 for repo in c.repos_list:
155 repos_data.append({
156 "menu": quick_menu(repo.repo_name),
157 "raw_name": repo.repo_name.lower(),
158 "name": repo_lnk(repo.repo_name, repo.repo_type,
159 repo.private, repo.fork),
160 "desc": repo.description,
161 "owner": repo.user.username,
162 "action": repo_actions(repo.repo_name),
163 })
164
165 c.data = json.dumps({
166 "totalRecords": total_records,
167 "startIndex": 0,
168 "sort": "name",
169 "dir": "asc",
170 "records": repos_data
171 })
138 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
139 admin=True)
140 #json used to render the grid
141 c.data = json.dumps(repos_data)
172 142
173 143 return render('admin/repos/repos.html')
174 144
@@ -295,54 +295,18 b' class ReposGroupsController(BaseControll'
295 295 c.groups = self.scm_model.get_repos_groups(groups)
296 296
297 297 if c.visual.lightweight_dashboard is False:
298 c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
299
300 c.repos_list = c.cached_repo_list
298 c.repo_list = self.scm_model.get_repos(all_repos=gr_filter)
301 299 ## lightweight version of dashboard
302 300 else:
303 301 c.repos_list = Repository.query()\
304 302 .filter(Repository.group_id == id)\
305 303 .order_by(func.lower(Repository.repo_name))\
306 304 .all()
307 repos_data = []
308 total_records = len(c.repos_list)
309 305
310 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
311 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
312
313 quick_menu = lambda repo_name: (template.get_def("quick_menu")
314 .render(repo_name, _=_, h=h, c=c))
315 repo_lnk = lambda name, rtype, private, fork_of: (
316 template.get_def("repo_name")
317 .render(name, rtype, private, fork_of, short_name=False,
318 admin=False, _=_, h=h, c=c))
319 last_change = lambda last_change: (template.get_def("last_change")
320 .render(last_change, _=_, h=h, c=c))
321 rss_lnk = lambda repo_name: (template.get_def("rss")
322 .render(repo_name, _=_, h=h, c=c))
323 atom_lnk = lambda repo_name: (template.get_def("atom")
324 .render(repo_name, _=_, h=h, c=c))
325
326 for repo in c.repos_list:
327 repos_data.append({
328 "menu": quick_menu(repo.repo_name),
329 "raw_name": repo.repo_name.lower(),
330 "name": repo_lnk(repo.repo_name, repo.repo_type,
331 repo.private, repo.fork),
332 "last_change": last_change(repo.last_db_change),
333 "desc": repo.description,
334 "owner": h.person(repo.user.username),
335 "rss": rss_lnk(repo.repo_name),
336 "atom": atom_lnk(repo.repo_name),
337 })
338
339 c.data = json.dumps({
340 "totalRecords": total_records,
341 "startIndex": 0,
342 "sort": "name",
343 "dir": "asc",
344 "records": repos_data
345 })
306 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
307 admin=False)
308 #json used to render the grid
309 c.data = json.dumps(repos_data)
346 310
347 311 return render('admin/repos_groups/repos_groups.html')
348 312
@@ -48,11 +48,12 b' from rhodecode.model.forms import UserFo'
48 48 ApplicationUiSettingsForm, ApplicationVisualisationForm
49 49 from rhodecode.model.scm import ScmModel
50 50 from rhodecode.model.user import UserModel
51 from rhodecode.model.repo import RepoModel
51 52 from rhodecode.model.db import User
52 53 from rhodecode.model.notification import EmailNotificationModel
53 54 from rhodecode.model.meta import Session
54 55 from rhodecode.lib.utils2 import str2bool, safe_unicode
55
56 from rhodecode.lib.compat import json
56 57 log = logging.getLogger(__name__)
57 58
58 59
@@ -390,17 +391,22 b' class SettingsController(BaseController)'
390 391 # url('admin_settings_my_account')
391 392
392 393 c.user = User.get(self.rhodecode_user.user_id)
393 all_repos = Session().query(Repository)\
394 .filter(Repository.user_id == c.user.user_id)\
395 .order_by(func.lower(Repository.repo_name)).all()
396
397 c.user_repos = ScmModel().get_repos(all_repos)
398 394
399 395 if c.user.username == 'default':
400 396 h.flash(_("You can't edit this user since it's"
401 397 " crucial for entire application"), category='warning')
402 398 return redirect(url('users'))
403 399
400 repos_list = Session().query(Repository)\
401 .filter(Repository.user_id ==
402 self.rhodecode_user.user_id)\
403 .order_by(func.lower(Repository.repo_name)).all()
404
405 repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
406 admin=True)
407 #json used to render the grid
408 c.data = json.dumps(repos_data)
409
404 410 defaults = c.user.get_dict()
405 411
406 412 c.form = htmlfill.render(
@@ -449,23 +455,14 b' class SettingsController(BaseController)'
449 455 return redirect(url('my_account'))
450 456
451 457 @NotAnonymous()
452 def my_account_my_repos(self):
453 all_repos = Session().query(Repository)\
454 .filter(Repository.user_id == self.rhodecode_user.user_id)\
455 .order_by(func.lower(Repository.repo_name))\
456 .all()
457 c.user_repos = ScmModel().get_repos(all_repos)
458 return render('admin/users/user_edit_my_account_repos.html')
459
460 @NotAnonymous()
461 458 def my_account_my_pullrequests(self):
462 459 c.my_pull_requests = PullRequest.query()\
463 .filter(PullRequest.user_id==
460 .filter(PullRequest.user_id ==
464 461 self.rhodecode_user.user_id)\
465 462 .all()
466 463 c.participate_in_pull_requests = \
467 464 [x.pull_request for x in PullRequestReviewers.query()\
468 .filter(PullRequestReviewers.user_id==
465 .filter(PullRequestReviewers.user_id ==
469 466 self.rhodecode_user.user_id)\
470 467 .all()]
471 468 return render('admin/users/user_edit_my_account_pullrequests.html')
@@ -28,6 +28,7 b' import logging'
28 28 from pylons import tmpl_context as c, request
29 29 from pylons.i18n.translation import _
30 30 from webob.exc import HTTPBadRequest
31 from sqlalchemy.sql.expression import func
31 32
32 33 import rhodecode
33 34 from rhodecode.lib import helpers as h
@@ -35,7 +36,8 b' from rhodecode.lib.ext_json import json'
35 36 from rhodecode.lib.auth import LoginRequired
36 37 from rhodecode.lib.base import BaseController, render
37 38 from rhodecode.model.db import Repository
38 from sqlalchemy.sql.expression import func
39 from rhodecode.model.repo import RepoModel
40
39 41
40 42 log = logging.getLogger(__name__)
41 43
@@ -58,59 +60,11 b' class HomeController(BaseController):'
58 60 .filter(Repository.group_id == None)\
59 61 .order_by(func.lower(Repository.repo_name))\
60 62 .all()
61 repos_data = []
62 total_records = len(c.repos_list)
63 63
64 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
65 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
66
67 quick_menu = lambda repo_name: (template.get_def("quick_menu")
68 .render(repo_name, _=_, h=h, c=c))
69 repo_lnk = lambda name, rtype, private, fork_of: (
70 template.get_def("repo_name")
71 .render(name, rtype, private, fork_of, short_name=False,
72 admin=False, _=_, h=h, c=c))
73 last_change = lambda last_change: (template.get_def("last_change")
74 .render(last_change, _=_, h=h, c=c))
75 rss_lnk = lambda repo_name: (template.get_def("rss")
76 .render(repo_name, _=_, h=h, c=c))
77 atom_lnk = lambda repo_name: (template.get_def("atom")
78 .render(repo_name, _=_, h=h, c=c))
79 tip = lambda repo_name, cs_cache: (template.get_def("revision")
80 .render(repo_name,
81 cs_cache.get('revision'),
82 cs_cache.get('raw_id'),
83 cs_cache.get('author'),
84 cs_cache.get('message'), _=_, h=h,
85 c=c))
86
87 def desc(desc):
88 if c.visual.stylify_metatags:
89 return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
90 else:
91 return h.urlify_text(h.truncate(desc, 60))
92
93 for repo in c.repos_list:
94 repos_data.append({
95 "menu": quick_menu(repo.repo_name),
96 "raw_name": repo.repo_name.lower(),
97 "name": repo_lnk(repo.repo_name, repo.repo_type,
98 repo.private, repo.fork),
99 "last_change": last_change(repo.last_db_change),
100 "tip": tip(repo.repo_name, repo.changeset_cache),
101 "desc": desc(repo.description),
102 "owner": h.person(repo.user.username),
103 "rss": rss_lnk(repo.repo_name),
104 "atom": atom_lnk(repo.repo_name),
105 })
106
107 c.data = json.dumps({
108 "totalRecords": total_records,
109 "startIndex": 0,
110 "sort": "name",
111 "dir": "asc",
112 "records": repos_data
113 })
64 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
65 admin=False)
66 #json used to render the grid
67 c.data = json.dumps(repos_data)
114 68
115 69 return render('/index.html')
116 70
@@ -27,6 +27,8 b' from itertools import groupby'
27 27
28 28 from sqlalchemy import or_
29 29 from sqlalchemy.orm import joinedload
30 from sqlalchemy.sql.expression import func
31
30 32 from webhelpers.paginate import Page
31 33 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
32 34
@@ -39,10 +41,10 b' from rhodecode.lib.auth import LoginRequ'
39 41 from rhodecode.lib.base import BaseController, render
40 42 from rhodecode.model.db import UserLog, UserFollowing, Repository, User
41 43 from rhodecode.model.meta import Session
42 from sqlalchemy.sql.expression import func
43 from rhodecode.model.scm import ScmModel
44 44 from rhodecode.lib.utils2 import safe_int, AttributeDict
45 45 from rhodecode.controllers.admin.admin import _journal_filter
46 from rhodecode.model.repo import RepoModel
47 from rhodecode.lib.compat import json
46 48
47 49 log = logging.getLogger(__name__)
48 50
@@ -78,18 +80,73 b' class JournalController(BaseController):'
78 80 c.journal_data = render('journal/journal_data.html')
79 81 if request.environ.get('HTTP_X_PARTIAL_XHR'):
80 82 return c.journal_data
81 return render('journal/journal.html')
83
84 repos_list = Session().query(Repository)\
85 .filter(Repository.user_id ==
86 self.rhodecode_user.user_id)\
87 .order_by(func.lower(Repository.repo_name)).all()
88
89 repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
90 admin=True)
91 #json used to render the grid
92 c.data = json.dumps(repos_data)
93
94 watched_repos_data = []
95
96 ## watched repos
97 _render = RepoModel._render_datatable
98
99 def quick_menu(repo_name):
100 return _render('quick_menu', repo_name)
101
102 def repo_lnk(name, rtype, private, fork_of):
103 return _render('repo_name', name, rtype, private, fork_of,
104 short_name=False, admin=False)
105
106 def last_rev(repo_name, cs_cache):
107 return _render('revision', repo_name, cs_cache.get('revision'),
108 cs_cache.get('raw_id'), cs_cache.get('author'),
109 cs_cache.get('message'))
82 110
83 @LoginRequired()
84 @NotAnonymous()
85 def index_my_repos(self):
86 c.user = User.get(self.rhodecode_user.user_id)
87 if request.environ.get('HTTP_X_PARTIAL_XHR'):
88 all_repos = self.sa.query(Repository)\
89 .filter(Repository.user_id == c.user.user_id)\
90 .order_by(func.lower(Repository.repo_name)).all()
91 c.user_repos = ScmModel().get_repos(all_repos)
92 return render('journal/journal_page_repos.html')
111 def desc(desc):
112 from pylons import tmpl_context as c
113 if c.visual.stylify_metatags:
114 return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
115 else:
116 return h.urlify_text(h.truncate(desc, 60))
117
118 def repo_actions(repo_name):
119 return _render('repo_actions', repo_name)
120
121 def owner_actions(user_id, username):
122 return _render('user_name', user_id, username)
123
124 def toogle_follow(repo_id):
125 return _render('toggle_follow', repo_id)
126
127 for entry in c.following:
128 repo = entry.follows_repository
129 cs_cache = repo.changeset_cache
130 row = {
131 "menu": quick_menu(repo.repo_name),
132 "raw_name": repo.repo_name.lower(),
133 "name": repo_lnk(repo.repo_name, repo.repo_type,
134 repo.private, repo.fork),
135 "last_changeset": last_rev(repo.repo_name, cs_cache),
136 "raw_tip": cs_cache.get('revision'),
137 "action": toogle_follow(repo.repo_id)
138 }
139
140 watched_repos_data.append(row)
141
142 c.watched_data = json.dumps({
143 "totalRecords": len(c.following),
144 "startIndex": 0,
145 "sort": "name",
146 "dir": "asc",
147 "records": watched_repos_data
148 })
149 return render('journal/journal.html')
93 150
94 151 @LoginRequired(api_access=True)
95 152 @NotAnonymous()
@@ -41,6 +41,7 b' from rhodecode.model.db import Repositor'
41 41 Statistics, UsersGroup, UsersGroupRepoToPerm, RhodeCodeUi, RepoGroup,\
42 42 RhodeCodeSetting
43 43 from rhodecode.lib import helpers as h
44 from rhodecode.lib.auth import HasRepoPermissionAny
44 45
45 46
46 47 log = logging.getLogger(__name__)
@@ -113,6 +114,95 b' class RepoModel(BaseModel):'
113 114 } for gr in users_groups]
114 115 )
115 116
117 @classmethod
118 def _render_datatable(cls, tmpl, *args, **kwargs):
119 import rhodecode
120 from pylons import tmpl_context as c
121 from pylons.i18n.translation import _
122
123 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
124 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
125
126 tmpl = template.get_def(tmpl)
127 kwargs.update(dict(_=_, h=h, c=c))
128 return tmpl.render(*args, **kwargs)
129
130 def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True):
131 _render = self._render_datatable
132
133 def quick_menu(repo_name):
134 return _render('quick_menu', repo_name)
135
136 def repo_lnk(name, rtype, private, fork_of):
137 return _render('repo_name', name, rtype, private, fork_of,
138 short_name=not admin, admin=False)
139
140 def last_change(last_change):
141 return _render("last_change", last_change)
142
143 def rss_lnk(repo_name):
144 return _render("rss", repo_name)
145
146 def atom_lnk(repo_name):
147 return _render("atom", repo_name)
148
149 def last_rev(repo_name, cs_cache):
150 return _render('revision', repo_name, cs_cache.get('revision'),
151 cs_cache.get('raw_id'), cs_cache.get('author'),
152 cs_cache.get('message'))
153
154 def desc(desc):
155 from pylons import tmpl_context as c
156 if c.visual.stylify_metatags:
157 return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
158 else:
159 return h.urlify_text(h.truncate(desc, 60))
160
161 def repo_actions(repo_name):
162 return _render('repo_actions', repo_name)
163
164 def owner_actions(user_id, username):
165 return _render('user_name', user_id, username)
166
167 repos_data = []
168 for repo in repos_list:
169 if perm_check:
170 # check permission at this level
171 if not HasRepoPermissionAny(
172 'repository.read', 'repository.write', 'repository.admin'
173 )(repo.repo_name, 'get_repos_as_dict check'):
174 continue
175 cs_cache = repo.changeset_cache
176 row = {
177 "menu": quick_menu(repo.repo_name),
178 "raw_name": repo.repo_name.lower(),
179 "name": repo_lnk(repo.repo_name, repo.repo_type,
180 repo.private, repo.fork),
181 "last_change": last_change(repo.last_db_change),
182 "last_changeset": last_rev(repo.repo_name, cs_cache),
183 "raw_tip": cs_cache.get('revision'),
184 "desc": desc(repo.description),
185 "owner": h.person(repo.user.username),
186 "rss": rss_lnk(repo.repo_name),
187 "atom": atom_lnk(repo.repo_name),
188
189 }
190 if admin:
191 row.update({
192 "action": repo_actions(repo.repo_name),
193 "owner": owner_actions(repo.user.user_id,
194 h.person(repo.user.username))
195 })
196 repos_data.append(row)
197
198 return {
199 "totalRecords": len(repos_list),
200 "startIndex": 0,
201 "sort": "name",
202 "dir": "asc",
203 "records": repos_data
204 }
205
116 206 def _get_defaults(self, repo_name):
117 207 """
118 208 Get's information about repository, and returns a dict for
@@ -3235,7 +3235,7 b' table.code-browser .submodule-dir {'
3235 3235 }
3236 3236
3237 3237 .edit_icon {
3238 background: url("../images/icons/folder_edit.png") no-repeat scroll 3px;
3238 background: url("../images/icons/application_form_edit.png") no-repeat scroll 3px;
3239 3239 padding-left: 20px;
3240 3240 padding-top: 0px;
3241 3241 text-align: left;
@@ -40,6 +40,7 b''
40 40 {key:"raw_name"},
41 41 {key:"name"},
42 42 {key:"desc"},
43 {key:"last_changeset"},
43 44 {key:"owner"},
44 45 {key:"action"},
45 46 ]
@@ -70,6 +71,8 b''
70 71 {key:"name",label:"${_('Name')}",sortable:true,
71 72 sortOptions: { sortFunction: nameSort }},
72 73 {key:"desc",label:"${_('Description')}",sortable:true},
74 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
75 sortOptions: { sortFunction: revisionSort }},
73 76 {key:"owner",label:"${_('Owner')}",sortable:true},
74 77 {key:"action",label:"${_('Action')}",sortable:false},
75 78 ];
@@ -77,7 +80,7 b''
77 80 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
78 81 sortedBy:{key:"name",dir:"asc"},
79 82 paginator: new YAHOO.widget.Paginator({
80 rowsPerPage: 15,
83 rowsPerPage: 25,
81 84 alwaysVisible: false,
82 85 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
83 86 pageLinks: 5,
@@ -111,7 +114,7 b''
111 114
112 115 // Reset sort
113 116 var state = myDataTable.getState();
114 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
117 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
115 118
116 119 // Get filtered data
117 120 myDataSource.sendRequest(YUD.get('q_filter').value,{
@@ -123,7 +126,11 b''
123 126
124 127 };
125 128 YUE.on('q_filter','click',function(){
126 YUD.get('q_filter').value = '';
129 if(!YUD.hasClass('q_filter', 'loaded')){
130 YUD.get('q_filter').value = '';
131 //TODO: load here full list later to do search within groups
132 YUD.addClass('q_filter', 'loaded');
133 }
127 134 });
128 135
129 136 YUE.on('q_filter','keyup',function (e) {
@@ -48,7 +48,7 b''
48 48 </ul>
49 49 </div>
50 50 <!-- end box / title -->
51 <div id="perms" class="table">
51 <div id="perms_container" class="table">
52 52 %for section in sorted(c.rhodecode_user.permissions.keys()):
53 53 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
54 54
@@ -94,30 +94,26 b''
94 94 </div>
95 95 %endfor
96 96 </div>
97 <div id="my" class="table" style="display:none">
97 <div id="my_container" style="display:none">
98 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
99 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
98 100 </div>
99 <div id="pullrequests" class="table" style="display:none"></div>
101 <div id="pullrequests_container" class="table" style="display:none">
102 ## loaded via AJAX
103 ${_('Loading...')}
104 </div>
100 105 </div>
101 106
102
103
104 107 <script type="text/javascript">
105 var filter_activate = function(){
106 var nodes = YUQ('#my tr td a.repo_name');
107 var func = function(node){
108 return node.parentNode.parentNode.parentNode.parentNode;
109 }
110 q_filter('q_filter',YUQ('#my tr td a.repo_name'),func);
111 }
112 108
113 109 var show_perms = function(e){
114 110 YUD.addClass('show_perms', 'current');
115 111 YUD.removeClass('show_my','current');
116 112 YUD.removeClass('show_pullrequests','current');
117 113
118 YUD.setStyle('my','display','none');
119 YUD.setStyle('pullrequests','display','none');
120 YUD.setStyle('perms','display','');
114 YUD.setStyle('my_container','display','none');
115 YUD.setStyle('pullrequests_container','display','none');
116 YUD.setStyle('perms_container','display','');
121 117 YUD.setStyle('q_filter','display','none');
122 118 }
123 119 YUE.on('show_perms','click',function(e){
@@ -129,17 +125,14 b' var show_my = function(e){'
129 125 YUD.removeClass('show_perms','current');
130 126 YUD.removeClass('show_pullrequests','current');
131 127
132 YUD.setStyle('perms','display','none');
133 YUD.setStyle('pullrequests','display','none');
134 YUD.setStyle('my','display','');
128 YUD.setStyle('perms_container','display','none');
129 YUD.setStyle('pullrequests_container','display','none');
130 YUD.setStyle('my_container','display','');
135 131 YUD.setStyle('q_filter','display','');
136
137
138 var url = "${h.url('journal_my_repos')}";
139 ypjax(url, 'my', function(){
140 table_sort();
141 filter_activate();
142 });
132 if(!YUD.hasClass('show_my', 'loaded')){
133 table_renderer(${c.data |n});
134 YUD.addClass('show_my', 'loaded');
135 }
143 136 }
144 137 YUE.on('show_my','click',function(e){
145 138 show_my(e);
@@ -150,13 +143,13 b' var show_pullrequests = function(e){'
150 143 YUD.removeClass('show_my','current');
151 144 YUD.removeClass('show_perms','current');
152 145
153 YUD.setStyle('my','display','none');
154 YUD.setStyle('perms','display','none');
155 YUD.setStyle('pullrequests','display','');
146 YUD.setStyle('my_container','display','none');
147 YUD.setStyle('perms_container','display','none');
148 YUD.setStyle('pullrequests_container','display','');
156 149 YUD.setStyle('q_filter','display','none');
157 150
158 151 var url = "${h.url('admin_settings_my_pullrequests')}";
159 ypjax(url, 'pullrequests');
152 ypjax(url, 'pullrequests_container');
160 153 }
161 154 YUE.on('show_pullrequests','click',function(e){
162 155 show_pullrequests(e)
@@ -177,72 +170,109 b' if (url[1]) {'
177 170 }
178 171 }
179 172
180 // main table sorting
181 var myColumnDefs = [
182 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
183 {key:"name",label:"${_('Name')}",sortable:true,
184 sortOptions: { sortFunction: nameSort }},
185 {key:"tip",label:"${_('Tip')}",sortable:true,
186 sortOptions: { sortFunction: revisionSort }},
187 {key:"action1",label:"",sortable:false},
188 {key:"action2",label:"",sortable:false},
189 ];
173 function table_renderer(data){
174 var myDataSource = new YAHOO.util.DataSource(data);
175 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
176
177 myDataSource.responseSchema = {
178 resultsList: "records",
179 fields: [
180 {key:"menu"},
181 {key:"raw_name"},
182 {key:"name"},
183 {key:"last_changeset"},
184 {key:"action"},
185 ]
186 };
187 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
188 // This is the filter function
189 var data = res.results || [],
190 filtered = [],
191 i,l;
192
193 if (req) {
194 req = req.toLowerCase();
195 for (i = 0; i<data.length; i++) {
196 var pos = data[i].raw_name.toLowerCase().indexOf(req)
197 if (pos != -1) {
198 filtered.push(data[i]);
199 }
200 }
201 res.results = filtered;
202 }
203 return res;
204 }
205
206 // main table sorting
207 var myColumnDefs = [
208 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
209 {key:"name",label:"${_('Name')}",sortable:true,
210 sortOptions: { sortFunction: nameSort }},
211 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
212 sortOptions: { sortFunction: revisionSort }},
213 {key:"action",label:"${_('Action')}",sortable:false},
214 ];
190 215
191 function table_sort(){
192 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list"));
193 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
194 myDataSource.responseSchema = {
195 fields: [
196 {key:"menu"},
197 {key:"name"},
198 {key:"tip"},
199 {key:"action1"},
200 {key:"action2"},
201 ]
202 };
203 var trans_defs = {
204 sortedBy:{key:"name",dir:"asc"},
205 MSG_SORTASC:"${_('Click to sort ascending')}",
206 MSG_SORTDESC:"${_('Click to sort descending')}",
207 MSG_EMPTY:"${_('No records found.')}",
208 MSG_ERROR:"${_('Data error.')}",
209 MSG_LOADING:"${_('Loading...')}",
210 }
211 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,trans_defs);
212 myDataTable.subscribe('postRenderEvent',function(oArgs) {
213 tooltip_activate();
214 quick_repo_menu();
215 filter_activate();
216 });
216 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
217 sortedBy:{key:"name",dir:"asc"},
218 paginator: new YAHOO.widget.Paginator({
219 rowsPerPage: 50,
220 alwaysVisible: false,
221 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
222 pageLinks: 5,
223 containerClass: 'pagination-wh',
224 currentPageClass: 'pager_curpage',
225 pageLinkClass: 'pager_link',
226 nextPageLinkLabel: '&gt;',
227 previousPageLinkLabel: '&lt;',
228 firstPageLinkLabel: '&lt;&lt;',
229 lastPageLinkLabel: '&gt;&gt;',
230 containers:['user-paginator']
231 }),
232
233 MSG_SORTASC:"${_('Click to sort ascending')}",
234 MSG_SORTDESC:"${_('Click to sort descending')}",
235 MSG_EMPTY:"${_('No records found.')}",
236 MSG_ERROR:"${_('Data error.')}",
237 MSG_LOADING:"${_('Loading...')}",
238 }
239 );
240 myDataTable.subscribe('postRenderEvent',function(oArgs) {
241 tooltip_activate();
242 quick_repo_menu();
243 });
244
245 var filterTimeout = null;
217 246
218 var permsColumnDefs = [
219 {key:"name",label:"${_('Name')}",sortable:true, sortOptions: { sortFunction: permNameSort }},
220 {key:"perm",label:"${_('Permission')}",sortable:false,},
221 ];
247 updateFilter = function() {
248 // Reset timeout
249 filterTimeout = null;
222 250
223 // perms repos table
224 var myDataSource2 = new YAHOO.util.DataSource(YUD.get("tbl_list_repositories"));
225 myDataSource2.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
226 myDataSource2.responseSchema = {
227 fields: [
228 {key:"name"},
229 {key:"perm"},
230 ]
231 };
251 // Reset sort
252 var state = myDataTable.getState();
253 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
232 254
233 new YAHOO.widget.DataTable("tbl_list_wrap_repositories", permsColumnDefs, myDataSource2, trans_defs);
255 // Get filtered data
256 myDataSource.sendRequest(YUD.get('q_filter').value,{
257 success : myDataTable.onDataReturnInitializeTable,
258 failure : myDataTable.onDataReturnInitializeTable,
259 scope : myDataTable,
260 argument: state
261 });
234 262
235 //perms groups table
236 var myDataSource3 = new YAHOO.util.DataSource(YUD.get("tbl_list_repositories_groups"));
237 myDataSource3.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
238 myDataSource3.responseSchema = {
239 fields: [
240 {key:"name"},
241 {key:"perm"},
242 ]
243 };
263 };
264 YUE.on('q_filter','click',function(){
265 if(!YUD.hasClass('q_filter', 'loaded')){
266 YUD.get('q_filter').value = '';
267 //TODO: load here full list later to do search within groups
268 YUD.addClass('q_filter', 'loaded');
269 }
270 });
244 271
245 new YAHOO.widget.DataTable("tbl_list_wrap_repositories_groups", permsColumnDefs, myDataSource3, trans_defs);
246 }
272 YUE.on('q_filter','keyup',function (e) {
273 clearTimeout(filterTimeout);
274 filterTimeout = setTimeout(updateFilter,600);
275 });
276 }
247 277 </script>
248 278 </%def>
@@ -1,46 +1,1 b''
1 <div id='repos_list_wrap' class="yui-skin-sam">
2 <table id="repos_list">
3 <thead>
4 <tr>
5 <th></th>
6 <th class="left">${_('Name')}</th>
7 <th class="left">${_('Revision')}</th>
8 <th class="left">${_('Action')}</th>
9 <th class="left">${_('Action')}</th>
10 </thead>
11 <tbody>
12 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
13 %if c.user_repos:
14 %for repo in c.user_repos:
15 <tr>
16 ##QUICK MENU
17 <td class="quick_repo_menu">
18 ${dt.quick_menu(repo['name'])}
19 </td>
20 ##REPO NAME AND ICONS
21 <td class="reponame">
22 ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']))}
23 </td>
24 ##LAST REVISION
25 <td>
26 ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
27 </td>
28 <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>
29 <td>
30 ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
31 ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")}
32 ${h.end_form()}
33 </td>
34 </tr>
35 %endfor
36 %else:
37 <div style="padding:5px 0px 10px 0px;">
38 ${_('No repositories yet')}
39 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
40 ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")}
41 %endif
42 </div>
43 %endif
44 </tbody>
45 </table>
46 </div>
1
@@ -2,12 +2,6 b''
2 2 ## usage:
3 3 ## <%namespace name="dt" file="/data_table/_dt_elements.html"/>
4 4
5 <%def name="repo_actions(repo_name)">
6 ${h.form(h.url('repo', repo_name=repo_name),method='delete')}
7 ${h.submit('remove_%s' % repo_name,_('delete'),class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo_name+"');")}
8 ${h.end_form()}
9 </%def>
10
11 5 <%def name="quick_menu(repo_name)">
12 6 <ul class="menu_items hidden">
13 7 <li style="border-top:1px solid #003367;margin-left:18px;padding-left:-99px"></li>
@@ -46,7 +40,7 b''
46 40 </ul>
47 41 </%def>
48 42
49 <%def name="repo_name(name,rtype,private,fork_of,short_name=False, admin=False)">
43 <%def name="repo_name(name,rtype,private,fork_of,short_name=False,admin=False)">
50 44 <%
51 45 def get_name(name,short_name=short_name):
52 46 if short_name:
@@ -116,6 +110,21 b''
116 110 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(email, size)}"/> </div>
117 111 </%def>
118 112
113 <%def name="repo_actions(repo_name)">
114 <div>
115 <div style="float:left">
116 <a href="${h.url('repo_settings_home',repo_name=repo_name)}" title="${_('edit')}">
117 ${h.submit('edit_%s' % repo_name,_('edit'),class_="edit_icon action_button")}
118 </a>
119 </div>
120 <div style="float:left">
121 ${h.form(h.url('repo', repo_name=repo_name),method='delete')}
122 ${h.submit('remove_%s' % repo_name,_('delete'),class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo_name+"');")}
123 ${h.end_form()}
124 </div>
125 </div>
126 </%def>
127
119 128 <%def name="user_actions(user_id, username)">
120 129 ${h.form(h.url('delete_user', id=user_id),method='delete')}
121 130 ${h.submit('remove_',_('delete'),id="remove_user_%s" % user_id,
@@ -126,3 +135,10 b''
126 135 <%def name="user_name(user_id, username)">
127 136 ${h.link_to(username,h.url('edit_user', id=user_id))}
128 137 </%def>
138
139 <%def name="toggle_follow(repo_id)">
140 <span id="follow_toggle_${repo_id}" class="following" title="${_('Stop following this repository')}"
141 onclick="javascript:toggleFollowingRepo(this, ${repo_id},'${str(h.get_token())}')">
142 </span>
143 </%def>
144
@@ -127,9 +127,6 b''
127 127 % if c.visual.lightweight_dashboard is False:
128 128 <script>
129 129 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
130 var func = function(node){
131 return node.parentNode.parentNode.parentNode.parentNode;
132 }
133 130
134 131 // groups table sorting
135 132 var myColumnDefs = [
@@ -214,13 +211,15 b''
214 211 myDataTable.subscribe('postRenderEvent',function(oArgs) {
215 212 tooltip_activate();
216 213 quick_repo_menu();
214 var func = function(node){
215 return node.parentNode.parentNode.parentNode.parentNode;
216 }
217 217 q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func);
218 218 });
219 219
220 220 </script>
221 221 % else:
222 222 <script>
223 //var url = "${h.url('formatted_users', format='json')}";
224 223 var data = ${c.data|n};
225 224 var myDataSource = new YAHOO.util.DataSource(data);
226 225 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
@@ -233,7 +232,7 b''
233 232 {key:"name"},
234 233 {key:"desc"},
235 234 {key:"last_change"},
236 {key: "tip"},
235 {key:"last_changeset"},
237 236 {key:"owner"},
238 237 {key:"rss"},
239 238 {key:"atom"},
@@ -267,7 +266,7 b''
267 266 {key:"desc",label:"${_('Description')}",sortable:true},
268 267 {key:"last_change",label:"${_('Last Change')}",sortable:true,
269 268 sortOptions: { sortFunction: ageSort }},
270 {key:"tip",label:"${_('Tip')}",sortable:true,
269 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
271 270 sortOptions: { sortFunction: revisionSort }},
272 271 {key:"owner",label:"${_('Owner')}",sortable:true},
273 272 {key:"rss",label:"",sortable:false},
@@ -311,7 +310,7 b''
311 310
312 311 // Reset sort
313 312 var state = myDataTable.getState();
314 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
313 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
315 314
316 315 // Get filtered data
317 316 myDataSource.sendRequest(YUD.get('q_filter').value,{
@@ -323,7 +322,11 b''
323 322
324 323 };
325 324 YUE.on('q_filter','click',function(){
326 YUD.get('q_filter').value = '';
325 if(!YUD.hasClass('q_filter', 'loaded')){
326 YUD.get('q_filter').value = '';
327 //TODO: load here full list later to do search within groups
328 YUD.addClass('q_filter', 'loaded');
329 }
327 330 });
328 331
329 332 YUE.on('q_filter','keyup',function (e) {
@@ -43,73 +43,36 b''
43 43 </div>
44 44 <div class="box box-right">
45 45 <!-- box / title -->
46
46 47 <div class="title">
47 48 <h5>
48 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
49 <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a> / <a id="show_my" class="link-white" href="#my">${_('My repos')}</a>
49 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
50 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
50 51 </h5>
51 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
52 <ul class="links">
52 <ul class="links" style="color:#DADADA">
53 53 <li>
54 <span>${h.link_to(_('ADD'),h.url('admin_settings_create_repository'))}</span>
54 <span><a id="show_watched" class="link-white current" href="#watched">${_('Watched')}</a> </span>
55 </li>
56 <li>
57 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
55 58 </li>
59 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
60 <li>
61 <span>${h.link_to(_('Add repo'),h.url('admin_settings_create_repository'))}</span>
62 </li>
63 %endif
56 64 </ul>
57 %endif
58 </div>
65 </div>
66
59 67 <!-- end box / title -->
60 <div id="my" class="table" style="display:none">
61 ## loaded via AJAX
62 ${_('Loading...')}
68 <div id="my_container" style="display:none">
69 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
70 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
63 71 </div>
64
65 <div id="watched" class="table">
66 %if c.following:
67 <table>
68 <thead>
69 <tr>
70 <th class="left">${_('Name')}</th>
71 </thead>
72 <tbody>
73 %for entry in c.following:
74 <tr>
75 <td>
76 %if entry.follows_user_id:
77 <img title="${_('following user')}" alt="${_('user')}" src="${h.url('/images/icons/user.png')}"/>
78 ${entry.follows_user.full_contact}
79 %endif
80
81 %if entry.follows_repo_id:
82 <div style="float:right;padding-right:5px">
83 <span id="follow_toggle_${entry.follows_repository.repo_id}" class="following" title="${_('Stop following this repository')}"
84 onclick="javascript:toggleFollowingRepo(this,${entry.follows_repository.repo_id},'${str(h.get_token())}')">
85 </span>
86 </div>
87
88 %if h.is_hg(entry.follows_repository):
89 <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
90 %elif h.is_git(entry.follows_repository):
91 <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
92 %endif
93
94 %if entry.follows_repository.private and c.visual.show_private_icon:
95 <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/>
96 %elif not entry.follows_repository.private and c.visual.show_public_icon:
97 <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
98 %endif
99 <span class="watched_repo">
100 ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',repo_name=entry.follows_repository.repo_name))}
101 </span>
102 %endif
103 </td>
104 </tr>
105 %endfor
106 </tbody>
107 </table>
108 %else:
109 <div style="padding:5px 0px 10px 0px;">
110 ${_('You are not following any users or repositories')}
111 </div>
112 %endif
72
73 <div id="watched_container">
74 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div>
75 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div>
113 76 </div>
114 77 </div>
115 78
@@ -134,29 +97,47 b''
134 97 });
135 98 fix_j_filter_width(YUD.get('j_filter').value.length);
136 99
137 var show_my = function(e){
138 YUD.setStyle('watched','display','none');
139 YUD.setStyle('my','display','');
140
141 var url = "${h.url('admin_settings_my_repos')}";
142 ypjax(url, 'my', function(){
100 YUE.on('refresh','click',function(e){
101 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
102 show_more_event();
143 103 tooltip_activate();
144 quick_repo_menu();
145 var nodes = YUQ('#my tr td a.repo_name');
146 var func = function(node){
147 return node.parentNode.parentNode.parentNode;
148 }
149 q_filter('q_filter',nodes,func);
150 });
104 show_changeset_tooltip();
105 });
106 YUE.preventDefault(e);
107 });
108
109 var show_my = function(e){
110 YUD.setStyle('watched_container','display','none');
111 YUD.setStyle('my_container','display','');
112 YUD.setStyle('q_filter','display','');
113 YUD.setStyle('q_filter_watched','display','none');
151 114
115 YUD.addClass('show_my', 'current');
116 YUD.removeClass('show_watched','current');
117
118 if(!YUD.hasClass('show_my', 'loaded')){
119 table_renderer(${c.data |n});
120 YUD.addClass('show_my', 'loaded');
121 }
152 122 }
153 123 YUE.on('show_my','click',function(e){
154 124 show_my(e);
155 125 })
156 126 var show_watched = function(e){
157 YUD.setStyle('my','display','none');
158 YUD.setStyle('watched','display','');
159 var nodes = YUQ('#watched .watched_repo a');
127 YUD.setStyle('my_container','display','none');
128 YUD.setStyle('watched_container','display','');
129 YUD.setStyle('q_filter_watched','display','');
130 YUD.setStyle('q_filter','display','none');
131
132 YUD.addClass('show_watched', 'current');
133 YUD.removeClass('show_my','current');
134 if(!YUD.hasClass('show_watched', 'loaded')){
135 watched_renderer(${c.watched_data |n});
136 YUD.addClass('show_watched', 'loaded');
137 }
138
139 return
140 var nodes = YUQ('#watched_container .watched_repo a');
160 141 var target = 'q_filter';
161 142 var func = function(node){
162 143 return node.parentNode.parentNode;
@@ -182,60 +163,213 b''
182 163 func();
183 164 }
184 165 }
166 function watched_renderer(data){
167 var myDataSource = new YAHOO.util.DataSource(data);
168 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
185 169
186 YUE.on('refresh','click',function(e){
187 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
188 show_more_event();
189 tooltip_activate();
190 show_changeset_tooltip();
191 });
192 YUE.preventDefault(e);
193 });
170 myDataSource.responseSchema = {
171 resultsList: "records",
172 fields: [
173 {key:"menu"},
174 {key:"raw_name"},
175 {key:"name"},
176 {key:"last_changeset"},
177 {key:"action"},
178 ]
179 };
180 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
181 // This is the filter function
182 var data = res.results || [],
183 filtered = [],
184 i,l;
194 185
186 if (req) {
187 req = req.toLowerCase();
188 for (i = 0; i<data.length; i++) {
189 var pos = data[i].raw_name.toLowerCase().indexOf(req)
190 if (pos != -1) {
191 filtered.push(data[i]);
192 }
193 }
194 res.results = filtered;
195 }
196 return res;
197 }
198 // main table sorting
199 var myColumnDefs = [
200 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
201 {key:"name",label:"${_('Name')}",sortable:true,
202 sortOptions: { sortFunction: nameSort }},
203 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
204 sortOptions: { sortFunction: revisionSort }},
205 {key:"action",label:"${_('Action')}",sortable:false},
206 ];
195 207
196 // main table sorting
197 var myColumnDefs = [
198 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
199 {key:"name",label:"${_('Name')}",sortable:true,
200 sortOptions: { sortFunction: nameSort }},
201 {key:"tip",label:"${_('Tip')}",sortable:true,
202 sortOptions: { sortFunction: revisionSort }},
203 {key:"action1",label:"",sortable:false},
204 {key:"action2",label:"",sortable:false},
205 ];
208 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{
209 sortedBy:{key:"name",dir:"asc"},
210 paginator: new YAHOO.widget.Paginator({
211 rowsPerPage: 25,
212 alwaysVisible: false,
213 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
214 pageLinks: 5,
215 containerClass: 'pagination-wh',
216 currentPageClass: 'pager_curpage',
217 pageLinkClass: 'pager_link',
218 nextPageLinkLabel: '&gt;',
219 previousPageLinkLabel: '&lt;',
220 firstPageLinkLabel: '&lt;&lt;',
221 lastPageLinkLabel: '&gt;&gt;',
222 containers:['watched-user-paginator']
223 }),
206 224
207 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list"));
225 MSG_SORTASC:"${_('Click to sort ascending')}",
226 MSG_SORTDESC:"${_('Click to sort descending')}",
227 MSG_EMPTY:"${_('No records found.')}",
228 MSG_ERROR:"${_('Data error.')}",
229 MSG_LOADING:"${_('Loading...')}",
230 }
231 );
232 myDataTable.subscribe('postRenderEvent',function(oArgs) {
233 tooltip_activate();
234 quick_repo_menu();
235 });
236
237 var filterTimeout = null;
238
239 updateFilter = function () {
240 // Reset timeout
241 filterTimeout = null;
208 242
209 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
243 // Reset sort
244 var state = myDataTable.getState();
245 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
246
247 // Get filtered data
248 myDataSource.sendRequest(YUD.get('q_filter_watched').value,{
249 success : myDataTable.onDataReturnInitializeTable,
250 failure : myDataTable.onDataReturnInitializeTable,
251 scope : myDataTable,
252 argument: state
253 });
254
255 };
256 YUE.on('q_filter_watched','click',function(){
257 if(!YUD.hasClass('q_filter_watched', 'loaded')){
258 YUD.get('q_filter_watched').value = '';
259 //TODO: load here full list later to do search within groups
260 YUD.addClass('q_filter_watched', 'loaded');
261 }
262 });
210 263
211 myDataSource.responseSchema = {
212 fields: [
213 {key:"menu"},
214 {key:"name"},
215 {key:"tip"},
216 {key:"action1"},
217 {key:"action2"}
218 ]
219 };
264 YUE.on('q_filter_watched','keyup',function (e) {
265 clearTimeout(filterTimeout);
266 filterTimeout = setTimeout(updateFilter,600);
267 });
268 }
269
270 function table_renderer(data){
271 var myDataSource = new YAHOO.util.DataSource(data);
272 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
273
274 myDataSource.responseSchema = {
275 resultsList: "records",
276 fields: [
277 {key:"menu"},
278 {key:"raw_name"},
279 {key:"name"},
280 {key:"last_changeset"},
281 {key:"action"},
282 ]
283 };
284 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
285 // This is the filter function
286 var data = res.results || [],
287 filtered = [],
288 i,l;
289
290 if (req) {
291 req = req.toLowerCase();
292 for (i = 0; i<data.length; i++) {
293 var pos = data[i].raw_name.toLowerCase().indexOf(req)
294 if (pos != -1) {
295 filtered.push(data[i]);
296 }
297 }
298 res.results = filtered;
299 }
300 return res;
301 }
302 // main table sorting
303 var myColumnDefs = [
304 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
305 {key:"name",label:"${_('Name')}",sortable:true,
306 sortOptions: { sortFunction: nameSort }},
307 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
308 sortOptions: { sortFunction: revisionSort }},
309 {key:"action",label:"${_('Action')}",sortable:false},
310 ];
220 311
221 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,
222 {
223 sortedBy:{key:"name",dir:"asc"},
224 MSG_SORTASC:"${_('Click to sort ascending')}",
225 MSG_SORTDESC:"${_('Click to sort descending')}",
226 MSG_EMPTY:"${_('No records found.')}",
227 MSG_ERROR:"${_('Data error.')}",
228 MSG_LOADING:"${_('Loading...')}",
312 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
313 sortedBy:{key:"name",dir:"asc"},
314 paginator: new YAHOO.widget.Paginator({
315 rowsPerPage: 25,
316 alwaysVisible: false,
317 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
318 pageLinks: 5,
319 containerClass: 'pagination-wh',
320 currentPageClass: 'pager_curpage',
321 pageLinkClass: 'pager_link',
322 nextPageLinkLabel: '&gt;',
323 previousPageLinkLabel: '&lt;',
324 firstPageLinkLabel: '&lt;&lt;',
325 lastPageLinkLabel: '&gt;&gt;',
326 containers:['user-paginator']
327 }),
328
329 MSG_SORTASC:"${_('Click to sort ascending')}",
330 MSG_SORTDESC:"${_('Click to sort descending')}",
331 MSG_EMPTY:"${_('No records found.')}",
332 MSG_ERROR:"${_('Data error.')}",
333 MSG_LOADING:"${_('Loading...')}",
334 }
335 );
336 myDataTable.subscribe('postRenderEvent',function(oArgs) {
337 tooltip_activate();
338 quick_repo_menu();
339 });
340
341 var filterTimeout = null;
342
343 updateFilter = function () {
344 // Reset timeout
345 filterTimeout = null;
346
347 // Reset sort
348 var state = myDataTable.getState();
349 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
350
351 // Get filtered data
352 myDataSource.sendRequest(YUD.get('q_filter').value,{
353 success : myDataTable.onDataReturnInitializeTable,
354 failure : myDataTable.onDataReturnInitializeTable,
355 scope : myDataTable,
356 argument: state
357 });
358
359 };
360 YUE.on('q_filter','click',function(){
361 if(!YUD.hasClass('q_filter', 'loaded')){
362 YUD.get('q_filter').value = '';
363 //TODO: load here full list later to do search within groups
364 YUD.addClass('q_filter', 'loaded');
229 365 }
230 );
231 myDataTable.subscribe('postRenderEvent',function(oArgs) {
232 tooltip_activate();
233 quick_repo_menu();
234 var func = function(node){
235 return node.parentNode.parentNode.parentNode.parentNode;
236 }
237 q_filter('q_filter',YUQ('#my tr td a.repo_name'),func);
238 });
366 });
239 367
368 YUE.on('q_filter','keyup',function (e) {
369 clearTimeout(filterTimeout);
370 filterTimeout = setTimeout(updateFilter,600);
371 });
372 }
373
240 374 </script>
241 375 </%def>
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now