refactor
This commit is contained in:
7
web/models/device.go
Normal file
7
web/models/device.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
type Device struct {
|
||||
DeviceName string
|
||||
LastSynced string
|
||||
CreatedAt string
|
||||
}
|
||||
@@ -29,5 +29,4 @@ type DocumentMetadata struct {
|
||||
Author string
|
||||
Description string
|
||||
Source metadata.Source
|
||||
Error *string
|
||||
}
|
||||
|
||||
12
web/models/info.go
Normal file
12
web/models/info.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
type UserInfo struct {
|
||||
Username string
|
||||
IsAdmin bool
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
RegistrationEnabled bool
|
||||
SearchEnabled bool
|
||||
Version string
|
||||
}
|
||||
13
web/models/notification.go
Normal file
13
web/models/notification.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
type NotificationType int
|
||||
|
||||
const (
|
||||
NotificationTypeSuccess NotificationType = iota
|
||||
NotificationTypeError
|
||||
)
|
||||
|
||||
type Notification struct {
|
||||
Content string
|
||||
Type NotificationType
|
||||
}
|
||||
52
web/models/page.go
Normal file
52
web/models/page.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package models
|
||||
|
||||
type PageContext struct {
|
||||
Route PageRoute
|
||||
UserInfo *UserInfo
|
||||
ServerInfo *ServerInfo
|
||||
Notifications []*Notification
|
||||
}
|
||||
|
||||
func (ctx PageContext) WithRoute(route PageRoute) PageContext {
|
||||
ctx.Route = route
|
||||
return ctx
|
||||
}
|
||||
|
||||
type PageRoute string
|
||||
|
||||
const (
|
||||
HomePage PageRoute = "home"
|
||||
DocumentPage PageRoute = "document"
|
||||
DocumentsPage PageRoute = "documents"
|
||||
ProgressPage PageRoute = "progress"
|
||||
ActivityPage PageRoute = "activity"
|
||||
SearchPage PageRoute = "search"
|
||||
SettingsPage PageRoute = "settings"
|
||||
AdminGeneralPage PageRoute = "admin-general"
|
||||
AdminImportPage PageRoute = "admin-import"
|
||||
AdminUsersPage PageRoute = "admin-users"
|
||||
AdminLogsPage PageRoute = "admin-logs"
|
||||
)
|
||||
|
||||
var pageTitleMap = map[PageRoute]string{
|
||||
HomePage: "Home",
|
||||
DocumentPage: "Document",
|
||||
DocumentsPage: "Documents",
|
||||
ProgressPage: "Progress",
|
||||
ActivityPage: "Activity",
|
||||
SearchPage: "Search",
|
||||
SettingsPage: "Settings",
|
||||
AdminGeneralPage: "Admin - General",
|
||||
AdminImportPage: "Admin - Import",
|
||||
AdminUsersPage: "Admin - Users",
|
||||
AdminLogsPage: "Admin - Logs",
|
||||
}
|
||||
|
||||
func (p PageRoute) Title() string {
|
||||
return pageTitleMap[p]
|
||||
}
|
||||
|
||||
func (p PageRoute) Valid() bool {
|
||||
_, ok := pageTitleMap[p]
|
||||
return ok
|
||||
}
|
||||
Reference in New Issue
Block a user