diff --git a/app/edge/components/EdgeCheckInIntervalField.tsx b/app/edge/components/EdgeCheckInIntervalField.tsx
new file mode 100644
index 000000000..056dca1e2
--- /dev/null
+++ b/app/edge/components/EdgeCheckInIntervalField.tsx
@@ -0,0 +1,94 @@
+import { useEffect, useState } from 'react';
+
+import { FormControl } from '@/portainer/components/form-components/FormControl';
+import { Select } from '@/portainer/components/form-components/Input';
+import { useSettings } from '@/portainer/settings/settings.service';
+import { r2a } from '@/react-tools/react2angular';
+
+interface Props {
+ value: number;
+ onChange(value: number): void;
+ isDefaultHidden?: boolean;
+ label?: string;
+ tooltip?: string;
+}
+
+export const checkinIntervalOptions = [
+ { label: 'Use default interval', value: 0 },
+ {
+ label: '5 seconds',
+ value: 5,
+ },
+ {
+ label: '10 seconds',
+ value: 10,
+ },
+ {
+ label: '30 seconds',
+ value: 30,
+ },
+ { label: '5 minutes', value: 300 },
+ { label: '1 hour', value: 3600 },
+ { label: '1 day', value: 86400 },
+];
+
+export function EdgeCheckinIntervalField({
+ value,
+ onChange,
+ isDefaultHidden = false,
+ label = 'Poll frequency',
+ tooltip = 'Interval used by this Edge agent to check in with the Portainer instance. Affects Edge environment management and Edge compute features.',
+}: Props) {
+ const options = useOptions(isDefaultHidden);
+
+ return (
+
+
+ );
+}
+
+export const EdgeCheckinIntervalFieldAngular = r2a(EdgeCheckinIntervalField, [
+ 'value',
+ 'onChange',
+]);
+
+function useOptions(isDefaultHidden: boolean) {
+ const [options, setOptions] = useState(checkinIntervalOptions);
+
+ const settingsQuery = useSettings(
+ (settings) => settings.EdgeAgentCheckinInterval
+ );
+
+ useEffect(() => {
+ if (isDefaultHidden) {
+ setOptions(checkinIntervalOptions.filter((option) => option.value !== 0));
+ }
+
+ if (!isDefaultHidden && typeof settingsQuery.data !== 'undefined') {
+ setOptions((options) => {
+ let label = `${settingsQuery.data} seconds`;
+ const option = options.find((o) => o.value === settingsQuery.data);
+ if (option) {
+ label = option.label;
+ }
+
+ return [
+ {
+ value: 0,
+ label: `Use default interval (${label})`,
+ },
+ ...options.slice(1),
+ ];
+ });
+ }
+ }, [settingsQuery.data, setOptions, isDefaultHidden]);
+
+ return options;
+}
diff --git a/app/edge/components/index.ts b/app/edge/components/index.ts
index 408b0a567..413afe19a 100644
--- a/app/edge/components/index.ts
+++ b/app/edge/components/index.ts
@@ -1,7 +1,9 @@
import angular from 'angular';
+import { EdgeCheckinIntervalFieldAngular } from './EdgeCheckInIntervalField';
import { EdgeScriptFormAngular } from './EdgeScriptForm';
export const componentsModule = angular
.module('app.edge.components', [])
+ .component('edgeCheckinIntervalField', EdgeCheckinIntervalFieldAngular)
.component('edgeScriptForm', EdgeScriptFormAngular).name;
diff --git a/app/portainer/settings/edge-compute/EdgeComputeSettings/EdgeComputeSettings.tsx b/app/portainer/settings/edge-compute/EdgeComputeSettings/EdgeComputeSettings.tsx
index 216a6fc63..45ca781c3 100644
--- a/app/portainer/settings/edge-compute/EdgeComputeSettings/EdgeComputeSettings.tsx
+++ b/app/portainer/settings/edge-compute/EdgeComputeSettings/EdgeComputeSettings.tsx
@@ -2,10 +2,11 @@ import { Formik, Form } from 'formik';
import { Switch } from '@/portainer/components/form-components/SwitchField/Switch';
import { FormControl } from '@/portainer/components/form-components/FormControl';
-import { Select } from '@/portainer/components/form-components/Input/Select';
import { Widget, WidgetBody, WidgetTitle } from '@/portainer/components/widget';
import { LoadingButton } from '@/portainer/components/Button/LoadingButton';
import { TextTip } from '@/portainer/components/Tip/TextTip';
+import { EdgeCheckinIntervalField } from '@/edge/components/EdgeCheckInIntervalField';
+import { FormSectionTitle } from '@/portainer/components/form-components/FormSectionTitle';
import { Settings } from '../types';
@@ -23,39 +24,18 @@ interface Props {
onSubmit(values: FormValues): void;
}
-const checkinIntervalOptions = [
- {
- value: 5,
- label: '5 seconds',
- },
- {
- value: 10,
- label: '10 seconds',
- },
- {
- value: 30,
- label: '30 seconds',
- },
-];
-
export function EdgeComputeSettings({ settings, onSubmit }: Props) {
if (!settings) {
return null;
}
- const initialValues: FormValues = {
- EdgeAgentCheckinInterval: settings.EdgeAgentCheckinInterval,
- EnableEdgeComputeFeatures: settings.EnableEdgeComputeFeatures,
- EnforceEdgeID: settings.EnforceEdgeID,
- };
-
return (
validationSchema()}
onSubmit={onSubmit}
@@ -76,26 +56,7 @@ export function EdgeComputeSettings({ settings, onSubmit }: Props) {
noValidate
>
-
-
-
+ Check-in Intervals
+
+
+ setFieldValue('EdgeAgentCheckinInterval', value)
+ }
+ isDefaultHidden
+ label="Edge agent default poll frequency"
+ tooltip="Interval used by default by each Edge agent to check in with the Portainer instance. Affects Edge environment management and Edge compute features."
+ />
+
{
+ $scope.formValues = {
+ ...$scope.formValues,
+ [name]: value,
+ };
+ });
+ }
+
$scope.addDockerEndpoint = function () {
var name = $scope.formValues.Name;
var URL = $filter('stripprotocol')($scope.formValues.URL);
@@ -320,7 +318,7 @@ angular
$scope.availableTags = data.tags;
const settings = data.settings;
- $scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`;
+
$scope.agentSecret = settings.AgentSecret;
})
.catch(function error(err) {
diff --git a/app/portainer/views/endpoints/create/createendpoint.html b/app/portainer/views/endpoints/create/createendpoint.html
index 5bf120a05..b6e146290 100644
--- a/app/portainer/views/endpoints/create/createendpoint.html
+++ b/app/portainer/views/endpoints/create/createendpoint.html
@@ -315,24 +315,10 @@
-
diff --git a/app/portainer/views/endpoints/edit/endpoint.html b/app/portainer/views/endpoints/edit/endpoint.html
index 231e0416f..baaa1c80b 100644
--- a/app/portainer/views/endpoints/edit/endpoint.html
+++ b/app/portainer/views/endpoints/edit/endpoint.html
@@ -137,23 +137,12 @@
-