1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Use new loading interface for collection indexes

This commit is contained in:
Romein van Buren 2023-06-26 21:09:28 +02:00
parent 9acb89205d
commit efcc78e3bb
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
3 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,10 @@
<script> <script>
export let name = ''; export let name = '';
export let spin = false;
if (name === 'loading') {
spin = true;
}
</script> </script>
<style> <style>
@ -35,7 +40,7 @@
stroke-width="2" stroke-width="2"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
class:spinning={name === 'loading'} class:spinning={spin}
> >
{#if name === 'radio'} {#if name === 'radio'}
<circle cx="12" cy="12" r="2"></circle><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"></path> <circle cx="12" cy="12" r="2"></circle><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"></path>

View File

@ -162,12 +162,10 @@ async function refresh() {
}; };
collection.getIndexes = async function() { collection.getIndexes = async function() {
const progress = startProgress(`Retrieving indexes of "${collKey}"…`);
collection.indexes = []; collection.indexes = [];
const { indexes, error } = await GetIndexes(hostKey, dbKey, collKey); const { indexes, error } = await GetIndexes(hostKey, dbKey, collKey);
if (error) { if (error) {
progress.end();
return error; return error;
} }
@ -187,8 +185,6 @@ async function refresh() {
collection.indexes.push(index); collection.indexes.push(index);
} }
progress.end();
}; };
collection.getIndexByName = function(indesName) { collection.getIndexByName = function(indesName) {

View File

@ -8,9 +8,12 @@
let activePath = []; let activePath = [];
let _indexes = []; let _indexes = [];
let error = ''; let error = '';
let busy = false;
async function refresh() { async function refresh() {
busy = 'Fetching indexes…';
error = await collection.getIndexes(); error = await collection.getIndexes();
if (!error) { if (!error) {
_indexes = collection.indexes.map(idx => { _indexes = collection.indexes.map(idx => {
return { return {
@ -22,6 +25,8 @@
}; };
}); });
} }
busy = false;
} }
async function createIndex() { async function createIndex() {
@ -56,12 +61,13 @@
errorTitle={error ? 'Error while getting indexes' : ''} errorTitle={error ? 'Error while getting indexes' : ''}
errorDescription={error} errorDescription={error}
bind:activePath bind:activePath
{busy}
/> />
</div> </div>
<div class="actions"> <div class="actions">
<button class="btn" on:click={refresh}> <button class="btn" on:click={refresh}>
<Icon name="reload" /> Reload <Icon name="reload" spin={busy} /> Reload
</button> </button>
<button class="btn" on:click={createIndex}> <button class="btn" on:click={createIndex}>
<Icon name="+" /> Create index… <Icon name="+" /> Create index…