Web interface: show warning when trying to register already registered username

This commit is contained in:
Jan Kaluza 2016-02-10 18:50:11 +01:00
parent c80c02ccb1
commit 2eccba0698
2 changed files with 12 additions and 8 deletions

View file

@ -197,20 +197,24 @@ function fill_instances_register_form() {
function fill_users_register_form() {
$(".button").click(function(e) {
e.preventDefault();
$(this).parent().empty().progressbar( {value: false} ).css('height', '1em');
var postdata ={
"username": $("#username").val(),
"password": $("#password").val()
};
$.post($.cookie("base_location") + "api/v1/users/add", postdata, function(data) {
var query = getQueryParams(document.location.search);
if (query.back_to_list == "1") {
window.location.replace("list.shtml");
$.post("/api/v1/users/add", postdata, function(data) {
if (data.error) {
$('#error').text(data.message);
}
else {
window.location.replace("../login/");
var query = getQueryParams(document.location.search);
if (query.back_to_list == "1") {
window.location.replace("list.shtml");
}
else {
window.location.replace("../login/");
}
}
});
})

View file

@ -1,7 +1,7 @@
<!--#include virtual="/header.shtml" -->
<h2>Register new Spectrum 2 manager account</h2>
<div id="error" style="text-align:center;color:red;"></div>
<form action="/api/v1/users/add" class="basic-grey" method="POST">
<h1>Register user
<span>Register new user to Spectrum 2 manager web interface.</span>
@ -13,7 +13,7 @@
<label><span>Password:</span>
<input type="password" id="password" name="password" placeholder="Password"></textarea>
</label>
<label>
<label id="submitbutton">
<span>&nbsp;</span>
<input type="submit" class="button" value="Add user" />
</label>