mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Add nice loading indicator to the host tree
This commit is contained in:
parent
426b0b8468
commit
fd1340f9e4
@ -156,6 +156,10 @@
|
|||||||
<Icon name={childrenOpen[item[key]] ? 'chev-d' : 'chev-r'} />
|
<Icon name={childrenOpen[item[key]] ? 'chev-d' : 'chev-r'} />
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if item.loading}
|
||||||
|
<span class="spinner" style:margin-left="{level * 10}px" />
|
||||||
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@ -234,11 +238,25 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
td.has-toggle {
|
td.has-toggle {
|
||||||
|
position: relative;
|
||||||
width: 1.5em;
|
width: 1.5em;
|
||||||
}
|
}
|
||||||
|
td.has-toggle .spinner {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.3em;
|
||||||
|
left: 0.22em;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
border: 1px solid var(--primary);
|
||||||
|
border-radius: 50px;
|
||||||
|
border-top-color: transparent;
|
||||||
|
border-left-color: transparent;
|
||||||
|
animation: .6s linear 0 spin;
|
||||||
|
animation-iteration-count: infinite;
|
||||||
|
}
|
||||||
td.has-icon {
|
td.has-icon {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 1px;
|
width: 1.5em;
|
||||||
}
|
}
|
||||||
td.has-icon :global(svg) {
|
td.has-icon :global(svg) {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
|
@ -11,11 +11,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@keyframes spinning {
|
|
||||||
0% { transform: rotate(0deg); }
|
|
||||||
100% { transform: rotate(360deg); }
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
transition: transform 0.25s;
|
transition: transform 0.25s;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
@ -23,7 +18,7 @@
|
|||||||
height: 1.2em;
|
height: 1.2em;
|
||||||
}
|
}
|
||||||
svg.spinning {
|
svg.spinning {
|
||||||
animation: spinning 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.field) svg {
|
:global(.field) svg {
|
||||||
|
@ -43,6 +43,7 @@ async function refresh() {
|
|||||||
hostKey,
|
hostKey,
|
||||||
hostDetails,
|
hostDetails,
|
||||||
] of Object.entries(hosts)) {
|
] of Object.entries(hosts)) {
|
||||||
|
|
||||||
hostTree[hostKey] = hostTree[hostKey] || {};
|
hostTree[hostKey] = hostTree[hostKey] || {};
|
||||||
const host = hostTree[hostKey];
|
const host = hostTree[hostKey];
|
||||||
host.key = hostKey;
|
host.key = hostKey;
|
||||||
@ -50,6 +51,9 @@ async function refresh() {
|
|||||||
host.uri = hostDetails.uri;
|
host.uri = hostDetails.uri;
|
||||||
|
|
||||||
host.open = async function() {
|
host.open = async function() {
|
||||||
|
host.loading = true;
|
||||||
|
set(hostTree);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
databases: dbNames,
|
databases: dbNames,
|
||||||
status,
|
status,
|
||||||
@ -88,6 +92,9 @@ async function refresh() {
|
|||||||
delete database.new;
|
delete database.new;
|
||||||
|
|
||||||
database.open = async function() {
|
database.open = async function() {
|
||||||
|
database.loading = true;
|
||||||
|
set(hostTree);
|
||||||
|
|
||||||
const { collections: collNames, stats, statsError } = await OpenDatabase(hostKey, dbKey);
|
const { collections: collNames, stats, statsError } = await OpenDatabase(hostKey, dbKey);
|
||||||
database.stats = stats;
|
database.stats = stats;
|
||||||
database.statsError = statsError;
|
database.statsError = statsError;
|
||||||
@ -285,6 +292,8 @@ async function refresh() {
|
|||||||
|
|
||||||
await refresh();
|
await refresh();
|
||||||
windowTitle.setSegments(dbKey, host.name, 'Rolens');
|
windowTitle.setSegments(dbKey, host.name, 'Rolens');
|
||||||
|
database.loading = false;
|
||||||
|
set(hostTree);
|
||||||
};
|
};
|
||||||
|
|
||||||
database.dump = function() {
|
database.dump = function() {
|
||||||
@ -324,6 +333,8 @@ async function refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await refresh();
|
await refresh();
|
||||||
|
host.loading = false;
|
||||||
|
set(hostTree);
|
||||||
};
|
};
|
||||||
|
|
||||||
host.executeShellScript = async function(script) {
|
host.executeShellScript = async function(script) {
|
||||||
|
@ -7,20 +7,27 @@
|
|||||||
|
|
||||||
<Grid
|
<Grid
|
||||||
striped={false}
|
striped={false}
|
||||||
columns={[ { key: 'name' }, { key: 'count', right: true } ]}
|
columns={[
|
||||||
|
{ key: 'name' },
|
||||||
|
{ key: 'count', right: true },
|
||||||
|
]}
|
||||||
items={Object.values($hostTree || {}).map(host => {
|
items={Object.values($hostTree || {}).map(host => {
|
||||||
return {
|
return {
|
||||||
id: host.key,
|
id: host.key,
|
||||||
name: host.name,
|
name: host.name,
|
||||||
|
loading: host.loading,
|
||||||
icon: 'server',
|
icon: 'server',
|
||||||
|
|
||||||
children: Object.values(host.databases || {})
|
children: Object.values(host.databases || {})
|
||||||
.sort((a, b) => a.key.localeCompare(b))
|
.sort((a, b) => a.key.localeCompare(b))
|
||||||
.map(database => {
|
.map(database => {
|
||||||
return {
|
return {
|
||||||
id: database.key,
|
id: database.key,
|
||||||
name: database.key,
|
name: database.key,
|
||||||
icon: 'db',
|
loading: database.loading,
|
||||||
count: Object.keys(database.collections || {}).length || '',
|
count: Object.keys(database.collections || {}).length || '',
|
||||||
|
icon: 'db',
|
||||||
|
|
||||||
children: Object.values(database.collections)
|
children: Object.values(database.collections)
|
||||||
.sort((a, b) => a.key.localeCompare(b))
|
.sort((a, b) => a.key.localeCompare(b))
|
||||||
.map(collection => {
|
.map(collection => {
|
||||||
@ -42,6 +49,7 @@
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}) || [],
|
}) || [],
|
||||||
|
|
||||||
menu: [
|
menu: [
|
||||||
{ label: 'Dump database (BSON via mongodump)…', fn: database.dump },
|
{ label: 'Dump database (BSON via mongodump)…', fn: database.dump },
|
||||||
{ label: 'Drop database…', fn: database.drop },
|
{ label: 'Drop database…', fn: database.drop },
|
||||||
@ -51,6 +59,7 @@
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
menu: [
|
menu: [
|
||||||
{ label: 'New database…', fn: host.newDatabase },
|
{ label: 'New database…', fn: host.newDatabase },
|
||||||
{ separator: true },
|
{ separator: true },
|
||||||
|
@ -218,3 +218,8 @@ code,
|
|||||||
.flash-green {
|
.flash-green {
|
||||||
animation: 1s ease-out 0s 1 flashGreen;
|
animation: 1s ease-out 0s 1 flashGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user