Skip to content

Commit a067d98

Browse files
authored
Merge pull request #189 from Open-STEM/kq-bugs
Added Busy dialog
2 parents 110f2b0 + d2e109f commit a067d98

7 files changed

Lines changed: 53 additions & 3 deletions

File tree

src/components/dialogs/busydlg.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import XRPBusyImage from '@assets/images/logo_x_rotate_in_place.gif';
2+
3+
type BusyDlgProps = {
4+
title: string;
5+
}
6+
7+
/**
8+
* Busy Dialog component
9+
* @param title
10+
* @returns
11+
*/
12+
function BusyDialog({title}: BusyDlgProps) {
13+
return (
14+
<div className="flex flex-col gap-4 items-center p-4">
15+
<h2 className='text-lg font-bold text-mountain-mist-700 dark:text-mountain-mist-300'>{title}</h2>
16+
<div className="flex flex-col items-center border-shark-800 dark:border-shark-500 dark:bg-shark-950 h-48 rounded-md border p-8 md:w-[500px] xl:w-[600px]">
17+
<img src={XRPBusyImage} alt="busy" className="self-center h-32 w-auto" />
18+
</div>
19+
</div>
20+
)
21+
}
22+
23+
export default BusyDialog;

src/components/navbar.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { fireGoogleUserTree, getUsernameFromEmail } from '@/utils/google-utils';
6565
import XRPDriverInstallDlg from './dialogs/driver-installs';
6666
import powerswitch_standard from '@assets/images/XRP-nonbeta-controller-power.jpg';
6767
import powerswitch_beta from '@assets/images/XRP_Controller-Power.jpg';
68+
import BusyDialog from './dialogs/busydlg';
6869

6970
type NavBarProps = {
7071
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -233,6 +234,16 @@ function NavBar({ layoutref }: NavBarProps) {
233234
}
234235
});
235236

237+
AppMgr.getInstance().on(EventType.EVENT_SHOWBLUETOOTH_CONNECTING, () => {
238+
setDialogContent(<BusyDialog title={t('connecting-bluetooth')} />);
239+
toggleDialog();
240+
});
241+
242+
AppMgr.getInstance().on(EventType.EVENT_HIDE_BLUETOOTH_CONNECTING, () => {
243+
toggleDialog();
244+
setDialogContent(<div />);
245+
});
246+
236247
hasSubscribed = true;
237248
}
238249
});
@@ -805,6 +816,7 @@ function NavBar({ layoutref }: NavBarProps) {
805816
setRunning(false);
806817
setIsStopping(false);
807818
broadcastRunningState(false);
819+
toggleDialog();
808820
AppMgr.getInstance().eventOff(EventType.EVENT_PROGRAM_EXECUTED);
809821
});
810822
}
@@ -918,6 +930,8 @@ function NavBar({ layoutref }: NavBarProps) {
918930
} else {
919931
setIsStopping(true);
920932
CommandToXRPMgr.getInstance().stopProgram();
933+
setDialogContent(<BusyDialog title={t('stopRunningProgram')} />);
934+
toggleDialog();
921935
}
922936
}
923937

src/connections/bluetoothconnection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ConnectionMgr from '@/managers/connectionmgr';
22
import { ConnectionType } from '@/utils/types';
33
import Connection, { ConnectionState } from '@connections/connection';
44
import TableMgr from '@/managers/tablemgr';
5+
import AppMgr, { EventType } from '@/managers/appmgr';
56

67
/**
78
* BluetoothConnection class
@@ -350,7 +351,8 @@ export class BluetoothConnection extends Connection {
350351
})
351352
.then(async (device) => {
352353
this.connLogger.info('Connecting to device...');
353-
//TODO: Put up a spinner until connection is fully complete, including reading the directory.
354+
// show a dialog that the bluetooth is connecting
355+
AppMgr.getInstance().emit(EventType.EVENT_SHOWBLUETOOTH_CONNECTING, 'show-bluetooth-connecting');
354356
this.bleDevice = device;
355357
if (device.gatt?.connected) {
356358
console.log("Reconnecting...");

src/managers/appmgr.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export enum EventType {
4747
EVENT_ALERT = 'alert', // Alert dialog event
4848
EVENT_ISRUNNING = 'is-running', // XRP is running user code
4949
EVENT_LOGIN_STATUS = 'login-status', // Google login status
50-
EVENT_PROGRAM_EXECUTED = 'runstop-complete' // Run/Stop command complete
50+
EVENT_PROGRAM_EXECUTED = 'runstop-complete', // Run/Stop command complete
51+
EVENT_SHOWBLUETOOTH_CONNECTING = 'show-bluetooth-connecting', // Show Bluetooth connecting dialog
52+
EVENT_HIDE_BLUETOOTH_CONNECTING = 'hide-bluetooth-connecting', // Hide Bluetooth connecting dialog
5153
}
5254

5355
type Events = {
@@ -82,6 +84,8 @@ type Events = {
8284
[EventType.EVENT_ISRUNNING]: string;
8385
[EventType.EVENT_LOGIN_STATUS]: string;
8486
[EventType.EVENT_PROGRAM_EXECUTED]: string;
87+
[EventType.EVENT_SHOWBLUETOOTH_CONNECTING]: string;
88+
[EventType.EVENT_HIDE_BLUETOOTH_CONNECTING]: string;
8589
};
8690

8791
/**

src/managers/connectionmgr.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export default class ConnectionMgr {
7575
// Check for plugins after connection is established
7676
await this.pluginMgr.pluginCheck();
7777

78-
//TODO: if this was a bluetooth connection this is where to take down the spinner.
78+
// After successufully connected to the bluetooth, hide the connecting dialog
79+
if (connType === ConnectionType.BLUETOOTH) {
80+
AppMgr.getInstance().emit(EventType.EVENT_HIDE_BLUETOOTH_CONNECTING, 'hide-bluetooth-connecting');
81+
}
7982
}
8083
} else if (state === ConnectionState.Disconnected) {
8184
this.appMgr.emit(

src/utils/i18n/locales/en/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"okButton": "OK",
2424
"cancelButton": "Cancel",
2525
"connections": "Connections",
26+
"connecting-bluetooth": "Connecting via Bluetooth...",
2627
"selectConnection": "Please select your desired connection to begin...",
2728
"usbConnection": "USB Connection",
2829
"bluetoothConnection": "Bluetooth Connection",
@@ -153,6 +154,7 @@
153154
"connectXRP": "CONNECT XRP",
154155
"run": "RUN",
155156
"stop": "STOP",
157+
"stopRunningProgram": "Stop Running Program...",
156158
"aiChat": {
157159
"buddyName": "XRPCode Buddy",
158160
"poweredBy": "Powered by Gemini",

src/utils/i18n/locales/es/es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"okButton": "Aceptar",
2424
"cancelButton": "Cancelar",
2525
"connections": "Conexiones",
26+
"connecting-bluetooth": "Conectando vía Bluetooth...",
2627
"selectConnection": "Por favor seleccione su conexión deseada para comenzar...",
2728
"usbConnection": "Conexión USB",
2829
"bluetoothConnection": "Conexión Bluetooth",
@@ -153,6 +154,7 @@
153154
"connectXRP": "CONECTAR XRP",
154155
"run": "EJECUTAR",
155156
"stop": "DETENER",
157+
"stopRunningProgram": "Detener Programa en Ejecución...",
156158
"aiChat": {
157159
"buddyName": "Compañero de Código XRP",
158160
"poweredBy": "Impulsado por Gemini",

0 commit comments

Comments
 (0)