feat(statuspage): add nested status page groups and optional component details
This commit is contained in:
1 parent
1c31003baf
commit
9b26b4150e
26 files changed
+4566
-760
No files matched your search
+25
-12
@@ -344,18 +344,30 @@ type SsoProvider struct {
|
||||
}
|
||||
|
||||
type StatusPage struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
CustomDomain *string
|
||||
DomainToken string
|
||||
DomainVerifiedAt *time.Time
|
||||
Theme []byte
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
CustomDomain *string
|
||||
DomainToken string
|
||||
DomainVerifiedAt *time.Time
|
||||
Theme []byte
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ShowComponentDetails bool
|
||||
}
|
||||
|
||||
type StatusPageGroup struct {
|
||||
ID uuid.UUID
|
||||
PageID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
ParentID *uuid.UUID
|
||||
Name string
|
||||
Position int32
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type StatusPageMonitor struct {
|
||||
@@ -365,6 +377,7 @@ type StatusPageMonitor struct {
|
||||
Section string
|
||||
Label string
|
||||
Position int32
|
||||
GroupID *uuid.UUID
|
||||
}
|
||||
|
||||
type User struct {
|
||||
|
||||
@@ -36,6 +36,7 @@ type Querier interface {
|
||||
// Shortens tokens that would outlive a newly set maximum lifetime.
|
||||
ClampAPITokenExpiry(ctx context.Context, arg ClampAPITokenExpiryParams) (int64, error)
|
||||
ClearMaintenanceTargets(ctx context.Context, windowID uuid.UUID) error
|
||||
ClearStatusPageGroups(ctx context.Context, pageID uuid.UUID) error
|
||||
ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID) error
|
||||
CountRoleAssignments(ctx context.Context, roleID uuid.UUID) (int64, error)
|
||||
CountUnusedRecoveryCodes(ctx context.Context, userID uuid.UUID) (int64, error)
|
||||
@@ -55,6 +56,7 @@ type Querier interface {
|
||||
CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
|
||||
CreateSSOProvider(ctx context.Context, arg CreateSSOProviderParams) (SsoProvider, error)
|
||||
CreateStatusPage(ctx context.Context, arg CreateStatusPageParams) (StatusPage, error)
|
||||
CreateStatusPageGroup(ctx context.Context, arg CreateStatusPageGroupParams) (StatusPageGroup, error)
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
||||
DailyBuckets(ctx context.Context, arg DailyBucketsParams) ([]DailyBucketsRow, error)
|
||||
DailyBucketsForMonitors(ctx context.Context, arg DailyBucketsForMonitorsParams) ([]DailyBucketsForMonitorsRow, error)
|
||||
@@ -82,6 +84,7 @@ type Querier interface {
|
||||
DeleteRole(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteSSOProvider(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteStatusPage(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteStatusPageGroup(ctx context.Context, arg DeleteStatusPageGroupParams) (int64, error)
|
||||
// Only the latest success per monitor and region is kept.
|
||||
DeleteSuccessEvidence(ctx context.Context, arg DeleteSuccessEvidenceParams) error
|
||||
DeleteUser(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
@@ -179,6 +182,7 @@ type Querier interface {
|
||||
ListPlatformRegions(ctx context.Context) ([]Region, error)
|
||||
ListRoles(ctx context.Context) ([]Role, error)
|
||||
ListSSOProviders(ctx context.Context) ([]SsoProvider, error)
|
||||
ListStatusPageGroups(ctx context.Context, pageID uuid.UUID) ([]StatusPageGroup, error)
|
||||
ListStatusPages(ctx context.Context) ([]StatusPage, error)
|
||||
ListUserIdentitiesInOrg(ctx context.Context, userID uuid.UUID) ([]ListUserIdentitiesInOrgRow, error)
|
||||
ListUserOrgs(ctx context.Context, userID uuid.UUID) ([]ListUserOrgsRow, error)
|
||||
@@ -244,6 +248,8 @@ type Querier interface {
|
||||
RemoveMembership(ctx context.Context, arg RemoveMembershipParams) (int64, error)
|
||||
// Moves the subgroups of a group that is about to be deleted.
|
||||
ReparentGroups(ctx context.Context, arg ReparentGroupsParams) error
|
||||
ReparentStatusPageGroupChildren(ctx context.Context, arg ReparentStatusPageGroupChildrenParams) error
|
||||
ReparentStatusPageGroupMonitors(ctx context.Context, arg ReparentStatusPageGroupMonitorsParams) error
|
||||
ResolveIncident(ctx context.Context, arg ResolveIncidentParams) (Incident, error)
|
||||
// The organization's latest results run by one checker instance.
|
||||
ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error)
|
||||
@@ -254,6 +260,7 @@ type Querier interface {
|
||||
SetPlatformSetting(ctx context.Context, arg SetPlatformSettingParams) error
|
||||
// Changing the domain drops a previous verification.
|
||||
SetStatusPageDomain(ctx context.Context, arg SetStatusPageDomainParams) (StatusPage, error)
|
||||
SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error
|
||||
SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error)
|
||||
SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error
|
||||
// Other instances of the same agent seen in the last day.
|
||||
@@ -278,6 +285,7 @@ type Querier interface {
|
||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||
UpdateSSOProvider(ctx context.Context, arg UpdateSSOProviderParams) (SsoProvider, error)
|
||||
UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error)
|
||||
UpdateStatusPageGroup(ctx context.Context, arg UpdateStatusPageGroupParams) (StatusPageGroup, error)
|
||||
UpsertAlertmanagerAlert(ctx context.Context, arg UpsertAlertmanagerAlertParams) error
|
||||
UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error
|
||||
// Uptime per monitor from the hourly aggregate, including the not yet
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
-- name: CreateStatusPage :one
|
||||
INSERT INTO status_pages (org_id, slug, title, description, published, domain_token, theme)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
INSERT INTO status_pages (org_id, slug, title, description, published, show_component_details, domain_token, theme)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateStatusPage :one
|
||||
UPDATE status_pages SET slug = $2, title = $3, description = $4, published = $5, theme = $6, updated_at = now()
|
||||
UPDATE status_pages
|
||||
SET slug = $2,
|
||||
title = $3,
|
||||
description = $4,
|
||||
published = $5,
|
||||
show_component_details = $6,
|
||||
theme = $7,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
@@ -30,7 +37,8 @@ SELECT * FROM status_pages ORDER BY title;
|
||||
DELETE FROM status_pages WHERE id = $1;
|
||||
|
||||
-- name: StatusPageMonitors :many
|
||||
SELECT spm.monitor_id, spm.section, spm.label, spm.position, m.name AS monitor_name, m.enabled
|
||||
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
||||
FROM status_page_monitors spm
|
||||
JOIN monitors m ON m.id = spm.monitor_id
|
||||
WHERE spm.page_id = $1
|
||||
@@ -40,8 +48,42 @@ ORDER BY spm.position, m.name;
|
||||
DELETE FROM status_page_monitors WHERE page_id = $1;
|
||||
|
||||
-- name: AddStatusPageMonitor :exec
|
||||
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, label, position)
|
||||
VALUES ($1, $2, $3, $4, $5, $6);
|
||||
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, group_id, label, position)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7);
|
||||
|
||||
-- name: SetStatusPageMonitorGroup :exec
|
||||
UPDATE status_page_monitors SET group_id = $3, section = $4
|
||||
WHERE page_id = $1 AND monitor_id = $2;
|
||||
|
||||
-- name: ListStatusPageGroups :many
|
||||
SELECT * FROM status_page_groups
|
||||
WHERE page_id = $1
|
||||
ORDER BY position, name, id;
|
||||
|
||||
-- name: CreateStatusPageGroup :one
|
||||
INSERT INTO status_page_groups (page_id, org_id, parent_id, name, position)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateStatusPageGroup :one
|
||||
UPDATE status_page_groups
|
||||
SET name = $3, parent_id = $4, position = $5, updated_at = now()
|
||||
WHERE id = $1 AND page_id = $2
|
||||
RETURNING *;
|
||||
|
||||
-- name: ReparentStatusPageGroupChildren :exec
|
||||
UPDATE status_page_groups SET parent_id = $3, updated_at = now()
|
||||
WHERE page_id = $1 AND parent_id = $2;
|
||||
|
||||
-- name: ReparentStatusPageGroupMonitors :exec
|
||||
UPDATE status_page_monitors SET group_id = $3
|
||||
WHERE page_id = $1 AND group_id = $2;
|
||||
|
||||
-- name: DeleteStatusPageGroup :execrows
|
||||
DELETE FROM status_page_groups WHERE id = $1 AND page_id = $2;
|
||||
|
||||
-- name: ClearStatusPageGroups :exec
|
||||
DELETE FROM status_page_groups WHERE page_id = $1;
|
||||
|
||||
-- name: FindPublishedPage :one
|
||||
-- System scope: resolves a request to a page by verified custom domain or
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
)
|
||||
|
||||
const addStatusPageMonitor = `-- name: AddStatusPageMonitor :exec
|
||||
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, label, position)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, group_id, label, position)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
`
|
||||
|
||||
type AddStatusPageMonitorParams struct {
|
||||
@@ -21,6 +21,7 @@ type AddStatusPageMonitorParams struct {
|
||||
MonitorID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Section string
|
||||
GroupID *uuid.UUID
|
||||
Label string
|
||||
Position int32
|
||||
}
|
||||
@@ -31,12 +32,22 @@ func (q *Queries) AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMon
|
||||
arg.MonitorID,
|
||||
arg.OrgID,
|
||||
arg.Section,
|
||||
arg.GroupID,
|
||||
arg.Label,
|
||||
arg.Position,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const clearStatusPageGroups = `-- name: ClearStatusPageGroups :exec
|
||||
DELETE FROM status_page_groups WHERE page_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) ClearStatusPageGroups(ctx context.Context, pageID uuid.UUID) error {
|
||||
_, err := q.db.Exec(ctx, clearStatusPageGroups, pageID)
|
||||
return err
|
||||
}
|
||||
|
||||
const clearStatusPageMonitors = `-- name: ClearStatusPageMonitors :exec
|
||||
DELETE FROM status_page_monitors WHERE page_id = $1
|
||||
`
|
||||
@@ -47,19 +58,20 @@ func (q *Queries) ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID)
|
||||
}
|
||||
|
||||
const createStatusPage = `-- name: CreateStatusPage :one
|
||||
INSERT INTO status_pages (org_id, slug, title, description, published, domain_token, theme)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at
|
||||
INSERT INTO status_pages (org_id, slug, title, description, published, show_component_details, domain_token, theme)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details
|
||||
`
|
||||
|
||||
type CreateStatusPageParams struct {
|
||||
OrgID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
DomainToken string
|
||||
Theme []byte
|
||||
OrgID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
ShowComponentDetails bool
|
||||
DomainToken string
|
||||
Theme []byte
|
||||
}
|
||||
|
||||
func (q *Queries) CreateStatusPage(ctx context.Context, arg CreateStatusPageParams) (StatusPage, error) {
|
||||
@@ -69,6 +81,7 @@ func (q *Queries) CreateStatusPage(ctx context.Context, arg CreateStatusPagePara
|
||||
arg.Title,
|
||||
arg.Description,
|
||||
arg.Published,
|
||||
arg.ShowComponentDetails,
|
||||
arg.DomainToken,
|
||||
arg.Theme,
|
||||
)
|
||||
@@ -86,6 +99,43 @@ func (q *Queries) CreateStatusPage(ctx context.Context, arg CreateStatusPagePara
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createStatusPageGroup = `-- name: CreateStatusPageGroup :one
|
||||
INSERT INTO status_page_groups (page_id, org_id, parent_id, name, position)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING id, page_id, org_id, parent_id, name, position, created_at, updated_at
|
||||
`
|
||||
|
||||
type CreateStatusPageGroupParams struct {
|
||||
PageID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
ParentID *uuid.UUID
|
||||
Name string
|
||||
Position int32
|
||||
}
|
||||
|
||||
func (q *Queries) CreateStatusPageGroup(ctx context.Context, arg CreateStatusPageGroupParams) (StatusPageGroup, error) {
|
||||
row := q.db.QueryRow(ctx, createStatusPageGroup,
|
||||
arg.PageID,
|
||||
arg.OrgID,
|
||||
arg.ParentID,
|
||||
arg.Name,
|
||||
arg.Position,
|
||||
)
|
||||
var i StatusPageGroup
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.PageID,
|
||||
&i.OrgID,
|
||||
&i.ParentID,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -102,8 +152,25 @@ func (q *Queries) DeleteStatusPage(ctx context.Context, id uuid.UUID) (int64, er
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const deleteStatusPageGroup = `-- name: DeleteStatusPageGroup :execrows
|
||||
DELETE FROM status_page_groups WHERE id = $1 AND page_id = $2
|
||||
`
|
||||
|
||||
type DeleteStatusPageGroupParams struct {
|
||||
ID uuid.UUID
|
||||
PageID uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteStatusPageGroup(ctx context.Context, arg DeleteStatusPageGroupParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteStatusPageGroup, arg.ID, arg.PageID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const findPublishedPage = `-- name: FindPublishedPage :one
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at FROM status_pages
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages
|
||||
WHERE published
|
||||
AND (($1::citext IS NOT NULL AND custom_domain = $1 AND domain_verified_at IS NOT NULL)
|
||||
OR ($2::citext IS NOT NULL AND slug = $2))
|
||||
@@ -132,12 +199,13 @@ func (q *Queries) FindPublishedPage(ctx context.Context, arg FindPublishedPagePa
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getStatusPage = `-- name: GetStatusPage :one
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at FROM status_pages WHERE id = $1
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage, error) {
|
||||
@@ -156,12 +224,48 @@ func (q *Queries) GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage,
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listStatusPageGroups = `-- name: ListStatusPageGroups :many
|
||||
SELECT id, page_id, org_id, parent_id, name, position, created_at, updated_at FROM status_page_groups
|
||||
WHERE page_id = $1
|
||||
ORDER BY position, name, id
|
||||
`
|
||||
|
||||
func (q *Queries) ListStatusPageGroups(ctx context.Context, pageID uuid.UUID) ([]StatusPageGroup, error) {
|
||||
rows, err := q.db.Query(ctx, listStatusPageGroups, pageID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []StatusPageGroup{}
|
||||
for rows.Next() {
|
||||
var i StatusPageGroup
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.PageID,
|
||||
&i.OrgID,
|
||||
&i.ParentID,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listStatusPages = `-- name: ListStatusPages :many
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at FROM status_pages ORDER BY title
|
||||
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages ORDER BY title
|
||||
`
|
||||
|
||||
func (q *Queries) ListStatusPages(ctx context.Context) ([]StatusPage, error) {
|
||||
@@ -186,6 +290,7 @@ func (q *Queries) ListStatusPages(ctx context.Context) ([]StatusPage, error) {
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -206,13 +311,45 @@ func (q *Queries) MarkDomainVerified(ctx context.Context, id uuid.UUID) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const reparentStatusPageGroupChildren = `-- name: ReparentStatusPageGroupChildren :exec
|
||||
UPDATE status_page_groups SET parent_id = $3, updated_at = now()
|
||||
WHERE page_id = $1 AND parent_id = $2
|
||||
`
|
||||
|
||||
type ReparentStatusPageGroupChildrenParams struct {
|
||||
PageID uuid.UUID
|
||||
ParentID *uuid.UUID
|
||||
ParentID_2 *uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) ReparentStatusPageGroupChildren(ctx context.Context, arg ReparentStatusPageGroupChildrenParams) error {
|
||||
_, err := q.db.Exec(ctx, reparentStatusPageGroupChildren, arg.PageID, arg.ParentID, arg.ParentID_2)
|
||||
return err
|
||||
}
|
||||
|
||||
const reparentStatusPageGroupMonitors = `-- name: ReparentStatusPageGroupMonitors :exec
|
||||
UPDATE status_page_monitors SET group_id = $3
|
||||
WHERE page_id = $1 AND group_id = $2
|
||||
`
|
||||
|
||||
type ReparentStatusPageGroupMonitorsParams struct {
|
||||
PageID uuid.UUID
|
||||
GroupID *uuid.UUID
|
||||
GroupID_2 *uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) ReparentStatusPageGroupMonitors(ctx context.Context, arg ReparentStatusPageGroupMonitorsParams) error {
|
||||
_, err := q.db.Exec(ctx, reparentStatusPageGroupMonitors, arg.PageID, arg.GroupID, arg.GroupID_2)
|
||||
return err
|
||||
}
|
||||
|
||||
const setStatusPageDomain = `-- name: SetStatusPageDomain :one
|
||||
UPDATE status_pages SET
|
||||
custom_domain = $1,
|
||||
domain_verified_at = CASE WHEN custom_domain IS NOT DISTINCT FROM $1 THEN domain_verified_at END,
|
||||
updated_at = now()
|
||||
WHERE id = $2
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details
|
||||
`
|
||||
|
||||
type SetStatusPageDomainParams struct {
|
||||
@@ -237,12 +374,36 @@ func (q *Queries) SetStatusPageDomain(ctx context.Context, arg SetStatusPageDoma
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const setStatusPageMonitorGroup = `-- name: SetStatusPageMonitorGroup :exec
|
||||
UPDATE status_page_monitors SET group_id = $3, section = $4
|
||||
WHERE page_id = $1 AND monitor_id = $2
|
||||
`
|
||||
|
||||
type SetStatusPageMonitorGroupParams struct {
|
||||
PageID uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
GroupID *uuid.UUID
|
||||
Section string
|
||||
}
|
||||
|
||||
func (q *Queries) SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error {
|
||||
_, err := q.db.Exec(ctx, setStatusPageMonitorGroup,
|
||||
arg.PageID,
|
||||
arg.MonitorID,
|
||||
arg.GroupID,
|
||||
arg.Section,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const statusPageMonitors = `-- name: StatusPageMonitors :many
|
||||
SELECT spm.monitor_id, spm.section, spm.label, spm.position, m.name AS monitor_name, m.enabled
|
||||
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
||||
FROM status_page_monitors spm
|
||||
JOIN monitors m ON m.id = spm.monitor_id
|
||||
WHERE spm.page_id = $1
|
||||
@@ -250,12 +411,14 @@ ORDER BY spm.position, m.name
|
||||
`
|
||||
|
||||
type StatusPageMonitorsRow struct {
|
||||
MonitorID uuid.UUID
|
||||
Section string
|
||||
Label string
|
||||
Position int32
|
||||
MonitorName string
|
||||
Enabled bool
|
||||
MonitorID uuid.UUID
|
||||
Section string
|
||||
GroupID *uuid.UUID
|
||||
Label string
|
||||
Position int32
|
||||
MonitorName string
|
||||
Enabled bool
|
||||
MonitorGroupID *uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error) {
|
||||
@@ -270,10 +433,12 @@ func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]S
|
||||
if err := rows.Scan(
|
||||
&i.MonitorID,
|
||||
&i.Section,
|
||||
&i.GroupID,
|
||||
&i.Label,
|
||||
&i.Position,
|
||||
&i.MonitorName,
|
||||
&i.Enabled,
|
||||
&i.MonitorGroupID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -286,18 +451,26 @@ func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]S
|
||||
}
|
||||
|
||||
const updateStatusPage = `-- name: UpdateStatusPage :one
|
||||
UPDATE status_pages SET slug = $2, title = $3, description = $4, published = $5, theme = $6, updated_at = now()
|
||||
UPDATE status_pages
|
||||
SET slug = $2,
|
||||
title = $3,
|
||||
description = $4,
|
||||
published = $5,
|
||||
show_component_details = $6,
|
||||
theme = $7,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at
|
||||
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details
|
||||
`
|
||||
|
||||
type UpdateStatusPageParams struct {
|
||||
ID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
Theme []byte
|
||||
ID uuid.UUID
|
||||
Slug string
|
||||
Title string
|
||||
Description string
|
||||
Published bool
|
||||
ShowComponentDetails bool
|
||||
Theme []byte
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error) {
|
||||
@@ -307,6 +480,7 @@ func (q *Queries) UpdateStatusPage(ctx context.Context, arg UpdateStatusPagePara
|
||||
arg.Title,
|
||||
arg.Description,
|
||||
arg.Published,
|
||||
arg.ShowComponentDetails,
|
||||
arg.Theme,
|
||||
)
|
||||
var i StatusPage
|
||||
@@ -323,6 +497,44 @@ func (q *Queries) UpdateStatusPage(ctx context.Context, arg UpdateStatusPagePara
|
||||
&i.Theme,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ShowComponentDetails,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateStatusPageGroup = `-- name: UpdateStatusPageGroup :one
|
||||
UPDATE status_page_groups
|
||||
SET name = $3, parent_id = $4, position = $5, updated_at = now()
|
||||
WHERE id = $1 AND page_id = $2
|
||||
RETURNING id, page_id, org_id, parent_id, name, position, created_at, updated_at
|
||||
`
|
||||
|
||||
type UpdateStatusPageGroupParams struct {
|
||||
ID uuid.UUID
|
||||
PageID uuid.UUID
|
||||
Name string
|
||||
ParentID *uuid.UUID
|
||||
Position int32
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateStatusPageGroup(ctx context.Context, arg UpdateStatusPageGroupParams) (StatusPageGroup, error) {
|
||||
row := q.db.QueryRow(ctx, updateStatusPageGroup,
|
||||
arg.ID,
|
||||
arg.PageID,
|
||||
arg.Name,
|
||||
arg.ParentID,
|
||||
arg.Position,
|
||||
)
|
||||
var i StatusPageGroup
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.PageID,
|
||||
&i.OrgID,
|
||||
&i.ParentID,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in new issue
Block a user