feat(console): sort the monitor list and put monitors in an order of one's own
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m49s
ci / test (pull_request) Successful in 14m39s
ci / build (pull_request) Canceled after 14m22s
ci / image (pull_request) Canceled after 0s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m49s
ci / test (pull_request) Successful in 14m39s
ci / build (pull_request) Canceled after 14m22s
ci / image (pull_request) Canceled after 0s
The monitor list gets a sort switcher: the organization's own order, by default, or by name, status (problems first), uptime (worst first) or latency (slowest first). The choice is remembered in a cookie; paging follows it. "Arrange monitors" shows the whole tree with each group's monitors to drag, or move with up and down, into the order wanted; every change is saved at once through PUT /api/v1/org/monitors/order, which needs write access to every monitor given and is audited. Monitors without a position follow the positioned ones, by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
ca852c8299
commit
b0d4bcc002
16 files changed
+3389
-2653
No files matched your search
@@ -58,7 +58,7 @@ func (q *Queries) AllMonitorRegions(ctx context.Context) ([]AllMonitorRegionsRow
|
||||
const createMonitor = `-- name: CreateMonitor :one
|
||||
INSERT INTO monitors (org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, confirmations, group_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id
|
||||
RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position
|
||||
`
|
||||
|
||||
type CreateMonitorParams struct {
|
||||
@@ -102,6 +102,7 @@ func (q *Queries) CreateMonitor(ctx context.Context, arg CreateMonitorParams) (M
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -128,7 +129,7 @@ func (q *Queries) DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID)
|
||||
}
|
||||
|
||||
const getMonitor = `-- name: GetMonitor :one
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors WHERE id = $1
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, error) {
|
||||
@@ -148,6 +149,7 @@ func (q *Queries) GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, error)
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -190,7 +192,7 @@ func (q *Queries) ListEnabledMonitorsForSchedule(ctx context.Context) ([]ListEna
|
||||
}
|
||||
|
||||
const listMonitors = `-- name: ListMonitors :many
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors ORDER BY name
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors ORDER BY name
|
||||
`
|
||||
|
||||
func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) {
|
||||
@@ -216,6 +218,7 @@ func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) {
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -228,7 +231,7 @@ func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) {
|
||||
}
|
||||
|
||||
const listMonitorsPage = `-- name: ListMonitorsPage :many
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors
|
||||
SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors
|
||||
WHERE true
|
||||
AND ($1::text IS NULL OR (name, id) > ($1, $2::uuid))
|
||||
AND ($3::text IS NULL OR (name, id) < ($3, $4::uuid))
|
||||
@@ -277,6 +280,7 @@ func (q *Queries) ListMonitorsPage(ctx context.Context, arg ListMonitorsPagePara
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -313,7 +317,7 @@ func (q *Queries) MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]uu
|
||||
}
|
||||
|
||||
const monitorsForJobs = `-- name: MonitorsForJobs :many
|
||||
SELECT m.id, m.org_id, m.name, m.type, m.target, m.interval_seconds, m.timeout_ms, m.config, m.enabled, m.created_at, m.updated_at, m.confirmations, m.group_id FROM monitors m
|
||||
SELECT m.id, m.org_id, m.name, m.type, m.target, m.interval_seconds, m.timeout_ms, m.config, m.enabled, m.created_at, m.updated_at, m.confirmations, m.group_id, m.position FROM monitors m
|
||||
JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = $1
|
||||
JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL
|
||||
WHERE m.id = ANY ($2::uuid[]) AND m.enabled
|
||||
@@ -352,6 +356,7 @@ func (q *Queries) MonitorsForJobs(ctx context.Context, arg MonitorsForJobsParams
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -419,11 +424,28 @@ func (q *Queries) MonitorsForResults(ctx context.Context, arg MonitorsForResults
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setMonitorPosition = `-- name: SetMonitorPosition :execrows
|
||||
UPDATE monitors SET position = $1 WHERE id = $2
|
||||
`
|
||||
|
||||
type SetMonitorPositionParams struct {
|
||||
Position *int32
|
||||
ID uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) SetMonitorPosition(ctx context.Context, arg SetMonitorPositionParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, setMonitorPosition, arg.Position, arg.ID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const updateMonitor = `-- name: UpdateMonitor :one
|
||||
UPDATE monitors SET name = $2, type = $3, target = $4, interval_seconds = $5,
|
||||
timeout_ms = $6, config = $7, enabled = $8, confirmations = $9, group_id = $10, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id
|
||||
RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position
|
||||
`
|
||||
|
||||
type UpdateMonitorParams struct {
|
||||
@@ -467,6 +489,7 @@ func (q *Queries) UpdateMonitor(ctx context.Context, arg UpdateMonitorParams) (M
|
||||
&i.UpdatedAt,
|
||||
&i.Confirmations,
|
||||
&i.GroupID,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in new issue
Block a user