Skip to content

Commit 212a5e0

Browse files
Merge pull request #8304 from rabbitmq/mergify/bp/v3.11.x/pr-8256
2 parents cd0c199 + a8fdef4 commit 212a5e0

File tree

88 files changed

+1260
-803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1260
-803
lines changed

deps/rabbitmq_management/priv/www/js/dispatcher.js

Lines changed: 95 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ dispatcher_add(function(sammy) {
4040
'node', '');
4141
});
4242

43-
sammy.get('#/connections', function() {
43+
if (ac.canAccessVhosts()) {
44+
sammy.get('#/connections', function() {
4445
renderConnections();
4546
});
46-
47-
48-
sammy.get('#/connections/:name', function() {
47+
sammy.get('#/connections/:name', function() {
4948
var name = esc(this.params['name']);
5049
render({'connection': {path: '/connections/' + name,
5150
options: {ranges: ['data-rates-conn']}},
5251
'channels': '/connections/' + name + '/channels'},
5352
'connection', '#/connections');
5453
});
55-
sammy.del('#/connections', function() {
54+
sammy.del('#/connections', function() {
5655
var options = {headers: {
5756
'X-Reason': this.params['reason']
5857
}};
@@ -62,51 +61,45 @@ dispatcher_add(function(sammy) {
6261

6362
return false;
6463
});
65-
66-
sammy.get('#/channels', function() {
64+
sammy.get('#/channels', function() {
6765
renderChannels();
6866
});
69-
70-
sammy.get('#/channels/:name', function() {
67+
sammy.get('#/channels/:name', function() {
7168
render({'channel': {path: '/channels/' + esc(this.params['name']),
7269
options:{ranges:['data-rates-ch','msg-rates-ch']}}},
7370
'channel', '#/channels');
7471
});
75-
76-
77-
sammy.get('#/exchanges', function() {
72+
sammy.get('#/exchanges', function() {
7873
renderExchanges();
7974
});
80-
81-
82-
sammy.get('#/exchanges/:vhost/:name', function() {
75+
sammy.get('#/exchanges/:vhost/:name', function() {
8376
var path = '/exchanges/' + esc(this.params['vhost']) + '/' + esc(this.params['name']);
8477
render({'exchange': {path: path,
8578
options: {ranges:['msg-rates-x']}},
8679
'bindings_source': path + '/bindings/source',
8780
'bindings_destination': path + '/bindings/destination'},
8881
'exchange', '#/exchanges');
8982
});
90-
sammy.put('#/exchanges', function() {
83+
sammy.put('#/exchanges', function() {
9184
if (sync_put(this, '/exchanges/:vhost/:name'))
9285
update();
9386
return false;
9487
});
95-
sammy.del('#/exchanges', function() {
88+
sammy.del('#/exchanges', function() {
9689
if (sync_delete(this, '/exchanges/:vhost/:name'))
9790
go_to('#/exchanges');
9891
return false;
9992
});
100-
sammy.post('#/exchanges/publish', function() {
93+
sammy.post('#/exchanges/publish', function() {
10194
publish_msg(this.params);
10295
return false;
10396
});
10497

105-
sammy.get('#/queues', function() {
98+
sammy.get('#/queues', function() {
10699
renderQueues();
107100
});
108101

109-
sammy.get('#/queues/:vhost/:name', function() {
102+
sammy.get('#/queues/:vhost/:name', function() {
110103
var vhost = this.params['vhost'];
111104
var queue = this.params['name'];
112105
var path = '/queues/' + esc(vhost) + '/' + esc(queue);
@@ -124,12 +117,12 @@ dispatcher_add(function(sammy) {
124117
}
125118
render(requests, 'queue', '#/queues');
126119
});
127-
sammy.put('#/queues', function() {
120+
sammy.put('#/queues', function() {
128121
if (sync_put(this, '/queues/:vhost/:name'))
129122
update();
130123
return false;
131124
});
132-
sammy.del('#/queues', function() {
125+
sammy.del('#/queues', function() {
133126
if (this.params['mode'] == 'delete') {
134127
if (sync_delete(this, '/queues/:vhost/:name'))
135128
go_to('#/queues');
@@ -142,32 +135,31 @@ dispatcher_add(function(sammy) {
142135
}
143136
return false;
144137
});
145-
sammy.post('#/queues/get', function() {
138+
sammy.post('#/queues/get', function() {
146139
get_msgs(this.params);
147140
return false;
148141
});
149-
sammy.post('#/queues/actions', function() {
142+
sammy.post('#/queues/actions', function() {
150143
if (sync_post(this, '/queues/:vhost/:name/actions'))
151144
// We can't refresh fast enough, it's racy. So grey
152145
// the button and wait for a normal refresh.
153146
$('#action-button').addClass('wait').prop('disabled', true);
154147
return false;
155148
});
156-
sammy.post('#/bindings', function() {
149+
sammy.post('#/bindings', function() {
157150
if (sync_post(this, '/bindings/:vhost/e/:source/:destination_type/:destination'))
158151
update();
159152
return false;
160153
});
161-
sammy.del('#/bindings', function() {
154+
sammy.del('#/bindings', function() {
162155
if (sync_delete(this, '/bindings/:vhost/e/:source/:destination_type/:destination/:properties_key'))
163156
update();
164157
return false;
165158
});
166-
167-
path('#/vhosts', {'vhosts': {path: '/vhosts',
159+
path('#/vhosts', {'vhosts': {path: '/vhosts',
168160
options: {sort:true}},
169161
'permissions': '/permissions'}, 'vhosts');
170-
sammy.get('#/vhosts/:id', function() {
162+
sammy.get('#/vhosts/:id', function() {
171163
render({'vhost': {path: '/vhosts/' + esc(this.params['id']),
172164
options: {ranges: ['lengths-vhost',
173165
'msg-rates-vhost',
@@ -178,26 +170,25 @@ dispatcher_add(function(sammy) {
178170
'exchanges' : '/exchanges/' + esc(this.params['id'])},
179171
'vhost', '#/vhosts');
180172
});
181-
182-
sammy.put('#/vhosts', function() {
173+
sammy.put('#/vhosts', function() {
183174
if (sync_put(this, '/vhosts/:name')) {
184175
update_vhosts();
185176
update();
186177
}
187178
return false;
188179
});
189-
sammy.del('#/vhosts', function() {
180+
sammy.del('#/vhosts', function() {
190181
if (sync_delete(this, '/vhosts/:name')) {
191182
update_vhosts();
192183
go_to('#/vhosts');
193184
}
194185
return false;
195186
});
196187

197-
sammy.get('#/users', function() {
188+
sammy.get('#/users', function() {
198189
renderUsers();
199-
});
200-
sammy.get('#/users/:id', function() {
190+
});
191+
sammy.get('#/users/:id', function() {
201192
var vhosts = JSON.parse(sync_get('/vhosts'));
202193
const current_vhost = get_pref('vhost');
203194
var index_vhost = 0;
@@ -213,8 +204,8 @@ dispatcher_add(function(sammy) {
213204
'vhosts': '/vhosts/',
214205
'exchanges': '/exchanges/' + esc(vhosts[index_vhost].name)},
215206
'user','#/users');
216-
});
217-
sammy.put('#/users-add', function() {
207+
});
208+
sammy.put('#/users-add', function() {
218209
res = sync_put(this, '/users/:username');
219210
if (res) {
220211
if (res.http_status === 204) {
@@ -225,75 +216,120 @@ dispatcher_add(function(sammy) {
225216
}
226217
return false;
227218
});
228-
sammy.put('#/users-modify', function() {
219+
sammy.put('#/users-modify', function() {
229220
if (sync_put(this, '/users/:username'))
230221
go_to('#/users');
231222
return false;
232223
});
233-
sammy.del('#/users', function() {
224+
sammy.del('#/users', function() {
234225
if (sync_delete(this, '/users/:username'))
235226
go_to('#/users');
236227
return false;
237228
});
238-
239-
path('#/feature-flags', {'feature_flags': {path: '/feature-flags',
240-
options: {sort:true}},
241-
'permissions': '/permissions'}, 'feature-flags');
242-
sammy.put('#/feature-flags-enable', function() {
243-
if (sync_put(this, '/feature-flags/:name/enable'))
244-
update();
245-
return false;
246-
});
247-
248-
sammy.put('#/permissions', function() {
229+
sammy.put('#/permissions', function() {
249230
if (sync_put(this, '/permissions/:vhost/:username'))
250231
update();
251232
return false;
252233
});
253-
sammy.del('#/permissions', function() {
234+
sammy.del('#/permissions', function() {
254235
if (sync_delete(this, '/permissions/:vhost/:username'))
255236
update();
256237
return false;
257238
});
258-
sammy.put('#/topic-permissions', function() {
239+
sammy.put('#/topic-permissions', function() {
259240
if (sync_put(this, '/topic-permissions/:vhost/:username'))
260241
update();
261242
return false;
262243
});
263-
sammy.del('#/topic-permissions', function() {
244+
sammy.del('#/topic-permissions', function() {
264245
if (sync_delete(this, '/topic-permissions/:vhost/:username/:exchange'))
265246
update();
266247
return false;
267248
});
268-
path('#/policies', {'policies': '/policies',
249+
path('#/policies', {'policies': '/policies',
269250
'operator_policies': '/operator-policies',
270251
'vhosts': '/vhosts'}, 'policies');
271-
sammy.get('#/policies/:vhost/:id', function() {
252+
sammy.get('#/policies/:vhost/:id', function() {
272253
render({'policy': '/policies/' + esc(this.params['vhost'])
273254
+ '/' + esc(this.params['id'])},
274255
'policy', '#/policies');
275256
});
276-
sammy.put('#/policies', function() {
257+
sammy.put('#/policies', function() {
277258
put_cast_params(this, '/policies/:vhost/:name',
278259
['name', 'pattern', 'policy'], ['priority'], []);
279260
return false;
280261
});
281-
sammy.del('#/policies', function() {
262+
sammy.del('#/policies', function() {
282263
if (sync_delete(this, '/policies/:vhost/:name'))
283264
go_to('#/policies');
284265
return false;
285266
});
286-
sammy.put('#/operator_policies', function() {
267+
sammy.put('#/operator_policies', function() {
287268
this.params = rename_multifield(this.params, "definitionop", "definition");
288269
put_cast_params(this, '/operator-policies/:vhost/:name',
289270
['name', 'pattern', 'policy'], ['priority'], []);
290271
return false;
291272
});
292-
sammy.del('#/operator_policies', function() {
273+
sammy.del('#/operator_policies', function() {
293274
if (sync_delete(this, '/operator-policies/:vhost/:name'))
294275
update();
295276
});
277+
let datamodel = {
278+
'limits': '/vhost-limits',
279+
'user_limits': '/user-limits',
280+
'vhosts': '/vhosts'
281+
}
282+
if (ac.isAdministratorUser()) {
283+
datamodel['users'] = '/users'
284+
}
285+
path('#/limits', datamodel, 'limits');
296286

287+
sammy.put('#/limits', function() {
288+
var valAsInt = parseInt(this.params.value);
289+
if (isNaN(valAsInt)) {
290+
var e = 'Validation failed\n\n' +
291+
this.params.name + ' should be a number, actually was "' +
292+
this.params.value + '"';
293+
show_popup('warn', fmt_escape_html(e));
294+
} else {
295+
this.params.value = valAsInt;
296+
if (sync_put(this, '/vhost-limits/:vhost/:name')) {
297+
update();
298+
}
299+
}
300+
})
301+
sammy.put('#/user-limits', function() {
302+
var valAsInt = parseInt(this.params.value);
303+
if (isNaN(valAsInt)) {
304+
var e = 'Validation failed\n\n' +
305+
this.params.name + ' should be a number, actually was "' +
306+
this.params.value + '"';
307+
show_popup('warn', fmt_escape_html(e));
308+
} else {
309+
this.params.value = valAsInt;
310+
if (sync_put(this, '/user-limits/:user/:name')) {
311+
update();
312+
}
313+
}
314+
})
315+
sammy.post('#/restart_vhost', function(){
316+
if(sync_post(this, '/vhosts/:vhost/start/:node')) update();
317+
})
318+
sammy.del('#/limits', function() {
319+
if (sync_delete(this, '/vhost-limits/:vhost/:name')) update();
320+
})
321+
sammy.del('#/user-limits', function() {
322+
if (sync_delete(this, '/user-limits/:user/:name')) update();
323+
})
324+
}
325+
path('#/feature-flags', {'feature_flags': {path: '/feature-flags',
326+
options: {sort:true}},
327+
'permissions': '/permissions'}, 'feature-flags');
328+
sammy.put('#/feature-flags-enable', function() {
329+
if (sync_put(this, '/feature-flags/:name/enable'))
330+
update();
331+
return false;
332+
});
297333
sammy.put('#/logout', function() {
298334
// clear a local storage value used by earlier versions
299335
clear_auth()
@@ -312,48 +348,7 @@ dispatcher_add(function(sammy) {
312348
sammy.put('#/column-options', function() {
313349
update_column_options(this);
314350
});
315-
path('#/limits', {'limits': '/vhost-limits',
316-
'user_limits': '/user-limits',
317-
'users': '/users',
318-
'vhosts': '/vhosts'}, 'limits');
319351

320-
sammy.put('#/limits', function() {
321-
var valAsInt = parseInt(this.params.value);
322-
if (isNaN(valAsInt)) {
323-
var e = 'Validation failed\n\n' +
324-
this.params.name + ' should be a number, actually was "' +
325-
this.params.value + '"';
326-
show_popup('warn', fmt_escape_html(e));
327-
} else {
328-
this.params.value = valAsInt;
329-
if (sync_put(this, '/vhost-limits/:vhost/:name')) {
330-
update();
331-
}
332-
}
333-
});
334-
sammy.put('#/user-limits', function() {
335-
var valAsInt = parseInt(this.params.value);
336-
if (isNaN(valAsInt)) {
337-
var e = 'Validation failed\n\n' +
338-
this.params.name + ' should be a number, actually was "' +
339-
this.params.value + '"';
340-
show_popup('warn', fmt_escape_html(e));
341-
} else {
342-
this.params.value = valAsInt;
343-
if (sync_put(this, '/user-limits/:user/:name')) {
344-
update();
345-
}
346-
}
347-
});
348-
sammy.post('#/restart_vhost', function(){
349-
if(sync_post(this, '/vhosts/:vhost/start/:node')) update();
350-
})
351-
sammy.del('#/limits', function() {
352-
if (sync_delete(this, '/vhost-limits/:vhost/:name')) update();
353-
});
354-
sammy.del('#/user-limits', function() {
355-
if (sync_delete(this, '/user-limits/:user/:name')) update();
356-
});
357352
sammy.del("#/reset", function(){
358353
if(sync_delete(this, '/reset')){
359354
update();

0 commit comments

Comments
 (0)