Skip to content

Commit 418d9c8

Browse files
author
Timo Stark
committed
Feature and Bugfix Release
- Feature: Adding "Create Virtual Server" Configuration UI - Feature: Display Protocol next to the exposed Port in Instances overview - Feature: Create virtual Servers using the Configuration UI - Feature: Allow editing all included configuration files. Not limited to /etc/nginx/conf.d/ anymore
1 parent e98b5b6 commit 418d9c8

9 files changed

+304
-90
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-extension: ## Build service image to be deployed as a desktop extension
1010
docker build --tag=$(IMAGE):$(TAG) .
1111

1212
remove-extension:
13-
docker extension remove $(IMAGE):$(TAG)
13+
docker extension remove $(IMAGE):$(TAG)
1414

1515
install-extension: build-extension ## Install the extension
1616
docker extension install $(IMAGE):$(TAG)
@@ -24,6 +24,9 @@ prepare-buildx: ## Create buildx builder for multi-arch build, if not exists
2424
push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
2525
docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) .
2626

27+
devel: ## Start Docker Extension in Dev mode
28+
docker extension dev debug $(IMAGE):$(TAG) && docker extension dev ui-source $(IMAGE):$(TAG) http://localhost:3000
29+
2730
help: ## Show this help
2831
@echo Please specify a build target. The choices are:
2932
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {ConfigurationTemplates} from "./ConfigurationTemplates";
2+
3+
4+
export class ConfigurationCreator {
5+
6+
public simpleProxyConfiguration(serverName: string, port: string, upstream: string) {
7+
let configurationString = ConfigurationTemplates.simpleProxyServerTemplate()
8+
configurationString = configurationString.replace(/\$\$LISTEN/g, port)
9+
configurationString = configurationString.replace(/\$\$SERVER_NAME/g, serverName)
10+
configurationString = configurationString.replace(/\$\$UPSTREAM/g, `http://${upstream}/`)
11+
return configurationString
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
4+
export class ConfigurationTemplates {
5+
6+
public static simpleProxyServerTemplate = () => {
7+
return `
8+
server {
9+
listen $$LISTEN;
10+
server_name $$SERVER_NAME;
11+
12+
location / {
13+
proxy_pass $$UPSTREAM;
14+
proxy_set_header Host $host;
15+
}
16+
}
17+
`
18+
}
19+
20+
}

ui/src/configurationUI/ConfigurationUi.tsx

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {useEffect, useState} from "react";
22
import {ConfigurationUiService} from "./ConfigurationUiService";
33
import {
44
Box,
5-
Chip,
5+
Chip, Grid,
66
IconButton,
77
Paper,
88
Slide,
@@ -83,8 +83,8 @@ export function ConfigurationUi(props: ConfigurationUiProps) {
8383
};
8484

8585
const content = (
86-
<Box
87-
sx={{ width: "100%", height: "100vh" }}
86+
<Grid
87+
sx={{width: "100%", height: "100vh"}}
8888
style={{
8989
position: "absolute",
9090
top: "0",
@@ -95,22 +95,20 @@ export function ConfigurationUi(props: ConfigurationUiProps) {
9595
backgroundColor: "transparent"
9696
}}
9797
>
98-
<Box
98+
<Grid
9999
style={{
100100
display: "flex",
101101
width: "75%",
102102
height: "100vh",
103-
borderLeft: "1px solid eee",
104-
boxShadow: "-3px 0px 5px rgb(0 0 0 / 20%)",
105103
flexDirection: "column",
106-
backgroundColor: "primary.light",
107104
alignItems: "flex-start"
108105
}}
106+
sx={{backgroundColor: "background.default", borderLeft: "2px solid", borderColor: "primary.dark"}}
109107
>
110108
<Close onClick={handleChangeServer} sx={{cursor: 'pointer'}} />
111-
<Server/>
112-
</Box>
113-
</Box>
109+
<Server nginxInstance={props.nginxInstance} />
110+
</Grid>
111+
</Grid>
114112
);
115113

116114
const [locationSlide, setLocationSlide] = useState(false);
@@ -161,11 +159,11 @@ export function ConfigurationUi(props: ConfigurationUiProps) {
161159
<TableHead>
162160
<TableRow>
163161
<TableCell color="text.secondary">Server
164-
{/*<Tooltip title="New Virtual Server">*/}
165-
{/* <IconButton onClick={handleChangeServer} sx={{fontSize:"0.9rem"}}>*/}
166-
{/* <Add/>*/}
167-
{/* </IconButton>*/}
168-
{/*</Tooltip>*/}
162+
<Tooltip title="New Virtual Server">
163+
<IconButton onClick={handleChangeServer} sx={{fontSize:"0.9rem"}}>
164+
<Add/>
165+
</IconButton>
166+
</Tooltip>
169167
</TableCell>
170168
<TableCell>Configuration File</TableCell>
171169
<TableCell align="right">Ports</TableCell>
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
import {InstancesService} from "../instances/InstancesService";
22
import {ConfigurationParser} from "../configuration/ConfigurationParser";
3+
import {ConfigurationCreator} from "../configuration/ConfigurationCreator";
4+
import {Base64} from "js-base64";
35

46

57
export class ConfigurationUiService {
68

79
private instanceService: InstancesService;
810
private configurationParser: ConfigurationParser;
11+
private configurationCreator: ConfigurationCreator;
12+
913
constructor() {
1014
this.instanceService = new InstancesService();
1115
this.configurationParser = new ConfigurationParser();
16+
this.configurationCreator = new ConfigurationCreator();
17+
1218
}
1319

1420
async getConfiguration(containerId: string) {
1521
const config = await this.instanceService.getInstanceConfiguration(containerId);
1622
return this.configurationParser.parse(config);
1723
}
24+
25+
createNewServerConfiguration(serverConfiguration: any, containerId: any) {
26+
console.log(serverConfiguration)
27+
let configTemplate = this.configurationCreator.simpleProxyConfiguration(serverConfiguration.serverName,
28+
serverConfiguration.listeners,
29+
serverConfiguration.upstream);
30+
console.log(configTemplate)
31+
const content = Base64.encode(configTemplate)
32+
this.instanceService.sendConfigurationToFile(serverConfiguration.file, containerId, content).then((data: any) => {
33+
this.instanceService.reloadNGINX(containerId).then((data: any) => {
34+
this.instanceService.displaySuccessMessage("Configuration successfully updated!");
35+
}).catch((reason: any) => {
36+
this.instanceService.displayErrorMessage(`Error while updating configuration: ${reason.stderr.split("\n")[1]}`);
37+
})
38+
})
39+
return configTemplate
40+
}
1841
}

0 commit comments

Comments
 (0)