This commit is contained in:
Alex Yatskov 2016-11-08 20:34:28 -08:00
parent 885f508eda
commit 5bbf9aa07b
2 changed files with 15 additions and 9 deletions

View File

@ -122,8 +122,8 @@ function populateDictionaries(opts) {
const dictError = $('#dict-error'); const dictError = $('#dict-error');
dictError.hide(); dictError.hide();
const dictLaggy = $('#dict-laggy'); const dictSpinner = $('#dict-spinner');
dictLaggy.show(); dictSpinner.show();
database().getDictionaries().then(rows => { database().getDictionaries().then(rows => {
rows.forEach(row => { rows.forEach(row => {
@ -145,7 +145,7 @@ function populateDictionaries(opts) {
}).catch(error => { }).catch(error => {
dictError.show().find('span').text(error); dictError.show().find('span').text(error);
}).then(() => { }).then(() => {
dictLaggy.hide(); dictSpinner.hide();
}); });
} }
@ -156,12 +156,17 @@ function onDictionaryDelete() {
const dictError = $('#dict-error'); const dictError = $('#dict-error');
dictError.hide(); dictError.hide();
const dictSpinner = $('#dict-spinner');
dictSpinner.show();
const dictGroup = dictDelete.closest('.dict-group'); const dictGroup = dictDelete.closest('.dict-group');
database().deleteDictionary(dictGroup.data('title')).then(() => { database().deleteDictionary(dictGroup.data('title')).then(() => {
dictGroup.slideUp(); dictGroup.slideUp();
}).catch(error => { }).catch(error => {
dictError.show().find('span').text(error); dictError.show().find('span').text(error);
dictDelete.prop('disabled', false); dictDelete.prop('disabled', false);
}).then(() => {
dictSpinner.hide();
}); });
} }
@ -172,6 +177,9 @@ function onDictionaryImport() {
const dictError = $('#dict-error'); const dictError = $('#dict-error');
dictError.hide(); dictError.hide();
const dictSpinner = $('#dict-spinner');
dictSpinner.show();
const progressbar = $('#dict-import-progress'); const progressbar = $('#dict-import-progress');
progressbar.show(); progressbar.show();
@ -185,9 +193,10 @@ function onDictionaryImport() {
}).catch(error => { }).catch(error => {
dictError.show().find('span').text(error); dictError.show().find('span').text(error);
}).then(() => { }).then(() => {
dictImport.prop('disabled', false);
dictUrl.val(''); dictUrl.val('');
progressbar.hide(); progressbar.hide();
dictImport.prop('disabled', false); dictSpinner.hide();
}); });
} }

View File

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css"> <link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
<style> <style>
#anki-spinner, #anki-general, #anki-error, #dict-error, #dict-import-progress, #dict-delete-progress, #dict-laggy, #options-advanced { #anki-spinner, #anki-general, #anki-error, #dict-spinner, #dict-import-progress, #dict-delete-progress, #dict-laggy, #options-advanced {
display: none; display: none;
} }
@ -65,6 +65,7 @@
<div> <div>
<h3>Dictionaries</h3> <h3>Dictionaries</h3>
<img src="img/spinner.gif" class="pull-right" id="dict-spinner" alt>
<div id="dict-groups"></div> <div id="dict-groups"></div>
<div class="alert alert-danger" id="dict-error"> <div class="alert alert-danger" id="dict-error">
@ -72,10 +73,6 @@
<span></span> <span></span>
</div> </div>
<div class="alert alert-warning" id="dict-laggy">
The dictionary database appears to be busy; please wait for currently executing tasks to complete.
</div>
<div class="progress" id="dict-import-progress"> <div class="progress" id="dict-import-progress">
<div class="progress-bar progress-bar-striped" style="width: 0%"></div> <div class="progress-bar progress-bar-striped" style="width: 0%"></div>
</div> </div>