feat(models): add alert and box models
Adds comprehensive data structures for Alert and Box functionality across models.
This commit is contained in:
@@ -119,6 +119,12 @@ func (app *App) GetAccountDashboard(ctx *gin.Context, actor metastore.User) (Acc
|
||||
ActiveBoxes: activeBoxes,
|
||||
StorageUsedLabel: helpers.FormatBytes(totalSize),
|
||||
}
|
||||
alertPreview := []accountAlertPreviewRow{}
|
||||
if perms.AdminAccess {
|
||||
stats.AlertCount, nav.AlertSeverity = app.openAlertSummary()
|
||||
nav.AlertCount = stats.AlertCount
|
||||
alertPreview = app.accountDashboardAlertPreview()
|
||||
}
|
||||
|
||||
showUsersStat := perms.AdminUsersManage
|
||||
if showUsersStat {
|
||||
@@ -144,7 +150,7 @@ func (app *App) GetAccountDashboard(ctx *gin.Context, actor metastore.User) (Acc
|
||||
CSRFToken: app.currentCSRFToken(ctx),
|
||||
Stats: stats,
|
||||
Statuses: app.accountDashboardStatuses(),
|
||||
Alerts: accountPlaceholderAlerts(),
|
||||
Alerts: alertPreview,
|
||||
RecentBoxes: recentBoxes,
|
||||
RecentActivity: accountPlaceholderActivity(actor, ctx),
|
||||
ShowUsersStat: showUsersStat,
|
||||
@@ -164,14 +170,23 @@ func (app *App) accountDashboardStatuses() []accountStatusRow {
|
||||
}
|
||||
}
|
||||
|
||||
func accountPlaceholderAlerts() []accountAlertPreviewRow {
|
||||
return []accountAlertPreviewRow{
|
||||
{
|
||||
Severity: "info",
|
||||
Title: "Alerts system pending",
|
||||
Detail: "Dedicated alert storage arrives in the alerts implementation pass.",
|
||||
},
|
||||
func (app *App) accountDashboardAlertPreview() []accountAlertPreviewRow {
|
||||
alerts, err := app.store.ListAlerts(metastore.AlertFilters{Status: metastore.AlertStatusOpen, Sort: "severity"})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
rows := make([]accountAlertPreviewRow, 0, minInt(len(alerts), 6))
|
||||
for _, alert := range alerts {
|
||||
if len(rows) == 6 {
|
||||
break
|
||||
}
|
||||
rows = append(rows, accountAlertPreviewRow{
|
||||
Severity: alert.Severity,
|
||||
Title: alert.Title,
|
||||
Detail: alert.Description,
|
||||
})
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func accountPlaceholderActivity(actor metastore.User, ctx *gin.Context) []accountActivityRow {
|
||||
|
||||
Reference in New Issue
Block a user