Files
backroad/app/portainer/views/settings/settingsController.js
Chaim Lev-Ari f2e59f3b4e refactor(settings): move buckup settign to component
fix(settings/backup): sync with CE
2023-06-06 10:51:10 +07:00

42 lines
1.4 KiB
JavaScript

import angular from 'angular';
angular.module('portainer.app').controller('SettingsController', [
'$scope',
'Notifications',
'SettingsService',
'StateManager',
function ($scope, Notifications, SettingsService, StateManager) {
$scope.updateSettings = updateSettings;
function updateSettings(settings, successMessage = 'Settings updated') {
// ignore CloudApiKeys to avoid overriding them
//
// it is not ideal solution as API still accepts CloudAPIKeys
// which may override the cloud provider API keys
settings.CloudApiKeys = undefined;
return SettingsService.update(settings)
.then(function success() {
Notifications.success('Success', successMessage);
StateManager.updateLogo(settings.LogoURL);
StateManager.updateSnapshotInterval(settings.SnapshotInterval);
StateManager.updateEnableTelemetry(settings.EnableTelemetry);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to update settings');
});
}
function initView() {
SettingsService.settings()
.then(function success(settings) {
$scope.settings = settings;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve application settings');
});
}
initView();
},
]);