@@ -9,14 +9,12 @@ import {
9
9
Tooltip ,
10
10
ThemeProvider ,
11
11
Typography ,
12
- createTheme ,
12
+ createTheme , Button ,
13
13
} from "@mui/material" ;
14
- import styled from "@emotion/styled" ;
15
14
import "./Instance.css" ;
16
15
17
16
import {
18
- ArrowBackIosNewOutlined ,
19
- Store
17
+ ArrowBackIosNewOutlined
20
18
} from "@mui/icons-material" ;
21
19
22
20
import DnsIcon from '@mui/icons-material/Dns' ;
@@ -89,7 +87,6 @@ export function NginxInstance() {
89
87
} )
90
88
}
91
89
92
-
93
90
//Refactoring! Move this into a separate component
94
91
const [ tabValue , setTabValue ] = useState ( '1' ) ;
95
92
const handleTabChange = ( event : React . SyntheticEvent , newValue : string ) => {
@@ -125,90 +122,104 @@ export function NginxInstance() {
125
122
126
123
return (
127
124
< Box sx = { { m : 1 } } >
128
- { ! loading ? (
129
- ! nginxInstance . id ? (
130
- < Box >
131
- < Typography variant = "subtitle2" > Active containers running NGINX</ Typography >
132
- < Grid container > {
133
- instances . map ( ( inst : any , key : number ) => (
134
- //Refactoring Component Instance
135
- < Grid item sm = { 6 } lg = { 4 } key = { key } >
136
- < Box className = { "ngx-instance" } borderRadius = { 1 } boxShadow = { 10 } margin = { 2 }
137
- padding = { 2 }
138
- background-color = { "red" }
139
- border = { "1px solid rgba(255,255,255,.2)" }
140
- onClick = { nginxInstanceOnClickHandler ( inst . id , inst . name ) } >
141
- < Typography variant = "h5" > { inst . name } </ Typography >
142
- < Typography variant = "subtitle2" display = "inline" > Container ID: </ Typography >
143
- < Typography variant = "body1" display = "inline" > { inst . id . substring ( 0 , 12 ) } </ Typography >
144
- < Box paddingTop = { 1 } >
145
- < Typography variant = "subtitle2" display = "inline" > Status: </ Typography >
146
- < Typography variant = "body1" display = "inline" > { inst . status . toLowerCase ( ) } </ Typography >
147
- </ Box >
148
- < Box >
149
- < Typography variant = "subtitle2" display = "inline" > NGINX Version: </ Typography >
150
- < Typography variant = "body1" display = "inline" > { inst . out . substring ( 15 , inst . out . length ) } </ Typography >
151
- </ Box >
125
+ { ! loading ? (
126
+ ! nginxInstance . id ? (
127
+ instances == 0 ? (
128
+ < Box >
129
+ There are no active NGINX containers! Start a container to get started!
130
+ { /* @ts -expect-error not typed yet! */ }
131
+ < Typography component = { "pre" } variant = "inline-code" > docker run -d -P nginx:latest</ Typography >
132
+ </ Box > ) : (
133
+ < Box >
134
+ < Typography variant = "subtitle2" > Active containers running NGINX</ Typography >
135
+ < Grid container > {
136
+ instances . map ( ( inst : any , key : number ) => (
137
+ //Refactoring Component Instance
138
+ < Grid item sm = { 6 } lg = { 4 } key = { key } >
139
+ < Box className = { "ngx-instance" } borderRadius = { 1 } boxShadow = { 10 } margin = { 2 }
140
+ padding = { 2 }
141
+ background-color = { "red" }
142
+ border = { "1px solid rgba(255,255,255,.2)" }
143
+ onClick = { nginxInstanceOnClickHandler ( inst . id , inst . name ) } >
144
+ < Typography variant = "h5" > { inst . name } </ Typography >
145
+ < Typography variant = "subtitle2" display = "inline" > Container ID: </ Typography >
146
+ < Typography variant = "body1"
147
+ display = "inline" > { inst . id . substring ( 0 , 12 ) } </ Typography >
148
+ < Box paddingTop = { 1 } >
149
+ < Typography variant = "subtitle2" display = "inline" > Status: </ Typography >
150
+ < Typography variant = "body1"
151
+ display = "inline" > { inst . status . toLowerCase ( ) } </ Typography >
152
+ </ Box >
153
+ < Box >
154
+ < Typography variant = "subtitle2" display = "inline" > NGINX
155
+ Version: </ Typography >
156
+ < Typography variant = "body1"
157
+ display = "inline" > { inst . out . substring ( 15 , inst . out . length ) } </ Typography >
158
+ </ Box >
159
+ < Box >
160
+ < Typography variant = "subtitle2" display = "inline" > Open Ports
161
+ (Host:Container): </ Typography >
162
+ { inst . ports . map ( ( port : any , key : number ) => containerNetwork ( port , key ) ) }
163
+ </ Box >
164
+ { inst . mounts . length > 0 ? (
152
165
< Box >
153
- < Typography variant = "subtitle2" display = "inline" > Open Ports (Host:Container): </ Typography >
154
- { inst . ports . map ( ( port : any , key : number ) => containerNetwork ( port , key ) ) }
166
+ < Typography variant = "subtitle2" display = "inline" > Number of Mounted
167
+ Volumes: </ Typography >
168
+ < Typography variant = "body1"
169
+ display = "inline" > { inst . mounts . length } </ Typography >
155
170
</ Box >
156
- { inst . mounts . length > 0 ? (
157
- < Box >
158
- < Typography variant = "subtitle2" display = "inline" > Number of Mounted Volumes: </ Typography >
159
- < Typography variant = "body1" display = "inline" > { inst . mounts . length } </ Typography >
160
- </ Box >
161
- ) : ( "" ) }
162
- </ Box >
163
- </ Grid >
164
- ) ) }
165
- </ Grid >
166
- </ Box >
167
- ) : (
168
- < Box >
169
- < Grid className = { errorClasses . bannerBackground } >
170
- < Typography paddingTop = { 2 } >
171
- < Tooltip title = "Back to Instances Overview" >
172
- < IconButton className = { "ngx-back-button" } onClick = { ( ) => {
173
- setContainerId ( undefined )
174
- setNginxInstance ( { id : "" , name : "" , mounts : [ ] } )
175
- } } disabled = { errorClasses . backToDashboardDisabled } >
176
- < ArrowBackIosNewOutlined />
177
- </ IconButton >
178
- </ Tooltip >
179
- < Typography variant = "h5" display = "inline" > { nginxInstance . name } </ Typography >
180
- </ Typography >
181
- < Typography variant = { "inherit" } paddingLeft = { 5 } paddingBottom = { 2 } >
182
- Container ID: { nginxInstance . id . substring ( 0 , 12 ) }
183
- </ Typography >
184
- { renderErrorMessageIfAny ( ) }
171
+ ) : ( "" ) }
172
+ </ Box >
173
+ </ Grid >
174
+ ) ) }
185
175
</ Grid >
186
-
187
- < TabContext value = { tabValue } >
188
- < Box >
189
- < Tabs value = { tabValue } onChange = { handleTabChange } aria-label = "icon label tabs example" >
190
- < Tab icon = { < DnsIcon /> } label = "Servers" value = { "1" } />
191
- < Tab icon = { < BorderColorIcon /> } label = "Configuration Editor" value = { "2" } />
192
- { /*<Tab icon={<Store />} label="Templates Store" value={"3"}/>*/ }
193
- { /*<Tab icon={<FileDownload/>} label="Export Configuration" value={"4"}/>*/ }
194
- </ Tabs >
195
- </ Box >
196
- < TabPanel value = { "1" } >
197
- < ConfigurationUi containerId = { nginxInstance . id } nginxInstance = { nginxInstance } />
198
- </ TabPanel >
199
- < TabPanel value = { "2" } >
200
- < ConfigurationEditor nginxInstance = { nginxInstance } />
201
- </ TabPanel >
202
- < TabPanel value = { "3" } >
203
- < TemplateStore />
204
- </ TabPanel >
205
- < TabPanel value = { "4" } >
206
- < > Exports</ >
207
- </ TabPanel >
208
- </ TabContext >
209
176
</ Box >
210
177
)
211
- ) : ( < Typography variant = 'h3' > Loading...</ Typography > ) }
178
+ ) : (
179
+ < Box >
180
+ < Grid className = { errorClasses . bannerBackground } >
181
+ < Typography paddingTop = { 2 } >
182
+ < Tooltip title = "Back to Instances Overview" >
183
+ < IconButton className = { "ngx-back-button" } onClick = { ( ) => {
184
+ setContainerId ( undefined )
185
+ setNginxInstance ( { id : "" , name : "" , mounts : [ ] } )
186
+ } } disabled = { errorClasses . backToDashboardDisabled } >
187
+ < ArrowBackIosNewOutlined />
188
+ </ IconButton >
189
+ </ Tooltip >
190
+ < Typography variant = "h5" display = "inline" > { nginxInstance . name } </ Typography >
191
+ </ Typography >
192
+ < Typography variant = { "inherit" } paddingLeft = { 5 } paddingBottom = { 2 } >
193
+ Container ID: { nginxInstance . id . substring ( 0 , 12 ) }
194
+ </ Typography >
195
+ { renderErrorMessageIfAny ( ) }
196
+ </ Grid >
197
+
198
+ < TabContext value = { tabValue } >
199
+ < Box >
200
+ < Tabs value = { tabValue } onChange = { handleTabChange } aria-label = "icon label tabs example" >
201
+ < Tab icon = { < DnsIcon /> } label = "Servers" value = { "1" } />
202
+ < Tab icon = { < BorderColorIcon /> } label = "Configuration Editor" value = { "2" } />
203
+ { /*<Tab icon={<Store />} label="Templates Store" value={"3"}/>*/ }
204
+ { /*<Tab icon={<FileDownload/>} label="Export Configuration" value={"4"}/>*/ }
205
+ </ Tabs >
206
+ </ Box >
207
+ < TabPanel value = { "1" } >
208
+ < ConfigurationUi containerId = { nginxInstance . id } nginxInstance = { nginxInstance } />
209
+ </ TabPanel >
210
+ < TabPanel value = { "2" } >
211
+ < ConfigurationEditor nginxInstance = { nginxInstance } />
212
+ </ TabPanel >
213
+ < TabPanel value = { "3" } >
214
+ < TemplateStore />
215
+ </ TabPanel >
216
+ < TabPanel value = { "4" } >
217
+ < > Exports</ >
218
+ </ TabPanel >
219
+ </ TabContext >
220
+ </ Box >
221
+ )
222
+ ) : ( < Typography variant = 'h3' > Loading...</ Typography > ) }
212
223
</ Box >
213
224
) ;
214
225
}
0 commit comments