feat(UI): modal that shows process query

This commit is contained in:
Fabio Di Stasio 2021-03-04 19:34:18 +01:00
parent 049143d143
commit 07f60c3917
6 changed files with 52 additions and 29 deletions

View File

@ -24,7 +24,7 @@
<slot name="body" /> <slot name="body" />
</div> </div>
</div> </div>
<div class="modal-footer"> <div v-if="!hideFooter" class="modal-footer">
<button <button
class="btn btn-primary mr-2" class="btn btn-primary mr-2"
@click.stop="confirmModal" @click.stop="confirmModal"
@ -51,6 +51,10 @@ export default {
validator: prop => ['small', 'medium', '400', 'large'].includes(prop), validator: prop => ['small', 'medium', '400', 'large'].includes(prop),
default: 'small' default: 'small'
}, },
hideFooter: {
type: Boolean,
default: false
},
confirmText: String, confirmText: String,
cancelText: String cancelText: String
}, },

View File

@ -41,14 +41,16 @@ export default {
localScrollElement: null localScrollElement: null
}; };
}, },
watch: {
scrollElement () {
this.setScrollElement();
}
},
mounted () { mounted () {
this._checkScrollPosition = this.checkScrollPosition.bind(this); this.setScrollElement();
this.localScrollElement = this.scrollElement ? this.scrollElement : this.$el;
this.updateWindow();
this.localScrollElement.addEventListener('scroll', this._checkScrollPosition);
}, },
beforeDestroy () { beforeDestroy () {
this.localScrollElement.removeEventListener('scroll', this._checkScrollPosition); this.localScrollElement.removeEventListener('scroll', this.checkScrollPosition);
}, },
methods: { methods: {
checkScrollPosition (e) { checkScrollPosition (e) {
@ -58,7 +60,7 @@ export default {
this.updateWindow(e); this.updateWindow(e);
}, 200); }, 200);
}, },
updateWindow (e) { updateWindow () {
const visibleItemsCount = Math.ceil(this.visibleHeight / this.itemHeight); const visibleItemsCount = Math.ceil(this.visibleHeight / this.itemHeight);
const totalScrollHeight = this.items.length * this.itemHeight; const totalScrollHeight = this.items.length * this.itemHeight;
const offset = 50; const offset = 50;
@ -74,6 +76,14 @@ export default {
this.topHeight = firstCutIndex * this.itemHeight; this.topHeight = firstCutIndex * this.itemHeight;
this.bottomHeight = totalScrollHeight - this.visibleItems.length * this.itemHeight - this.topHeight; this.bottomHeight = totalScrollHeight - this.visibleItems.length * this.itemHeight - this.topHeight;
},
setScrollElement () {
if (this.localScrollElement)
this.localScrollElement.removeEventListener('scroll', this.checkScrollPosition);
this.localScrollElement = this.scrollElement ? this.scrollElement : this.$el;
this.updateWindow();
this.localScrollElement.addEventListener('scroll', this.checkScrollPosition);
} }
} }
}; };

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="modal active"> <div class="modal active">
<a class="modal-overlay" @click.stop="closeModal" /> <a class="modal-overlay" @click.stop="closeModal" />
<div class="modal-container p-0"> <div class="modal-container p-0 pb-4">
<div class="modal-header pl-2"> <div class="modal-header pl-2">
<div class="modal-title h6"> <div class="modal-title h6">
<div class="d-flex"> <div class="d-flex">
@ -34,7 +34,7 @@
type="range" type="range"
min="0" min="0"
max="30" max="30"
step="1" step="0.5"
@change="setRefreshInterval" @change="setRefreshInterval"
> >
</div> </div>
@ -42,12 +42,16 @@
</div> </div>
<div class="workspace-query-info"> <div class="workspace-query-info">
<div v-if="sortedResults.length"> <div v-if="sortedResults.length">
{{ $t('word.results') }}: <b>{{ sortedResults.length.toLocaleString() }}</b> {{ $t('word.processes') }}: <b>{{ sortedResults.length.toLocaleString() }}</b>
</div> </div>
</div> </div>
</div> </div>
<div ref="tableWrapper" class="modal-body py-0"> <div class="modal-body py-0 workspace-query-results">
<div class="vscroll workspace-query-results" :style="{'height': resultsSize+'px'}"> <div
ref="tableWrapper"
class="vscroll"
:style="{'height': resultsSize+'px'}"
>
<div ref="table" class="table table-hover"> <div ref="table" class="table table-hover">
<div class="thead"> <div class="thead">
<div class="tr"> <div class="tr">
@ -84,18 +88,13 @@
class="process-row" class="process-row"
:row="row" :row="row"
@contextmenu="contextMenu" @contextmenu="contextMenu"
@show-info="showInfoModal" @stop-refresh="stopRefresh"
/> />
</template> </template>
</BaseVirtualScroll> </BaseVirtualScroll>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer text-light">
<button class="btn btn-link" @click.stop="closeModal">
{{ $t('word.close') }}
</button>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -213,7 +212,7 @@ export default {
}, },
resizeResults () { resizeResults () {
if (this.$refs.resultTable) { if (this.$refs.resultTable) {
const el = this.$refs.tableWrapper; const el = this.$refs.tableWrapper.parentElement;
if (el) { if (el) {
const size = el.offsetHeight; const size = el.offsetHeight;
@ -241,7 +240,7 @@ export default {
this.currentSort = ''; this.currentSort = '';
this.currentSortDir = 'asc'; this.currentSortDir = 'asc';
}, },
showInfoModal () { stopRefresh () {
this.autorefreshTimer = 0; this.autorefreshTimer = 0;
this.clearRefresh(); this.clearRefresh();
}, },

View File

@ -18,23 +18,26 @@
</template> </template>
</div> </div>
<ConfirmModal <ConfirmModal
v-if="isTextareaEditor" v-if="isInfoModal"
:confirm-text="$t('word.update')" :confirm-text="$t('word.update')"
:cancel-text="$t('word.close')"
size="medium" size="medium"
@hide="hideEditorModal" :hide-footer="true"
@hide="hideInfoModal"
> >
<template :slot="'header'"> <template :slot="'header'">
<div class="d-flex"> <div class="d-flex">
<i class="mdi mdi-24px mdi-playlist-edit mr-1" /> {{ $t('word.edit') }} "{{ editingField }}" <i class="mdi mdi-24px mdi-information-outline mr-1" /> {{ $t('message.processInfo') }}
</div> </div>
</template> </template>
<div :slot="'body'"> <div :slot="'body'">
<div class="mb-2"> <div>
<div> <div>
<TextEditor <TextEditor
:value.sync="editingContent" :value="row.info"
editor-class="textarea-editor" editor-class="textarea-editor"
:mode="editorMode" :mode="editorMode"
:read-only="true"
/> />
</div> </div>
</div> </div>
@ -56,7 +59,7 @@ export default {
filters: { filters: {
cutText (val) { cutText (val) {
if (typeof val !== 'string') return val; if (typeof val !== 'string') return val;
return val.length > 128 ? `${val.substring(0, 128)}[...]` : val; return val.length > 250 ? `${val.substring(0, 250)}[...]` : val;
} }
}, },
props: { props: {
@ -65,7 +68,7 @@ export default {
data () { data () {
return { return {
isInlineEditor: {}, isInlineEditor: {},
isTextareaEditor: false, isInfoModal: false,
editorMode: 'sql' editorMode: 'sql'
}; };
}, },
@ -90,9 +93,13 @@ export default {
this.$emit('contextmenu', event, payload); this.$emit('contextmenu', event, payload);
} }
}, },
hideInfoModal () {
this.isInfoModal = false;
},
dblClick (col) { dblClick (col) {
if (col !== 'info') return; if (col !== 'info') return;
this.$emit('show-info', col); this.$emit('stop-refresh');
this.isInfoModal = true;
}, },
onKey (e) { onKey (e) {
e.stopPropagation(); e.stopPropagation();

View File

@ -99,7 +99,8 @@ module.exports = {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
tools: 'Tools', tools: 'Tools',
variables: 'Variables' variables: 'Variables',
processes: 'Processes'
}, },
message: { message: {
appWelcome: 'Welcome to Antares SQL Client!', appWelcome: 'Welcome to Antares SQL Client!',
@ -197,6 +198,7 @@ module.exports = {
includeBetaUpdates: 'Include beta updates', includeBetaUpdates: 'Include beta updates',
setNull: 'Set NULL', setNull: 'Set NULL',
processesList: 'Processes list', processesList: 'Processes list',
processInfo: 'Process info',
manageUsers: 'Manage users' manageUsers: 'Manage users'
}, },
faker: { faker: {

View File

@ -30,6 +30,7 @@
"double": $number-color, "double": $number-color,
"decimal": $number-color, "decimal": $number-color,
"bigint": $number-color, "bigint": $number-color,
"newdecimal": $number-color,
"datetime": $date-color, "datetime": $date-color,
"date": $date-color, "date": $date-color,
"time": $date-color, "time": $date-color,