diff --git a/models/campaign.go b/models/campaign.go index c3efbd16..f4706913 100644 --- a/models/campaign.go +++ b/models/campaign.go @@ -226,14 +226,14 @@ func PostCampaign(c *Campaign, uid int64) error { for _, g := range c.Groups { // Insert a result for each target in the group for _, t := range g.Targets { - r := Result{Email: t.Email, Status: STATUS_UNKNOWN, CampaignId: c.Id, UserId: c.UserId, FirstName: t.FirstName, LastName: t.LastName} + r := &Result{Email: t.Email, Status: STATUS_SENDING, CampaignId: c.Id, UserId: c.UserId, FirstName: t.FirstName, LastName: t.LastName} r.GenerateId() - err = db.Save(&r).Error + err = db.Save(r).Error if err != nil { Logger.Printf("Error adding result record for target %s\n", t.Email) Logger.Println(err) } - c.Results = append(c.Results, r) + c.Results = append(c.Results, *r) } } return nil diff --git a/models/models.go b/models/models.go index 68c8d09c..e4907f8d 100644 --- a/models/models.go +++ b/models/models.go @@ -34,6 +34,7 @@ const ( EVENT_OPENED string = "Email Opened" EVENT_CLICKED string = "Clicked Link" STATUS_SUCCESS string = "Success" + STATUS_SENDING string = "Sending" STATUS_UNKNOWN string = "Unknown" ERROR string = "Error" ) diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js index 440b3439..74f01bc2 100644 --- a/static/js/app/campaign_results.js +++ b/static/js/app/campaign_results.js @@ -44,6 +44,12 @@ var statuses = { label: "label-default", icon: "fa-question" }, + "Sending": { + slice: "ct-slice-donut-error", + legend: "ct-legend-error", + label: "label-primary", + icon: "fa-spinner" + }, "Campaign Created": { label: "label-success", icon: "fa-rocket" diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js index 2768ca75..e6c7052b 100644 --- a/static/js/app/campaigns.js +++ b/static/js/app/campaigns.js @@ -10,7 +10,7 @@ var labels = { var campaigns = [] -// Save attempts to POST to /campaigns/ +// Launch attempts to POST to /campaigns/ function launch() { if (!confirm("This will launch the campaign. Are you sure?")) { return false; @@ -22,31 +22,35 @@ function launch() { }) }) var campaign = { - name: $("#name").val(), - template: { - name: $("#template").val() - }, - url: $("#url").val(), - page: { - name: $("#page").val() - }, - smtp: { - from_address: $("input[name=from]").val(), - host: $("input[name=host]").val(), - username: $("input[name=username]").val(), - password: $("input[name=password]").val(), - }, - groups: groups - } + name: $("#name").val(), + template: { + name: $("#template").val() + }, + url: $("#url").val(), + page: { + name: $("#page").val() + }, + smtp: { + from_address: $("input[name=from]").val(), + host: $("input[name=host]").val(), + username: $("input[name=username]").val(), + password: $("input[name=password]").val(), + }, + groups: groups + } + launchHtml = $("launchButton").html() + $("launchButton").html(' Launching Campaign') // Submit the campaign api.campaigns.post(campaign) .success(function(data) { successFlash("Campaign successfully launched!") + $("launchButton").html(' Redirecting') window.location = "/campaigns/" + data.id.toString() }) .error(function(data) { $("#modal\\.flashes").empty().append("