mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-17 13:23:42 +08:00
- Introduced a new field `custom_phone_number` in the CardPolicy model and database schema. - Updated the API to handle custom phone number input, including validation and normalization. - Modified the CardPolicyPanel component to allow users to set and save a custom phone number. - Enhanced the settings API to include the custom phone number in responses and updates. - Added tests to ensure the correct functionality of custom phone number handling. - Removed hardcoded environment variable for VOCAT_ADDR in service files.
72 lines
2.7 KiB
TypeScript
72 lines
2.7 KiB
TypeScript
import { useState } from "react";
|
|
import { OverviewNetworkCard } from "./OverviewNetworkCard";
|
|
import { OverviewVowifiCard } from "./OverviewVowifiCard";
|
|
import { OverviewSimPanel } from "./OverviewSimPanel";
|
|
import { OverviewNetworkPanel } from "./OverviewNetworkPanel";
|
|
import { OverviewTrafficChart } from "./OverviewTrafficChart";
|
|
import { OperatorSelectionDialog } from "./OperatorSelectionDialog";
|
|
import type { DeviceDetail } from "./types";
|
|
import { useI18n } from "../../lib/i18n";
|
|
import { isVoWiFiInUse } from "./shared";
|
|
|
|
export interface DeviceOverviewTabProps {
|
|
device: DeviceDetail;
|
|
simOperatorDisplay: string;
|
|
customPhoneNumber?: string;
|
|
trafficSpeedRx: string;
|
|
trafficSpeedTx: string;
|
|
trafficMinuteRx: string;
|
|
trafficMinuteTx: string;
|
|
e911Starting: boolean;
|
|
onSetupE911: () => void;
|
|
onRefresh: () => void;
|
|
}
|
|
|
|
export function DeviceOverviewTab(props: DeviceOverviewTabProps) {
|
|
const { t } = useI18n();
|
|
const [operatorOpen, setOperatorOpen] = useState(false);
|
|
const { device } = props;
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
|
<div className="ui-panel-muted p-4">
|
|
<div className="mb-3 text-xs font-bold uppercase tracking-wider text-gray-500">{t("运行状态")}</div>
|
|
{isVoWiFiInUse(device) ? (
|
|
<OverviewVowifiCard device={device} />
|
|
) : (
|
|
<OverviewNetworkCard device={device} onOpenOperatorSelection={() => setOperatorOpen(true)} />
|
|
)}
|
|
</div>
|
|
<OverviewSimPanel
|
|
device={device}
|
|
simOperatorDisplay={props.simOperatorDisplay}
|
|
customPhoneNumber={props.customPhoneNumber}
|
|
e911Starting={props.e911Starting}
|
|
onSetupE911={props.onSetupE911}
|
|
/>
|
|
<OverviewNetworkPanel
|
|
device={device}
|
|
trafficMinuteRx={props.trafficMinuteRx}
|
|
trafficMinuteTx={props.trafficMinuteTx}
|
|
trafficSpeedRx={props.trafficSpeedRx}
|
|
trafficSpeedTx={props.trafficSpeedTx}
|
|
/>
|
|
</div>
|
|
{device.developerEnabled && device.networkEnabled && device.id ? <OverviewTrafficChart deviceId={device.id} /> : null}
|
|
{device?.id ? (
|
|
<OperatorSelectionDialog
|
|
open={operatorOpen}
|
|
deviceId={device.id}
|
|
scanBlockedReason={
|
|
device.flightMode || device.modem?.operatingMode === 0 || device.modem?.operatingMode === 4
|
|
? t("运营商扫描需要开启蜂窝射频;请先关闭飞行模式,再手动开始扫描。")
|
|
: ""
|
|
}
|
|
onClose={() => setOperatorOpen(false)}
|
|
onUpdated={props.onRefresh}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|