import CloudUploadIcon from "@mui/icons-material/CloudUpload"; import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, FormControl, InputLabel, MenuItem, Select, styled, } from "@mui/material"; import React from "react"; import { OTAAPI } from "../api/OTAApi"; import { useAlert } from "../hooks/context_providers/AlertDialogProvider"; import { useLoadingMessage } from "../hooks/context_providers/LoadingMessageProvider"; import { useSnackbar } from "../hooks/context_providers/SnackbarProvider"; import { checkVersion } from "../utils/StringsUtils"; import { TextInput } from "../widgets/forms/TextInput"; const VisuallyHiddenInput = styled("input")({ clip: "rect(0 0 0 0)", clipPath: "inset(50%)", height: 1, overflow: "hidden", position: "absolute", bottom: 0, left: 0, whiteSpace: "nowrap", width: 1, }); export function UploadUpdateDialog(p: { platforms: string[]; onClose: () => void; onCreated: () => void; }): React.ReactElement { const alert = useAlert(); const snackbar = useSnackbar(); const loadingMessage = useLoadingMessage(); const [platform, setPlatform] = React.useState(); const [version, setVersion] = React.useState(); const [file, setFile] = React.useState(); const canSubmit = platform && version && checkVersion(version) && file; const upload = async () => { try { loadingMessage.show("Uploading firmware..."); await OTAAPI.UploadFirmware(platform!, version!, file!); snackbar("Successfully uploaded new firmware!"); p.onCreated(); } catch (e) { console.error(e); alert(`Failed to upload firmware: ${e}`); } finally { loadingMessage.hide(); } }; return ( Submit a new update You can upload a new firmware using this form.
Platform


); }