@@ -43,6 +43,12 @@ function error(e) {
43
43
44
44
updateStatus ( 'error' , `Error: ${ e . message } ` ) ;
45
45
46
+ // Clear loading spinner in the current tab when an error occurs
47
+ const tabOutputElm = document . querySelector ( `#${ currentTabId } .results-content` ) ;
48
+ if ( tabOutputElm ) {
49
+ tabOutputElm . innerHTML = `<div class="no-results error-result">Query failed: ${ e . message } </div>` ;
50
+ }
51
+
46
52
setTimeout ( ( ) => {
47
53
errorElm . style . opacity = 0 ;
48
54
setTimeout ( ( ) => {
@@ -102,7 +108,7 @@ function execute(commands, tabId = currentTabId) {
102
108
const executionTime = toc ( "Executing SQL" ) ;
103
109
104
110
if ( ! results ) {
105
- error ( { message : event . data . error } ) ;
111
+ error ( { message : event . data . error || "Unknown error occurred" } ) ;
106
112
return ;
107
113
}
108
114
@@ -125,6 +131,11 @@ function execute(commands, tabId = currentTabId) {
125
131
}
126
132
127
133
worker . postMessage ( { action : 'exec' , sql : commands } ) ;
134
+
135
+ // Set up error handling for the worker
136
+ worker . onerror = function ( e ) {
137
+ error ( e ) ;
138
+ } ;
128
139
}
129
140
130
141
// Create an HTML table
@@ -172,7 +183,11 @@ function execEditorContents() {
172
183
createNewTab ( ) ;
173
184
}
174
185
175
- execute ( editor . getValue ( ) + ';' ) ;
186
+ try {
187
+ execute ( editor . getValue ( ) + ';' ) ;
188
+ } catch ( e ) {
189
+ error ( e ) ;
190
+ }
176
191
177
192
// Add visual feedback for button click
178
193
execBtn . classList . add ( 'active' ) ;
@@ -298,6 +313,7 @@ function showNotification(message) {
298
313
// Initialize resizable panels
299
314
function initResizer ( ) {
300
315
const editorPanel = document . querySelector ( '.editor-panel' ) ;
316
+ const isMobileView = window . matchMedia ( '(max-width: 768px)' ) . matches ;
301
317
302
318
panelResizerElm . addEventListener ( 'mousedown' , function ( e ) {
303
319
isResizing = true ;
@@ -312,7 +328,7 @@ function initResizer() {
312
328
let newWidth ;
313
329
314
330
// Check if we're in mobile view (flexbox column)
315
- const isMobileView = window . getComputedStyle ( document . querySelector ( '.app-container' ) ) . flexDirection === 'column' ;
331
+ const isMobileView = window . matchMedia ( '(max-width: 768px)' ) . matches ;
316
332
317
333
if ( isMobileView ) {
318
334
// In mobile view, resize height instead of width
@@ -341,6 +357,15 @@ function initResizer() {
341
357
panelResizerElm . classList . remove ( 'active' ) ;
342
358
}
343
359
} ) ;
360
+
361
+ // Set initial width/height based on view
362
+ if ( isMobileView ) {
363
+ editorPanel . style . height = '50%' ;
364
+ editorPanel . style . width = '' ;
365
+ } else {
366
+ editorPanel . style . width = '50%' ;
367
+ editorPanel . style . height = '' ;
368
+ }
344
369
}
345
370
346
371
// Initialize tabs
@@ -368,6 +393,12 @@ function initTabs() {
368
393
}
369
394
}
370
395
} ) ;
396
+
397
+ // Initialize the first tab
398
+ const firstTab = document . querySelector ( '.tab[data-tab="tab1"]' ) ;
399
+ if ( firstTab ) {
400
+ setActiveTab ( 'tab1' ) ;
401
+ }
371
402
}
372
403
373
404
// Create a new results tab
@@ -535,116 +566,23 @@ window.addEventListener('resize', function() {
535
566
}
536
567
} ) ;
537
568
538
- // Add CSS for new elements
539
- const style = document . createElement ( 'style' ) ;
540
- style . textContent = `
541
- .loading {
542
- display: flex;
543
- align-items: center;
544
- justify-content: center;
545
- flex-direction: column;
546
- height: 100px;
547
- color: rgba(255, 255, 255, 0.7);
548
- }
549
-
550
- .spinner {
551
- width: 30px;
552
- height: 30px;
553
- border: 3px solid rgba(79, 190, 255, 0.3);
554
- border-radius: 50%;
555
- border-top-color: #4fbeff;
556
- animation: spin 1s ease-in-out infinite;
557
- margin-bottom: 15px;
558
- }
559
-
560
- @keyframes spin {
561
- to { transform: rotate(360deg); }
562
- }
563
-
564
- .table-wrapper {
565
- margin-bottom: 20px;
566
- }
567
-
568
- .table-caption {
569
- color: rgba(255, 255, 255, 0.6);
570
- font-size: 0.85em;
571
- margin-bottom: 8px;
572
- text-align: right;
573
- }
574
-
575
- .no-results {
576
- color: rgba(255, 255, 255, 0.5);
577
- text-align: center;
578
- padding: 30px;
579
- }
580
-
581
- .notification {
582
- position: fixed;
583
- bottom: -60px;
584
- left: 50%;
585
- transform: translateX(-50%);
586
- background: rgba(40, 60, 80, 0.9);
587
- color: #fff;
588
- padding: 12px 20px;
589
- border-radius: 8px;
590
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
591
- transition: bottom 0.3s ease;
592
- z-index: 1000;
593
- border-left: 3px solid #4fbeff;
594
- }
595
-
596
- .notification.show {
597
- bottom: 20px;
598
- }
599
-
600
- .button.active {
601
- transform: translateY(1px);
602
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) inset;
603
- }
604
-
605
- .results-header, .editor-header {
606
- display: flex;
607
- justify-content: space-between;
608
- align-items: center;
609
- margin-bottom: 8px;
610
- color: rgba(255, 255, 255, 0.7);
611
- font-weight: 500;
612
- }
613
-
614
- .actions {
615
- display: flex;
616
- flex-wrap: wrap;
617
- margin: 15px 0;
618
- }
619
-
620
- .github-corner:hover .octo-arm {
621
- animation: octocat-wave 560ms ease-in-out;
622
- }
623
-
624
- @keyframes octocat-wave {
625
- 0%, 100% { transform: rotate(0); }
626
- 20%, 60% { transform: rotate(-25deg); }
627
- 40%, 80% { transform: rotate(10deg); }
628
- }
629
-
630
- @media (max-width: 500px) {
631
- .github-corner:hover .octo-arm {
632
- animation: none;
633
- }
634
- .github-corner .octo-arm {
635
- animation: octocat-wave 560ms ease-in-out;
636
- }
637
- }
638
- ` ;
639
- document . head . appendChild ( style ) ;
640
-
641
569
// Add keyboard shortcuts info
642
570
document . addEventListener ( 'DOMContentLoaded' , function ( ) {
643
571
const editorHeader = document . querySelector ( '.editor-header' ) ;
644
572
if ( editorHeader ) {
645
573
const shortcuts = document . createElement ( 'div' ) ;
646
574
shortcuts . className = 'shortcuts' ;
647
- shortcuts . innerHTML = '<span title="Execute: Ctrl/Cmd+Enter, Save: Ctrl/Cmd+S">Keyboard shortcuts</span>' ;
575
+ shortcuts . innerHTML = `
576
+ <span title="Execute: Ctrl/Cmd+Enter">
577
+ <span class="shortcut-key">Ctrl+Enter</span>
578
+ </span>
579
+ <span title="Save DB: Ctrl/Cmd+S">
580
+ <span class="shortcut-key">Ctrl+S</span>
581
+ </span>
582
+ <span title="Toggle History: Ctrl+Space">
583
+ <span class="shortcut-key">Ctrl+Space</span>
584
+ </span>
585
+ ` ;
648
586
editorHeader . appendChild ( shortcuts ) ;
649
587
}
650
588
} ) ;
0 commit comments