Skip to content

Commit

Permalink
Added search to incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
gauffininteractive committed Feb 16, 2017
1 parent 02e928b commit 3f53e08
Show file tree
Hide file tree
Showing 20 changed files with 219 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public FindIncidents()
/// </summary>
public bool ReOpened { get; set; }

/// <summary>
/// Will be searched in incident.message and report.stacktrace.
/// </summary>
public string FreeText { get; set; }

/// <summary>
/// Sort order
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using DotNetCqs;
using Griffin.Container;
using OneTrueError.Api.Core.Support;
using OneTrueError.App.Configuration;
using OneTrueError.Infrastructure.Configuration;

namespace OneTrueError.App.Core.Support
{
/// <summary>
/// Sends a support request to the OneTrueError Team.
/// </summary>
/// <remarks>
/// <para>
/// You must have bought commercial support or registered to get 30 days of free support.
/// </para>
/// </remarks>
[Component]
public class SendSupportRequestHandler : ICommandHandler<SendSupportRequest>
{
/// <inheritdoc />
public async Task ExecuteAsync(SendSupportRequest command)
{
var baseConfig = ConfigurationStore.Instance.Load<BaseConfiguration>();
var errorConfig = ConfigurationStore.Instance.Load<OneTrueErrorConfigSection>();

string installationId = null;
var email = baseConfig.SupportEmail;
if (errorConfig != null)
{
email = errorConfig.ContactEmail;
installationId = errorConfig.InstallationId;
}


var items = new List<KeyValuePair<string, string>>();
if (installationId != null)
items.Add(new KeyValuePair<string, string>("InstallationId", installationId));
items.Add(new KeyValuePair<string, string>("ContactEmail", email));
items.Add(new KeyValuePair<string, string>("Subject", command.Subject));
items.Add(new KeyValuePair<string, string>("Message", command.Message));

//To know which page the user had trouble with
items.Add(new KeyValuePair<string, string>("PageUrl", command.Url));

var content = new FormUrlEncodedContent(items);
var client = new HttpClient();
await client.PostAsync("https://onetrueerror.com/support/request", content);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public async Task HandleAsync(ReportAddedToIncident e)
if (string.IsNullOrEmpty(e.Report.RemoteAddress))
return;

if (e.Report.RemoteAddress == "::1")
return;
if (e.Report.RemoteAddress == "127.0.0.1")
return;
//if (e.Report.RemoteAddress == "::1")
// return;
//if (e.Report.RemoteAddress == "127.0.0.1")
// return;

var request = WebRequest.CreateHttp("http://freegeoip.net/json/" + e.Report.RemoteAddress);
try
Expand Down
1 change: 1 addition & 0 deletions src/Server/OneTrueError.App/OneTrueError.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="Core\Reports\Jobs\DeleteOldReports.cs" />
<Compile Include="Core\Reports\Jobs\DeleteReportsBelowReportLimit.cs" />
<Compile Include="Core\Reports\PagedReports.cs" />
<Compile Include="Core\Support\SendSupportRequestHandler.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Modules\Geolocation\ErrorOrginResult.cs" />
<Compile Include="Modules\Geolocation\QueryHandlers\GetOriginsForIncidentHandler.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ FROM Incidents
JOIN Applications ON (Applications.Id = Incidents.ApplicationId)
JOIN ApplicationMembers atm ON (atm.ApplicationId = Applications.Id AND AccountId = @accountId)";
cmd.AddParameter("accountId", ClaimsPrincipal.Current.GetAccountId());

if (query.ApplicationId > 0)
{
sqlQuery += " WHERE Applications.Id = @id AND (";
sqlQuery += " WHERE Applications.Id = @id";
cmd.AddParameter("id", query.ApplicationId);
}
else
if (query.FreeText != null)
{
sqlQuery += "AND (";
sqlQuery += @" AND (
Incidents.Id IN (SELECT Distinct IncidentId FROM ErrorReports WHERE StackTrace LIKE @FreeText
Or Incidents.Description LIKE @FreeText)
)";
cmd.AddParameter("FreeText", $"%{query.FreeText}%");
}

sqlQuery += " AND (";
if (query.Ignored)
sqlQuery += "IgnoreReports = 1 OR ";
if (query.Closed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<Compile Include="Core\Users\ApplicationTeamMemberMapper.cs" />
<Compile Include="Core\Users\UserMapper.cs" />
<Compile Include="Core\Users\UserRepository.cs" />
<Compile Include="Modules\Geolocation\StoreErrorOriginHandler.cs" />
<Compile Include="Modules\Geolocation\ErrorOriginRepository.cs" />
<Compile Include="Modules\ReportSpikes\ReportSpikesRepository.cs" />
<Compile Include="Modules\Similarities\Mappers\SimilarityCollectionMapper.cs" />
<Compile Include="Modules\Similarities\Mappers\SimilarityMapper.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Mvc;
using OneTrueError.App.Configuration;
using OneTrueError.Infrastructure;
Expand All @@ -24,6 +27,36 @@ public ActionResult Activate()
return Redirect("~/?#/welcome");
}

public ActionResult Support()
{
return View(new SupportViewModel());
}

[HttpPost]
public async Task<ActionResult> Support(SupportViewModel model)
{
if (!ModelState.IsValid)
return View(model);

try
{
var client = new HttpClient();
var content =
new FormUrlEncodedContent(new []
{
new KeyValuePair<string, string>("EmailAddress", model.Email),
new KeyValuePair<string, string>("CompanyName", model.CompanyName)
});
await client.PostAsync("https://onetrueerror.com/support/register/", content);
return Redirect(Url.GetNextWizardStep());
}
catch (Exception ex)
{
ModelState.AddModelError("", ex.Message);
return View(model);
}
}

public ActionResult Basics()
{
var model = new BasicsViewModel();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;

namespace OneTrueError.Web.Areas.Installation.Models
{
public class SupportViewModel
{
[EmailAddress]
public string Email { get; set; }

public string CompanyName { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@model OneTrueError.Web.Areas.Installation.Models.SupportViewModel
@{
ViewBag.Title = "Installation - Support";
}
<div class="container">
<div class="col-lg-6">

<h2>Free Support</h2>
<p>Do you want to get 30 days of free email support?</p>
<p>No obligations attached, but you can purchase commercial support after that if you would like to support the project.</p>
<form method="post" action="@Url.Action("Support")" style="width: 100%" class="form">
@Html.ValidationSummary(false)
<div>
<input type="text"
name="CompanyName" class="form-control" value="@Model.CompanyName" placeholder="Company name" />

<input type="email"
name="Email" class="form-control" value="@Model.Email" placeholder="Your email address" />
</div>
<div><em>(Leave fields empty if you do not want to sign up)</em></div>
<div>&nbsp;</div>
<br />
@Html.Raw(ViewBag.PrevLink)
<input type="submit" class="btn btn-primary" value="Signup" />
@Html.Raw(ViewBag.NextLink)
</form>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class WizardSteps
new WizardStepInfo("Error tracking", "~/installation/setup/errors/"),
new WizardStepInfo("Create admin account", "~/installation/account/admin/"),
new WizardStepInfo("Mail settings", "~/installation/messaging/email/"),
new WizardStepInfo("Support", "~/installation/setup/support"),
new WizardStepInfo("Completed", "~/installation/setup/completed/")
};

Expand Down
2 changes: 2 additions & 0 deletions src/Server/OneTrueError.Web/OneTrueError.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<Compile Include="Areas\Installation\Models\EmailViewModel.cs" />
<Compile Include="Areas\Installation\Models\ErrorTrackingViewModel.cs" />
<Compile Include="Areas\Installation\Models\QueueViewModel.cs" />
<Compile Include="Areas\Installation\Models\SupportViewModel.cs" />
<Compile Include="Areas\Installation\WizardStepInfo.cs" />
<Compile Include="Areas\Installation\WizardSteps.cs" />
<Compile Include="Areas\Admin\Controllers\MessagingController.cs" />
Expand Down Expand Up @@ -419,6 +420,7 @@
<Content Include="Areas\Admin\Views\ApiKeys\Details.cshtml" />
<Content Include="Areas\Admin\Views\ApiKeys\Deleted.cshtml" />
<Content Include="Areas\Admin\Views\Reporting\Index.cshtml" />
<Content Include="Areas\Installation\Views\Setup\Support.cshtml" />
<None Include="compilerconfig.json" />
<None Include="compilerconfig.json.defaults">
<DependentUpon>compilerconfig.json</DependentUpon>
Expand Down
3 changes: 2 additions & 1 deletion src/Server/OneTrueError.Web/Scripts/Griffin.Yo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Server/OneTrueError.Web/Scripts/Models/AllModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ module OneTrueError.Core.Incidents.Queries {
SortAscending: boolean;
SortType: Incidents.IncidentOrder;
QueryId: string;
FreeText: string;
}

export class GetIncident {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f53e08

Please sign in to comment.