Skip to content

Commit ee76b31

Browse files
committed
fix balloon
1 parent eddba96 commit ee76b31

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

packages/server/client/balloon.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ let timer = null;
7272
let printer = null;
7373

7474
async function printBalloon(doc, lang) {
75+
const status = (doc.total ? Object.keys(doc.total).map(async (k) =>
76+
`- ${k}: ${lang === 'zh' ? await convertToChinese(doc.total[k].color) : doc.total[k].color}`).join('\n') : 'N/A');
7577
const bReceipt = receiptText(
7678
doc.balloonid,
7779
doc.location ? doc.location : 'N/A',
7880
doc.problem,
7981
lang === 'zh' ? await convertToChinese(doc.contestproblem.color) : doc.contestproblem.color,
8082
doc.awards ? doc.awards : 'N/A',
8183
doc.team,
82-
doc.total ? Object.keys(doc.total).map(async (k) =>
83-
`- ${k}: ${lang === 'zh' ? await convertToChinese(doc.total[k].color) : doc.total[k].color}`).join('\n') : 'N/A',
84+
status,
8485
lang,
8586
);
8687
printer = await checkReceiptStatus(printer);

packages/server/utils/receipt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function checkReceiptStatus(printer) {
4444
printer: printer.printer,
4545
info: fs.readFileSync(`/sys/class/usbmisc/${lp}/device/ieee1284_id`, 'utf8').trim(),
4646
};
47-
if (!oldPrinter || oldPrinter.info === printer.info) return printer;
47+
if (!oldPrinter?.info || oldPrinter.info === printer.info) return printer;
4848
logger.info('Printer changed:', printer.printer, printer.info);
4949
const usbDevices = fs.readdirSync('/dev/usb');
5050
for (const f of usbDevices) {

packages/ui/app/components/BalloonsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function BalloonsClient({ clients, refresh }) {
5959
{clients.map((item) => (
6060
<Accordion.Item key={item.id} value={item.name}>
6161
<Accordion.Control
62-
icon={(<Tooltip label={item.updateAt || item.updateAt > new Date().getTime() - 1000 * 60 ? 'Online' : 'Offline'}>
62+
icon={(<Tooltip label={item.updateAt && item.updateAt > new Date().getTime() - 1000 * 60 ? 'Online' : 'Offline'}>
6363
<ThemeIcon radius="xl" size="sm" color={item.updateAt ? 'green' : 'red'}>
6464
{ item.updateAt ? (<IconCheck />) : (<IconX />)}
6565
</ThemeIcon>

packages/ui/app/components/Header.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { useLocation, useNavigate } from 'react-router-dom';
1212
const iconStyle = { width: rem(18), height: rem(18) };
1313

1414
const mainLinks = [
15-
{ link: '/', label: 'Dashboard', icon: <IconHome style={iconStyle} /> },
16-
{ link: '/print', label: 'Print', icon: <IconPrinter style={iconStyle} /> },
17-
{ link: '/balloon', label: 'Balloon', icon: <IconBalloonFilled style={iconStyle} /> },
18-
{ link: '/monitor', label: 'Monitor', icon: <IconDeviceHeartMonitor style={iconStyle} /> },
19-
{ link: '/commands', label: 'Commands', icon: <IconDeviceHeartMonitor style={iconStyle} /> },
15+
{ link: '/', label: <Text visibleFrom="md">Dashboard</Text>, icon: <IconHome style={iconStyle} /> },
16+
{ link: '/print', label: <Text visibleFrom="md">Print</Text>, icon: <IconPrinter style={iconStyle} /> },
17+
{ link: '/balloon', label: <Text visibleFrom="md">Balloon</Text>, icon: <IconBalloonFilled style={iconStyle} /> },
18+
{ link: '/monitor', label: <Text visibleFrom="md">Monitor</Text>, icon: <IconDeviceHeartMonitor style={iconStyle} /> },
19+
{ link: '/commands', label: <Text visibleFrom="md">Commands</Text>, icon: <IconDeviceHeartMonitor style={iconStyle} /> },
2020
];
2121

2222
export function Header() {
@@ -33,11 +33,11 @@ export function Header() {
3333
<header>
3434
<Container size="xl">
3535
<Group justify="space-between" h="100%" px="md">
36-
<Title order={4}>Hydro/XCPC-TOOLS</Title>
37-
38-
<Group visibleFrom="sm">
39-
<Text>{window.Context.contest.name}</Text>
40-
</Group>
36+
<Title order={3}>
37+
Hydro/XCPC-TOOLS
38+
<Text hiddenFrom="xl">{window.Context.contest.id}</Text>
39+
<Text visibleFrom="xl">{window.Context.contest.name}</Text>
40+
</Title>
4141

4242
<Group h="100%" gap={0} visibleFrom="sm">
4343
<Tabs

0 commit comments

Comments
 (0)