Add a loading icon for deck upload
This commit is contained in:
parent
a4bd5f0605
commit
adced87ca3
@ -4,6 +4,7 @@
|
||||
<div id="controls">
|
||||
<div>
|
||||
<button type="button" @click="upload"> Save Deck </button>
|
||||
<Loader :loading="uploading"></Loader>
|
||||
Download:
|
||||
<button type="button" @click="jsonInputDownload">
|
||||
Input JSON
|
||||
@ -57,14 +58,16 @@
|
||||
<script>
|
||||
import yaml from 'js-yaml';
|
||||
import Deck from './Deck.vue';
|
||||
import Loader from './Loader.vue';
|
||||
|
||||
export default {
|
||||
name: 'Editor',
|
||||
components: {Deck},
|
||||
components: {Deck, Loader},
|
||||
|
||||
props: ['deckID'],
|
||||
data() {
|
||||
return {
|
||||
uploading: false,
|
||||
selected: null,
|
||||
deckInfo: {meta: {name: "", type: ""},
|
||||
cards: {}},
|
||||
@ -119,6 +122,7 @@
|
||||
|
||||
upload() {
|
||||
// POST the inputed json to the server
|
||||
this.uploading = true;
|
||||
fetch('/upload', {
|
||||
method: 'post',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@ -129,7 +133,10 @@
|
||||
css: document.styleSheets[0].href,
|
||||
})})
|
||||
.then(r => r.json())
|
||||
.then(j => this.$router.replace('/edit/' + j.id))
|
||||
.then(j => {
|
||||
this.$router.replace('/edit/' + j.id);
|
||||
this.uploading = false;
|
||||
})
|
||||
.catch(err => console.log('Failed to upload' + err));
|
||||
},
|
||||
},
|
||||
|
27
src/Loader.vue
Normal file
27
src/Loader.vue
Normal file
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div v-show="loading" class="loader"> </div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Loader",
|
||||
props: ['loading'],
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.loader {
|
||||
display: inline-block;
|
||||
border: .33em solid #f3f3f3; /* Light grey */
|
||||
border-top: .33em solid #3498db; /* Blue */
|
||||
border-radius: 50%;
|
||||
width: .33em;
|
||||
height: .33em;
|
||||
animation: spin 2s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user