Skip to content

Commit

Permalink
fix balloon
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy committed Jun 16, 2024
1 parent eddba96 commit ee76b31
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions packages/server/client/balloon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ let timer = null;
let printer = null;

async function printBalloon(doc, lang) {
const status = (doc.total ? Object.keys(doc.total).map(async (k) =>
`- ${k}: ${lang === 'zh' ? await convertToChinese(doc.total[k].color) : doc.total[k].color}`).join('\n') : 'N/A');
const bReceipt = receiptText(
doc.balloonid,
doc.location ? doc.location : 'N/A',
doc.problem,
lang === 'zh' ? await convertToChinese(doc.contestproblem.color) : doc.contestproblem.color,
doc.awards ? doc.awards : 'N/A',
doc.team,
doc.total ? Object.keys(doc.total).map(async (k) =>
`- ${k}: ${lang === 'zh' ? await convertToChinese(doc.total[k].color) : doc.total[k].color}`).join('\n') : 'N/A',
status,
lang,
);
printer = await checkReceiptStatus(printer);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/utils/receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function checkReceiptStatus(printer) {
printer: printer.printer,
info: fs.readFileSync(`/sys/class/usbmisc/${lp}/device/ieee1284_id`, 'utf8').trim(),
};
if (!oldPrinter || oldPrinter.info === printer.info) return printer;
if (!oldPrinter?.info || oldPrinter.info === printer.info) return printer;
logger.info('Printer changed:', printer.printer, printer.info);
const usbDevices = fs.readdirSync('/dev/usb');
for (const f of usbDevices) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/components/BalloonsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function BalloonsClient({ clients, refresh }) {
{clients.map((item) => (
<Accordion.Item key={item.id} value={item.name}>
<Accordion.Control
icon={(<Tooltip label={item.updateAt || item.updateAt > new Date().getTime() - 1000 * 60 ? 'Online' : 'Offline'}>
icon={(<Tooltip label={item.updateAt && item.updateAt > new Date().getTime() - 1000 * 60 ? 'Online' : 'Offline'}>
<ThemeIcon radius="xl" size="sm" color={item.updateAt ? 'green' : 'red'}>
{ item.updateAt ? (<IconCheck />) : (<IconX />)}
</ThemeIcon>
Expand Down
20 changes: 10 additions & 10 deletions packages/ui/app/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { useLocation, useNavigate } from 'react-router-dom';
const iconStyle = { width: rem(18), height: rem(18) };

const mainLinks = [
{ link: '/', label: 'Dashboard', icon: <IconHome style={iconStyle} /> },
{ link: '/print', label: 'Print', icon: <IconPrinter style={iconStyle} /> },
{ link: '/balloon', label: 'Balloon', icon: <IconBalloonFilled style={iconStyle} /> },
{ link: '/monitor', label: 'Monitor', icon: <IconDeviceHeartMonitor style={iconStyle} /> },
{ link: '/commands', label: 'Commands', icon: <IconDeviceHeartMonitor style={iconStyle} /> },
{ link: '/', label: <Text visibleFrom="md">Dashboard</Text>, icon: <IconHome style={iconStyle} /> },
{ link: '/print', label: <Text visibleFrom="md">Print</Text>, icon: <IconPrinter style={iconStyle} /> },
{ link: '/balloon', label: <Text visibleFrom="md">Balloon</Text>, icon: <IconBalloonFilled style={iconStyle} /> },
{ link: '/monitor', label: <Text visibleFrom="md">Monitor</Text>, icon: <IconDeviceHeartMonitor style={iconStyle} /> },
{ link: '/commands', label: <Text visibleFrom="md">Commands</Text>, icon: <IconDeviceHeartMonitor style={iconStyle} /> },
];

export function Header() {
Expand All @@ -33,11 +33,11 @@ export function Header() {
<header>
<Container size="xl">
<Group justify="space-between" h="100%" px="md">
<Title order={4}>Hydro/XCPC-TOOLS</Title>

<Group visibleFrom="sm">
<Text>{window.Context.contest.name}</Text>
</Group>
<Title order={3}>
Hydro/XCPC-TOOLS
<Text hiddenFrom="xl">{window.Context.contest.id}</Text>
<Text visibleFrom="xl">{window.Context.contest.name}</Text>
</Title>

<Group h="100%" gap={0} visibleFrom="sm">
<Tabs
Expand Down

0 comments on commit ee76b31

Please sign in to comment.