##// 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 m.connect('api', '/api')
359 m.connect('api', '/api')
360
360
361 #USER JOURNAL
361 #USER JOURNAL
362 rmap.connect('journal_my_repos', '%s/journal_my_repos' % ADMIN_PREFIX,
363 controller='journal', action='index_my_repos')
364 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
362 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
365 controller='journal', action='index')
363 controller='journal', action='index')
366 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
364 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
@@ -135,40 +135,10 b' class ReposController(BaseController):'
135 .order_by(func.lower(Repository.repo_name))\
135 .order_by(func.lower(Repository.repo_name))\
136 .all()
136 .all()
137
137
138 repos_data = []
138 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
139 total_records = len(c.repos_list)
139 admin=True)
140
140 #json used to render the grid
141 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
141 c.data = json.dumps(repos_data)
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 })
172
142
173 return render('admin/repos/repos.html')
143 return render('admin/repos/repos.html')
174
144
@@ -295,54 +295,18 b' class ReposGroupsController(BaseControll'
295 c.groups = self.scm_model.get_repos_groups(groups)
295 c.groups = self.scm_model.get_repos_groups(groups)
296
296
297 if c.visual.lightweight_dashboard is False:
297 if c.visual.lightweight_dashboard is False:
298 c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
298 c.repo_list = self.scm_model.get_repos(all_repos=gr_filter)
299
300 c.repos_list = c.cached_repo_list
301 ## lightweight version of dashboard
299 ## lightweight version of dashboard
302 else:
300 else:
303 c.repos_list = Repository.query()\
301 c.repos_list = Repository.query()\
304 .filter(Repository.group_id == id)\
302 .filter(Repository.group_id == id)\
305 .order_by(func.lower(Repository.repo_name))\
303 .order_by(func.lower(Repository.repo_name))\
306 .all()
304 .all()
307 repos_data = []
308 total_records = len(c.repos_list)
309
305
310 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
306 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
311 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
307 admin=False)
312
308 #json used to render the grid
313 quick_menu = lambda repo_name: (template.get_def("quick_menu")
309 c.data = json.dumps(repos_data)
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 })
346
310
347 return render('admin/repos_groups/repos_groups.html')
311 return render('admin/repos_groups/repos_groups.html')
348
312
@@ -48,11 +48,12 b' from rhodecode.model.forms import UserFo'
48 ApplicationUiSettingsForm, ApplicationVisualisationForm
48 ApplicationUiSettingsForm, ApplicationVisualisationForm
49 from rhodecode.model.scm import ScmModel
49 from rhodecode.model.scm import ScmModel
50 from rhodecode.model.user import UserModel
50 from rhodecode.model.user import UserModel
51 from rhodecode.model.repo import RepoModel
51 from rhodecode.model.db import User
52 from rhodecode.model.db import User
52 from rhodecode.model.notification import EmailNotificationModel
53 from rhodecode.model.notification import EmailNotificationModel
53 from rhodecode.model.meta import Session
54 from rhodecode.model.meta import Session
54 from rhodecode.lib.utils2 import str2bool, safe_unicode
55 from rhodecode.lib.utils2 import str2bool, safe_unicode
55
56 from rhodecode.lib.compat import json
56 log = logging.getLogger(__name__)
57 log = logging.getLogger(__name__)
57
58
58
59
@@ -390,17 +391,22 b' class SettingsController(BaseController)'
390 # url('admin_settings_my_account')
391 # url('admin_settings_my_account')
391
392
392 c.user = User.get(self.rhodecode_user.user_id)
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 if c.user.username == 'default':
395 if c.user.username == 'default':
400 h.flash(_("You can't edit this user since it's"
396 h.flash(_("You can't edit this user since it's"
401 " crucial for entire application"), category='warning')
397 " crucial for entire application"), category='warning')
402 return redirect(url('users'))
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 defaults = c.user.get_dict()
410 defaults = c.user.get_dict()
405
411
406 c.form = htmlfill.render(
412 c.form = htmlfill.render(
@@ -449,15 +455,6 b' class SettingsController(BaseController)'
449 return redirect(url('my_account'))
455 return redirect(url('my_account'))
450
456
451 @NotAnonymous()
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 def my_account_my_pullrequests(self):
458 def my_account_my_pullrequests(self):
462 c.my_pull_requests = PullRequest.query()\
459 c.my_pull_requests = PullRequest.query()\
463 .filter(PullRequest.user_id==
460 .filter(PullRequest.user_id ==
@@ -28,6 +28,7 b' import logging'
28 from pylons import tmpl_context as c, request
28 from pylons import tmpl_context as c, request
29 from pylons.i18n.translation import _
29 from pylons.i18n.translation import _
30 from webob.exc import HTTPBadRequest
30 from webob.exc import HTTPBadRequest
31 from sqlalchemy.sql.expression import func
31
32
32 import rhodecode
33 import rhodecode
33 from rhodecode.lib import helpers as h
34 from rhodecode.lib import helpers as h
@@ -35,7 +36,8 b' from rhodecode.lib.ext_json import json'
35 from rhodecode.lib.auth import LoginRequired
36 from rhodecode.lib.auth import LoginRequired
36 from rhodecode.lib.base import BaseController, render
37 from rhodecode.lib.base import BaseController, render
37 from rhodecode.model.db import Repository
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 log = logging.getLogger(__name__)
42 log = logging.getLogger(__name__)
41
43
@@ -58,59 +60,11 b' class HomeController(BaseController):'
58 .filter(Repository.group_id == None)\
60 .filter(Repository.group_id == None)\
59 .order_by(func.lower(Repository.repo_name))\
61 .order_by(func.lower(Repository.repo_name))\
60 .all()
62 .all()
61 repos_data = []
62 total_records = len(c.repos_list)
63
63
64 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
64 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
65 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
65 admin=False)
66
66 #json used to render the grid
67 quick_menu = lambda repo_name: (template.get_def("quick_menu")
67 c.data = json.dumps(repos_data)
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 })
114
68
115 return render('/index.html')
69 return render('/index.html')
116
70
@@ -27,6 +27,8 b' from itertools import groupby'
27
27
28 from sqlalchemy import or_
28 from sqlalchemy import or_
29 from sqlalchemy.orm import joinedload
29 from sqlalchemy.orm import joinedload
30 from sqlalchemy.sql.expression import func
31
30 from webhelpers.paginate import Page
32 from webhelpers.paginate import Page
31 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
33 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
32
34
@@ -39,10 +41,10 b' from rhodecode.lib.auth import LoginRequ'
39 from rhodecode.lib.base import BaseController, render
41 from rhodecode.lib.base import BaseController, render
40 from rhodecode.model.db import UserLog, UserFollowing, Repository, User
42 from rhodecode.model.db import UserLog, UserFollowing, Repository, User
41 from rhodecode.model.meta import Session
43 from rhodecode.model.meta import Session
42 from sqlalchemy.sql.expression import func
43 from rhodecode.model.scm import ScmModel
44 from rhodecode.lib.utils2 import safe_int, AttributeDict
44 from rhodecode.lib.utils2 import safe_int, AttributeDict
45 from rhodecode.controllers.admin.admin import _journal_filter
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 log = logging.getLogger(__name__)
49 log = logging.getLogger(__name__)
48
50
@@ -78,18 +80,73 b' class JournalController(BaseController):'
78 c.journal_data = render('journal/journal_data.html')
80 c.journal_data = render('journal/journal_data.html')
79 if request.environ.get('HTTP_X_PARTIAL_XHR'):
81 if request.environ.get('HTTP_X_PARTIAL_XHR'):
80 return c.journal_data
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()
111 def desc(desc):
84 @NotAnonymous()
112 from pylons import tmpl_context as c
85 def index_my_repos(self):
113 if c.visual.stylify_metatags:
86 c.user = User.get(self.rhodecode_user.user_id)
114 return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
87 if request.environ.get('HTTP_X_PARTIAL_XHR'):
115 else:
88 all_repos = self.sa.query(Repository)\
116 return h.urlify_text(h.truncate(desc, 60))
89 .filter(Repository.user_id == c.user.user_id)\
117
90 .order_by(func.lower(Repository.repo_name)).all()
118 def repo_actions(repo_name):
91 c.user_repos = ScmModel().get_repos(all_repos)
119 return _render('repo_actions', repo_name)
92 return render('journal/journal_page_repos.html')
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 @LoginRequired(api_access=True)
151 @LoginRequired(api_access=True)
95 @NotAnonymous()
152 @NotAnonymous()
@@ -41,6 +41,7 b' from rhodecode.model.db import Repositor'
41 Statistics, UsersGroup, UsersGroupRepoToPerm, RhodeCodeUi, RepoGroup,\
41 Statistics, UsersGroup, UsersGroupRepoToPerm, RhodeCodeUi, RepoGroup,\
42 RhodeCodeSetting
42 RhodeCodeSetting
43 from rhodecode.lib import helpers as h
43 from rhodecode.lib import helpers as h
44 from rhodecode.lib.auth import HasRepoPermissionAny
44
45
45
46
46 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
@@ -113,6 +114,95 b' class RepoModel(BaseModel):'
113 } for gr in users_groups]
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 def _get_defaults(self, repo_name):
206 def _get_defaults(self, repo_name):
117 """
207 """
118 Get's information about repository, and returns a dict for
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 .edit_icon {
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 padding-left: 20px;
3239 padding-left: 20px;
3240 padding-top: 0px;
3240 padding-top: 0px;
3241 text-align: left;
3241 text-align: left;
@@ -40,6 +40,7 b''
40 {key:"raw_name"},
40 {key:"raw_name"},
41 {key:"name"},
41 {key:"name"},
42 {key:"desc"},
42 {key:"desc"},
43 {key:"last_changeset"},
43 {key:"owner"},
44 {key:"owner"},
44 {key:"action"},
45 {key:"action"},
45 ]
46 ]
@@ -70,6 +71,8 b''
70 {key:"name",label:"${_('Name')}",sortable:true,
71 {key:"name",label:"${_('Name')}",sortable:true,
71 sortOptions: { sortFunction: nameSort }},
72 sortOptions: { sortFunction: nameSort }},
72 {key:"desc",label:"${_('Description')}",sortable:true},
73 {key:"desc",label:"${_('Description')}",sortable:true},
74 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
75 sortOptions: { sortFunction: revisionSort }},
73 {key:"owner",label:"${_('Owner')}",sortable:true},
76 {key:"owner",label:"${_('Owner')}",sortable:true},
74 {key:"action",label:"${_('Action')}",sortable:false},
77 {key:"action",label:"${_('Action')}",sortable:false},
75 ];
78 ];
@@ -77,7 +80,7 b''
77 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
80 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
78 sortedBy:{key:"name",dir:"asc"},
81 sortedBy:{key:"name",dir:"asc"},
79 paginator: new YAHOO.widget.Paginator({
82 paginator: new YAHOO.widget.Paginator({
80 rowsPerPage: 15,
83 rowsPerPage: 25,
81 alwaysVisible: false,
84 alwaysVisible: false,
82 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
85 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
83 pageLinks: 5,
86 pageLinks: 5,
@@ -123,7 +126,11 b''
123
126
124 };
127 };
125 YUE.on('q_filter','click',function(){
128 YUE.on('q_filter','click',function(){
129 if(!YUD.hasClass('q_filter', 'loaded')){
126 YUD.get('q_filter').value = '';
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 YUE.on('q_filter','keyup',function (e) {
136 YUE.on('q_filter','keyup',function (e) {
@@ -48,7 +48,7 b''
48 </ul>
48 </ul>
49 </div>
49 </div>
50 <!-- end box / title -->
50 <!-- end box / title -->
51 <div id="perms" class="table">
51 <div id="perms_container" class="table">
52 %for section in sorted(c.rhodecode_user.permissions.keys()):
52 %for section in sorted(c.rhodecode_user.permissions.keys()):
53 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
53 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
54
54
@@ -94,30 +94,26 b''
94 </div>
94 </div>
95 %endfor
95 %endfor
96 </div>
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 </div>
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...')}
100 </div>
104 </div>
101
105 </div>
102
103
106
104 <script type="text/javascript">
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 var show_perms = function(e){
109 var show_perms = function(e){
114 YUD.addClass('show_perms', 'current');
110 YUD.addClass('show_perms', 'current');
115 YUD.removeClass('show_my','current');
111 YUD.removeClass('show_my','current');
116 YUD.removeClass('show_pullrequests','current');
112 YUD.removeClass('show_pullrequests','current');
117
113
118 YUD.setStyle('my','display','none');
114 YUD.setStyle('my_container','display','none');
119 YUD.setStyle('pullrequests','display','none');
115 YUD.setStyle('pullrequests_container','display','none');
120 YUD.setStyle('perms','display','');
116 YUD.setStyle('perms_container','display','');
121 YUD.setStyle('q_filter','display','none');
117 YUD.setStyle('q_filter','display','none');
122 }
118 }
123 YUE.on('show_perms','click',function(e){
119 YUE.on('show_perms','click',function(e){
@@ -129,17 +125,14 b' var show_my = function(e){'
129 YUD.removeClass('show_perms','current');
125 YUD.removeClass('show_perms','current');
130 YUD.removeClass('show_pullrequests','current');
126 YUD.removeClass('show_pullrequests','current');
131
127
132 YUD.setStyle('perms','display','none');
128 YUD.setStyle('perms_container','display','none');
133 YUD.setStyle('pullrequests','display','none');
129 YUD.setStyle('pullrequests_container','display','none');
134 YUD.setStyle('my','display','');
130 YUD.setStyle('my_container','display','');
135 YUD.setStyle('q_filter','display','');
131 YUD.setStyle('q_filter','display','');
136
132 if(!YUD.hasClass('show_my', 'loaded')){
137
133 table_renderer(${c.data |n});
138 var url = "${h.url('journal_my_repos')}";
134 YUD.addClass('show_my', 'loaded');
139 ypjax(url, 'my', function(){
135 }
140 table_sort();
141 filter_activate();
142 });
143 }
136 }
144 YUE.on('show_my','click',function(e){
137 YUE.on('show_my','click',function(e){
145 show_my(e);
138 show_my(e);
@@ -150,13 +143,13 b' var show_pullrequests = function(e){'
150 YUD.removeClass('show_my','current');
143 YUD.removeClass('show_my','current');
151 YUD.removeClass('show_perms','current');
144 YUD.removeClass('show_perms','current');
152
145
153 YUD.setStyle('my','display','none');
146 YUD.setStyle('my_container','display','none');
154 YUD.setStyle('perms','display','none');
147 YUD.setStyle('perms_container','display','none');
155 YUD.setStyle('pullrequests','display','');
148 YUD.setStyle('pullrequests_container','display','');
156 YUD.setStyle('q_filter','display','none');
149 YUD.setStyle('q_filter','display','none');
157
150
158 var url = "${h.url('admin_settings_my_pullrequests')}";
151 var url = "${h.url('admin_settings_my_pullrequests')}";
159 ypjax(url, 'pullrequests');
152 ypjax(url, 'pullrequests_container');
160 }
153 }
161 YUE.on('show_pullrequests','click',function(e){
154 YUE.on('show_pullrequests','click',function(e){
162 show_pullrequests(e)
155 show_pullrequests(e)
@@ -177,72 +170,109 b' if (url[1]) {'
177 }
170 }
178 }
171 }
179
172
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
180 // main table sorting
206 // main table sorting
181 var myColumnDefs = [
207 var myColumnDefs = [
182 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
208 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
183 {key:"name",label:"${_('Name')}",sortable:true,
209 {key:"name",label:"${_('Name')}",sortable:true,
184 sortOptions: { sortFunction: nameSort }},
210 sortOptions: { sortFunction: nameSort }},
185 {key:"tip",label:"${_('Tip')}",sortable:true,
211 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
186 sortOptions: { sortFunction: revisionSort }},
212 sortOptions: { sortFunction: revisionSort }},
187 {key:"action1",label:"",sortable:false},
213 {key:"action",label:"${_('Action')}",sortable:false},
188 {key:"action2",label:"",sortable:false},
189 ];
214 ];
190
215
191 function table_sort(){
216 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
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"},
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
205 MSG_SORTASC:"${_('Click to sort ascending')}",
233 MSG_SORTASC:"${_('Click to sort ascending')}",
206 MSG_SORTDESC:"${_('Click to sort descending')}",
234 MSG_SORTDESC:"${_('Click to sort descending')}",
207 MSG_EMPTY:"${_('No records found.')}",
235 MSG_EMPTY:"${_('No records found.')}",
208 MSG_ERROR:"${_('Data error.')}",
236 MSG_ERROR:"${_('Data error.')}",
209 MSG_LOADING:"${_('Loading...')}",
237 MSG_LOADING:"${_('Loading...')}",
210 }
238 }
211 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,trans_defs);
239 );
212 myDataTable.subscribe('postRenderEvent',function(oArgs) {
240 myDataTable.subscribe('postRenderEvent',function(oArgs) {
213 tooltip_activate();
241 tooltip_activate();
214 quick_repo_menu();
242 quick_repo_menu();
215 filter_activate();
216 });
243 });
217
244
218 var permsColumnDefs = [
245 var filterTimeout = null;
219 {key:"name",label:"${_('Name')}",sortable:true, sortOptions: { sortFunction: permNameSort }},
246
220 {key:"perm",label:"${_('Permission')}",sortable:false,},
247 updateFilter = function() {
221 ];
248 // Reset timeout
249 filterTimeout = null;
222
250
223 // perms repos table
251 // Reset sort
224 var myDataSource2 = new YAHOO.util.DataSource(YUD.get("tbl_list_repositories"));
252 var state = myDataTable.getState();
225 myDataSource2.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
253 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
226 myDataSource2.responseSchema = {
254
227 fields: [
255 // Get filtered data
228 {key:"name"},
256 myDataSource.sendRequest(YUD.get('q_filter').value,{
229 {key:"perm"},
257 success : myDataTable.onDataReturnInitializeTable,
230 ]
258 failure : myDataTable.onDataReturnInitializeTable,
259 scope : myDataTable,
260 argument: state
261 });
262
231 };
263 };
232
264 YUE.on('q_filter','click',function(){
233 new YAHOO.widget.DataTable("tbl_list_wrap_repositories", permsColumnDefs, myDataSource2, trans_defs);
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 });
234
271
235 //perms groups table
272 YUE.on('q_filter','keyup',function (e) {
236 var myDataSource3 = new YAHOO.util.DataSource(YUD.get("tbl_list_repositories_groups"));
273 clearTimeout(filterTimeout);
237 myDataSource3.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
274 filterTimeout = setTimeout(updateFilter,600);
238 myDataSource3.responseSchema = {
275 });
239 fields: [
240 {key:"name"},
241 {key:"perm"},
242 ]
243 };
244
245 new YAHOO.widget.DataTable("tbl_list_wrap_repositories_groups", permsColumnDefs, myDataSource3, trans_defs);
246 }
276 }
247 </script>
277 </script>
248 </%def>
278 </%def>
@@ -1,46 +1,1 b''
1 <div id='repos_list_wrap' class="yui-skin-sam">
1
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>
@@ -2,12 +2,6 b''
2 ## usage:
2 ## usage:
3 ## <%namespace name="dt" file="/data_table/_dt_elements.html"/>
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 <%def name="quick_menu(repo_name)">
5 <%def name="quick_menu(repo_name)">
12 <ul class="menu_items hidden">
6 <ul class="menu_items hidden">
13 <li style="border-top:1px solid #003367;margin-left:18px;padding-left:-99px"></li>
7 <li style="border-top:1px solid #003367;margin-left:18px;padding-left:-99px"></li>
@@ -116,6 +110,21 b''
116 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(email, size)}"/> </div>
110 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(email, size)}"/> </div>
117 </%def>
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 <%def name="user_actions(user_id, username)">
128 <%def name="user_actions(user_id, username)">
120 ${h.form(h.url('delete_user', id=user_id),method='delete')}
129 ${h.form(h.url('delete_user', id=user_id),method='delete')}
121 ${h.submit('remove_',_('delete'),id="remove_user_%s" % user_id,
130 ${h.submit('remove_',_('delete'),id="remove_user_%s" % user_id,
@@ -126,3 +135,10 b''
126 <%def name="user_name(user_id, username)">
135 <%def name="user_name(user_id, username)">
127 ${h.link_to(username,h.url('edit_user', id=user_id))}
136 ${h.link_to(username,h.url('edit_user', id=user_id))}
128 </%def>
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 % if c.visual.lightweight_dashboard is False:
127 % if c.visual.lightweight_dashboard is False:
128 <script>
128 <script>
129 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
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 // groups table sorting
131 // groups table sorting
135 var myColumnDefs = [
132 var myColumnDefs = [
@@ -214,13 +211,15 b''
214 myDataTable.subscribe('postRenderEvent',function(oArgs) {
211 myDataTable.subscribe('postRenderEvent',function(oArgs) {
215 tooltip_activate();
212 tooltip_activate();
216 quick_repo_menu();
213 quick_repo_menu();
214 var func = function(node){
215 return node.parentNode.parentNode.parentNode.parentNode;
216 }
217 q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func);
217 q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func);
218 });
218 });
219
219
220 </script>
220 </script>
221 % else:
221 % else:
222 <script>
222 <script>
223 //var url = "${h.url('formatted_users', format='json')}";
224 var data = ${c.data|n};
223 var data = ${c.data|n};
225 var myDataSource = new YAHOO.util.DataSource(data);
224 var myDataSource = new YAHOO.util.DataSource(data);
226 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
225 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
@@ -233,7 +232,7 b''
233 {key:"name"},
232 {key:"name"},
234 {key:"desc"},
233 {key:"desc"},
235 {key:"last_change"},
234 {key:"last_change"},
236 {key: "tip"},
235 {key:"last_changeset"},
237 {key:"owner"},
236 {key:"owner"},
238 {key:"rss"},
237 {key:"rss"},
239 {key:"atom"},
238 {key:"atom"},
@@ -267,7 +266,7 b''
267 {key:"desc",label:"${_('Description')}",sortable:true},
266 {key:"desc",label:"${_('Description')}",sortable:true},
268 {key:"last_change",label:"${_('Last Change')}",sortable:true,
267 {key:"last_change",label:"${_('Last Change')}",sortable:true,
269 sortOptions: { sortFunction: ageSort }},
268 sortOptions: { sortFunction: ageSort }},
270 {key:"tip",label:"${_('Tip')}",sortable:true,
269 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
271 sortOptions: { sortFunction: revisionSort }},
270 sortOptions: { sortFunction: revisionSort }},
272 {key:"owner",label:"${_('Owner')}",sortable:true},
271 {key:"owner",label:"${_('Owner')}",sortable:true},
273 {key:"rss",label:"",sortable:false},
272 {key:"rss",label:"",sortable:false},
@@ -323,7 +322,11 b''
323
322
324 };
323 };
325 YUE.on('q_filter','click',function(){
324 YUE.on('q_filter','click',function(){
325 if(!YUD.hasClass('q_filter', 'loaded')){
326 YUD.get('q_filter').value = '';
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 YUE.on('q_filter','keyup',function (e) {
332 YUE.on('q_filter','keyup',function (e) {
@@ -43,73 +43,36 b''
43 </div>
43 </div>
44 <div class="box box-right">
44 <div class="box box-right">
45 <!-- box / title -->
45 <!-- box / title -->
46
46 <div class="title">
47 <div class="title">
47 <h5>
48 <h5>
48 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
49 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
49 <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a> / <a id="show_my" class="link-white" href="#my">${_('My repos')}</a>
50 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
50 </h5>
51 </h5>
51 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
52 <ul class="links" style="color:#DADADA">
52 <ul class="links">
53 <li>
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>
55 </li>
56 </ul>
56 <li>
57 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
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>
57 %endif
63 %endif
58 </div>
64 </ul>
59 <!-- end box / title -->
60 <div id="my" class="table" style="display:none">
61 ## loaded via AJAX
62 ${_('Loading...')}
63 </div>
65 </div>
64
66
65 <div id="watched" class="table">
67 <!-- end box / title -->
66 %if c.following:
68 <div id="my_container" style="display:none">
67 <table>
69 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
68 <thead>
70 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
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>
71 </div>
87
72
88 %if h.is_hg(entry.follows_repository):
73 <div id="watched_container">
89 <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
74 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div>
90 %elif h.is_git(entry.follows_repository):
75 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div>
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
113 </div>
76 </div>
114 </div>
77 </div>
115
78
@@ -134,29 +97,47 b''
134 });
97 });
135 fix_j_filter_width(YUD.get('j_filter').value.length);
98 fix_j_filter_width(YUD.get('j_filter').value.length);
136
99
137 var show_my = function(e){
100 YUE.on('refresh','click',function(e){
138 YUD.setStyle('watched','display','none');
101 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
139 YUD.setStyle('my','display','');
102 show_more_event();
140
141 var url = "${h.url('admin_settings_my_repos')}";
142 ypjax(url, 'my', function(){
143 tooltip_activate();
103 tooltip_activate();
144 quick_repo_menu();
104 show_changeset_tooltip();
145 var nodes = YUQ('#my tr td a.repo_name');
105 });
146 var func = function(node){
106 YUE.preventDefault(e);
147 return node.parentNode.parentNode.parentNode;
148 }
149 q_filter('q_filter',nodes,func);
150 });
107 });
151
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');
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 YUE.on('show_my','click',function(e){
123 YUE.on('show_my','click',function(e){
154 show_my(e);
124 show_my(e);
155 })
125 })
156 var show_watched = function(e){
126 var show_watched = function(e){
157 YUD.setStyle('my','display','none');
127 YUD.setStyle('my_container','display','none');
158 YUD.setStyle('watched','display','');
128 YUD.setStyle('watched_container','display','');
159 var nodes = YUQ('#watched .watched_repo a');
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 var target = 'q_filter';
141 var target = 'q_filter';
161 var func = function(node){
142 var func = function(node){
162 return node.parentNode.parentNode;
143 return node.parentNode.parentNode;
@@ -182,45 +163,65 b''
182 func();
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){
170 myDataSource.responseSchema = {
187 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
171 resultsList: "records",
188 show_more_event();
172 fields: [
189 tooltip_activate();
173 {key:"menu"},
190 show_changeset_tooltip();
174 {key:"raw_name"},
191 });
175 {key:"name"},
192 YUE.preventDefault(e);
176 {key:"last_changeset"},
193 });
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
195
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 }
196 // main table sorting
198 // main table sorting
197 var myColumnDefs = [
199 var myColumnDefs = [
198 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
200 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
199 {key:"name",label:"${_('Name')}",sortable:true,
201 {key:"name",label:"${_('Name')}",sortable:true,
200 sortOptions: { sortFunction: nameSort }},
202 sortOptions: { sortFunction: nameSort }},
201 {key:"tip",label:"${_('Tip')}",sortable:true,
203 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
202 sortOptions: { sortFunction: revisionSort }},
204 sortOptions: { sortFunction: revisionSort }},
203 {key:"action1",label:"",sortable:false},
205 {key:"action",label:"${_('Action')}",sortable:false},
204 {key:"action2",label:"",sortable:false},
205 ];
206 ];
206
207
207 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list"));
208 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{
208
209 sortedBy:{key:"name",dir:"asc"},
209 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
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 }),
210
224
211 myDataSource.responseSchema = {
212 fields: [
213 {key:"menu"},
214 {key:"name"},
215 {key:"tip"},
216 {key:"action1"},
217 {key:"action2"}
218 ]
219 };
220
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_SORTASC:"${_('Click to sort ascending')}",
225 MSG_SORTDESC:"${_('Click to sort descending')}",
226 MSG_SORTDESC:"${_('Click to sort descending')}",
226 MSG_EMPTY:"${_('No records found.')}",
227 MSG_EMPTY:"${_('No records found.')}",
@@ -231,11 +232,144 b''
231 myDataTable.subscribe('postRenderEvent',function(oArgs) {
232 myDataTable.subscribe('postRenderEvent',function(oArgs) {
232 tooltip_activate();
233 tooltip_activate();
233 quick_repo_menu();
234 quick_repo_menu();
234 var func = function(node){
235 });
235 return node.parentNode.parentNode.parentNode.parentNode;
236
237 var filterTimeout = null;
238
239 updateFilter = function () {
240 // Reset timeout
241 filterTimeout = null;
242
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 });
263
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;
236 }
301 }
237 q_filter('q_filter',YUQ('#my tr td a.repo_name'),func);
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 ];
311
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();
238 });
339 });
239
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');
365 }
366 });
367
368 YUE.on('q_filter','keyup',function (e) {
369 clearTimeout(filterTimeout);
370 filterTimeout = setTimeout(updateFilter,600);
371 });
372 }
373
240 </script>
374 </script>
241 </%def>
375 </%def>
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now