This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
home.go
173 lines (145 loc) · 6.07 KB
/
home.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package components
import (
"github.com/maxence-charriere/go-app/v9/pkg/app"
"github.com/pojntfx/bofied/pkg/providers"
)
type Home struct {
app.Compo
}
func (c *Home) Render() app.UI {
return &providers.SetupProvider{
StoragePrefix: "bofied.configuration",
StateQueryParameter: "state",
CodeQueryParameter: "code",
Children: func(cpcp providers.SetupProviderChildrenProps) app.UI {
// This div is required so that there are no authorization loops
return app.Div().
Class("pf-x-ws-router").
Body(
app.If(cpcp.Ready,
// Identity provider
&providers.IdentityProvider{
Issuer: cpcp.OIDCIssuer,
ClientID: cpcp.OIDCClientID,
RedirectURL: cpcp.OIDCRedirectURL,
HomeURL: "/",
Scopes: []string{"profile", "email"},
StoragePrefix: "bofied.identity",
Children: func(ipcp providers.IdentityProviderChildrenProps) app.UI {
// Configuration shell
if ipcp.Error != nil {
return &SetupShell{
LogoSrc: "/web/logo.svg",
Title: "Log in to bofied",
ShortDescription: "Modern network boot server.",
LongDescription: `bofied is a network boot server. It provides everything you need to PXE boot a node, from a (proxy)DHCP server for PXE service to a TFTP and HTTP server to serve boot files.`,
HelpLink: "https://github.com/pojntfx/bofied#Usage",
Links: map[string]string{
"License": "https://github.com/pojntfx/bofied/blob/main/LICENSE",
"Source Code": "https://github.com/pojntfx/bofied",
"Documentation": "https://github.com/pojntfx/bofied#Usage",
},
BackendURL: cpcp.BackendURL,
OIDCIssuer: cpcp.OIDCIssuer,
OIDCClientID: cpcp.OIDCClientID,
OIDCRedirectURL: cpcp.OIDCRedirectURL,
SetBackendURL: cpcp.SetBackendURL,
SetOIDCIssuer: cpcp.SetOIDCIssuer,
SetOIDCClientID: cpcp.SetOIDCClientID,
SetOIDCRedirectURL: cpcp.SetOIDCRedirectURL,
ApplyConfig: cpcp.ApplyConfig,
Error: ipcp.Error,
}
}
// Configuration placeholder
if ipcp.IDToken == "" || ipcp.UserInfo.Email == "" {
return app.P().Text("Authorizing ...")
}
// Data provider
return &providers.DataProvider{
BackendURL: cpcp.BackendURL,
IDToken: ipcp.IDToken,
Children: func(dpcp providers.DataProviderChildrenProps) app.UI {
// Data shell
return &DataShell{
// Config file editor
ConfigFile: dpcp.ConfigFile,
SetConfigFile: dpcp.SetConfigFile,
FormatConfigFile: dpcp.FormatConfigFile,
RefreshConfigFile: dpcp.RefreshConfigFile,
SaveConfigFile: dpcp.SaveConfigFile,
ConfigFileError: dpcp.ConfigFileError,
IgnoreConfigFileError: dpcp.IgnoreConfigFileError,
// File explorer
CurrentPath: dpcp.CurrentPath,
SetCurrentPath: dpcp.SetCurrentPath,
Index: dpcp.Index,
RefreshIndex: dpcp.RefreshIndex,
WriteToPath: dpcp.WriteToPath,
HTTPShareLink: dpcp.HTTPShareLink,
TFTPShareLink: dpcp.TFTPShareLink,
SharePath: dpcp.SharePath,
CreatePath: dpcp.CreatePath,
CreateEmptyFile: dpcp.CreateEmptyFile,
DeletePath: dpcp.DeletePath,
MovePath: dpcp.MovePath,
CopyPath: dpcp.CopyPath,
EditPathContents: dpcp.EditPathContents,
SetEditPathContents: dpcp.SetEditPathContents,
EditPath: dpcp.EditPath,
WebDAVAddress: dpcp.WebDAVAddress,
WebDAVUsername: dpcp.WebDAVUsername,
WebDAVPassword: dpcp.WebDAVPassword,
OperationIndex: dpcp.OperationIndex,
OperationCurrentPath: dpcp.OperationCurrentPath,
OperationSetCurrentPath: dpcp.OperationSetCurrentPath,
FileExplorerError: dpcp.FileExplorerError,
RecoverFileExplorerError: dpcp.RecoverFileExplorerError,
IgnoreFileExplorerError: dpcp.IgnoreFileExplorerError,
Events: dpcp.Events,
EventsError: dpcp.EventsError,
RecoverEventsError: dpcp.RecoverEventsError,
IgnoreEventsError: dpcp.IgnoreEventsError,
UserInfo: ipcp.UserInfo,
Logout: ipcp.Logout,
// Metadata
UseAdvertisedIP: dpcp.UseAdvertisedIP,
SetUseAdvertisedIP: dpcp.SetUseAdvertisedIP,
UseAdvertisedIPForWebDAV: dpcp.UseAdvertisedIPForWebDAV,
SetUseAdvertisedIPForWebDAV: dpcp.SetUseAdvertisedIPForWebDAV,
SetUseHTTPS: dpcp.SetUseHTTPS,
SetUseDavs: dpcp.SetUseDavs,
}
},
}
},
},
).Else(
// Configuration shell
&SetupShell{
LogoSrc: "/web/logo.svg",
Title: "Log in to bofied",
ShortDescription: "Modern network boot server.",
LongDescription: `bofied is a network boot server. It provides everything you need to PXE boot a node, from a (proxy)DHCP server for PXE service to a TFTP and HTTP server to serve boot files.`,
HelpLink: "https://github.com/pojntfx/bofied#Usage",
Links: map[string]string{
"License": "https://github.com/pojntfx/bofied/blob/main/LICENSE",
"Source Code": "https://github.com/pojntfx/bofied",
"Documentation": "https://github.com/pojntfx/bofied#Usage",
},
BackendURL: cpcp.BackendURL,
OIDCIssuer: cpcp.OIDCIssuer,
OIDCClientID: cpcp.OIDCClientID,
OIDCRedirectURL: cpcp.OIDCRedirectURL,
SetBackendURL: cpcp.SetBackendURL,
SetOIDCIssuer: cpcp.SetOIDCIssuer,
SetOIDCClientID: cpcp.SetOIDCClientID,
SetOIDCRedirectURL: cpcp.SetOIDCRedirectURL,
ApplyConfig: cpcp.ApplyConfig,
Error: cpcp.Error,
},
),
)
},
}
}