Refactors all Glances widgets to inherit from parent mixin

This commit is contained in:
Alicia Sykes
2022-01-19 11:43:04 +00:00
parent ea3ffa5d36
commit dfea4e317c
14 changed files with 75 additions and 107 deletions

View File

@@ -20,10 +20,11 @@
<script>
import WidgetMixin from '@/mixins/WidgetMixin';
import GlancesMixin from '@/mixins/GlancesMixin';
import { timestampToDateTime, getTimeAgo, getTimeDifference } from '@/utils/MiscHelpers';
export default {
mixins: [WidgetMixin],
mixins: [WidgetMixin, GlancesMixin],
data() {
return {
alerts: null,
@@ -31,19 +32,12 @@ export default {
};
},
computed: {
hostname() {
if (!this.options.hostname) this.error('You must specify a \'hostname\' for Glaces');
return this.options.hostname;
},
endpoint() {
return `${this.hostname}/api/3/alert`;
return this.makeGlancesUrl('alert');
},
},
filters: {},
methods: {
fetchData() {
this.makeRequest(this.endpoint).then(this.processData);
},
processData(alertData) {
if (!alertData || alertData.length === 0) {
this.noResults = true;