2020-06-12 18:10:45 +02:00
|
|
|
<template>
|
2021-07-13 09:09:25 +02:00
|
|
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless no-outline p-0">
|
2020-06-12 18:10:45 +02:00
|
|
|
<div class="workspace-query-runner column col-12">
|
|
|
|
<div class="workspace-query-runner-footer">
|
|
|
|
<div class="workspace-query-buttons">
|
2020-10-08 18:51:08 +02:00
|
|
|
<div class="dropdown">
|
|
|
|
<div class="btn-group">
|
|
|
|
<button
|
2020-10-18 10:27:02 +02:00
|
|
|
class="btn btn-dark btn-sm mr-0 pr-1"
|
2020-10-08 18:51:08 +02:00
|
|
|
:class="{'loading':isQuering}"
|
|
|
|
title="F5"
|
|
|
|
@click="reloadTable"
|
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i v-if="!+autorefreshTimer" class="mdi mdi-24px mdi-refresh mr-1" />
|
|
|
|
<i v-else class="mdi mdi-24px mdi-history mdi-flip-h mr-1" />
|
2020-10-08 18:51:08 +02:00
|
|
|
<span>{{ $t('word.refresh') }}</span>
|
|
|
|
</button>
|
2020-10-18 10:27:02 +02:00
|
|
|
<div class="btn btn-dark btn-sm dropdown-toggle pl-0 pr-0" tabindex="0">
|
2020-10-08 18:51:08 +02:00
|
|
|
<i class="mdi mdi-24px mdi-menu-down" />
|
|
|
|
</div>
|
|
|
|
<div class="menu px-3">
|
|
|
|
<span>{{ $t('word.autoRefresh') }}: <b>{{ +autorefreshTimer ? `${autorefreshTimer}s` : 'OFF' }}</b></span>
|
|
|
|
<input
|
|
|
|
v-model="autorefreshTimer"
|
|
|
|
class="slider no-border"
|
|
|
|
type="range"
|
|
|
|
min="0"
|
|
|
|
max="30"
|
|
|
|
step="1"
|
|
|
|
@change="setRefreshInterval"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-27 22:13:59 +02:00
|
|
|
<div class="btn-group">
|
|
|
|
<button
|
|
|
|
class="btn btn-dark btn-sm mr-0"
|
|
|
|
:disabled="isQuering || page === 1"
|
2021-05-29 11:26:23 +02:00
|
|
|
title="CTRL+ᐊ"
|
2021-05-27 22:13:59 +02:00
|
|
|
@click="pageChange('prev')"
|
|
|
|
>
|
|
|
|
<i class="mdi mdi-24px mdi-skip-previous" />
|
|
|
|
</button>
|
2021-06-19 12:13:09 +02:00
|
|
|
<div class="dropdown" :class="{'active': isPageMenu}">
|
2021-06-24 21:49:46 +02:00
|
|
|
<div @click="openPageMenu">
|
|
|
|
<div class="btn btn-dark btn-sm mr-0 no-radius dropdown-toggle text-bold px-3">
|
2021-06-19 12:13:09 +02:00
|
|
|
{{ page }}
|
|
|
|
</div>
|
|
|
|
<div class="menu px-3">
|
|
|
|
<span>{{ $t('message.pageNumber') }}</span>
|
|
|
|
<input
|
|
|
|
ref="pageSelect"
|
|
|
|
v-model="pageProxy"
|
|
|
|
type="number"
|
|
|
|
min="1"
|
|
|
|
class="form-input"
|
|
|
|
@blur="setPageNumber"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-27 22:13:59 +02:00
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
class="btn btn-dark btn-sm mr-0"
|
|
|
|
:disabled="isQuering || (results.length && results[0].rows.length < limit)"
|
2021-05-29 11:26:23 +02:00
|
|
|
title="CTRL+ᐅ"
|
2021-05-27 22:13:59 +02:00
|
|
|
@click="pageChange('next')"
|
|
|
|
>
|
|
|
|
<i class="mdi mdi-24px mdi-skip-next" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="divider-vert py-3" />
|
2021-01-08 21:55:03 +01:00
|
|
|
|
2021-10-17 23:54:00 +02:00
|
|
|
<button
|
|
|
|
class="btn btn-sm"
|
|
|
|
:class="{'btn-primary': isSearch, 'btn-dark': !isSearch}"
|
|
|
|
@click="isSearch = !isSearch"
|
|
|
|
>
|
|
|
|
<i class="mdi mdi-24px mdi-magnify" />
|
|
|
|
</button>
|
2021-02-16 19:13:20 +01:00
|
|
|
<button
|
|
|
|
v-if="isTable"
|
|
|
|
class="btn btn-dark btn-sm"
|
2021-02-20 18:55:08 +01:00
|
|
|
:disabled="isQuering"
|
2021-02-16 19:13:20 +01:00
|
|
|
@click="showFakerModal"
|
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-playlist-plus mr-1" />
|
2021-02-16 19:13:20 +01:00
|
|
|
<span>{{ $t('message.tableFiller') }}</span>
|
2020-08-05 22:08:20 +02:00
|
|
|
</button>
|
2021-02-13 18:45:16 +01:00
|
|
|
|
2021-06-29 23:31:18 +02:00
|
|
|
<div class="dropdown table-dropdown pr-2">
|
2021-01-08 21:55:03 +01:00
|
|
|
<button
|
|
|
|
:disabled="isQuering"
|
|
|
|
class="btn btn-dark btn-sm dropdown-toggle mr-0 pr-0"
|
|
|
|
tabindex="0"
|
|
|
|
>
|
2021-07-09 15:51:02 +02:00
|
|
|
<i class="mdi mdi-24px mdi-file-export mr-1" />
|
2021-01-08 21:55:03 +01:00
|
|
|
<span>{{ $t('word.export') }}</span>
|
|
|
|
<i class="mdi mdi-24px mdi-menu-down" />
|
|
|
|
</button>
|
|
|
|
<ul class="menu text-left">
|
|
|
|
<li class="menu-item">
|
|
|
|
<a class="c-hand" @click="downloadTable('json')">JSON</a>
|
|
|
|
</li>
|
|
|
|
<li class="menu-item">
|
|
|
|
<a class="c-hand" @click="downloadTable('csv')">CSV</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2020-06-12 18:10:45 +02:00
|
|
|
</div>
|
|
|
|
<div class="workspace-query-info">
|
2021-02-26 18:45:00 +01:00
|
|
|
<div
|
|
|
|
v-if="results.length"
|
|
|
|
class="d-flex"
|
|
|
|
:title="$t('message.queryDuration')"
|
|
|
|
>
|
|
|
|
<i class="mdi mdi-timer-sand mdi-rotate-180 pr-1" /> <b>{{ results[0].duration / 1000 }}s</b>
|
|
|
|
</div>
|
2020-09-14 12:49:09 +02:00
|
|
|
<div v-if="results.length && results[0].rows">
|
2021-06-03 10:57:57 +02:00
|
|
|
{{ $t('word.results') }}: <b>{{ results[0].rows.length | localeString }}</b>
|
2020-11-25 11:47:35 +01:00
|
|
|
</div>
|
2021-08-04 15:52:26 +02:00
|
|
|
<div v-if="hasApproximately || (page > 1 && approximateCount)">
|
|
|
|
{{ $t('word.total') }}: <b :title="$t('word.approximately')">≈ {{ approximateCount | localeString }}</b>
|
2020-06-12 18:10:45 +02:00
|
|
|
</div>
|
2021-07-14 12:31:12 +02:00
|
|
|
<div class="d-flex" :title="$t('word.schema')">
|
|
|
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
2020-06-12 18:10:45 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-17 23:54:00 +02:00
|
|
|
<WorkspaceTabTableFilters
|
|
|
|
v-if="isSearch"
|
|
|
|
:fields="fields"
|
2021-10-19 17:42:31 +02:00
|
|
|
:conn-client="connection.client"
|
2021-10-17 23:54:00 +02:00
|
|
|
@filter="updateFilters"
|
2021-10-18 21:11:09 +02:00
|
|
|
@filter-change="onFilterChange"
|
2021-10-17 23:54:00 +02:00
|
|
|
/>
|
2021-03-09 19:14:02 +01:00
|
|
|
<div class="workspace-query-results p-relative column col-12">
|
|
|
|
<BaseLoader v-if="isQuering" />
|
2021-08-12 09:54:13 +02:00
|
|
|
<WorkspaceTabQueryTable
|
2020-06-16 18:01:22 +02:00
|
|
|
v-if="results"
|
2020-06-28 15:31:16 +02:00
|
|
|
ref="queryTable"
|
2020-09-14 11:08:11 +02:00
|
|
|
:results="results"
|
2020-08-14 18:07:29 +02:00
|
|
|
:tab-uid="tabUid"
|
2020-09-18 12:54:02 +02:00
|
|
|
:conn-uid="connection.uid"
|
2021-03-05 17:10:52 +01:00
|
|
|
:is-selected="isSelected"
|
2020-09-18 12:54:02 +02:00
|
|
|
mode="table"
|
2021-07-14 16:10:34 +02:00
|
|
|
:element-type="elementType"
|
2020-08-18 18:03:59 +02:00
|
|
|
@update-field="updateField"
|
|
|
|
@delete-selected="deleteSelected"
|
2020-12-07 17:51:48 +01:00
|
|
|
@hard-sort="hardSort"
|
2020-06-16 18:01:22 +02:00
|
|
|
/>
|
2020-06-12 18:10:45 +02:00
|
|
|
</div>
|
2020-08-12 18:12:30 +02:00
|
|
|
<ModalNewTableRow
|
|
|
|
v-if="isAddModal"
|
2020-10-27 16:41:00 +01:00
|
|
|
:fields="fields"
|
|
|
|
:key-usage="keyUsage"
|
2020-08-17 15:10:19 +02:00
|
|
|
:tab-uid="tabUid"
|
2020-08-12 18:12:30 +02:00
|
|
|
@hide="hideAddModal"
|
|
|
|
@reload="reloadTable"
|
|
|
|
/>
|
2021-02-13 18:45:16 +01:00
|
|
|
<ModalFakerRows
|
|
|
|
v-if="isFakerModal"
|
|
|
|
:fields="fields"
|
|
|
|
:key-usage="keyUsage"
|
|
|
|
:tab-uid="tabUid"
|
|
|
|
@hide="hideFakerModal"
|
|
|
|
@reload="reloadTable"
|
|
|
|
/>
|
2020-06-12 18:10:45 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-07-24 13:26:56 +02:00
|
|
|
import Tables from '@/ipc-api/Tables';
|
2021-03-09 19:14:02 +01:00
|
|
|
import BaseLoader from '@/components/BaseLoader';
|
2021-08-12 09:54:13 +02:00
|
|
|
import WorkspaceTabQueryTable from '@/components/WorkspaceTabQueryTable';
|
2021-10-17 23:54:00 +02:00
|
|
|
import WorkspaceTabTableFilters from '@/components/WorkspaceTabTableFilters';
|
2020-08-12 18:12:30 +02:00
|
|
|
import ModalNewTableRow from '@/components/ModalNewTableRow';
|
2021-02-13 18:45:16 +01:00
|
|
|
import ModalFakerRows from '@/components/ModalFakerRows';
|
2020-06-12 18:10:45 +02:00
|
|
|
import { mapGetters, mapActions } from 'vuex';
|
2020-07-23 19:10:14 +02:00
|
|
|
import tableTabs from '@/mixins/tableTabs';
|
2020-06-12 18:10:45 +02:00
|
|
|
|
|
|
|
export default {
|
2021-08-12 09:54:13 +02:00
|
|
|
name: 'WorkspaceTabTable',
|
2020-06-12 18:10:45 +02:00
|
|
|
components: {
|
2021-03-09 19:14:02 +01:00
|
|
|
BaseLoader,
|
2021-08-12 09:54:13 +02:00
|
|
|
WorkspaceTabQueryTable,
|
2021-10-17 23:54:00 +02:00
|
|
|
WorkspaceTabTableFilters,
|
2021-02-13 18:45:16 +01:00
|
|
|
ModalNewTableRow,
|
|
|
|
ModalFakerRows
|
2020-06-12 18:10:45 +02:00
|
|
|
},
|
2021-06-03 10:57:57 +02:00
|
|
|
filters: {
|
|
|
|
localeString (val) {
|
2021-08-04 15:52:26 +02:00
|
|
|
if (val !== null)
|
2021-06-03 10:57:57 +02:00
|
|
|
return val.toLocaleString();
|
|
|
|
}
|
|
|
|
},
|
2020-07-23 19:10:14 +02:00
|
|
|
mixins: [tableTabs],
|
2020-06-12 18:10:45 +02:00
|
|
|
props: {
|
|
|
|
connection: Object,
|
2021-07-13 09:09:25 +02:00
|
|
|
isSelected: Boolean,
|
|
|
|
table: String,
|
2021-07-14 16:10:34 +02:00
|
|
|
schema: String,
|
|
|
|
elementType: String
|
2020-06-12 18:10:45 +02:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2021-07-13 19:23:02 +02:00
|
|
|
tabUid: 'data', // ???
|
2020-06-12 18:10:45 +02:00
|
|
|
isQuering: false,
|
2021-06-19 12:13:09 +02:00
|
|
|
isPageMenu: false,
|
2021-10-17 23:54:00 +02:00
|
|
|
isSearch: false,
|
2020-09-14 11:08:11 +02:00
|
|
|
results: [],
|
2020-08-12 10:48:18 +02:00
|
|
|
lastTable: null,
|
2020-10-08 18:51:08 +02:00
|
|
|
isAddModal: false,
|
2021-02-13 18:45:16 +01:00
|
|
|
isFakerModal: false,
|
2020-10-08 18:51:08 +02:00
|
|
|
autorefreshTimer: 0,
|
2020-12-08 18:41:08 +01:00
|
|
|
refreshInterval: null,
|
2021-05-27 22:13:59 +02:00
|
|
|
sortParams: {},
|
2021-10-17 23:54:00 +02:00
|
|
|
filters: [],
|
2021-06-19 12:13:09 +02:00
|
|
|
page: 1,
|
2021-08-04 15:52:26 +02:00
|
|
|
pageProxy: 1,
|
|
|
|
approximateCount: 0
|
2020-06-12 18:10:45 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2021-02-18 18:01:12 +01:00
|
|
|
getWorkspace: 'workspaces/getWorkspace',
|
2021-05-27 22:13:59 +02:00
|
|
|
selectedWorkspace: 'workspaces/getSelected',
|
|
|
|
limit: 'settings/getDataTabLimit'
|
2020-06-12 18:10:45 +02:00
|
|
|
}),
|
|
|
|
workspace () {
|
|
|
|
return this.getWorkspace(this.connection.uid);
|
|
|
|
},
|
2021-02-16 19:13:20 +01:00
|
|
|
isTable () {
|
|
|
|
return !!this.workspace.breadcrumbs.table;
|
|
|
|
},
|
2020-10-27 16:41:00 +01:00
|
|
|
fields () {
|
|
|
|
return this.results.length ? this.results[0].fields : [];
|
|
|
|
},
|
|
|
|
keyUsage () {
|
|
|
|
return this.results.length ? this.results[0].keys : [];
|
2020-11-25 11:47:35 +01:00
|
|
|
},
|
|
|
|
tableInfo () {
|
2020-12-03 16:15:10 +01:00
|
|
|
try {
|
|
|
|
return this.workspace.structure.find(db => db.name === this.schema).tables.find(table => table.name === this.table);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { rows: 0 };
|
|
|
|
}
|
2021-04-15 10:13:55 +02:00
|
|
|
},
|
|
|
|
hasApproximately () {
|
|
|
|
return this.results.length &&
|
|
|
|
this.results[0].rows &&
|
2021-05-27 22:13:59 +02:00
|
|
|
this.results[0].rows.length === this.limit &&
|
2021-08-04 15:52:26 +02:00
|
|
|
this.results[0].rows.length < this.approximateCount;
|
2020-06-12 18:10:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2021-07-13 16:53:47 +02:00
|
|
|
schema () {
|
|
|
|
if (this.isSelected) {
|
|
|
|
this.page = 1;
|
2021-08-04 15:52:26 +02:00
|
|
|
this.approximateCount = 0;
|
2021-07-13 16:53:47 +02:00
|
|
|
this.sortParams = {};
|
|
|
|
this.getTableData();
|
|
|
|
this.lastTable = this.table;
|
|
|
|
this.$refs.queryTable.resetSort();
|
|
|
|
}
|
|
|
|
},
|
2020-07-24 13:26:56 +02:00
|
|
|
table () {
|
2020-06-13 18:14:32 +02:00
|
|
|
if (this.isSelected) {
|
2021-06-03 11:02:24 +02:00
|
|
|
this.page = 1;
|
2021-08-04 15:52:26 +02:00
|
|
|
this.approximateCount = 0;
|
2020-12-08 18:41:08 +01:00
|
|
|
this.sortParams = {};
|
2020-06-15 18:23:51 +02:00
|
|
|
this.getTableData();
|
2020-06-13 18:14:32 +02:00
|
|
|
this.lastTable = this.table;
|
2020-12-07 17:51:48 +01:00
|
|
|
this.$refs.queryTable.resetSort();
|
2020-06-13 18:14:32 +02:00
|
|
|
}
|
|
|
|
},
|
2021-06-19 12:13:09 +02:00
|
|
|
page (val, oldVal) {
|
|
|
|
if (val && val > 0 && val !== oldVal) {
|
|
|
|
this.pageProxy = this.page;
|
|
|
|
this.getTableData();
|
|
|
|
}
|
2021-05-27 22:13:59 +02:00
|
|
|
},
|
2020-07-24 13:26:56 +02:00
|
|
|
isSelected (val) {
|
2021-07-14 16:10:34 +02:00
|
|
|
if (val) {
|
|
|
|
this.changeBreadcrumbs({ schema: this.schema, [this.elementType]: this.table });
|
|
|
|
|
|
|
|
if (this.lastTable !== this.table)
|
|
|
|
this.getTableData();
|
2020-06-13 18:14:32 +02:00
|
|
|
}
|
2021-10-17 23:54:00 +02:00
|
|
|
},
|
|
|
|
isSearch (val) {
|
|
|
|
if (this.filters.length > 0 && !val) {
|
|
|
|
this.filters = [];
|
|
|
|
this.getTableData();
|
|
|
|
}
|
2021-10-18 11:58:29 +02:00
|
|
|
this.resizeScroller();
|
2020-06-12 18:10:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created () {
|
2020-06-15 18:23:51 +02:00
|
|
|
this.getTableData();
|
2020-10-04 17:32:15 +02:00
|
|
|
window.addEventListener('keydown', this.onKey);
|
|
|
|
},
|
|
|
|
beforeDestroy () {
|
|
|
|
window.removeEventListener('keydown', this.onKey);
|
2020-10-08 18:51:08 +02:00
|
|
|
clearInterval(this.refreshInterval);
|
2020-06-12 18:10:45 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2021-07-14 16:10:34 +02:00
|
|
|
addNotification: 'notifications/addNotification',
|
|
|
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
2020-06-12 18:10:45 +02:00
|
|
|
}),
|
2021-07-22 18:22:47 +02:00
|
|
|
async getTableData () {
|
2021-09-13 10:03:27 +02:00
|
|
|
if (!this.table || !this.isSelected) return;
|
2020-06-12 18:10:45 +02:00
|
|
|
this.isQuering = true;
|
2020-10-07 20:42:04 +02:00
|
|
|
|
|
|
|
// if table changes clear cached values
|
2020-10-27 16:41:00 +01:00
|
|
|
if (this.lastTable !== this.table)
|
2020-10-07 20:42:04 +02:00
|
|
|
this.results = [];
|
2020-06-12 18:10:45 +02:00
|
|
|
|
2021-07-14 16:10:34 +02:00
|
|
|
this.lastTable = this.table;
|
|
|
|
|
2020-06-12 18:10:45 +02:00
|
|
|
const params = {
|
|
|
|
uid: this.connection.uid,
|
2020-09-08 11:47:01 +02:00
|
|
|
schema: this.schema,
|
2021-07-13 09:09:25 +02:00
|
|
|
table: this.table,
|
2021-05-27 22:13:59 +02:00
|
|
|
limit: this.limit,
|
|
|
|
page: this.page,
|
2021-10-17 23:54:00 +02:00
|
|
|
sortParams: this.sortParams,
|
|
|
|
where: this.filters || []
|
2020-06-12 18:10:45 +02:00
|
|
|
};
|
|
|
|
|
2020-10-07 20:42:04 +02:00
|
|
|
try { // Table data
|
|
|
|
const { status, response } = await Tables.getTableData(params);
|
2020-09-24 13:09:01 +02:00
|
|
|
|
2020-10-07 20:42:04 +02:00
|
|
|
if (status === 'success')
|
|
|
|
this.results = [response];
|
2020-08-14 18:07:29 +02:00
|
|
|
else
|
|
|
|
this.addNotification({ status: 'error', message: response });
|
2020-06-12 18:10:45 +02:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.addNotification({ status: 'error', message: err.stack });
|
|
|
|
}
|
|
|
|
|
2021-08-04 15:52:26 +02:00
|
|
|
if (this.results.length && this.results[0].rows.length === this.limit) {
|
|
|
|
try { // Table approximate count
|
|
|
|
const { status, response } = await Tables.getTableApproximateCount(params);
|
|
|
|
|
|
|
|
if (status === 'success')
|
|
|
|
this.approximateCount = response;
|
|
|
|
else
|
|
|
|
this.addNotification({ status: 'error', message: response });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.addNotification({ status: 'error', message: err.stack });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-12 18:10:45 +02:00
|
|
|
this.isQuering = false;
|
2020-08-04 17:54:19 +02:00
|
|
|
},
|
2020-09-06 10:35:32 +02:00
|
|
|
getTable () {
|
|
|
|
return this.table;
|
|
|
|
},
|
2020-08-04 17:54:19 +02:00
|
|
|
reloadTable () {
|
2021-07-22 18:22:47 +02:00
|
|
|
this.getTableData();
|
2020-08-05 22:08:20 +02:00
|
|
|
},
|
2020-12-07 17:51:48 +01:00
|
|
|
hardSort (sortParams) {
|
2020-12-08 18:41:08 +01:00
|
|
|
this.sortParams = sortParams;
|
2021-07-22 18:22:47 +02:00
|
|
|
this.getTableData();
|
2020-12-07 17:51:48 +01:00
|
|
|
},
|
2021-06-19 12:13:09 +02:00
|
|
|
openPageMenu () {
|
2021-07-23 09:01:50 +02:00
|
|
|
if (this.isQuering || (this.results.length && this.results[0].rows.length < this.limit && this.page === 1)) return;
|
2021-06-19 12:13:09 +02:00
|
|
|
|
|
|
|
this.isPageMenu = true;
|
|
|
|
if (this.isPageMenu)
|
|
|
|
setTimeout(() => this.$refs.pageSelect.focus(), 20);
|
|
|
|
},
|
|
|
|
setPageNumber () {
|
|
|
|
this.isPageMenu = false;
|
|
|
|
|
|
|
|
if (this.pageProxy > 0)
|
|
|
|
this.page = this.pageProxy;
|
|
|
|
else
|
|
|
|
this.pageProxy = this.page;
|
|
|
|
},
|
2021-05-27 22:13:59 +02:00
|
|
|
pageChange (direction) {
|
2021-05-29 11:26:23 +02:00
|
|
|
if (this.isQuering) return;
|
|
|
|
|
2021-06-19 12:13:09 +02:00
|
|
|
if (direction === 'next' && (this.results.length && this.results[0].rows.length === this.limit)) {
|
|
|
|
if (!this.page)
|
|
|
|
this.page = 2;
|
|
|
|
else
|
|
|
|
this.page++;
|
|
|
|
}
|
2021-05-29 11:26:23 +02:00
|
|
|
else if (direction === 'prev' && this.page > 1)
|
2021-05-27 22:13:59 +02:00
|
|
|
this.page--;
|
|
|
|
},
|
2020-08-12 10:48:18 +02:00
|
|
|
showAddModal () {
|
|
|
|
this.isAddModal = true;
|
|
|
|
},
|
|
|
|
hideAddModal () {
|
|
|
|
this.isAddModal = false;
|
2020-10-04 17:32:15 +02:00
|
|
|
},
|
2021-02-13 18:45:16 +01:00
|
|
|
showFakerModal () {
|
2021-02-20 18:55:08 +01:00
|
|
|
if (this.isQuering) return;
|
2021-02-13 18:45:16 +01:00
|
|
|
this.isFakerModal = true;
|
|
|
|
},
|
|
|
|
hideFakerModal () {
|
|
|
|
this.isFakerModal = false;
|
|
|
|
},
|
2020-10-04 17:32:15 +02:00
|
|
|
onKey (e) {
|
2020-11-13 12:39:40 +01:00
|
|
|
if (this.isSelected) {
|
|
|
|
e.stopPropagation();
|
2020-10-27 17:04:39 +01:00
|
|
|
if (e.key === 'F5')
|
|
|
|
this.reloadTable();
|
2021-05-29 11:26:23 +02:00
|
|
|
|
2021-10-17 23:54:00 +02:00
|
|
|
if (e.ctrlKey || e.metaKey) {
|
2021-05-29 11:26:23 +02:00
|
|
|
if (e.key === 'ArrowRight')
|
|
|
|
this.pageChange('next');
|
|
|
|
if (e.key === 'ArrowLeft')
|
|
|
|
this.pageChange('prev');
|
2021-10-17 23:54:00 +02:00
|
|
|
if (e.keyCode === 70) // f
|
|
|
|
this.isSearch = !this.isSearch;
|
2021-05-29 11:26:23 +02:00
|
|
|
}
|
2020-10-27 17:04:39 +01:00
|
|
|
}
|
2020-10-08 18:51:08 +02:00
|
|
|
},
|
|
|
|
setRefreshInterval () {
|
|
|
|
if (this.refreshInterval)
|
|
|
|
clearInterval(this.refreshInterval);
|
|
|
|
|
|
|
|
if (+this.autorefreshTimer) {
|
|
|
|
this.refreshInterval = setInterval(() => {
|
|
|
|
if (!this.isQuering)
|
|
|
|
this.reloadTable();
|
|
|
|
}, this.autorefreshTimer * 1000);
|
|
|
|
}
|
2021-01-08 21:55:03 +01:00
|
|
|
},
|
|
|
|
downloadTable (format) {
|
|
|
|
this.$refs.queryTable.downloadTable(format, this.table);
|
2021-10-17 23:54:00 +02:00
|
|
|
},
|
2021-10-18 21:11:09 +02:00
|
|
|
onFilterChange (clausoles) {
|
2021-10-18 21:23:22 +02:00
|
|
|
this.resizeScroller();
|
2021-10-18 21:11:09 +02:00
|
|
|
if (clausoles.length === 0)
|
|
|
|
this.isSearch = false;
|
|
|
|
},
|
2021-10-18 11:58:29 +02:00
|
|
|
resizeScroller () {
|
|
|
|
setTimeout(() => this.$refs.queryTable.refreshScroller(), 1);
|
|
|
|
},
|
2021-10-17 23:54:00 +02:00
|
|
|
updateFilters (clausoles) {
|
|
|
|
this.filters = clausoles;
|
|
|
|
this.getTableData();
|
2020-08-12 10:48:18 +02:00
|
|
|
}
|
2020-06-12 18:10:45 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|