/
admin.js
127 lines (116 loc) · 5.23 KB
/
admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
var jQuery = require( 'jquery' ),
$ = jQuery,
GalaxyApp = require( 'galaxy' ).GalaxyApp,
AdminPanel = require( './panels/admin-panel' ),
FormWrapper = require( 'mvc/form/form-wrapper' ),
GridView = require( 'mvc/grid/grid-view' ),
Ui = require( 'mvc/ui/ui-misc' ),
QueryStringParsing = require( 'utils/query-string-parsing' ),
Router = require( 'layout/router' ),
Page = require( 'layout/page' );
window.app = function app( options, bootstrapped ){
window.Galaxy = new GalaxyApp( options, bootstrapped );
Galaxy.debug( 'admin app' );
/** Routes */
var AdminRouter = Router.extend({
routes: {
'(/)admin(/)users' : 'show_users',
'(/)admin(/)roles' : 'show_roles',
'(/)admin(/)groups' : 'show_groups',
'(/)admin(/)tool_versions' : 'show_tool_versions',
'(/)admin(/)quotas' : 'show_quotas',
'(/)admin(/)forms' : 'show_forms',
'(/)admin(/)form(/)(:form_id)' : 'show_form'
},
authenticate: function( args, name ) {
return Galaxy.user && Galaxy.user.id && Galaxy.user.get( 'is_admin' );
},
show_users: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'admin/users_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_roles: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'admin/roles_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_groups: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'admin/groups_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_tool_versions: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'admin/tool_versions_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_quotas: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'admin/quotas_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_forms: function() {
this.page.display( new GridView( { url_base: Galaxy.root + 'forms/forms_list', url_data: Galaxy.params, dict_format: true } ) );
},
show_form : function( form_id ) {
var id = '?id=' + QueryStringParsing.get( 'id' );
var form_defs = {
reset_user_password: {
title : 'Reset passwords',
url : 'admin/reset_user_password' + id,
icon : 'fa-user',
submit_title : 'Save new password',
redirect : 'admin/users'
},
manage_roles_and_groups_for_user: {
url : 'admin/manage_roles_and_groups_for_user' + id,
icon : 'fa-users',
redirect : 'admin/users'
},
manage_users_and_groups_for_role: {
url : 'admin/manage_users_and_groups_for_role' + id,
redirect : 'admin/roles'
},
manage_users_and_roles_for_group: {
url : 'admin/manage_users_and_roles_for_group' + id,
redirect : 'admin/groups'
},
manage_users_and_groups_for_quota: {
url : 'admin/manage_users_and_groups_for_quota' + id,
redirect : 'admin/quotas'
},
create_role: {
url : 'admin/create_role',
redirect : 'admin/roles'
},
create_group: {
url : 'admin/create_group',
redirect : 'admin/groups'
},
create_quota: {
url : 'admin/create_quota',
redirect : 'admin/quotas'
},
rename_role: {
url : 'admin/rename_role' + id,
redirect : 'admin/roles'
},
rename_group: {
url : 'admin/rename_group' + id,
redirect : 'admin/groups'
},
rename_quota: {
url : 'admin/rename_quota' + id,
redirect : 'admin/quotas'
},
edit_quota: {
url : 'admin/edit_quota' + id,
redirect : 'admin/quotas'
},
set_quota_default: {
url : 'admin/set_quota_default' + id,
redirect : 'admin/quotas'
},
};
this.page.display( new FormWrapper.View ( form_defs[ form_id ] ) );
}
});
$(function() {
_.extend( options.config, { active_view : 'admin' } );
Galaxy.page = new Page.View( _.extend( options, {
Left : AdminPanel,
Router : AdminRouter
} ) );
});
};