angular.module("administrationModule")
.controller("targetsController", ["$scope", "$http", "securityService", "$filter", "$compile", "$rootScope", function ($scope, $http, securityService, $filter, $compile, $rootScope) {
$scope.status = { open: true };
var refreshAction = "refresh";
$rootScope.data = null;
$scope.accessGroupData = null;
$scope.maximumGridHeight;
var maximumRowNumbers = 4;
$scope.columns = [
{ field: "targetNumber", headerText: administrationSecurityResources.targetNumber, width: 100 },
{ field: "targetType", headerText: administrationSecurityResources.targetType, width: 100 },
{ field: "targetName", headerText: administrationSecurityResources.targetName, width: 100 },
{ field: "targetDescription", headerText: administrationSecurityResources.description, width: 100 },
{ field: "accessGroupMarking", headerText: administrationSecurityResources.accessGroup, template: "true", templateID: "#accessGroupTemplate", width: 120 },
];
$scope.targetGroupColumn = ["targetType"];
$scope.compile = function (el) {
$compile(el)($scope);
}
$scope.complete = function (args) {
if (!this.initialRender) {
$scope.compile($(".drpAccessGroup"))
}
};
$scope.setTargetList = function (targetList) {
$rootScope.data = targetList;
$rootScope.data = $filter('orderBy')($scope.data, 'targetName');
$scope.getListofAccessGroup();
//console.log($scope.data)
}
$scope.getListofAccessGroup = function () {
securityService.getAccessGroupsList()
.then(function (accessGroupData) {
$scope.accessGroupData = $filter('orderBy')(accessGroupData, 'markingString');;
//$scope.accessGroupData.splice(0, 0, { markingString: "<Unrestricted>" });
}).catch(function (error) {
});
};
}]);