mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
sort token / fingerprint table by system name
This commit is contained in:
@@ -42,6 +42,10 @@ const pbFingerprintOptions = {
|
|||||||
fields: "id,fingerprint,token,system,expand.system.name",
|
fields: "id,fingerprint,token,system,expand.system.name",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sortFingerprints(fingerprints: FingerprintRecord[]) {
|
||||||
|
return fingerprints.sort((a, b) => a.expand.system.name.localeCompare(b.expand.system.name))
|
||||||
|
}
|
||||||
|
|
||||||
const SettingsFingerprintsPage = memo(() => {
|
const SettingsFingerprintsPage = memo(() => {
|
||||||
if (isReadOnlyUser()) {
|
if (isReadOnlyUser()) {
|
||||||
redirectPage($router, "settings", { name: "general" })
|
redirectPage($router, "settings", { name: "general" })
|
||||||
@@ -51,9 +55,10 @@ const SettingsFingerprintsPage = memo(() => {
|
|||||||
// Get fingerprint records on mount
|
// Get fingerprint records on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pb.collection("fingerprints")
|
pb.collection("fingerprints")
|
||||||
.getFullList(pbFingerprintOptions)
|
.getFullList<FingerprintRecord>(pbFingerprintOptions)
|
||||||
// @ts-ignore
|
.then((prints) => {
|
||||||
.then(setFingerprints)
|
setFingerprints(sortFingerprints(prints))
|
||||||
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Subscribe to fingerprint updates
|
// Subscribe to fingerprint updates
|
||||||
@@ -66,7 +71,7 @@ const SettingsFingerprintsPage = memo(() => {
|
|||||||
(res) => {
|
(res) => {
|
||||||
setFingerprints((currentFingerprints) => {
|
setFingerprints((currentFingerprints) => {
|
||||||
if (res.action === "create") {
|
if (res.action === "create") {
|
||||||
return [...currentFingerprints, res.record as FingerprintRecord]
|
return sortFingerprints([...currentFingerprints, res.record as FingerprintRecord])
|
||||||
}
|
}
|
||||||
if (res.action === "update") {
|
if (res.action === "update") {
|
||||||
return currentFingerprints.map((fingerprint) => {
|
return currentFingerprints.map((fingerprint) => {
|
||||||
|
Reference in New Issue
Block a user