-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from vertex-center/feature/scalable-containers…
…-app First draft of the new Vertex Containers compatibility
- Loading branch information
Showing
29 changed files
with
379 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { createServer } from "../../../backend/server"; | ||
import { | ||
Container, | ||
ContainerFilters, | ||
Containers, | ||
EnvVariables, | ||
Tags, | ||
} from "./models"; | ||
import { DockerContainerInfo } from "../../../models/docker"; | ||
import { Service } from "./service"; | ||
|
||
// @ts-ignore | ||
const server = createServer(window.api_urls.containers); | ||
|
||
const getContainers = async (query?: ContainerFilters) => { | ||
const { data } = await server.get<Containers>(`/containers`, { | ||
params: query, | ||
}); | ||
return data; | ||
}; | ||
|
||
const getAllTags = async () => { | ||
const { data } = await server.get<Tags>(`/tags`); | ||
return data; | ||
}; | ||
|
||
const installService = async (serviceId: string) => { | ||
const { data } = await server.post(`/service/${serviceId}/install`); | ||
return data; | ||
}; | ||
|
||
const getAllServices = async () => { | ||
const { data } = await server.get<Service[]>(`/services`); | ||
return data; | ||
}; | ||
|
||
const getContainer = async (id: string) => { | ||
const { data } = await server.get<Container>(`/container/${id}`); | ||
return data; | ||
}; | ||
|
||
const deleteContainer = (id: string) => { | ||
return server.delete(`/container/${id}`); | ||
}; | ||
|
||
const startContainer = (id: string) => { | ||
return server.post(`/container/${id}/start`); | ||
}; | ||
|
||
const stopContainer = (id: string) => { | ||
return server.post(`/container/${id}/stop`); | ||
}; | ||
|
||
const patchContainer = (id: string, params: any) => { | ||
return server.patch(`/container/${id}`, params); | ||
}; | ||
|
||
const getLogs = async (id: string) => { | ||
const { data } = await server.get(`/container/${id}/logs`); | ||
return data; | ||
}; | ||
|
||
const getContainerEnvironment = async (id: string) => { | ||
const { data } = await server.get<EnvVariables>( | ||
`/container/${id}/environment` | ||
); | ||
return data; | ||
}; | ||
|
||
const saveEnv = (id: string, env: EnvVariables) => { | ||
return server.patch(`/container/${id}/environment`, { env }); | ||
}; | ||
|
||
const getDocker = async (id: string) => { | ||
const { data } = await server.get<DockerContainerInfo>( | ||
`/container/${id}/docker` | ||
); | ||
return data; | ||
}; | ||
|
||
const recreateDocker = (id: string) => { | ||
return server.post(`/container/${id}/docker/recreate`); | ||
}; | ||
|
||
const updateService = (id: string) => { | ||
return server.post(`/container/${id}/update/service`); | ||
}; | ||
|
||
const getVersions = async (id: string, cache?: boolean) => { | ||
const { data } = await server.get<string[]>( | ||
`/container/${id}/versions?cache=${cache}` | ||
); | ||
return data; | ||
}; | ||
|
||
export const API = { | ||
getContainer, | ||
getContainers, | ||
getAllTags, | ||
deleteContainer, | ||
startContainer, | ||
stopContainer, | ||
patchContainer, | ||
getLogs, | ||
getContainerEnvironment, | ||
saveEnv, | ||
getDockerInfo: getDocker, | ||
recreateDocker, | ||
updateService, | ||
getVersions, | ||
installService, | ||
getAllServices, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
export type ContainerFilters = { | ||
features?: string[]; | ||
tags?: string[]; | ||
}; | ||
|
||
export type ContainerUpdate = { | ||
current_version: string; | ||
latest_version: string; | ||
}; | ||
|
||
export type ServiceUpdate = { | ||
available?: boolean; | ||
}; | ||
|
||
export type Tags = Tag[]; | ||
export type Tag = { | ||
container_id: string; | ||
tag: string; | ||
}; | ||
|
||
export type EnvVariables = EnvVariable[]; | ||
export type EnvVariable = { | ||
container_id: string; | ||
type: string; | ||
name: string; | ||
display_name: string; | ||
value: string; | ||
default: string; | ||
description: string; | ||
secret: boolean; | ||
}; | ||
|
||
export type Containers = Container[]; | ||
export type Container = { | ||
id: string; | ||
service_id: string; | ||
user_id: string; | ||
image: string; | ||
image_tag: string; | ||
status: string; | ||
launch_on_startup: boolean; | ||
name: string; | ||
description?: string; | ||
color?: string; | ||
icon?: string; | ||
command?: string; | ||
environment: EnvVariables; | ||
capabilities: { | ||
container_id: string; | ||
name: string; | ||
}; | ||
ports: { | ||
container_id: string; | ||
in: string; | ||
out: string; | ||
}[]; | ||
volumes: { | ||
container_id: string; | ||
in: string; | ||
out: string; | ||
}[]; | ||
sysctls: { | ||
container_id: string; | ||
name: string; | ||
value: string; | ||
}[]; | ||
tags: Tags; | ||
|
||
update?: ContainerUpdate; | ||
service_update?: ServiceUpdate; | ||
databases?: { [key: string]: string }; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/apps/Containers/components/EnvVariableInput/EnvVariableInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,38 @@ | ||
import { api } from "../../../backend/api/backend"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { API } from "../backend/api"; | ||
|
||
export default function useContainer(uuid?: string) { | ||
export default function useContainer(id?: string) { | ||
const queryContainer = useQuery({ | ||
queryKey: ["containers", uuid], | ||
queryFn: api.vxContainers.container(uuid).get, | ||
queryKey: ["containers", id], | ||
queryFn: () => API.getContainer(id), | ||
}); | ||
return { container: queryContainer.data, ...queryContainer }; | ||
} | ||
|
||
export function useContainerLogs(uuid?: string) { | ||
export function useContainerLogs(id?: string) { | ||
const queryLogs = useQuery({ | ||
queryKey: ["container_logs", uuid], | ||
queryFn: api.vxContainers.container(uuid).logs.get, | ||
queryKey: ["container_logs", id], | ||
queryFn: () => API.getLogs(id), | ||
}); | ||
return { logs: queryLogs.data, ...queryLogs }; | ||
} | ||
|
||
export function useDockerInfo(uuid?: string) { | ||
export function useDockerInfo(id?: string) { | ||
const queryDockerInfo = useQuery({ | ||
queryKey: ["container_docker", uuid], | ||
queryFn: api.vxContainers.container(uuid).docker.get, | ||
queryKey: ["container_docker", id], | ||
queryFn: () => API.getDockerInfo(id), | ||
}); | ||
return { dockerInfo: queryDockerInfo.data, ...queryDockerInfo }; | ||
} | ||
|
||
export function useContainerEnv(id?: string) { | ||
const queryEnv = useQuery({ | ||
queryKey: ["container_env", id], | ||
queryFn: () => API.getContainerEnvironment(id), | ||
}); | ||
return { | ||
env: queryEnv.data, | ||
isLoadingEnv: queryEnv.isLoading, | ||
errorEnv: queryEnv.error, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.