Project

General

Profile

Download (1.97 KB) Statistics
| Branch: | Tag: | Revision:
/**
* Copyright 2014 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public
* License as published by the Free Software Foundation; either version
* 2 of the License (GPLv2) or (at your option) any later version.
* There is NO WARRANTY for this software, express or implied,
* including the implied warranties of MERCHANTABILITY,
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
* have received a copy of GPLv2 along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*/

/**
* @ngdoc object
* @name Bastion.gpg-keys.controller:GPGKeyDetailsController
*
* @requires $scope
* @requires GPGKey
* @requires $q
* @requires gettext
*
* @description
* Provides the functionality for the gpgKey details action pane.
*/
angular.module('Bastion.gpg-keys').controller('GPGKeyDetailsController',
['$scope', 'GPGKey', '$q', 'gettext', function ($scope, GPGKey, $q, gettext) {
$scope.errorMessages = [];
$scope.successMessages = [];

$scope.panel = $scope.panel || {loading: false};

$scope.gpgKey = GPGKey.get({id: $scope.$stateParams.gpgKeyId}, function () {
$scope.panel.loading = false;
});

$scope.save = function (gpgKey) {
var deferred = $q.defer();

gpgKey.$update(function (response) {
deferred.resolve(response);
$scope.successMessages.push(gettext('Gpg Key updated'));
$scope.table.replaceRow(response);

}, function (response) {
deferred.reject(response);
$scope.errorMessages = [response.data.displayMessage];
});

return deferred.promise;
};

$scope.removeGPGKey = function (gpgKey) {
var id = gpgKey.id;

gpgKey.$delete(function () {
$scope.removeRow(id);
$scope.transitionTo('gpgKeys.index');
});
};
}]
);
(2-2/2)