diff --git a/controllers/route.go b/controllers/route.go index 629cb39b..85cd66a7 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -32,10 +32,10 @@ func CreateRouter() *nosurf.CSRFHandler { api := router.PathPrefix("/api").Subrouter() api.HandleFunc("/", Use(API, mid.RequireLogin)) api.HandleFunc("/reset", Use(API_Reset, mid.RequireLogin)) - api.HandleFunc("/campaigns", Use(API_Campaigns, mid.RequireAPIKey)) + api.HandleFunc("/campaigns/", Use(API_Campaigns, mid.RequireAPIKey)) api.HandleFunc("/campaigns/{id:[0-9]+}", Use(API_Campaigns_Id, mid.RequireAPIKey)) api.HandleFunc("/campaigns/id:[0-9]+}", Use(API_Campaigns_Id_Launch, mid.RequireAPIKey)) - api.HandleFunc("/groups", Use(API_Groups, mid.RequireAPIKey)) + api.HandleFunc("/groups/", Use(API_Groups, mid.RequireAPIKey)) api.HandleFunc("/groups/{id:[0-9]+}", Use(API_Groups_Id, mid.RequireAPIKey)) // Setup static file serving diff --git a/static/js/app/controllers.js b/static/js/app/controllers.js deleted file mode 100644 index cbf09103..00000000 --- a/static/js/app/controllers.js +++ /dev/null @@ -1,13 +0,0 @@ -var gophishApp = angular.module('gophishApp', []); - -gophishApp.controller('CampaignCtrl', function($scope, $http) { - $http.get('/api/campaigns?api_key=' + API_KEY).success(function(data) { - $scope.campaigns = data; - }) -}) - -gophishApp.controller('GroupCtrl', function($scope, $http) { - $http.get('/api/groups?api_key=' + API_KEY).success(function(data) { - $scope.groups = data; - }) -}) \ No newline at end of file diff --git a/static/js/app/gophish.js b/static/js/app/gophish.js new file mode 100644 index 00000000..d2be3c68 --- /dev/null +++ b/static/js/app/gophish.js @@ -0,0 +1,38 @@ +var app = angular.module('gophish', ['ngTable', 'ngResource']); + +app.factory('CampaignService', function($resource) { + return $resource('/api/campaigns/:id?api_key=' + API_KEY); +}); + +app.factory('GroupService', function($resource) { + return $resource('/api/groups/:id?api_key=' + API_KEY); +}); + +app.controller('CampaignCtrl', function($scope, CampaignService) { + CampaignService.query(function(campaigns){ + $scope.campaigns = campaigns + }) +}); + +app.controller('GroupCtrl', function($scope, GroupService) { + GroupService.query(function(groups) { + $scope.groups = groups + }) + + $scope.editGroup = function(group) { + if (group === 'new') { + $scope.newGroup = true; + $scope.group = { + name: '', + targets: [{ + email: '' + }], + id: 0 + }; + + } else { + $scope.newGroup = false; + $scope.group = group; + } + }; +}) diff --git a/static/js/ng-resource.min.js b/static/js/ng-resource.min.js new file mode 100644 index 00000000..132e444d --- /dev/null +++ b/static/js/ng-resource.min.js @@ -0,0 +1,13 @@ +/* + AngularJS v1.2.11 + (c) 2010-2014 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(H,a,A){'use strict';function D(p,g){g=g||{};a.forEach(g,function(a,c){delete g[c]});for(var c in p)p.hasOwnProperty(c)&&("$"!==c.charAt(0)&&"$"!==c.charAt(1))&&(g[c]=p[c]);return g}var v=a.$$minErr("$resource"),C=/^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;a.module("ngResource",["ng"]).factory("$resource",["$http","$q",function(p,g){function c(a,c){this.template=a;this.defaults=c||{};this.urlParams={}}function t(n,w,l){function r(h,d){var e={};d=x({},w,d);s(d,function(b,d){u(b)&&(b=b());var k;if(b&& +b.charAt&&"@"==b.charAt(0)){k=h;var a=b.substr(1);if(null==a||""===a||"hasOwnProperty"===a||!C.test("."+a))throw v("badmember",a);for(var a=a.split("."),f=0,c=a.length;f=0){for(var i=f.split(/\[(.*)\]/).reverse(),j="",k=0,l=i.length;l>k;k++){var m=i[k];if(""!==m){var n=g;g={},g[j=m]=d(n)?parseFloat(n):n}}"sorting"===j&&(h[j]={}),h[j]=a.extend(h[j]||{},g[j])}else h[f]=d(b[f])?parseFloat(b[f]):b[f]}return c.debug&&c.debug("ngTable: set parameters",h),this}return h},this.settings=function(b){return a.isDefined(b)?(a.isArray(b.data)&&(b.total=b.data.length),i=a.extend(i,b),c.debug&&c.debug("ngTable: set settings",i),this):i},this.page=function(b){return a.isDefined(b)?this.parameters({page:b}):h.page},this.total=function(b){return a.isDefined(b)?this.settings({total:b}):i.total},this.count=function(b){return a.isDefined(b)?this.parameters({count:b,page:1}):h.count},this.filter=function(b){return a.isDefined(b)?this.parameters({filter:b}):h.filter},this.sorting=function(b){if(2==arguments.length){var c={};return c[b]=arguments[1],this.parameters({sorting:c}),this}return a.isDefined(b)?this.parameters({sorting:b}):h.sorting},this.isSortBy=function(b,c){return a.isDefined(h.sorting[b])&&h.sorting[b]==c},this.orderBy=function(){var a=[];for(var b in h.sorting)a.push(("asc"===h.sorting[b]?"+":"-")+b);return a},this.getData=function(b,c){b.resolve(a.isArray(this.data)&&a.isObject(c)?this.data.slice((c.page()-1)*c.count(),c.page()*c.count()):[])},this.getGroups=function(d,e){var f=b.defer();f.promise.then(function(b){var f={};a.forEach(b,function(b){var c=a.isFunction(e)?e(b):b[e];f[c]=f[c]||{data:[]},f[c].value=c,f[c].data.push(b)});var g=[];for(var h in f)g.push(f[h]);c.debug&&c.debug("ngTable: refresh groups",g),d.resolve(g)}),this.getData(f,g)},this.generatePagesArray=function(a,b,c){var d,e,f,g,h,i;if(d=11,i=[],h=Math.ceil(b/c),h>1){i.push({type:"prev",number:Math.max(1,a-1),active:a>1}),i.push({type:"first",number:1,active:a>1}),f=Math.round((d-5)/2),g=Math.max(2,a-f),e=Math.min(h-1,a+2*f-(a-g)),g=Math.max(2,g-(2*f-(e-g)));for(var j=g;e>=j;)i.push(j===g&&2!==j||j===e&&j!==h-1?{type:"more",active:!1}:{type:"page",number:j,active:a!==j}),j++;i.push({type:"last",number:h,active:a!==h}),i.push({type:"next",number:Math.min(h,a+1),active:h>a})}return i},this.url=function(b){b=b||!1;var c=b?[]:{};for(key in h)if(h.hasOwnProperty(key)){var d=h[key],e=encodeURIComponent(key);if("object"==typeof d){for(var f in d)if(!a.isUndefined(d[f])&&""!==d[f]){var g=e+"["+encodeURIComponent(f)+"]";b?c.push(g+"="+d[f]):c[g]=d[f]}}else a.isFunction(d)||a.isUndefined(d)||""===d||(b?c.push(e+"="+encodeURIComponent(d)):c[e]=encodeURIComponent(d))}return c},this.reload=function(){var a=b.defer(),d=this;i.$loading=!0,i.groupBy?i.getGroups(a,i.groupBy,this):i.getData(a,this),c.debug&&c.debug("ngTable: reload data"),a.promise.then(function(a){i.$loading=!1,c.debug&&c.debug("ngTable: current scope",i.$scope),d.data=i.groupBy?i.$scope.$groups=a:i.$scope.$data=a,i.$scope.pages=d.generatePagesArray(d.page(),d.total(),d.count())})},this.reloadPages=function(){var a=this;i.$scope.pages=a.generatePagesArray(a.page(),a.total(),a.count())};var h=this.$params={page:1,count:1,filter:{},sorting:{},group:{},groupBy:null},i={$scope:null,$loading:!1,data:null,total:0,counts:[10,25,50,100],getGroups:this.getGroups,getData:this.getData};return this.settings(f),this.parameters(e,!0),this};return e}]);var c=["$scope","ngTableParams","$q",function(a,b){a.$loading=!1,a.params||(a.params=new b),a.params.settings().$scope=a,a.$watch("params.$params",function(){a.params.settings().$scope=a,a.params.reload()},!0),a.sortBy=function(b,c){var d=a.parse(b.sortable);if(d){var e=a.params.sorting()&&a.params.sorting()[d]&&"desc"===a.params.sorting()[d],f=c.ctrlKey?a.params.sorting():{};f[d]=e?"asc":"desc",a.params.parameters({sorting:f})}}}];return b.directive("ngTable",["$compile","$q","$parse",function(b,d,e){"use strict";return{restrict:"A",priority:1001,scope:!0,controller:c,compile:function(c){var d=[],f=0,g=null,h=c.find("thead");return a.forEach(a.element(c.find("tr")),function(b){b=a.element(b),b.hasClass("ng-table-group")||g||(g=b)}),g?(a.forEach(g.find("td"),function(b){var c=a.element(b);if(!c.attr("ignore-cell")||"true"!==c.attr("ignore-cell")){var g=function(a,b){return function(f){return e(c.attr("x-data-"+a)||c.attr("data-"+a)||c.attr(a))(f,{$columns:d})||b}},h=g("title"," "),i=g("header",!1),j=g("filter",!1)(),k=!1,l=!1;j&&j.name&&(l=j.name,delete j.name),j&&j.templateURL&&(k=j.templateURL,delete j.templateURL),c.attr("data-title-text",h()),d.push({id:f++,title:h,sortable:g("sortable",!1),"class":c.attr("x-data-header-class")||c.attr("data-header-class")||c.attr("header-class"),filter:j,filterTemplateURL:k,filterName:l,headerTemplateURL:i,filterData:c.attr("filter-data")?c.attr("filter-data"):null,show:c.attr("ng-show")?function(a){return e(c.attr("ng-show"))(a)}:function(){return!0}})}}),function(c,f,g){if(c.$loading=!1,c.$columns=d,c.$watch(g.ngTable,function(b){a.isUndefined(b)||(c.paramsModel=e(g.ngTable),c.params=b)},!0),c.parse=function(b){return a.isDefined(b)?b(c):""},g.showFilter&&c.$parent.$watch(g.showFilter,function(a){c.show_filter=a}),a.forEach(d,function(b){var d;if(b.filterData){if(d=e(b.filterData)(c,{$column:b}),!a.isObject(d)||!a.isObject(d.promise))throw new Error("Function "+b.filterData+" must be instance of $q.defer()");return delete b.filterData,d.promise.then(function(c){a.isArray(c)||(c=[]),c.unshift({title:"-",id:""}),b.data=c})}}),!f.hasClass("ng-table")){c.templates={header:g.templateHeader?g.templateHeader:"ng-table/header.html",pagination:g.templatePagination?g.templatePagination:"ng-table/pager.html"};var i=h.length>0?h:a.element(document.createElement("thead")).attr("ng-include","templates.header"),j=a.element(document.createElement("div")).attr("ng-include","templates.pagination");f.find("thead").remove();{f.find("tbody")}return f.prepend(i),b(i)(c),b(j)(c),f.addClass("ng-table"),f.after(j)}}):void 0}}}]),a.module("ngTable").run(["$templateCache",function(a){a.put("ng-table/filters/select-multiple.html",''),a.put("ng-table/filters/select.html",''),a.put("ng-table/filters/text.html",''),a.put("ng-table/header.html",'
'),a.put("ng-table/pager.html",'
')}]),b}); +//# sourceMappingURL=ng-table.map \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index d6f6f6e6..1d3f32a2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {{% define "base" %}} - + @@ -37,7 +37,9 @@ - + + + diff --git a/templates/dashboard.html b/templates/dashboard.html index bf12f047..56f5acaa 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -25,7 +25,7 @@  
- +
@@ -43,12 +43,12 @@ Toggle Dropdown diff --git a/templates/users.html b/templates/users.html index 98cc5c4e..a73a74f2 100644 --- a/templates/users.html +++ b/templates/users.html @@ -6,7 +6,7 @@ -
+
-
+
- +
 
-
Date
+
@@ -46,12 +46,12 @@ Toggle Dropdown @@ -62,37 +62,38 @@
Name
- - -