'use strict';
app.controller('signaturePoliciesController', ['$scope', '$http', '$modal', '$timeout', '$translate', 'blockUI', 'lib', function ($scope, $http, $modal, $timeout, $translate, blockUI, lib) {

	$scope.policyTypes = ['Cades', 'Pades', 'Xml'];
	$scope.policies = null;

	var init = function () {
		if (!lib.checkIsAuthenticated()) {
			return;
		}
		$http.get('/Api/SignaturePolicies').then(function (response) {
			$scope.policies = response.data;
		}, lib.handleRestError);
	};

	$scope.showPolicy = function (policy) {
		var modalInstance = $modal.open({
			templateUrl: views.signaturePolicyDetails,
			controller: 'signaturePolicyDetailsController',
			size: 'lg',
			resolve: {
				modelId: function () {
					return policy.id;
				},
				isEditorEnabled: function () {
					return false;
				}
			}
		});
		modalInstance.result.then(init, init);
	};

	init();
}]);
