mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-03 16:03:20 +00:00
remove pagination
This commit is contained in:
@@ -12945,7 +12945,7 @@ paths:
|
||||
/w/{workspace}/assets/link:
|
||||
post:
|
||||
summary: Deletes all current assets of the corresponding entity and updates them to the new ones
|
||||
operationId: link
|
||||
operationId: linkAssets
|
||||
tags:
|
||||
- asset
|
||||
parameters:
|
||||
@@ -12974,13 +12974,11 @@ paths:
|
||||
/w/{workspace}/assets/list:
|
||||
get:
|
||||
summary: List all assets in the workspace
|
||||
operationId: list
|
||||
operationId: listAssets
|
||||
tags:
|
||||
- asset
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/WorkspaceId'
|
||||
- $ref: "#/components/parameters/Page"
|
||||
- $ref: "#/components/parameters/PerPage"
|
||||
responses:
|
||||
'200':
|
||||
description: assets linked
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use axum::{extract::{Path, Query}, routing::{post, get}, Extension, Json, Router};
|
||||
use axum::{extract::{Path}, routing::{post, get}, Extension, Json, Router};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use sqlx::{Postgres, Transaction};
|
||||
use windmill_common::{db::UserDB, error::{JsonResult, Result}, utils::Pagination};
|
||||
use windmill_common::{db::UserDB, error::{JsonResult, Result}};
|
||||
|
||||
use crate::db::ApiAuthed;
|
||||
|
||||
@@ -86,9 +86,7 @@ async fn list_assets(
|
||||
authed: ApiAuthed,
|
||||
Path(w_id): Path<String>,
|
||||
Extension(user_db): Extension<UserDB>,
|
||||
Query(pagination): Query<Pagination>
|
||||
) -> JsonResult<Vec<Value>> {
|
||||
let limit = pagination.per_page.unwrap_or(50).min(100);
|
||||
let assets = sqlx::query_scalar!(
|
||||
r#"SELECT
|
||||
jsonb_build_object(
|
||||
@@ -101,11 +99,8 @@ async fn list_assets(
|
||||
) as "list!: _"
|
||||
FROM asset
|
||||
WHERE workspace_id = $1
|
||||
GROUP BY path, kind
|
||||
LIMIT $2 OFFSET $3"#,
|
||||
GROUP BY path, kind"#,
|
||||
w_id,
|
||||
limit as i64,
|
||||
(pagination.page.unwrap_or(1).saturating_sub(1) * limit) as i64
|
||||
)
|
||||
.fetch_all(&mut *user_db.begin(&authed).await?)
|
||||
.await?;
|
||||
|
||||
@@ -7,23 +7,15 @@
|
||||
import S3FilePicker from '$lib/components/S3FilePicker.svelte'
|
||||
import { Cell, DataTable } from '$lib/components/table'
|
||||
import Head from '$lib/components/table/Head.svelte'
|
||||
import { AssetService } from '$lib/gen'
|
||||
import { AssetService, type ListAssetsResponse } from '$lib/gen'
|
||||
import { userStore, workspaceStore, userWorkspaces } from '$lib/stores'
|
||||
import { usePaginated } from '$lib/svelte5Utils.svelte'
|
||||
import { usePromise } from '$lib/svelte5Utils.svelte'
|
||||
import { isS3Uri, pluralize } from '$lib/utils'
|
||||
import { File, RefreshCw } from 'lucide-svelte'
|
||||
import { File } from 'lucide-svelte'
|
||||
|
||||
let assets = usePaginated(async (page) => {
|
||||
return {
|
||||
items: await AssetService.list({
|
||||
workspace: $workspaceStore ?? '',
|
||||
page,
|
||||
perPage: 50
|
||||
})
|
||||
}
|
||||
})
|
||||
let assets = usePromise(() => AssetService.listAssets({ workspace: $workspaceStore ?? '' }))
|
||||
|
||||
let viewOccurences: (typeof assets)['items'][number] | undefined = $state()
|
||||
let viewOccurences: ListAssetsResponse[number] | undefined = $state()
|
||||
let s3FilePicker: S3FilePicker | undefined = $state()
|
||||
</script>
|
||||
|
||||
@@ -48,7 +40,7 @@
|
||||
</tr>
|
||||
</Head>
|
||||
<tbody class="divide-y bg-surface">
|
||||
{#each assets.items as item}
|
||||
{#each assets.value ?? [] as item}
|
||||
{@const assetUri = formatAsset(item)}
|
||||
<tr>
|
||||
<Cell first>{assetUri}</Cell>
|
||||
@@ -72,19 +64,6 @@
|
||||
</Cell>
|
||||
</tr>
|
||||
{/each}
|
||||
<tr class="w-full">
|
||||
<td colspan={99} class="p-1">
|
||||
<Button
|
||||
wrapperClasses="mx-auto"
|
||||
size="xs"
|
||||
startIcon={{ icon: RefreshCw }}
|
||||
color="light"
|
||||
on:click={() => assets.loadMore()}
|
||||
>
|
||||
Load more
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</DataTable>
|
||||
</CenteredPage>
|
||||
|
||||
Reference in New Issue
Block a user