frontend: Add create-bot loading indicator.

The former "the-bot-is-being-created" indicator was useless,
since it only edited the value attribute of the "create-bot" button;
that attribute only sets the text of a button when it is initially created.

This commit replaces the old code with a spinning loading indicator,
like the one used for editing bots.
This commit is contained in:
Robert Hönig
2018-02-14 09:29:33 +01:00
committed by Tim Abbott
parent 47f3af9e50
commit 35c7428490
2 changed files with 4 additions and 2 deletions

View File

@@ -135,6 +135,7 @@ exports.set_up = function () {
var interface_type = $('#create_interface_type').val();
var service_name = $('#select_service_name :selected').val();
var formData = new FormData();
var spinner = $('.create_bot_spinner');
formData.append('csrfmiddlewaretoken', csrf_token);
formData.append('bot_type', bot_type);
@@ -156,7 +157,7 @@ exports.set_up = function () {
jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) {
formData.append('file-'+i, file);
});
$('#create_bot_button').val('Adding bot...').prop('disabled', true);
loading.make_indicator(spinner, {text: i18n.t('Creating bot')});
channel.post({
url: '/json/bots',
data: formData,
@@ -186,7 +187,7 @@ exports.set_up = function () {
$('#bot_table_error').text(JSON.parse(xhr.responseText).msg).show();
},
complete: function () {
$('#create_bot_button').val('Create bot').prop('disabled', false);
loading.destroy_indicator(spinner);
},
});
},

View File

@@ -100,6 +100,7 @@
<button type="submit" class="button white rounded sea-green" id="create_bot_button">
{{t 'Create bot' }}
</button>
<div class="create_bot_spinner"></div>
</div>
</form>
</div>