mirror of https://github.com/gophish/gophish
Working on adding campaign results page
parent
79cef0341e
commit
5f1bd43344
|
@ -167,7 +167,7 @@ func Campaigns_Id(w http.ResponseWriter, r *http.Request) {
|
|||
Title string
|
||||
Flashes []interface{}
|
||||
}{Title: "Results", User: ctx.Get(r, "user").(models.User)}
|
||||
getTemplate(w, "dashboard").ExecuteTemplate(w, "base", params)
|
||||
getTemplate(w, "campaign_results").ExecuteTemplate(w, "base", params)
|
||||
}
|
||||
|
||||
func Login(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
7
db/db.go
7
db/db.go
|
@ -38,7 +38,7 @@ func Setup() error {
|
|||
`CREATE TABLE campaigns (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, created_date TIMESTAMP NOT NULL, completed_date TIMESTAMP, template TEXT, status TEXT NOT NULL);`,
|
||||
`CREATE TABLE targets (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT NOT NULL, UNIQUE(email));`,
|
||||
`CREATE TABLE groups (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, modified_date TIMESTAMP NOT NULL);`,
|
||||
`CREATE TABLE campaign_results (cid INTEGER NOT NULL, email TEXT NOT NULL, result TEXT NOT NULL, FOREIGN KEY (cid) REFERENCES users(id), UNIQUE(cid, email))`,
|
||||
`CREATE TABLE campaign_results (cid INTEGER NOT NULL, email TEXT NOT NULL, status TEXT NOT NULL, FOREIGN KEY (cid) REFERENCES campaigns(id), UNIQUE(cid, email, status))`,
|
||||
`CREATE TABLE user_campaigns (uid INTEGER NOT NULL, cid INTEGER NOT NULL, FOREIGN KEY (uid) REFERENCES users(id), FOREIGN KEY (cid) REFERENCES campaigns(id), UNIQUE(uid, cid))`,
|
||||
`CREATE TABLE user_groups (uid INTEGER NOT NULL, gid INTEGER NOT NULL, FOREIGN KEY (uid) REFERENCES users(id), FOREIGN KEY (gid) REFERENCES groups(id), UNIQUE(uid, gid))`,
|
||||
`CREATE TABLE group_targets (gid INTEGER NOT NULL, tid INTEGER NOT NULL, FOREIGN KEY (gid) REFERENCES groups(id), FOREIGN KEY (tid) REFERENCES targets(id), UNIQUE(gid, tid));`,
|
||||
|
@ -119,6 +119,10 @@ func GetCampaigns(uid int64) ([]models.Campaign, error) {
|
|||
func GetCampaign(id int64, uid int64) (models.Campaign, error) {
|
||||
c := models.Campaign{}
|
||||
err := Conn.SelectOne(&c, "SELECT c.id, name, created_date, completed_date, status, template FROM campaigns c, user_campaigns uc, users u WHERE uc.uid=u.id AND uc.cid=c.id AND c.id=? AND u.id=?", id, uid)
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
_, err = Conn.Select(&c.Results, "SELECT r.email, r.status FROM campaign_results r WHERE r.cid=?", c.Id)
|
||||
return c, err
|
||||
}
|
||||
|
||||
|
@ -155,7 +159,6 @@ func PostCampaign(c *models.Campaign, uid int64) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Now, let's add the user->user_groups->group mapping
|
||||
_, err = Conn.Exec("INSERT OR IGNORE INTO user_campaigns VALUES (?,?)", uid, c.Id)
|
||||
if err != nil {
|
||||
Logger.Printf("Error adding many-many mapping for campaign %s\n", c.Name)
|
||||
|
|
|
@ -108,6 +108,31 @@ app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, n
|
|||
}
|
||||
});
|
||||
|
||||
app.controller('CampaignResultsCtrl', function($scope, CampaignService, GroupService, ngTableParams, $http, $window) {
|
||||
id = $window.location.pathname.split( '/' )[2];
|
||||
$scope.flashes = []
|
||||
$scope.mainTableParams = 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) {
|
||||
CampaignService.get({"id" : id}, function(campaign) {
|
||||
$scope.campaign = campaign
|
||||
params.total(campaign.results.length)
|
||||
$defer.resolve(campaign.results.slice((params.page() - 1) * params.count(), params.page() * params.count()));
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$scope.errorFlash = function(message) {
|
||||
$scope.flashes.push({"type" : "danger", "message" : message, "icon" : "fa-exclamation-circle"})
|
||||
}
|
||||
});
|
||||
|
||||
app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) {
|
||||
$scope.mainTableParams = new ngTableParams({
|
||||
page: 1, // show first page
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
{{% define "content" %}} {{% template "nav" .User %}}
|
||||
<div class="jumbotron">
|
||||
<div class="container" style="text-align:center;">
|
||||
<h1 class="sans header">
|
||||
Dashboard
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="col-md-3 sidebar">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="active"><a href="/">Dashboard</a>
|
||||
</li>
|
||||
<li><a href="/users">Users & Groups</a>
|
||||
</li>
|
||||
<li><a href="/settings">Settings</a>
|
||||
</li>
|
||||
<li><a href="/api/">API Documentation</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-9" ng-controller="CampaignResultsCtrl">
|
||||
<div class="row">
|
||||
<h1 style="margin-top:0px;">Results for {{campaign.name}}</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-cogs fa-lg"></i>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Export</a>
|
||||
</li>
|
||||
<li><a href="#">Relaunch</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger"><i class="fa fa-times fa-lg"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<table ng-table="mainTableParams" class="table table-hover table-striped table-bordered">
|
||||
<tbody>
|
||||
<tr ng-repeat="result in $data" class="editable-row">
|
||||
<td data-title="'Email'" class="col-sm-1">{{result.email}}</td>
|
||||
<td data-title="'Status'" class="col-sm-2">{{result.status}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{% end %}}
|
Loading…
Reference in New Issue