mirror of
https://github.com/siemens-mobile-hacks/web-tools.git
synced 2026-11-25 17:17:22 +00:00
Enhance file/phone selector in explorer
This commit is contained in:
parent
e3574c8ca1
commit
5973cf9d86
8 changed files with 198 additions and 96 deletions
|
|
@ -179,7 +179,7 @@ export const App: ParentComponent = (props) => {
|
|||
gridArea: 'main',
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
p: 1,
|
||||
p: 2,
|
||||
maxWidth: '100%',
|
||||
overflow: hasPermanentDrawer() ? 'auto' : undefined,
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
FormControlLabel,
|
||||
FormGroup,
|
||||
FormLabel,
|
||||
IconButton,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
Popover,
|
||||
|
|
@ -85,7 +86,13 @@ export const SerialConnect: Component<SerialConnectProps> = (props) => {
|
|||
);
|
||||
|
||||
return (
|
||||
<Stack alignItems="center" gap={1} direction="row" alignContent="center">
|
||||
<Stack
|
||||
alignItems="center"
|
||||
gap={1}
|
||||
direction="row"
|
||||
alignContent="center"
|
||||
sx={{ width: { xs: '100%', sm: 'auto' }, minWidth: 0 }}
|
||||
>
|
||||
<Show
|
||||
when={!invalidProtocol()}
|
||||
fallback={
|
||||
|
|
@ -96,13 +103,25 @@ export const SerialConnect: Component<SerialConnectProps> = (props) => {
|
|||
<Typography>Already connected to <b>{serial.protocol()}</b>.</Typography>
|
||||
</Stack>
|
||||
</Typography>
|
||||
<Button size="small" variant="contained" color="error" onClick={handleDisconnect}>Disconnect</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
onClick={handleDisconnect}
|
||||
sx={{ height: 40 }}
|
||||
>
|
||||
Disconnect
|
||||
</Button>
|
||||
</Stack>
|
||||
}
|
||||
>
|
||||
<FormControl
|
||||
ref={popperAnchorRef}
|
||||
sx={{ minWidth: 120 }}
|
||||
sx={{
|
||||
minWidth: 0,
|
||||
width: { xs: 'auto', sm: 160 },
|
||||
flexGrow: { xs: 1, sm: 0 },
|
||||
flexShrink: 1,
|
||||
}}
|
||||
size="small"
|
||||
disabled={serial.readyState() !== SerialReadyState.DISCONNECTED || !serial.transport()}
|
||||
>
|
||||
|
|
@ -138,21 +157,22 @@ export const SerialConnect: Component<SerialConnectProps> = (props) => {
|
|||
</Alert>
|
||||
</PopperWithArrow>
|
||||
|
||||
<Button
|
||||
sx={{ minWidth: 0, padding: '6px' }}
|
||||
variant="outlined"
|
||||
<IconButton
|
||||
color="primary"
|
||||
title="Settings"
|
||||
aria-label="Settings"
|
||||
onClick={(event) => setSettingsAnchor(event.currentTarget)}
|
||||
disabled={serial.readyState() !== SerialReadyState.DISCONNECTED}
|
||||
>
|
||||
<SettingsIcon />
|
||||
</Button>
|
||||
</IconButton>
|
||||
|
||||
<Show when={serial.readyState() === SerialReadyState.DISCONNECTED || serial.readyState() === SerialReadyState.CONNECTING}>
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={serial.readyState() !== SerialReadyState.DISCONNECTED || !serial.transport()}
|
||||
onClick={handleConnect}
|
||||
sx={{ height: 40 }}
|
||||
>
|
||||
<ButtonLoadingText loading={serial.readyState() === SerialReadyState.CONNECTING}>
|
||||
Connect
|
||||
|
|
@ -166,6 +186,7 @@ export const SerialConnect: Component<SerialConnectProps> = (props) => {
|
|||
color="error"
|
||||
disabled={serial.readyState() !== SerialReadyState.CONNECTED}
|
||||
onClick={handleDisconnect}
|
||||
sx={{ height: 40 }}
|
||||
>
|
||||
<ButtonLoadingText loading={serial.readyState() === SerialReadyState.DISCONNECTING}>
|
||||
Disconnect
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export const UnlockBootloaderPage: Component = () => {
|
|||
};
|
||||
|
||||
return (
|
||||
<Box mt={1}>
|
||||
<Box>
|
||||
<PageTitle>Unlock Bootloader</PageTitle>
|
||||
|
||||
<SerialConnect protocol="DWD" />
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ import ArrowUpwardIcon from '@suid/icons-material/ArrowUpward';
|
|||
import ArrowDownwardIcon from '@suid/icons-material/ArrowDownward';
|
||||
import RefreshIcon from '@suid/icons-material/Refresh';
|
||||
import OpenInNewIcon from '@suid/icons-material/OpenInNew';
|
||||
import MemoryIcon from '@suid/icons-material/Memory';
|
||||
import PhoneAndroidIcon from '@suid/icons-material/PhoneAndroid';
|
||||
import { useSerial } from '@/providers/SerialProvider.js';
|
||||
import { SerialReadyState } from '@/workers/endpoints/serial';
|
||||
import { PageTitle } from '@/components/Layout/PageTitle';
|
||||
|
|
@ -336,7 +338,6 @@ export const FileExplorerPage: Component = () => {
|
|||
};
|
||||
|
||||
const switchSource = (_: unknown, value: Source | null): void => {
|
||||
// null when the selected button is clicked again
|
||||
if (value)
|
||||
navigateTo([], value);
|
||||
};
|
||||
|
|
@ -830,61 +831,108 @@ export const FileExplorerPage: Component = () => {
|
|||
<Box>
|
||||
<PageTitle>File Explorer</PageTitle>
|
||||
|
||||
<Box mb={2}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
mb: 1,
|
||||
minWidth: 0,
|
||||
gap: { xs: 2, sm: 1 },
|
||||
flexDirection: { xs: 'column', sm: 'row' },
|
||||
alignItems: { xs: 'stretch', sm: 'center' },
|
||||
}}
|
||||
>
|
||||
<ToggleButtonGroup
|
||||
exclusive
|
||||
size="small"
|
||||
color="primary"
|
||||
value={source()}
|
||||
disabled={isBusy()}
|
||||
aria-label="Source"
|
||||
onChange={switchSource}
|
||||
sx={{
|
||||
width: { xs: '100%', sm: 'auto' },
|
||||
height: 40,
|
||||
flexShrink: 0,
|
||||
'& .MuiToggleButtonGroup-grouped': {
|
||||
flexGrow: { xs: 1, sm: 0 },
|
||||
},
|
||||
}}
|
||||
>
|
||||
<ToggleButton value="phone">Phone</ToggleButton>
|
||||
<ToggleButton value="fullflash">Fullflash</ToggleButton>
|
||||
<ToggleButton value="phone">
|
||||
<PhoneAndroidIcon fontSize="small" />
|
||||
Phone
|
||||
</ToggleButton>
|
||||
<ToggleButton value="fullflash">
|
||||
<MemoryIcon fontSize="small" />
|
||||
Fullflash
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</Box>
|
||||
|
||||
<Box mb={2}>
|
||||
{/* Progress lives next to the connect controls so an active transfer
|
||||
doesn't add a line and shift the file list down */}
|
||||
<Stack direction="row" alignItems="center" flexWrap="wrap" gap={1}>
|
||||
<Show
|
||||
when={source() == 'phone'}
|
||||
fallback={
|
||||
<FullFlashStatusBar
|
||||
fullflash={fullflash()}
|
||||
disk={disk()}
|
||||
disabled={isBusy()}
|
||||
onChange={changeFullflash}
|
||||
onError={showFullflashError}
|
||||
/>
|
||||
}
|
||||
<Show
|
||||
when={source() == 'phone'}
|
||||
fallback={
|
||||
<FullFlashStatusBar
|
||||
fullflash={fullflash()}
|
||||
disk={disk()}
|
||||
disabled={isBusy()}
|
||||
onChange={changeFullflash}
|
||||
onError={showFullflashError}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ObexStatusBar disk={disk()} />
|
||||
</Show>
|
||||
<Show when={transfer()}>{(activeTransfer) =>
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
gap={1}
|
||||
sx={{
|
||||
width: { xs: '100%', sm: 'auto' },
|
||||
minWidth: 0,
|
||||
flexGrow: 1,
|
||||
flexWrap: { xs: 'wrap', sm: 'nowrap' },
|
||||
}}
|
||||
>
|
||||
<ObexStatusBar disk={disk()} />
|
||||
</Show>
|
||||
<Show when={transfer()}>
|
||||
<Stack direction="row" alignItems="center" gap={1} sx={{ minWidth: 0, flexGrow: 1 }}>
|
||||
<Typography variant="body2" sx={{ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{transfer()!.kind == 'download' ? 'Downloading' : 'Uploading'}: {transfer()!.name}
|
||||
<Show when={transfer()!.filesTotal}>
|
||||
{' '}({transfer()!.filesDone} / {transfer()!.filesTotal})
|
||||
</Show>
|
||||
</Typography>
|
||||
<Box sx={{ flexGrow: 1, minWidth: 80 }}>
|
||||
<LinearProgress
|
||||
variant={transfer()!.percent >= 0 ? 'determinate' : 'indeterminate'}
|
||||
value={transfer()!.percent >= 0 ? transfer()!.percent : undefined}
|
||||
/>
|
||||
</Box>
|
||||
<Typography variant="caption" sx={{ whiteSpace: 'nowrap' }}>
|
||||
{formatSize(transfer()!.cursor)}{transfer()!.total > 0 ? ` / ${formatSize(transfer()!.total)}` : ''}, {formatSize(transfer()!.speed)}/s
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Show>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
minWidth: 0,
|
||||
order: 1,
|
||||
flex: { xs: '1 1 0', sm: '0 1 auto' },
|
||||
whiteSpace: 'nowrap',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
}}
|
||||
>
|
||||
{activeTransfer().kind == 'download' ? 'Downloading' : 'Uploading'}: {activeTransfer().name}
|
||||
<Show when={activeTransfer().filesTotal}>
|
||||
{' '}({activeTransfer().filesDone} / {activeTransfer().filesTotal})
|
||||
</Show>
|
||||
</Typography>
|
||||
<Box
|
||||
sx={{
|
||||
order: { xs: 3, sm: 2 },
|
||||
width: { xs: '100%', sm: 'auto' },
|
||||
flexGrow: 1,
|
||||
minWidth: 80,
|
||||
}}
|
||||
>
|
||||
<LinearProgress
|
||||
variant={activeTransfer().percent >= 0 ? 'determinate' : 'indeterminate'}
|
||||
value={activeTransfer().percent >= 0 ? activeTransfer().percent : undefined}
|
||||
/>
|
||||
</Box>
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ order: { xs: 2, sm: 3 }, whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{formatSize(activeTransfer().cursor)}{activeTransfer().total > 0 ? ` / ${formatSize(activeTransfer().total)}` : ''}, {formatSize(activeTransfer().speed)}/s
|
||||
</Typography>
|
||||
</Stack>
|
||||
}</Show>
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={2} sx={{ maxWidth: 900 }}>
|
||||
<Stack spacing={2}>
|
||||
<Show when={source() == 'fullflash' && fullflash()}>{(opened) =>
|
||||
<FullFlashNotices info={opened().info} />
|
||||
}</Show>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { Component, createEffect, createMemo, createSignal, onCleanup, Show } from 'solid-js';
|
||||
import { Button, IconButton, Stack, Typography } from '@suid/material';
|
||||
import FileOpenIcon from '@suid/icons-material/FileOpen';
|
||||
import SaveIcon from '@suid/icons-material/Save';
|
||||
import { Box, Button, IconButton, Stack } from '@suid/material';
|
||||
import CloseIcon from '@suid/icons-material/Close';
|
||||
import InsertDriveFileIcon from '@suid/icons-material/InsertDriveFile';
|
||||
import FileOpenIcon from '@suid/icons-material/FileOpen';
|
||||
import SaveOutlinedIcon from '@suid/icons-material/SaveOutlined';
|
||||
import { ButtonLoadingText } from '@/components/UI/ButtonLoadingText';
|
||||
import { useApp } from '@/providers/AppProvider';
|
||||
import { downloadBlob } from '@/utils';
|
||||
|
|
@ -22,7 +23,6 @@ interface FullFlashStatusBarProps {
|
|||
export const FullFlashStatusBar: Component<FullFlashStatusBarProps> = (props) => {
|
||||
const app = useApp();
|
||||
const [isOpening, setIsOpening] = createSignal(false);
|
||||
let fileInputRef!: HTMLInputElement;
|
||||
|
||||
// Asks before changes that were not saved are lost
|
||||
const close = (): boolean => {
|
||||
|
|
@ -62,7 +62,7 @@ export const FullFlashStatusBar: Component<FullFlashStatusBarProps> = (props) =>
|
|||
const parts = [info.deviceName, info.imei && `IMEI ${info.imei}`, info.platform];
|
||||
if (props.disk)
|
||||
parts.push(formatFreeSpace(props.disk));
|
||||
return parts.filter(Boolean).join(" · ");
|
||||
return parts.filter(Boolean).join(' · ');
|
||||
});
|
||||
|
||||
// In the title bar, over the phone's connection, which shows again once the fullflash is closed or
|
||||
|
|
@ -71,48 +71,81 @@ export const FullFlashStatusBar: Component<FullFlashStatusBarProps> = (props) =>
|
|||
onCleanup(() => app.setFileStatus(undefined));
|
||||
|
||||
return (
|
||||
<Stack direction="row" alignItems="center" flexWrap="wrap" gap={1} sx={{ minWidth: 0, flexGrow: 1 }}>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<FileOpenIcon />}
|
||||
disabled={props.disabled || isOpening()}
|
||||
onClick={() => fileInputRef.click()}
|
||||
>
|
||||
<ButtonLoadingText loading={isOpening()}>Open fullflash</ButtonLoadingText>
|
||||
</Button>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
aria-label="Fullflash"
|
||||
hidden
|
||||
onChange={(e) => {
|
||||
const file = e.currentTarget.files?.[0];
|
||||
e.currentTarget.value = "";
|
||||
if (file)
|
||||
void open(file);
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
gap={1}
|
||||
sx={{ width: { xs: '100%', sm: 'auto' }, minWidth: 0, flexGrow: 1 }}
|
||||
>
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
gap={0.5}
|
||||
sx={{
|
||||
minWidth: 0,
|
||||
flex: { xs: '1 1 0', sm: '0 1 auto' },
|
||||
}}
|
||||
/>
|
||||
<Show when={props.fullflash}>{(opened) =>
|
||||
<>
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<SaveIcon />}
|
||||
disabled={props.disabled || !opened().isModified()}
|
||||
onClick={() => void save(opened())}
|
||||
>
|
||||
Save fullflash
|
||||
</Button>
|
||||
<Typography variant="body2" sx={{ flex: '1 1 8em', overflowWrap: 'anywhere' }}>
|
||||
{opened().fileName}
|
||||
</Typography>
|
||||
>
|
||||
<Button
|
||||
component="label"
|
||||
variant={props.fullflash ? 'text' : 'contained'}
|
||||
startIcon={props.fullflash ? <InsertDriveFileIcon /> : <FileOpenIcon />}
|
||||
title={props.fullflash?.fileName}
|
||||
disabled={props.disabled || isOpening()}
|
||||
sx={{
|
||||
height: 40,
|
||||
minWidth: 0,
|
||||
flexGrow: 1,
|
||||
textTransform: 'none',
|
||||
}}
|
||||
>
|
||||
<Show
|
||||
when={props.fullflash}
|
||||
fallback={<ButtonLoadingText loading={isOpening()}>Open fullflash</ButtonLoadingText>}
|
||||
>{(opened) =>
|
||||
<Box
|
||||
component="span"
|
||||
sx={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{opened().fileName}
|
||||
</Box>
|
||||
}</Show>
|
||||
<input
|
||||
type="file"
|
||||
aria-label="Fullflash"
|
||||
hidden
|
||||
disabled={props.disabled || isOpening()}
|
||||
onChange={(e) => {
|
||||
const file = e.currentTarget.files?.[0];
|
||||
e.currentTarget.value = '';
|
||||
if (file)
|
||||
void open(file);
|
||||
}}
|
||||
/>
|
||||
</Button>
|
||||
<Show when={props.fullflash}>
|
||||
<IconButton
|
||||
title="Close fullflash"
|
||||
aria-label="Close fullflash"
|
||||
disabled={props.disabled}
|
||||
onClick={close}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</>
|
||||
</Show>
|
||||
</Stack>
|
||||
<Show when={props.fullflash}>{(opened) =>
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<SaveOutlinedIcon />}
|
||||
title="Save fullflash"
|
||||
aria-label="Save fullflash"
|
||||
color="primary"
|
||||
disabled={props.disabled || !opened().isModified()}
|
||||
onClick={() => void save(opened())}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
}</Show>
|
||||
</Stack>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const FlasherPage: Component = () => {
|
|||
const deviceModeLocked = createMemo(() => serial.readyState() !== SerialReadyState.DISCONNECTED);
|
||||
|
||||
return (
|
||||
<Stack sx={{ p: 2, maxWidth: 1100, mx: 'auto' }} spacing={2} alignItems="flex-start">
|
||||
<Stack sx={{ maxWidth: 1100, mx: 'auto' }} spacing={2} alignItems="flex-start">
|
||||
<PageTitle>Flasher/Patcher</PageTitle>
|
||||
<Typography variant="body2" color="text.secondary" pb={2}>
|
||||
A reimplementation of V_KLay.
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ export const MemoryDumperPage: Component = () => {
|
|||
};
|
||||
|
||||
return (
|
||||
<Box mt={1}>
|
||||
<Box>
|
||||
<PageTitle>Memory Dumper</PageTitle>
|
||||
<SerialConnect protocol={protocol} />
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ export class FileExplorer {
|
|||
}
|
||||
|
||||
fileNameBesideSave(): Promise<string | null> {
|
||||
return this.page.getByRole('button', { name: 'Save fullflash' }).locator('xpath=following-sibling::*[1]').textContent();
|
||||
return this.page.getByRole('button', { name: 'Save fullflash' }).locator('xpath=preceding-sibling::*[1]').textContent();
|
||||
}
|
||||
|
||||
async enter(name: string): Promise<void> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue