mirror of https://github.com/Budibase/budibase.git
41 changed files with 3230 additions and 1336 deletions
@ -0,0 +1,71 @@ |
|||
<script> |
|||
import { Label, Select, Body } from "@budibase/bbui" |
|||
import { tables } from "stores/backend" |
|||
import { onMount } from "svelte" |
|||
|
|||
export let parameters |
|||
$: tableOptions = $tables.list || [] |
|||
|
|||
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 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.tableId} |
|||
options={tableOptions} |
|||
getOptionLabel={option => option.name} |
|||
getOptionValue={option => option._id} |
|||
/> |
|||
|
|||
<Label small>Type</Label> |
|||
<Select bind:value={parameters.type} options={FORMATS} /> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
.root { |
|||
width: 100%; |
|||
max-width: 800px; |
|||
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-l); |
|||
row-gap: var(--spacing-s); |
|||
grid-template-columns: 100px 1fr; |
|||
align-items: center; |
|||
} |
|||
</style> |
|||
File diff suppressed because one or more lines are too long
@ -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