Show More
@@ -44,6 +44,14 b' def includeme(config):' | |||||
44 | pattern='/') |
|
44 | pattern='/') | |
45 |
|
45 | |||
46 | config.add_route( |
|
46 | config.add_route( | |
|
47 | name='main_page_repos_data', | |||
|
48 | pattern='/_home_repos') | |||
|
49 | ||||
|
50 | config.add_route( | |||
|
51 | name='main_page_repo_groups_data', | |||
|
52 | pattern='/_home_repo_groups') | |||
|
53 | ||||
|
54 | config.add_route( | |||
47 | name='user_autocomplete_data', |
|
55 | name='user_autocomplete_data', | |
48 | pattern='/_users') |
|
56 | pattern='/_users') | |
49 |
|
57 |
@@ -22,29 +22,30 b' import re' | |||||
22 | import logging |
|
22 | import logging | |
23 | import collections |
|
23 | import collections | |
24 |
|
24 | |||
|
25 | from pyramid.httpexceptions import HTTPNotFound | |||
25 | from pyramid.view import view_config |
|
26 | from pyramid.view import view_config | |
26 |
|
27 | |||
27 | from rhodecode.apps._base import BaseAppView |
|
28 | from rhodecode.apps._base import BaseAppView, DataGridAppView | |
28 | from rhodecode.lib import helpers as h |
|
29 | from rhodecode.lib import helpers as h | |
29 | from rhodecode.lib.auth import ( |
|
30 | from rhodecode.lib.auth import ( | |
30 |
LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired |
|
31 | LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired, | |
|
32 | HasRepoGroupPermissionAny) | |||
31 | from rhodecode.lib.codeblocks import filenode_as_lines_tokens |
|
33 | from rhodecode.lib.codeblocks import filenode_as_lines_tokens | |
32 | from rhodecode.lib.index import searcher_from_config |
|
34 | from rhodecode.lib.index import searcher_from_config | |
33 | from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int |
|
35 | from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int | |
34 | from rhodecode.lib.ext_json import json |
|
|||
35 | from rhodecode.lib.vcs.nodes import FileNode |
|
36 | from rhodecode.lib.vcs.nodes import FileNode | |
36 | from rhodecode.model.db import ( |
|
37 | from rhodecode.model.db import ( | |
37 |
func, true, or_, case, in_filter_generator, |
|
38 | func, true, or_, case, in_filter_generator, Session, | |
|
39 | Repository, RepoGroup, User, UserGroup) | |||
38 | from rhodecode.model.repo import RepoModel |
|
40 | from rhodecode.model.repo import RepoModel | |
39 | from rhodecode.model.repo_group import RepoGroupModel |
|
41 | from rhodecode.model.repo_group import RepoGroupModel | |
40 | from rhodecode.model.scm import RepoGroupList, RepoList |
|
|||
41 | from rhodecode.model.user import UserModel |
|
42 | from rhodecode.model.user import UserModel | |
42 | from rhodecode.model.user_group import UserGroupModel |
|
43 | from rhodecode.model.user_group import UserGroupModel | |
43 |
|
44 | |||
44 | log = logging.getLogger(__name__) |
|
45 | log = logging.getLogger(__name__) | |
45 |
|
46 | |||
46 |
|
47 | |||
47 | class HomeView(BaseAppView): |
|
48 | class HomeView(BaseAppView, DataGridAppView): | |
48 |
|
49 | |||
49 | def load_default_context(self): |
|
50 | def load_default_context(self): | |
50 | c = self._get_local_tmpl_context() |
|
51 | c = self._get_local_tmpl_context() | |
@@ -673,23 +674,6 b' class HomeView(BaseAppView):' | |||||
673 |
|
674 | |||
674 | return {'suggestions': res} |
|
675 | return {'suggestions': res} | |
675 |
|
676 | |||
676 | def _get_groups_and_repos(self, repo_group_id=None): |
|
|||
677 | # repo groups groups |
|
|||
678 | repo_group_list = RepoGroup.get_all_repo_groups(group_id=repo_group_id) |
|
|||
679 | _perms = ['group.read', 'group.write', 'group.admin'] |
|
|||
680 | repo_group_list_acl = RepoGroupList(repo_group_list, perm_set=_perms) |
|
|||
681 | repo_group_data = RepoGroupModel().get_repo_groups_as_dict( |
|
|||
682 | repo_group_list=repo_group_list_acl, admin=False) |
|
|||
683 |
|
||||
684 | # repositories |
|
|||
685 | repo_list = Repository.get_all_repos(group_id=repo_group_id) |
|
|||
686 | _perms = ['repository.read', 'repository.write', 'repository.admin'] |
|
|||
687 | repo_list_acl = RepoList(repo_list, perm_set=_perms) |
|
|||
688 | repo_data = RepoModel().get_repos_as_dict( |
|
|||
689 | repo_list=repo_list_acl, admin=False) |
|
|||
690 |
|
||||
691 | return repo_data, repo_group_data |
|
|||
692 |
|
||||
693 | @LoginRequired() |
|
677 | @LoginRequired() | |
694 | @view_config( |
|
678 | @view_config( | |
695 | route_name='home', request_method='GET', |
|
679 | route_name='home', request_method='GET', | |
@@ -697,13 +681,71 b' class HomeView(BaseAppView):' | |||||
697 | def main_page(self): |
|
681 | def main_page(self): | |
698 | c = self.load_default_context() |
|
682 | c = self.load_default_context() | |
699 | c.repo_group = None |
|
683 | c.repo_group = None | |
|
684 | return self._get_template_context(c) | |||
700 |
|
685 | |||
701 | repo_data, repo_group_data = self._get_groups_and_repos() |
|
686 | def _main_page_repo_groups_data(self, repo_group_id): | |
702 | # json used to render the grids |
|
687 | column_map = { | |
703 | c.repos_data = json.dumps(repo_data) |
|
688 | 'name_raw': 'group_name_hash', | |
704 | c.repo_groups_data = json.dumps(repo_group_data) |
|
689 | 'desc': 'group_description', | |
|
690 | 'last_change_raw': 'updated_on', | |||
|
691 | 'owner': 'user_username', | |||
|
692 | } | |||
|
693 | draw, start, limit = self._extract_chunk(self.request) | |||
|
694 | search_q, order_by, order_dir = self._extract_ordering( | |||
|
695 | self.request, column_map=column_map) | |||
|
696 | return RepoGroupModel().get_repo_groups_data_table( | |||
|
697 | draw, start, limit, | |||
|
698 | search_q, order_by, order_dir, | |||
|
699 | self._rhodecode_user, repo_group_id) | |||
|
700 | ||||
|
701 | def _main_page_repos_data(self, repo_group_id): | |||
|
702 | column_map = { | |||
|
703 | 'name_raw': 'repo_name', | |||
|
704 | 'desc': 'description', | |||
|
705 | 'last_change_raw': 'updated_on', | |||
|
706 | 'owner': 'user_username', | |||
|
707 | } | |||
|
708 | draw, start, limit = self._extract_chunk(self.request) | |||
|
709 | search_q, order_by, order_dir = self._extract_ordering( | |||
|
710 | self.request, column_map=column_map) | |||
|
711 | return RepoModel().get_repos_data_table( | |||
|
712 | draw, start, limit, | |||
|
713 | search_q, order_by, order_dir, | |||
|
714 | self._rhodecode_user, repo_group_id) | |||
705 |
|
715 | |||
706 | return self._get_template_context(c) |
|
716 | @LoginRequired() | |
|
717 | @view_config( | |||
|
718 | route_name='main_page_repo_groups_data', | |||
|
719 | request_method='GET', renderer='json_ext', xhr=True) | |||
|
720 | def main_page_repo_groups_data(self): | |||
|
721 | self.load_default_context() | |||
|
722 | repo_group_id = safe_int(self.request.GET.get('repo_group_id')) | |||
|
723 | ||||
|
724 | if repo_group_id: | |||
|
725 | group = RepoGroup.get_or_404(repo_group_id) | |||
|
726 | _perms = ['group.read', 'group.write', 'group.admin'] | |||
|
727 | if not HasRepoGroupPermissionAny(*_perms)( | |||
|
728 | group.group_name, 'user is allowed to list repo group children'): | |||
|
729 | raise HTTPNotFound() | |||
|
730 | ||||
|
731 | return self._main_page_repo_groups_data(repo_group_id) | |||
|
732 | ||||
|
733 | @LoginRequired() | |||
|
734 | @view_config( | |||
|
735 | route_name='main_page_repos_data', | |||
|
736 | request_method='GET', renderer='json_ext', xhr=True) | |||
|
737 | def main_page_repos_data(self): | |||
|
738 | self.load_default_context() | |||
|
739 | repo_group_id = safe_int(self.request.GET.get('repo_group_id')) | |||
|
740 | ||||
|
741 | if repo_group_id: | |||
|
742 | group = RepoGroup.get_or_404(repo_group_id) | |||
|
743 | _perms = ['group.read', 'group.write', 'group.admin'] | |||
|
744 | if not HasRepoGroupPermissionAny(*_perms)( | |||
|
745 | group.group_name, 'user is allowed to list repo group children'): | |||
|
746 | raise HTTPNotFound() | |||
|
747 | ||||
|
748 | return self._main_page_repos_data(repo_group_id) | |||
707 |
|
749 | |||
708 | @LoginRequired() |
|
750 | @LoginRequired() | |
709 | @HasRepoGroupPermissionAnyDecorator( |
|
751 | @HasRepoGroupPermissionAnyDecorator( | |
@@ -717,16 +759,6 b' class HomeView(BaseAppView):' | |||||
717 | def repo_group_main_page(self): |
|
759 | def repo_group_main_page(self): | |
718 | c = self.load_default_context() |
|
760 | c = self.load_default_context() | |
719 | c.repo_group = self.request.db_repo_group |
|
761 | c.repo_group = self.request.db_repo_group | |
720 | repo_data, repo_group_data = self._get_groups_and_repos(c.repo_group.group_id) |
|
|||
721 |
|
||||
722 | # update every 5 min |
|
|||
723 | if self.request.db_repo_group.last_commit_cache_update_diff > 60 * 5: |
|
|||
724 | self.request.db_repo_group.update_commit_cache() |
|
|||
725 |
|
||||
726 | # json used to render the grids |
|
|||
727 | c.repos_data = json.dumps(repo_data) |
|
|||
728 | c.repo_groups_data = json.dumps(repo_group_data) |
|
|||
729 |
|
||||
730 | return self._get_template_context(c) |
|
762 | return self._get_template_context(c) | |
731 |
|
763 | |||
732 | @LoginRequired() |
|
764 | @LoginRequired() |
@@ -528,6 +528,8 b' def add_events_routes(config):' | |||||
528 | from rhodecode.apps._base import ADMIN_PREFIX |
|
528 | from rhodecode.apps._base import ADMIN_PREFIX | |
529 |
|
529 | |||
530 | config.add_route(name='home', pattern='/') |
|
530 | config.add_route(name='home', pattern='/') | |
|
531 | config.add_route(name='main_page_repos_data', pattern='/_home_repos') | |||
|
532 | config.add_route(name='main_page_repo_groups_data', pattern='/_home_repo_groups') | |||
531 |
|
533 | |||
532 | config.add_route(name='login', pattern=ADMIN_PREFIX + '/login') |
|
534 | config.add_route(name='login', pattern=ADMIN_PREFIX + '/login') | |
533 | config.add_route(name='logout', pattern=ADMIN_PREFIX + '/logout') |
|
535 | config.add_route(name='logout', pattern=ADMIN_PREFIX + '/logout') |
@@ -281,6 +281,87 b' class RepoModel(BaseModel):' | |||||
281 |
|
281 | |||
282 | return repos_data |
|
282 | return repos_data | |
283 |
|
283 | |||
|
284 | def get_repos_data_table( | |||
|
285 | self, draw, start, limit, | |||
|
286 | search_q, order_by, order_dir, | |||
|
287 | auth_user, repo_group_id): | |||
|
288 | from rhodecode.model.scm import RepoList | |||
|
289 | ||||
|
290 | _perms = ['repository.read', 'repository.write', 'repository.admin'] | |||
|
291 | ||||
|
292 | repos = Repository.query() \ | |||
|
293 | .filter(Repository.group_id == repo_group_id) \ | |||
|
294 | .all() | |||
|
295 | auth_repo_list = RepoList( | |||
|
296 | repos, perm_set=_perms, | |||
|
297 | extra_kwargs=dict(user=auth_user)) | |||
|
298 | ||||
|
299 | allowed_ids = [-1] | |||
|
300 | for repo in auth_repo_list: | |||
|
301 | allowed_ids.append(repo.repo_id) | |||
|
302 | ||||
|
303 | repos_data_total_count = Repository.query() \ | |||
|
304 | .filter(Repository.group_id == repo_group_id) \ | |||
|
305 | .filter(or_( | |||
|
306 | # generate multiple IN to fix limitation problems | |||
|
307 | *in_filter_generator(Repository.repo_id, allowed_ids)) | |||
|
308 | ) \ | |||
|
309 | .count() | |||
|
310 | ||||
|
311 | base_q = Session.query( | |||
|
312 | Repository.repo_id, | |||
|
313 | Repository.repo_name, | |||
|
314 | Repository.description, | |||
|
315 | Repository.repo_type, | |||
|
316 | Repository.repo_state, | |||
|
317 | Repository.private, | |||
|
318 | Repository.archived, | |||
|
319 | Repository.fork, | |||
|
320 | Repository.updated_on, | |||
|
321 | Repository._changeset_cache, | |||
|
322 | User, | |||
|
323 | ) \ | |||
|
324 | .filter(Repository.group_id == repo_group_id) \ | |||
|
325 | .filter(or_( | |||
|
326 | # generate multiple IN to fix limitation problems | |||
|
327 | *in_filter_generator(Repository.repo_id, allowed_ids)) | |||
|
328 | ) \ | |||
|
329 | .join(User, User.user_id == Repository.user_id) \ | |||
|
330 | .group_by(Repository, User) | |||
|
331 | ||||
|
332 | repos_data_total_filtered_count = base_q.count() | |||
|
333 | ||||
|
334 | sort_defined = False | |||
|
335 | if order_by == 'repo_name': | |||
|
336 | sort_col = func.lower(Repository.repo_name) | |||
|
337 | sort_defined = True | |||
|
338 | elif order_by == 'user_username': | |||
|
339 | sort_col = User.username | |||
|
340 | else: | |||
|
341 | sort_col = getattr(Repository, order_by, None) | |||
|
342 | ||||
|
343 | if sort_defined or sort_col: | |||
|
344 | if order_dir == 'asc': | |||
|
345 | sort_col = sort_col.asc() | |||
|
346 | else: | |||
|
347 | sort_col = sort_col.desc() | |||
|
348 | ||||
|
349 | base_q = base_q.order_by(sort_col) | |||
|
350 | base_q = base_q.offset(start).limit(limit) | |||
|
351 | ||||
|
352 | repos_list = base_q.all() | |||
|
353 | ||||
|
354 | repos_data = RepoModel().get_repos_as_dict( | |||
|
355 | repo_list=repos_list, admin=False) | |||
|
356 | ||||
|
357 | data = ({ | |||
|
358 | 'draw': draw, | |||
|
359 | 'data': repos_data, | |||
|
360 | 'recordsTotal': repos_data_total_count, | |||
|
361 | 'recordsFiltered': repos_data_total_filtered_count, | |||
|
362 | }) | |||
|
363 | return data | |||
|
364 | ||||
284 | def _get_defaults(self, repo_name): |
|
365 | def _get_defaults(self, repo_name): | |
285 | """ |
|
366 | """ | |
286 | Gets information about repository, and returns a dict for |
|
367 | Gets information about repository, and returns a dict for |
@@ -775,6 +775,84 b' class RepoGroupModel(BaseModel):' | |||||
775 |
|
775 | |||
776 | return repo_group_data |
|
776 | return repo_group_data | |
777 |
|
777 | |||
|
778 | def get_repo_groups_data_table( | |||
|
779 | self, draw, start, limit, | |||
|
780 | search_q, order_by, order_dir, | |||
|
781 | auth_user, repo_group_id): | |||
|
782 | from rhodecode.model.scm import RepoGroupList | |||
|
783 | ||||
|
784 | _perms = ['group.read', 'group.write', 'group.admin'] | |||
|
785 | repo_groups = RepoGroup.query() \ | |||
|
786 | .filter(RepoGroup.group_parent_id == repo_group_id) \ | |||
|
787 | .all() | |||
|
788 | auth_repo_group_list = RepoGroupList( | |||
|
789 | repo_groups, perm_set=_perms, | |||
|
790 | extra_kwargs=dict(user=auth_user)) | |||
|
791 | ||||
|
792 | allowed_ids = [-1] | |||
|
793 | for repo_group in auth_repo_group_list: | |||
|
794 | allowed_ids.append(repo_group.group_id) | |||
|
795 | ||||
|
796 | repo_groups_data_total_count = RepoGroup.query() \ | |||
|
797 | .filter(RepoGroup.group_parent_id == repo_group_id) \ | |||
|
798 | .filter(or_( | |||
|
799 | # generate multiple IN to fix limitation problems | |||
|
800 | *in_filter_generator(RepoGroup.group_id, allowed_ids)) | |||
|
801 | ) \ | |||
|
802 | .count() | |||
|
803 | ||||
|
804 | base_q = Session.query( | |||
|
805 | RepoGroup.group_name, | |||
|
806 | RepoGroup.group_name_hash, | |||
|
807 | RepoGroup.group_description, | |||
|
808 | RepoGroup.group_id, | |||
|
809 | RepoGroup.personal, | |||
|
810 | RepoGroup.updated_on, | |||
|
811 | RepoGroup._changeset_cache, | |||
|
812 | User, | |||
|
813 | ) \ | |||
|
814 | .filter(RepoGroup.group_parent_id == repo_group_id) \ | |||
|
815 | .filter(or_( | |||
|
816 | # generate multiple IN to fix limitation problems | |||
|
817 | *in_filter_generator(RepoGroup.group_id, allowed_ids)) | |||
|
818 | ) \ | |||
|
819 | .join(User, User.user_id == RepoGroup.user_id) \ | |||
|
820 | .group_by(RepoGroup, User) | |||
|
821 | ||||
|
822 | repo_groups_data_total_filtered_count = base_q.count() | |||
|
823 | ||||
|
824 | sort_defined = False | |||
|
825 | ||||
|
826 | if order_by == 'group_name': | |||
|
827 | sort_col = func.lower(RepoGroup.group_name) | |||
|
828 | sort_defined = True | |||
|
829 | elif order_by == 'user_username': | |||
|
830 | sort_col = User.username | |||
|
831 | else: | |||
|
832 | sort_col = getattr(RepoGroup, order_by, None) | |||
|
833 | ||||
|
834 | if sort_defined or sort_col: | |||
|
835 | if order_dir == 'asc': | |||
|
836 | sort_col = sort_col.asc() | |||
|
837 | else: | |||
|
838 | sort_col = sort_col.desc() | |||
|
839 | ||||
|
840 | base_q = base_q.order_by(sort_col) | |||
|
841 | base_q = base_q.offset(start).limit(limit) | |||
|
842 | ||||
|
843 | repo_group_list = base_q.all() | |||
|
844 | ||||
|
845 | repo_groups_data = RepoGroupModel().get_repo_groups_as_dict( | |||
|
846 | repo_group_list=repo_group_list, admin=False) | |||
|
847 | ||||
|
848 | data = ({ | |||
|
849 | 'draw': draw, | |||
|
850 | 'data': repo_groups_data, | |||
|
851 | 'recordsTotal': repo_groups_data_total_count, | |||
|
852 | 'recordsFiltered': repo_groups_data_total_filtered_count, | |||
|
853 | }) | |||
|
854 | return data | |||
|
855 | ||||
778 | def _get_defaults(self, repo_group_name): |
|
856 | def _get_defaults(self, repo_group_name): | |
779 | repo_group = RepoGroup.get_by_group_name(repo_group_name) |
|
857 | repo_group = RepoGroup.get_by_group_name(repo_group_name) | |
780 |
|
858 |
@@ -150,6 +150,8 b' function registerRCRoutes() {' | |||||
150 | pyroutes.register('reset_password', '/_admin/password_reset', []); |
|
150 | pyroutes.register('reset_password', '/_admin/password_reset', []); | |
151 | pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []); |
|
151 | pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []); | |
152 | pyroutes.register('home', '/', []); |
|
152 | pyroutes.register('home', '/', []); | |
|
153 | pyroutes.register('main_page_repos_data', '/_home_repos', []); | |||
|
154 | pyroutes.register('main_page_repo_groups_data', '/_home_repo_groups', []); | |||
153 | pyroutes.register('user_autocomplete_data', '/_users', []); |
|
155 | pyroutes.register('user_autocomplete_data', '/_users', []); | |
154 | pyroutes.register('user_group_autocomplete_data', '/_user_groups', []); |
|
156 | pyroutes.register('user_group_autocomplete_data', '/_user_groups', []); | |
155 | pyroutes.register('repo_list_data', '/_repos', []); |
|
157 | pyroutes.register('repo_list_data', '/_repos', []); |
@@ -15,58 +15,97 b'' | |||||
15 |
|
15 | |||
16 | </div> |
|
16 | </div> | |
17 | <!-- end box / title --> |
|
17 | <!-- end box / title --> | |
|
18 | <div id="no_grid_data" class="table" style="display: none"> | |||
|
19 | <h2 class="no-object-border"> | |||
|
20 | ${_('No repositories or repositories groups exists here.')} | |||
|
21 | </h2> | |||
|
22 | </div> | |||
|
23 | ||||
18 | <div class="table"> |
|
24 | <div class="table"> | |
19 | <div id="groups_list_wrap"> |
|
25 | <div id="groups_list_wrap" style="min-height: 200px;"> | |
20 | <table id="group_list_table" class="display" style="width: 100%"></table> |
|
26 | <table id="group_list_table" class="display" style="width: 100%;"></table> | |
21 | </div> |
|
27 | </div> | |
22 | </div> |
|
28 | </div> | |
23 |
|
29 | |||
24 | <div class="table"> |
|
30 | <div class="table"> | |
25 | <div id="repos_list_wrap"> |
|
31 | <div id="repos_list_wrap" style="min-height: 200px;"> | |
26 | <table id="repo_list_table" class="display" style="width: 100%"></table> |
|
32 | <table id="repo_list_table" class="display" style="width: 100%;"></table> | |
27 | </div> |
|
33 | </div> | |
28 | </div> |
|
34 | </div> | |
29 |
|
35 | |||
30 | ## no repository groups and repos present, show something to the users |
|
|||
31 | % if c.repo_groups_data == '[]' and c.repos_data == '[]': |
|
|||
32 | <div class="table"> |
|
|||
33 | <h2 class="no-object-border"> |
|
|||
34 | ${_('No repositories or repositories groups exists here.')} |
|
|||
35 | </h2> |
|
|||
36 | </div> |
|
|||
37 | % endif |
|
|||
38 |
|
||||
39 | </div> |
|
36 | </div> | |
40 | <script> |
|
37 | <script> | |
41 |
|
|
38 | $(document).ready(function () { | |
42 |
|
39 | |||
43 | // repo group list |
|
40 | // repo group list | |
44 | % if c.repo_groups_data != '[]': |
|
41 | var $groupListTable = $('#group_list_table'); | |
45 | $('#group_list_table').DataTable({ |
|
42 | ||
46 | data: ${c.repo_groups_data|n}, |
|
43 | $groupListTable.DataTable({ | |
|
44 | processing: true, | |||
|
45 | serverSide: true, | |||
|
46 | ajax: { | |||
|
47 | "url": "${h.route_path('main_page_repo_groups_data')}", | |||
|
48 | "data": function (d) { | |||
|
49 | % if c.repo_group: | |||
|
50 | d.repo_group_id = ${c.repo_group.group_id} | |||
|
51 | % endif | |||
|
52 | } | |||
|
53 | }, | |||
47 | dom: 'rtp', |
|
54 | dom: 'rtp', | |
48 | pageLength: ${c.visual.dashboard_items}, |
|
55 | pageLength: ${c.visual.dashboard_items}, | |
49 |
order: [[ |
|
56 | order: [[0, "asc"]], | |
50 | columns: [ |
|
57 | columns: [ | |
51 | { data: {"_": "name", |
|
58 | { | |
52 | "sort": "name_raw"}, title: "${_('Name')}", className: "truncate-wrap td-grid-name" }, |
|
59 | data: { | |
|
60 | "_": "name", | |||
|
61 | "sort": "name_raw" | |||
|
62 | }, title: "${_('Name')}", className: "truncate-wrap td-grid-name" | |||
|
63 | }, | |||
53 |
{ |
|
64 | {data: 'menu', "bSortable": false, className: "quick_repo_menu"}, | |
54 | { data: {"_": "desc", |
|
65 | { | |
55 | "sort": "desc"}, title: "${_('Description')}", className: "td-description" }, |
|
66 | data: { | |
56 |
|
|
67 | "_": "desc", | |
|
68 | "sort": "desc" | |||
|
69 | }, title: "${_('Description')}", className: "td-description" | |||
|
70 | }, | |||
|
71 | { | |||
|
72 | data: { | |||
|
73 | "_": "last_change", | |||
57 | "sort": "last_change_raw", |
|
74 | "sort": "last_change_raw", | |
58 | "type": Number}, title: "${_('Last Change')}", className: "td-time" }, |
|
75 | "type": Number | |
59 | { data: {"_": "last_changeset", |
|
76 | }, title: "${_('Last Change')}", className: "td-time" | |
|
77 | }, | |||
|
78 | { | |||
|
79 | data: { | |||
|
80 | "_": "last_changeset", | |||
60 | "sort": "last_changeset_raw", |
|
81 | "sort": "last_changeset_raw", | |
61 |
"type": Number |
|
82 | "type": Number | |
62 | { data: {"_": "owner", |
|
83 | }, title: "", className: "td-hash" | |
63 | "sort": "owner"}, title: "${_('Owner')}", className: "td-user" } |
|
84 | }, | |
|
85 | { | |||
|
86 | data: { | |||
|
87 | "_": "owner", | |||
|
88 | "sort": "owner" | |||
|
89 | }, title: "${_('Owner')}", className: "td-user" | |||
|
90 | } | |||
64 | ], |
|
91 | ], | |
65 | language: { |
|
92 | language: { | |
66 | paginate: DEFAULT_GRID_PAGINATION, |
|
93 | paginate: DEFAULT_GRID_PAGINATION, | |
67 | emptyTable: _gettext("No repository groups available yet.") |
|
94 | sProcessing: _gettext('loading...'), | |
|
95 | emptyTable: _gettext("No repository groups present.") | |||
68 | }, |
|
96 | }, | |
69 |
"drawCallback": function( |
|
97 | "drawCallback": function (settings, json) { | |
|
98 | // hide grid if it's empty | |||
|
99 | if (settings.fnRecordsDisplay() === 0) { | |||
|
100 | $('#groups_list_wrap').hide(); | |||
|
101 | // both hidden, show no-data | |||
|
102 | if ($('#repos_list_wrap').is(':hidden')) { | |||
|
103 | $('#no_grid_data').show(); | |||
|
104 | } | |||
|
105 | } else { | |||
|
106 | $('#groups_list_wrap').show(); | |||
|
107 | } | |||
|
108 | ||||
70 | timeagoActivate(); |
|
109 | timeagoActivate(); | |
71 | tooltipActivate(); |
|
110 | tooltipActivate(); | |
72 | quick_repo_menu(); |
|
111 | quick_repo_menu(); | |
@@ -74,37 +113,90 b'' | |||||
74 | if (settings._iDisplayLength >= settings.fnRecordsDisplay()) { |
|
113 | if (settings._iDisplayLength >= settings.fnRecordsDisplay()) { | |
75 | $(settings.nTableWrapper).find('.dataTables_paginate').hide(); |
|
114 | $(settings.nTableWrapper).find('.dataTables_paginate').hide(); | |
76 | } |
|
115 | } | |
77 | } |
|
116 | ||
|
117 | }, | |||
78 | }); |
|
118 | }); | |
79 | % endif |
|
119 | ||
|
120 | $groupListTable.on('xhr.dt', function (e, settings, json, xhr) { | |||
|
121 | $groupListTable.css('opacity', 1); | |||
|
122 | }); | |||
|
123 | ||||
|
124 | $groupListTable.on('preXhr.dt', function (e, settings, data) { | |||
|
125 | $groupListTable.css('opacity', 0.3); | |||
|
126 | }); | |||
|
127 | ||||
80 |
|
128 | |||
81 | // repo list |
|
129 | ## // repo list | |
82 | % if c.repos_data != '[]': |
|
130 | var $repoListTable = $('#repo_list_table'); | |
83 | $('#repo_list_table').DataTable({ |
|
131 | ||
84 | data: ${c.repos_data|n}, |
|
132 | $repoListTable.DataTable({ | |
|
133 | processing: true, | |||
|
134 | serverSide: true, | |||
|
135 | ajax: { | |||
|
136 | "url": "${h.route_path('main_page_repos_data')}", | |||
|
137 | "data": function (d) { | |||
|
138 | % if c.repo_group: | |||
|
139 | d.repo_group_id = ${c.repo_group.group_id} | |||
|
140 | % endif | |||
|
141 | } | |||
|
142 | }, | |||
|
143 | order: [[0, "asc"]], | |||
85 | dom: 'rtp', |
|
144 | dom: 'rtp', | |
86 | order: [[ 0, "asc" ]], |
|
|||
87 | pageLength: ${c.visual.dashboard_items}, |
|
145 | pageLength: ${c.visual.dashboard_items}, | |
88 | columns: [ |
|
146 | columns: [ | |
89 | { data: {"_": "name", |
|
147 | { | |
90 | "sort": "name_raw"}, title: "${_('Name')}", className: "truncate-wrap td-grid-name" }, |
|
148 | data: { | |
91 | { data: 'menu', "bSortable": false, className: "quick_repo_menu" }, |
|
149 | "_": "name", | |
92 | { data: {"_": "desc", |
|
150 | "sort": "name_raw" | |
93 |
|
|
151 | }, title: "${_('Name')}", className: "truncate-wrap td-grid-name" | |
94 | { data: {"_": "last_change", |
|
152 | }, | |
|
153 | { | |||
|
154 | data: 'menu', "bSortable": false, className: "quick_repo_menu" | |||
|
155 | }, | |||
|
156 | { | |||
|
157 | data: { | |||
|
158 | "_": "desc", | |||
|
159 | "sort": "desc" | |||
|
160 | }, title: "${_('Description')}", className: "td-description" | |||
|
161 | }, | |||
|
162 | { | |||
|
163 | data: { | |||
|
164 | "_": "last_change", | |||
95 | "sort": "last_change_raw", |
|
165 | "sort": "last_change_raw", | |
96 | "type": Number}, title: "${_('Last Change')}", className: "td-time" }, |
|
166 | "type": Number | |
97 | { data: {"_": "last_changeset", |
|
167 | }, title: "${_('Last Change')}", className: "td-time", orderable: false | |
|
168 | }, | |||
|
169 | { | |||
|
170 | data: { | |||
|
171 | "_": "last_changeset", | |||
98 | "sort": "last_changeset_raw", |
|
172 | "sort": "last_changeset_raw", | |
99 | "type": Number}, title: "${_('Commit')}", className: "td-hash" }, |
|
173 | "type": Number | |
100 | { data: {"_": "owner", |
|
174 | }, title: "${_('Commit')}", className: "td-hash" | |
101 | "sort": "owner"}, title: "${_('Owner')}", className: "td-user" } |
|
175 | }, | |
|
176 | { | |||
|
177 | data: { | |||
|
178 | "_": "owner", | |||
|
179 | "sort": "owner" | |||
|
180 | }, title: "${_('Owner')}", className: "td-user" | |||
|
181 | } | |||
102 | ], |
|
182 | ], | |
103 | language: { |
|
183 | language: { | |
104 | paginate: DEFAULT_GRID_PAGINATION, |
|
184 | paginate: DEFAULT_GRID_PAGINATION, | |
105 | emptyTable: _gettext("No repositories available yet.") |
|
185 | sProcessing: _gettext('loading...'), | |
|
186 | emptyTable: _gettext("No repositories present.") | |||
106 | }, |
|
187 | }, | |
107 |
"drawCallback": function( |
|
188 | "drawCallback": function (settings, json) { | |
|
189 | // hide grid if it's empty | |||
|
190 | if (settings.fnRecordsDisplay() == 0) { | |||
|
191 | $('#repos_list_wrap').hide() | |||
|
192 | // both hidden, show no-data | |||
|
193 | if ($('#groups_list_wrap').is(':hidden')) { | |||
|
194 | $('#no_grid_data').show() | |||
|
195 | } | |||
|
196 | } else { | |||
|
197 | $('#repos_list_wrap').show() | |||
|
198 | } | |||
|
199 | ||||
108 | timeagoActivate(); |
|
200 | timeagoActivate(); | |
109 | tooltipActivate(); |
|
201 | tooltipActivate(); | |
110 | quick_repo_menu(); |
|
202 | quick_repo_menu(); | |
@@ -112,9 +204,17 b'' | |||||
112 | if (settings._iDisplayLength >= settings.fnRecordsDisplay()) { |
|
204 | if (settings._iDisplayLength >= settings.fnRecordsDisplay()) { | |
113 | $(settings.nTableWrapper).find('.dataTables_paginate').hide(); |
|
205 | $(settings.nTableWrapper).find('.dataTables_paginate').hide(); | |
114 | } |
|
206 | } | |
115 | } |
|
207 | ||
|
208 | }, | |||
116 | }); |
|
209 | }); | |
117 | % endif |
|
210 | ||
|
211 | $repoListTable.on('xhr.dt', function (e, settings, json, xhr) { | |||
|
212 | $repoListTable.css('opacity', 1); | |||
|
213 | }); | |||
|
214 | ||||
|
215 | $repoListTable.on('preXhr.dt', function (e, settings, data) { | |||
|
216 | $repoListTable.css('opacity', 0.3); | |||
|
217 | }); | |||
118 |
|
218 | |||
119 |
|
|
219 | }); | |
120 | </script> |
|
220 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now