feat(frontend): set default app refesh interval (#5380)

This commit is contained in:
Alexander Petric
2025-02-25 17:21:36 -05:00
committed by GitHub
parent 47c8b334ef
commit 478d3fbf4a
2 changed files with 34 additions and 2 deletions
@@ -21,7 +21,8 @@
export let render: boolean
export let horizontalAlignment: 'left' | 'center' | 'right' | undefined = undefined
const { app, worldStore, policy } = getContext<AppViewerContext>('AppViewerContext')
const { app, worldStore, policy, recomputeAllContext } =
getContext<AppViewerContext>('AppViewerContext')
let resolvedConfig = initConfig(
components['recomputeallcomponent'].initialData.configuration,
@@ -35,6 +36,22 @@
initializing = false
let css = initCss($app.css?.recomputeallcomponent, customCss)
$: resolvedConfig.defaultRefreshInterval && handleRefreshInterval()
function handleRefreshInterval() {
if (resolvedConfig.defaultRefreshInterval !== undefined) {
const newInterval =
typeof resolvedConfig.defaultRefreshInterval === 'number'
? resolvedConfig.defaultRefreshInterval * 1000
: parseInt(resolvedConfig.defaultRefreshInterval) * 1000
if (newInterval !== $recomputeAllContext.interval) {
$recomputeAllContext.setInter?.(newInterval)
}
}
}
</script>
{#each Object.keys(components['recomputeallcomponent'].initialData.configuration) as key (key)}
@@ -4157,7 +4157,22 @@ See date-fns format for more information. By default, it is 'dd.MM.yyyy HH:mm'
initialData: {
...defaultAlignement,
componentInput: undefined,
configuration: {},
configuration: {
defaultRefreshInterval: {
fieldType: 'select',
type: 'static',
selectOptions: [
{ value: '0', label: 'Once' },
{ value: '5', label: 'Every 5 seconds' },
{ value: '10', label: 'Every 10 seconds' },
{ value: '15', label: 'Every 15 seconds' },
{ value: '20', label: 'Every 20 seconds' },
{ value: '25', label: 'Every 25 seconds' },
{ value: '30', label: 'Every 30 seconds' }
],
value: '0'
}
},
menuItems: true
}
}