mirror of https://github.com/jetkvm/kvm.git
Compare commits
5 Commits
release/0.
...
main
Author | SHA1 | Date |
---|---|---|
|
fe77acd5f0 | |
|
83caa8f82d | |
|
27750b9cc2 | |
|
5112bef19c | |
|
1ffdca4fd6 |
14
Makefile
14
Makefile
|
@ -1,9 +1,9 @@
|
||||||
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
BUILDDATE ?= $(shell date -u +%FT%T%z)
|
BUILDDATE := $(shell date -u +%FT%T%z)
|
||||||
BUILDTS ?= $(shell date -u +%s)
|
BUILDTS := $(shell date -u +%s)
|
||||||
REVISION ?= $(shell git rev-parse HEAD)
|
REVISION := $(shell git rev-parse HEAD)
|
||||||
VERSION_DEV ?= 0.4.8-dev$(shell date +%Y%m%d%H%M)
|
VERSION_DEV := 0.4.9-dev$(shell date +%Y%m%d%H%M)
|
||||||
VERSION ?= 0.4.7
|
VERSION := 0.4.8
|
||||||
|
|
||||||
PROMETHEUS_TAG := github.com/prometheus/common/version
|
PROMETHEUS_TAG := github.com/prometheus/common/version
|
||||||
KVM_PKG_NAME := github.com/jetkvm/kvm
|
KVM_PKG_NAME := github.com/jetkvm/kvm
|
||||||
|
@ -80,7 +80,7 @@ frontend:
|
||||||
-exec sh -c 'gzip -9 -kfv {}' \;
|
-exec sh -c 'gzip -9 -kfv {}' \;
|
||||||
|
|
||||||
dev_release: frontend build_dev
|
dev_release: frontend build_dev
|
||||||
@echo "Uploading release..."
|
@echo "Uploading release... $(VERSION_DEV)"
|
||||||
@shasum -a 256 bin/jetkvm_app | cut -d ' ' -f 1 > bin/jetkvm_app.sha256
|
@shasum -a 256 bin/jetkvm_app | cut -d ' ' -f 1 > bin/jetkvm_app.sha256
|
||||||
rclone copyto bin/jetkvm_app r2://jetkvm-update/app/$(VERSION_DEV)/jetkvm_app
|
rclone copyto bin/jetkvm_app r2://jetkvm-update/app/$(VERSION_DEV)/jetkvm_app
|
||||||
rclone copyto bin/jetkvm_app.sha256 r2://jetkvm-update/app/$(VERSION_DEV)/jetkvm_app.sha256
|
rclone copyto bin/jetkvm_app.sha256 r2://jetkvm-update/app/$(VERSION_DEV)/jetkvm_app.sha256
|
||||||
|
|
14
jsonrpc.go
14
jsonrpc.go
|
@ -282,6 +282,17 @@ func rpcGetUpdateStatus() (*UpdateStatus, error) {
|
||||||
return updateStatus, nil
|
return updateStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rpcGetLocalVersion() (*LocalMetadata, error) {
|
||||||
|
systemVersion, appVersion, err := GetLocalVersion()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error getting local version: %w", err)
|
||||||
|
}
|
||||||
|
return &LocalMetadata{
|
||||||
|
AppVersion: appVersion.String(),
|
||||||
|
SystemVersion: systemVersion.String(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func rpcTryUpdate() error {
|
func rpcTryUpdate() error {
|
||||||
includePreRelease := config.IncludePreRelease
|
includePreRelease := config.IncludePreRelease
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1168,6 +1179,8 @@ var rpcHandlers = map[string]RPCHandler{
|
||||||
"renewDHCPLease": {Func: rpcRenewDHCPLease},
|
"renewDHCPLease": {Func: rpcRenewDHCPLease},
|
||||||
"getKeyboardLedState": {Func: rpcGetKeyboardLedState},
|
"getKeyboardLedState": {Func: rpcGetKeyboardLedState},
|
||||||
"getKeyDownState": {Func: rpcGetKeysDownState},
|
"getKeyDownState": {Func: rpcGetKeysDownState},
|
||||||
|
"keyboardReport": {Func: rpcKeyboardReport, Params: []string{"modifier", "keys"}},
|
||||||
|
"keypressReport": {Func: rpcKeypressReport, Params: []string{"key", "press"}},
|
||||||
"absMouseReport": {Func: rpcAbsMouseReport, Params: []string{"x", "y", "buttons"}},
|
"absMouseReport": {Func: rpcAbsMouseReport, Params: []string{"x", "y", "buttons"}},
|
||||||
"relMouseReport": {Func: rpcRelMouseReport, Params: []string{"dx", "dy", "buttons"}},
|
"relMouseReport": {Func: rpcRelMouseReport, Params: []string{"dx", "dy", "buttons"}},
|
||||||
"wheelReport": {Func: rpcWheelReport, Params: []string{"wheelY"}},
|
"wheelReport": {Func: rpcWheelReport, Params: []string{"wheelY"}},
|
||||||
|
@ -1189,6 +1202,7 @@ var rpcHandlers = map[string]RPCHandler{
|
||||||
"setEDID": {Func: rpcSetEDID, Params: []string{"edid"}},
|
"setEDID": {Func: rpcSetEDID, Params: []string{"edid"}},
|
||||||
"getDevChannelState": {Func: rpcGetDevChannelState},
|
"getDevChannelState": {Func: rpcGetDevChannelState},
|
||||||
"setDevChannelState": {Func: rpcSetDevChannelState, Params: []string{"enabled"}},
|
"setDevChannelState": {Func: rpcSetDevChannelState, Params: []string{"enabled"}},
|
||||||
|
"getLocalVersion": {Func: rpcGetLocalVersion},
|
||||||
"getUpdateStatus": {Func: rpcGetUpdateStatus},
|
"getUpdateStatus": {Func: rpcGetUpdateStatus},
|
||||||
"tryUpdate": {Func: rpcTryUpdate},
|
"tryUpdate": {Func: rpcTryUpdate},
|
||||||
"getDevModeState": {Func: rpcGetDevModeState},
|
"getDevModeState": {Func: rpcGetDevModeState},
|
||||||
|
|
|
@ -29,6 +29,8 @@ export interface JsonRpcErrorResponse {
|
||||||
|
|
||||||
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
||||||
|
|
||||||
|
export const RpcMethodNotFound = -32601;
|
||||||
|
|
||||||
const callbackStore = new Map<number | string, (resp: JsonRpcResponse) => void>();
|
const callbackStore = new Map<number | string, (resp: JsonRpcResponse) => void>();
|
||||||
let requestCounter = 0;
|
let requestCounter = 0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
import { useCallback } from "react";
|
||||||
|
|
||||||
|
import { useDeviceStore } from "@/hooks/stores";
|
||||||
|
import { type JsonRpcResponse, RpcMethodNotFound, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||||
|
import notifications from "@/notifications";
|
||||||
|
|
||||||
|
export interface VersionInfo {
|
||||||
|
appVersion: string;
|
||||||
|
systemVersion: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SystemVersionInfo {
|
||||||
|
local: VersionInfo;
|
||||||
|
remote?: VersionInfo;
|
||||||
|
systemUpdateAvailable: boolean;
|
||||||
|
appUpdateAvailable: boolean;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useVersion() {
|
||||||
|
const {
|
||||||
|
appVersion,
|
||||||
|
systemVersion,
|
||||||
|
setAppVersion,
|
||||||
|
setSystemVersion,
|
||||||
|
} = useDeviceStore();
|
||||||
|
const { send } = useJsonRpc();
|
||||||
|
const getVersionInfo = useCallback(() => {
|
||||||
|
return new Promise<SystemVersionInfo>((resolve, reject) => {
|
||||||
|
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
||||||
|
if ("error" in resp) {
|
||||||
|
notifications.error(`Failed to check for updates: ${resp.error}`);
|
||||||
|
reject(new Error("Failed to check for updates"));
|
||||||
|
} else {
|
||||||
|
const result = resp.result as SystemVersionInfo;
|
||||||
|
setAppVersion(result.local.appVersion);
|
||||||
|
setSystemVersion(result.local.systemVersion);
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
notifications.error(`Failed to check for updates: ${result.error}`);
|
||||||
|
reject(new Error("Failed to check for updates"));
|
||||||
|
} else {
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, [send, setAppVersion, setSystemVersion]);
|
||||||
|
|
||||||
|
const getLocalVersion = useCallback(() => {
|
||||||
|
return new Promise<VersionInfo>((resolve, reject) => {
|
||||||
|
send("getLocalVersion", {}, (resp: JsonRpcResponse) => {
|
||||||
|
if ("error" in resp) {
|
||||||
|
console.log(resp.error)
|
||||||
|
if (resp.error.code === RpcMethodNotFound) {
|
||||||
|
console.warn("Failed to get device version, using legacy version");
|
||||||
|
return getVersionInfo().then(result => resolve(result.local)).catch(reject);
|
||||||
|
}
|
||||||
|
console.error("Failed to get device version N", resp.error);
|
||||||
|
notifications.error(`Failed to get device version: ${resp.error}`);
|
||||||
|
reject(new Error("Failed to get device version"));
|
||||||
|
} else {
|
||||||
|
const result = resp.result as VersionInfo;
|
||||||
|
|
||||||
|
setAppVersion(result.appVersion);
|
||||||
|
setSystemVersion(result.systemVersion);
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, [send, setAppVersion, setSystemVersion, getVersionInfo]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
getVersionInfo,
|
||||||
|
getLocalVersion,
|
||||||
|
appVersion,
|
||||||
|
systemVersion,
|
||||||
|
};
|
||||||
|
}
|
|
@ -239,7 +239,7 @@ video::-webkit-media-controls {
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple-keyboard-arrows .hg-button {
|
.simple-keyboard-arrows .hg-button {
|
||||||
@apply flex w-[50px] grow-0 items-center justify-center;
|
@apply flex w-[50px] items-center justify-center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controlArrows {
|
.controlArrows {
|
||||||
|
@ -264,7 +264,7 @@ video::-webkit-media-controls {
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple-keyboard-control .hg-button {
|
.simple-keyboard-control .hg-button {
|
||||||
@apply flex w-[50px] grow-0 items-center justify-center;
|
@apply flex w-[50px] items-center justify-center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.numPad {
|
.numPad {
|
||||||
|
@ -332,7 +332,7 @@ video::-webkit-media-controls {
|
||||||
|
|
||||||
.keyboard-detached .simple-keyboard.hg-theme-default div.hg-button {
|
.keyboard-detached .simple-keyboard.hg-theme-default div.hg-button {
|
||||||
text-wrap: auto;
|
text-wrap: auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
min-width: 6ch;
|
min-width: 6ch;
|
||||||
}
|
}
|
||||||
.keyboard-detached .simple-keyboard.hg-theme-default .hg-button span {
|
.keyboard-detached .simple-keyboard.hg-theme-default .hg-button span {
|
||||||
|
|
|
@ -3,12 +3,12 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { CheckCircleIcon } from "@heroicons/react/20/solid";
|
import { CheckCircleIcon } from "@heroicons/react/20/solid";
|
||||||
|
|
||||||
import Card from "@/components/Card";
|
import Card from "@/components/Card";
|
||||||
import { JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
|
import { useJsonRpc } from "@/hooks/useJsonRpc";
|
||||||
import { Button } from "@components/Button";
|
import { Button } from "@components/Button";
|
||||||
import { UpdateState, useDeviceStore, useUpdateStore } from "@/hooks/stores";
|
import { UpdateState, useUpdateStore } from "@/hooks/stores";
|
||||||
import notifications from "@/notifications";
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner";
|
import LoadingSpinner from "@/components/LoadingSpinner";
|
||||||
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
||||||
|
import { SystemVersionInfo, useVersion } from "@/hooks/useVersion";
|
||||||
|
|
||||||
export default function SettingsGeneralUpdateRoute() {
|
export default function SettingsGeneralUpdateRoute() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -41,13 +41,7 @@ export default function SettingsGeneralUpdateRoute() {
|
||||||
return <Dialog onClose={() => navigate("..")} onConfirmUpdate={onConfirmUpdate} />;
|
return <Dialog onClose={() => navigate("..")} onConfirmUpdate={onConfirmUpdate} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SystemVersionInfo {
|
|
||||||
local: { appVersion: string; systemVersion: string };
|
|
||||||
remote?: { appVersion: string; systemVersion: string };
|
|
||||||
systemUpdateAvailable: boolean;
|
|
||||||
appUpdateAvailable: boolean;
|
|
||||||
error?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Dialog({
|
export function Dialog({
|
||||||
onClose,
|
onClose,
|
||||||
|
@ -134,30 +128,8 @@ function LoadingState({
|
||||||
}) {
|
}) {
|
||||||
const [progressWidth, setProgressWidth] = useState("0%");
|
const [progressWidth, setProgressWidth] = useState("0%");
|
||||||
const abortControllerRef = useRef<AbortController | null>(null);
|
const abortControllerRef = useRef<AbortController | null>(null);
|
||||||
const { setAppVersion, setSystemVersion } = useDeviceStore();
|
|
||||||
const { send } = useJsonRpc();
|
|
||||||
|
|
||||||
const getVersionInfo = useCallback(() => {
|
const { getVersionInfo } = useVersion();
|
||||||
return new Promise<SystemVersionInfo>((resolve, reject) => {
|
|
||||||
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
|
||||||
if ("error" in resp) {
|
|
||||||
notifications.error(`Failed to check for updates: ${resp.error}`);
|
|
||||||
reject(new Error("Failed to check for updates"));
|
|
||||||
} else {
|
|
||||||
const result = resp.result as SystemVersionInfo;
|
|
||||||
setAppVersion(result.local.appVersion);
|
|
||||||
setSystemVersion(result.local.systemVersion);
|
|
||||||
|
|
||||||
if (result.error) {
|
|
||||||
notifications.error(`Failed to check for updates: ${result.error}`);
|
|
||||||
reject(new Error("Failed to check for updates"));
|
|
||||||
} else {
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, [send, setAppVersion, setSystemVersion]);
|
|
||||||
|
|
||||||
const progressBarRef = useRef<HTMLDivElement>(null);
|
const progressBarRef = useRef<HTMLDivElement>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -19,14 +19,12 @@ import { CLOUD_API, DEVICE_API } from "@/ui.config";
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
import { checkAuth, isInCloud, isOnDevice } from "@/main";
|
import { checkAuth, isInCloud, isOnDevice } from "@/main";
|
||||||
import { cx } from "@/cva.config";
|
import { cx } from "@/cva.config";
|
||||||
import notifications from "@/notifications";
|
|
||||||
import {
|
import {
|
||||||
KeyboardLedState,
|
KeyboardLedState,
|
||||||
KeysDownState,
|
KeysDownState,
|
||||||
NetworkState,
|
NetworkState,
|
||||||
OtaState,
|
OtaState,
|
||||||
USBStates,
|
USBStates,
|
||||||
useDeviceStore,
|
|
||||||
useHidStore,
|
useHidStore,
|
||||||
useNetworkStateStore,
|
useNetworkStateStore,
|
||||||
User,
|
User,
|
||||||
|
@ -42,7 +40,7 @@ const ConnectionStatsSidebar = lazy(() => import('@/components/sidebar/connectio
|
||||||
const Terminal = lazy(() => import('@components/Terminal'));
|
const Terminal = lazy(() => import('@components/Terminal'));
|
||||||
const UpdateInProgressStatusCard = lazy(() => import("@/components/UpdateInProgressStatusCard"));
|
const UpdateInProgressStatusCard = lazy(() => import("@/components/UpdateInProgressStatusCard"));
|
||||||
import Modal from "@/components/Modal";
|
import Modal from "@/components/Modal";
|
||||||
import { JsonRpcRequest, JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
|
import { JsonRpcRequest, JsonRpcResponse, RpcMethodNotFound, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||||
import {
|
import {
|
||||||
ConnectionFailedOverlay,
|
ConnectionFailedOverlay,
|
||||||
LoadingConnectionOverlay,
|
LoadingConnectionOverlay,
|
||||||
|
@ -51,7 +49,7 @@ import {
|
||||||
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
||||||
import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider";
|
import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider";
|
||||||
import { DeviceStatus } from "@routes/welcome-local";
|
import { DeviceStatus } from "@routes/welcome-local";
|
||||||
import { SystemVersionInfo } from "@routes/devices.$id.settings.general.update";
|
import { useVersion } from "@/hooks/useVersion";
|
||||||
|
|
||||||
interface LocalLoaderResp {
|
interface LocalLoaderResp {
|
||||||
authMode: "password" | "noPassword" | null;
|
authMode: "password" | "noPassword" | null;
|
||||||
|
@ -715,7 +713,7 @@ export default function KvmIdRoute() {
|
||||||
send("getKeyDownState", {}, (resp: JsonRpcResponse) => {
|
send("getKeyDownState", {}, (resp: JsonRpcResponse) => {
|
||||||
if ("error" in resp) {
|
if ("error" in resp) {
|
||||||
// -32601 means the method is not supported
|
// -32601 means the method is not supported
|
||||||
if (resp.error.code === -32601) {
|
if (resp.error.code === RpcMethodNotFound) {
|
||||||
// if we don't support key down state, we know key press is also not available
|
// if we don't support key down state, we know key press is also not available
|
||||||
console.warn("Failed to get key down state, switching to old-school", resp.error);
|
console.warn("Failed to get key down state, switching to old-school", resp.error);
|
||||||
setHidRpcDisabled(true);
|
setHidRpcDisabled(true);
|
||||||
|
@ -758,26 +756,13 @@ export default function KvmIdRoute() {
|
||||||
if (location.pathname !== "/other-session") navigateTo("/");
|
if (location.pathname !== "/other-session") navigateTo("/");
|
||||||
}, [navigateTo, location.pathname]);
|
}, [navigateTo, location.pathname]);
|
||||||
|
|
||||||
const { appVersion, setAppVersion, setSystemVersion} = useDeviceStore();
|
const { appVersion, getLocalVersion} = useVersion();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (appVersion) return;
|
if (appVersion) return;
|
||||||
|
|
||||||
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
getLocalVersion();
|
||||||
if ("error" in resp) {
|
}, [appVersion, getLocalVersion]);
|
||||||
notifications.error(`Failed to get device version: ${resp.error}`);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = resp.result as SystemVersionInfo;
|
|
||||||
if (result.error) {
|
|
||||||
notifications.error(`Failed to get device version: ${result.error}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
setAppVersion(result.local.appVersion);
|
|
||||||
setSystemVersion(result.local.systemVersion);
|
|
||||||
});
|
|
||||||
}, [appVersion, send, setAppVersion, setSystemVersion]);
|
|
||||||
|
|
||||||
const ConnectionStatusElement = useMemo(() => {
|
const ConnectionStatusElement = useMemo(() => {
|
||||||
const hasConnectionFailed =
|
const hasConnectionFailed =
|
||||||
|
|
Loading…
Reference in New Issue