Skip to content

Commit 331fe99

Browse files
committed
optimize
1 parent b755f11 commit 331fe99

File tree

9 files changed

+18
-150
lines changed

9 files changed

+18
-150
lines changed

src/components/Iframe.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import hljs from 'highlight.js'
44
import 'highlight.js/scss/vs.scss'
55
import { copyToClipboard } from 'quasar'
66
7-
const props = defineProps(['query', 'queryType'])
7+
const props = defineProps(['query'])
88
99
const showIframeDialog = ref(false)
1010
const iFrameCode = ref('')
@@ -13,8 +13,7 @@ watch(
1313
() => props.query,
1414
() => {
1515
const query = {
16-
query: props.query,
17-
queryType: props.queryType
16+
query: props.query
1817
}
1918
iFrameCode.value = `<iframe src="${window.location.origin}/embed/?session=[${encodeURIComponent(JSON.stringify(query))}]" width="100%" height="500px"></iframe>`
2019
}

src/components/InputPanel.vue

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const GlobalVariables = inject('GlobalVariables')
99
1010
const emits = defineEmits(['run', 'clear', 'editorHeightChanged'])
1111
12-
const props = defineProps(['cypherInput', 'textInput', 'activeTab', 'serveInOutput'])
12+
const props = defineProps(['cypherInput', 'serveInOutput'])
1313
1414
const code = ref()
15-
const tab = ref('')
1615
let cypher = ''
17-
let text = ''
1816
let editor = null
1917
const minHeight = 3
2018
const maxHeight = 10
@@ -36,15 +34,10 @@ const updateEditorHeight = () => {
3634
const runQuery = () => {
3735
const getValue = editor.getValue()
3836
if (getValue !== '') {
39-
emits('run', getValue, tab.value)
40-
if (props.serveInOutput) {
41-
if (tab.value === 'cypher') {
42-
text = ''
43-
}
44-
} else {
37+
emits('run', getValue)
38+
if (!props.serveInOutput) {
4539
editor.setValue('')
4640
cypher = ''
47-
text = ''
4841
}
4942
}
5043
}
@@ -53,48 +46,20 @@ const clearQuery = () => {
5346
if (!props.serveInOutput) {
5447
editor.setValue('')
5548
cypher = ''
56-
text = ''
57-
tab.value = 'cypher'
5849
} else {
5950
emits('clear')
6051
}
6152
}
6253
63-
watch(tab, (newTab, oldTab) => {
64-
if (newTab === 'text' && oldTab === 'cypher') {
65-
cypher = editor.getValue()
66-
editor.setValue(text)
67-
} else if (newTab === 'cypher' && oldTab === 'text') {
68-
text = editor.getValue()
69-
editor.setValue(cypher)
70-
}
71-
monaco.editor.setModelLanguage(editor.getModel(), tab.value)
72-
})
73-
7454
watch(
7555
() => props.cypherInput,
7656
() => {
7757
cypher = props.cypherInput
78-
if (props.activeTab === 'cypher') {
79-
tab.value = 'cypher'
80-
editor.setValue(cypher)
81-
}
82-
}
83-
)
84-
85-
watch(
86-
() => props.textInput,
87-
() => {
88-
text = props.textInput
89-
if (props.activeTab === 'text') {
90-
tab.value = 'text'
91-
editor.setValue(text)
92-
}
58+
editor.setValue(cypher)
9359
}
9460
)
9561
9662
onMounted(() => {
97-
tab.value = 'cypher'
9863
editor = monaco.editor.create(code.value, {
9964
value: '',
10065
language: 'cypher',
@@ -308,12 +273,6 @@ onBeforeUnmount(() => {
308273
309274
<template>
310275
<div class="input-container row">
311-
<!-- <q-tabs v-model="tab" class="input-language-switcher" vertical dense>
312-
<q-tab v-if="!GlobalVariables.disableCypherInput" name="cypher" label="Cypher" />
313-
<q-tab v-if="!GlobalVariables.disableTextInput" name="text" label="Text" disable>
314-
<q-badge>Coming Soon</q-badge>
315-
</q-tab>
316-
</q-tabs> -->
317276
<div ref="code" class="code col q-mr-md q-ml-xs"></div>
318277
<div class="col-auto q-mr-md">
319278
<div class="row q-mb-sm">

src/components/OutputPanel.vue

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,24 @@ import { ref, inject, onMounted } from 'vue'
33
import InputPanel from '@/components/InputPanel.vue'
44
import GraphOutput from '@/components/output/GraphOutput.vue'
55
import TableOutput from '@/components/output/TableOutput.vue'
6-
import ExplanationOutput from '@/components/output/ExplanationOutput.vue'
76
import { version } from '../../package.json'
87
import interact from 'interactjs'
98
import Iframe from '@/components/Iframe.vue'
109
1110
const Neo4jApi = inject('Neo4jApi')
12-
const LlmApi = inject('LlmApi')
1311
const GlobalVariables = inject('GlobalVariables')
1412
1513
const emits = defineEmits(['clear', 'share', 'update'])
1614
17-
const props = defineProps([
18-
'query',
19-
'queryTypeInput',
20-
'disableInput',
21-
'disableTopBar',
22-
'disableResizer'
23-
])
15+
const props = defineProps(['query', 'disableInput', 'disableTopBar', 'disableResizer'])
2416
2517
const cypherQuery = ref('')
26-
const textQuery = ref('')
27-
const queryType = ref('')
2818
const tab = ref('graph')
2919
const loading = ref(false)
3020
const nodes = ref([])
3121
const relationships = ref([])
3222
const rows = ref([])
3323
const columns = ref([])
34-
const explanationText = ref('')
3524
const errorText = ref('')
3625
const outputPanel = ref()
3726
const isFullscreen = ref(false)
@@ -56,35 +45,17 @@ const runCypher = async (cypher) => {
5645
relationships.value = []
5746
rows.value = []
5847
columns.value = []
59-
explanationText.value = []
6048
}
6149
loading.value = false
6250
}
6351
64-
const runLlm = async (text) => {
65-
loading.value = true
66-
const res = await LlmApi.run(text)
67-
cypherQuery.value = res.cypher
68-
explanationText.value = res.explanation
69-
runCypher(cypherQuery.value)
70-
loading.value = false
71-
}
72-
73-
const run = async (queryInput, queryInputType) => {
74-
queryType.value = queryInputType
52+
const run = async (queryInput) => {
7553
errorText.value = ''
7654
tab.value = 'graph'
77-
if (queryType.value === 'cypher') {
78-
cypherQuery.value = queryInput
79-
textQuery.value = ''
80-
runCypher(cypherQuery.value)
81-
} else {
82-
textQuery.value = queryInput
83-
runLlm(textQuery.value)
84-
}
55+
cypherQuery.value = queryInput
56+
runCypher(cypherQuery.value)
8557
emits('update', {
86-
query: queryInput,
87-
queryType: queryInputType
58+
query: queryInput
8859
})
8960
}
9061
@@ -121,7 +92,7 @@ const changeTab = (tabName) => {
12192
}
12293
12394
onMounted(() => {
124-
run(props.query, props.queryTypeInput)
95+
run(props.query)
12596
if (!props.disableResizer) {
12697
interact(outputPanel.value)
12798
.origin('self')
@@ -151,7 +122,7 @@ onMounted(() => {
151122
<q-btn dense flat icon="link" color="white" @click="emits('share')">
152123
<q-tooltip>Share</q-tooltip>
153124
</q-btn>
154-
<Iframe :query="cypherQuery" :query-type="queryType" />
125+
<Iframe :query="cypherQuery" />
155126
<q-btn
156127
dense
157128
flat
@@ -168,8 +139,6 @@ onMounted(() => {
168139
<InputPanel
169140
v-if="!disableInput"
170141
:cypher-input="cypherQuery"
171-
:text-input="textQuery"
172-
:active-tab="queryType"
173142
:serve-in-output="true"
174143
@run="run"
175144
@clear="emits('clear')"
@@ -180,12 +149,6 @@ onMounted(() => {
180149
<q-btn-group outline class="output-tabs q-ml-md q-pt-sm">
181150
<q-btn outline label="Graph" v-if="nodes.length" @click="changeTab('graph')" />
182151
<q-btn outline label="Table" v-if="rows.length" @click="changeTab('table')" />
183-
<q-btn
184-
outline
185-
label="Explanation"
186-
v-if="textQuery !== ''"
187-
@click="changeTab('explanation')"
188-
/>
189152
<q-btn outline label="Error" v-if="errorText !== ''" @click="changeTab('error')" />
190153
</q-btn-group>
191154
<q-tab-panels v-model="tab" vertical class="output-panels">
@@ -200,9 +163,6 @@ onMounted(() => {
200163
<q-tab-panel name="table" v-if="rows.length" class="output-tab-panel">
201164
<TableOutput :rows="rows" :columns="columns" />
202165
</q-tab-panel>
203-
<q-tab-panel name="explanation" v-if="textQuery !== ''" class="output-tab-panel">
204-
<ExplanationOutput :text="explanationText" />
205-
</q-tab-panel>
206166
<q-tab-panel name="error" v-if="errorText !== ''" class="output-tab-panel">
207167
<div class="text-body2 q-pt-xl">{{ errorText }}</div>
208168
</q-tab-panel>

src/components/output/ExplanationOutput.vue

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import App from './App.vue'
55
import router from './router'
66
import { Quasar, Notify } from 'quasar'
77
import { Neo4jApi } from '@/plugins/Neo4jApi'
8-
import { LlmApi } from '@/plugins/LlmApi'
98
import { GlobalVariables } from '@/plugins/GlobalVariables'
109

1110
import '@quasar/extras/roboto-font/roboto-font.css'
@@ -22,7 +21,6 @@ app.use(Quasar, {
2221
}
2322
})
2423
app.use(Neo4jApi)
25-
app.use(LlmApi)
2624
app.use(GlobalVariables)
2725

2826
app.mount('#app')

src/plugins/GlobalVariables.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const GlobalVariables = {
22
install: (app) => {
33
const GlobalVariables = {
4-
disableCypherInput: false,
5-
disableTextInput: true,
64
outputPanelHeight: 580
75
}
86
app.provide('GlobalVariables', GlobalVariables)

src/plugins/LlmApi.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/views/BrowserView.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const queries = ref(route.query.session ? JSON.parse(route.query.session) : [])
1313
const outputPanel = ref()
1414
const outputPanelHeight = ref(`${GlobalVariables.outputPanelHeight}px`)
1515
16-
const runQuery = (query, queryType) => {
16+
const runQuery = (query) => {
1717
const uuid = uid()
18-
queries.value.push({ query, queryType, uuid })
18+
queries.value.push({ query, uuid })
1919
}
2020
2121
const clearQuery = (uuid) => {
@@ -29,16 +29,12 @@ const shareQuery = (query) => {
2929
3030
const updateQuery = (query, uuid) => {
3131
const index = queries.value.findIndex((obj) => obj.uuid === uuid)
32-
if (
33-
queries.value[index].query !== query.query ||
34-
queries.value[index].queryType !== query.queryType
35-
) {
32+
if (queries.value[index].query !== query.query) {
3633
queries.value = queries.value.map((obj) => {
3734
if (obj.uuid === uuid) {
3835
return {
3936
...obj,
40-
query: query.query,
41-
queryType: query.queryType
37+
query: query.query
4238
}
4339
}
4440
return obj
@@ -67,14 +63,13 @@ watch(
6763
<template>
6864
<div class="container">
6965
<div class="browser-input-container">
70-
<InputPanel active-tab="cypher" @run="runQuery" />
66+
<InputPanel @run="runQuery" />
7167
</div>
7268
<div class="browser-output-container">
7369
<div v-for="query in queries" :key="query.uuid">
7470
<OutputPanel
7571
ref="outputPanel"
7672
:query="query.query"
77-
:query-type-input="query.queryType"
7873
:disable-input="false"
7974
:disable-top-bar="false"
8075
:disable-resizer="false"

src/views/EmbedView.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const query = ref(JSON.parse(route.query.session)[0])
1010
<template>
1111
<OutputPanel
1212
:query="query.query"
13-
:query-type-input="query.queryType"
1413
:disable-input="true"
1514
:disable-top-bar="true"
1615
:disable-resizer="true"

0 commit comments

Comments
 (0)