tab status bar improved

This commit is contained in:
Jan Prochazka 2021-11-21 12:39:52 +01:00
parent a5bc66eb27
commit 6a606bc733
4 changed files with 56 additions and 20 deletions

View File

@ -249,6 +249,7 @@
import GenerateSqlFromDataModal from '../modals/GenerateSqlFromDataModal.svelte'; import GenerateSqlFromDataModal from '../modals/GenerateSqlFromDataModal.svelte';
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import { updateStatuBarInfo } from '../widgets/StatusBar.svelte'; import { updateStatuBarInfo } from '../widgets/StatusBar.svelte';
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
export let onLoadNextData = undefined; export let onLoadNextData = undefined;
export let grider = undefined; export let grider = undefined;
@ -1196,15 +1197,15 @@
]; ];
} }
$: { // $: {
if (!tabControlHiddenTab) { // if (!tabControlHiddenTab) {
if (!multipleGridsOnTab && allRowCount != null) { // if (!multipleGridsOnTab && allRowCount != null) {
updateStatuBarInfo(tabid, [{ text: `Rows: ${allRowCount.toLocaleString()}` }]); // updateStatuBarInfo(tabid, [{ text: `Rows: ${allRowCount.toLocaleString()}` }]);
} else { // } else {
updateStatuBarInfo(tabid, []); // updateStatuBarInfo(tabid, []);
} // }
} // }
} // }
</script> </script>
{#if !display || (!isDynamicStructure && (!columns || columns.length == 0))} {#if !display || (!isDynamicStructure && (!columns || columns.length == 0))}
@ -1384,6 +1385,10 @@
{#if isLoading} {#if isLoading}
<LoadingInfo wrapper message="Loading data" /> <LoadingInfo wrapper message="Loading data" />
{/if} {/if}
{#if !tabControlHiddenTab && !multipleGridsOnTab && allRowCount != null}
<StatusBarTabItem text={`Rows: ${allRowCount.toLocaleString()}`} />
{/if}
</div> </div>
{/if} {/if}

View File

@ -1,6 +1,6 @@
import _ from 'lodash'; import _ from 'lodash';
import { getContext, onDestroy } from 'svelte'; import { getContext, onDestroy } from 'svelte';
import { updateStatuBarInfo } from '../widgets/StatusBar.svelte'; import { updateStatuBarInfoItem } from '../widgets/StatusBar.svelte';
function formatSeconds(duration) { function formatSeconds(duration) {
if (duration == null) return ''; if (duration == null) return '';
@ -17,11 +17,7 @@ export default function useTimerLabel() {
const tabid = getContext('tabid'); const tabid = getContext('tabid');
const update = () => { const update = () => {
updateStatuBarInfo(tabid, [ updateStatuBarInfoItem(tabid, 'durationSeconds', { text: formatSeconds(duration) });
{
text: formatSeconds(duration),
},
]);
}; };
const start = () => { const start = () => {

View File

@ -1,15 +1,34 @@
<script lang="ts" context="module"> <script lang="ts" context="module">
const statusBarTabInfo = writable({}); const statusBarTabInfo = writable({});
export function updateStatuBarInfo(tabid, info) { // export function updateStatuBarInfo(tabid, info) {
statusBarTabInfo.update(x => ({ // statusBarTabInfo.update(x => ({
...x, // ...x,
[tabid]: info, // [tabid]: info,
})); // }));
// }
export function updateStatuBarInfoItem(tabid, key, item) {
statusBarTabInfo.update(tabs => {
const items = tabs[tabid] || [];
let newItems;
if (item == null) {
newItems = items.filter(x => x.key != key);
} else if (items.find(x => x.key == key)) {
newItems = items.map(x => (x.key == key ? { ...item, key } : x));
} else {
newItems = [...items, { ...item, key }];
}
return {
...tabs,
[tabid]: newItems,
};
});
} }
</script> </script>
<script lang="ts"> <script lang="ts">
import _ from 'lodash';
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
import moment from 'moment'; import moment from 'moment';

View File

@ -0,0 +1,16 @@
<script lang="ts">
import { getContext, onDestroy, onMount } from 'svelte';
import uuidv1 from 'uuid/v1';
import { updateStatuBarInfoItem } from './StatusBar.svelte';
export let text;
const key = uuidv1();
const tabid = getContext('tabid');
onMount(() => {
updateStatuBarInfoItem(tabid, key, { text });
});
onDestroy(() => updateStatuBarInfoItem(tabid, key, null));
</script>