Skip to content

Commit b877bea

Browse files
committed
Table improvements, add modals
1 parent 306ac20 commit b877bea

File tree

17 files changed

+1149
-121
lines changed

17 files changed

+1149
-121
lines changed

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@types/react": "18.0.15",
1616
"@types/react-dom": "18.0.6",
1717
"@types/react-router-dom": "5.3.3",
18+
"@types/react-syntax-highlighter": "^15.5.6",
1819
"@types/react-table": "^7.7.12",
1920
"@types/styled-components": "5.1.25",
2021
"@typescript-eslint/eslint-plugin": "^5.30.6",
@@ -57,6 +58,7 @@
5758
"react-query": "^3.39.1",
5859
"react-router-dom": "^6.3.0",
5960
"react-scripts": "5.0.1",
61+
"react-syntax-highlighter": "^15.5.0",
6062
"react-table": "7.8.0",
6163
"rooks": "5.11.8",
6264
"tmp": "^0.2.1",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as api from "./base";
2+
3+
export async function getUpstreamNginxConfig(
4+
id: number,
5+
params = {},
6+
): Promise<string> {
7+
const { result } = await api.get({
8+
url: `/upstreams/${id}/nginx-config`,
9+
params,
10+
});
11+
return result;
12+
}

frontend/src/api/npm/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from "./getHosts";
1313
export * from "./getNginxTemplates";
1414
export * from "./getSettings";
1515
export * from "./getToken";
16+
export * from "./getUpstreamNginxConfig";
1617
export * from "./getUpstreams";
1718
export * from "./getUser";
1819
export * from "./getUsers";

frontend/src/components/Table/Formatters.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { Monospace, RowAction, RowActionsMenu } from "components";
1313
import { intl } from "locale";
1414
import getNiceDNSProvider from "modules/Acmesh";
1515

16+
const errorColor = "red.400";
17+
1618
function ActionsFormatter(rowActions: RowAction[]) {
1719
const formatCell = (instance: any) => {
1820
return <RowActionsMenu data={instance.row.original} actions={rowActions} />;
@@ -24,7 +26,7 @@ function ActionsFormatter(rowActions: RowAction[]) {
2426
function BooleanFormatter() {
2527
const formatCell = ({ value }: any) => {
2628
return (
27-
<Badge color={value ? "cyan.500" : "red.400"}>
29+
<Badge color={value ? "cyan.500" : errorColor}>
2830
{value ? "true" : "false"}
2931
</Badge>
3032
);
@@ -86,7 +88,7 @@ function CertificateStatusFormatter() {
8688
let color = "cyan.500";
8789
switch (value) {
8890
case "failed":
89-
color = "red.400";
91+
color = errorColor;
9092
break;
9193
case "provided":
9294
color = "green.400";
@@ -137,7 +139,7 @@ function DisabledFormatter() {
137139
const formatCell = ({ value, row }: any) => {
138140
if (row?.original?.isDisabled) {
139141
return (
140-
<Text color="red.500">
142+
<Text color={errorColor}>
141143
<Tooltip label={intl.formatMessage({ id: "user.disabled" })}>
142144
{value}
143145
</Tooltip>
@@ -173,7 +175,7 @@ function DomainsFormatter() {
173175
</>
174176
);
175177
}
176-
return <Badge color="red.400">No domains!</Badge>;
178+
return <Badge color={errorColor}>No domains!</Badge>;
177179
};
178180

179181
return formatCell;
@@ -191,7 +193,9 @@ function HostStatusFormatter() {
191193
const formatCell = ({ row }: any) => {
192194
if (row.original.isDisabled) {
193195
return (
194-
<Badge color="red.400">{intl.formatMessage({ id: "disabled" })}</Badge>
196+
<Badge color={errorColor}>
197+
{intl.formatMessage({ id: "disabled" })}
198+
</Badge>
195199
);
196200
}
197201

@@ -209,7 +213,9 @@ function HostStatusFormatter() {
209213
if (row.original.certificate.status === "error") {
210214
return (
211215
<Tooltip label={row.original.certificate.errorMessage}>
212-
<Badge color="red.400">{intl.formatMessage({ id: "error" })}</Badge>
216+
<Badge color={errorColor}>
217+
{intl.formatMessage({ id: "error" })}
218+
</Badge>
213219
</Tooltip>
214220
);
215221
}
@@ -255,9 +261,21 @@ function UpstreamStatusFormatter() {
255261
}
256262
if (value === "error") {
257263
return (
258-
<Tooltip label={row.original.errorMessage}>
259-
<Badge color="red.500">{intl.formatMessage({ id: "error" })}</Badge>
260-
</Tooltip>
264+
<Popover>
265+
<PopoverTrigger>
266+
<Badge color={errorColor} style={{ cursor: "pointer" }}>
267+
{intl.formatMessage({ id: "error" })}
268+
</Badge>
269+
</PopoverTrigger>
270+
<PopoverContent>
271+
<PopoverArrow />
272+
<PopoverBody>
273+
<pre className="wrappable error">
274+
{row?.original?.errorMessage}
275+
</pre>
276+
</PopoverBody>
277+
</PopoverContent>
278+
</Popover>
261279
);
262280
}
263281
};

frontend/src/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./useHealth";
99
export * from "./useHosts";
1010
export * from "./useNginxTemplates";
1111
export * from "./useSettings";
12+
export * from "./useUpstreamNginxConfig";
1213
export * from "./useUpstreams";
1314
export * from "./useUser";
1415
export * from "./useUsers";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { getUpstreamNginxConfig } from "api/npm";
2+
import { useQuery } from "react-query";
3+
4+
const fetchUpstreamNginxConfig = (id: any) => {
5+
return getUpstreamNginxConfig(id);
6+
};
7+
8+
const useUpstreamNginxConfig = (id: number, options = {}) => {
9+
return useQuery<string, Error>(
10+
["upstream-nginx-config", id],
11+
() => fetchUpstreamNginxConfig(id),
12+
{
13+
staleTime: 30 * 1000, // 30 seconds
14+
...options,
15+
},
16+
);
17+
};
18+
19+
export { useUpstreamNginxConfig };

frontend/src/locale/src/en.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"access-list.create": {
3+
"defaultMessage": "Create Access List"
4+
},
25
"access-lists.title": {
36
"defaultMessage": "Access Lists"
47
},
@@ -242,6 +245,9 @@
242245
"action.edit": {
243246
"defaultMessage": "Edit"
244247
},
248+
"action.nginx-config": {
249+
"defaultMessage": "View Nginx Config"
250+
},
245251
"action.set-password": {
246252
"defaultMessage": "Set Password"
247253
},
@@ -372,7 +378,7 @@
372378
"defaultMessage": "Wildcard Support"
373379
},
374380
"create-access-list-title": {
375-
"defaultMessage": "Create Access List"
381+
"defaultMessage": "There are no Access Lists"
376382
},
377383
"create-certificate": {
378384
"defaultMessage": "Create Certificate"
@@ -398,9 +404,6 @@
398404
"create-host-title": {
399405
"defaultMessage": "There are no Proxy Hosts"
400406
},
401-
"create-upstream": {
402-
"defaultMessage": "Create Upstream"
403-
},
404407
"create-upstream-title": {
405408
"defaultMessage": "There are no Upstreams"
406409
},
@@ -521,6 +524,9 @@
521524
"general-settings.title": {
522525
"defaultMessage": "General Settings"
523526
},
527+
"nginx-config": {
528+
"defaultMessage": "Nginx Config"
529+
},
524530
"nginx-templates.title": {
525531
"defaultMessage": "Nginx Templates"
526532
},
@@ -653,6 +659,9 @@
653659
"unhealthy.title": {
654660
"defaultMessage": "Nginx Proxy Manager is unhealthy"
655661
},
662+
"upstream.create": {
663+
"defaultMessage": "Create Upstream"
664+
},
656665
"upstreams.title": {
657666
"defaultMessage": "Upstreams"
658667
},

0 commit comments

Comments
 (0)