Skip to content

Commit 8ba2574

Browse files
author
gauffininteractive
committed
Merge
2 parents f088d2f + c806f29 commit 8ba2574

File tree

20 files changed

+222
-39
lines changed

20 files changed

+222
-39
lines changed

src/Server/OneTrueError.Api/Core/Incidents/Queries/FindIncidents.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public FindIncidents()
7171
/// </summary>
7272
public bool ReOpened { get; set; }
7373

74+
/// <summary>
75+
/// Will be searched in incident.message and report.stacktrace.
76+
/// </summary>
77+
public string FreeText { get; set; }
78+
7479
/// <summary>
7580
/// Sort order
7681
/// </summary>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Collections.Generic;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
using DotNetCqs;
5+
using Griffin.Container;
6+
using OneTrueError.Api.Core.Support;
7+
using OneTrueError.App.Configuration;
8+
using OneTrueError.Infrastructure.Configuration;
9+
10+
namespace OneTrueError.App.Core.Support
11+
{
12+
/// <summary>
13+
/// Sends a support request to the OneTrueError Team.
14+
/// </summary>
15+
/// <remarks>
16+
/// <para>
17+
/// You must have bought commercial support or registered to get 30 days of free support.
18+
/// </para>
19+
/// </remarks>
20+
[Component]
21+
public class SendSupportRequestHandler : ICommandHandler<SendSupportRequest>
22+
{
23+
/// <inheritdoc />
24+
public async Task ExecuteAsync(SendSupportRequest command)
25+
{
26+
var baseConfig = ConfigurationStore.Instance.Load<BaseConfiguration>();
27+
var errorConfig = ConfigurationStore.Instance.Load<OneTrueErrorConfigSection>();
28+
29+
string installationId = null;
30+
var email = baseConfig.SupportEmail;
31+
if (errorConfig != null)
32+
{
33+
email = errorConfig.ContactEmail;
34+
installationId = errorConfig.InstallationId;
35+
}
36+
37+
38+
var items = new List<KeyValuePair<string, string>>();
39+
if (installationId != null)
40+
items.Add(new KeyValuePair<string, string>("InstallationId", installationId));
41+
items.Add(new KeyValuePair<string, string>("ContactEmail", email));
42+
items.Add(new KeyValuePair<string, string>("Subject", command.Subject));
43+
items.Add(new KeyValuePair<string, string>("Message", command.Message));
44+
45+
//To know which page the user had trouble with
46+
items.Add(new KeyValuePair<string, string>("PageUrl", command.Url));
47+
48+
var content = new FormUrlEncodedContent(items);
49+
var client = new HttpClient();
50+
await client.PostAsync("https://onetrueerror.com/support/request", content);
51+
}
52+
}
53+
}

src/Server/OneTrueError.App/OneTrueError.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<Compile Include="Core\Reports\Jobs\DeleteOldReports.cs" />
9696
<Compile Include="Core\Reports\Jobs\DeleteReportsBelowReportLimit.cs" />
9797
<Compile Include="Core\Reports\PagedReports.cs" />
98+
<Compile Include="Core\Support\SendSupportRequestHandler.cs" />
9899
<Compile Include="GlobalSuppressions.cs" />
99100
<Compile Include="Modules\Geolocation\ErrorOrginResult.cs" />
100101
<Compile Include="Modules\Geolocation\QueryHandlers\GetOriginsForIncidentHandler.cs" />

src/Server/OneTrueError.SqlServer/Core/Incidents/Queries/FindIncidentsHandler.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,22 @@ FROM Incidents
3232
JOIN Applications ON (Applications.Id = Incidents.ApplicationId)
3333
JOIN ApplicationMembers atm ON (atm.ApplicationId = Applications.Id AND AccountId = @accountId)";
3434
cmd.AddParameter("accountId", ClaimsPrincipal.Current.GetAccountId());
35+
3536
if (query.ApplicationId > 0)
3637
{
37-
sqlQuery += " WHERE Applications.Id = @id AND (";
38+
sqlQuery += " WHERE Applications.Id = @id";
3839
cmd.AddParameter("id", query.ApplicationId);
3940
}
40-
else
41+
if (query.FreeText != null)
4142
{
42-
sqlQuery += "AND (";
43+
sqlQuery += @" AND (
44+
Incidents.Id IN (SELECT Distinct IncidentId FROM ErrorReports WHERE StackTrace LIKE @FreeText
45+
Or Incidents.Description LIKE @FreeText)
46+
)";
47+
cmd.AddParameter("FreeText", $"%{query.FreeText}%");
4348
}
4449

50+
sqlQuery += " AND (";
4551
if (query.Ignored)
4652
sqlQuery += "IgnoreReports = 1 OR ";
4753
if (query.Closed)

src/Server/OneTrueError.SqlServer/OneTrueError.SqlServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<Compile Include="Core\Users\ApplicationTeamMemberMapper.cs" />
126126
<Compile Include="Core\Users\UserMapper.cs" />
127127
<Compile Include="Core\Users\UserRepository.cs" />
128-
<Compile Include="Modules\Geolocation\StoreErrorOriginHandler.cs" />
128+
<Compile Include="Modules\Geolocation\ErrorOriginRepository.cs" />
129129
<Compile Include="Modules\ReportSpikes\ReportSpikesRepository.cs" />
130130
<Compile Include="Modules\Similarities\Mappers\SimilarityCollectionMapper.cs" />
131131
<Compile Include="Modules\Similarities\Mappers\SimilarityMapper.cs" />

src/Server/OneTrueError.Web/Areas/Installation/Controllers/SetupController.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Configuration;
4+
using System.Net.Http;
5+
using System.Threading.Tasks;
36
using System.Web.Mvc;
47
using OneTrueError.App.Configuration;
58
using OneTrueError.Infrastructure;
@@ -24,6 +27,36 @@ public ActionResult Activate()
2427
return Redirect("~/?#/welcome");
2528
}
2629

30+
public ActionResult Support()
31+
{
32+
return View(new SupportViewModel());
33+
}
34+
35+
[HttpPost]
36+
public async Task<ActionResult> Support(SupportViewModel model)
37+
{
38+
if (!ModelState.IsValid)
39+
return View(model);
40+
41+
try
42+
{
43+
var client = new HttpClient();
44+
var content =
45+
new FormUrlEncodedContent(new []
46+
{
47+
new KeyValuePair<string, string>("EmailAddress", model.Email),
48+
new KeyValuePair<string, string>("CompanyName", model.CompanyName)
49+
});
50+
await client.PostAsync("https://onetrueerror.com/support/register/", content);
51+
return Redirect(Url.GetNextWizardStep());
52+
}
53+
catch (Exception ex)
54+
{
55+
ModelState.AddModelError("", ex.Message);
56+
return View(model);
57+
}
58+
}
59+
2760
public ActionResult Basics()
2861
{
2962
var model = new BasicsViewModel();
@@ -35,7 +68,7 @@ public ActionResult Basics()
3568
}
3669
else
3770
{
38-
model.BaseUrl = Request.Url.ToString().Replace("installation/setup/basics/", "");
71+
model.BaseUrl = Request.Url.ToString().Replace("installation/setup/basics/", "").Replace("localhost", "yourServerName");
3972
ViewBag.NextLink = "";
4073
}
4174

@@ -50,6 +83,11 @@ public ActionResult Basics(BasicsViewModel model)
5083
if (!model.BaseUrl.EndsWith("/"))
5184
model.BaseUrl += "/";
5285

86+
if (model.BaseUrl.IndexOf("localhost", StringComparison.OrdinalIgnoreCase) != -1)
87+
{
88+
ModelState.AddModelError("BaseUrl", "Use the servers real DNS name instead of 'localhost'. If you don't the Ajax request wont work as CORS would be enforced by IIS.");
89+
return View(model);
90+
}
5391
settings.BaseUrl = new Uri(model.BaseUrl);
5492
settings.SupportEmail = model.SupportEmail;
5593
ConfigurationStore.Instance.Store(settings);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace OneTrueError.Web.Areas.Installation.Models
4+
{
5+
public class SupportViewModel
6+
{
7+
[EmailAddress]
8+
public string Email { get; set; }
9+
10+
public string CompanyName { get; set; }
11+
}
12+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@model OneTrueError.Web.Areas.Installation.Models.SupportViewModel
2+
@{
3+
ViewBag.Title = "Installation - Support";
4+
}
5+
<div class="container">
6+
<div class="col-lg-6">
7+
8+
<h2>Free Support</h2>
9+
<p>Do you want to get 30 days of free email support?</p>
10+
<p>No obligations attached, but you can purchase commercial support after that if you would like to support the project.</p>
11+
<form method="post" action="@Url.Action("Support")" style="width: 100%" class="form">
12+
@Html.ValidationSummary(false)
13+
<div>
14+
<input type="text"
15+
name="CompanyName" class="form-control" value="@Model.CompanyName" placeholder="Company name" />
16+
17+
<input type="email"
18+
name="Email" class="form-control" value="@Model.Email" placeholder="Your email address" />
19+
</div>
20+
<div><em>(Leave fields empty if you do not want to sign up)</em></div>
21+
<div>&nbsp;</div>
22+
<br />
23+
@Html.Raw(ViewBag.PrevLink)
24+
<input type="submit" class="btn btn-primary" value="Signup" />
25+
@Html.Raw(ViewBag.NextLink)
26+
</form>
27+
</div>
28+
</div>

src/Server/OneTrueError.Web/Areas/Installation/WizardSteps.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public static class WizardSteps
1313
new WizardStepInfo("Error tracking", "~/installation/setup/errors/"),
1414
new WizardStepInfo("Create admin account", "~/installation/account/admin/"),
1515
new WizardStepInfo("Mail settings", "~/installation/messaging/email/"),
16+
new WizardStepInfo("Support", "~/installation/setup/support"),
1617
new WizardStepInfo("Completed", "~/installation/setup/completed/")
1718
};
1819

0 commit comments

Comments
 (0)