mirror of https://github.com/jetkvm/kvm.git
Compare commits
1 Commits
0513328620
...
e344fd97c3
| Author | SHA1 | Date |
|---|---|---|
|
|
e344fd97c3 |
|
|
@ -311,27 +311,13 @@ func (s *State) checkUpdateStatus(
|
||||||
appUpdateStatus.available = false
|
appUpdateStatus.available = false
|
||||||
}
|
}
|
||||||
|
|
||||||
components := params.Components
|
// Handle custom target versions
|
||||||
// skip check if no components are specified
|
if slices.Contains(params.Components, "app") && params.AppTargetVersion != "" {
|
||||||
if len(components) == 0 {
|
appUpdateStatus.available = appVersionRemote.String() != appUpdateStatus.localVersion
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: simplify this
|
if slices.Contains(params.Components, "system") && params.SystemTargetVersion != "" {
|
||||||
if slices.Contains(components, "app") {
|
systemUpdateStatus.available = systemVersionRemote.String() != systemUpdateStatus.localVersion
|
||||||
if params.AppTargetVersion != "" {
|
|
||||||
appUpdateStatus.available = appVersionRemote.String() != appVersionLocal.String()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
appUpdateStatus.available = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if slices.Contains(components, "system") {
|
|
||||||
if params.SystemTargetVersion != "" {
|
|
||||||
systemUpdateStatus.available = systemVersionRemote.String() != systemVersionLocal.String()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
systemUpdateStatus.available = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
package ota
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func pseudoGetLocalVersion() (systemVersion *semver.Version, appVersion *semver.Version, err error) {
|
|
||||||
systemVersion = semver.MustParse("0.2.5")
|
|
||||||
appVersion = semver.MustParse("0.4.7")
|
|
||||||
return systemVersion, appVersion, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newOtaState() *State {
|
|
||||||
logger := zerolog.New(os.Stdout).Level(zerolog.TraceLevel)
|
|
||||||
otaState := NewState(Options{
|
|
||||||
SkipConfirmSystem: true,
|
|
||||||
Logger: &logger,
|
|
||||||
ReleaseAPIEndpoint: "https://api.jetkvm.com/releases",
|
|
||||||
GetHTTPClient: func() *http.Client {
|
|
||||||
transport := http.DefaultTransport.(*http.Transport).Clone()
|
|
||||||
client := &http.Client{
|
|
||||||
Transport: transport,
|
|
||||||
}
|
|
||||||
return client
|
|
||||||
},
|
|
||||||
GetLocalVersion: pseudoGetLocalVersion,
|
|
||||||
HwReboot: func(force bool, postRebootAction *PostRebootAction, delay time.Duration) error { return nil },
|
|
||||||
ResetConfig: func() error { return nil },
|
|
||||||
OnStateUpdate: func(state *RPCState) {},
|
|
||||||
OnProgressUpdate: func(progress float32) {},
|
|
||||||
})
|
|
||||||
return otaState
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCheckUpdateComponents(t *testing.T) {
|
|
||||||
otaState := newOtaState()
|
|
||||||
updateParams := UpdateParams{
|
|
||||||
DeviceID: "test",
|
|
||||||
IncludePreRelease: false,
|
|
||||||
SystemTargetVersion: "0.2.2",
|
|
||||||
Components: []string{"system"},
|
|
||||||
}
|
|
||||||
info, err := otaState.GetUpdateStatus(context.Background(), updateParams)
|
|
||||||
t.Logf("update status: %+v", info)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to check update: %v", err)
|
|
||||||
}
|
|
||||||
assert.True(t, info.SystemUpdateAvailable)
|
|
||||||
assert.False(t, info.AppUpdateAvailable)
|
|
||||||
}
|
|
||||||
|
|
@ -203,7 +203,6 @@ type Options struct {
|
||||||
HwReboot HwRebootFunc
|
HwReboot HwRebootFunc
|
||||||
ReleaseAPIEndpoint string
|
ReleaseAPIEndpoint string
|
||||||
ResetConfig ResetConfigFunc
|
ResetConfig ResetConfigFunc
|
||||||
SkipConfirmSystem bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewState creates a new OTA state
|
// NewState creates a new OTA state
|
||||||
|
|
@ -222,9 +221,7 @@ func NewState(opts Options) *State {
|
||||||
releaseAPIEndpoint: opts.ReleaseAPIEndpoint,
|
releaseAPIEndpoint: opts.ReleaseAPIEndpoint,
|
||||||
resetConfig: opts.ResetConfig,
|
resetConfig: opts.ResetConfig,
|
||||||
}
|
}
|
||||||
if !opts.SkipConfirmSystem {
|
go s.confirmCurrentSystem()
|
||||||
go s.confirmCurrentSystem()
|
|
||||||
}
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
ota.go
4
ota.go
|
|
@ -91,7 +91,7 @@ func getUpdateStatus(includePreRelease bool) (*ota.UpdateStatus, error) {
|
||||||
updateStatus.Error = err.Error()
|
updateStatus.Error = err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
otaLogger.Info().Interface("updateStatus", updateStatus).Msg("Update status")
|
logger.Info().Interface("updateStatus", updateStatus).Msg("Update status")
|
||||||
|
|
||||||
return updateStatus, nil
|
return updateStatus, nil
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ func rpcTryUpdateComponents(params updateParams, includePreRelease bool, resetCo
|
||||||
go func() {
|
go func() {
|
||||||
err := otaState.TryUpdate(context.Background(), updateParams)
|
err := otaState.TryUpdate(context.Background(), updateParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
otaLogger.Warn().Err(err).Msg("failed to try update")
|
logger.Warn().Err(err).Msg("failed to try update")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "kvm-ui",
|
"name": "kvm-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2025.11.07.2130",
|
"version": "2025.10.24.2140",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^22.20.0"
|
"node": "^22.20.0"
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
"@xterm/addon-webgl": "^0.18.0",
|
"@xterm/addon-webgl": "^0.18.0",
|
||||||
"@xterm/xterm": "^5.5.0",
|
"@xterm/xterm": "^5.5.0",
|
||||||
"cva": "^1.0.0-beta.4",
|
"cva": "^1.0.0-beta.4",
|
||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.18",
|
||||||
"eslint-import-resolver-alias": "^1.1.2",
|
"eslint-import-resolver-alias": "^1.1.2",
|
||||||
"focus-trap-react": "^11.0.4",
|
"focus-trap-react": "^11.0.4",
|
||||||
"framer-motion": "^12.23.24",
|
"framer-motion": "^12.23.24",
|
||||||
|
|
@ -47,52 +47,52 @@
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
"react-animate-height": "^3.2.3",
|
"react-animate-height": "^3.2.3",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
"react-hook-form": "^7.66.0",
|
"react-hook-form": "^7.65.0",
|
||||||
"react-hot-toast": "^2.6.0",
|
"react-hot-toast": "^2.6.0",
|
||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-router": "^7.9.5",
|
"react-router": "^7.9.5",
|
||||||
"react-simple-keyboard": "^3.8.132",
|
"react-simple-keyboard": "^3.8.131",
|
||||||
"react-use-websocket": "^4.13.0",
|
"react-use-websocket": "^4.13.0",
|
||||||
"react-xtermjs": "^1.0.10",
|
"react-xtermjs": "^1.0.10",
|
||||||
"recharts": "^3.3.0",
|
"recharts": "^3.3.0",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"usehooks-ts": "^3.1.1",
|
"usehooks-ts": "^3.1.1",
|
||||||
"validator": "^13.15.20",
|
"validator": "^13.15.15",
|
||||||
"zustand": "^4.5.2"
|
"zustand": "^4.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.4.1",
|
"@eslint/compat": "^1.4.1",
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@eslint/js": "^9.39.1",
|
"@eslint/js": "^9.39.0",
|
||||||
"@inlang/cli": "^3.0.12",
|
"@inlang/cli": "^3.0.12",
|
||||||
"@inlang/paraglide-js": "^2.4.0",
|
"@inlang/paraglide-js": "^2.4.0",
|
||||||
"@inlang/plugin-m-function-matcher": "^2.1.0",
|
"@inlang/plugin-m-function-matcher": "^2.1.0",
|
||||||
"@inlang/plugin-message-format": "^4.0.0",
|
"@inlang/plugin-message-format": "^4.0.0",
|
||||||
"@inlang/sdk": "^2.4.9",
|
"@inlang/sdk": "^2.4.9",
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.17",
|
"@tailwindcss/postcss": "^4.1.16",
|
||||||
"@tailwindcss/typography": "^0.5.19",
|
"@tailwindcss/typography": "^0.5.19",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.16",
|
||||||
"@types/react": "^19.2.2",
|
"@types/react": "^19.2.2",
|
||||||
"@types/react-dom": "^19.2.2",
|
"@types/react-dom": "^19.2.2",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/validator": "^13.15.4",
|
"@types/validator": "^13.15.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
||||||
"@typescript-eslint/parser": "^8.46.3",
|
"@typescript-eslint/parser": "^8.46.2",
|
||||||
"@vitejs/plugin-react-swc": "^4.2.1",
|
"@vitejs/plugin-react-swc": "^4.2.0",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.38.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
"eslint-plugin-react-refresh": "^0.4.24",
|
"eslint-plugin-react-refresh": "^0.4.24",
|
||||||
"globals": "^16.5.0",
|
"globals": "^16.4.0",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"prettier-plugin-tailwindcss": "^0.7.1",
|
"prettier-plugin-tailwindcss": "^0.7.1",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.16",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^7.1.12",
|
"vite": "^7.1.12",
|
||||||
"vite-tsconfig-paths": "^5.1.4"
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
|
|
|
||||||
|
|
@ -603,9 +603,6 @@ export interface UpdateState {
|
||||||
|
|
||||||
updateErrorMessage: string | null;
|
updateErrorMessage: string | null;
|
||||||
setUpdateErrorMessage: (errorMessage: string) => void;
|
setUpdateErrorMessage: (errorMessage: string) => void;
|
||||||
|
|
||||||
shouldReload: boolean;
|
|
||||||
setShouldReload: (reloadRequired: boolean) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUpdateStore = create<UpdateState>(set => ({
|
export const useUpdateStore = create<UpdateState>(set => ({
|
||||||
|
|
@ -643,9 +640,6 @@ export const useUpdateStore = create<UpdateState>(set => ({
|
||||||
updateErrorMessage: null,
|
updateErrorMessage: null,
|
||||||
setUpdateErrorMessage: (errorMessage: string) =>
|
setUpdateErrorMessage: (errorMessage: string) =>
|
||||||
set({ updateErrorMessage: errorMessage }),
|
set({ updateErrorMessage: errorMessage }),
|
||||||
|
|
||||||
shouldReload: false,
|
|
||||||
setShouldReload: (reloadRequired: boolean) => set({ shouldReload: reloadRequired }),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess";
|
export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess";
|
||||||
|
|
@ -856,12 +850,12 @@ export interface MacrosState {
|
||||||
loadMacros: () => Promise<void>;
|
loadMacros: () => Promise<void>;
|
||||||
saveMacros: (macros: KeySequence[]) => Promise<void>;
|
saveMacros: (macros: KeySequence[]) => Promise<void>;
|
||||||
sendFn:
|
sendFn:
|
||||||
| ((
|
| ((
|
||||||
method: string,
|
method: string,
|
||||||
params: unknown,
|
params: unknown,
|
||||||
callback?: ((resp: JsonRpcResponse) => void) | undefined,
|
callback?: ((resp: JsonRpcResponse) => void) | undefined,
|
||||||
) => void)
|
) => void)
|
||||||
| null;
|
| null;
|
||||||
setSendFn: (
|
setSendFn: (
|
||||||
sendFn: (
|
sendFn: (
|
||||||
method: string,
|
method: string,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default function SettingsGeneralUpdateRoute() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const { updateSuccess } = location.state || {};
|
const { updateSuccess } = location.state || {};
|
||||||
|
|
||||||
const { setModalView, otaState, shouldReload, setShouldReload } = useUpdateStore();
|
const { setModalView, otaState } = useUpdateStore();
|
||||||
const { send } = useJsonRpc();
|
const { send } = useJsonRpc();
|
||||||
|
|
||||||
const customAppVersion = useMemo(() => searchParams.get("custom_app_version") || undefined, [searchParams]);
|
const customAppVersion = useMemo(() => searchParams.get("custom_app_version") || undefined, [searchParams]);
|
||||||
|
|
@ -28,19 +28,15 @@ export default function SettingsGeneralUpdateRoute() {
|
||||||
|
|
||||||
const onClose = useCallback(async () => {
|
const onClose = useCallback(async () => {
|
||||||
navigate(".."); // back to the devices.$id.settings page
|
navigate(".."); // back to the devices.$id.settings page
|
||||||
|
// Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
|
||||||
if (shouldReload) {
|
await sleep(1000);
|
||||||
setShouldReload(false);
|
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
|
||||||
await sleep(1000); // Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
|
}, [navigate]);
|
||||||
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
|
|
||||||
}
|
|
||||||
}, [navigate, setShouldReload, shouldReload]);
|
|
||||||
|
|
||||||
const onConfirmUpdate = useCallback(() => {
|
const onConfirmUpdate = useCallback(() => {
|
||||||
setShouldReload(true);
|
|
||||||
send("tryUpdate", {});
|
send("tryUpdate", {});
|
||||||
setModalView("updating");
|
setModalView("updating");
|
||||||
}, [send, setModalView, setShouldReload]);
|
}, [send, setModalView]);
|
||||||
|
|
||||||
const onConfirmCustomUpdate = useCallback((appTargetVersion?: string, systemTargetVersion?: string) => {
|
const onConfirmCustomUpdate = useCallback((appTargetVersion?: string, systemTargetVersion?: string) => {
|
||||||
const components = [];
|
const components = [];
|
||||||
|
|
@ -101,9 +97,10 @@ export function Dialog({
|
||||||
const { modalView, setModalView, otaState } = useUpdateStore();
|
const { modalView, setModalView, otaState } = useUpdateStore();
|
||||||
const forceCustomUpdate = customSystemVersion !== undefined || customAppVersion !== undefined;
|
const forceCustomUpdate = customSystemVersion !== undefined || customAppVersion !== undefined;
|
||||||
const onConfirmCustomUpdate = useCallback(() => {
|
const onConfirmCustomUpdate = useCallback(() => {
|
||||||
|
console.debug("onConfirmCustomUpdate", customAppVersion, customSystemVersion, versionInfo);
|
||||||
onConfirmCustomUpdateCallback(
|
onConfirmCustomUpdateCallback(
|
||||||
customAppVersion !== undefined ? versionInfo?.remote?.appVersion : undefined,
|
customAppVersion !== undefined ? customAppVersion : versionInfo?.remote?.appVersion,
|
||||||
customSystemVersion !== undefined ? versionInfo?.remote?.systemVersion : undefined,
|
customSystemVersion !== undefined ? customSystemVersion : versionInfo?.remote?.systemVersion,
|
||||||
);
|
);
|
||||||
}, [onConfirmCustomUpdateCallback, customAppVersion, customSystemVersion, versionInfo]);
|
}, [onConfirmCustomUpdateCallback, customAppVersion, customSystemVersion, versionInfo]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue