diff --git a/frontend/src/api/backend/createAccessList.ts b/frontend/src/api/backend/createAccessList.ts index d90f7c97..8135a976 100644 --- a/frontend/src/api/backend/createAccessList.ts +++ b/frontend/src/api/backend/createAccessList.ts @@ -1,13 +1,10 @@ import * as api from "./base"; import type { AccessList } from "./models"; -export async function createAccessList(item: AccessList, abortController?: AbortController): Promise { - return await api.post( - { - url: "/nginx/access-lists", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createAccessList(item: AccessList): Promise { + return await api.post({ + url: "/nginx/access-lists", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createCertificate.ts b/frontend/src/api/backend/createCertificate.ts index ba9655a3..57f89478 100644 --- a/frontend/src/api/backend/createCertificate.ts +++ b/frontend/src/api/backend/createCertificate.ts @@ -1,13 +1,10 @@ import * as api from "./base"; import type { Certificate } from "./models"; -export async function createCertificate(item: Certificate, abortController?: AbortController): Promise { - return await api.post( - { - url: "/nginx/certificates", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createCertificate(item: Certificate): Promise { + return await api.post({ + url: "/nginx/certificates", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createDeadHost.ts b/frontend/src/api/backend/createDeadHost.ts index ab090446..521075a3 100644 --- a/frontend/src/api/backend/createDeadHost.ts +++ b/frontend/src/api/backend/createDeadHost.ts @@ -1,13 +1,10 @@ import * as api from "./base"; import type { DeadHost } from "./models"; -export async function createDeadHost(item: DeadHost, abortController?: AbortController): Promise { - return await api.post( - { - url: "/nginx/dead-hosts", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createDeadHost(item: DeadHost): Promise { + return await api.post({ + url: "/nginx/dead-hosts", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createProxyHost.ts b/frontend/src/api/backend/createProxyHost.ts index 6b548b87..830fb22e 100644 --- a/frontend/src/api/backend/createProxyHost.ts +++ b/frontend/src/api/backend/createProxyHost.ts @@ -1,13 +1,10 @@ import * as api from "./base"; import type { ProxyHost } from "./models"; -export async function createProxyHost(item: ProxyHost, abortController?: AbortController): Promise { - return await api.post( - { - url: "/nginx/proxy-hosts", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createProxyHost(item: ProxyHost): Promise { + return await api.post({ + url: "/nginx/proxy-hosts", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createRedirectionHost.ts b/frontend/src/api/backend/createRedirectionHost.ts index ea73a226..83ae6914 100644 --- a/frontend/src/api/backend/createRedirectionHost.ts +++ b/frontend/src/api/backend/createRedirectionHost.ts @@ -1,16 +1,10 @@ import * as api from "./base"; import type { RedirectionHost } from "./models"; -export async function createRedirectionHost( - item: RedirectionHost, - abortController?: AbortController, -): Promise { - return await api.post( - { - url: "/nginx/redirection-hosts", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createRedirectionHost(item: RedirectionHost): Promise { + return await api.post({ + url: "/nginx/redirection-hosts", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createStream.ts b/frontend/src/api/backend/createStream.ts index c8a6cf1f..e5f84605 100644 --- a/frontend/src/api/backend/createStream.ts +++ b/frontend/src/api/backend/createStream.ts @@ -1,13 +1,10 @@ import * as api from "./base"; import type { Stream } from "./models"; -export async function createStream(item: Stream, abortController?: AbortController): Promise { - return await api.post( - { - url: "/nginx/streams", - // todo: only use whitelist of fields for this data - data: item, - }, - abortController, - ); +export async function createStream(item: Stream): Promise { + return await api.post({ + url: "/nginx/streams", + // todo: only use whitelist of fields for this data + data: item, + }); } diff --git a/frontend/src/api/backend/createUser.ts b/frontend/src/api/backend/createUser.ts index 1aadda34..dcaa5feb 100644 --- a/frontend/src/api/backend/createUser.ts +++ b/frontend/src/api/backend/createUser.ts @@ -15,14 +15,11 @@ export interface NewUser { roles?: string[]; } -export async function createUser(item: NewUser, noAuth?: boolean, abortController?: AbortController): Promise { - return await api.post( - { - url: "/users", - // todo: only use whitelist of fields for this data - data: item, - noAuth, - }, - abortController, - ); +export async function createUser(item: NewUser, noAuth?: boolean): Promise { + return await api.post({ + url: "/users", + // todo: only use whitelist of fields for this data + data: item, + noAuth, + }); } diff --git a/frontend/src/api/backend/deleteAccessList.ts b/frontend/src/api/backend/deleteAccessList.ts index 96b51dbf..838c940b 100644 --- a/frontend/src/api/backend/deleteAccessList.ts +++ b/frontend/src/api/backend/deleteAccessList.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteAccessList(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/access-lists/${id}`, - }, - abortController, - ); +export async function deleteAccessList(id: number): Promise { + return await api.del({ + url: `/nginx/access-lists/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteCertificate.ts b/frontend/src/api/backend/deleteCertificate.ts index 97debf87..2257316c 100644 --- a/frontend/src/api/backend/deleteCertificate.ts +++ b/frontend/src/api/backend/deleteCertificate.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteCertificate(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/certificates/${id}`, - }, - abortController, - ); +export async function deleteCertificate(id: number): Promise { + return await api.del({ + url: `/nginx/certificates/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteDeadHost.ts b/frontend/src/api/backend/deleteDeadHost.ts index 50ba6fa0..8e72ca84 100644 --- a/frontend/src/api/backend/deleteDeadHost.ts +++ b/frontend/src/api/backend/deleteDeadHost.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteDeadHost(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/dead-hosts/${id}`, - }, - abortController, - ); +export async function deleteDeadHost(id: number): Promise { + return await api.del({ + url: `/nginx/dead-hosts/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteProxyHost.ts b/frontend/src/api/backend/deleteProxyHost.ts index f5ddc4d4..7b7f2d82 100644 --- a/frontend/src/api/backend/deleteProxyHost.ts +++ b/frontend/src/api/backend/deleteProxyHost.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteProxyHost(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/proxy-hosts/${id}`, - }, - abortController, - ); +export async function deleteProxyHost(id: number): Promise { + return await api.del({ + url: `/nginx/proxy-hosts/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteRedirectionHost.ts b/frontend/src/api/backend/deleteRedirectionHost.ts index 0fe5cc2d..7c594b68 100644 --- a/frontend/src/api/backend/deleteRedirectionHost.ts +++ b/frontend/src/api/backend/deleteRedirectionHost.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteRedirectionHost(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/redirection-hosts/${id}`, - }, - abortController, - ); +export async function deleteRedirectionHost(id: number): Promise { + return await api.del({ + url: `/nginx/redirection-hosts/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteStream.ts b/frontend/src/api/backend/deleteStream.ts index 17871d13..db9e11f1 100644 --- a/frontend/src/api/backend/deleteStream.ts +++ b/frontend/src/api/backend/deleteStream.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteStream(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/nginx/streams/${id}`, - }, - abortController, - ); +export async function deleteStream(id: number): Promise { + return await api.del({ + url: `/nginx/streams/${id}`, + }); } diff --git a/frontend/src/api/backend/deleteUser.ts b/frontend/src/api/backend/deleteUser.ts index 30faa701..2a04a6e9 100644 --- a/frontend/src/api/backend/deleteUser.ts +++ b/frontend/src/api/backend/deleteUser.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function deleteUser(id: number, abortController?: AbortController): Promise { - return await api.del( - { - url: `/users/${id}`, - }, - abortController, - ); +export async function deleteUser(id: number): Promise { + return await api.del({ + url: `/users/${id}`, + }); } diff --git a/frontend/src/api/backend/downloadCertificate.ts b/frontend/src/api/backend/downloadCertificate.ts index aa980071..dc7aa312 100644 --- a/frontend/src/api/backend/downloadCertificate.ts +++ b/frontend/src/api/backend/downloadCertificate.ts @@ -1,11 +1,8 @@ import * as api from "./base"; import type { Binary } from "./responseTypes"; -export async function downloadCertificate(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/certificates/${id}/download`, - }, - abortController, - ); +export async function downloadCertificate(id: number): Promise { + return await api.get({ + url: `/nginx/certificates/${id}/download`, + }); } diff --git a/frontend/src/api/backend/expansions.ts b/frontend/src/api/backend/expansions.ts new file mode 100644 index 00000000..2f31e4d0 --- /dev/null +++ b/frontend/src/api/backend/expansions.ts @@ -0,0 +1,6 @@ +export type AccessListExpansion = "owner" | "items" | "clients"; +export type AuditLogExpansion = "user"; +export type CertificateExpansion = "owner" | "proxy_hosts" | "redirection_hosts" | "dead_hosts"; +export type HostExpansion = "owner" | "certificate"; +export type ProxyHostExpansion = "owner" | "access_list" | "certificate"; +export type UserExpansion = "permissions"; diff --git a/frontend/src/api/backend/getAccessList.ts b/frontend/src/api/backend/getAccessList.ts index 75fea51e..a1afd350 100644 --- a/frontend/src/api/backend/getAccessList.ts +++ b/frontend/src/api/backend/getAccessList.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { AccessListExpansion } from "./expansions"; import type { AccessList } from "./models"; -export async function getAccessList(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/access-lists/${id}`, +export async function getAccessList(id: number, expand?: AccessListExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/access-lists/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getAccessLists.ts b/frontend/src/api/backend/getAccessLists.ts index 96eaa91a..515f1e21 100644 --- a/frontend/src/api/backend/getAccessLists.ts +++ b/frontend/src/api/backend/getAccessLists.ts @@ -1,8 +1,7 @@ import * as api from "./base"; +import type { AccessListExpansion } from "./expansions"; import type { AccessList } from "./models"; -export type AccessListExpansion = "owner" | "items" | "clients"; - export async function getAccessLists(expand?: AccessListExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/access-lists", diff --git a/frontend/src/api/backend/getAuditLog.ts b/frontend/src/api/backend/getAuditLog.ts index cea0872d..d2d01f70 100644 --- a/frontend/src/api/backend/getAuditLog.ts +++ b/frontend/src/api/backend/getAuditLog.ts @@ -1,5 +1,5 @@ import * as api from "./base"; -import type { AuditLogExpansion } from "./getAuditLogs"; +import type { AuditLogExpansion } from "./expansions"; import type { AuditLog } from "./models"; export async function getAuditLog(id: number, expand?: AuditLogExpansion[], params = {}): Promise { diff --git a/frontend/src/api/backend/getAuditLogs.ts b/frontend/src/api/backend/getAuditLogs.ts index e1be7c28..bbdb2f16 100644 --- a/frontend/src/api/backend/getAuditLogs.ts +++ b/frontend/src/api/backend/getAuditLogs.ts @@ -1,8 +1,7 @@ import * as api from "./base"; +import type { AuditLogExpansion } from "./expansions"; import type { AuditLog } from "./models"; -export type AuditLogExpansion = "user"; - export async function getAuditLogs(expand?: AuditLogExpansion[], params = {}): Promise { return await api.get({ url: "/audit-log", diff --git a/frontend/src/api/backend/getCertificate.ts b/frontend/src/api/backend/getCertificate.ts index fc6a4c6d..13de898d 100644 --- a/frontend/src/api/backend/getCertificate.ts +++ b/frontend/src/api/backend/getCertificate.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { CertificateExpansion } from "./expansions"; import type { Certificate } from "./models"; -export async function getCertificate(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/certificates/${id}`, +export async function getCertificate(id: number, expand?: CertificateExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/certificates/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getCertificates.ts b/frontend/src/api/backend/getCertificates.ts index 9389fe44..d6d215b5 100644 --- a/frontend/src/api/backend/getCertificates.ts +++ b/frontend/src/api/backend/getCertificates.ts @@ -1,8 +1,7 @@ import * as api from "./base"; +import type { CertificateExpansion } from "./expansions"; import type { Certificate } from "./models"; -export type CertificateExpansion = "owner" | "proxy_hosts" | "redirection_hosts" | "dead_hosts"; - export async function getCertificates(expand?: CertificateExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/certificates", diff --git a/frontend/src/api/backend/getDeadHost.ts b/frontend/src/api/backend/getDeadHost.ts index 7759b094..d6c062b9 100644 --- a/frontend/src/api/backend/getDeadHost.ts +++ b/frontend/src/api/backend/getDeadHost.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { DeadHost } from "./models"; -export async function getDeadHost(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/dead-hosts/${id}`, +export async function getDeadHost(id: number, expand?: HostExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/dead-hosts/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getDeadHosts.ts b/frontend/src/api/backend/getDeadHosts.ts index 398221b6..1ca410e4 100644 --- a/frontend/src/api/backend/getDeadHosts.ts +++ b/frontend/src/api/backend/getDeadHosts.ts @@ -1,9 +1,8 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { DeadHost } from "./models"; -export type DeadHostExpansion = "owner" | "certificate"; - -export async function getDeadHosts(expand?: DeadHostExpansion[], params = {}): Promise { +export async function getDeadHosts(expand?: HostExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/dead-hosts", params: { diff --git a/frontend/src/api/backend/getHealth.ts b/frontend/src/api/backend/getHealth.ts index b423f5de..055681ce 100644 --- a/frontend/src/api/backend/getHealth.ts +++ b/frontend/src/api/backend/getHealth.ts @@ -1,11 +1,8 @@ import * as api from "./base"; import type { HealthResponse } from "./responseTypes"; -export async function getHealth(abortController?: AbortController): Promise { - return await api.get( - { - url: "/", - }, - abortController, - ); +export async function getHealth(): Promise { + return await api.get({ + url: "/", + }); } diff --git a/frontend/src/api/backend/getHostsReport.ts b/frontend/src/api/backend/getHostsReport.ts index b396e291..938d3a74 100644 --- a/frontend/src/api/backend/getHostsReport.ts +++ b/frontend/src/api/backend/getHostsReport.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function getHostsReport(abortController?: AbortController): Promise> { - return await api.get( - { - url: "/reports/hosts", - }, - abortController, - ); +export async function getHostsReport(): Promise> { + return await api.get({ + url: "/reports/hosts", + }); } diff --git a/frontend/src/api/backend/getProxyHost.ts b/frontend/src/api/backend/getProxyHost.ts index f51795ca..911b89c3 100644 --- a/frontend/src/api/backend/getProxyHost.ts +++ b/frontend/src/api/backend/getProxyHost.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { ProxyHostExpansion } from "./expansions"; import type { ProxyHost } from "./models"; -export async function getProxyHost(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/proxy-hosts/${id}`, +export async function getProxyHost(id: number, expand?: ProxyHostExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/proxy-hosts/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getProxyHosts.ts b/frontend/src/api/backend/getProxyHosts.ts index 5db1779c..ba9c864a 100644 --- a/frontend/src/api/backend/getProxyHosts.ts +++ b/frontend/src/api/backend/getProxyHosts.ts @@ -1,8 +1,7 @@ import * as api from "./base"; +import type { ProxyHostExpansion } from "./expansions"; import type { ProxyHost } from "./models"; -export type ProxyHostExpansion = "owner" | "access_list" | "certificate"; - export async function getProxyHosts(expand?: ProxyHostExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/proxy-hosts", diff --git a/frontend/src/api/backend/getRedirectionHost.ts b/frontend/src/api/backend/getRedirectionHost.ts index fa537130..9b188741 100644 --- a/frontend/src/api/backend/getRedirectionHost.ts +++ b/frontend/src/api/backend/getRedirectionHost.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { ProxyHost } from "./models"; -export async function getRedirectionHost(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/redirection-hosts/${id}`, +export async function getRedirectionHost(id: number, expand?: HostExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/redirection-hosts/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getRedirectionHosts.ts b/frontend/src/api/backend/getRedirectionHosts.ts index 4e44c6ee..63e292f7 100644 --- a/frontend/src/api/backend/getRedirectionHosts.ts +++ b/frontend/src/api/backend/getRedirectionHosts.ts @@ -1,11 +1,8 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { RedirectionHost } from "./models"; -export type RedirectionHostExpansion = "owner" | "certificate"; -export async function getRedirectionHosts( - expand?: RedirectionHostExpansion[], - params = {}, -): Promise { +export async function getRedirectionHosts(expand?: HostExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/redirection-hosts", params: { diff --git a/frontend/src/api/backend/getSetting.ts b/frontend/src/api/backend/getSetting.ts index f04f7fad..daa54fee 100644 --- a/frontend/src/api/backend/getSetting.ts +++ b/frontend/src/api/backend/getSetting.ts @@ -1,11 +1,12 @@ import * as api from "./base"; import type { Setting } from "./models"; -export async function getSetting(id: string, abortController?: AbortController): Promise { - return await api.get( - { - url: `/settings/${id}`, +export async function getSetting(id: string, expand?: string[], params = {}): Promise { + return await api.get({ + url: `/settings/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getStream.ts b/frontend/src/api/backend/getStream.ts index 61927b68..82e10a04 100644 --- a/frontend/src/api/backend/getStream.ts +++ b/frontend/src/api/backend/getStream.ts @@ -1,11 +1,13 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { Stream } from "./models"; -export async function getStream(id: number, abortController?: AbortController): Promise { - return await api.get( - { - url: `/nginx/streams/${id}`, +export async function getStream(id: number, expand?: HostExpansion[], params = {}): Promise { + return await api.get({ + url: `/nginx/streams/${id}`, + params: { + expand: expand?.join(","), + ...params, }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/getStreams.ts b/frontend/src/api/backend/getStreams.ts index 8468a55d..b5e9379b 100644 --- a/frontend/src/api/backend/getStreams.ts +++ b/frontend/src/api/backend/getStreams.ts @@ -1,9 +1,8 @@ import * as api from "./base"; +import type { HostExpansion } from "./expansions"; import type { Stream } from "./models"; -export type StreamExpansion = "owner" | "certificate"; - -export async function getStreams(expand?: StreamExpansion[], params = {}): Promise { +export async function getStreams(expand?: HostExpansion[], params = {}): Promise { return await api.get({ url: "/nginx/streams", params: { diff --git a/frontend/src/api/backend/getToken.ts b/frontend/src/api/backend/getToken.ts index be20e112..600f0529 100644 --- a/frontend/src/api/backend/getToken.ts +++ b/frontend/src/api/backend/getToken.ts @@ -1,19 +1,9 @@ import * as api from "./base"; import type { TokenResponse } from "./responseTypes"; -interface Options { - payload: { - identity: string; - secret: string; - }; -} - -export async function getToken({ payload }: Options, abortController?: AbortController): Promise { - return await api.post( - { - url: "/tokens", - data: payload, - }, - abortController, - ); +export async function getToken(identity: string, secret: string): Promise { + return await api.post({ + url: "/tokens", + data: { identity, secret }, + }); } diff --git a/frontend/src/api/backend/getUser.ts b/frontend/src/api/backend/getUser.ts index ae57783f..a006782a 100644 --- a/frontend/src/api/backend/getUser.ts +++ b/frontend/src/api/backend/getUser.ts @@ -1,10 +1,14 @@ import * as api from "./base"; +import type { UserExpansion } from "./expansions"; import type { User } from "./models"; -export async function getUser(id: number | string = "me", params = {}): Promise { +export async function getUser(id: number | string = "me", expand?: UserExpansion[], params = {}): Promise { const userId = id ? id : "me"; return await api.get({ url: `/users/${userId}`, - params, + params: { + expand: expand?.join(","), + ...params, + }, }); } diff --git a/frontend/src/api/backend/getUsers.ts b/frontend/src/api/backend/getUsers.ts index a4a03f7c..dab584f4 100644 --- a/frontend/src/api/backend/getUsers.ts +++ b/frontend/src/api/backend/getUsers.ts @@ -1,8 +1,7 @@ import * as api from "./base"; +import type { UserExpansion } from "./expansions"; import type { User } from "./models"; -export type UserExpansion = "permissions"; - export async function getUsers(expand?: UserExpansion[], params = {}): Promise { return await api.get({ url: "/users", diff --git a/frontend/src/api/backend/index.ts b/frontend/src/api/backend/index.ts index f5e63edc..cb771c04 100644 --- a/frontend/src/api/backend/index.ts +++ b/frontend/src/api/backend/index.ts @@ -13,6 +13,7 @@ export * from "./deleteRedirectionHost"; export * from "./deleteStream"; export * from "./deleteUser"; export * from "./downloadCertificate"; +export * from "./expansions"; export * from "./getAccessList"; export * from "./getAccessLists"; export * from "./getAuditLog"; diff --git a/frontend/src/api/backend/refreshToken.ts b/frontend/src/api/backend/refreshToken.ts index 6502fdbe..de1848c2 100644 --- a/frontend/src/api/backend/refreshToken.ts +++ b/frontend/src/api/backend/refreshToken.ts @@ -1,11 +1,8 @@ import * as api from "./base"; import type { TokenResponse } from "./responseTypes"; -export async function refreshToken(abortController?: AbortController): Promise { - return await api.get( - { - url: "/tokens", - }, - abortController, - ); +export async function refreshToken(): Promise { + return await api.get({ + url: "/tokens", + }); } diff --git a/frontend/src/api/backend/renewCertificate.ts b/frontend/src/api/backend/renewCertificate.ts index 9eefff5d..0f3d082d 100644 --- a/frontend/src/api/backend/renewCertificate.ts +++ b/frontend/src/api/backend/renewCertificate.ts @@ -1,11 +1,8 @@ import * as api from "./base"; import type { Certificate } from "./models"; -export async function renewCertificate(id: number, abortController?: AbortController): Promise { - return await api.post( - { - url: `/nginx/certificates/${id}/renew`, - }, - abortController, - ); +export async function renewCertificate(id: number): Promise { + return await api.post({ + url: `/nginx/certificates/${id}/renew`, + }); } diff --git a/frontend/src/api/backend/setPermissions.ts b/frontend/src/api/backend/setPermissions.ts index 80616e97..47fa6306 100644 --- a/frontend/src/api/backend/setPermissions.ts +++ b/frontend/src/api/backend/setPermissions.ts @@ -1,17 +1,10 @@ import * as api from "./base"; import type { UserPermissions } from "./models"; -export async function setPermissions( - userId: number, - data: UserPermissions, - abortController?: AbortController, -): Promise { +export async function setPermissions(userId: number, data: UserPermissions): Promise { // Remove readonly fields - return await api.put( - { - url: `/users/${userId}/permissions`, - data, - }, - abortController, - ); + return await api.put({ + url: `/users/${userId}/permissions`, + data, + }); } diff --git a/frontend/src/api/backend/testHttpCertificate.ts b/frontend/src/api/backend/testHttpCertificate.ts index c6e4eaf0..a35d1fce 100644 --- a/frontend/src/api/backend/testHttpCertificate.ts +++ b/frontend/src/api/backend/testHttpCertificate.ts @@ -1,16 +1,10 @@ import * as api from "./base"; -export async function testHttpCertificate( - domains: string[], - abortController?: AbortController, -): Promise> { - return await api.get( - { - url: "/nginx/certificates/test-http", - params: { - domains: domains.join(","), - }, +export async function testHttpCertificate(domains: string[]): Promise> { + return await api.get({ + url: "/nginx/certificates/test-http", + params: { + domains: domains.join(","), }, - abortController, - ); + }); } diff --git a/frontend/src/api/backend/toggleDeadHost.ts b/frontend/src/api/backend/toggleDeadHost.ts index 967d65db..71a780ef 100644 --- a/frontend/src/api/backend/toggleDeadHost.ts +++ b/frontend/src/api/backend/toggleDeadHost.ts @@ -1,14 +1,7 @@ import * as api from "./base"; -export async function toggleDeadHost( - id: number, - enabled: boolean, - abortController?: AbortController, -): Promise { - return await api.post( - { - url: `/nginx/dead-hosts/${id}/${enabled ? "enable" : "disable"}`, - }, - abortController, - ); +export async function toggleDeadHost(id: number, enabled: boolean): Promise { + return await api.post({ + url: `/nginx/dead-hosts/${id}/${enabled ? "enable" : "disable"}`, + }); } diff --git a/frontend/src/api/backend/toggleProxyHost.ts b/frontend/src/api/backend/toggleProxyHost.ts index 2de3f2a5..376e7881 100644 --- a/frontend/src/api/backend/toggleProxyHost.ts +++ b/frontend/src/api/backend/toggleProxyHost.ts @@ -1,14 +1,7 @@ import * as api from "./base"; -export async function toggleProxyHost( - id: number, - enabled: boolean, - abortController?: AbortController, -): Promise { - return await api.post( - { - url: `/nginx/proxy-hosts/${id}/${enabled ? "enable" : "disable"}`, - }, - abortController, - ); +export async function toggleProxyHost(id: number, enabled: boolean): Promise { + return await api.post({ + url: `/nginx/proxy-hosts/${id}/${enabled ? "enable" : "disable"}`, + }); } diff --git a/frontend/src/api/backend/toggleRedirectionHost.ts b/frontend/src/api/backend/toggleRedirectionHost.ts index 4f2fe41d..0cfa5733 100644 --- a/frontend/src/api/backend/toggleRedirectionHost.ts +++ b/frontend/src/api/backend/toggleRedirectionHost.ts @@ -1,14 +1,7 @@ import * as api from "./base"; -export async function toggleRedirectionHost( - id: number, - enabled: boolean, - abortController?: AbortController, -): Promise { - return await api.post( - { - url: `/nginx/redirection-hosts/${id}/${enabled ? "enable" : "disable"}`, - }, - abortController, - ); +export async function toggleRedirectionHost(id: number, enabled: boolean): Promise { + return await api.post({ + url: `/nginx/redirection-hosts/${id}/${enabled ? "enable" : "disable"}`, + }); } diff --git a/frontend/src/api/backend/toggleStream.ts b/frontend/src/api/backend/toggleStream.ts index 3f8e2e9e..2b71f720 100644 --- a/frontend/src/api/backend/toggleStream.ts +++ b/frontend/src/api/backend/toggleStream.ts @@ -1,10 +1,7 @@ import * as api from "./base"; -export async function toggleStream(id: number, enabled: boolean, abortController?: AbortController): Promise { - return await api.post( - { - url: `/nginx/streams/${id}/${enabled ? "enable" : "disable"}`, - }, - abortController, - ); +export async function toggleStream(id: number, enabled: boolean): Promise { + return await api.post({ + url: `/nginx/streams/${id}/${enabled ? "enable" : "disable"}`, + }); } diff --git a/frontend/src/api/backend/updateAccessList.ts b/frontend/src/api/backend/updateAccessList.ts index cfae9389..7a23566b 100644 --- a/frontend/src/api/backend/updateAccessList.ts +++ b/frontend/src/api/backend/updateAccessList.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { AccessList } from "./models"; -export async function updateAccessList(item: AccessList, abortController?: AbortController): Promise { +export async function updateAccessList(item: AccessList): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/nginx/access-lists/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/nginx/access-lists/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateAuth.ts b/frontend/src/api/backend/updateAuth.ts index c63dfeeb..5b14b076 100644 --- a/frontend/src/api/backend/updateAuth.ts +++ b/frontend/src/api/backend/updateAuth.ts @@ -1,12 +1,7 @@ import * as api from "./base"; import type { User } from "./models"; -export async function updateAuth( - userId: number | "me", - newPassword: string, - current?: string, - abortController?: AbortController, -): Promise { +export async function updateAuth(userId: number | "me", newPassword: string, current?: string): Promise { const data = { type: "password", current: current, @@ -16,11 +11,8 @@ export async function updateAuth( data.current = current; } - return await api.put( - { - url: `/users/${userId}/auth`, - data, - }, - abortController, - ); + return await api.put({ + url: `/users/${userId}/auth`, + data, + }); } diff --git a/frontend/src/api/backend/updateDeadHost.ts b/frontend/src/api/backend/updateDeadHost.ts index 8afd44ab..1eb5631b 100644 --- a/frontend/src/api/backend/updateDeadHost.ts +++ b/frontend/src/api/backend/updateDeadHost.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { DeadHost } from "./models"; -export async function updateDeadHost(item: DeadHost, abortController?: AbortController): Promise { +export async function updateDeadHost(item: DeadHost): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/nginx/dead-hosts/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/nginx/dead-hosts/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateProxyHost.ts b/frontend/src/api/backend/updateProxyHost.ts index 55cdc24c..e7ee3d90 100644 --- a/frontend/src/api/backend/updateProxyHost.ts +++ b/frontend/src/api/backend/updateProxyHost.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { ProxyHost } from "./models"; -export async function updateProxyHost(item: ProxyHost, abortController?: AbortController): Promise { +export async function updateProxyHost(item: ProxyHost): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/nginx/proxy-hosts/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/nginx/proxy-hosts/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateRedirectionHost.ts b/frontend/src/api/backend/updateRedirectionHost.ts index e66aabb9..4cc36f1e 100644 --- a/frontend/src/api/backend/updateRedirectionHost.ts +++ b/frontend/src/api/backend/updateRedirectionHost.ts @@ -1,18 +1,12 @@ import * as api from "./base"; import type { RedirectionHost } from "./models"; -export async function updateRedirectionHost( - item: RedirectionHost, - abortController?: AbortController, -): Promise { +export async function updateRedirectionHost(item: RedirectionHost): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/nginx/redirection-hosts/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/nginx/redirection-hosts/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateSetting.ts b/frontend/src/api/backend/updateSetting.ts index e257528a..bcb94059 100644 --- a/frontend/src/api/backend/updateSetting.ts +++ b/frontend/src/api/backend/updateSetting.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { Setting } from "./models"; -export async function updateSetting(item: Setting, abortController?: AbortController): Promise { +export async function updateSetting(item: Setting): Promise { // Remove readonly fields const { id, ...data } = item; - return await api.put( - { - url: `/settings/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/settings/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateStream.ts b/frontend/src/api/backend/updateStream.ts index 18da6ff4..508bcece 100644 --- a/frontend/src/api/backend/updateStream.ts +++ b/frontend/src/api/backend/updateStream.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { Stream } from "./models"; -export async function updateStream(item: Stream, abortController?: AbortController): Promise { +export async function updateStream(item: Stream): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/nginx/streams/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/nginx/streams/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/updateUser.ts b/frontend/src/api/backend/updateUser.ts index 0df5c279..d063e127 100644 --- a/frontend/src/api/backend/updateUser.ts +++ b/frontend/src/api/backend/updateUser.ts @@ -1,15 +1,12 @@ import * as api from "./base"; import type { User } from "./models"; -export async function updateUser(item: User, abortController?: AbortController): Promise { +export async function updateUser(item: User): Promise { // Remove readonly fields const { id, createdOn: _, modifiedOn: __, ...data } = item; - return await api.put( - { - url: `/users/${id}`, - data: data, - }, - abortController, - ); + return await api.put({ + url: `/users/${id}`, + data: data, + }); } diff --git a/frontend/src/api/backend/uploadCertificate.ts b/frontend/src/api/backend/uploadCertificate.ts index 6c920538..94549a79 100644 --- a/frontend/src/api/backend/uploadCertificate.ts +++ b/frontend/src/api/backend/uploadCertificate.ts @@ -6,13 +6,9 @@ export async function uploadCertificate( certificate: string, certificateKey: string, intermediateCertificate?: string, - abortController?: AbortController, ): Promise { - return await api.post( - { - url: `/nginx/certificates/${id}/upload`, - data: { certificate, certificateKey, intermediateCertificate }, - }, - abortController, - ); + return await api.post({ + url: `/nginx/certificates/${id}/upload`, + data: { certificate, certificateKey, intermediateCertificate }, + }); } diff --git a/frontend/src/api/backend/validateCertificate.ts b/frontend/src/api/backend/validateCertificate.ts index c4065076..a1901e03 100644 --- a/frontend/src/api/backend/validateCertificate.ts +++ b/frontend/src/api/backend/validateCertificate.ts @@ -5,13 +5,9 @@ export async function validateCertificate( certificate: string, certificateKey: string, intermediateCertificate?: string, - abortController?: AbortController, ): Promise { - return await api.post( - { - url: "/nginx/certificates/validate", - data: { certificate, certificateKey, intermediateCertificate }, - }, - abortController, - ); + return await api.post({ + url: "/nginx/certificates/validate", + data: { certificate, certificateKey, intermediateCertificate }, + }); } diff --git a/frontend/src/components/ErrorNotFound.tsx b/frontend/src/components/ErrorNotFound.tsx index ab864dad..5b92b6d5 100644 --- a/frontend/src/components/ErrorNotFound.tsx +++ b/frontend/src/components/ErrorNotFound.tsx @@ -1,6 +1,6 @@ -import { intl } from "src/locale"; import { useNavigate } from "react-router-dom"; import { Button } from "src/components"; +import { intl } from "src/locale"; export function ErrorNotFound() { const navigate = useNavigate(); @@ -9,9 +9,7 @@ export function ErrorNotFound() {

{intl.formatMessage({ id: "notfound.title" })}

-

- {intl.formatMessage({ id: "notfound.text" })} -

+

{intl.formatMessage({ id: "notfound.text" })}

+
+
+ + {({ field, form }: any) => ( +
+ + + {form.errors.nickname ? ( +
+ {form.errors.nickname && form.touched.nickname + ? form.errors.nickname + : null} +
+ ) : null} +
+ )} +
+
+
+
+
+ + {({ field, form }: any) => ( +
+ + + {form.errors.email ? ( +
+ {form.errors.email && form.touched.email + ? form.errors.email + : null} +
+ ) : null} +
+ )} +
+
+ {currentUser && data && currentUser?.id !== data?.id ? ( +
+

{intl.formatMessage({ id: "user.flags.title" })}

+
+
+ +
+
+ +
+
+
+ ) : null} */} + + + + + + + )} + + )} + + ); +} diff --git a/frontend/src/modals/index.ts b/frontend/src/modals/index.ts index c8e89fb5..a5c7fa86 100644 --- a/frontend/src/modals/index.ts +++ b/frontend/src/modals/index.ts @@ -1,4 +1,5 @@ export * from "./ChangePasswordModal"; +export * from "./DeadHostModal"; export * from "./DeleteConfirmModal"; export * from "./EventDetailsModal"; export * from "./PermissionsModal"; diff --git a/frontend/src/pages/Certificates/CertificateTable.tsx b/frontend/src/pages/Certificates/CertificateTable.tsx deleted file mode 100644 index df607d13..00000000 --- a/frontend/src/pages/Certificates/CertificateTable.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import { IconDotsVertical, IconEdit, IconPower, IconSearch, IconTrash } from "@tabler/icons-react"; -import { Button } from "src/components"; -import { intl } from "src/locale"; - -export default function CertificateTable() { - return ( -
-
-
-
-
-
-

{intl.formatMessage({ id: "certificates.title" })}

-
-
-
-
- - - - -
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
-
- -
-
-
-
- blog.jc21.com -
-
Created: 20th September 2024
-
-
http://172.17.0.1:3001Let's EncryptPublic - Online - - - -
- Proxy Host #2 - - - Edit - - - - Disable - - - -
-
-
-
-
- ); -} diff --git a/frontend/src/pages/Nginx/DeadHosts/Empty.tsx b/frontend/src/pages/Nginx/DeadHosts/Empty.tsx index 48865c88..59a22279 100644 --- a/frontend/src/pages/Nginx/DeadHosts/Empty.tsx +++ b/frontend/src/pages/Nginx/DeadHosts/Empty.tsx @@ -4,15 +4,18 @@ import { intl } from "src/locale"; interface Props { tableInstance: ReactTable; + onNew?: () => void; } -export default function Empty({ tableInstance }: Props) { +export default function Empty({ tableInstance, onNew }: Props) { return (

{intl.formatMessage({ id: "dead-hosts.empty" })}

{intl.formatMessage({ id: "empty-subtitle" })}

- +
diff --git a/frontend/src/pages/Nginx/DeadHosts/Table.tsx b/frontend/src/pages/Nginx/DeadHosts/Table.tsx index d9531956..77d9ae91 100644 --- a/frontend/src/pages/Nginx/DeadHosts/Table.tsx +++ b/frontend/src/pages/Nginx/DeadHosts/Table.tsx @@ -10,8 +10,10 @@ import Empty from "./Empty"; interface Props { data: DeadHost[]; isFetching?: boolean; + onDelete?: (id: number) => void; + onNew?: () => void; } -export default function Table({ data, isFetching }: Props) { +export default function Table({ data, isFetching, onDelete, onNew }: Props) { const columnHelper = createColumnHelper(); const columns = useMemo( () => [ @@ -78,7 +80,14 @@ export default function Table({ data, isFetching }: Props) { {intl.formatMessage({ id: "action.disable" })}
- + { + e.preventDefault(); + onDelete?.(info.row.original.id); + }} + > {intl.formatMessage({ id: "action.delete" })} @@ -91,7 +100,7 @@ export default function Table({ data, isFetching }: Props) { }, }), ], - [columnHelper], + [columnHelper, onDelete], ); const tableInstance = useReactTable({ @@ -105,5 +114,7 @@ export default function Table({ data, isFetching }: Props) { enableSortingRemoval: false, }); - return } />; + return ( + } /> + ); } diff --git a/frontend/src/pages/Nginx/DeadHosts/TableWrapper.tsx b/frontend/src/pages/Nginx/DeadHosts/TableWrapper.tsx index 5badc3b1..ad8c072d 100644 --- a/frontend/src/pages/Nginx/DeadHosts/TableWrapper.tsx +++ b/frontend/src/pages/Nginx/DeadHosts/TableWrapper.tsx @@ -1,11 +1,16 @@ import { IconSearch } from "@tabler/icons-react"; +import { useState } from "react"; import Alert from "react-bootstrap/Alert"; import { Button, LoadingPage } from "src/components"; import { useDeadHosts } from "src/hooks"; import { intl } from "src/locale"; +import { DeadHostModal, DeleteConfirmModal } from "src/modals"; +import { showSuccess } from "src/notifications"; import Table from "./Table"; export default function TableWrapper() { + const [deleteId, setDeleteId] = useState(0); + const [editId, setEditId] = useState(0 as number | "new"); const { isFetching, isLoading, isError, error, data } = useDeadHosts(["owner", "certificate"]); if (isLoading) { @@ -16,6 +21,11 @@ export default function TableWrapper() { return {error?.message || "Unknown error"}; } + const handleDelete = async () => { + // await deleteUser(deleteId); + showSuccess(intl.formatMessage({ id: "notification.host-deleted" })); + }; + return (
@@ -38,14 +48,30 @@ export default function TableWrapper() { autoComplete="off" />
-
- +
setDeleteId(id)} + onNew={() => setEditId("new")} + /> + {editId ? setEditId(0)} /> : null} + {deleteId ? ( + setDeleteId(0)} + invalidations={[["dead-hosts"], ["dead-host", deleteId]]} + > + {intl.formatMessage({ id: "user.delete.content" })} + + ) : null} );