Add a loading icon for deck upload
This commit is contained in:
parent
62e92eaf92
commit
82539bfc60
@ -4,6 +4,7 @@
|
|||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div>
|
<div>
|
||||||
<button type="button" @click="upload"> Save Deck </button>
|
<button type="button" @click="upload"> Save Deck </button>
|
||||||
|
<Loader :loading="uploading"></Loader>
|
||||||
Download:
|
Download:
|
||||||
<button type="button" @click="jsonInputDownload">
|
<button type="button" @click="jsonInputDownload">
|
||||||
Input JSON
|
Input JSON
|
||||||
@ -57,14 +58,16 @@
|
|||||||
<script>
|
<script>
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import Deck from './Deck.vue';
|
import Deck from './Deck.vue';
|
||||||
|
import Loader from './Loader.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Editor',
|
name: 'Editor',
|
||||||
components: {Deck},
|
components: {Deck, Loader},
|
||||||
|
|
||||||
props: ['deckID'],
|
props: ['deckID'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
uploading: false,
|
||||||
selected: null,
|
selected: null,
|
||||||
deckInfo: {meta: {name: "", type: ""},
|
deckInfo: {meta: {name: "", type: ""},
|
||||||
cards: {}},
|
cards: {}},
|
||||||
@ -119,6 +122,7 @@
|
|||||||
|
|
||||||
upload() {
|
upload() {
|
||||||
// POST the inputed json to the server
|
// POST the inputed json to the server
|
||||||
|
this.uploading = true;
|
||||||
fetch('/upload', {
|
fetch('/upload', {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
@ -129,7 +133,10 @@
|
|||||||
css: document.styleSheets[0].href,
|
css: document.styleSheets[0].href,
|
||||||
})})
|
})})
|
||||||
.then(r => r.json())
|
.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));
|
.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