Skip to content

Commit

Permalink
feat: views edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Dec 26, 2020
1 parent dcf469e commit 56f2a27
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/main/ipc-handlers/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ export default (connections) => {
return { status: 'error', response: err.toString() };
}
});

ipcMain.handle('alter-view', async (event, params) => {
try {
await connections[params.uid].alterView(params);
return { status: 'success' };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
};
12 changes: 12 additions & 0 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ export class MySQLClient extends AntaresCore {
return await this.raw(sql);
}

/**
* ALTER VIEW
*
* @returns {Array.<Object>} parameters
* @memberof MySQLClient
*/
async alterView (params) {
const { view } = params;
const sql = `ALTER ALGORITHM = ${view.algorithm} DEFINER=${view.definer} SQL SECURITY ${view.security} VIEW \`${view.name}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
return await this.raw(sql);
}

/**
* SHOW COLLATION
*
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/components/QueryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ export default {
if (this.autoFocus) {
setTimeout(() => {
this.editor.focus();
this.editor.resize();
}, 20);
}
setTimeout(() => {
this.editor.resize();
}, 20);
}
};
</script>
Expand Down
33 changes: 24 additions & 9 deletions src/renderer/components/Workspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
</a>
</li>
<li
v-if="workspace.breadcrumbs.table"
v-if="schemaChild"
class="tab-item"
:class="{'active': selectedTab === 'prop'}"
@click="selectTab({uid: workspace.uid, tab: 'prop'})"
>
<a class="tab-link">
<i class="mdi mdi-18px mdi-tune mr-1" />
<span :title="workspace.breadcrumbs.table">{{ $t('word.properties').toUpperCase() }}: {{ workspace.breadcrumbs.table }}</span>
<span :title="schemaChild">{{ $t('word.properties').toUpperCase() }}: {{ schemaChild }}</span>
</a>
</li>
<li
v-if="workspace.breadcrumbs.table"
v-if="workspace.breadcrumbs.table || workspace.breadcrumbs.view"
class="tab-item"
:class="{'active': selectedTab === 'data'}"
@click="selectTab({uid: workspace.uid, tab: 'data'})"
>
<a class="tab-link">
<i class="mdi mdi-18px mdi-table mr-1" />
<span :title="workspace.breadcrumbs.table">{{ $t('word.data').toUpperCase() }}: {{ workspace.breadcrumbs.table }}</span>
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" />
<span :title="schemaChild">{{ $t('word.data').toUpperCase() }}: {{ schemaChild }}</span>
</a>
</li>
<li
Expand Down Expand Up @@ -66,15 +66,21 @@
</li>
</ul>
<WorkspacePropsTab
v-show="selectedTab === 'prop'"
v-show="selectedTab === 'prop' && workspace.breadcrumbs.table"
:is-selected="selectedTab === 'prop'"
:connection="connection"
:table="workspace.breadcrumbs.table"
/>
<WorkspacePropsTabView
v-show="selectedTab === 'prop' && workspace.breadcrumbs.view"
:is-selected="selectedTab === 'prop'"
:connection="connection"
:view="workspace.breadcrumbs.view"
/>
<WorkspaceTableTab
v-show="selectedTab === 'data'"
:connection="connection"
:table="workspace.breadcrumbs.table"
:table="workspace.breadcrumbs.table || workspace.breadcrumbs.view"
/>
<WorkspaceQueryTab
v-for="tab of queryTabs"
Expand All @@ -94,14 +100,16 @@ import WorkspaceExploreBar from '@/components/WorkspaceExploreBar';
import WorkspaceQueryTab from '@/components/WorkspaceQueryTab';
import WorkspaceTableTab from '@/components/WorkspaceTableTab';
import WorkspacePropsTab from '@/components/WorkspacePropsTab';
import WorkspacePropsTabView from '@/components/WorkspacePropsTabView';
export default {
name: 'Workspace',
components: {
WorkspaceExploreBar,
WorkspaceQueryTab,
WorkspaceTableTab,
WorkspacePropsTab
WorkspacePropsTab,
WorkspacePropsTabView
},
props: {
connection: Object
Expand All @@ -123,7 +131,7 @@ export default {
return this.selectedWorkspace === this.connection.uid;
},
selectedTab () {
if (this.workspace.breadcrumbs.table === null && ['data', 'prop'].includes(this.workspace.selected_tab))
if (this.workspace.breadcrumbs.table === null && this.workspace.breadcrumbs.view === null && ['data', 'prop'].includes(this.workspace.selected_tab))
return this.queryTabs[0].uid;
return this.queryTabs.find(tab => tab.uid === this.workspace.selected_tab) ||
Expand All @@ -133,6 +141,13 @@ export default {
},
queryTabs () {
return this.workspace.tabs.filter(tab => tab.type === 'query');
},
schemaChild () {
for (const key in this.workspace.breadcrumbs) {
if (key === 'schema') continue;
if (this.workspace.breadcrumbs[key]) return this.workspace.breadcrumbs[key];
}
return false;
}
},
async created () {
Expand Down
17 changes: 17 additions & 0 deletions src/renderer/components/WorkspaceExploreBarDatabaseContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<div class="context-element" @click="showCreateTableModal">
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
</div>
<div class="context-element" @click="showCreateTableModal">
<span class="d-flex"><i class="mdi mdi-18px mdi-table-eye text-light pr-1" /> {{ $t('word.view') }}</span>
</div>
<div class="context-element d-none" @click="false">
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $t('word.trigger') }}</span>
</div>
<div class="context-element d-none" @click="false">
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-box pr-1" /> {{ $t('word.storedRoutine') }}</span>
</div>
<div class="context-element d-none" @click="false">
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $t('word.scheduler') }}</span>
</div>
</div>
</div>
<div class="context-element" @click="showEditModal">
Expand Down Expand Up @@ -124,3 +136,8 @@ export default {
}
};
</script>
<style lang="scss" scoped>
.context-submenu {
min-width: 150px !important;
}
</style>
Loading

0 comments on commit 56f2a27

Please sign in to comment.