mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 07:23:00 +00:00
create multiple users in admin panel
usernames separated by lines
This commit is contained in:
@@ -42,7 +42,7 @@ require(["jquery", "bootstrap", "moment", "jhapi", "utils"], function ($, bs, mo
|
||||
$("th").map(function (i, th) {
|
||||
th = $(th);
|
||||
var col = th.data('sort');
|
||||
if (!col || col.length == 0) {
|
||||
if (!col || col.length === 0) {
|
||||
return;
|
||||
}
|
||||
var order = th.find('i').hasClass('fa-sort-desc') ? 'asc':'desc';
|
||||
@@ -50,7 +50,7 @@ require(["jquery", "bootstrap", "moment", "jhapi", "utils"], function ($, bs, mo
|
||||
function () {
|
||||
resort(col, order);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
$(".time-col").map(function (i, el) {
|
||||
@@ -161,9 +161,17 @@ require(["jquery", "bootstrap", "moment", "jhapi", "utils"], function ($, bs, mo
|
||||
|
||||
$("#add-user-dialog").find(".save-button").click(function () {
|
||||
var dialog = $("#add-user-dialog");
|
||||
var username = dialog.find(".username-input").val();
|
||||
var lines = dialog.find(".username-input").val().split('\n');
|
||||
var admin = dialog.find(".admin-checkbox").prop("checked");
|
||||
api.add_user(username, {admin: admin}, {
|
||||
var usernames = [];
|
||||
lines.map(function (line) {
|
||||
var username = line.trim();
|
||||
if (username.length) {
|
||||
usernames.push(username);
|
||||
}
|
||||
});
|
||||
|
||||
api.add_users(usernames, {admin: admin}, {
|
||||
success: function () {
|
||||
window.location.reload();
|
||||
}
|
||||
|
@@ -72,18 +72,16 @@ define(['jquery', 'utils'], function ($, utils) {
|
||||
);
|
||||
};
|
||||
|
||||
JHAPI.prototype.add_user = function (user, userinfo, options) {
|
||||
JHAPI.prototype.add_users = function (usernames, userinfo, options) {
|
||||
options = options || {};
|
||||
var data = update(userinfo, {usernames: usernames});
|
||||
options = update(options, {
|
||||
type: 'POST',
|
||||
dataType: null,
|
||||
data: JSON.stringify(userinfo)
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
|
||||
this.api_request(
|
||||
utils.url_path_join('users', user),
|
||||
options
|
||||
);
|
||||
this.api_request('users', options);
|
||||
};
|
||||
|
||||
JHAPI.prototype.edit_user = function (user, userinfo, options) {
|
||||
|
@@ -86,10 +86,17 @@
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
{% macro user_modal(name) %}
|
||||
{% macro user_modal(name, multi=False) %}
|
||||
{% call modal(name, btn_class='btn-primary save-button') %}
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control username-input" placeholder="username">
|
||||
<{%- if multi -%}
|
||||
textarea
|
||||
{%- else -%}
|
||||
input type="text"
|
||||
{%- endif %}
|
||||
class="form-control username-input"
|
||||
placeholder="{%- if multi -%} usernames separated by lines{%- else -%} username {%-endif-%}">
|
||||
{%- if multi -%}</textarea>{%- endif -%}
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
@@ -101,7 +108,7 @@
|
||||
|
||||
{{ user_modal('Edit User') }}
|
||||
|
||||
{{ user_modal('Add User') }}
|
||||
{{ user_modal('Add User', multi=True) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
Reference in New Issue
Block a user