🚧 Commiting to switch computers...
This commit is contained in:
@@ -57,6 +57,9 @@ export default {
|
||||
if (!this.options.hostname) this.error('A hostname is required');
|
||||
return this.options.hostname;
|
||||
},
|
||||
limit() {
|
||||
return this.options.limit;
|
||||
},
|
||||
proxyReqEndpoint() {
|
||||
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
|
||||
return `${baseUrl}${serviceEndpoints.corsProxy}`;
|
||||
@@ -114,7 +117,7 @@ export default {
|
||||
return 'unknown';
|
||||
},
|
||||
processData(data) {
|
||||
const services = [];
|
||||
let services = [];
|
||||
data.forEach((service) => {
|
||||
services.push({
|
||||
name: service.name,
|
||||
@@ -128,6 +131,7 @@ export default {
|
||||
lastFailure: this.getTimeAgo(service.last_error),
|
||||
});
|
||||
});
|
||||
if (this.limit) services = services.slice(0, this.limit);
|
||||
this.services = services;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -290,6 +290,7 @@ export default {
|
||||
loading: false,
|
||||
error: false,
|
||||
errorMsg: null,
|
||||
updater: null, // Stores interval
|
||||
}),
|
||||
computed: {
|
||||
/* Returns the widget type, shows error if not specified */
|
||||
@@ -308,6 +309,20 @@ export default {
|
||||
widgetRef() {
|
||||
return `widget-${this.widgetType}-${this.index}`;
|
||||
},
|
||||
/* Returns either `false` or a number in ms to continuously update widget data */
|
||||
updateInterval() {
|
||||
const usersInterval = this.widget.updateInterval;
|
||||
if (!usersInterval) return false;
|
||||
// If set to `true`, then default to 30 seconds
|
||||
if (typeof usersInterval === 'boolean') return 30 * 1000;
|
||||
// If set to a number, and within valid range, return user choice
|
||||
if (typeof usersInterval === 'number'
|
||||
&& usersInterval >= 10
|
||||
&& usersInterval < 7200) {
|
||||
return usersInterval * 1000;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
/* Calls update data method on widget */
|
||||
@@ -328,6 +343,17 @@ export default {
|
||||
this.loading = loading;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// If continuous updates enabled, create interval
|
||||
if (this.updateInterval) {
|
||||
this.updater = setInterval(() => {
|
||||
this.update();
|
||||
}, this.updateInterval);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.updater);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -488,8 +488,7 @@
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"items"
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
@@ -716,9 +715,30 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"widgets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"title": "Widget Type",
|
||||
"type": "string",
|
||||
"description": "The type of widget to use, see docs for supported options"
|
||||
},
|
||||
"options": {
|
||||
"title": "Widget Options",
|
||||
"type": "object",
|
||||
"description": "Configuration options for widget. Varies depending on widget type, see docs for all options"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user