Implemented Async loading of cards via pagination (500 cards per request)
ref #175
This commit is contained in:
parent
019e14ab1f
commit
c33dfcfddd
@ -32,7 +32,7 @@
|
|||||||
export let original_data = {};
|
export let original_data = {};
|
||||||
export let current_cards = [];
|
export let current_cards = [];
|
||||||
export const addCards = (cards) => {
|
export const addCards = (cards) => {
|
||||||
console.log(cards)
|
console.log(cards);
|
||||||
current_cards = current_cards.concat(...cards);
|
current_cards = current_cards.concat(...cards);
|
||||||
options.update((options) => ({
|
options.update((options) => ({
|
||||||
...options,
|
...options,
|
||||||
@ -155,15 +155,29 @@
|
|||||||
}).showToast();
|
}).showToast();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(async () => {
|
||||||
RunnerCardService.runnerCardControllerGetAll().then((val) => {
|
let page = 0;
|
||||||
current_cards = val;
|
while (page >= 0) {
|
||||||
|
const cards = await RunnerCardService.runnerCardControllerGetAll(
|
||||||
|
page,
|
||||||
|
500
|
||||||
|
);
|
||||||
|
if (cards.length == 0) {
|
||||||
|
page = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_cards = current_cards.concat(...cards);
|
||||||
options.update((options) => ({
|
options.update((options) => ({
|
||||||
...options,
|
...options,
|
||||||
data: current_cards,
|
data: current_cards,
|
||||||
}));
|
}));
|
||||||
dataLoaded = true;
|
|
||||||
});
|
if (page == 0) {
|
||||||
|
dataLoaded = true;
|
||||||
|
}
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
console.log("All cards loaded");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -229,7 +243,7 @@
|
|||||||
...options,
|
...options,
|
||||||
data: current_cards,
|
data: current_cards,
|
||||||
}));
|
}));
|
||||||
$table.resetRowSelection()
|
$table.resetRowSelection();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{$_("delete-cards")}
|
{$_("delete-cards")}
|
||||||
@ -249,7 +263,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
<GenerateRunnerCards cards_show={selected.length>0} bind:generate_cards={selectedCards} />
|
<GenerateRunnerCards
|
||||||
|
cards_show={selected.length > 0}
|
||||||
|
bind:generate_cards={selectedCards}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="w-full">
|
<table class="w-full">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user