feat: auto-clear logs on connect
This commit is contained in:
13
App.tsx
13
App.tsx
@@ -128,7 +128,7 @@ const App: React.FC = () => {
|
|||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = `serial-log-${portName.toLowerCase()}-${new Date().toISOString().slice(0,19).replace(/[:T]/g,'-')}.txt`;
|
a.download = `serial-log-${portName.toLowerCase()}-${new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-')}.txt`;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
@@ -140,6 +140,7 @@ const App: React.FC = () => {
|
|||||||
const handleConnectA = async () => {
|
const handleConnectA = async () => {
|
||||||
try {
|
try {
|
||||||
console.log("Connect A Clicked");
|
console.log("Connect A Clicked");
|
||||||
|
setLogsA([]);
|
||||||
await serialA.current.connect(baudRateA);
|
await serialA.current.connect(baudRateA);
|
||||||
setIsConnectedA(true);
|
setIsConnectedA(true);
|
||||||
serialA.current.startReading((data) => {
|
serialA.current.startReading((data) => {
|
||||||
@@ -166,6 +167,7 @@ const App: React.FC = () => {
|
|||||||
const handleConnectB = async () => {
|
const handleConnectB = async () => {
|
||||||
try {
|
try {
|
||||||
console.log("Connect B Clicked");
|
console.log("Connect B Clicked");
|
||||||
|
setLogsB([]);
|
||||||
await serialB.current.connect(baudRateB);
|
await serialB.current.connect(baudRateB);
|
||||||
setIsConnectedB(true);
|
setIsConnectedB(true);
|
||||||
serialB.current.startReading((data) => {
|
serialB.current.startReading((data) => {
|
||||||
@@ -246,16 +248,14 @@ const App: React.FC = () => {
|
|||||||
<div className="flex bg-gray-800 rounded border border-gray-700 ml-2">
|
<div className="flex bg-gray-800 rounded border border-gray-700 ml-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => setViewMode(ViewMode.ASCII)}
|
onClick={() => setViewMode(ViewMode.ASCII)}
|
||||||
className={`px-2 py-0.5 text-[10px] font-bold rounded-l transition-all ${
|
className={`px-2 py-0.5 text-[10px] font-bold rounded-l transition-all ${viewMode === ViewMode.ASCII ? 'bg-gray-600 text-white' : 'text-gray-400 hover:text-white'
|
||||||
viewMode === ViewMode.ASCII ? 'bg-gray-600 text-white' : 'text-gray-400 hover:text-white'
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
ASCII
|
ASCII
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setViewMode(ViewMode.HEX)}
|
onClick={() => setViewMode(ViewMode.HEX)}
|
||||||
className={`px-2 py-0.5 text-[10px] font-bold rounded-r transition-all ${
|
className={`px-2 py-0.5 text-[10px] font-bold rounded-r transition-all ${viewMode === ViewMode.HEX ? 'bg-gray-600 text-white' : 'text-gray-400 hover:text-white'
|
||||||
viewMode === ViewMode.HEX ? 'bg-gray-600 text-white' : 'text-gray-400 hover:text-white'
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
HEX
|
HEX
|
||||||
@@ -288,8 +288,7 @@ const App: React.FC = () => {
|
|||||||
<div className={`flex-1 flex overflow-hidden p-2 md:p-4 gap-2 md:gap-4 ${isDualMode ? 'flex-col md:flex-row' : 'flex-col'}`}>
|
<div className={`flex-1 flex overflow-hidden p-2 md:p-4 gap-2 md:gap-4 ${isDualMode ? 'flex-col md:flex-row' : 'flex-col'}`}>
|
||||||
|
|
||||||
{/* Port A Terminal */}
|
{/* Port A Terminal */}
|
||||||
<div className={`flex flex-col transition-all duration-300 ease-in-out ${
|
<div className={`flex flex-col transition-all duration-300 ease-in-out ${isDualMode
|
||||||
isDualMode
|
|
||||||
? 'w-full h-1/2 md:w-1/2 md:h-full'
|
? 'w-full h-1/2 md:w-1/2 md:h-full'
|
||||||
: 'w-full h-full'
|
: 'w-full h-full'
|
||||||
}`}>
|
}`}>
|
||||||
|
|||||||
Reference in New Issue
Block a user