mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-17 17:06:56 +08:00
Feat: Use UptimeCalculator
for PingChart (#4264)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
@@ -41,6 +41,33 @@ export default {
|
||||
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a Unix timestamp to a formatted date and time string.
|
||||
* @param {number} value - The Unix timestamp to convert.
|
||||
* @returns {string} The formatted date and time string.
|
||||
*/
|
||||
unixToDateTime(value) {
|
||||
return dayjs.unix(value).tz(this.timezone).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a Unix timestamp to a dayjs object.
|
||||
* @param {number} value - The Unix timestamp to convert.
|
||||
* @returns {dayjs.Dayjs} The dayjs object representing the given timestamp.
|
||||
*/
|
||||
unixToDayjs(value) {
|
||||
return dayjs.unix(value).tz(this.timezone);
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the given value to a dayjs object.
|
||||
* @param {string} value - the value to be converted
|
||||
* @returns {dayjs.Dayjs} a dayjs object in the timezone of this instance
|
||||
*/
|
||||
toDayjs(value) {
|
||||
return dayjs.utc(value).tz(this.timezone);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get time for maintenance
|
||||
* @param {string | number | Date | dayjs.Dayjs} value Time to
|
||||
|
@@ -673,6 +673,17 @@ export default {
|
||||
getMonitorBeats(monitorID, period, callback) {
|
||||
socket.emit("getMonitorBeats", monitorID, period, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves monitor chart data.
|
||||
* @param {string} monitorID - The ID of the monitor.
|
||||
* @param {number} period - The time period for the chart data, in hours.
|
||||
* @param {socketCB} callback - The callback function to handle the chart data.
|
||||
* @returns {void}
|
||||
*/
|
||||
getMonitorChartData(monitorID, period, callback) {
|
||||
socket.emit("getMonitorChartData", monitorID, period, callback);
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
Reference in New Issue
Block a user