import React from "react"
import * as antd from "antd"
import { Icons } from "components/Icons"
import config from "config"
import "./index.less"
const connectionsTooltipStrings = {
secure: "This connection is secure",
insecure: "This connection is insecure, cause it's not using HTTPS protocol and the server cannot be verified on the trusted certificate authority.",
warning: "This connection is secure but the server cannot be verified on the trusted certificate authority.",
}
const Footer = () => {
const isDevMode = window.__evite?.env?.NODE_ENV !== "production"
return
{config.app?.siteName}
{isDevMode ? : }
{isDevMode ? "development" : "production"}
}
const latencyToColor = (latency, type) => {
switch (type) {
case "http": {
if (latency < 100) {
return "green"
}
if (latency < 200) {
return "orange"
}
return "red"
}
case "ws": {
if (latency < 80) {
return "green"
}
if (latency < 120) {
return "orange"
}
return "red"
}
}
}
export default {
id: "about",
icon: "Info",
label: "About",
group: "bottom",
render: () => {
const isProduction = import.meta.env.PROD
const [serverManifest, setServerManifest] = React.useState(null)
const [serverOrigin, setServerOrigin] = React.useState(null)
const [serverHealth, setServerHealth] = React.useState(null)
const [secureConnection, setSecureConnection] = React.useState(false)
const [connectionPing, setConnectionPing] = React.useState({})
const checkServerVersion = async () => {
const serverManifest = await app.cores.api.customRequest()
setServerManifest(serverManifest.data)
}
const checkServerOrigin = async () => {
const instance = app.cores.api.instance()
if (instance) {
setServerOrigin(instance.mainOrigin)
if (instance.mainOrigin.startsWith("https")) {
setSecureConnection(true)
}
}
}
const fetchServerHealth = async () => {
const response = await app.cores.api.customRequest({
method: "GET",
url: "/server/health",
}).catch(() => null)
console.log(response.data)
if (response) {
setServerHealth(response.data)
}
}
const measurePing = async () => {
const result = await app.cores.api.measurePing()
console.log(result)
setConnectionPing(result)
}
React.useEffect(() => {
checkServerVersion()
checkServerOrigin()
fetchServerHealth()
measurePing()
const measureInterval = setInterval(() => {
fetchServerHealth()
measurePing()
}, 3000)
return () => {
clearInterval(measureInterval)
}
}, [])
return
{config.app.siteName}
{config.author}
Licensed with {config.package?.license ?? "unlicensed"}
v{window.app.version ?? "experimental"}
{isProduction ? : }
{String(import.meta.env.MODE)}
Server information
Origin
: }
>
{
secureConnection ? " Secure connection" : "Insecure connection"
}
{serverOrigin ?? "Unknown"}
Version
{serverManifest?.version ?? "Unknown"}
{
serverManifest?.LINEBRIDGE_SERVER_VERSION &&
Powered by Linebridgeâ„¢
}
}
}