From d72bc4b7dff4da721fc073b67456bec9efe5c26f Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 10 Feb 2014 01:15:36 -0600 Subject: [PATCH] Updated interfacing with ng-table module. Will propagate changes to campaigns soon. Updated footer copyright year Cleaned up tables in templates --- controllers/api.go | 2 +- db/db.go | 2 +- static/css/main.css | 4 ++++ static/js/app/gophish.js | 26 ++++++++++++++++++++------ templates/base.html | 2 +- templates/users.html | 31 ++++++++++++------------------- 6 files changed, 39 insertions(+), 28 deletions(-) diff --git a/controllers/api.go b/controllers/api.go index 9aaf85c0..a42f30b5 100644 --- a/controllers/api.go +++ b/controllers/api.go @@ -190,7 +190,7 @@ func API_Groups_Id(w http.ResponseWriter, r *http.Request) { } writeJSON(w, gj) case r.Method == "DELETE": - err := db.DeleteGroup(id) + err := db.DeleteGroup(id, ctx.Get(r, "user_id").(int64)) if checkError(err, w, "Error creating JSON response") { return } diff --git a/db/db.go b/db/db.go index bc54a9b6..a32430e9 100644 --- a/db/db.go +++ b/db/db.go @@ -207,6 +207,6 @@ func PostGroup(g *models.Group, uid int64) error { return nil } -func DeleteGroup(id int64) error { +func DeleteGroup(id int64, uid int64) error { return nil } diff --git a/static/css/main.css b/static/css/main.css index e2dc5662..4d041286 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -104,4 +104,8 @@ .remove-row { float:right; cursor:pointer; + } + + .pagination { + margin:0px; } \ No newline at end of file diff --git a/static/js/app/gophish.js b/static/js/app/gophish.js index 3a254c52..b7dd729b 100644 --- a/static/js/app/gophish.js +++ b/static/js/app/gophish.js @@ -24,10 +24,25 @@ app.controller('CampaignCtrl', function($scope, CampaignService) { }) }); -app.controller('GroupCtrl', function($scope, GroupService) { - GroupService.query(function(groups) { - $scope.groups = groups - }) +app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { + + + $scope.tableParams = 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) { + GroupService.query(function(groups) { + $scope.groups = groups + params.total(groups.length) + $defer.resolve(groups.slice((params.page() - 1) * params.count(), params.page() * params.count())); + }) + } + }); $scope.editGroup = function(group) { if (group === 'new') { @@ -61,8 +76,7 @@ app.controller('GroupCtrl', function($scope, GroupService) { newGroup.$save(function() { $scope.groups.push(newGroup); }); - } - else { + } else { newGroup.$update() } } diff --git a/templates/base.html b/templates/base.html index 1d3f32a2..ed14458e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -30,7 +30,7 @@

diff --git a/templates/users.html b/templates/users.html index dca2f49b..9a770373 100644 --- a/templates/users.html +++ b/templates/users.html @@ -25,18 +25,11 @@  
- - - - - - - - +
NameMembersModified Date
- - - + + - +
{{group.name}} +
{{group.name}} {{target.email}}{{$last ? '' : ', '}} @@ -56,14 +49,14 @@ {{group.modified_date | date:'medium'}}{{group.modified_date | date:'medium'}}
-