Merge pull request #13182 from Budibase/data-provider-auto-refresh
Data provider auto-refresh
This commit is contained in:
commit
b3810cef1b
|
@ -1,4 +1,6 @@
|
||||||
import { Checkbox, Select, RadioGroup, Stepper, Input } from "@budibase/bbui"
|
import { Checkbox, Select, RadioGroup, Stepper, Input } from "@budibase/bbui"
|
||||||
|
import { licensing } from "stores/portal"
|
||||||
|
import { get } from "svelte/store"
|
||||||
import DataSourceSelect from "./controls/DataSourceSelect/DataSourceSelect.svelte"
|
import DataSourceSelect from "./controls/DataSourceSelect/DataSourceSelect.svelte"
|
||||||
import S3DataSourceSelect from "./controls/S3DataSourceSelect.svelte"
|
import S3DataSourceSelect from "./controls/S3DataSourceSelect.svelte"
|
||||||
import DataProviderSelect from "./controls/DataProviderSelect.svelte"
|
import DataProviderSelect from "./controls/DataProviderSelect.svelte"
|
||||||
|
@ -26,7 +28,8 @@ import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration
|
||||||
import ButtonConfiguration from "./controls/ButtonConfiguration/ButtonConfiguration.svelte"
|
import ButtonConfiguration from "./controls/ButtonConfiguration/ButtonConfiguration.svelte"
|
||||||
import RelationshipFilterEditor from "./controls/RelationshipFilterEditor.svelte"
|
import RelationshipFilterEditor from "./controls/RelationshipFilterEditor.svelte"
|
||||||
import FormStepConfiguration from "./controls/FormStepConfiguration.svelte"
|
import FormStepConfiguration from "./controls/FormStepConfiguration.svelte"
|
||||||
import FormStepControls from "components/design/settings/controls/FormStepControls.svelte"
|
import FormStepControls from "./controls/FormStepControls.svelte"
|
||||||
|
import PaywalledSetting from "./controls/PaywalledSetting.svelte"
|
||||||
|
|
||||||
const componentMap = {
|
const componentMap = {
|
||||||
text: DrawerBindableInput,
|
text: DrawerBindableInput,
|
||||||
|
@ -86,11 +89,16 @@ const componentMap = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getComponentForSetting = setting => {
|
export const getComponentForSetting = setting => {
|
||||||
const { type, showInBar, barStyle } = setting || {}
|
const { type, showInBar, barStyle, license } = setting || {}
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for paywalled settings
|
||||||
|
if (license && get(licensing).isFreePlan) {
|
||||||
|
return PaywalledSetting
|
||||||
|
}
|
||||||
|
|
||||||
// We can show a clone of the bar settings for certain select settings
|
// We can show a clone of the bar settings for certain select settings
|
||||||
if (showInBar && type === "select" && barStyle === "buttons") {
|
if (showInBar && type === "select" && barStyle === "buttons") {
|
||||||
return BarButtonList
|
return BarButtonList
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<script>
|
||||||
|
import { Tag, Tags } from "@budibase/bbui"
|
||||||
|
import { getFormattedPlanName } from "helpers/planTitle"
|
||||||
|
|
||||||
|
export let license
|
||||||
|
|
||||||
|
$: title = getFormattedPlanName(license)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Tags>
|
||||||
|
<Tag icon="LockClosed">{title}</Tag>
|
||||||
|
</Tags>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -183,6 +183,7 @@
|
||||||
props={{
|
props={{
|
||||||
// Generic settings
|
// Generic settings
|
||||||
placeholder: setting.placeholder || null,
|
placeholder: setting.placeholder || null,
|
||||||
|
license: setting.license,
|
||||||
|
|
||||||
// Select settings
|
// Select settings
|
||||||
options: setting.options || [],
|
options: setting.options || [],
|
||||||
|
|
|
@ -4610,6 +4610,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "filter",
|
"type": "filter",
|
||||||
"label": "Filtering",
|
"label": "Filtering",
|
||||||
|
@ -4977,6 +5006,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"label": "Title",
|
"label": "Title",
|
||||||
|
@ -5445,6 +5503,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "columns",
|
"type": "columns",
|
||||||
"label": "Columns",
|
"label": "Columns",
|
||||||
|
@ -5731,6 +5818,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "searchfield",
|
"type": "searchfield",
|
||||||
"label": "Search columns",
|
"label": "Search columns",
|
||||||
|
@ -5908,6 +6024,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "filter",
|
"type": "filter",
|
||||||
"label": "Filtering",
|
"label": "Filtering",
|
||||||
|
@ -6504,6 +6649,35 @@
|
||||||
"key": "dataSource",
|
"key": "dataSource",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Auto-refresh",
|
||||||
|
"key": "autoRefresh",
|
||||||
|
"license": "premium",
|
||||||
|
"placeholder": "Never",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "10 seconds",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 seconds",
|
||||||
|
"value": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "1 minute",
|
||||||
|
"value": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5 minutes",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 minutes",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"label": "Height",
|
"label": "Height",
|
||||||
|
|
|
@ -9,17 +9,18 @@
|
||||||
export let sortOrder
|
export let sortOrder
|
||||||
export let limit
|
export let limit
|
||||||
export let paginate
|
export let paginate
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
const { styleable, Provider, ActionTypes, API } = getContext("sdk")
|
const { styleable, Provider, ActionTypes, API } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
|
let interval
|
||||||
|
let queryExtensions = {}
|
||||||
|
|
||||||
// We need to manage our lucene query manually as we want to allow components
|
// We need to manage our lucene query manually as we want to allow components
|
||||||
// to extend it
|
// to extend it
|
||||||
let queryExtensions = {}
|
|
||||||
$: defaultQuery = LuceneUtils.buildLuceneQuery(filter)
|
$: defaultQuery = LuceneUtils.buildLuceneQuery(filter)
|
||||||
$: query = extendQuery(defaultQuery, queryExtensions)
|
$: query = extendQuery(defaultQuery, queryExtensions)
|
||||||
|
|
||||||
// Fetch data and refresh when needed
|
|
||||||
$: fetch = createFetch(dataSource)
|
$: fetch = createFetch(dataSource)
|
||||||
$: fetch.update({
|
$: fetch.update({
|
||||||
query,
|
query,
|
||||||
|
@ -28,11 +29,8 @@
|
||||||
limit,
|
limit,
|
||||||
paginate,
|
paginate,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Sanitize schema to remove hidden fields
|
|
||||||
$: schema = sanitizeSchema($fetch.schema)
|
$: schema = sanitizeSchema($fetch.schema)
|
||||||
|
$: setUpAutoRefresh(autoRefresh)
|
||||||
// Build our action context
|
|
||||||
$: actions = [
|
$: actions = [
|
||||||
{
|
{
|
||||||
type: ActionTypes.RefreshDatasource,
|
type: ActionTypes.RefreshDatasource,
|
||||||
|
@ -63,8 +61,6 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// Build our data context
|
|
||||||
$: dataContext = {
|
$: dataContext = {
|
||||||
rows: $fetch.rows,
|
rows: $fetch.rows,
|
||||||
info: $fetch.info,
|
info: $fetch.info,
|
||||||
|
@ -140,6 +136,13 @@
|
||||||
})
|
})
|
||||||
return extendedQuery
|
return extendedQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setUpAutoRefresh = autoRefresh => {
|
||||||
|
clearInterval(interval)
|
||||||
|
if (autoRefresh) {
|
||||||
|
interval = setInterval(fetch.refresh, Math.max(10000, autoRefresh * 1000))
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div use:styleable={$component.styles} class="container">
|
<div use:styleable={$component.styles} class="container">
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
export let columns = null
|
export let columns = null
|
||||||
export let onRowClick = null
|
export let onRowClick = null
|
||||||
export let buttons = null
|
export let buttons = null
|
||||||
|
export let repeat = null
|
||||||
|
|
||||||
const context = getContext("context")
|
const context = getContext("context")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
@ -122,6 +123,7 @@
|
||||||
{fixedRowHeight}
|
{fixedRowHeight}
|
||||||
{columnWhitelist}
|
{columnWhitelist}
|
||||||
{schemaOverrides}
|
{schemaOverrides}
|
||||||
|
{repeat}
|
||||||
canAddRows={allowAddRows}
|
canAddRows={allowAddRows}
|
||||||
canEditRows={allowEditRows}
|
canEditRows={allowEditRows}
|
||||||
canDeleteRows={allowDeleteRows}
|
canDeleteRows={allowDeleteRows}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
export let cardButtonOnClick
|
export let cardButtonOnClick
|
||||||
export let linkColumn
|
export let linkColumn
|
||||||
export let noRowsMessage
|
export let noRowsMessage
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
const context = getContext("context")
|
const context = getContext("context")
|
||||||
const { fetchDatasourceSchema, generateGoldenSample } = getContext("sdk")
|
const { fetchDatasourceSchema, generateGoldenSample } = getContext("sdk")
|
||||||
|
@ -184,6 +185,7 @@
|
||||||
sortOrder,
|
sortOrder,
|
||||||
paginate,
|
paginate,
|
||||||
limit,
|
limit,
|
||||||
|
autoRefresh,
|
||||||
}}
|
}}
|
||||||
order={1}
|
order={1}
|
||||||
>
|
>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
export let sortColumn
|
export let sortColumn
|
||||||
export let sortOrder
|
export let sortOrder
|
||||||
export let limit
|
export let limit
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
export let chartTitle
|
export let chartTitle
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
sortColumn,
|
sortColumn,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
limit,
|
limit,
|
||||||
|
autoRefresh,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if dataProviderId && chartType}
|
{#if dataProviderId && chartType}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
export let hAlign
|
export let hAlign
|
||||||
export let vAlign
|
export let vAlign
|
||||||
export let gap
|
export let gap
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const context = getContext("context")
|
const context = getContext("context")
|
||||||
|
@ -47,6 +48,7 @@
|
||||||
sortOrder,
|
sortOrder,
|
||||||
limit,
|
limit,
|
||||||
paginate,
|
paginate,
|
||||||
|
autoRefresh,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if $component.empty}
|
{#if $component.empty}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
export let detailFields
|
export let detailFields
|
||||||
export let detailTitle
|
export let detailTitle
|
||||||
export let noRowsMessage
|
export let noRowsMessage
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
const stateKey = generate()
|
const stateKey = generate()
|
||||||
const context = getContext("context")
|
const context = getContext("context")
|
||||||
|
@ -66,6 +67,7 @@
|
||||||
noValue: false,
|
noValue: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
autoRefresh,
|
||||||
}}
|
}}
|
||||||
styles={{
|
styles={{
|
||||||
custom: `
|
custom: `
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
export let sidePanelSaveLabel
|
export let sidePanelSaveLabel
|
||||||
export let sidePanelDeleteLabel
|
export let sidePanelDeleteLabel
|
||||||
export let notificationOverride
|
export let notificationOverride
|
||||||
|
export let autoRefresh
|
||||||
|
|
||||||
const { fetchDatasourceSchema, API, generateGoldenSample } = getContext("sdk")
|
const { fetchDatasourceSchema, API, generateGoldenSample } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
@ -243,6 +244,7 @@
|
||||||
sortOrder,
|
sortOrder,
|
||||||
paginate,
|
paginate,
|
||||||
limit: rowCount,
|
limit: rowCount,
|
||||||
|
autoRefresh,
|
||||||
}}
|
}}
|
||||||
context="provider"
|
context="provider"
|
||||||
order={1}
|
order={1}
|
||||||
|
|
Loading…
Reference in New Issue