diff --git a/static/js/app/gophish.js b/static/js/app/gophish.js index b7dd729b..3c44533b 100644 --- a/static/js/app/gophish.js +++ b/static/js/app/gophish.js @@ -1,9 +1,7 @@ var app = angular.module('gophish', ['ngTable', 'ngResource']); app.factory('CampaignService', function($resource) { - return $resource('/api/campaigns/:id?api_key=' + API_KEY, { - id: "@id" - }, { + return $resource('/api/campaigns/:id?api_key=' + API_KEY, {}, { update: { method: 'PUT' } @@ -18,20 +16,31 @@ app.factory('GroupService', function($resource) { }); }); -app.controller('CampaignCtrl', function($scope, CampaignService) { - CampaignService.query(function(campaigns) { - $scope.campaigns = campaigns - }) -}); - -app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { - - +app.controller('CampaignCtrl', function($scope, CampaignService, ngTableParams) { $scope.tableParams = new ngTableParams({ page: 1, // show first page count: 10, // count per page sorting: { - name: 'asc' // initial sorting + name: 'asc' // initial sorting + } + }, { + total: 0, // length of data + getData: function($defer, params) { + CampaignService.query(function(campaigns) { + $scope.campaigns = campaigns + params.total(campaigns.length) + $defer.resolve(campaigns.slice((params.page() - 1) * params.count(), params.page() * params.count())); + }) + } + }); +}); + +app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { + $scope.mainTableParams = new ngTableParams({ + page: 1, // show first page + count: 10, // count per page + sorting: { + name: 'asc' // initial sorting } }, { total: 0, // length of data @@ -44,6 +53,20 @@ app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { } }); + $scope.editGroupTableParams = new ngTableParams({ + page: 1, // show first page + count: 10, // count per page + sorting: { + name: 'asc' // initial sorting + } + }, { + total: 0, // length of data + getData: function($defer, params) { + params.total($scope.group.targets.length) + $defer.resolve($scope.group.targets.slice((params.page() - 1) * params.count(), params.page() * params.count())); + } + }); + $scope.editGroup = function(group) { if (group === 'new') { $scope.newGroup = true; @@ -56,6 +79,7 @@ app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { } else { $scope.newGroup = false; $scope.group = group; + $scope.editGroupTableParams.reload() } }; @@ -65,10 +89,12 @@ app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { email: $scope.newTarget.email }); $scope.newTarget.email = "" + $scope.editGroupTableParams.reload() } }; $scope.removeTarget = function(target) { $scope.group.targets.splice($scope.group.targets.indexOf(target), 1); + $scope.editGroupTableParams.reload() }; $scope.saveGroup = function(group) { var newGroup = new GroupService($scope.group); diff --git a/templates/dashboard.html b/templates/dashboard.html index 748d21eb..0a82d286 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -25,18 +25,11 @@  
- - - - - - - - +
DateNameStatus
- - - + + - +
{{campaign.created_date | date:'medium'}}{{campaign.name}} +
{{campaign.created_date | date:'medium'}}{{campaign.name}}
{{campaign.status}}{{campaign.status}}
diff --git a/templates/users.html b/templates/users.html index 9a770373..4d53a952 100644 --- a/templates/users.html +++ b/templates/users.html @@ -25,7 +25,7 @@
 
- +
@@ -82,9 +82,9 @@
-
{{group.name}}
+
- +
{{target.email}}