2017-06-01 08:14:55 +00:00
|
|
|
angular.module('portainer.services')
|
|
|
|
.factory('SettingsService', ['$q', 'Settings', function SettingsServiceFactory($q, Settings) {
|
|
|
|
'use strict';
|
|
|
|
var service = {};
|
|
|
|
|
|
|
|
service.settings = function() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
Settings.get().$promise
|
|
|
|
.then(function success(data) {
|
2017-06-20 11:00:32 +00:00
|
|
|
var settings = new SettingsViewModel(data);
|
|
|
|
deferred.resolve(settings);
|
2017-06-01 08:14:55 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve application settings', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.update = function(settings) {
|
|
|
|
return Settings.update({}, settings).$promise;
|
|
|
|
};
|
|
|
|
|
2017-08-10 08:35:23 +00:00
|
|
|
service.publicSettings = function() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
Settings.publicSettings().$promise
|
|
|
|
.then(function success(data) {
|
|
|
|
var settings = new SettingsViewModel(data);
|
|
|
|
deferred.resolve(settings);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve application settings', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.checkLDAPConnectivity = function(settings) {
|
|
|
|
return Settings.checkLDAPConnectivity({}, settings).$promise;
|
|
|
|
};
|
|
|
|
|
2017-06-01 08:14:55 +00:00
|
|
|
return service;
|
|
|
|
}]);
|