42 lines
1.4 KiB
JavaScript
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();
|
|
},
|
|
]);
|