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'} />
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if item.loading}
|
||||
<span class="spinner" style:margin-left="{level * 10}px" />
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
|
||||
@ -234,11 +238,25 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
td.has-toggle {
|
||||
position: relative;
|
||||
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 {
|
||||
padding: 0;
|
||||
width: 1px;
|
||||
width: 1.5em;
|
||||
}
|
||||
td.has-icon :global(svg) {
|
||||
width: 1em;
|
||||
|
@ -11,11 +11,6 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@keyframes spinning {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
svg {
|
||||
transition: transform 0.25s;
|
||||
will-change: transform;
|
||||
@ -23,7 +18,7 @@
|
||||
height: 1.2em;
|
||||
}
|
||||
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 {
|
||||
|
@ -43,6 +43,7 @@ async function refresh() {
|
||||
hostKey,
|
||||
hostDetails,
|
||||
] of Object.entries(hosts)) {
|
||||
|
||||
hostTree[hostKey] = hostTree[hostKey] || {};
|
||||
const host = hostTree[hostKey];
|
||||
host.key = hostKey;
|
||||
@ -50,6 +51,9 @@ async function refresh() {
|
||||
host.uri = hostDetails.uri;
|
||||
|
||||
host.open = async function() {
|
||||
host.loading = true;
|
||||
set(hostTree);
|
||||
|
||||
const {
|
||||
databases: dbNames,
|
||||
status,
|
||||
@ -88,6 +92,9 @@ async function refresh() {
|
||||
delete database.new;
|
||||
|
||||
database.open = async function() {
|
||||
database.loading = true;
|
||||
set(hostTree);
|
||||
|
||||
const { collections: collNames, stats, statsError } = await OpenDatabase(hostKey, dbKey);
|
||||
database.stats = stats;
|
||||
database.statsError = statsError;
|
||||
@ -285,6 +292,8 @@ async function refresh() {
|
||||
|
||||
await refresh();
|
||||
windowTitle.setSegments(dbKey, host.name, 'Rolens');
|
||||
database.loading = false;
|
||||
set(hostTree);
|
||||
};
|
||||
|
||||
database.dump = function() {
|
||||
@ -324,6 +333,8 @@ async function refresh() {
|
||||
}
|
||||
|
||||
await refresh();
|
||||
host.loading = false;
|
||||
set(hostTree);
|
||||
};
|
||||
|
||||
host.executeShellScript = async function(script) {
|
||||
|
@ -7,20 +7,27 @@
|
||||
|
||||
<Grid
|
||||
striped={false}
|
||||
columns={[ { key: 'name' }, { key: 'count', right: true } ]}
|
||||
columns={[
|
||||
{ key: 'name' },
|
||||
{ key: 'count', right: true },
|
||||
]}
|
||||
items={Object.values($hostTree || {}).map(host => {
|
||||
return {
|
||||
id: host.key,
|
||||
name: host.name,
|
||||
loading: host.loading,
|
||||
icon: 'server',
|
||||
|
||||
children: Object.values(host.databases || {})
|
||||
.sort((a, b) => a.key.localeCompare(b))
|
||||
.map(database => {
|
||||
return {
|
||||
id: database.key,
|
||||
name: database.key,
|
||||
icon: 'db',
|
||||
loading: database.loading,
|
||||
count: Object.keys(database.collections || {}).length || '',
|
||||
icon: 'db',
|
||||
|
||||
children: Object.values(database.collections)
|
||||
.sort((a, b) => a.key.localeCompare(b))
|
||||
.map(collection => {
|
||||
@ -42,6 +49,7 @@
|
||||
],
|
||||
};
|
||||
}) || [],
|
||||
|
||||
menu: [
|
||||
{ label: 'Dump database (BSON via mongodump)…', fn: database.dump },
|
||||
{ label: 'Drop database…', fn: database.drop },
|
||||
@ -51,6 +59,7 @@
|
||||
],
|
||||
};
|
||||
}),
|
||||
|
||||
menu: [
|
||||
{ label: 'New database…', fn: host.newDatabase },
|
||||
{ separator: true },
|
||||
|
@ -218,3 +218,8 @@ code,
|
||||
.flash-green {
|
||||
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