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 16
/
setup_shell.go
145 lines (131 loc) · 3.35 KB
/
setup_shell.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
package components
import (
"github.com/maxence-charriere/go-app/v8/pkg/app"
)
type SetupShell struct {
app.Compo
LogoSrc string
Title string
ShortDescription string
LongDescription string
HelpLink string
Links map[string]string
BackendURL string
OIDCIssuer string
OIDCClientID string
OIDCRedirectURL string
SetBackendURL,
SetOIDCIssuer,
SetOIDCClientID,
SetOIDCRedirectURL func(string)
ApplyConfig func()
Error error
}
func (c *SetupShell) Render() app.UI {
// Display the error message if error != nil
errorMessage := ""
if c.Error != nil {
errorMessage = c.Error.Error()
}
return app.Div().
Class("pf-u-h-100").
Body(
app.Div().
Class("pf-c-background-image").
Body(
app.Raw(`<svg
xmlns="http://www.w3.org/2000/svg"
class="pf-c-background-image__filter"
width="0"
height="0"
>
<filter id="image_overlay">
<feColorMatrix
type="matrix"
values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0"
></feColorMatrix>
<feComponentTransfer
color-interpolation-filters="sRGB"
result="duotone"
>
<feFuncR
type="table"
tableValues="0.086274509803922 0.43921568627451"
></feFuncR>
<feFuncG
type="table"
tableValues="0.086274509803922 0.43921568627451"
></feFuncG>
<feFuncB
type="table"
tableValues="0.086274509803922 0.43921568627451"
></feFuncB>
<feFuncA type="table" tableValues="0 1"></feFuncA>
</feComponentTransfer>
</filter>
</svg>`),
),
app.Div().Class("pf-c-login").Body(
app.Div().Class("pf-c-login__container").Body(
app.Header().Class("pf-c-login__header").Body(
app.Img().
Class("pf-c-brand pf-x-c-brand--main").
Src(c.LogoSrc).
Alt("Logo"),
),
app.Main().Class("pf-c-login__main").Body(
app.Header().Class("pf-c-login__main-header").Body(
app.H1().Class("pf-c-title pf-m-3xl").Text(
c.Title,
),
app.P().Class("pf-c-login__main-header-desc").Text(
c.ShortDescription,
),
),
app.Div().Class("pf-c-login__main-body").Body(
&SetupForm{
Error: c.Error,
ErrorMessage: errorMessage,
BackendURL: c.BackendURL,
SetBackendURL: c.SetBackendURL,
OIDCIssuer: c.OIDCIssuer,
SetOIDCIssuer: c.SetOIDCIssuer,
OIDCClientID: c.OIDCClientID,
SetOIDCClientID: c.SetOIDCClientID,
OIDCRedirectURL: c.OIDCRedirectURL,
SetOIDCRedirectURL: c.SetOIDCRedirectURL,
Submit: c.ApplyConfig,
},
),
app.Footer().Class("pf-c-login__main-footer").Body(
app.Div().Class("pf-c-login__main-footer-band").Body(
app.P().Class("pf-c-login__main-footer-band-item").Body(
app.Text("Not sure what to do? "),
app.A().
Href(c.HelpLink).
Target("_blank").
Text("Get help."),
),
),
),
),
app.Footer().Class("pf-c-login__footer").Body(
app.P().Text(
c.LongDescription,
),
app.Ul().Class("pf-c-list pf-m-inline").Body(
app.Range(c.Links).Map(func(s string) app.UI {
return app.Li().Body(
app.
A().
Target("_blank").
Href(c.Links[s]).
Text(s),
)
}),
),
),
),
),
)
}