Created
May 10, 2019 12:34
-
-
Save ntakouris/aaaebf087ae3e364b54290598e747dc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<!-- ... --> | |
<h2 class="row">Online Nodes</h2> | |
<div class="row"> | |
<p v-if="error == '' && !loading && nodes.length == 0">No nodes found</p> | |
<div v-if="!loading && processedNodes.length > 0" class="table-responsive"> | |
<!-- ... --> | |
</div> | |
</div> | |
<div v-if="loading && error.length != 0" class="row justify-content-center"> | |
<Spinner></Spinner> | |
</div> | |
<div class="row"> | |
<p class="text-center" style="color: red;">{{ error }}</p> | |
</div> | |
</div> | |
</template> | |
<script> | |
import { mapState } from 'vuex' | |
import Spinner from '@/components/Util/Spinner' | |
export default { | |
name: 'NodeList', | |
components: { | |
Spinner | |
}, | |
data () { | |
return { | |
loading: false, | |
error: '' | |
} | |
}, | |
async mounted () { // note this function | |
this.error = '' | |
this.loading = true | |
try { | |
await this.$store.dispatch('nodes/getNodeList') | |
} catch (e) { | |
this.error = e | |
} | |
this.loading = false | |
}, | |
computed: { | |
...mapState({ | |
nodes: state => state.nodes.nodeList | |
}), | |
} | |
} | |
</script> | |
<style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment