mirror of https://github.com/Budibase/budibase.git
33 changed files with 4344 additions and 1280 deletions
@ -0,0 +1,86 @@ |
|||
<script> |
|||
import { Label, Select, Body } from "@budibase/bbui" |
|||
import { findAllMatchingComponents } from "builderStore/componentUtils" |
|||
import { currentAsset } from "builderStore" |
|||
import { onMount } from "svelte" |
|||
|
|||
export let parameters |
|||
|
|||
$: tables = findAllMatchingComponents($currentAsset?.props, component => |
|||
component._component.endsWith("table") |
|||
).map(table => ({ |
|||
label: table._instanceName, |
|||
value: table._id, |
|||
})) |
|||
|
|||
$: tableBlocks = findAllMatchingComponents($currentAsset?.props, component => |
|||
component._component.endsWith("tableblock") |
|||
).map(block => ({ |
|||
label: block._instanceName, |
|||
value: `${block._id}-table`, |
|||
})) |
|||
|
|||
$: componentOptions = tables.concat(tableBlocks) |
|||
|
|||
const FORMATS = [ |
|||
{ |
|||
label: "CSV", |
|||
value: "csv", |
|||
}, |
|||
{ |
|||
label: "JSON", |
|||
value: "json", |
|||
}, |
|||
] |
|||
|
|||
onMount(() => { |
|||
if (!parameters.type) { |
|||
parameters.type = "csv" |
|||
} |
|||
}) |
|||
</script> |
|||
|
|||
<div class="root"> |
|||
<Body size="S"> |
|||
Choose the table component that you would like to export your row selection |
|||
from. |
|||
<br /> |
|||
Please ensure you have enabled row selection in the table settings. |
|||
</Body> |
|||
|
|||
<div class="params"> |
|||
<Label small>Table</Label> |
|||
<Select |
|||
bind:value={parameters.tableComponentId} |
|||
options={componentOptions} |
|||
/> |
|||
|
|||
<Label small>Export as</Label> |
|||
<Select bind:value={parameters.type} options={FORMATS} /> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
.root { |
|||
width: 100%; |
|||
max-width: 500px; |
|||
margin: 0 auto; |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: flex-start; |
|||
align-items: stretch; |
|||
gap: var(--spacing-xl); |
|||
} |
|||
|
|||
.root :global(p) { |
|||
line-height: 1.5; |
|||
} |
|||
|
|||
.params { |
|||
display: grid; |
|||
column-gap: var(--spacing-xs); |
|||
row-gap: var(--spacing-s); |
|||
grid-template-columns: 70px 1fr; |
|||
align-items: center; |
|||
} |
|||
</style> |
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
@ -1,61 +1,66 @@ |
|||
export const buildAttachmentEndpoints = API => ({ |
|||
/** |
|||
* Uploads an attachment to the server. |
|||
* @param data the attachment to upload |
|||
* @param tableId the table ID to upload to |
|||
*/ |
|||
uploadAttachment: async ({ data, tableId }) => { |
|||
return await API.post({ |
|||
url: `/api/attachments/${tableId}/upload`, |
|||
body: data, |
|||
json: false, |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* Uploads an attachment to the server as a builder user from the builder. |
|||
* @param data the data to upload |
|||
*/ |
|||
uploadBuilderAttachment: async data => { |
|||
return await API.post({ |
|||
url: "/api/attachments/process", |
|||
body: data, |
|||
json: false, |
|||
}) |
|||
}, |
|||
|
|||
export const buildAttachmentEndpoints = API => { |
|||
/** |
|||
* Generates a signed URL to upload a file to an external datasource. |
|||
* @param datasourceId the ID of the datasource to upload to |
|||
* @param bucket the name of the bucket to upload to |
|||
* @param key the name of the file to upload to |
|||
*/ |
|||
getSignedDatasourceURL: async ({ datasourceId, bucket, key }) => { |
|||
const getSignedDatasourceURL = async ({ datasourceId, bucket, key }) => { |
|||
return await API.post({ |
|||
url: `/api/attachments/${datasourceId}/url`, |
|||
body: { bucket, key }, |
|||
}) |
|||
}, |
|||
} |
|||
|
|||
/** |
|||
* Uploads a file to an external datasource. |
|||
* @param datasourceId the ID of the datasource to upload to |
|||
* @param bucket the name of the bucket to upload to |
|||
* @param key the name of the file to upload to |
|||
* @param data the file to upload |
|||
*/ |
|||
externalUpload: async ({ datasourceId, bucket, key, data }) => { |
|||
const { signedUrl, publicUrl } = await API.getSignedDatasourceURL({ |
|||
datasourceId, |
|||
bucket, |
|||
key, |
|||
}) |
|||
await API.put({ |
|||
url: signedUrl, |
|||
body: data, |
|||
json: false, |
|||
external: true, |
|||
}) |
|||
return { publicUrl } |
|||
}, |
|||
}) |
|||
return { |
|||
getSignedDatasourceURL, |
|||
|
|||
/** |
|||
* Uploads an attachment to the server. |
|||
* @param data the attachment to upload |
|||
* @param tableId the table ID to upload to |
|||
*/ |
|||
uploadAttachment: async ({ data, tableId }) => { |
|||
return await API.post({ |
|||
url: `/api/attachments/${tableId}/upload`, |
|||
body: data, |
|||
json: false, |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* Uploads an attachment to the server as a builder user from the builder. |
|||
* @param data the data to upload |
|||
*/ |
|||
uploadBuilderAttachment: async data => { |
|||
return await API.post({ |
|||
url: "/api/attachments/process", |
|||
body: data, |
|||
json: false, |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* Uploads a file to an external datasource. |
|||
* @param datasourceId the ID of the datasource to upload to |
|||
* @param bucket the name of the bucket to upload to |
|||
* @param key the name of the file to upload to |
|||
* @param data the file to upload |
|||
*/ |
|||
externalUpload: async ({ datasourceId, bucket, key, data }) => { |
|||
console.log(API) |
|||
const { signedUrl, publicUrl } = await getSignedDatasourceURL({ |
|||
datasourceId, |
|||
bucket, |
|||
key, |
|||
}) |
|||
await API.put({ |
|||
url: signedUrl, |
|||
body: data, |
|||
json: false, |
|||
external: true, |
|||
}) |
|||
return { publicUrl } |
|||
}, |
|||
} |
|||
} |
|||
|
|||
File diff suppressed because it is too large
Loading…
Reference in new issue