mirror of https://github.com/Fabio286/antares.git
feat: schedulers delete
This commit is contained in:
parent
c0a32c040e
commit
1e7d4ca347
|
@ -88,3 +88,7 @@ This is a roadmap with major features will come in near future.
|
||||||
[Giuseppe Gigliotti](https://github.com/ReverbOD) / [Italian Translation](https://github.com/Fabio286/antares/pull/20)
|
[Giuseppe Gigliotti](https://github.com/ReverbOD) / [Italian Translation](https://github.com/Fabio286/antares/pull/20)
|
||||||
[Mohd-PH](https://github.com/Mohd-PH) / [Arabic Translation](https://github.com/Fabio286/antares/pull/29)
|
[Mohd-PH](https://github.com/Mohd-PH) / [Arabic Translation](https://github.com/Fabio286/antares/pull/29)
|
||||||
[hongkfui](https://github.com/hongkfui) / [Spanish Translation](https://github.com/Fabio286/antares/pull/32)
|
[hongkfui](https://github.com/hongkfui) / [Spanish Translation](https://github.com/Fabio286/antares/pull/32)
|
||||||
|
|
||||||
|
## Reviews
|
||||||
|
|
||||||
|
<a target="_blank" href="https://www.softx64.com/windows/antares-sql-client.html" title="Antares SQL Client review"><img src="https://www.softx64.com/softx64-review.png" alt="Antares SQL Client review" /></a>
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
"AppImage"
|
"AppImage"
|
||||||
],
|
],
|
||||||
"category": "Development"
|
"category": "Development"
|
||||||
|
},
|
||||||
|
"appImage": {
|
||||||
|
"license": "./LICENSE",
|
||||||
|
"category": "Development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electronWebpack": {
|
"electronWebpack": {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import views from './views';
|
||||||
import triggers from './triggers';
|
import triggers from './triggers';
|
||||||
import routines from './routines';
|
import routines from './routines';
|
||||||
import functions from './functions';
|
import functions from './functions';
|
||||||
|
import schedulers from './schedulers';
|
||||||
import updates from './updates';
|
import updates from './updates';
|
||||||
import application from './application';
|
import application from './application';
|
||||||
import database from './database';
|
import database from './database';
|
||||||
|
@ -18,6 +19,7 @@ export default () => {
|
||||||
triggers(connections);
|
triggers(connections);
|
||||||
routines(connections);
|
routines(connections);
|
||||||
functions(connections);
|
functions(connections);
|
||||||
|
schedulers(connections);
|
||||||
database(connections);
|
database(connections);
|
||||||
users(connections);
|
users(connections);
|
||||||
updates();
|
updates();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { ipcMain } from 'electron';
|
||||||
|
|
||||||
|
export default (connections) => {
|
||||||
|
ipcMain.handle('get-scheduler-informations', async (event, params) => {
|
||||||
|
try {
|
||||||
|
const result = await connections[params.uid].getEventInformations(params);
|
||||||
|
return { status: 'success', response: result };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return { status: 'error', response: err.toString() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('drop-scheduler', async (event, params) => {
|
||||||
|
try {
|
||||||
|
await connections[params.uid].dropEvent(params);
|
||||||
|
return { status: 'success' };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return { status: 'error', response: err.toString() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('alter-scheduler', async (event, params) => {
|
||||||
|
try {
|
||||||
|
await connections[params.uid].alterEvent(params);
|
||||||
|
return { status: 'success' };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return { status: 'error', response: err.toString() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('create-scheduler', async (event, params) => {
|
||||||
|
try {
|
||||||
|
await connections[params.uid].createEvent(params);
|
||||||
|
return { status: 'success' };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return { status: 'error', response: err.toString() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
|
@ -663,6 +663,96 @@ export class MySQLClient extends AntaresCore {
|
||||||
return await this.raw(sql, { split: false });
|
return await this.raw(sql, { split: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHOW CREATE EVENT
|
||||||
|
*
|
||||||
|
* @returns {Array.<Object>} view informations
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async getEventInformations ({ schema, scheduler }) {
|
||||||
|
const sql = `SHOW CREATE EVENT \`${schema}\`.\`${scheduler}\``;
|
||||||
|
const results = await this.raw(sql);
|
||||||
|
|
||||||
|
return results.rows.map(row => {
|
||||||
|
const schedule = row['Create Event'].match(/(?<=ON SCHEDULE\n*?\s*?).*?(?=\n)/gs)[0];
|
||||||
|
const execution = schedule.includes('EVERY') ? 'EVERY' : 'ONCE';
|
||||||
|
const every = execution === 'EVERY' ? row['Create Event'].match(/(?<=EVERY )(\s*(\w+)){0,2}/gs)[0].split(' ') : [];
|
||||||
|
const starts = execution === 'EVERY' && schedule.includes('STARTS') ? schedule.match(/(?<=STARTS ').*?(?='\s)/gs)[0] : '';
|
||||||
|
const ends = execution === 'EVERY' && schedule.includes('ENDS') ? schedule.match(/(?<=ENDS ').*?(?='\s)/gs)[0] : '';
|
||||||
|
const at = execution === 'ONCE' && schedule.includes('AT') ? schedule.match(/(?<=AT ').*?(?='\s)/gs)[0] : '';
|
||||||
|
|
||||||
|
return {
|
||||||
|
definer: row['Create Event'].match(/(?<=DEFINER=).*?(?=\s)/gs)[0],
|
||||||
|
sql: row['Create Event'].match(/(BEGIN|begin)(.*)(END|end)/gs)[0],
|
||||||
|
name: row.Event,
|
||||||
|
comment: row['Create Event'].match(/(?<=COMMENT ').*?(?=')/gs) ? row['Create Event'].match(/(?<=COMMENT ').*?(?=')/gs)[0] : '',
|
||||||
|
state: row['Create Event'].includes('ENABLE') ? 'ENABLE' : row['Create Event'].includes('DISABLE ON SLAVE') ? 'DISABLE ON SLAVE' : 'DISABLE',
|
||||||
|
preserve: row['Create Event'].includes('ON COMPLETION PRESERVE'),
|
||||||
|
execution,
|
||||||
|
every,
|
||||||
|
starts,
|
||||||
|
ends,
|
||||||
|
at
|
||||||
|
};
|
||||||
|
})[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DROP EVENT
|
||||||
|
*
|
||||||
|
* @returns {Array.<Object>} parameters
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async dropEvent (params) {
|
||||||
|
const sql = `DROP EVENT \`${params.scheduler}\``;
|
||||||
|
return await this.raw(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ALTER EVENT
|
||||||
|
*
|
||||||
|
* @returns {Array.<Object>} parameters
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async alterEvent (params) {
|
||||||
|
const { scheduler } = params;
|
||||||
|
const tempProcedure = Object.assign({}, scheduler);
|
||||||
|
tempProcedure.name = `Antares_${tempProcedure.name}_tmp`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.createEvent(tempProcedure);
|
||||||
|
await this.dropEvent({ scheduler: tempProcedure.name });
|
||||||
|
await this.dropEvent({ scheduler: scheduler.oldName });
|
||||||
|
await this.createEvent(scheduler);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CREATE EVENT
|
||||||
|
*
|
||||||
|
* @returns {Array.<Object>} parameters
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async createEvent (scheduler) {
|
||||||
|
const parameters = scheduler.parameters.reduce((acc, curr) => {
|
||||||
|
acc.push(`\`${curr.name}\` ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
|
||||||
|
return acc;
|
||||||
|
}, []).join(',');
|
||||||
|
|
||||||
|
const sql = `CREATE ${scheduler.definer ? `DEFINER=${scheduler.definer} ` : ''}FUNCTION \`${scheduler.name}\`(${parameters}) RETURNS ${scheduler.returns}${scheduler.returnsLength ? `(${scheduler.returnsLength})` : ''}
|
||||||
|
LANGUAGE SQL
|
||||||
|
${scheduler.deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'}
|
||||||
|
${scheduler.dataAccess}
|
||||||
|
SQL SECURITY ${scheduler.security}
|
||||||
|
COMMENT '${scheduler.comment}'
|
||||||
|
${scheduler.sql}`;
|
||||||
|
|
||||||
|
return await this.raw(sql, { split: false });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SHOW COLLATION
|
* SHOW COLLATION
|
||||||
*
|
*
|
||||||
|
|
|
@ -95,6 +95,12 @@
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
:function="workspace.breadcrumbs.function"
|
:function="workspace.breadcrumbs.function"
|
||||||
/>
|
/>
|
||||||
|
<WorkspacePropsTabScheduler
|
||||||
|
v-show="selectedTab === 'prop' && workspace.breadcrumbs.scheduler"
|
||||||
|
:is-selected="selectedTab === 'prop'"
|
||||||
|
:connection="connection"
|
||||||
|
:scheduler="workspace.breadcrumbs.scheduler"
|
||||||
|
/>
|
||||||
<WorkspaceTableTab
|
<WorkspaceTableTab
|
||||||
v-show="selectedTab === 'data'"
|
v-show="selectedTab === 'data'"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
|
@ -122,6 +128,7 @@ import WorkspacePropsTabView from '@/components/WorkspacePropsTabView';
|
||||||
import WorkspacePropsTabTrigger from '@/components/WorkspacePropsTabTrigger';
|
import WorkspacePropsTabTrigger from '@/components/WorkspacePropsTabTrigger';
|
||||||
import WorkspacePropsTabRoutine from '@/components/WorkspacePropsTabRoutine';
|
import WorkspacePropsTabRoutine from '@/components/WorkspacePropsTabRoutine';
|
||||||
import WorkspacePropsTabFunction from '@/components/WorkspacePropsTabFunction';
|
import WorkspacePropsTabFunction from '@/components/WorkspacePropsTabFunction';
|
||||||
|
import WorkspacePropsTabScheduler from '@/components/WorkspacePropsTabScheduler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Workspace',
|
name: 'Workspace',
|
||||||
|
@ -133,7 +140,8 @@ export default {
|
||||||
WorkspacePropsTabView,
|
WorkspacePropsTabView,
|
||||||
WorkspacePropsTabTrigger,
|
WorkspacePropsTabTrigger,
|
||||||
WorkspacePropsTabRoutine,
|
WorkspacePropsTabRoutine,
|
||||||
WorkspacePropsTabFunction
|
WorkspacePropsTabFunction,
|
||||||
|
WorkspacePropsTabScheduler
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
connection: Object
|
connection: Object
|
||||||
|
|
|
@ -39,6 +39,7 @@ import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import Triggers from '@/ipc-api/Triggers';
|
import Triggers from '@/ipc-api/Triggers';
|
||||||
import Routines from '@/ipc-api/Routines';
|
import Routines from '@/ipc-api/Routines';
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceExploreBarMiscContext',
|
name: 'WorkspaceExploreBarMiscContext',
|
||||||
|
@ -72,6 +73,8 @@ export default {
|
||||||
return this.$t('message.deleteRoutine');
|
return this.$t('message.deleteRoutine');
|
||||||
case 'function':
|
case 'function':
|
||||||
return this.$t('message.deleteFunction');
|
return this.$t('message.deleteFunction');
|
||||||
|
case 'scheduler':
|
||||||
|
return this.$t('message.deleteScheduler');
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -123,12 +126,12 @@ export default {
|
||||||
func: this.selectedMisc.name
|
func: this.selectedMisc.name
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
// case 'schedulers':
|
case 'scheduler':
|
||||||
// res = await Tables.dropScheduler({
|
res = await Schedulers.dropScheduler({
|
||||||
// uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
// scheduler: this.selectedMisc.name
|
scheduler: this.selectedMisc.name
|
||||||
// });
|
});
|
||||||
// break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { status, response } = res;
|
const { status, response } = res;
|
||||||
|
|
|
@ -0,0 +1,301 @@
|
||||||
|
<template>
|
||||||
|
<div class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save ml-1" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep ml-1" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="divider-vert py-3" />
|
||||||
|
<button class="btn btn-dark btn-sm" @click="false">
|
||||||
|
<span>{{ $t('word.timing') }}</span>
|
||||||
|
<i class="mdi mdi-24px mdi-timer ml-1" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns mb-4">
|
||||||
|
<div class="column col-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.definer') }}</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localScheduler.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option v-if="!isDefinerInUsers" :value="originalScheduler.definer">
|
||||||
|
{{ originalScheduler.definer.replaceAll('`', '') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.comment') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="columns">
|
||||||
|
<!-- <div class="column"> TODO: move in timing modal
|
||||||
|
<label class="form-checkbox form-inline">
|
||||||
|
<input v-model="localScheduler.preserve" type="checkbox"><i class="form-icon" /> {{ $t('message.preserveOnCompletion') }}
|
||||||
|
</label>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label mr-2">{{ $t('word.state') }}</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="ENABLE"
|
||||||
|
><i class="form-icon" /> ENABLE
|
||||||
|
</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="DISABLE"
|
||||||
|
><i class="form-icon" /> DISABLE
|
||||||
|
</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="DISABLE ON SLAVE"
|
||||||
|
><i class="form-icon" /> DISABLE ON SLAVE
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2">
|
||||||
|
<label class="form-label ml-2">{{ $t('message.schedulerBody') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-if="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localScheduler.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspacePropsTabScheduler',
|
||||||
|
components: {
|
||||||
|
QueryEditor
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
scheduler: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
tabUid: 'prop',
|
||||||
|
isQuering: false,
|
||||||
|
isSaving: false,
|
||||||
|
originalScheduler: null,
|
||||||
|
localScheduler: { sql: '' },
|
||||||
|
lastScheduler: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
isSelected () {
|
||||||
|
return this.workspace.selected_tab === 'prop';
|
||||||
|
},
|
||||||
|
schema () {
|
||||||
|
return this.workspace.breadcrumbs.schema;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalScheduler) !== JSON.stringify(this.localScheduler);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalScheduler ? this.workspace.users.some(user => this.originalScheduler.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
async scheduler () {
|
||||||
|
if (this.isSelected) {
|
||||||
|
await this.getSchedulerData();
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
|
||||||
|
this.lastScheduler = this.scheduler;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async isSelected (val) {
|
||||||
|
if (val && this.lastScheduler !== this.scheduler) {
|
||||||
|
await this.getSchedulerData();
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
|
||||||
|
this.lastScheduler = this.scheduler;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
if (this.isSelected && this.lastScheduler === this.scheduler && this.scheduler !== null)
|
||||||
|
this.setUnsavedChanges(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
|
}),
|
||||||
|
async getSchedulerData () {
|
||||||
|
if (!this.scheduler) return;
|
||||||
|
this.isQuering = true;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
scheduler: this.workspace.breadcrumbs.scheduler
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Schedulers.getSchedulerInformations(params);
|
||||||
|
if (status === 'success') {
|
||||||
|
this.originalScheduler = response;
|
||||||
|
this.localScheduler = JSON.parse(JSON.stringify(this.originalScheduler));
|
||||||
|
this.sqlProxy = this.localScheduler.sql;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
this.isQuering = false;
|
||||||
|
},
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
scheduler: {
|
||||||
|
...this.localScheduler,
|
||||||
|
oldName: this.originalScheduler.name
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Schedulers.alterScheduler(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
const oldName = this.originalScheduler.name;
|
||||||
|
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
if (oldName !== this.localScheduler.name) {
|
||||||
|
this.setUnsavedChanges(false);
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, scheduler: this.localScheduler.name });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getSchedulerData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localScheduler = JSON.parse(JSON.stringify(this.originalScheduler));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -359,7 +359,7 @@ export default {
|
||||||
downloadTable (format, filename) {
|
downloadTable (format, filename) {
|
||||||
if (!this.sortedResults) return;
|
if (!this.sortedResults) return;
|
||||||
|
|
||||||
const rows = this.sortedResults.map(row => {
|
const rows = [...this.sortedResults].map(row => {
|
||||||
delete row._id;
|
delete row._id;
|
||||||
return row;
|
return row;
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,7 +80,9 @@ module.exports = {
|
||||||
deterministic: 'Deterministic',
|
deterministic: 'Deterministic',
|
||||||
context: 'Context',
|
context: 'Context',
|
||||||
export: 'Export',
|
export: 'Export',
|
||||||
returns: 'Returns'
|
returns: 'Returns',
|
||||||
|
timing: 'Timing',
|
||||||
|
state: 'State'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
@ -163,7 +165,11 @@ module.exports = {
|
||||||
deleteRoutine: 'Delete stored routine',
|
deleteRoutine: 'Delete stored routine',
|
||||||
functionBody: 'Function body',
|
functionBody: 'Function body',
|
||||||
createNewFunction: 'Create new function',
|
createNewFunction: 'Create new function',
|
||||||
deleteFunction: 'Delete function'
|
deleteFunction: 'Delete function',
|
||||||
|
schedulerBody: 'Scheduler body',
|
||||||
|
createNewScheduler: 'Create new scheduler',
|
||||||
|
deleteScheduler: 'Delete scheduler',
|
||||||
|
preserveOnCompletion: 'Preserve on completion'
|
||||||
},
|
},
|
||||||
// Date and Time
|
// Date and Time
|
||||||
short: {
|
short: {
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
import { ipcRenderer } from 'electron';
|
||||||
|
|
||||||
|
export default class {
|
||||||
|
static getSchedulerInformations (params) {
|
||||||
|
return ipcRenderer.invoke('get-scheduler-informations', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static dropScheduler (params) {
|
||||||
|
return ipcRenderer.invoke('drop-scheduler', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static alterScheduler (params) {
|
||||||
|
return ipcRenderer.invoke('alter-scheduler', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static createScheduler (params) {
|
||||||
|
return ipcRenderer.invoke('create-scheduler', params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,6 @@ const arrayToFile = args => {
|
||||||
mime = 'application/json';
|
mime = 'application/json';
|
||||||
content = JSON.stringify(args.content, null, 3);
|
content = JSON.stringify(args.content, null, 3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue