@@ -8,12 +8,13 @@ a-card.editor-card(:bordered="false")
8
8
:disabled ="isButtonDisabled || explainQueryRunning"
9
9
@click ="runPartQuery()"
10
10
)
11
- a-popover( position ="bl" content-class ="code-tooltip" : content= "currentStatement" )
12
- a-space( :size ="4" )
13
- icon-loading( v-if ="secondaryCodeRunning" spin )
14
- icon-play-arrow( v-else )
15
- div {{ $t('dashboard.runQuery') + (queryType === 'sql' && currentQueryNumber ? ' #' + currentQueryNumber : '') }}
16
- icon-close-circle-fill.icon-16 ( v-if ="secondaryCodeRunning" )
11
+ a-tooltip( position ="left" content ="Ctrl + Enter" )
12
+ a-popover( position ="bl" content-class ="code-tooltip" : content= "currentStatement" )
13
+ a-space( :size ="4" )
14
+ icon-loading( v-if ="secondaryCodeRunning" spin )
15
+ icon-play-arrow( v-else )
16
+ div {{ $t('dashboard.runQuery') + (queryType === 'sql' && currentQueryNumber ? ' #' + currentQueryNumber : '') }}
17
+ icon-close-circle-fill.icon-16 ( v-if ="secondaryCodeRunning" )
17
18
template( #icon )
18
19
icon-down
19
20
template( #content )
@@ -47,17 +48,24 @@ a-card.editor-card(:bordered="false")
47
48
template( #icon )
48
49
icon-import
49
50
| {{ $t('dashboard.importExplain') }}
50
- a-button (
51
+ a-tooltip (
51
52
v-if ="queryType === 'sql'"
52
- type = "outline "
53
- :disabled = "isButtonDisabled "
54
- @click = "runQueryAll()"
53
+ position = "br "
54
+ content = "Alt + Enter "
55
+ mini
55
56
)
56
- a-space( :size ="4" )
57
- icon-loading( v-if ="primaryCodeRunning" spin )
58
- icon-play-arrow( v-else )
59
- | {{ $t('dashboard.runAll') }}
60
- icon-close-circle-fill.icon-16 ( v-if ="primaryCodeRunning" )
57
+ a-button( type ="outline" : disabled= "isButtonDisabled" @click ="runQueryAll()" )
58
+ a-space( :size ="4" )
59
+ icon-loading( v-if ="primaryCodeRunning" spin )
60
+ icon-play-arrow( v-else )
61
+ | {{ $t('dashboard.runAll') }}
62
+ icon-close-circle-fill.icon-16 ( v-if ="primaryCodeRunning" )
63
+ a-tooltip( mini position ="right" : content= "$t('dashboard.timeAssistance')" )
64
+ a-button( type ="secondary" @click ="openTimeAssistance" )
65
+ template( #icon )
66
+ svg.icon-18
67
+ use( href ="#time-index" )
68
+ TimeAssistance( ref ="tsRef" : cm= "currentView" )
61
69
.query-select
62
70
a-space( size ="medium" )
63
71
a-tooltip( v-if ="queryType === 'sql'" mini :content ="$t('dashboard.format')" )
@@ -154,7 +162,7 @@ a-card.editor-card(:bordered="false")
154
162
import { acceptCompletion } from ' @codemirror/autocomplete'
155
163
import type { PromForm } from ' @/store/modules/code-run/types'
156
164
import { useStorage } from ' @vueuse/core'
157
- import { sqlFormatter , parseSqlStatements , findStatementAtPosition , debounce } from ' @/utils/sql'
165
+ import { sqlFormatter , parseSqlStatements , findStatementAtPosition } from ' @/utils/sql'
158
166
import { Message } from ' @arco-design/web-vue'
159
167
import fileDownload from ' js-file-download'
160
168
@@ -173,6 +181,8 @@ a-card.editor-card(:bordered="false")
173
181
tabSize: 2 ,
174
182
})
175
183
184
+ const tsRef = ref <InstanceType <typeof import (' ./time-assistance.vue' ).default > | null >(null )
185
+
176
186
const {
177
187
codes,
178
188
queryType,
@@ -185,9 +195,12 @@ a-card.editor-card(:bordered="false")
185
195
clearCode,
186
196
} = useQueryCode ()
187
197
198
+ // Get current active CodeMirror view based on query type
199
+ const currentView = computed (() => {
200
+ return queryType .value === ' sql' ? sqlView .value : promqlView .value
201
+ })
202
+
188
203
const currentSqlPreview = ref (' ' )
189
- const triggerVisible = ref (false )
190
- const rangePickerVisible = ref (false )
191
204
const promForm = reactive <PromForm >({
192
205
time: 5 ,
193
206
step: ' 30s' ,
@@ -206,6 +219,11 @@ a-card.editor-card(:bordered="false")
206
219
207
220
const emit = defineEmits ([' selectExplainTab' ])
208
221
222
+ const openTimeAssistance = () => {
223
+ if (tsRef .value ) {
224
+ tsRef .value ?.open ()
225
+ }
226
+ }
209
227
// Show the import explain modal
210
228
const showImportExplainModal = () => {
211
229
importExplainModalVisible .value = true
@@ -417,28 +435,36 @@ a-card.editor-card(:bordered="false")
417
435
label: ` Last ${value } minutes ` ,
418
436
}))
419
437
420
- // TODO: fix this
421
- const defaultKeymap = [
438
+ const myKeymap = keymap .of ([
422
439
{
423
- key: ' alt-Enter' ,
440
+ key: ` Ctrl-Enter ` ,
441
+ run : () => {
442
+ runPartQuery ()
443
+ return true
444
+ },
445
+ },
446
+ {
447
+ key: ' Alt-Enter' , // Run All
424
448
run : () => {
425
449
runQueryAll ()
450
+ return true
426
451
},
427
452
},
428
453
{
429
- key: ' ctrl-Enter ' ,
454
+ key: ' Ctrl-Shift-; ' , // Time Assistant(Cmd/Ctrl+Shift+;)
430
455
run : () => {
431
- runPartQuery ()
456
+ openTimeAssistance ()
457
+ return true
432
458
},
433
459
},
434
460
{
435
461
key: ' Tab' ,
436
462
run: acceptCompletion ,
437
463
},
438
- ]
464
+ ])
439
465
440
- const extensionsForSql = [... extensions .value .sql , keymap . of ( defaultKeymap as any ) ]
441
- const extensionsForPromql = [... extensions .value .promql , keymap . of ( defaultKeymap as any ) ]
466
+ const extensionsForSql = [myKeymap , ... extensions .value .sql ]
467
+ const extensionsForPromql = [myKeymap , ... extensions .value .promql ]
442
468
const placeholder = ` Paste response from explain analyze format json here. Example format:
443
469
{
444
470
"output": [
0 commit comments