mirror of https://github.com/Fabio286/antares.git
feat: option to select schema in query tabs
This commit is contained in:
parent
0a9983d30d
commit
a73a2f483e
|
@ -21,11 +21,16 @@ export default {
|
|||
name: 'WorkspaceEmptyState',
|
||||
computed: {
|
||||
...mapGetters({
|
||||
applicationTheme: 'settings/getApplicationTheme'
|
||||
})
|
||||
applicationTheme: 'settings/getApplicationTheme',
|
||||
getWorkspace: 'workspaces/getWorkspace',
|
||||
selectedWorkspace: 'workspaces/getSelected'
|
||||
}),
|
||||
workspace () {
|
||||
return this.getWorkspace(this.selectedWorkspace);
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.changeBreadcrumbs({});
|
||||
this.changeBreadcrumbs({ schema: this.workspace.breadcrumbs.schema });
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
:auto-focus="true"
|
||||
:value.sync="query"
|
||||
:workspace="workspace"
|
||||
:schema="schema"
|
||||
:schema="breadcrumbsSchema"
|
||||
:is-selected="isSelected"
|
||||
:height="editorHeight"
|
||||
/>
|
||||
|
@ -86,12 +86,16 @@
|
|||
<div v-if="affectedCount">
|
||||
{{ $t('message.affectedRows') }}: <b>{{ affectedCount }}</b>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.breadcrumbs.schema"
|
||||
class="d-flex"
|
||||
:title="$t('word.schema')"
|
||||
>
|
||||
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ workspace.breadcrumbs.schema }}</b>
|
||||
<div class="input-group" :title="$t('word.schema')">
|
||||
<i class="input-group-addon addon-sm mdi mdi-24px mdi-database" />
|
||||
<select v-model="selectedSchema" class="form-select select-sm text-bold">
|
||||
<option :value="null">
|
||||
{{ $t('message.noSchema') }}
|
||||
</option>
|
||||
<option v-for="schemaName in databaseSchemas" :key="schemaName">
|
||||
{{ schemaName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -142,6 +146,7 @@ export default {
|
|||
lastQuery: '',
|
||||
isQuering: false,
|
||||
results: [],
|
||||
selectedSchema: null,
|
||||
resultsCount: 0,
|
||||
durationsCount: 0,
|
||||
affectedCount: 0,
|
||||
|
@ -156,9 +161,15 @@ export default {
|
|||
workspace () {
|
||||
return this.getWorkspace(this.connection.uid);
|
||||
},
|
||||
schema () {
|
||||
breadcrumbsSchema () {
|
||||
return this.workspace.breadcrumbs.schema;
|
||||
},
|
||||
databaseSchemas () {
|
||||
return this.workspace.structure.reduce((acc, curr) => {
|
||||
acc.push(curr.name);
|
||||
return acc;
|
||||
}, []);
|
||||
},
|
||||
isWorkspaceSelected () {
|
||||
return this.workspace.uid === this.selectedWorkspace;
|
||||
}
|
||||
|
@ -166,12 +177,16 @@ export default {
|
|||
watch: {
|
||||
isSelected (val) {
|
||||
if (val)
|
||||
this.changeBreadcrumbs({ schema: this.schema, query: `Query #${this.tab.index}` });
|
||||
this.changeBreadcrumbs({ schema: this.selectedSchema, query: `Query #${this.tab.index}` });
|
||||
},
|
||||
selectedSchema () {
|
||||
this.changeBreadcrumbs({ schema: this.selectedSchema, query: `Query #${this.tab.index}` });
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.query = this.tab.content;
|
||||
this.changeBreadcrumbs({ schema: this.schema, query: `Query #${this.tab.index}` });
|
||||
this.selectedSchema = this.breadcrumbsSchema;
|
||||
this.changeBreadcrumbs({ schema: this.selectedSchema, query: `Query #${this.tab.index}` });
|
||||
|
||||
window.addEventListener('keydown', this.onKey);
|
||||
},
|
||||
|
@ -205,7 +220,7 @@ export default {
|
|||
try { // Query Data
|
||||
const params = {
|
||||
uid: this.connection.uid,
|
||||
schema: this.schema,
|
||||
schema: this.selectedSchema,
|
||||
query
|
||||
};
|
||||
|
||||
|
@ -314,8 +329,10 @@ export default {
|
|||
align-items: center;
|
||||
height: 42px;
|
||||
|
||||
.workspace-query-buttons {
|
||||
.workspace-query-buttons,
|
||||
.workspace-query-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
|
@ -325,7 +342,7 @@ export default {
|
|||
}
|
||||
|
||||
.workspace-query-info {
|
||||
display: flex;
|
||||
overflow: visible;
|
||||
|
||||
> div + div {
|
||||
padding-left: 0.6rem;
|
||||
|
|
|
@ -225,7 +225,8 @@ module.exports = {
|
|||
enableSsh: 'Enable SSH',
|
||||
pageNumber: 'Page number',
|
||||
duplicateTable: 'Duplicate table',
|
||||
noOpenTabs: 'There are no open tabs, navigate on the left bar or:'
|
||||
noOpenTabs: 'There are no open tabs, navigate on the left bar or:',
|
||||
noSchema: 'No schema'
|
||||
},
|
||||
faker: {
|
||||
address: 'Address',
|
||||
|
|
|
@ -4,7 +4,6 @@ import Schema from '@/ipc-api/Schema';
|
|||
import Users from '@/ipc-api/Users';
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
const tabIndex = [];
|
||||
let lastBreadcrumbs = {};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
@ -503,6 +502,7 @@ export default {
|
|||
schema: null,
|
||||
table: null,
|
||||
trigger: null,
|
||||
triggerFunction: null,
|
||||
procedure: null,
|
||||
function: null,
|
||||
scheduler: null,
|
||||
|
@ -510,16 +510,7 @@ export default {
|
|||
query: null
|
||||
};
|
||||
|
||||
const hasLastChildren = Object.keys(lastBreadcrumbs).filter(b => b !== 'schema').some(b => lastBreadcrumbs[b]);
|
||||
const hasChildren = Object.keys(payload).filter(b => b !== 'schema').some(b => payload[b]);
|
||||
|
||||
if (lastBreadcrumbs.schema === payload.schema && hasLastChildren && !hasChildren) return;
|
||||
|
||||
if (lastBreadcrumbs.schema !== payload.schema)
|
||||
Schema.useSchema({ uid: getters.getSelected, schema: payload.schema });
|
||||
|
||||
commit('CHANGE_BREADCRUMBS', { uid: getters.getSelected, breadcrumbs: { ...breadcrumbsObj, ...payload } });
|
||||
lastBreadcrumbs = { ...breadcrumbsObj, ...payload };
|
||||
|
||||
if (payload.schema)
|
||||
commit('ADD_LOADED_SCHEMA', { uid: getters.getSelected, schema: payload.schema });
|
||||
|
|
Loading…
Reference in New Issue