mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-10-04 11:50:09 +00:00
Compare commits
6 Commits
cd6b2ef98f
...
5c08a2391d
Author | SHA1 | Date | |
---|---|---|---|
|
5c08a2391d | ||
|
409c166c67 | ||
|
645b363330 | ||
|
188193a22d | ||
|
f2b9a66459 | ||
|
72b8aee234 |
@@ -422,7 +422,6 @@ const internalProxyHost = {
|
|||||||
*/
|
*/
|
||||||
getAll: async (access, expand, searchQuery) => {
|
getAll: async (access, expand, searchQuery) => {
|
||||||
const accessData = await access.can("proxy_hosts:list");
|
const accessData = await access.can("proxy_hosts:list");
|
||||||
|
|
||||||
const query = proxyHostModel
|
const query = proxyHostModel
|
||||||
.query()
|
.query()
|
||||||
.where("is_deleted", 0)
|
.where("is_deleted", 0)
|
||||||
@@ -446,11 +445,9 @@ const internalProxyHost = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rows = await query.then(utils.omitRows(omissions()));
|
const rows = await query.then(utils.omitRows(omissions()));
|
||||||
|
|
||||||
if (typeof expand !== "undefined" && expand !== null && expand.indexOf("certificate") !== -1) {
|
if (typeof expand !== "undefined" && expand !== null && expand.indexOf("certificate") !== -1) {
|
||||||
return internalHost.cleanAllRowsCertificateMeta(rows);
|
return internalHost.cleanAllRowsCertificateMeta(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -348,7 +348,7 @@ const internalStream = {
|
|||||||
// Add to audit log
|
// Add to audit log
|
||||||
return internalAuditLog.add(access, {
|
return internalAuditLog.add(access, {
|
||||||
action: "disabled",
|
action: "disabled",
|
||||||
object_type: "stream-host",
|
object_type: "stream",
|
||||||
object_id: row.id,
|
object_id: row.id,
|
||||||
meta: _.omit(row, omissions()),
|
meta: _.omit(row, omissions()),
|
||||||
});
|
});
|
||||||
|
@@ -131,7 +131,7 @@ export default function (tokenString) {
|
|||||||
const rows = await query;
|
const rows = await query;
|
||||||
objects = [];
|
objects = [];
|
||||||
_.forEach(rows, (ruleRow) => {
|
_.forEach(rows, (ruleRow) => {
|
||||||
result.push(ruleRow.id);
|
objects.push(ruleRow.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
// enum should not have less than 1 item
|
// enum should not have less than 1 item
|
||||||
|
@@ -37,6 +37,9 @@
|
|||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"$ref": "../../../components/stream-object.json#/properties/meta"
|
"$ref": "../../../components/stream-object.json#/properties/meta"
|
||||||
|
},
|
||||||
|
"domain_names": {
|
||||||
|
"$ref": "../../../components/dead-host-object.json#/properties/domain_names"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ ENV SUPPRESS_NO_CONFIG_WARNING=1 \
|
|||||||
|
|
||||||
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf \
|
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y jq python3-pip logrotate \
|
&& apt-get install -y jq python3-pip logrotate moreutils \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
"prettier": "biome format --write ./src",
|
"prettier": "biome format --write ./src",
|
||||||
"locale-extract": "formatjs extract 'src/**/*.tsx'",
|
"locale-extract": "formatjs extract 'src/**/*.tsx'",
|
||||||
"locale-compile": "formatjs compile-folder src/locale/src src/locale/lang",
|
"locale-compile": "formatjs compile-folder src/locale/src src/locale/lang",
|
||||||
|
"locale-sort": "./src/locale/scripts/locale-sort.sh",
|
||||||
"test": "vitest"
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@@ -70,3 +70,7 @@
|
|||||||
font-family: 'Courier New', Courier, monospace !important;
|
font-family: 'Courier New', Courier, monospace !important;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label.row {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import * as api from "./base";
|
import * as api from "./base";
|
||||||
import type { HostExpansion } from "./expansions";
|
import type { HostExpansion } from "./expansions";
|
||||||
import type { ProxyHost } from "./models";
|
import type { RedirectionHost } from "./models";
|
||||||
|
|
||||||
export async function getRedirectionHost(id: number, expand?: HostExpansion[], params = {}): Promise<ProxyHost> {
|
export async function getRedirectionHost(id: number, expand?: HostExpansion[], params = {}): Promise<RedirectionHost> {
|
||||||
return await api.get({
|
return await api.get({
|
||||||
url: `/nginx/redirection-hosts/${id}`,
|
url: `/nginx/redirection-hosts/${id}`,
|
||||||
params: {
|
params: {
|
||||||
|
@@ -103,6 +103,7 @@ export interface ProxyHost {
|
|||||||
modifiedOn: string;
|
modifiedOn: string;
|
||||||
ownerUserId: number;
|
ownerUserId: number;
|
||||||
domainNames: string[];
|
domainNames: string[];
|
||||||
|
forwardScheme: string;
|
||||||
forwardHost: string;
|
forwardHost: string;
|
||||||
forwardPort: number;
|
forwardPort: number;
|
||||||
accessListId: number;
|
accessListId: number;
|
||||||
@@ -114,9 +115,8 @@ export interface ProxyHost {
|
|||||||
meta: Record<string, any>;
|
meta: Record<string, any>;
|
||||||
allowWebsocketUpgrade: boolean;
|
allowWebsocketUpgrade: boolean;
|
||||||
http2Support: boolean;
|
http2Support: boolean;
|
||||||
forwardScheme: string;
|
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
locations: string[]; // todo: string or object?
|
locations?: string[]; // todo: string or object?
|
||||||
hstsEnabled: boolean;
|
hstsEnabled: boolean;
|
||||||
hstsSubdomains: boolean;
|
hstsSubdomains: boolean;
|
||||||
// Expansions:
|
// Expansions:
|
||||||
|
@@ -31,6 +31,7 @@ interface Props {
|
|||||||
label?: string;
|
label?: string;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
allowNew?: boolean;
|
allowNew?: boolean;
|
||||||
|
forHttp?: boolean; // the sslForced, http2Support, hstsEnabled, hstsSubdomains fields
|
||||||
}
|
}
|
||||||
export function SSLCertificateField({
|
export function SSLCertificateField({
|
||||||
name = "certificateId",
|
name = "certificateId",
|
||||||
@@ -38,6 +39,7 @@ export function SSLCertificateField({
|
|||||||
id = "certificateId",
|
id = "certificateId",
|
||||||
required,
|
required,
|
||||||
allowNew,
|
allowNew,
|
||||||
|
forHttp = true,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { isLoading, isError, error, data } = useCertificates();
|
const { isLoading, isError, error, data } = useCertificates();
|
||||||
const { values, setFieldValue } = useFormikContext();
|
const { values, setFieldValue } = useFormikContext();
|
||||||
@@ -55,7 +57,7 @@ export function SSLCertificateField({
|
|||||||
dnsProviderCredentials,
|
dnsProviderCredentials,
|
||||||
propagationSeconds,
|
propagationSeconds,
|
||||||
} = v;
|
} = v;
|
||||||
if (!newValue?.value) {
|
if (forHttp && !newValue?.value) {
|
||||||
sslForced && setFieldValue("sslForced", false);
|
sslForced && setFieldValue("sslForced", false);
|
||||||
http2Support && setFieldValue("http2Support", false);
|
http2Support && setFieldValue("http2Support", false);
|
||||||
hstsEnabled && setFieldValue("hstsEnabled", false);
|
hstsEnabled && setFieldValue("hstsEnabled", false);
|
||||||
@@ -94,7 +96,7 @@ export function SSLCertificateField({
|
|||||||
options?.unshift({
|
options?.unshift({
|
||||||
value: 0,
|
value: 0,
|
||||||
label: "None",
|
label: "None",
|
||||||
subLabel: "This host will not use HTTPS",
|
subLabel: forHttp ? "This host will not use HTTPS" : "No certificate assigned",
|
||||||
icon: <IconShield size={14} className="text-red" />,
|
icon: <IconShield size={14} className="text-red" />,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,15 @@
|
|||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
import { Field, useFormikContext } from "formik";
|
import { Field, useFormikContext } from "formik";
|
||||||
import { DNSProviderFields } from "src/components";
|
import { DNSProviderFields, DomainNamesField } from "src/components";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
|
|
||||||
export function SSLOptionsFields() {
|
interface Props {
|
||||||
|
forHttp?: boolean; // the sslForced, http2Support, hstsEnabled, hstsSubdomains fields
|
||||||
|
forceDNSForNew?: boolean;
|
||||||
|
requireDomainNames?: boolean; // used for streams
|
||||||
|
color?: string;
|
||||||
|
}
|
||||||
|
export function SSLOptionsFields({ forHttp = true, forceDNSForNew, requireDomainNames, color = "bg-cyan" }: Props) {
|
||||||
const { values, setFieldValue } = useFormikContext();
|
const { values, setFieldValue } = useFormikContext();
|
||||||
const v: any = values || {};
|
const v: any = values || {};
|
||||||
|
|
||||||
@@ -12,6 +18,10 @@ export function SSLOptionsFields() {
|
|||||||
const { sslForced, http2Support, hstsEnabled, hstsSubdomains, meta } = v;
|
const { sslForced, http2Support, hstsEnabled, hstsSubdomains, meta } = v;
|
||||||
const { dnsChallenge } = meta || {};
|
const { dnsChallenge } = meta || {};
|
||||||
|
|
||||||
|
if (forceDNSForNew && newCertificate && !dnsChallenge) {
|
||||||
|
setFieldValue("meta.dnsChallenge", true);
|
||||||
|
}
|
||||||
|
|
||||||
const handleToggleChange = (e: any, fieldName: string) => {
|
const handleToggleChange = (e: any, fieldName: string) => {
|
||||||
setFieldValue(fieldName, e.target.checked);
|
setFieldValue(fieldName, e.target.checked);
|
||||||
if (fieldName === "meta.dnsChallenge" && !e.target.checked) {
|
if (fieldName === "meta.dnsChallenge" && !e.target.checked) {
|
||||||
@@ -22,10 +32,10 @@ export function SSLOptionsFields() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const toggleClasses = "form-check-input";
|
const toggleClasses = "form-check-input";
|
||||||
const toggleEnabled = cn(toggleClasses, "bg-cyan");
|
const toggleEnabled = cn(toggleClasses, color);
|
||||||
|
|
||||||
return (
|
const getHttpOptions = () => (
|
||||||
<>
|
<div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-6">
|
<div className="col-6">
|
||||||
<Field name="sslForced">
|
<Field name="sslForced">
|
||||||
@@ -102,6 +112,12 @@ export function SSLOptionsFields() {
|
|||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{forHttp ? getHttpOptions() : null}
|
||||||
{newCertificate ? (
|
{newCertificate ? (
|
||||||
<>
|
<>
|
||||||
<Field name="meta.dnsChallenge">
|
<Field name="meta.dnsChallenge">
|
||||||
@@ -110,7 +126,8 @@ export function SSLOptionsFields() {
|
|||||||
<input
|
<input
|
||||||
className={dnsChallenge ? toggleEnabled : toggleClasses}
|
className={dnsChallenge ? toggleEnabled : toggleClasses}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={!!dnsChallenge}
|
checked={forceDNSForNew ? true : !!dnsChallenge}
|
||||||
|
disabled={forceDNSForNew}
|
||||||
onChange={(e) => handleToggleChange(e, field.name)}
|
onChange={(e) => handleToggleChange(e, field.name)}
|
||||||
/>
|
/>
|
||||||
<span className="form-check-label">
|
<span className="form-check-label">
|
||||||
@@ -119,10 +136,10 @@ export function SSLOptionsFields() {
|
|||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
|
{requireDomainNames ? <DomainNamesField /> : null}
|
||||||
{dnsChallenge ? <DNSProviderFields /> : null}
|
{dnsChallenge ? <DNSProviderFields /> : null}
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { IconBoltOff, IconUser } from "@tabler/icons-react";
|
import { IconArrowsCross, IconBolt, IconBoltOff, IconDisc, IconUser } from "@tabler/icons-react";
|
||||||
import type { AuditLog } from "src/api/backend";
|
import type { AuditLog } from "src/api/backend";
|
||||||
import { DateTimeFormat, intl } from "src/locale";
|
import { DateTimeFormat, intl } from "src/locale";
|
||||||
|
|
||||||
@@ -10,8 +10,12 @@ const getEventValue = (event: AuditLog) => {
|
|||||||
switch (event.objectType) {
|
switch (event.objectType) {
|
||||||
case "user":
|
case "user":
|
||||||
return event.meta?.name;
|
return event.meta?.name;
|
||||||
|
case "proxy-host":
|
||||||
|
case "redirection-host":
|
||||||
case "dead-host":
|
case "dead-host":
|
||||||
return event.meta?.domainNames?.join(", ") || "N/A";
|
return event.meta?.domainNames?.join(", ") || "N/A";
|
||||||
|
case "stream":
|
||||||
|
return event.meta?.incomingPort || "N/A";
|
||||||
default:
|
default:
|
||||||
return `UNKNOWN EVENT TYPE: ${event.objectType}`;
|
return `UNKNOWN EVENT TYPE: ${event.objectType}`;
|
||||||
}
|
}
|
||||||
@@ -35,9 +39,18 @@ const getIcon = (row: AuditLog) => {
|
|||||||
case "user":
|
case "user":
|
||||||
ico = <IconUser size={16} className={c} />;
|
ico = <IconUser size={16} className={c} />;
|
||||||
break;
|
break;
|
||||||
|
case "proxy-host":
|
||||||
|
ico = <IconBolt size={16} className={c} />;
|
||||||
|
break;
|
||||||
|
case "redirection-host":
|
||||||
|
ico = <IconArrowsCross size={16} className={c} />;
|
||||||
|
break;
|
||||||
case "dead-host":
|
case "dead-host":
|
||||||
ico = <IconBoltOff size={16} className={c} />;
|
ico = <IconBoltOff size={16} className={c} />;
|
||||||
break;
|
break;
|
||||||
|
case "stream":
|
||||||
|
ico = <IconDisc size={16} className={c} />;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ico;
|
return ico;
|
||||||
|
@@ -7,8 +7,11 @@ export * from "./useDeadHosts";
|
|||||||
export * from "./useDnsProviders";
|
export * from "./useDnsProviders";
|
||||||
export * from "./useHealth";
|
export * from "./useHealth";
|
||||||
export * from "./useHostReport";
|
export * from "./useHostReport";
|
||||||
|
export * from "./useProxyHost";
|
||||||
export * from "./useProxyHosts";
|
export * from "./useProxyHosts";
|
||||||
|
export * from "./useRedirectionHost";
|
||||||
export * from "./useRedirectionHosts";
|
export * from "./useRedirectionHosts";
|
||||||
|
export * from "./useStream";
|
||||||
export * from "./useStreams";
|
export * from "./useStreams";
|
||||||
export * from "./useTheme";
|
export * from "./useTheme";
|
||||||
export * from "./useUser";
|
export * from "./useUser";
|
||||||
|
65
frontend/src/hooks/useProxyHost.ts
Normal file
65
frontend/src/hooks/useProxyHost.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { createProxyHost, getProxyHost, type ProxyHost, updateProxyHost } from "src/api/backend";
|
||||||
|
|
||||||
|
const fetchProxyHost = (id: number | "new") => {
|
||||||
|
if (id === "new") {
|
||||||
|
return Promise.resolve({
|
||||||
|
id: 0,
|
||||||
|
createdOn: "",
|
||||||
|
modifiedOn: "",
|
||||||
|
ownerUserId: 0,
|
||||||
|
domainNames: [],
|
||||||
|
forwardHost: "",
|
||||||
|
forwardPort: 0,
|
||||||
|
accessListId: 0,
|
||||||
|
certificateId: 0,
|
||||||
|
sslForced: false,
|
||||||
|
cachingEnabled: false,
|
||||||
|
blockExploits: false,
|
||||||
|
advancedConfig: "",
|
||||||
|
meta: {},
|
||||||
|
allowWebsocketUpgrade: false,
|
||||||
|
http2Support: false,
|
||||||
|
forwardScheme: "",
|
||||||
|
enabled: true,
|
||||||
|
hstsEnabled: false,
|
||||||
|
hstsSubdomains: false,
|
||||||
|
} as ProxyHost);
|
||||||
|
}
|
||||||
|
return getProxyHost(id, ["owner"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const useProxyHost = (id: number | "new", options = {}) => {
|
||||||
|
return useQuery<ProxyHost, Error>({
|
||||||
|
queryKey: ["proxy-host", id],
|
||||||
|
queryFn: () => fetchProxyHost(id),
|
||||||
|
staleTime: 60 * 1000, // 1 minute
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const useSetProxyHost = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (values: ProxyHost) => (values.id ? updateProxyHost(values) : createProxyHost(values)),
|
||||||
|
onMutate: (values: ProxyHost) => {
|
||||||
|
if (!values.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousObject = queryClient.getQueryData(["proxy-host", values.id]);
|
||||||
|
queryClient.setQueryData(["proxy-host", values.id], (old: ProxyHost) => ({
|
||||||
|
...old,
|
||||||
|
...values,
|
||||||
|
}));
|
||||||
|
return () => queryClient.setQueryData(["proxy-host", values.id], previousObject);
|
||||||
|
},
|
||||||
|
onError: (_, __, rollback: any) => rollback(),
|
||||||
|
onSuccess: async ({ id }: ProxyHost) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["proxy-host", id] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["proxy-hosts"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["audit-logs"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useProxyHost, useSetProxyHost };
|
69
frontend/src/hooks/useRedirectionHost.ts
Normal file
69
frontend/src/hooks/useRedirectionHost.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
createRedirectionHost,
|
||||||
|
getRedirectionHost,
|
||||||
|
type RedirectionHost,
|
||||||
|
updateRedirectionHost,
|
||||||
|
} from "src/api/backend";
|
||||||
|
|
||||||
|
const fetchRedirectionHost = (id: number | "new") => {
|
||||||
|
if (id === "new") {
|
||||||
|
return Promise.resolve({
|
||||||
|
id: 0,
|
||||||
|
createdOn: "",
|
||||||
|
modifiedOn: "",
|
||||||
|
ownerUserId: 0,
|
||||||
|
domainNames: [],
|
||||||
|
forwardDomainName: "",
|
||||||
|
preservePath: false,
|
||||||
|
certificateId: 0,
|
||||||
|
sslForced: false,
|
||||||
|
advancedConfig: "",
|
||||||
|
meta: {},
|
||||||
|
http2Support: false,
|
||||||
|
forwardScheme: "auto",
|
||||||
|
forwardHttpCode: 301,
|
||||||
|
blockExploits: false,
|
||||||
|
enabled: true,
|
||||||
|
hstsEnabled: false,
|
||||||
|
hstsSubdomains: false,
|
||||||
|
} as RedirectionHost);
|
||||||
|
}
|
||||||
|
return getRedirectionHost(id, ["owner"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const useRedirectionHost = (id: number | "new", options = {}) => {
|
||||||
|
return useQuery<RedirectionHost, Error>({
|
||||||
|
queryKey: ["redirection-host", id],
|
||||||
|
queryFn: () => fetchRedirectionHost(id),
|
||||||
|
staleTime: 60 * 1000, // 1 minute
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const useSetRedirectionHost = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (values: RedirectionHost) =>
|
||||||
|
values.id ? updateRedirectionHost(values) : createRedirectionHost(values),
|
||||||
|
onMutate: (values: RedirectionHost) => {
|
||||||
|
if (!values.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousObject = queryClient.getQueryData(["redirection-host", values.id]);
|
||||||
|
queryClient.setQueryData(["redirection-host", values.id], (old: RedirectionHost) => ({
|
||||||
|
...old,
|
||||||
|
...values,
|
||||||
|
}));
|
||||||
|
return () => queryClient.setQueryData(["redirection-host", values.id], previousObject);
|
||||||
|
},
|
||||||
|
onError: (_, __, rollback: any) => rollback(),
|
||||||
|
onSuccess: async ({ id }: RedirectionHost) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["redirection-host", id] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["redirection-hosts"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["audit-logs"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useRedirectionHost, useSetRedirectionHost };
|
54
frontend/src/hooks/useStream.ts
Normal file
54
frontend/src/hooks/useStream.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { createStream, getStream, type Stream, updateStream } from "src/api/backend";
|
||||||
|
|
||||||
|
const fetchStream = (id: number | "new") => {
|
||||||
|
if (id === "new") {
|
||||||
|
return Promise.resolve({
|
||||||
|
id: 0,
|
||||||
|
createdOn: "",
|
||||||
|
modifiedOn: "",
|
||||||
|
ownerUserId: 0,
|
||||||
|
tcpForwarding: true,
|
||||||
|
udpForwarding: false,
|
||||||
|
meta: {},
|
||||||
|
enabled: true,
|
||||||
|
certificateId: 0,
|
||||||
|
} as Stream);
|
||||||
|
}
|
||||||
|
return getStream(id, ["owner"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const useStream = (id: number | "new", options = {}) => {
|
||||||
|
return useQuery<Stream, Error>({
|
||||||
|
queryKey: ["stream", id],
|
||||||
|
queryFn: () => fetchStream(id),
|
||||||
|
staleTime: 60 * 1000, // 1 minute
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const useSetStream = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (values: Stream) => (values.id ? updateStream(values) : createStream(values)),
|
||||||
|
onMutate: (values: Stream) => {
|
||||||
|
if (!values.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousObject = queryClient.getQueryData(["stream", values.id]);
|
||||||
|
queryClient.setQueryData(["stream", values.id], (old: Stream) => ({
|
||||||
|
...old,
|
||||||
|
...values,
|
||||||
|
}));
|
||||||
|
return () => queryClient.setQueryData(["stream", values.id], previousObject);
|
||||||
|
},
|
||||||
|
onError: (_, __, rollback: any) => rollback(),
|
||||||
|
onSuccess: async ({ id }: Stream) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["stream", id] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["streams"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["audit-logs"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useStream, useSetStream };
|
@@ -23,6 +23,7 @@
|
|||||||
"close": "Close",
|
"close": "Close",
|
||||||
"column.access": "Access",
|
"column.access": "Access",
|
||||||
"column.authorization": "Authorization",
|
"column.authorization": "Authorization",
|
||||||
|
"column.custom-locations": "Custom Locations",
|
||||||
"column.destination": "Destination",
|
"column.destination": "Destination",
|
||||||
"column.details": "Details",
|
"column.details": "Details",
|
||||||
"column.email": "Email",
|
"column.email": "Email",
|
||||||
@@ -72,13 +73,29 @@
|
|||||||
"error.passwords-must-match": "Passwords must match",
|
"error.passwords-must-match": "Passwords must match",
|
||||||
"error.required": "This is required",
|
"error.required": "This is required",
|
||||||
"event.created-dead-host": "Created 404 Host",
|
"event.created-dead-host": "Created 404 Host",
|
||||||
|
"event.created-redirection-host": "Created Redirection Host",
|
||||||
|
"event.created-stream": "Created Stream",
|
||||||
"event.created-user": "Created User",
|
"event.created-user": "Created User",
|
||||||
"event.deleted-dead-host": "Deleted 404 Host",
|
"event.deleted-dead-host": "Deleted 404 Host",
|
||||||
|
"event.deleted-stream": "Deleted Stream",
|
||||||
"event.deleted-user": "Deleted User",
|
"event.deleted-user": "Deleted User",
|
||||||
"event.disabled-dead-host": "Disabled 404 Host",
|
"event.disabled-dead-host": "Disabled 404 Host",
|
||||||
|
"event.disabled-redirection-host": "Disabled Redirection Host",
|
||||||
|
"event.disabled-stream": "Disabled Stream",
|
||||||
"event.enabled-dead-host": "Enabled 404 Host",
|
"event.enabled-dead-host": "Enabled 404 Host",
|
||||||
|
"event.enabled-redirection-host": "Enabled Redirection Host",
|
||||||
|
"event.enabled-stream": "Enabled Stream",
|
||||||
|
"event.updated-redirection-host": "Updated Redirection Host",
|
||||||
"event.updated-user": "Updated User",
|
"event.updated-user": "Updated User",
|
||||||
"footer.github-fork": "Fork me on Github",
|
"footer.github-fork": "Fork me on Github",
|
||||||
|
"host.flags.block-exploits": "Block Common Exploits",
|
||||||
|
"host.flags.cache-assets": "Cache Assets",
|
||||||
|
"host.flags.preserve-path": "Preserve Path",
|
||||||
|
"host.flags.protocols": "Protocols",
|
||||||
|
"host.flags.title": "Options",
|
||||||
|
"host.flags.websockets-upgrade": "Websockets Support",
|
||||||
|
"host.forward-port": "Forward Port",
|
||||||
|
"host.forward-scheme": "Scheme",
|
||||||
"hosts.title": "Hosts",
|
"hosts.title": "Hosts",
|
||||||
"http-only": "HTTP Only",
|
"http-only": "HTTP Only",
|
||||||
"lets-encrypt": "Let's Encrypt",
|
"lets-encrypt": "Let's Encrypt",
|
||||||
@@ -95,6 +112,10 @@
|
|||||||
"notification.host-deleted": "Host has been deleted",
|
"notification.host-deleted": "Host has been deleted",
|
||||||
"notification.host-disabled": "Host has been disabled",
|
"notification.host-disabled": "Host has been disabled",
|
||||||
"notification.host-enabled": "Host has been enabled",
|
"notification.host-enabled": "Host has been enabled",
|
||||||
|
"notification.redirection-host-saved": "Redirection Host has been saved",
|
||||||
|
"notification.stream-deleted": "Stream has been deleted",
|
||||||
|
"notification.stream-disabled": "Stream has been disabled",
|
||||||
|
"notification.stream-enabled": "Stream has been enabled",
|
||||||
"notification.success": "Success",
|
"notification.success": "Success",
|
||||||
"notification.user-deleted": "User has been deleted",
|
"notification.user-deleted": "User has been deleted",
|
||||||
"notification.user-disabled": "User has been disabled",
|
"notification.user-disabled": "User has been disabled",
|
||||||
@@ -112,11 +133,15 @@
|
|||||||
"permissions.visibility.all": "All Items",
|
"permissions.visibility.all": "All Items",
|
||||||
"permissions.visibility.title": "Item Visibility",
|
"permissions.visibility.title": "Item Visibility",
|
||||||
"permissions.visibility.user": "Created Items Only",
|
"permissions.visibility.user": "Created Items Only",
|
||||||
|
"proxy-host.forward-host": "Forward Hostname / IP",
|
||||||
|
"proxy-host.new": "New Proxy Host",
|
||||||
"proxy-hosts.actions-title": "Proxy Host #{id}",
|
"proxy-hosts.actions-title": "Proxy Host #{id}",
|
||||||
"proxy-hosts.add": "Add Proxy Host",
|
"proxy-hosts.add": "Add Proxy Host",
|
||||||
"proxy-hosts.count": "{count} Proxy Hosts",
|
"proxy-hosts.count": "{count} Proxy Hosts",
|
||||||
"proxy-hosts.empty": "There are no Proxy Hosts",
|
"proxy-hosts.empty": "There are no Proxy Hosts",
|
||||||
"proxy-hosts.title": "Proxy Hosts",
|
"proxy-hosts.title": "Proxy Hosts",
|
||||||
|
"redirection-host.forward-domain": "Forward Domain",
|
||||||
|
"redirection-host.new": "New Redirection Host",
|
||||||
"redirection-hosts.actions-title": "Redirection Host #{id}",
|
"redirection-hosts.actions-title": "Redirection Host #{id}",
|
||||||
"redirection-hosts.add": "Add Redirection Host",
|
"redirection-hosts.add": "Add Redirection Host",
|
||||||
"redirection-hosts.count": "{count} Redirection Hosts",
|
"redirection-hosts.count": "{count} Redirection Hosts",
|
||||||
@@ -130,6 +155,11 @@
|
|||||||
"setup.title": "Welcome!",
|
"setup.title": "Welcome!",
|
||||||
"sign-in": "Sign in",
|
"sign-in": "Sign in",
|
||||||
"ssl-certificate": "SSL Certificate",
|
"ssl-certificate": "SSL Certificate",
|
||||||
|
"stream.delete.content": "Are you sure you want to delete this Stream?",
|
||||||
|
"stream.delete.title": "Delete Stream",
|
||||||
|
"stream.forward-host": "Forward Host",
|
||||||
|
"stream.incoming-port": "Incoming Port",
|
||||||
|
"stream.new": "New Stream",
|
||||||
"streams.actions-title": "Stream #{id}",
|
"streams.actions-title": "Stream #{id}",
|
||||||
"streams.add": "Add Stream",
|
"streams.add": "Add Stream",
|
||||||
"streams.count": "{count} Streams",
|
"streams.count": "{count} Streams",
|
||||||
|
36
frontend/src/locale/scripts/locale-sort.sh
Executable file
36
frontend/src/locale/scripts/locale-sort.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e -o pipefail
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$DIR/../src" || exit 1
|
||||||
|
|
||||||
|
if ! command -v jq &> /dev/null; then
|
||||||
|
echo "jq could not be found, please install it to sort JSON files."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# iterate over all json files in the current directory
|
||||||
|
for file in *.json; do
|
||||||
|
if [[ -f "$file" ]]; then
|
||||||
|
if [[ ! -s "$file" ]]; then
|
||||||
|
echo "Skipping empty file $file"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$file" == "lang-list.json" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get content of file before sorting
|
||||||
|
original_content=$(<"$file")
|
||||||
|
# compare with sorted content
|
||||||
|
sorted_content=$(jq --tab --sort-keys . "$file")
|
||||||
|
if [ "$original_content" == "$sorted_content" ]; then
|
||||||
|
echo "$file is already sorted"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Sorting $file"
|
||||||
|
jq --tab --sort-keys . "$file" | sponge "$file"
|
||||||
|
fi
|
||||||
|
done
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"access.actions-title": {
|
|
||||||
"defaultMessage": "Access List #{id}"
|
|
||||||
},
|
|
||||||
"access.access-count": {
|
"access.access-count": {
|
||||||
"defaultMessage": "{count} Rules"
|
"defaultMessage": "{count} Rules"
|
||||||
},
|
},
|
||||||
|
"access.actions-title": {
|
||||||
|
"defaultMessage": "Access List #{id}"
|
||||||
|
},
|
||||||
"access.add": {
|
"access.add": {
|
||||||
"defaultMessage": "Add Access List"
|
"defaultMessage": "Add Access List"
|
||||||
},
|
},
|
||||||
@@ -29,21 +29,21 @@
|
|||||||
"action.disable": {
|
"action.disable": {
|
||||||
"defaultMessage": "Disable"
|
"defaultMessage": "Disable"
|
||||||
},
|
},
|
||||||
"action.enable": {
|
|
||||||
"defaultMessage": "Enable"
|
|
||||||
},
|
|
||||||
"action.edit": {
|
"action.edit": {
|
||||||
"defaultMessage": "Edit"
|
"defaultMessage": "Edit"
|
||||||
},
|
},
|
||||||
|
"action.enable": {
|
||||||
|
"defaultMessage": "Enable"
|
||||||
|
},
|
||||||
"action.permissions": {
|
"action.permissions": {
|
||||||
"defaultMessage": "Permissions"
|
"defaultMessage": "Permissions"
|
||||||
},
|
},
|
||||||
"auditlog.title": {
|
|
||||||
"defaultMessage": "Audit Log"
|
|
||||||
},
|
|
||||||
"action.view-details": {
|
"action.view-details": {
|
||||||
"defaultMessage": "View Details"
|
"defaultMessage": "View Details"
|
||||||
},
|
},
|
||||||
|
"auditlog.title": {
|
||||||
|
"defaultMessage": "Audit Log"
|
||||||
|
},
|
||||||
"cancel": {
|
"cancel": {
|
||||||
"defaultMessage": "Cancel"
|
"defaultMessage": "Cancel"
|
||||||
},
|
},
|
||||||
@@ -65,15 +65,15 @@
|
|||||||
"close": {
|
"close": {
|
||||||
"defaultMessage": "Close"
|
"defaultMessage": "Close"
|
||||||
},
|
},
|
||||||
"created-on": {
|
|
||||||
"defaultMessage": "Created: {date}"
|
|
||||||
},
|
|
||||||
"column.access": {
|
"column.access": {
|
||||||
"defaultMessage": "Access"
|
"defaultMessage": "Access"
|
||||||
},
|
},
|
||||||
"column.authorization": {
|
"column.authorization": {
|
||||||
"defaultMessage": "Authorization"
|
"defaultMessage": "Authorization"
|
||||||
},
|
},
|
||||||
|
"column.custom-locations": {
|
||||||
|
"defaultMessage": "Custom Locations"
|
||||||
|
},
|
||||||
"column.destination": {
|
"column.destination": {
|
||||||
"defaultMessage": "Destination"
|
"defaultMessage": "Destination"
|
||||||
},
|
},
|
||||||
@@ -113,30 +113,21 @@
|
|||||||
"column.scheme": {
|
"column.scheme": {
|
||||||
"defaultMessage": "Scheme"
|
"defaultMessage": "Scheme"
|
||||||
},
|
},
|
||||||
"column.status": {
|
"column.source": {
|
||||||
"defaultMessage": "Status"
|
"defaultMessage": "Source"
|
||||||
},
|
},
|
||||||
"column.ssl": {
|
"column.ssl": {
|
||||||
"defaultMessage": "SSL"
|
"defaultMessage": "SSL"
|
||||||
},
|
},
|
||||||
"column.source": {
|
"column.status": {
|
||||||
"defaultMessage": "Source"
|
"defaultMessage": "Status"
|
||||||
|
},
|
||||||
|
"created-on": {
|
||||||
|
"defaultMessage": "Created: {date}"
|
||||||
},
|
},
|
||||||
"dashboard.title": {
|
"dashboard.title": {
|
||||||
"defaultMessage": "Dashboard"
|
"defaultMessage": "Dashboard"
|
||||||
},
|
},
|
||||||
"dead-hosts.actions-title": {
|
|
||||||
"defaultMessage": "404 Host #{id}"
|
|
||||||
},
|
|
||||||
"dead-hosts.add": {
|
|
||||||
"defaultMessage": "Add 404 Host"
|
|
||||||
},
|
|
||||||
"dead-hosts.count": {
|
|
||||||
"defaultMessage": "{count} 404 Hosts"
|
|
||||||
},
|
|
||||||
"dead-hosts.empty": {
|
|
||||||
"defaultMessage": "There are no 404 Hosts"
|
|
||||||
},
|
|
||||||
"dead-host.delete.content": {
|
"dead-host.delete.content": {
|
||||||
"defaultMessage": "Are you sure you want to delete this 404 host?"
|
"defaultMessage": "Are you sure you want to delete this 404 host?"
|
||||||
},
|
},
|
||||||
@@ -149,6 +140,18 @@
|
|||||||
"dead-host.new": {
|
"dead-host.new": {
|
||||||
"defaultMessage": "New 404 Host"
|
"defaultMessage": "New 404 Host"
|
||||||
},
|
},
|
||||||
|
"dead-hosts.actions-title": {
|
||||||
|
"defaultMessage": "404 Host #{id}"
|
||||||
|
},
|
||||||
|
"dead-hosts.add": {
|
||||||
|
"defaultMessage": "Add 404 Host"
|
||||||
|
},
|
||||||
|
"dead-hosts.count": {
|
||||||
|
"defaultMessage": "{count} 404 Hosts"
|
||||||
|
},
|
||||||
|
"dead-hosts.empty": {
|
||||||
|
"defaultMessage": "There are no 404 Hosts"
|
||||||
|
},
|
||||||
"dead-hosts.title": {
|
"dead-hosts.title": {
|
||||||
"defaultMessage": "404 Hosts"
|
"defaultMessage": "404 Hosts"
|
||||||
},
|
},
|
||||||
@@ -191,12 +194,12 @@
|
|||||||
"empty-search": {
|
"empty-search": {
|
||||||
"defaultMessage": "No results found"
|
"defaultMessage": "No results found"
|
||||||
},
|
},
|
||||||
|
"empty-subtitle": {
|
||||||
|
"defaultMessage": "Why don't you create one?"
|
||||||
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"defaultMessage": "Enabled"
|
"defaultMessage": "Enabled"
|
||||||
},
|
},
|
||||||
"error.passwords-must-match": {
|
|
||||||
"defaultMessage": "Passwords must match"
|
|
||||||
},
|
|
||||||
"error.invalid-auth": {
|
"error.invalid-auth": {
|
||||||
"defaultMessage": "Invalid email or password"
|
"defaultMessage": "Invalid email or password"
|
||||||
},
|
},
|
||||||
@@ -209,35 +212,83 @@
|
|||||||
"error.max-domains": {
|
"error.max-domains": {
|
||||||
"defaultMessage": "Too many domains, max is {max}"
|
"defaultMessage": "Too many domains, max is {max}"
|
||||||
},
|
},
|
||||||
|
"error.passwords-must-match": {
|
||||||
|
"defaultMessage": "Passwords must match"
|
||||||
|
},
|
||||||
"error.required": {
|
"error.required": {
|
||||||
"defaultMessage": "This is required"
|
"defaultMessage": "This is required"
|
||||||
},
|
},
|
||||||
"event.created-dead-host": {
|
"event.created-dead-host": {
|
||||||
"defaultMessage": "Created 404 Host"
|
"defaultMessage": "Created 404 Host"
|
||||||
},
|
},
|
||||||
|
"event.created-redirection-host": {
|
||||||
|
"defaultMessage": "Created Redirection Host"
|
||||||
|
},
|
||||||
|
"event.created-stream": {
|
||||||
|
"defaultMessage": "Created Stream"
|
||||||
|
},
|
||||||
"event.created-user": {
|
"event.created-user": {
|
||||||
"defaultMessage": "Created User"
|
"defaultMessage": "Created User"
|
||||||
},
|
},
|
||||||
"event.deleted-dead-host": {
|
"event.deleted-dead-host": {
|
||||||
"defaultMessage": "Deleted 404 Host"
|
"defaultMessage": "Deleted 404 Host"
|
||||||
},
|
},
|
||||||
|
"event.deleted-stream": {
|
||||||
|
"defaultMessage": "Deleted Stream"
|
||||||
|
},
|
||||||
"event.deleted-user": {
|
"event.deleted-user": {
|
||||||
"defaultMessage": "Deleted User"
|
"defaultMessage": "Deleted User"
|
||||||
},
|
},
|
||||||
"event.disabled-dead-host": {
|
"event.disabled-dead-host": {
|
||||||
"defaultMessage": "Disabled 404 Host"
|
"defaultMessage": "Disabled 404 Host"
|
||||||
},
|
},
|
||||||
|
"event.disabled-redirection-host": {
|
||||||
|
"defaultMessage": "Disabled Redirection Host"
|
||||||
|
},
|
||||||
|
"event.disabled-stream": {
|
||||||
|
"defaultMessage": "Disabled Stream"
|
||||||
|
},
|
||||||
"event.enabled-dead-host": {
|
"event.enabled-dead-host": {
|
||||||
"defaultMessage": "Enabled 404 Host"
|
"defaultMessage": "Enabled 404 Host"
|
||||||
},
|
},
|
||||||
|
"event.enabled-redirection-host": {
|
||||||
|
"defaultMessage": "Enabled Redirection Host"
|
||||||
|
},
|
||||||
|
"event.enabled-stream": {
|
||||||
|
"defaultMessage": "Enabled Stream"
|
||||||
|
},
|
||||||
|
"event.updated-redirection-host": {
|
||||||
|
"defaultMessage": "Updated Redirection Host"
|
||||||
|
},
|
||||||
"event.updated-user": {
|
"event.updated-user": {
|
||||||
"defaultMessage": "Updated User"
|
"defaultMessage": "Updated User"
|
||||||
},
|
},
|
||||||
"footer.github-fork": {
|
"footer.github-fork": {
|
||||||
"defaultMessage": "Fork me on Github"
|
"defaultMessage": "Fork me on Github"
|
||||||
},
|
},
|
||||||
"empty-subtitle": {
|
"host.flags.block-exploits": {
|
||||||
"defaultMessage": "Why don't you create one?"
|
"defaultMessage": "Block Common Exploits"
|
||||||
|
},
|
||||||
|
"host.flags.cache-assets": {
|
||||||
|
"defaultMessage": "Cache Assets"
|
||||||
|
},
|
||||||
|
"host.flags.preserve-path": {
|
||||||
|
"defaultMessage": "Preserve Path"
|
||||||
|
},
|
||||||
|
"host.flags.protocols": {
|
||||||
|
"defaultMessage": "Protocols"
|
||||||
|
},
|
||||||
|
"host.flags.title": {
|
||||||
|
"defaultMessage": "Options"
|
||||||
|
},
|
||||||
|
"host.flags.websockets-upgrade": {
|
||||||
|
"defaultMessage": "Websockets Support"
|
||||||
|
},
|
||||||
|
"host.forward-port": {
|
||||||
|
"defaultMessage": "Forward Port"
|
||||||
|
},
|
||||||
|
"host.forward-scheme": {
|
||||||
|
"defaultMessage": "Scheme"
|
||||||
},
|
},
|
||||||
"hosts.title": {
|
"hosts.title": {
|
||||||
"defaultMessage": "Hosts"
|
"defaultMessage": "Hosts"
|
||||||
@@ -281,15 +332,30 @@
|
|||||||
"notification.host-deleted": {
|
"notification.host-deleted": {
|
||||||
"defaultMessage": "Host has been deleted"
|
"defaultMessage": "Host has been deleted"
|
||||||
},
|
},
|
||||||
"notification.user-deleted": {
|
|
||||||
"defaultMessage": "User has been deleted"
|
|
||||||
},
|
|
||||||
"notification.host-disabled": {
|
"notification.host-disabled": {
|
||||||
"defaultMessage": "Host has been disabled"
|
"defaultMessage": "Host has been disabled"
|
||||||
},
|
},
|
||||||
"notification.host-enabled": {
|
"notification.host-enabled": {
|
||||||
"defaultMessage": "Host has been enabled"
|
"defaultMessage": "Host has been enabled"
|
||||||
},
|
},
|
||||||
|
"notification.redirection-host-saved": {
|
||||||
|
"defaultMessage": "Redirection Host has been saved"
|
||||||
|
},
|
||||||
|
"notification.stream-deleted": {
|
||||||
|
"defaultMessage": "Stream has been deleted"
|
||||||
|
},
|
||||||
|
"notification.stream-disabled": {
|
||||||
|
"defaultMessage": "Stream has been disabled"
|
||||||
|
},
|
||||||
|
"notification.stream-enabled": {
|
||||||
|
"defaultMessage": "Stream has been enabled"
|
||||||
|
},
|
||||||
|
"notification.success": {
|
||||||
|
"defaultMessage": "Success"
|
||||||
|
},
|
||||||
|
"notification.user-deleted": {
|
||||||
|
"defaultMessage": "User has been deleted"
|
||||||
|
},
|
||||||
"notification.user-disabled": {
|
"notification.user-disabled": {
|
||||||
"defaultMessage": "User has been disabled"
|
"defaultMessage": "User has been disabled"
|
||||||
},
|
},
|
||||||
@@ -299,9 +365,6 @@
|
|||||||
"notification.user-saved": {
|
"notification.user-saved": {
|
||||||
"defaultMessage": "User has been saved"
|
"defaultMessage": "User has been saved"
|
||||||
},
|
},
|
||||||
"notification.success": {
|
|
||||||
"defaultMessage": "Success"
|
|
||||||
},
|
|
||||||
"offline": {
|
"offline": {
|
||||||
"defaultMessage": "Offline"
|
"defaultMessage": "Offline"
|
||||||
},
|
},
|
||||||
@@ -338,6 +401,12 @@
|
|||||||
"permissions.visibility.user": {
|
"permissions.visibility.user": {
|
||||||
"defaultMessage": "Created Items Only"
|
"defaultMessage": "Created Items Only"
|
||||||
},
|
},
|
||||||
|
"proxy-host.forward-host": {
|
||||||
|
"defaultMessage": "Forward Hostname / IP"
|
||||||
|
},
|
||||||
|
"proxy-host.new": {
|
||||||
|
"defaultMessage": "New Proxy Host"
|
||||||
|
},
|
||||||
"proxy-hosts.actions-title": {
|
"proxy-hosts.actions-title": {
|
||||||
"defaultMessage": "Proxy Host #{id}"
|
"defaultMessage": "Proxy Host #{id}"
|
||||||
},
|
},
|
||||||
@@ -353,6 +422,12 @@
|
|||||||
"proxy-hosts.title": {
|
"proxy-hosts.title": {
|
||||||
"defaultMessage": "Proxy Hosts"
|
"defaultMessage": "Proxy Hosts"
|
||||||
},
|
},
|
||||||
|
"redirection-host.forward-domain": {
|
||||||
|
"defaultMessage": "Forward Domain"
|
||||||
|
},
|
||||||
|
"redirection-host.new": {
|
||||||
|
"defaultMessage": "New Redirection Host"
|
||||||
|
},
|
||||||
"redirection-hosts.actions-title": {
|
"redirection-hosts.actions-title": {
|
||||||
"defaultMessage": "Redirection Host #{id}"
|
"defaultMessage": "Redirection Host #{id}"
|
||||||
},
|
},
|
||||||
@@ -392,6 +467,21 @@
|
|||||||
"ssl-certificate": {
|
"ssl-certificate": {
|
||||||
"defaultMessage": "SSL Certificate"
|
"defaultMessage": "SSL Certificate"
|
||||||
},
|
},
|
||||||
|
"stream.delete.content": {
|
||||||
|
"defaultMessage": "Are you sure you want to delete this Stream?"
|
||||||
|
},
|
||||||
|
"stream.delete.title": {
|
||||||
|
"defaultMessage": "Delete Stream"
|
||||||
|
},
|
||||||
|
"stream.forward-host": {
|
||||||
|
"defaultMessage": "Forward Host"
|
||||||
|
},
|
||||||
|
"stream.incoming-port": {
|
||||||
|
"defaultMessage": "Incoming Port"
|
||||||
|
},
|
||||||
|
"stream.new": {
|
||||||
|
"defaultMessage": "New Stream"
|
||||||
|
},
|
||||||
"streams.actions-title": {
|
"streams.actions-title": {
|
||||||
"defaultMessage": "Stream #{id}"
|
"defaultMessage": "Stream #{id}"
|
||||||
},
|
},
|
||||||
@@ -422,12 +512,12 @@
|
|||||||
"user.current-password": {
|
"user.current-password": {
|
||||||
"defaultMessage": "Current Password"
|
"defaultMessage": "Current Password"
|
||||||
},
|
},
|
||||||
"user.delete.title": {
|
|
||||||
"defaultMessage": "Delete User"
|
|
||||||
},
|
|
||||||
"user.delete.content": {
|
"user.delete.content": {
|
||||||
"defaultMessage": "Are you sure you want to delete this user?"
|
"defaultMessage": "Are you sure you want to delete this user?"
|
||||||
},
|
},
|
||||||
|
"user.delete.title": {
|
||||||
|
"defaultMessage": "Delete User"
|
||||||
|
},
|
||||||
"user.edit": {
|
"user.edit": {
|
||||||
"defaultMessage": "Edit User"
|
"defaultMessage": "Edit User"
|
||||||
},
|
},
|
||||||
|
@@ -136,7 +136,7 @@ export function DeadHostModal({ id, onClose }: Props) {
|
|||||||
label="ssl-certificate"
|
label="ssl-certificate"
|
||||||
allowNew
|
allowNew
|
||||||
/>
|
/>
|
||||||
<SSLOptionsFields />
|
<SSLOptionsFields color="bg-red" />
|
||||||
</div>
|
</div>
|
||||||
<div className="tab-pane" id="tab-advanced" role="tabpanel">
|
<div className="tab-pane" id="tab-advanced" role="tabpanel">
|
||||||
<NginxConfigField />
|
<NginxConfigField />
|
||||||
@@ -152,7 +152,7 @@ export function DeadHostModal({ id, onClose }: Props) {
|
|||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
actionType="primary"
|
actionType="primary"
|
||||||
className="ms-auto"
|
className="ms-auto bg-red"
|
||||||
data-bs-dismiss="modal"
|
data-bs-dismiss="modal"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
|
377
frontend/src/modals/ProxyHostModal.tsx
Normal file
377
frontend/src/modals/ProxyHostModal.tsx
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
import { IconSettings } from "@tabler/icons-react";
|
||||||
|
import cn from "classnames";
|
||||||
|
import { Field, Form, Formik } from "formik";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Alert } from "react-bootstrap";
|
||||||
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
DomainNamesField,
|
||||||
|
Loading,
|
||||||
|
NginxConfigField,
|
||||||
|
SSLCertificateField,
|
||||||
|
SSLOptionsFields,
|
||||||
|
} from "src/components";
|
||||||
|
import { useProxyHost, useSetProxyHost } from "src/hooks";
|
||||||
|
import { intl } from "src/locale";
|
||||||
|
import { validateNumber, validateString } from "src/modules/Validations";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number | "new";
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
export function ProxyHostModal({ id, onClose }: Props) {
|
||||||
|
const { data, isLoading, error } = useProxyHost(id);
|
||||||
|
const { mutate: setProxyHost } = useSetProxyHost();
|
||||||
|
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
const onSubmit = async (values: any, { setSubmitting }: any) => {
|
||||||
|
if (isSubmitting) return;
|
||||||
|
setIsSubmitting(true);
|
||||||
|
setErrorMsg(null);
|
||||||
|
|
||||||
|
const { ...payload } = {
|
||||||
|
id: id === "new" ? undefined : id,
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
|
||||||
|
setProxyHost(payload, {
|
||||||
|
onError: (err: any) => setErrorMsg(err.message),
|
||||||
|
onSuccess: () => {
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.proxy-host-saved" }));
|
||||||
|
onClose();
|
||||||
|
},
|
||||||
|
onSettled: () => {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
setSubmitting(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal show onHide={onClose} animation={false}>
|
||||||
|
{!isLoading && error && (
|
||||||
|
<Alert variant="danger" className="m-3">
|
||||||
|
{error?.message || "Unknown error"}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{isLoading && <Loading noLogo />}
|
||||||
|
{!isLoading && data && (
|
||||||
|
<Formik
|
||||||
|
initialValues={
|
||||||
|
{
|
||||||
|
// Details tab
|
||||||
|
domainNames: data?.domainNames || [],
|
||||||
|
forwardScheme: data?.forwardScheme || "http",
|
||||||
|
forwardHost: data?.forwardHost || "",
|
||||||
|
forwardPort: data?.forwardPort || undefined,
|
||||||
|
accessListId: data?.accessListId || 0,
|
||||||
|
cachingEnabled: data?.cachingEnabled || false,
|
||||||
|
blockExploits: data?.blockExploits || false,
|
||||||
|
allowWebsocketUpgrade: data?.allowWebsocketUpgrade || false,
|
||||||
|
// Locations tab
|
||||||
|
locations: data?.locations || [],
|
||||||
|
// SSL tab
|
||||||
|
certificateId: data?.certificateId || 0,
|
||||||
|
sslForced: data?.sslForced || false,
|
||||||
|
http2Support: data?.http2Support || false,
|
||||||
|
hstsEnabled: data?.hstsEnabled || false,
|
||||||
|
hstsSubdomains: data?.hstsSubdomains || false,
|
||||||
|
// Advanced tab
|
||||||
|
advancedConfig: data?.advancedConfig || "",
|
||||||
|
meta: data?.meta || {},
|
||||||
|
} as any
|
||||||
|
}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
|
{() => (
|
||||||
|
<Form>
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: data?.id ? "proxy-host.edit" : "proxy-host.new",
|
||||||
|
})}
|
||||||
|
</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body className="p-0">
|
||||||
|
<Alert variant="danger" show={!!errorMsg} onClose={() => setErrorMsg(null)} dismissible>
|
||||||
|
{errorMsg}
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<div className="card m-0 border-0">
|
||||||
|
<div className="card-header">
|
||||||
|
<ul className="nav nav-tabs card-header-tabs" data-bs-toggle="tabs">
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-details"
|
||||||
|
className="nav-link active"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="true"
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.details" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-locations"
|
||||||
|
className="nav-link"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.custom-locations" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-ssl"
|
||||||
|
className="nav-link"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.ssl" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item ms-auto" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-advanced"
|
||||||
|
className="nav-link"
|
||||||
|
title="Settings"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
<IconSettings size={20} />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="tab-content">
|
||||||
|
<div className="tab-pane active show" id="tab-details" role="tabpanel">
|
||||||
|
<DomainNamesField isWildcardPermitted />
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-3">
|
||||||
|
<Field name="forwardScheme">
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label
|
||||||
|
className="form-label"
|
||||||
|
htmlFor="forwardScheme"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.forward-scheme",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="forwardScheme"
|
||||||
|
className={`form-control ${form.errors.forwardScheme && form.touched.forwardScheme ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
{...field}
|
||||||
|
>
|
||||||
|
<option value="http">http</option>
|
||||||
|
<option value="https">https</option>
|
||||||
|
</select>
|
||||||
|
{form.errors.forwardScheme ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardScheme &&
|
||||||
|
form.touched.forwardScheme
|
||||||
|
? form.errors.forwardScheme
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<Field name="forwardHost" validate={validateString(1, 255)}>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label" htmlFor="forwardHost">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "proxy-host.forward-host",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="forwardHost"
|
||||||
|
type="text"
|
||||||
|
className={`form-control ${form.errors.forwardHost && form.touched.forwardHost ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="example.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.forwardHost ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardHost &&
|
||||||
|
form.touched.forwardHost
|
||||||
|
? form.errors.forwardHost
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-3">
|
||||||
|
<Field name="forwardPort" validate={validateNumber(1, 65535)}>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label" htmlFor="forwardPort">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.forward-port",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="forwardPort"
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
max={65535}
|
||||||
|
className={`form-control ${form.errors.forwardPort && form.touched.forwardPort ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="eg: 8081"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.forwardPort ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardPort &&
|
||||||
|
form.touched.forwardPort
|
||||||
|
? form.errors.forwardPort
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="my-3">
|
||||||
|
<h4 className="py-2">
|
||||||
|
{intl.formatMessage({ id: "host.flags.title" })}
|
||||||
|
</h4>
|
||||||
|
<div className="divide-y">
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="cachingEnabled">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.flags.cache-assets",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="cachingEnabled" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
{...field}
|
||||||
|
id="cachingEnabled"
|
||||||
|
className={cn("form-check-input", {
|
||||||
|
"bg-lime": field.checked,
|
||||||
|
})}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="blockExploits">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.flags.block-exploits",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="blockExploits" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
{...field}
|
||||||
|
id="blockExploits"
|
||||||
|
className={cn("form-check-input", {
|
||||||
|
"bg-lime": field.checked,
|
||||||
|
})}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="allowWebsocketUpgrade">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.flags.websockets-upgrade",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="allowWebsocketUpgrade" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
{...field}
|
||||||
|
id="allowWebsocketUpgrade"
|
||||||
|
className={cn("form-check-input", {
|
||||||
|
"bg-lime": field.checked,
|
||||||
|
})}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-locations" role="tabpanel">
|
||||||
|
locations
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-ssl" role="tabpanel">
|
||||||
|
<SSLCertificateField
|
||||||
|
name="certificateId"
|
||||||
|
label="ssl-certificate"
|
||||||
|
allowNew
|
||||||
|
/>
|
||||||
|
<SSLOptionsFields color="bg-lime" />
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-advanced" role="tabpanel">
|
||||||
|
<NginxConfigField />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal.Body>
|
||||||
|
<Modal.Footer>
|
||||||
|
<Button data-bs-dismiss="modal" onClick={onClose} disabled={isSubmitting}>
|
||||||
|
{intl.formatMessage({ id: "cancel" })}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
actionType="primary"
|
||||||
|
className="ms-auto bg-lime"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "save" })}
|
||||||
|
</Button>
|
||||||
|
</Modal.Footer>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
|
</Formik>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
309
frontend/src/modals/RedirectionHostModal.tsx
Normal file
309
frontend/src/modals/RedirectionHostModal.tsx
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
import { IconSettings } from "@tabler/icons-react";
|
||||||
|
import cn from "classnames";
|
||||||
|
import { Field, Form, Formik } from "formik";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Alert } from "react-bootstrap";
|
||||||
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
DomainNamesField,
|
||||||
|
Loading,
|
||||||
|
NginxConfigField,
|
||||||
|
SSLCertificateField,
|
||||||
|
SSLOptionsFields,
|
||||||
|
} from "src/components";
|
||||||
|
import { useRedirectionHost, useSetRedirectionHost } from "src/hooks";
|
||||||
|
import { intl } from "src/locale";
|
||||||
|
import { validateString } from "src/modules/Validations";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number | "new";
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
export function RedirectionHostModal({ id, onClose }: Props) {
|
||||||
|
const { data, isLoading, error } = useRedirectionHost(id);
|
||||||
|
const { mutate: setRedirectionHost } = useSetRedirectionHost();
|
||||||
|
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
const onSubmit = async (values: any, { setSubmitting }: any) => {
|
||||||
|
if (isSubmitting) return;
|
||||||
|
setIsSubmitting(true);
|
||||||
|
setErrorMsg(null);
|
||||||
|
|
||||||
|
const { ...payload } = {
|
||||||
|
id: id === "new" ? undefined : id,
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
|
||||||
|
setRedirectionHost(payload, {
|
||||||
|
onError: (err: any) => setErrorMsg(err.message),
|
||||||
|
onSuccess: () => {
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.redirection-host-saved" }));
|
||||||
|
onClose();
|
||||||
|
},
|
||||||
|
onSettled: () => {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
setSubmitting(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal show onHide={onClose} animation={false}>
|
||||||
|
{!isLoading && error && (
|
||||||
|
<Alert variant="danger" className="m-3">
|
||||||
|
{error?.message || "Unknown error"}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{isLoading && <Loading noLogo />}
|
||||||
|
{!isLoading && data && (
|
||||||
|
<Formik
|
||||||
|
initialValues={
|
||||||
|
{
|
||||||
|
// Details tab
|
||||||
|
domainNames: data?.domainNames || [],
|
||||||
|
forwardDomainName: data?.forwardDomainName || "",
|
||||||
|
forwardScheme: data?.forwardScheme || "auto",
|
||||||
|
forwardHttpCode: data?.forwardHttpCode || 301,
|
||||||
|
preservePath: data?.preservePath || false,
|
||||||
|
blockExploits: data?.blockExploits || false,
|
||||||
|
// SSL tab
|
||||||
|
certificateId: data?.certificateId || 0,
|
||||||
|
sslForced: data?.sslForced || false,
|
||||||
|
http2Support: data?.http2Support || false,
|
||||||
|
hstsEnabled: data?.hstsEnabled || false,
|
||||||
|
hstsSubdomains: data?.hstsSubdomains || false,
|
||||||
|
// Advanced tab
|
||||||
|
advancedConfig: data?.advancedConfig || "",
|
||||||
|
meta: data?.meta || {},
|
||||||
|
} as any
|
||||||
|
}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
|
{() => (
|
||||||
|
<Form>
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: data?.id ? "redirection-host.edit" : "redirection-host.new",
|
||||||
|
})}
|
||||||
|
</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body className="p-0">
|
||||||
|
<Alert variant="danger" show={!!errorMsg} onClose={() => setErrorMsg(null)} dismissible>
|
||||||
|
{errorMsg}
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<div className="card m-0 border-0">
|
||||||
|
<div className="card-header">
|
||||||
|
<ul className="nav nav-tabs card-header-tabs" data-bs-toggle="tabs">
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-details"
|
||||||
|
className="nav-link active"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="true"
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.details" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-ssl"
|
||||||
|
className="nav-link"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.ssl" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item ms-auto" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-advanced"
|
||||||
|
className="nav-link"
|
||||||
|
title="Settings"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
<IconSettings size={20} />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="tab-content">
|
||||||
|
<div className="tab-pane active show" id="tab-details" role="tabpanel">
|
||||||
|
<DomainNamesField isWildcardPermitted />
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-4">
|
||||||
|
<Field name="forwardScheme">
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label
|
||||||
|
className="form-label"
|
||||||
|
htmlFor="forwardScheme"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.forward-scheme",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="forwardScheme"
|
||||||
|
className={`form-control ${form.errors.forwardScheme && form.touched.forwardScheme ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
{...field}
|
||||||
|
>
|
||||||
|
<option value="$scheme">Auto</option>
|
||||||
|
<option value="http">http</option>
|
||||||
|
<option value="https">https</option>
|
||||||
|
</select>
|
||||||
|
{form.errors.forwardScheme ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardScheme &&
|
||||||
|
form.touched.forwardScheme
|
||||||
|
? form.errors.forwardScheme
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-8">
|
||||||
|
<Field
|
||||||
|
name="forwardDomainName"
|
||||||
|
validate={validateString(1, 255)}
|
||||||
|
>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label
|
||||||
|
className="form-label"
|
||||||
|
htmlFor="forwardDomainName"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "redirection-host.forward-domain",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="forwardDomainName"
|
||||||
|
type="text"
|
||||||
|
className={`form-control ${form.errors.forwardDomainName && form.touched.forwardDomainName ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="example.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.forwardDomainName ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardDomainName &&
|
||||||
|
form.touched.forwardDomainName
|
||||||
|
? form.errors.forwardDomainName
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="my-3">
|
||||||
|
<h4 className="py-2">
|
||||||
|
{intl.formatMessage({ id: "host.flags.title" })}
|
||||||
|
</h4>
|
||||||
|
<div className="divide-y">
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="preservePath">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.flags.preserve-path",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="preservePath" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
{...field}
|
||||||
|
id="preservePath"
|
||||||
|
className={cn("form-check-input", {
|
||||||
|
"bg-yellow": field.checked,
|
||||||
|
})}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="blockExploits">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.flags.block-exploits",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="blockExploits" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
{...field}
|
||||||
|
id="blockExploits"
|
||||||
|
className={cn("form-check-input", {
|
||||||
|
"bg-yellow": field.checked,
|
||||||
|
})}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-ssl" role="tabpanel">
|
||||||
|
<SSLCertificateField
|
||||||
|
name="certificateId"
|
||||||
|
label="ssl-certificate"
|
||||||
|
allowNew
|
||||||
|
/>
|
||||||
|
<SSLOptionsFields color="bg-yellow" />
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-advanced" role="tabpanel">
|
||||||
|
<NginxConfigField />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal.Body>
|
||||||
|
<Modal.Footer>
|
||||||
|
<Button data-bs-dismiss="modal" onClick={onClose} disabled={isSubmitting}>
|
||||||
|
{intl.formatMessage({ id: "cancel" })}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
actionType="primary"
|
||||||
|
className="ms-auto bg-yellow"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "save" })}
|
||||||
|
</Button>
|
||||||
|
</Modal.Footer>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
|
</Formik>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
327
frontend/src/modals/StreamModal.tsx
Normal file
327
frontend/src/modals/StreamModal.tsx
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
import { Field, Form, Formik } from "formik";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Alert } from "react-bootstrap";
|
||||||
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import { Button, Loading, SSLCertificateField, SSLOptionsFields } from "src/components";
|
||||||
|
import { useSetStream, useStream } from "src/hooks";
|
||||||
|
import { intl } from "src/locale";
|
||||||
|
import { validateNumber, validateString } from "src/modules/Validations";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number | "new";
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
export function StreamModal({ id, onClose }: Props) {
|
||||||
|
const { data, isLoading, error } = useStream(id);
|
||||||
|
const { mutate: setStream } = useSetStream();
|
||||||
|
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
const onSubmit = async (values: any, { setSubmitting }: any) => {
|
||||||
|
if (isSubmitting) return;
|
||||||
|
setIsSubmitting(true);
|
||||||
|
setErrorMsg(null);
|
||||||
|
|
||||||
|
const { ...payload } = {
|
||||||
|
id: id === "new" ? undefined : id,
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
|
||||||
|
setStream(payload, {
|
||||||
|
onError: (err: any) => setErrorMsg(err.message),
|
||||||
|
onSuccess: () => {
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.stream-saved" }));
|
||||||
|
onClose();
|
||||||
|
},
|
||||||
|
onSettled: () => {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
setSubmitting(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal show onHide={onClose} animation={false}>
|
||||||
|
{!isLoading && error && (
|
||||||
|
<Alert variant="danger" className="m-3">
|
||||||
|
{error?.message || "Unknown error"}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{isLoading && <Loading noLogo />}
|
||||||
|
{!isLoading && data && (
|
||||||
|
<Formik
|
||||||
|
initialValues={
|
||||||
|
{
|
||||||
|
incomingPort: data?.incomingPort,
|
||||||
|
forwardingHost: data?.forwardingHost,
|
||||||
|
forwardingPort: data?.forwardingPort,
|
||||||
|
tcpForwarding: data?.tcpForwarding,
|
||||||
|
udpForwarding: data?.udpForwarding,
|
||||||
|
certificateId: data?.certificateId,
|
||||||
|
meta: data?.meta || {},
|
||||||
|
} as any
|
||||||
|
}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
|
{({ setFieldValue }: any) => (
|
||||||
|
<Form>
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>
|
||||||
|
{intl.formatMessage({ id: data?.id ? "stream.edit" : "stream.new" })}
|
||||||
|
</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body className="p-0">
|
||||||
|
<Alert variant="danger" show={!!errorMsg} onClose={() => setErrorMsg(null)} dismissible>
|
||||||
|
{errorMsg}
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<div className="card m-0 border-0">
|
||||||
|
<div className="card-header">
|
||||||
|
<ul className="nav nav-tabs card-header-tabs" data-bs-toggle="tabs">
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-details"
|
||||||
|
className="nav-link active"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="true"
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.details" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item" role="presentation">
|
||||||
|
<a
|
||||||
|
href="#tab-ssl"
|
||||||
|
className="nav-link"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
aria-selected="false"
|
||||||
|
tabIndex={-1}
|
||||||
|
role="tab"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "column.ssl" })}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="tab-content">
|
||||||
|
<div className="tab-pane active show" id="tab-details" role="tabpanel">
|
||||||
|
<Field name="incomingPort" validate={validateNumber(1, 65535)}>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label" htmlFor="incomingPort">
|
||||||
|
{intl.formatMessage({ id: "stream.incoming-port" })}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="incomingPort"
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
max={65535}
|
||||||
|
className={`form-control ${form.errors.incomingPort && form.touched.incomingPort ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="eg: 8080"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.incomingPort ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.incomingPort &&
|
||||||
|
form.touched.incomingPort
|
||||||
|
? form.errors.incomingPort
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-8">
|
||||||
|
<Field name="forwardingHost" validate={validateString(1, 255)}>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label
|
||||||
|
className="form-label"
|
||||||
|
htmlFor="forwardingHost"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "stream.forward-host",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="forwardingHost"
|
||||||
|
type="text"
|
||||||
|
className={`form-control ${form.errors.forwardingHost && form.touched.forwardingHost ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="example.com or 10.0.0.1 or 2001:db8:3333:4444:5555:6666:7777:8888"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.forwardingHost ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardingHost &&
|
||||||
|
form.touched.forwardingHost
|
||||||
|
? form.errors.forwardingHost
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<Field
|
||||||
|
name="forwardingPort"
|
||||||
|
validate={validateNumber(1, 65535)}
|
||||||
|
>
|
||||||
|
{({ field, form }: any) => (
|
||||||
|
<div className="mb-3">
|
||||||
|
<label
|
||||||
|
className="form-label"
|
||||||
|
htmlFor="forwardingPort"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "host.forward-port",
|
||||||
|
})}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="forwardingPort"
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
max={65535}
|
||||||
|
className={`form-control ${form.errors.forwardingPort && form.touched.forwardingPort ? "is-invalid" : ""}`}
|
||||||
|
required
|
||||||
|
placeholder="eg: 8081"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
{form.errors.forwardingPort ? (
|
||||||
|
<div className="invalid-feedback">
|
||||||
|
{form.errors.forwardingPort &&
|
||||||
|
form.touched.forwardingPort
|
||||||
|
? form.errors.forwardingPort
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="my-3">
|
||||||
|
<h3 className="py-2">
|
||||||
|
{intl.formatMessage({ id: "host.flags.protocols" })}
|
||||||
|
</h3>
|
||||||
|
<div className="divide-y">
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="tcpForwarding">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "streams.tcp",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="tcpForwarding" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
id="tcpForwarding"
|
||||||
|
className="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
name={field.name}
|
||||||
|
checked={field.value}
|
||||||
|
onChange={(e: any) => {
|
||||||
|
setFieldValue(
|
||||||
|
field.name,
|
||||||
|
e.target.checked,
|
||||||
|
);
|
||||||
|
if (!e.target.checked) {
|
||||||
|
setFieldValue(
|
||||||
|
"udpForwarding",
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="row" htmlFor="udpForwarding">
|
||||||
|
<span className="col">
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: "streams.udp",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<span className="col-auto">
|
||||||
|
<Field name="udpForwarding" type="checkbox">
|
||||||
|
{({ field }: any) => (
|
||||||
|
<label className="form-check form-check-single form-switch">
|
||||||
|
<input
|
||||||
|
id="udpForwarding"
|
||||||
|
className="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
name={field.name}
|
||||||
|
checked={field.value}
|
||||||
|
onChange={(e: any) => {
|
||||||
|
setFieldValue(
|
||||||
|
field.name,
|
||||||
|
e.target.checked,
|
||||||
|
);
|
||||||
|
if (!e.target.checked) {
|
||||||
|
setFieldValue(
|
||||||
|
"tcpForwarding",
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="tab-pane" id="tab-ssl" role="tabpanel">
|
||||||
|
<SSLCertificateField
|
||||||
|
name="certificateId"
|
||||||
|
label="ssl-certificate"
|
||||||
|
allowNew
|
||||||
|
forHttp={false}
|
||||||
|
/>
|
||||||
|
<SSLOptionsFields
|
||||||
|
color="bg-blue"
|
||||||
|
forHttp={false}
|
||||||
|
forceDNSForNew
|
||||||
|
requireDomainNames
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal.Body>
|
||||||
|
<Modal.Footer>
|
||||||
|
<Button data-bs-dismiss="modal" onClick={onClose} disabled={isSubmitting}>
|
||||||
|
{intl.formatMessage({ id: "cancel" })}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
actionType="primary"
|
||||||
|
className="ms-auto"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "save" })}
|
||||||
|
</Button>
|
||||||
|
</Modal.Footer>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
|
</Formik>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
@@ -167,7 +167,7 @@ export function UserModal({ userId, onClose }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
{currentUser && data && currentUser?.id !== data?.id ? (
|
{currentUser && data && currentUser?.id !== data?.id ? (
|
||||||
<div className="my-3">
|
<div className="my-3">
|
||||||
<h3 className="py-2">{intl.formatMessage({ id: "user.flags.title" })}</h3>
|
<h4 className="py-2">{intl.formatMessage({ id: "user.flags.title" })}</h4>
|
||||||
<div className="divide-y">
|
<div className="divide-y">
|
||||||
<div>
|
<div>
|
||||||
<label className="row" htmlFor="isAdmin">
|
<label className="row" htmlFor="isAdmin">
|
||||||
|
@@ -3,5 +3,8 @@ export * from "./DeadHostModal";
|
|||||||
export * from "./DeleteConfirmModal";
|
export * from "./DeleteConfirmModal";
|
||||||
export * from "./EventDetailsModal";
|
export * from "./EventDetailsModal";
|
||||||
export * from "./PermissionsModal";
|
export * from "./PermissionsModal";
|
||||||
|
export * from "./ProxyHostModal";
|
||||||
|
export * from "./RedirectionHostModal";
|
||||||
export * from "./SetPasswordModal";
|
export * from "./SetPasswordModal";
|
||||||
|
export * from "./StreamModal";
|
||||||
export * from "./UserModal";
|
export * from "./UserModal";
|
||||||
|
@@ -85,18 +85,18 @@ const validateDomain = (allowWildcards = false) => {
|
|||||||
const validateDomains = (allowWildcards = false, maxDomains?: number) => {
|
const validateDomains = (allowWildcards = false, maxDomains?: number) => {
|
||||||
const vDom = validateDomain(allowWildcards);
|
const vDom = validateDomain(allowWildcards);
|
||||||
|
|
||||||
return (value: string[]): string | undefined => {
|
return (value?: string[]): string | undefined => {
|
||||||
if (!value.length) {
|
if (!value?.length) {
|
||||||
return intl.formatMessage({ id: "error.required" });
|
return intl.formatMessage({ id: "error.required" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny if the list of domains is hit
|
// Deny if the list of domains is hit
|
||||||
if (maxDomains && value.length >= maxDomains) {
|
if (maxDomains && value?.length >= maxDomains) {
|
||||||
return intl.formatMessage({ id: "error.max-domains" }, { max: maxDomains });
|
return intl.formatMessage({ id: "error.max-domains" }, { max: maxDomains });
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate each domain
|
// validate each domain
|
||||||
for (let i = 0; i < value.length; i++) {
|
for (let i = 0; i < value?.length; i++) {
|
||||||
if (!vDom(value[i])) {
|
if (!vDom(value[i])) {
|
||||||
return intl.formatMessage({ id: "error.invalid-domain" }, { domain: value[i] });
|
return intl.formatMessage({ id: "error.invalid-domain" }, { domain: value[i] });
|
||||||
}
|
}
|
||||||
|
@@ -122,14 +122,9 @@ const Dashboard = () => {
|
|||||||
<pre>
|
<pre>
|
||||||
<code>{`Todo:
|
<code>{`Todo:
|
||||||
|
|
||||||
- Users: permissions modal and trigger after adding user
|
|
||||||
- modal dialgs for everything
|
|
||||||
- Tables
|
|
||||||
- check mobile
|
- check mobile
|
||||||
- fix bad jwt not refreshing entire page
|
|
||||||
- add help docs for host types
|
- add help docs for host types
|
||||||
- REDO SCREENSHOTS in docs folder
|
- REDO SCREENSHOTS in docs folder
|
||||||
- Remove letsEncryptEmail field from new certificate requests, use current user email server side
|
|
||||||
|
|
||||||
More for api, then implement here:
|
More for api, then implement here:
|
||||||
- Properly implement refresh tokens
|
- Properly implement refresh tokens
|
||||||
|
@@ -5,17 +5,24 @@ import { intl } from "src/locale";
|
|||||||
interface Props {
|
interface Props {
|
||||||
tableInstance: ReactTable<any>;
|
tableInstance: ReactTable<any>;
|
||||||
onNew?: () => void;
|
onNew?: () => void;
|
||||||
|
isFiltered?: boolean;
|
||||||
}
|
}
|
||||||
export default function Empty({ tableInstance, onNew }: Props) {
|
export default function Empty({ tableInstance, onNew, isFiltered }: Props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||||
<div className="text-center my-4">
|
<div className="text-center my-4">
|
||||||
|
{isFiltered ? (
|
||||||
|
<h2>{intl.formatMessage({ id: "empty-search" })}</h2>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<h2>{intl.formatMessage({ id: "dead-hosts.empty" })}</h2>
|
<h2>{intl.formatMessage({ id: "dead-hosts.empty" })}</h2>
|
||||||
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
||||||
<Button className="btn-red my-3" onClick={onNew}>
|
<Button className="btn-red my-3" onClick={onNew}>
|
||||||
{intl.formatMessage({ id: "dead-hosts.add" })}
|
{intl.formatMessage({ id: "dead-hosts.add" })}
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -9,13 +9,14 @@ import Empty from "./Empty";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: DeadHost[];
|
data: DeadHost[];
|
||||||
|
isFiltered?: boolean;
|
||||||
isFetching?: boolean;
|
isFetching?: boolean;
|
||||||
onEdit?: (id: number) => void;
|
onEdit?: (id: number) => void;
|
||||||
onDelete?: (id: number) => void;
|
onDelete?: (id: number) => void;
|
||||||
onDisableToggle?: (id: number, enabled: boolean) => void;
|
onDisableToggle?: (id: number, enabled: boolean) => void;
|
||||||
onNew?: () => void;
|
onNew?: () => void;
|
||||||
}
|
}
|
||||||
export default function Table({ data, isFetching, onEdit, onDelete, onDisableToggle, onNew }: Props) {
|
export default function Table({ data, isFetching, onEdit, onDelete, onDisableToggle, onNew, isFiltered }: Props) {
|
||||||
const columnHelper = createColumnHelper<DeadHost>();
|
const columnHelper = createColumnHelper<DeadHost>();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@@ -133,6 +134,9 @@ export default function Table({ data, isFetching, onEdit, onDelete, onDisableTog
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableLayout tableInstance={tableInstance} emptyState={<Empty tableInstance={tableInstance} onNew={onNew} />} />
|
<TableLayout
|
||||||
|
tableInstance={tableInstance}
|
||||||
|
emptyState={<Empty tableInstance={tableInstance} onNew={onNew} isFiltered={isFiltered} />}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -56,9 +56,9 @@ export default function TableWrapper() {
|
|||||||
<div className="col">
|
<div className="col">
|
||||||
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "dead-hosts.title" })}</h2>
|
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "dead-hosts.title" })}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.length ? (
|
||||||
<div className="col-md-auto col-sm-12">
|
<div className="col-md-auto col-sm-12">
|
||||||
<div className="ms-auto d-flex flex-wrap btn-list">
|
<div className="ms-auto d-flex flex-wrap btn-list">
|
||||||
{data?.length ? (
|
|
||||||
<div className="input-group input-group-flat w-auto">
|
<div className="input-group input-group-flat w-auto">
|
||||||
<span className="input-group-text input-group-text-sm">
|
<span className="input-group-text input-group-text-sm">
|
||||||
<IconSearch size={16} />
|
<IconSearch size={16} />
|
||||||
@@ -71,16 +71,18 @@ export default function TableWrapper() {
|
|||||||
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
<Button size="sm" className="btn-red" onClick={() => setEditId("new")}>
|
<Button size="sm" className="btn-red" onClick={() => setEditId("new")}>
|
||||||
{intl.formatMessage({ id: "dead-hosts.add" })}
|
{intl.formatMessage({ id: "dead-hosts.add" })}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
data={filtered ?? data ?? []}
|
data={filtered ?? data ?? []}
|
||||||
|
isFiltered={!!search}
|
||||||
isFetching={isFetching}
|
isFetching={isFetching}
|
||||||
onEdit={(id: number) => setEditId(id)}
|
onEdit={(id: number) => setEditId(id)}
|
||||||
onDelete={(id: number) => setDeleteId(id)}
|
onDelete={(id: number) => setDeleteId(id)}
|
||||||
|
@@ -2,22 +2,27 @@ import type { Table as ReactTable } from "@tanstack/react-table";
|
|||||||
import { Button } from "src/components";
|
import { Button } from "src/components";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
|
|
||||||
/**
|
|
||||||
* This component should never render as there should always be 1 user minimum,
|
|
||||||
* but I'm keeping it for consistency.
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
tableInstance: ReactTable<any>;
|
tableInstance: ReactTable<any>;
|
||||||
|
onNew?: () => void;
|
||||||
|
isFiltered?: boolean;
|
||||||
}
|
}
|
||||||
export default function Empty({ tableInstance }: Props) {
|
export default function Empty({ tableInstance, onNew, isFiltered }: Props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||||
<div className="text-center my-4">
|
<div className="text-center my-4">
|
||||||
|
{isFiltered ? (
|
||||||
|
<h2>{intl.formatMessage({ id: "empty-search" })}</h2>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<h2>{intl.formatMessage({ id: "proxy-hosts.empty" })}</h2>
|
<h2>{intl.formatMessage({ id: "proxy-hosts.empty" })}</h2>
|
||||||
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
||||||
<Button className="btn-lime my-3">{intl.formatMessage({ id: "proxy-hosts.add" })}</Button>
|
<Button className="btn-lime my-3" onClick={onNew}>
|
||||||
|
{intl.formatMessage({ id: "proxy-hosts.add" })}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -9,9 +9,14 @@ import Empty from "./Empty";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: ProxyHost[];
|
data: ProxyHost[];
|
||||||
|
isFiltered?: boolean;
|
||||||
isFetching?: boolean;
|
isFetching?: boolean;
|
||||||
|
onEdit?: (id: number) => void;
|
||||||
|
onDelete?: (id: number) => void;
|
||||||
|
onDisableToggle?: (id: number, enabled: boolean) => void;
|
||||||
|
onNew?: () => void;
|
||||||
}
|
}
|
||||||
export default function Table({ data, isFetching }: Props) {
|
export default function Table({ data, isFetching, onEdit, onDelete, onDisableToggle, onNew, isFiltered }: Props) {
|
||||||
const columnHelper = createColumnHelper<ProxyHost>();
|
const columnHelper = createColumnHelper<ProxyHost>();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@@ -64,7 +69,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
id: "id", // todo: not needed for a display?
|
id: "id",
|
||||||
cell: (info: any) => {
|
cell: (info: any) => {
|
||||||
return (
|
return (
|
||||||
<span className="dropdown">
|
<span className="dropdown">
|
||||||
@@ -85,16 +90,39 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
{ id: info.row.original.id },
|
{ id: info.row.original.id },
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onEdit?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconEdit size={16} />
|
<IconEdit size={16} />
|
||||||
{intl.formatMessage({ id: "action.edit" })}
|
{intl.formatMessage({ id: "action.edit" })}
|
||||||
</a>
|
</a>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDisableToggle?.(info.row.original.id, !info.row.original.enabled);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconPower size={16} />
|
<IconPower size={16} />
|
||||||
{intl.formatMessage({ id: "action.disable" })}
|
{intl.formatMessage({
|
||||||
|
id: info.row.original.enabled ? "action.disable" : "action.enable",
|
||||||
|
})}
|
||||||
</a>
|
</a>
|
||||||
<div className="dropdown-divider" />
|
<div className="dropdown-divider" />
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDelete?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconTrash size={16} />
|
<IconTrash size={16} />
|
||||||
{intl.formatMessage({ id: "action.delete" })}
|
{intl.formatMessage({ id: "action.delete" })}
|
||||||
</a>
|
</a>
|
||||||
@@ -107,7 +135,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
[columnHelper],
|
[columnHelper, onEdit, onDisableToggle, onDelete],
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableInstance = useReactTable<ProxyHost>({
|
const tableInstance = useReactTable<ProxyHost>({
|
||||||
@@ -121,5 +149,10 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
enableSortingRemoval: false,
|
enableSortingRemoval: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return <TableLayout tableInstance={tableInstance} emptyState={<Empty tableInstance={tableInstance} />} />;
|
return (
|
||||||
|
<TableLayout
|
||||||
|
tableInstance={tableInstance}
|
||||||
|
emptyState={<Empty tableInstance={tableInstance} onNew={onNew} isFiltered={isFiltered} />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,20 @@
|
|||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useState } from "react";
|
||||||
import Alert from "react-bootstrap/Alert";
|
import Alert from "react-bootstrap/Alert";
|
||||||
|
import { deleteProxyHost, toggleProxyHost } from "src/api/backend";
|
||||||
import { Button, LoadingPage } from "src/components";
|
import { Button, LoadingPage } from "src/components";
|
||||||
import { useProxyHosts } from "src/hooks";
|
import { useProxyHosts } from "src/hooks";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
|
import { DeleteConfirmModal, ProxyHostModal } from "src/modals";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
import Table from "./Table";
|
import Table from "./Table";
|
||||||
|
|
||||||
export default function TableWrapper() {
|
export default function TableWrapper() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const [deleteId, setDeleteId] = useState(0);
|
||||||
|
const [editId, setEditId] = useState(0 as number | "new");
|
||||||
const { isFetching, isLoading, isError, error, data } = useProxyHosts(["owner", "access_list", "certificate"]);
|
const { isFetching, isLoading, isError, error, data } = useProxyHosts(["owner", "access_list", "certificate"]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -16,6 +25,31 @@ export default function TableWrapper() {
|
|||||||
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
await deleteProxyHost(deleteId);
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.host-deleted" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDisableToggle = async (id: number, enabled: boolean) => {
|
||||||
|
await toggleProxyHost(id, enabled);
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["proxy-hosts"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["proxy-host", id] });
|
||||||
|
showSuccess(intl.formatMessage({ id: enabled ? "notification.host-enabled" : "notification.host-disabled" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
let filtered = null;
|
||||||
|
if (search && data) {
|
||||||
|
filtered = data?.filter((_item) => {
|
||||||
|
return true;
|
||||||
|
// item.domainNames.some((domain: string) => domain.toLowerCase().includes(search)) ||
|
||||||
|
// item.forwardDomainName.toLowerCase().includes(search)
|
||||||
|
// );
|
||||||
|
});
|
||||||
|
} else if (search !== "") {
|
||||||
|
// this can happen if someone deletes the last item while searching
|
||||||
|
setSearch("");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card mt-4">
|
<div className="card mt-4">
|
||||||
<div className="card-status-top bg-lime" />
|
<div className="card-status-top bg-lime" />
|
||||||
@@ -25,6 +59,7 @@ export default function TableWrapper() {
|
|||||||
<div className="col">
|
<div className="col">
|
||||||
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "proxy-hosts.title" })}</h2>
|
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "proxy-hosts.title" })}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.length ? (
|
||||||
<div className="col-md-auto col-sm-12">
|
<div className="col-md-auto col-sm-12">
|
||||||
<div className="ms-auto d-flex flex-wrap btn-list">
|
<div className="ms-auto d-flex flex-wrap btn-list">
|
||||||
<div className="input-group input-group-flat w-auto">
|
<div className="input-group input-group-flat w-auto">
|
||||||
@@ -43,9 +78,29 @@ export default function TableWrapper() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table data={data ?? []} isFetching={isFetching} />
|
<Table
|
||||||
|
data={filtered ?? data ?? []}
|
||||||
|
isFiltered={!!search}
|
||||||
|
isFetching={isFetching}
|
||||||
|
onEdit={(id: number) => setEditId(id)}
|
||||||
|
onDelete={(id: number) => setDeleteId(id)}
|
||||||
|
onDisableToggle={handleDisableToggle}
|
||||||
|
onNew={() => setEditId("new")}
|
||||||
|
/>
|
||||||
|
{editId ? <ProxyHostModal id={editId} onClose={() => setEditId(0)} /> : null}
|
||||||
|
{deleteId ? (
|
||||||
|
<DeleteConfirmModal
|
||||||
|
title={intl.formatMessage({ id: "proxy-host.delete.title" })}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
onClose={() => setDeleteId(0)}
|
||||||
|
invalidations={[["proxy-hosts"], ["proxy-host", deleteId]]}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "proxy-host.delete.content" })}
|
||||||
|
</DeleteConfirmModal>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -4,15 +4,25 @@ import { intl } from "src/locale";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
tableInstance: ReactTable<any>;
|
tableInstance: ReactTable<any>;
|
||||||
|
onNew?: () => void;
|
||||||
|
isFiltered?: boolean;
|
||||||
}
|
}
|
||||||
export default function Empty({ tableInstance }: Props) {
|
export default function Empty({ tableInstance, onNew, isFiltered }: Props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||||
<div className="text-center my-4">
|
<div className="text-center my-4">
|
||||||
|
{isFiltered ? (
|
||||||
|
<h2>{intl.formatMessage({ id: "empty-search" })}</h2>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<h2>{intl.formatMessage({ id: "redirection-hosts.empty" })}</h2>
|
<h2>{intl.formatMessage({ id: "redirection-hosts.empty" })}</h2>
|
||||||
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
||||||
<Button className="btn-yellow my-3">{intl.formatMessage({ id: "redirection-hosts.add" })}</Button>
|
<Button className="btn-yellow my-3" onClick={onNew}>
|
||||||
|
{intl.formatMessage({ id: "redirection-hosts.add" })}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -9,9 +9,14 @@ import Empty from "./Empty";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: RedirectionHost[];
|
data: RedirectionHost[];
|
||||||
|
isFiltered?: boolean;
|
||||||
isFetching?: boolean;
|
isFetching?: boolean;
|
||||||
|
onEdit?: (id: number) => void;
|
||||||
|
onDelete?: (id: number) => void;
|
||||||
|
onDisableToggle?: (id: number, enabled: boolean) => void;
|
||||||
|
onNew?: () => void;
|
||||||
}
|
}
|
||||||
export default function Table({ data, isFetching }: Props) {
|
export default function Table({ data, isFetching, onEdit, onDelete, onDisableToggle, onNew, isFiltered }: Props) {
|
||||||
const columnHelper = createColumnHelper<RedirectionHost>();
|
const columnHelper = createColumnHelper<RedirectionHost>();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@@ -69,7 +74,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
id: "id", // todo: not needed for a display?
|
id: "id",
|
||||||
cell: (info: any) => {
|
cell: (info: any) => {
|
||||||
return (
|
return (
|
||||||
<span className="dropdown">
|
<span className="dropdown">
|
||||||
@@ -90,16 +95,39 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
{ id: info.row.original.id },
|
{ id: info.row.original.id },
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onEdit?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconEdit size={16} />
|
<IconEdit size={16} />
|
||||||
{intl.formatMessage({ id: "action.edit" })}
|
{intl.formatMessage({ id: "action.edit" })}
|
||||||
</a>
|
</a>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDisableToggle?.(info.row.original.id, !info.row.original.enabled);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconPower size={16} />
|
<IconPower size={16} />
|
||||||
{intl.formatMessage({ id: "action.disable" })}
|
{intl.formatMessage({
|
||||||
|
id: info.row.original.enabled ? "action.disable" : "action.enable",
|
||||||
|
})}
|
||||||
</a>
|
</a>
|
||||||
<div className="dropdown-divider" />
|
<div className="dropdown-divider" />
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDelete?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconTrash size={16} />
|
<IconTrash size={16} />
|
||||||
{intl.formatMessage({ id: "action.delete" })}
|
{intl.formatMessage({ id: "action.delete" })}
|
||||||
</a>
|
</a>
|
||||||
@@ -112,7 +140,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
[columnHelper],
|
[columnHelper, onEdit, onDisableToggle, onDelete],
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableInstance = useReactTable<RedirectionHost>({
|
const tableInstance = useReactTable<RedirectionHost>({
|
||||||
@@ -126,5 +154,10 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
enableSortingRemoval: false,
|
enableSortingRemoval: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return <TableLayout tableInstance={tableInstance} emptyState={<Empty tableInstance={tableInstance} />} />;
|
return (
|
||||||
|
<TableLayout
|
||||||
|
tableInstance={tableInstance}
|
||||||
|
emptyState={<Empty tableInstance={tableInstance} onNew={onNew} isFiltered={isFiltered} />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,20 @@
|
|||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useState } from "react";
|
||||||
import Alert from "react-bootstrap/Alert";
|
import Alert from "react-bootstrap/Alert";
|
||||||
|
import { deleteRedirectionHost, toggleRedirectionHost } from "src/api/backend";
|
||||||
import { Button, LoadingPage } from "src/components";
|
import { Button, LoadingPage } from "src/components";
|
||||||
import { useRedirectionHosts } from "src/hooks";
|
import { useRedirectionHosts } from "src/hooks";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
|
import { DeleteConfirmModal, RedirectionHostModal } from "src/modals";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
import Table from "./Table";
|
import Table from "./Table";
|
||||||
|
|
||||||
export default function TableWrapper() {
|
export default function TableWrapper() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const [deleteId, setDeleteId] = useState(0);
|
||||||
|
const [editId, setEditId] = useState(0 as number | "new");
|
||||||
const { isFetching, isLoading, isError, error, data } = useRedirectionHosts(["owner", "certificate"]);
|
const { isFetching, isLoading, isError, error, data } = useRedirectionHosts(["owner", "certificate"]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -16,6 +25,31 @@ export default function TableWrapper() {
|
|||||||
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
await deleteRedirectionHost(deleteId);
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.host-deleted" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDisableToggle = async (id: number, enabled: boolean) => {
|
||||||
|
await toggleRedirectionHost(id, enabled);
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["redirection-hosts"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["redirection-host", id] });
|
||||||
|
showSuccess(intl.formatMessage({ id: enabled ? "notification.host-enabled" : "notification.host-disabled" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
let filtered = null;
|
||||||
|
if (search && data) {
|
||||||
|
filtered = data?.filter((item) => {
|
||||||
|
return (
|
||||||
|
item.domainNames.some((domain: string) => domain.toLowerCase().includes(search)) ||
|
||||||
|
item.forwardDomainName.toLowerCase().includes(search)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else if (search !== "") {
|
||||||
|
// this can happen if someone deletes the last item while searching
|
||||||
|
setSearch("");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card mt-4">
|
<div className="card mt-4">
|
||||||
<div className="card-status-top bg-yellow" />
|
<div className="card-status-top bg-yellow" />
|
||||||
@@ -25,6 +59,7 @@ export default function TableWrapper() {
|
|||||||
<div className="col">
|
<div className="col">
|
||||||
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "redirection-hosts.title" })}</h2>
|
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "redirection-hosts.title" })}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.length ? (
|
||||||
<div className="col-md-auto col-sm-12">
|
<div className="col-md-auto col-sm-12">
|
||||||
<div className="ms-auto d-flex flex-wrap btn-list">
|
<div className="ms-auto d-flex flex-wrap btn-list">
|
||||||
<div className="input-group input-group-flat w-auto">
|
<div className="input-group input-group-flat w-auto">
|
||||||
@@ -36,16 +71,38 @@ export default function TableWrapper() {
|
|||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
|
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button size="sm" className="btn-yellow">
|
|
||||||
|
<Button size="sm" className="btn-yellow" onClick={() => setEditId("new")}>
|
||||||
{intl.formatMessage({ id: "redirection-hosts.add" })}
|
{intl.formatMessage({ id: "redirection-hosts.add" })}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table data={data ?? []} isFetching={isFetching} />
|
<Table
|
||||||
|
data={filtered ?? data ?? []}
|
||||||
|
isFiltered={!!search}
|
||||||
|
isFetching={isFetching}
|
||||||
|
onEdit={(id: number) => setEditId(id)}
|
||||||
|
onDelete={(id: number) => setDeleteId(id)}
|
||||||
|
onDisableToggle={handleDisableToggle}
|
||||||
|
onNew={() => setEditId("new")}
|
||||||
|
/>
|
||||||
|
{editId ? <RedirectionHostModal id={editId} onClose={() => setEditId(0)} /> : null}
|
||||||
|
{deleteId ? (
|
||||||
|
<DeleteConfirmModal
|
||||||
|
title={intl.formatMessage({ id: "redirection-host.delete.title" })}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
onClose={() => setDeleteId(0)}
|
||||||
|
invalidations={[["redirection-hosts"], ["redirection-host", deleteId]]}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "redirection-host.delete.content" })}
|
||||||
|
</DeleteConfirmModal>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -4,15 +4,25 @@ import { intl } from "src/locale";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
tableInstance: ReactTable<any>;
|
tableInstance: ReactTable<any>;
|
||||||
|
onNew?: () => void;
|
||||||
|
isFiltered?: boolean;
|
||||||
}
|
}
|
||||||
export default function Empty({ tableInstance }: Props) {
|
export default function Empty({ tableInstance, onNew, isFiltered }: Props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||||
<div className="text-center my-4">
|
<div className="text-center my-4">
|
||||||
|
{isFiltered ? (
|
||||||
|
<h2>{intl.formatMessage({ id: "empty-search" })}</h2>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<h2>{intl.formatMessage({ id: "streams.empty" })}</h2>
|
<h2>{intl.formatMessage({ id: "streams.empty" })}</h2>
|
||||||
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
||||||
<Button className="btn-blue my-3">{intl.formatMessage({ id: "streams.add" })}</Button>
|
<Button className="btn-blue my-3" onClick={onNew}>
|
||||||
|
{intl.formatMessage({ id: "streams.add" })}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -2,16 +2,21 @@ import { IconDotsVertical, IconEdit, IconPower, IconTrash } from "@tabler/icons-
|
|||||||
import { createColumnHelper, getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
import { createColumnHelper, getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import type { Stream } from "src/api/backend";
|
import type { Stream } from "src/api/backend";
|
||||||
import { CertificateFormatter, DomainsFormatter, GravatarFormatter, StatusFormatter } from "src/components";
|
import { CertificateFormatter, GravatarFormatter, StatusFormatter, ValueWithDateFormatter } from "src/components";
|
||||||
import { TableLayout } from "src/components/Table/TableLayout";
|
import { TableLayout } from "src/components/Table/TableLayout";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
import Empty from "./Empty";
|
import Empty from "./Empty";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: Stream[];
|
data: Stream[];
|
||||||
|
isFiltered?: boolean;
|
||||||
isFetching?: boolean;
|
isFetching?: boolean;
|
||||||
|
onEdit?: (id: number) => void;
|
||||||
|
onDelete?: (id: number) => void;
|
||||||
|
onDisableToggle?: (id: number, enabled: boolean) => void;
|
||||||
|
onNew?: () => void;
|
||||||
}
|
}
|
||||||
export default function Table({ data, isFetching }: Props) {
|
export default function Table({ data, isFetching, isFiltered, onEdit, onDelete, onDisableToggle, onNew }: Props) {
|
||||||
const columnHelper = createColumnHelper<Stream>();
|
const columnHelper = createColumnHelper<Stream>();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@@ -30,8 +35,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
header: intl.formatMessage({ id: "column.incoming-port" }),
|
header: intl.formatMessage({ id: "column.incoming-port" }),
|
||||||
cell: (info: any) => {
|
cell: (info: any) => {
|
||||||
const value = info.getValue();
|
const value = info.getValue();
|
||||||
// Bit of a hack to reuse the DomainsFormatter component
|
return <ValueWithDateFormatter value={value.incomingPort} createdOn={value.createdOn} />;
|
||||||
return <DomainsFormatter domains={[value.incomingPort]} createdOn={value.createdOn} />;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor((row: any) => row, {
|
columnHelper.accessor((row: any) => row, {
|
||||||
@@ -99,16 +103,37 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
{ id: info.row.original.id },
|
{ id: info.row.original.id },
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onEdit?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconEdit size={16} />
|
<IconEdit size={16} />
|
||||||
{intl.formatMessage({ id: "action.edit" })}
|
{intl.formatMessage({ id: "action.edit" })}
|
||||||
</a>
|
</a>
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDisableToggle?.(info.row.original.id, !info.row.original.enabled);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconPower size={16} />
|
<IconPower size={16} />
|
||||||
{intl.formatMessage({ id: "action.disable" })}
|
{intl.formatMessage({ id: "action.disable" })}
|
||||||
</a>
|
</a>
|
||||||
<div className="dropdown-divider" />
|
<div className="dropdown-divider" />
|
||||||
<a className="dropdown-item" href="#">
|
<a
|
||||||
|
className="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onDelete?.(info.row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IconTrash size={16} />
|
<IconTrash size={16} />
|
||||||
{intl.formatMessage({ id: "action.delete" })}
|
{intl.formatMessage({ id: "action.delete" })}
|
||||||
</a>
|
</a>
|
||||||
@@ -121,7 +146,7 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
[columnHelper],
|
[columnHelper, onEdit, onDisableToggle, onDelete],
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableInstance = useReactTable<Stream>({
|
const tableInstance = useReactTable<Stream>({
|
||||||
@@ -135,5 +160,10 @@ export default function Table({ data, isFetching }: Props) {
|
|||||||
enableSortingRemoval: false,
|
enableSortingRemoval: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return <TableLayout tableInstance={tableInstance} emptyState={<Empty tableInstance={tableInstance} />} />;
|
return (
|
||||||
|
<TableLayout
|
||||||
|
tableInstance={tableInstance}
|
||||||
|
emptyState={<Empty tableInstance={tableInstance} onNew={onNew} isFiltered={isFiltered} />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,20 @@
|
|||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useState } from "react";
|
||||||
import Alert from "react-bootstrap/Alert";
|
import Alert from "react-bootstrap/Alert";
|
||||||
|
import { deleteStream, toggleStream } from "src/api/backend";
|
||||||
import { Button, LoadingPage } from "src/components";
|
import { Button, LoadingPage } from "src/components";
|
||||||
import { useStreams } from "src/hooks";
|
import { useStreams } from "src/hooks";
|
||||||
import { intl } from "src/locale";
|
import { intl } from "src/locale";
|
||||||
|
import { DeleteConfirmModal, StreamModal } from "src/modals";
|
||||||
|
import { showSuccess } from "src/notifications";
|
||||||
import Table from "./Table";
|
import Table from "./Table";
|
||||||
|
|
||||||
export default function TableWrapper() {
|
export default function TableWrapper() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const [editId, setEditId] = useState(0 as number | "new");
|
||||||
|
const [deleteId, setDeleteId] = useState(0);
|
||||||
const { isFetching, isLoading, isError, error, data } = useStreams(["owner", "certificate"]);
|
const { isFetching, isLoading, isError, error, data } = useStreams(["owner", "certificate"]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -16,6 +25,34 @@ export default function TableWrapper() {
|
|||||||
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
return <Alert variant="danger">{error?.message || "Unknown error"}</Alert>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
await deleteStream(deleteId);
|
||||||
|
showSuccess(intl.formatMessage({ id: "notification.stream-deleted" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDisableToggle = async (id: number, enabled: boolean) => {
|
||||||
|
await toggleStream(id, enabled);
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["streams"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["stream", id] });
|
||||||
|
showSuccess(
|
||||||
|
intl.formatMessage({ id: enabled ? "notification.stream-enabled" : "notification.stream-disabled" }),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let filtered = null;
|
||||||
|
if (search && data) {
|
||||||
|
filtered = data?.filter((item) => {
|
||||||
|
return (
|
||||||
|
`${item.incomingPort}`.includes(search) ||
|
||||||
|
`${item.forwardingPort}`.includes(search) ||
|
||||||
|
item.forwardingHost.includes(search)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else if (search !== "") {
|
||||||
|
// this can happen if someone deletes the last item while searching
|
||||||
|
setSearch("");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card mt-4">
|
<div className="card mt-4">
|
||||||
<div className="card-status-top bg-blue" />
|
<div className="card-status-top bg-blue" />
|
||||||
@@ -25,6 +62,7 @@ export default function TableWrapper() {
|
|||||||
<div className="col">
|
<div className="col">
|
||||||
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "streams.title" })}</h2>
|
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "streams.title" })}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.length ? (
|
||||||
<div className="col-md-auto col-sm-12">
|
<div className="col-md-auto col-sm-12">
|
||||||
<div className="ms-auto d-flex flex-wrap btn-list">
|
<div className="ms-auto d-flex flex-wrap btn-list">
|
||||||
<div className="input-group input-group-flat w-auto">
|
<div className="input-group input-group-flat w-auto">
|
||||||
@@ -36,16 +74,37 @@ export default function TableWrapper() {
|
|||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
|
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button size="sm" className="btn-blue">
|
<Button size="sm" className="btn-blue" onClick={() => setEditId("new")}>
|
||||||
{intl.formatMessage({ id: "streams.add" })}
|
{intl.formatMessage({ id: "streams.add" })}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table data={data ?? []} isFetching={isFetching} />
|
<Table
|
||||||
|
data={filtered ?? data ?? []}
|
||||||
|
isFetching={isFetching}
|
||||||
|
isFiltered={!!filtered}
|
||||||
|
onEdit={(id: number) => setEditId(id)}
|
||||||
|
onDelete={(id: number) => setDeleteId(id)}
|
||||||
|
onDisableToggle={handleDisableToggle}
|
||||||
|
onNew={() => setEditId("new")}
|
||||||
|
/>
|
||||||
|
{editId ? <StreamModal id={editId} onClose={() => setEditId(0)} /> : null}
|
||||||
|
{deleteId ? (
|
||||||
|
<DeleteConfirmModal
|
||||||
|
title={intl.formatMessage({ id: "stream.delete.title" })}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
onClose={() => setDeleteId(0)}
|
||||||
|
invalidations={[["streams"], ["stream", deleteId]]}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: "stream.delete.content" })}
|
||||||
|
</DeleteConfirmModal>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -8,9 +8,6 @@ interface Props {
|
|||||||
isFiltered?: boolean;
|
isFiltered?: boolean;
|
||||||
}
|
}
|
||||||
export default function Empty({ tableInstance, onNewUser, isFiltered }: Props) {
|
export default function Empty({ tableInstance, onNewUser, isFiltered }: Props) {
|
||||||
if (isFiltered) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||||
|
@@ -63,9 +63,9 @@ export default function TableWrapper() {
|
|||||||
<div className="col">
|
<div className="col">
|
||||||
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "users.title" })}</h2>
|
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "users.title" })}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.length ? (
|
||||||
<div className="col-md-auto col-sm-12">
|
<div className="col-md-auto col-sm-12">
|
||||||
<div className="ms-auto d-flex flex-wrap btn-list">
|
<div className="ms-auto d-flex flex-wrap btn-list">
|
||||||
{data?.length ? (
|
|
||||||
<div className="input-group input-group-flat w-auto">
|
<div className="input-group input-group-flat w-auto">
|
||||||
<span className="input-group-text input-group-text-sm">
|
<span className="input-group-text input-group-text-sm">
|
||||||
<IconSearch size={16} />
|
<IconSearch size={16} />
|
||||||
@@ -78,12 +78,13 @@ export default function TableWrapper() {
|
|||||||
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
onChange={(e: any) => setSearch(e.target.value.toLowerCase().trim())}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
<Button size="sm" className="btn-orange" onClick={() => setEditUserId("new")}>
|
<Button size="sm" className="btn-orange" onClick={() => setEditUserId("new")}>
|
||||||
{intl.formatMessage({ id: "users.add" })}
|
{intl.formatMessage({ id: "users.add" })}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
|
@@ -19,6 +19,12 @@ export default defineConfig({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
|
execFile("yarn", ["locale-sort"], (error, stdout, _stderr) => {
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
console.log(stdout);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -5,7 +5,6 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
|
|
||||||
echo -e "${BLUE}❯ ${CYAN}Building docker multiarch: ${YELLOW}${*}${RESET}"
|
echo -e "${BLUE}❯ ${CYAN}Building docker multiarch: ${YELLOW}${*}${RESET}"
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
cd "${DIR}/.." || exit 1
|
cd "${DIR}/.." || exit 1
|
||||||
|
|
||||||
# determine commit if not already set
|
# determine commit if not already set
|
||||||
|
Reference in New Issue
Block a user