diff --git a/static/css/dataTables.bootstrap.css b/static/css/dataTables.bootstrap.css
index fcff8398..f238fd18 100644
--- a/static/css/dataTables.bootstrap.css
+++ b/static/css/dataTables.bootstrap.css
@@ -39,6 +39,7 @@ div.dataTables_info {
div.dataTables_paginate ul.pagination {
margin: 2px 0;
white-space: nowrap;
+ float: right !important;
}
@media screen and (max-width: 767px) {
diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js
index 579f8696..73f52769 100644
--- a/static/js/app/campaigns.js
+++ b/static/js/app/campaigns.js
@@ -1,12 +1,44 @@
-$(document).ready(function(){
- campaigns.get()
+function save(){
+ var campaign = {
+ name: $("#name").val(),
+ template:{
+ name: $("#template").val()
+ },
+ smtp: {
+ from_address: $("input[name=from]").val(),
+ host: $("input[name=host]").val(),
+ username: $("input[name=username]").val(),
+ password: $("input[name=password]").val(),
+ },
+ groups: [{name : "Morning catch employees"}]
+ }
+ // Submit the campaign
+ campaigns.post(campaign)
.success(function(data){
- successFlash("worked!")
+ successFlash("submitted!")
console.log(data)
})
.error(function(data){
- errorFlash("No work")
- console.log(data)
+ $("#modal\\.flashes").empty().append("
\
+ " + data.responseJSON.message + "
")
+ })
+}
+$(document).ready(function(){
+ var campaignData = {}
+ campaigns.get()
+ .success(function(data){
+ successFlash("worked!")
+ campaignData = data
+ })
+ .error(function(data){
+ errorFlash("No work")
+ })
+ campaignTable = $("#campaignTable").DataTable();
+ $.each(campaignData, function(i, campaign){
+ campaignTable.row.add([
+ campaign.created_date,
+ campaign.name,
+ campaign.status
+ ]).draw()
})
- $("#table_id").DataTable();
})
diff --git a/static/js/gophish.js b/static/js/gophish.js
index ef80a919..f3e7f35b 100644
--- a/static/js/gophish.js
+++ b/static/js/gophish.js
@@ -15,8 +15,9 @@ function api(endpoint, method, data) {
url: "/api" + endpoint + "?api_key=" + user.api_key,
async: false,
method: method,
- data: data,
- dataType:"json"
+ data: JSON.stringify(data),
+ dataType:"json",
+ contentType: "application/json"
})
}
@@ -27,11 +28,11 @@ Define our API Endpoints
var campaigns = {
// get() - Queries the API for GET /campaigns
get: function(){
- return api("/campaigns", "GET", {})
+ return api("/campaigns/", "GET", {})
},
// post() - Posts a campaign to POST /campaigns
post: function(data){
- return api("/campaigns", "POST", data)
+ return api("/campaigns/", "POST", data)
}
}
@@ -59,11 +60,11 @@ var campaignId = {
var groups = {
// get() - Queries the API for GET /groups
get: function(){
- return api("/groups", "GET", {})
+ return api("/groups/", "GET", {})
},
// post() - Posts a campaign to POST /groups
post: function(group){
- return api("/groups", "POST", group)
+ return api("/groups/", "POST", group)
}
}
@@ -91,11 +92,11 @@ var groupId = {
var templates = {
// get() - Queries the API for GET /templates
get: function(){
- return api("/templates", "GET", {})
+ return api("/templates/", "GET", {})
},
// post() - Posts a campaign to POST /templates
post: function(template){
- return api("/templates", "POST", template)
+ return api("/templates/", "POST", template)
}
}
diff --git a/templates/campaigns.html b/templates/campaigns.html
index 0d93840e..e2258c4b 100644
--- a/templates/campaigns.html
+++ b/templates/campaigns.html
@@ -21,46 +21,31 @@
-
+
-
-
-
-
+
-
-
-
- No campaigns created yet. Let's create one!
-
+
+
+ No campaigns created yet. Let's create one!
-
-
-
-
- Column 1 |
- Column 2 |
-
-
-
-
- Row 1 Data 1 |
- Row 1 Data 2 |
-
-
- Row 2 Data 1 |
- Row 2 Data 2 |
-
-
-
+
+
+
+ Created Date |
+ Name |
+ Status |
+
+
+
+
+
-
+
-