fix(ui): tidy up Edge Devices configuration EE-3604 (#7797)

pull/7761/head
matias-portainer 2022-11-10 16:13:20 -03:00 committed by GitHub
parent e1e81731b9
commit 30e23ea5b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 17 deletions

View File

@ -4,7 +4,7 @@ import { r2a } from '@/react-tools/react2angular';
import { useSettings } from '@/react/portainer/settings/queries'; import { useSettings } from '@/react/portainer/settings/queries';
import { withReactQuery } from '@/react-tools/withReactQuery'; import { withReactQuery } from '@/react-tools/withReactQuery';
import { FormControl } from '@@/form-components/FormControl'; import { FormControl, Size } from '@@/form-components/FormControl';
import { Select } from '@@/form-components/Input'; import { Select } from '@@/form-components/Input';
interface Props { interface Props {
@ -14,6 +14,7 @@ interface Props {
label?: string; label?: string;
tooltip?: string; tooltip?: string;
readonly?: boolean; readonly?: boolean;
size?: Size;
} }
export const checkinIntervalOptions = [ export const checkinIntervalOptions = [
@ -42,11 +43,17 @@ export function EdgeCheckinIntervalField({
isDefaultHidden = false, isDefaultHidden = false,
label = 'Poll frequency', 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.', tooltip = 'Interval used by this Edge agent to check in with the Portainer instance. Affects Edge environment management and Edge compute features.',
size = 'small',
}: Props) { }: Props) {
const options = useOptions(isDefaultHidden); const options = useOptions(isDefaultHidden);
return ( return (
<FormControl inputId="edge_checkin" label={label} tooltip={tooltip}> <FormControl
inputId="edge_checkin"
label={label}
tooltip={tooltip}
size={size}
>
<Select <Select
value={value} value={value}
onChange={(e) => { onChange={(e) => {
@ -61,7 +68,15 @@ export function EdgeCheckinIntervalField({
export const EdgeCheckinIntervalFieldAngular = r2a( export const EdgeCheckinIntervalFieldAngular = r2a(
withReactQuery(EdgeCheckinIntervalField), withReactQuery(EdgeCheckinIntervalField),
['value', 'onChange', 'isDefaultHidden', 'tooltip', 'label', 'readonly'] [
'value',
'onChange',
'isDefaultHidden',
'tooltip',
'label',
'readonly',
'size',
]
); );
function useOptions(isDefaultHidden: boolean) { function useOptions(isDefaultHidden: boolean) {

View File

@ -14,6 +14,17 @@
</div> </div>
</div> </div>
<!-- !snapshot-interval --> <!-- !snapshot-interval -->
<!-- checkin-interval -->
<edge-checkin-interval-field
size="'xsmall'"
value="settings.EdgeAgentCheckinInterval"
label="'Edge agent default poll frequency'"
is-default-hidden="true"
on-change="(onChangeCheckInInterval)"
></edge-checkin-interval-field>
<!-- !checkin-interval -->
<!-- logo --> <!-- logo -->
<div class="form-group"> <div class="form-group">
<por-switch-field <por-switch-field

View File

@ -83,6 +83,13 @@ angular.module('portainer.app').controller('SettingsController', [
$scope.state.featureLimited = limited; $scope.state.featureLimited = limited;
}; };
$scope.onChangeCheckInInterval = function (interval) {
$scope.$evalAsync(() => {
var settings = $scope.settings;
settings.EdgeAgentCheckinInterval = interval;
});
};
$scope.removeFilteredContainerLabel = function (index) { $scope.removeFilteredContainerLabel = function (index) {
var settings = $scope.settings; var settings = $scope.settings;
settings.BlackListedLabels.splice(index, 1); settings.BlackListedLabels.splice(index, 1);

View File

@ -7,7 +7,7 @@ import { FormError } from '../FormError';
import styles from './FormControl.module.css'; import styles from './FormControl.module.css';
type Size = 'small' | 'medium' | 'large'; export type Size = 'xsmall' | 'small' | 'medium' | 'large';
export interface Props { export interface Props {
inputId?: string; inputId?: string;
@ -60,6 +60,8 @@ function sizeClassLabel(size?: Size) {
return 'col-sm-5 col-lg-4'; return 'col-sm-5 col-lg-4';
case 'medium': case 'medium':
return 'col-sm-4 col-lg-3'; return 'col-sm-4 col-lg-3';
case 'xsmall':
return 'col-sm-2';
default: default:
return 'col-sm-3 col-lg-2'; return 'col-sm-3 col-lg-2';
} }
@ -71,6 +73,8 @@ function sizeClassChildren(size?: Size) {
return 'col-sm-7 col-lg-8'; return 'col-sm-7 col-lg-8';
case 'medium': case 'medium':
return 'col-sm-8 col-lg-9'; return 'col-sm-8 col-lg-9';
case 'xsmall':
return 'col-sm-8';
default: default:
return 'col-sm-9 col-lg-10'; return 'col-sm-9 col-lg-10';
} }

View File

@ -1 +1,2 @@
export { FormControl } from './FormControl'; export { FormControl } from './FormControl';
export type { Size } from './FormControl';

View File

@ -83,25 +83,27 @@ export function DeploymentSyncOptions() {
</TextTip> </TextTip>
<FormSection title="Check-in Intervals"> <FormSection title="Check-in Intervals">
{!values.Edge.AsyncMode ? ( <EdgeCheckinIntervalField
<EdgeCheckinIntervalField value={values.EdgeAgentCheckinInterval}
value={values.EdgeAgentCheckinInterval} onChange={(value) =>
onChange={(value) => setFieldValue('EdgeAgentCheckinInterval', value)
setFieldValue('EdgeAgentCheckinInterval', value) }
} isDefaultHidden
isDefaultHidden label="Edge agent default poll frequency"
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."
tooltip="Interval used by default by each Edge agent to check in with the Portainer instance. Affects Edge environment management and Edge compute features." />
/> </FormSection>
) : (
{values.Edge.AsyncMode && (
<FormSection title="Async Check-in Intervals">
<EdgeAsyncIntervalsForm <EdgeAsyncIntervalsForm
values={values.Edge} values={values.Edge}
onChange={(value) => setFieldValue('Edge', value)} onChange={(value) => setFieldValue('Edge', value)}
isDefaultHidden isDefaultHidden
fieldSettings={asyncIntervalFieldSettings} fieldSettings={asyncIntervalFieldSettings}
/> />
)} </FormSection>
</FormSection> )}
<FormSection title="Actions"> <FormSection title="Actions">
<div className="form-group mt-5"> <div className="form-group mt-5">