mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 05:53:00 +00:00
support adding note to new tokens on token page
turn token request into a form
This commit is contained in:
@@ -1,26 +1,36 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
require(["jquery", "jhapi", "moment"], function ($, JHAPI, moment) {
|
||||
"use strict";
|
||||
require(["jquery", "jhapi", "moment"], function($, JHAPI, moment) {
|
||||
"use strict";
|
||||
|
||||
var base_url = window.jhdata.base_url;
|
||||
var user = window.jhdata.user;
|
||||
var api = new JHAPI(base_url);
|
||||
var base_url = window.jhdata.base_url;
|
||||
var user = window.jhdata.user;
|
||||
var api = new JHAPI(base_url);
|
||||
|
||||
$(".time-col").map(function (i, el) {
|
||||
// convert ISO datestamps to nice momentjs ones
|
||||
el = $(el);
|
||||
let m = moment(new Date(el.text().trim()));
|
||||
el.text(m.isValid() ? m.fromNow() : "Never");
|
||||
});
|
||||
$(".time-col").map(function(i, el) {
|
||||
// convert ISO datestamps to nice momentjs ones
|
||||
el = $(el);
|
||||
let m = moment(new Date(el.text().trim()));
|
||||
el.text(m.isValid() ? m.fromNow() : "Never");
|
||||
});
|
||||
|
||||
$("#request-token").click(function () {
|
||||
api.request_token({
|
||||
success: function (reply) {
|
||||
$("#token-result").text(reply.token);
|
||||
$("#token-area").show();
|
||||
}
|
||||
});
|
||||
$("#request-token-form").submit(function() {
|
||||
var note = $("#token-note").val();
|
||||
if (!note.length) {
|
||||
note = "requested via form page";
|
||||
}
|
||||
api.request_token(
|
||||
user,
|
||||
{ note: note },
|
||||
{
|
||||
success: function(reply) {
|
||||
$("#token-result").text(reply.token);
|
||||
$("#token-area").show();
|
||||
},
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user