mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 18:56:17 +01:00
updates
This commit is contained in:
@@ -25,8 +25,14 @@ export const $authenticated = atom(pb.authStore.isValid)
|
||||
/** List of system records */
|
||||
export const $systems = atom([] as SystemRecord[])
|
||||
|
||||
/** Last updated system record (realtime) */
|
||||
export const $updatedSystem = atom({} as SystemRecord)
|
||||
|
||||
/** List of alert records */
|
||||
export const $alerts = atom([] as AlertRecord[])
|
||||
|
||||
/** SSH public key */
|
||||
export const $publicKey = atom('')
|
||||
|
||||
/** Chart time period */
|
||||
export const $chartTime = atom('1h')
|
||||
|
||||
@@ -96,3 +96,25 @@ export function updateRecordList<T extends RecordModel>(
|
||||
}
|
||||
$store.set(newRecords)
|
||||
}
|
||||
|
||||
export function getPbTimestamp(timeString: string) {
|
||||
const now = new Date()
|
||||
let timeValue = parseInt(timeString.slice(0, -1))
|
||||
let unit = timeString.slice(-1)
|
||||
|
||||
if (unit === 'h') {
|
||||
now.setUTCHours(now.getUTCHours() - timeValue)
|
||||
} else {
|
||||
// d
|
||||
now.setUTCDate(now.getUTCDate() - timeValue)
|
||||
}
|
||||
|
||||
const year = now.getUTCFullYear()
|
||||
const month = String(now.getUTCMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getUTCDate()).padStart(2, '0')
|
||||
const hours = String(now.getUTCHours()).padStart(2, '0')
|
||||
const minutes = String(now.getUTCMinutes()).padStart(2, '0')
|
||||
const seconds = String(now.getUTCSeconds()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user