fixed port mappings
Some checks failed
Build and Push Docker Image / Build image (push) Has been cancelled
Some checks failed
Build and Push Docker Image / Build image (push) Has been cancelled
This commit is contained in:
parent
f8647c50ae
commit
1d6bc8736e
@ -6,6 +6,12 @@ export interface Port {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface PortMapping {
|
||||||
|
ContainerPort: number
|
||||||
|
HostPort: number
|
||||||
|
Protocol: 'tcp' | 'udp'
|
||||||
|
}
|
||||||
|
|
||||||
export interface ImageInfo {
|
export interface ImageInfo {
|
||||||
Id: string
|
Id: string
|
||||||
Name: string
|
Name: string
|
||||||
@ -20,7 +26,7 @@ export interface ServerInfo {
|
|||||||
On: boolean
|
On: boolean
|
||||||
OwnerId: string
|
OwnerId: string
|
||||||
Image: ImageInfo
|
Image: ImageInfo
|
||||||
Ports: Port[] | null
|
Ports: PortMapping[] | null
|
||||||
Domain: string
|
Domain: string
|
||||||
Nickname?: string
|
Nickname?: string
|
||||||
}
|
}
|
||||||
@ -44,13 +50,13 @@ export interface Browser {
|
|||||||
|
|
||||||
export interface OpenApiMethodSchema {
|
export interface OpenApiMethodSchema {
|
||||||
summary: string
|
summary: string
|
||||||
requestBody: {content: Record<string, {schema: JSONSchema7}>}
|
requestBody: { content: Record<string, { schema: JSONSchema7 }> }
|
||||||
api_response: 'Ignore' | 'Browse' | 'Terminal'
|
api_response: 'Ignore' | 'Browse' | 'Terminal'
|
||||||
permissions: number
|
permissions: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface OpenAPISchema {
|
export interface OpenAPISchema {
|
||||||
paths: Record<string, {get?: OpenApiMethodSchema, post?: OpenApiMethodSchema, delete?: OpenApiMethodSchema}>
|
paths: Record<string, { get?: OpenApiMethodSchema, post?: OpenApiMethodSchema, delete?: OpenApiMethodSchema }>
|
||||||
components: {schema: Record<string, JSONSchema7>}
|
components: { schema: Record<string, JSONSchema7> }
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
import { AxiosInstance } from "axios"
|
import { AxiosInstance } from "axios"
|
||||||
import { ActionGroup, ActionInfo, DataTable, UserInfoContext, actionIdentifierContext, api, apiAuthenticatedContext} from "./common"
|
import { ActionGroup, ActionInfo, DataTable, UserInfoContext, actionIdentifierContext, api, apiAuthenticatedContext } from "./common"
|
||||||
import React, { Context, Dispatch, createContext, useContext, useEffect, useState } from "react"
|
import { Context, Dispatch, createContext, useContext, useEffect, useState } from "react"
|
||||||
import { TableRow, TableCell, Chip } from "@mui/material"
|
import { TableRow, TableCell, Chip } from "@mui/material"
|
||||||
import { ImageInfo, ServerInfo } from "./interfaces"
|
import { PortMapping, ServerInfo } from "./interfaces"
|
||||||
import { JSONSchema7 } from "json-schema"
|
|
||||||
import { CREATE_SERVER_ACTION, Permission, SERVER_ACTIONS } from "./actions"
|
import { CREATE_SERVER_ACTION, Permission, SERVER_ACTIONS } from "./actions"
|
||||||
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -18,22 +18,28 @@ export async function loadServers(api: AxiosInstance): Promise<{ status: number,
|
|||||||
|
|
||||||
const serverActionsContext: Context<ActionInfo[]> = createContext([] as ActionInfo[])
|
const serverActionsContext: Context<ActionInfo[]> = createContext([] as ActionInfo[])
|
||||||
|
|
||||||
|
function generateChipHandler(domain: string, port: PortMapping) {
|
||||||
|
return () => {
|
||||||
|
navigator.clipboard.writeText(`${domain}:${port.HostPort}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function ServerItem(props: { server_info: ServerInfo }) {
|
function ServerItem(props: { server_info: ServerInfo }) {
|
||||||
const actions = useContext(serverActionsContext)
|
const actions = useContext(serverActionsContext)
|
||||||
const [serverPermissions, setServerPermissions] = useState(null as null|number)
|
const [serverPermissions, setServerPermissions] = useState(null as null | number)
|
||||||
const user = useContext(UserInfoContext)
|
const user = useContext(UserInfoContext)
|
||||||
let permissions = 0
|
let permissions = 0
|
||||||
console.log(user)
|
console.log(user)
|
||||||
if (props.server_info.OwnerId === user?.Username){
|
if (props.server_info.OwnerId === user?.Username) {
|
||||||
permissions |= Permission.Admin
|
permissions |= Permission.Admin
|
||||||
}else{
|
} else {
|
||||||
if (serverPermissions === null){
|
if (serverPermissions === null) {
|
||||||
api.get(`/servers/${props.server_info.Id}/permissions`).then((event)=>{setServerPermissions(event.data)})
|
api.get(`/servers/${props.server_info.Id}/permissions`).then((event) => { setServerPermissions(event.data) })
|
||||||
}else{
|
} else {
|
||||||
permissions |= serverPermissions
|
permissions |= serverPermissions
|
||||||
}
|
}
|
||||||
if (user){
|
if (user) {
|
||||||
permissions |= user.Permissions
|
permissions |= user.Permissions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +52,7 @@ function ServerItem(props: { server_info: ServerInfo }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserInfoContext.Provider value={user? {Username: user.Username, Email: user.Email, Permissions: permissions}: null}>
|
<UserInfoContext.Provider value={user ? { Username: user.Username, Email: user.Email, Permissions: permissions } : null}>
|
||||||
<actionIdentifierContext.Provider value={props.server_info.Id}>
|
<actionIdentifierContext.Provider value={props.server_info.Id}>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell>{props.server_info.Nickname}</TableCell>
|
<TableCell>{props.server_info.Nickname}</TableCell>
|
||||||
@ -54,17 +60,18 @@ function ServerItem(props: { server_info: ServerInfo }) {
|
|||||||
<TableCell>{props.server_info.Image.Name}</TableCell>
|
<TableCell>{props.server_info.Image.Name}</TableCell>
|
||||||
<TableCell>{props.server_info.Image.Version}</TableCell>
|
<TableCell>{props.server_info.Image.Version}</TableCell>
|
||||||
<TableCell>{props.server_info.Domain}</TableCell>
|
<TableCell>{props.server_info.Domain}</TableCell>
|
||||||
<TableCell>{props.server_info.Ports.map((port, index, array) => { return <Chip label={`${port.Number}/${port.Protocol}`} /> })}</TableCell>
|
<TableCell>{props.server_info.Ports.map((port, index, array) => { return <Chip onClick={generateChipHandler(props.server_info.Domain, port)} label={`${port.HostPort}:${port.ContainerPort}/${port.Protocol}`} icon={<ContentCopyIcon />} /> })}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<ActionGroup actions={actions.filter((value)=>{
|
<ActionGroup actions={actions.filter((value) => {
|
||||||
switch (value.ServerState){
|
switch (value.ServerState) {
|
||||||
case undefined:
|
case undefined:
|
||||||
return true
|
return true
|
||||||
case "off":
|
case "off":
|
||||||
return !props.server_info.On
|
return !props.server_info.On
|
||||||
case "on":
|
case "on":
|
||||||
return props.server_info.On
|
return props.server_info.On
|
||||||
}})} identifierSubstring="server_id" />
|
}
|
||||||
|
})} identifierSubstring="server_id" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</actionIdentifierContext.Provider>
|
</actionIdentifierContext.Provider>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user