mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 06:22:59 +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.
|
// Copyright (c) Jupyter Development Team.
|
||||||
// Distributed under the terms of the Modified BSD License.
|
// Distributed under the terms of the Modified BSD License.
|
||||||
|
|
||||||
require(["jquery", "jhapi", "moment"], function ($, JHAPI, moment) {
|
require(["jquery", "jhapi", "moment"], function($, JHAPI, moment) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var base_url = window.jhdata.base_url;
|
var base_url = window.jhdata.base_url;
|
||||||
var user = window.jhdata.user;
|
var user = window.jhdata.user;
|
||||||
var api = new JHAPI(base_url);
|
var api = new JHAPI(base_url);
|
||||||
|
|
||||||
$(".time-col").map(function (i, el) {
|
$(".time-col").map(function(i, el) {
|
||||||
// convert ISO datestamps to nice momentjs ones
|
// convert ISO datestamps to nice momentjs ones
|
||||||
el = $(el);
|
el = $(el);
|
||||||
let m = moment(new Date(el.text().trim()));
|
let m = moment(new Date(el.text().trim()));
|
||||||
el.text(m.isValid() ? m.fromNow() : "Never");
|
el.text(m.isValid() ? m.fromNow() : "Never");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#request-token").click(function () {
|
$("#request-token-form").submit(function() {
|
||||||
api.request_token({
|
var note = $("#token-note").val();
|
||||||
success: function (reply) {
|
if (!note.length) {
|
||||||
|
note = "requested via form page";
|
||||||
|
}
|
||||||
|
api.request_token(
|
||||||
|
user,
|
||||||
|
{ note: note },
|
||||||
|
{
|
||||||
|
success: function(reply) {
|
||||||
$("#token-result").text(reply.token);
|
$("#token-result").text(reply.token);
|
||||||
$("#token-area").show();
|
$("#token-area").show();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,12 +4,25 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<form id="request-token-form" class="col-md-offset-3 col-md-6">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<a id="request-token" role="button" class="btn btn-lg btn-jupyter" href="#">
|
<button type="submit" class="btn btn-lg btn-jupyter">
|
||||||
Request new API token
|
Request new API token
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="token-note">Note</label>
|
||||||
|
<input
|
||||||
|
id="token-note"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="note to identify your new token">
|
||||||
|
<small id="note-note" class="form-text text-muted">
|
||||||
|
This note will help you keep track of what your tokens are for.
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p>
|
<p>
|
||||||
<div id="token-area" class="col-md-6 col-md-offset-3" style="display: none;">
|
<div id="token-area" class="col-md-6 col-md-offset-3" style="display: none;">
|
||||||
|
Reference in New Issue
Block a user