sorting
This commit is contained in:
1 parent
e3921beac4
commit
0a408f8cfd
2 files changed
+10
-2
No files matched your search
@@ -28,7 +28,7 @@ export const useStatusPageForm = ({
|
|||||||
url: data?.url || generateDefaultUrl(),
|
url: data?.url || generateDefaultUrl(),
|
||||||
timezone: data?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
timezone: data?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
color: data?.color || "#4169E1",
|
color: data?.color || "#4169E1",
|
||||||
monitors: monitors?.map((m) => m.id) || [],
|
monitors: data?.monitors || [],
|
||||||
isPublished: data?.isPublished ?? false,
|
isPublished: data?.isPublished ?? false,
|
||||||
showCharts: data?.showCharts ?? true,
|
showCharts: data?.showCharts ?? true,
|
||||||
showUptimePercentage: data?.showUptimePercentage ?? true,
|
showUptimePercentage: data?.showUptimePercentage ?? true,
|
||||||
|
|||||||
@@ -82,7 +82,15 @@ class StatusPageController {
|
|||||||
const showURL = settings.showURL;
|
const showURL = settings.showURL;
|
||||||
|
|
||||||
const monitors = await this.monitorsRepository.findByIds(statusPage.monitors);
|
const monitors = await this.monitorsRepository.findByIds(statusPage.monitors);
|
||||||
const normalizedMonitors = monitors.map((monitor) => {
|
// Sort monitors according to the order in statusPage.monitors
|
||||||
|
const monitorOrder = new Map(statusPage.monitors.map((id, index) => [id, index]));
|
||||||
|
const sortedMonitors = [...monitors].sort((a, b) => {
|
||||||
|
const orderA = monitorOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
const orderB = monitorOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
return orderA - orderB;
|
||||||
|
});
|
||||||
|
|
||||||
|
const normalizedMonitors = sortedMonitors.map((monitor) => {
|
||||||
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
||||||
if (!showURL) {
|
if (!showURL) {
|
||||||
const { url, port, secret, notifications, ...rest } = monitor;
|
const { url, port, secret, notifications, ...rest } = monitor;
|
||||||
|
|||||||
Reference in new issue
Block a user