Files
portainer/app/portainer/views/settings/edge-compute/settingsEdgeComputeController.js
T
2024-06-10 16:05:24 +03:00

71 lines
2.2 KiB
JavaScript

import _ from 'lodash-es';
import angular from 'angular';
import { configureFDO } from '@/portainer/hostmanagement/fdo/fdo.service';
import { configureAMT } from 'Portainer/hostmanagement/open-amt/open-amt.service';
import { getSettings } from '@/react/portainer/settings/queries/useSettings';
angular.module('portainer.app').controller('SettingsEdgeComputeController', SettingsEdgeComputeController);
/* @ngInject */
export default function SettingsEdgeComputeController($q, $async, $state, Notifications, SettingsService) {
var ctrl = this;
this.onSubmitEdgeCompute = async function (settings) {
try {
await SettingsService.update(settings);
Notifications.success('Success', 'Settings updated');
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Unable to update settings');
}
};
this.onSubmitOpenAMT = async function (formValues) {
try {
await configureAMT(formValues);
Notifications.success('Success', `OpenAMT successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Failed applying changes');
}
};
this.onSubmitFDO = async function (formValues) {
try {
await configureFDO(formValues);
Notifications.success('Success', `FDO successfully ${formValues.enabled ? 'enabled' : 'disabled'}`);
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Failed applying changes');
}
};
function initView() {
$async(async () => {
try {
const settings = await getSettings();
const defaultMTLS = {
..._.get(settings, 'Edge.MTLS', {}),
UseSeparateCert: _.get(settings, 'Edge.MTLS.UseSeparateCert', false),
};
ctrl.settings = {
...settings,
EnableEdgeComputeFeatures: !!settings.EnableEdgeComputeFeatures,
EnforceEdgeID: !!settings.EnforceEdgeID,
Edge: {
...settings.Edge,
MTLS: defaultMTLS,
},
};
} catch (err) {
Notifications.error('Failure', err, 'Unable to retrieve application settings');
}
});
}
initView();
}