From ce34017467bd0d0a13ff8035287765675cef08d0 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Sat, 4 Nov 2023 09:37:30 +0100 Subject: [PATCH] fix(frontend): fix treeview (#2552) * fix(frontend): fix wip * fix(frontend): improving home performance * slice number of items to show --------- Co-authored-by: Ruben Fiszel --- frontend/src/lib/components/Dropdown.svelte | 2 +- .../lib/components/common/menu/Menu.svelte | 9 +- .../lib/components/common/table/AppRow.svelte | 14 +- .../components/common/table/FlowRow.svelte | 11 +- .../components/common/table/RawAppRow.svelte | 48 ++-- .../components/common/table/ScriptRow.svelte | 11 +- frontend/src/lib/components/home/Item.svelte | 84 ++++--- .../src/lib/components/home/ItemsList.svelte | 34 +-- .../src/lib/components/home/TreeView.svelte | 222 ++++++++++-------- 9 files changed, 261 insertions(+), 174 deletions(-) diff --git a/frontend/src/lib/components/Dropdown.svelte b/frontend/src/lib/components/Dropdown.svelte index d0ea077bec..1a22910311 100644 --- a/frontend/src/lib/components/Dropdown.svelte +++ b/frontend/src/lib/components/Dropdown.svelte @@ -27,7 +27,7 @@ } - + + -{#if item} - {#if isFolder(item)} -
-
+{#if isFolder(item)} +
+
+
0 ? `padding-left: ${depth * 16}px;` : ''} + >
0 ? `padding-left: ${depth * 16}px;` : ''} + class=" rounded-md p-1 flex justify-center items-center border bg-gray-50 border-gray-200 dark:bg-transparent dark:border-gray-900" > -
- {#if depth === 0} - - {:else} - - {/if} -
- -
- {#if depth === 0}f/{/if}{item.folderName} -
- ({pluralize(item.items.length, ' item')}) -
-
-
- -
- {#if opened} -
- {#each item.items as subItem} - - {/each}
- {/if} + +
+ {#if depth === 0}f/{/if}{item.folderName} +
+ ({pluralize(item.items.length, ' item')}) +
+
+
+
- {:else if isUser(item)} -
-
+ {#if opened} +
+ {#each item.items.slice(0, showMax) as subItem (subItem['path'] ?? 'folder__' + subItem['folderName'])} + + {/each} + {#if showMax < item.items.length} +
{ + if (isFolder(item)) { + showMax += Math.min(30, item.items.length - showMax) + showMax = showMax + console.log(showMax) + } + }} + > + Show more ({showMax}/{item.items.length}) +
+ {/if} +
+ {/if} +
+{:else if isUser(item)} +
+
+
0 ? `padding-left: ${depth * 16}px;` : ''} + >
0 ? `padding-left: ${depth * 16}px;` : ''} + class=" rounded-md p-1 flex justify-center items-center border bg-gray-50 border-gray-200 dark:bg-transparent dark:border-gray-900" > -
- -
+ +
-
- u/{item.username} -
({pluralize(item.items.length, ' item')})
-
+
+ u/{item.username} +
({pluralize(item.items.length, ' item')})
-
- {#if opened} -
- {#each item.items as subItem} - - {/each} -
- {/if} +
- {:else} - - {/if} + {#if opened} +
+ {#each item.items.slice(0, showMax) as subItem (subItem['path'] ?? 'folder__' + subItem['folderName'])} + + {/each} + {#if showMax < item.items.length} + + +
{ + if (isUser(item)) { + showMax += Math.min(30, item.items.length - showMax) + } + }} + > + Show more ({showMax}/{item.items.length}) +
+ {/if} +
+ {/if} +
+{:else} + {/if}