mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: new data tabs
This commit is contained in:
@ -29,7 +29,7 @@ export default (connections) => {
|
|||||||
if (sortParams && sortParams.field && sortParams.dir)
|
if (sortParams && sortParams.field && sortParams.dir)
|
||||||
query.orderBy({ [sortParams.field]: sortParams.dir.toUpperCase() });
|
query.orderBy({ [sortParams.field]: sortParams.dir.toUpperCase() });
|
||||||
|
|
||||||
const result = await query.run({ details: true });
|
const result = await query.run({ details: true, schema });
|
||||||
|
|
||||||
return { status: 'success', response: result };
|
return { status: 'success', response: result };
|
||||||
}
|
}
|
||||||
|
@ -1419,7 +1419,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
name: field.orgName,
|
name: field.orgName,
|
||||||
alias: field.name,
|
alias: field.name,
|
||||||
orgName: field.orgName,
|
orgName: field.orgName,
|
||||||
schema: field.schema,
|
schema: field.schema || args.schema,
|
||||||
table: field.table,
|
table: field.table,
|
||||||
tableAlias: field.table,
|
tableAlias: field.table,
|
||||||
orgTable: field.orgTable,
|
orgTable: field.orgTable,
|
||||||
|
@ -91,7 +91,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a v-if="tab.type === 'temp-data'" class="tab-link">
|
<a
|
||||||
|
v-if="tab.type === 'temp-data'"
|
||||||
|
class="tab-link"
|
||||||
|
@dblclick="openAsDataTab(tab)"
|
||||||
|
>
|
||||||
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" />
|
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" />
|
||||||
<span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`">
|
<span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`">
|
||||||
<span class=" text-italic">{{ tab.table }}</span>
|
<span class=" text-italic">{{ tab.table }}</span>
|
||||||
@ -102,6 +106,18 @@
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a v-if="tab.type === 'data'" class="tab-link">
|
||||||
|
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" />
|
||||||
|
<span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`">
|
||||||
|
{{ tab.table }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="tab-item">
|
<li class="tab-item">
|
||||||
<a
|
<a
|
||||||
@ -164,7 +180,7 @@
|
|||||||
:connection="connection"
|
:connection="connection"
|
||||||
/>
|
/>
|
||||||
<WorkspaceTableTab
|
<WorkspaceTableTab
|
||||||
v-else-if="tab.type==='temp-data'"
|
v-else-if="['temp-data', 'data'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
:is-selected="selectedTab === tab.uid"
|
:is-selected="selectedTab === tab.uid"
|
||||||
@ -307,14 +323,11 @@ export default {
|
|||||||
}),
|
}),
|
||||||
addQueryTab () {
|
addQueryTab () {
|
||||||
this.newTab({ uid: this.connection.uid, type: 'query' });
|
this.newTab({ uid: this.connection.uid, type: 'query' });
|
||||||
|
this.addWheelEvent();
|
||||||
if (!this.hasWheelEvent) {
|
},
|
||||||
this.$refs.tabWrap.addEventListener('wheel', e => {
|
openAsDataTab (tab) {
|
||||||
if (e.deltaY > 0) this.$refs.tabWrap.scrollLeft += 50;
|
this.newTab({ uid: this.connection.uid, schema: tab.schema, table: tab.table, type: 'data' });
|
||||||
else this.$refs.tabWrap.scrollLeft -= 50;
|
this.addWheelEvent();
|
||||||
});
|
|
||||||
this.hasWheelEvent = true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
closeTab (tab) {
|
closeTab (tab) {
|
||||||
if (tab.type === 'query' && this.queryTabs.length === 1) return;
|
if (tab.type === 'query' && this.queryTabs.length === 1) return;
|
||||||
@ -328,6 +341,15 @@ export default {
|
|||||||
},
|
},
|
||||||
hideProcessesModal () {
|
hideProcessesModal () {
|
||||||
this.isProcessesModal = false;
|
this.isProcessesModal = false;
|
||||||
|
},
|
||||||
|
addWheelEvent () {
|
||||||
|
if (!this.hasWheelEvent) {
|
||||||
|
this.$refs.tabWrap.addEventListener('wheel', e => {
|
||||||
|
if (e.deltaY > 0) this.$refs.tabWrap.scrollLeft += 50;
|
||||||
|
else this.$refs.tabWrap.scrollLeft -= 50;
|
||||||
|
});
|
||||||
|
this.hasWheelEvent = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'text-bold': breadcrumbs.schema === database.name && [breadcrumbs.table, breadcrumbs.view].includes(table.name)}"
|
:class="{'text-bold': breadcrumbs.schema === database.name && [breadcrumbs.table, breadcrumbs.view].includes(table.name)}"
|
||||||
@click="selectTable({schema: database.name, table})"
|
@click="selectTable({schema: database.name, table})"
|
||||||
|
@dblclick="openDataTab({schema: database.name, table})"
|
||||||
@contextmenu.prevent="showTableContext($event, table)"
|
@contextmenu.prevent="showTableContext($event, table)"
|
||||||
>
|
>
|
||||||
<a class="table-name">
|
<a class="table-name">
|
||||||
@ -281,8 +282,12 @@ export default {
|
|||||||
this.changeBreadcrumbs({ schema, table: null });
|
this.changeBreadcrumbs({ schema, table: null });
|
||||||
},
|
},
|
||||||
selectTable ({ schema, table }) {
|
selectTable ({ schema, table }) {
|
||||||
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
|
||||||
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' });
|
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' });
|
||||||
|
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
||||||
|
},
|
||||||
|
openDataTab ({ schema, table }) {
|
||||||
|
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'data' });
|
||||||
|
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
||||||
},
|
},
|
||||||
showSchemaContext (event, schema) {
|
showSchemaContext (event, schema) {
|
||||||
this.selectSchema(schema);
|
this.selectSchema(schema);
|
||||||
|
@ -187,7 +187,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
tabUid: 'data',
|
tabUid: 'data', // ???
|
||||||
isQuering: false,
|
isQuering: false,
|
||||||
isPageMenu: false,
|
isPageMenu: false,
|
||||||
results: [],
|
results: [],
|
||||||
|
@ -493,10 +493,22 @@ export default {
|
|||||||
},
|
},
|
||||||
newTab ({ state, commit }, { uid, content, type, autorun, schema, table }) {
|
newTab ({ state, commit }, { uid, content, type, autorun, schema, table }) {
|
||||||
let tabUid;
|
let tabUid;
|
||||||
if (type === 'temp-data') {
|
|
||||||
const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid);
|
const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid);
|
||||||
|
|
||||||
|
if (type === 'temp-data') {
|
||||||
|
const existentTab = workspaceTabs
|
||||||
|
? workspaceTabs.tabs.find(tab =>
|
||||||
|
tab.schema === schema &&
|
||||||
|
tab.table === table &&
|
||||||
|
['temp-data', 'data'].includes(tab.type))
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (existentTab) { // if data tab exists
|
||||||
|
tabUid = existentTab.uid;
|
||||||
|
}
|
||||||
|
else {
|
||||||
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
||||||
if (tempTabs && tempTabs.length) { // id temp table already opened
|
if (tempTabs && tempTabs.length) { // if temp table already opened
|
||||||
for (const tab of tempTabs) {
|
for (const tab of tempTabs) {
|
||||||
commit('REPLACE_TAB', { uid, tab: tab.uid, type, schema, table });
|
commit('REPLACE_TAB', { uid, tab: tab.uid, type, schema, table });
|
||||||
tabUid = tab.uid;
|
tabUid = tab.uid;
|
||||||
@ -507,6 +519,24 @@ export default {
|
|||||||
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table });
|
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (type === 'data') {
|
||||||
|
const existentTab = workspaceTabs
|
||||||
|
? workspaceTabs.tabs.find(tab =>
|
||||||
|
tab.schema === schema &&
|
||||||
|
tab.table === table &&
|
||||||
|
['temp-data', 'data'].includes(tab.type))
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (existentTab) {
|
||||||
|
commit('REPLACE_TAB', { uid, tab: existentTab.uid, type, schema, table });
|
||||||
|
tabUid = existentTab.uid;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tabUid = uidGen('T');
|
||||||
|
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table });
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
tabUid = uidGen('T');
|
tabUid = uidGen('T');
|
||||||
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table });
|
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table });
|
||||||
|
Reference in New Issue
Block a user