mirror of https://github.com/Lissy93/dashy.git
⚡ Refactors NetData widget data requeest
This commit is contained in:
parent
6e2ae6d3fc
commit
eb1bc69155
|
@ -33,9 +33,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to NetData */
|
/* Make GET request to NetData */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
this.makeRequest(this.endpoint).then(
|
this.makeRequest(this.endpoint).then(this.processData);
|
||||||
(response) => { this.processData(response); },
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(inputData) {
|
processData(inputData) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
|
||||||
import WidgetMixin from '@/mixins/WidgetMixin';
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
import ChartingMixin from '@/mixins/ChartingMixin';
|
import ChartingMixin from '@/mixins/ChartingMixin';
|
||||||
|
|
||||||
|
@ -34,16 +33,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to NetData */
|
/* Make GET request to NetData */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
axios.get(this.endpoint)
|
this.makeRequest(this.endpoint).then(this.processData);
|
||||||
.then((response) => {
|
|
||||||
this.processData(response.data);
|
|
||||||
})
|
|
||||||
.catch((dataFetchError) => {
|
|
||||||
this.error('Unable to fetch data', dataFetchError);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.finishLoading();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(data) {
|
processData(data) {
|
||||||
|
|
|
@ -36,9 +36,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
/* Make GET request to NetData */
|
/* Make GET request to NetData */
|
||||||
fetchData() {
|
fetchData() {
|
||||||
this.makeRequest(this.endpoint).then(
|
this.makeRequest(this.endpoint).then(this.processData);
|
||||||
(response) => { this.processData(response); },
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(inputData) {
|
processData(inputData) {
|
||||||
|
|
|
@ -196,7 +196,7 @@
|
||||||
:ref="widgetRef"
|
:ref="widgetRef"
|
||||||
/>
|
/>
|
||||||
<GlNetworkTraffic
|
<GlNetworkTraffic
|
||||||
v-else-if="widgetType === 'gl-network-activity'"
|
v-else-if="widgetType === 'gl-network-traffic'"
|
||||||
:options="widgetOptions"
|
:options="widgetOptions"
|
||||||
@loading="setLoaderState"
|
@loading="setLoaderState"
|
||||||
@error="handleError"
|
@error="handleError"
|
||||||
|
|
Loading…
Reference in New Issue