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 ( + + - setFieldValue( - 'EdgeAgentCheckinInterval', - parseInt(e.currentTarget.value, 10) - ) - } - options={checkinIntervalOptions} - /> - - - + 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 @@
-
- -
- -
+ +
+
Check-in Intervals
+
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 @@ -
- -
- -
+ +
+
Check-in Intervals
+
+ { + $scope.endpoint = { + ...$scope.endpoint, + [name]: value, + }; + }); + } + $scope.updateEndpoint = function () { var endpoint = $scope.endpoint; var securityData = $scope.formValues.SecurityFormData; @@ -120,7 +118,6 @@ function EndpointController( PublicURL: endpoint.PublicURL, GroupID: endpoint.GroupId, TagIds: endpoint.TagIds, - EdgeCheckinInterval: endpoint.EdgeCheckinInterval, TLS: TLS, TLSSkipVerify: TLSSkipVerify, TLSSkipClientVerify: TLSSkipClientVerify, @@ -130,6 +127,7 @@ function EndpointController( AzureApplicationID: endpoint.AzureCredentials.ApplicationID, AzureTenantID: endpoint.AzureCredentials.TenantID, AzureAuthenticationKey: endpoint.AzureCredentials.AuthenticationKey, + EdgeCheckinInterval: endpoint.EdgeCheckinInterval, }; if ( @@ -228,8 +226,6 @@ function EndpointController( $scope.state.edgeAssociated = !!endpoint.EdgeID; endpoint.EdgeID = endpoint.EdgeID || uuidv4(); - - $scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`; } $scope.endpoint = endpoint;