Skip to content

Commit e053a85

Browse files
committed
Improved the installation wizard.
1 parent 908c4fe commit e053a85

File tree

16 files changed

+84
-48
lines changed

16 files changed

+84
-48
lines changed

src/Server/Coderr.Server.App/Modules/Messaging/Commands/DotNetSmtpSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void IConfigurationSection.Load(IDictionary<string, string> items)
5656
AccountName = items.GetString("AccountName");
5757
AccountPassword = items.GetString("AccountPassword", "");
5858
SmtpHost = items.GetString("SmtpHost");
59-
PortNumber = items.GetInteger("PortNumber");
60-
UseSsl = items.GetBoolean("UseSSL");
59+
PortNumber = items.GetInteger("PortNumber", 0);
60+
UseSsl = items.GetBoolean("UseSSL", false);
6161
}
6262
}
6363
}

src/Server/Coderr.Server.Infrastructure/Configuration/DictionaryExtensions.cs renamed to src/Server/Coderr.Server.Infrastructure/Configuration/ConfigDictionaryExtensions.cs

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace codeRR.Server.Infrastructure.Configuration
77
/// <summary>
88
/// Moves otherwise repeated conversions to a single place.
99
/// </summary>
10-
public static class DictionaryExtensions
10+
public static class ConfigDictionaryExtensions
1111
{
1212
/// <summary>
1313
/// Convert dictionary item to a boolean.
@@ -17,19 +17,25 @@ public static class DictionaryExtensions
1717
/// <returns>Value</returns>
1818
/// <exception cref="ArgumentException">If key is not present. Key name is included in the exception message.</exception>
1919
/// <exception cref="FormatException">Value is not a boolean. Includes key name and source value in the exception message.</exception>
20-
public static bool GetBoolean(this IDictionary<string, string> dictionary, string name)
20+
public static bool GetBoolean(this IDictionary<string, string> dictionary, string name, bool? defaultValue = false)
2121
{
2222
if (dictionary == null) throw new ArgumentNullException("dictionary");
2323
if (name == null) throw new ArgumentNullException("name");
24-
string value;
25-
if (!dictionary.TryGetValue(name, out value))
26-
throw new ArgumentException(string.Format("Failed to find key '{0}' in dictionary.", name));
27-
28-
bool boolValue;
29-
if (!bool.TryParse(value, out boolValue))
30-
throw new FormatException(string.Format("Failed to convert '{0}' from value '{1}' to a boolean.", name,
31-
value));
32-
return boolValue;
24+
25+
if (!dictionary.TryGetValue(name, out var value))
26+
{
27+
if (defaultValue != null)
28+
return defaultValue.Value;
29+
throw new ArgumentException($"Failed to find key '{name}' in dictionary.");
30+
}
31+
32+
if (bool.TryParse(value, out var boolValue))
33+
return boolValue;
34+
35+
if (defaultValue != null)
36+
return defaultValue.Value;
37+
38+
throw new FormatException($"Failed to convert '{name}' from value '{value}' to a boolean.");
3339
}
3440

3541
/// <summary>
@@ -41,19 +47,26 @@ public static bool GetBoolean(this IDictionary<string, string> dictionary, strin
4147
/// <exception cref="ArgumentException">If key is not present. Key name is included in the exception message.</exception>
4248
/// <exception cref="FormatException">Value is not a boolean. Includes key name and source value in the exception message.</exception>
4349
[SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "integer")]
44-
public static int GetInteger(this IDictionary<string, string> dictionary, string name)
50+
public static int GetInteger(this IDictionary<string, string> dictionary, string name, int? defaultValue = 0)
4551
{
4652
if (dictionary == null) throw new ArgumentNullException("dictionary");
4753
if (name == null) throw new ArgumentNullException("name");
48-
string value;
49-
if (!dictionary.TryGetValue(name, out value))
50-
throw new ArgumentException(string.Format("Failed to find key '{0}' in dictionary.", name));
51-
52-
int intValue;
53-
if (!int.TryParse(value, out intValue))
54-
throw new FormatException(string.Format("Failed to convert '{0}' from value '{1}' to an integer.",
55-
name, value));
56-
return intValue;
54+
55+
if (!dictionary.TryGetValue(name, out var value))
56+
{
57+
if (defaultValue != null)
58+
return defaultValue.Value;
59+
throw new ArgumentException($"Failed to find key '{name}' in dictionary.");
60+
}
61+
62+
63+
if (int.TryParse(value, out var intValue))
64+
return intValue;
65+
66+
if (defaultValue != null)
67+
return defaultValue.Value;
68+
69+
throw new FormatException($"Failed to convert '{name}' from value '{value}' to an integer.");
5770
}
5871

5972
/// <summary>
@@ -63,15 +76,18 @@ public static int GetInteger(this IDictionary<string, string> dictionary, string
6376
/// <param name="name">Key</param>
6477
/// <returns>Value</returns>
6578
/// <exception cref="ArgumentException">If key is not present. Key name is included in the exception message.</exception>
66-
public static string GetString(this IDictionary<string, string> dictionary, string name)
79+
public static string GetString(this IDictionary<string, string> dictionary, string name, bool requireParameter = true)
6780
{
6881
if (dictionary == null) throw new ArgumentNullException("dictionary");
6982
if (name == null) throw new ArgumentNullException("name");
70-
string value;
71-
if (!dictionary.TryGetValue(name, out value))
72-
throw new ArgumentException(string.Format("Failed to find key '{0}' in dictionary.", name));
7383

74-
return value;
84+
if (dictionary.TryGetValue(name, out var value))
85+
return value;
86+
87+
if (requireParameter)
88+
throw new ArgumentException($"Failed to find key '{name}' in dictionary.");
89+
90+
return null;
7591
}
7692

7793
/// <summary>
@@ -86,8 +102,9 @@ public static string GetString(this IDictionary<string, string> dictionary, stri
86102
{
87103
if (dictionary == null) throw new ArgumentNullException("dictionary");
88104
if (name == null) throw new ArgumentNullException("name");
89-
string value;
90-
return !dictionary.TryGetValue(name, out value) ? defaultValue : value;
105+
return !dictionary.TryGetValue(name, out var value)
106+
? defaultValue
107+
: value;
91108
}
92109
}
93110
}

src/Server/Coderr.Server.Web/App_Start/CompositionRoot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void Build(Action<ContainerRegistrar> action, ConfigurationStore configSt
4747
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
4848
builder.RegisterControllers(Assembly.GetExecutingAssembly());
4949

50-
builder.RegisterService(x => Startup.ConfigurationStore.Load<BaseConfiguration>());
50+
builder.RegisterService(x => configStore.Load<BaseConfiguration>());
5151
var ioc = builder.Build();
5252

5353
DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc));

src/Server/Coderr.Server.Web/Areas/Admin/Controllers/HomeController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ public ActionResult Basics()
4141
[HttpPost]
4242
public ActionResult Basics(BasicsViewModel model)
4343
{
44+
if (model.BaseUrl.StartsWith("http://yourServerName/", StringComparison.OrdinalIgnoreCase))
45+
ModelState.AddModelError("BaseUrl", "You must specify a correct URL, or all links in notification emails will be incorrect.");
46+
47+
if (!ModelState.IsValid)
48+
{
49+
ViewBag.NextLink = "";
50+
return View(model);
51+
}
52+
4453
var settings = new BaseConfiguration
4554
{
4655
BaseUrl = new Uri(model.BaseUrl),

src/Server/Coderr.Server.Web/Areas/Admin/Models/BasicsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class BasicsViewModel
77
/// <summary>
88
/// URL to coderr (typically "http://yourHostName/" or "http://somehost/coderr/")
99
/// </summary>
10-
[Required, MinLength(4)]
10+
[Required, MinLength(8)]
1111
public string BaseUrl { get; set; }
1212

1313
/// <summary>

src/Server/Coderr.Server.Web/Areas/Admin/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<hr />
4747
<footer>
4848
<p>
49-
&copy; 2017 - 1TCompany AB | <a href="mailto:help@coderrapp.com">help@coderrapp.com</a>
49+
&copy; 2017 - 1TCompany AB | <a href="http://discuss.coderrapp.com">Join our community</a>
5050
</p>
5151
</footer>
5252
</div>

src/Server/Coderr.Server.Web/Areas/Installation/Controllers/MessagingController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public class MessagingController : Controller
1010
{
1111
private ConfigurationStore _configStore;
1212

13-
public MessagingController(ConfigurationStore configStore)
13+
public MessagingController()
1414
{
15-
_configStore = configStore;
15+
_configStore = Startup.ConfigurationStore;
1616
}
1717

1818
public ActionResult Email()

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class SetupController : Controller
1616
{
1717
private ConfigurationStore _configStore;
1818

19-
public SetupController(ConfigurationStore configStore)
19+
public SetupController()
2020
{
21-
_configStore = configStore;
21+
_configStore = Startup.ConfigurationStore;
2222
}
2323

2424
[HttpPost]
@@ -57,6 +57,19 @@ public ActionResult Basics()
5757
[HttpPost]
5858
public ActionResult Basics(BasicsViewModel model)
5959
{
60+
if (model.BaseUrl.StartsWith("http://yourServerName/", StringComparison.OrdinalIgnoreCase))
61+
ModelState.AddModelError("BaseUrl", "You must specify a correct server name in the URL, or all links in notification emails will be incorrect.");
62+
if (model.BaseUrl.StartsWith("http://localhost/", StringComparison.OrdinalIgnoreCase))
63+
ModelState.AddModelError("BaseUrl", "You must specify a correct server name in the URL, or all links in notification emails will be incorrect.");
64+
if (model.BaseUrl.StartsWith("https://localhost/", StringComparison.OrdinalIgnoreCase))
65+
ModelState.AddModelError("BaseUrl", "You must specify a correct server name in the URL, or all links in notification emails will be incorrect.");
66+
67+
if (!ModelState.IsValid)
68+
{
69+
ViewBag.NextLink = "";
70+
return View(model);
71+
}
72+
6073
var settings = new BaseConfiguration();
6174
if (!model.BaseUrl.EndsWith("/"))
6275
model.BaseUrl += "/";

src/Server/Coderr.Server.Web/Areas/Installation/Models/BasicsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace codeRR.Server.Web.Areas.Installation.Models
44
{
55
public class BasicsViewModel
66
{
7-
[Required, MinLength(4)]
7+
[Required, MinLength(8)]
88
public string BaseUrl { get; set; }
99

1010
[Required, EmailAddress]

src/Server/Coderr.Server.Web/Areas/Installation/Views/Setup/ErrorTracking.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h2>Error tracking</h2>
99
<p>
1010
To correct bugs faster we have activated codeRR in the community server. By completing this
11-
setup, you allow us to collect error information and send it to our own hosted service.
11+
setup, you allow us to collect error information (i.e. bugs in codeRR Community Server) and send it to our own hosted service.
1212
</p>
1313
<p>
1414
You can optionally enter your email address to get notifications when the errors in your

src/Server/Coderr.Server.Web/Areas/Installation/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<hr/>
2727
<footer>
2828
<p>
29-
&copy; 2017 1TCompany AB | <a href="mailto:help@coderrapp.com">help@coderrapp.com</a>
29+
&copy; 2017 1TCompany AB | <a href="http://discuss.coderrapp.com">Join our community</a>
3030
</p>
3131
</footer>
3232
</div>

src/Server/Coderr.Server.Web/Areas/Installation/Views/Sql/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</em>
3535
</p>
3636
<h3>Example</h3>
37-
<pre><code>Data Source=(localdb)\ProjectsV12;Initial Catalog=codeRR;Integrated Security=True;Connect Timeout=30;</code></pre>
37+
<pre><code>Data Source=.;Initial Catalog=coderr;Integrated Security=True;Connect Timeout=30;</code></pre>
3838
<h2>Tip!</h2>
3939
<p>
4040
Do you want to give permissions to the IIS app pool? Add <em>"IIS APPPOOL\YourAppPool"</em> as the windows account in SQL Server Management Studio.

src/Server/Coderr.Server.Web/Controllers/WizardController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public async Task<ActionResult> Validate(ValidateViewModel model)
169169
if (result.TotalCount == 0)
170170
return View(model);
171171

172-
return Redirect("~/#/application/" + model.ApplicationId);
172+
return Redirect("~/#/application/" + model.ApplicationId + "/");
173173
}
174174

175175
protected async Task Init(int maxCount = 0)

src/Server/Coderr.Server.Web/Views/Shared/_Layout.NoAuth.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<div class="container">
4141
<div class="row">
4242
<div class="col-lg-6 offset-lg-3 col-sm-12 col-md-8 offset-md-2">
43-
&copy; 2017 1TCompany AB | <a href="mailto:help@coderrapp.com">help@coderrapp.com</a>
43+
&copy; 2017 1TCompany AB | <a href="http://discuss.coderrapp.com">Join our community</a>
4444
</div>
4545
</div>
4646
</div>

src/Server/Coderr.Server.Web/Web.Release.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</appSettings>
1010
<connectionStrings>
1111
<add name="Db"
12-
connectionString="Data Source=.;Initial Catalog=OneTrueError;Integrated Security=True;Connect Timeout=30;multipleactiveresultsets=true"
12+
connectionString="Data Source=.;Initial Catalog=coderr;Integrated Security=True;Connect Timeout=30;multipleactiveresultsets=true"
1313
providerName="System.Data.SqlClient"
1414
xdt:Transform="Replace" xdt:Locator="Match(name)" />
1515
</connectionStrings>

src/Server/Coderr.Server.Web/Web.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
<configuration>
44
<appSettings>
5-
<add key="Configured" value="true" />
5+
<add key="Configured" value="false" />
66
<add key="ConfigurationKey" value="change_this_to_your_own_password_before_running_the_installer" />
77

8-
<add key="ScanForNewErrorReportsBatcher.Enabled" value="true" />
9-
<add key="ProcessFeedbackHandler.Enabled" value="true" />
10-
118
</appSettings>
129
<connectionStrings>
1310
<add name="Db" connectionString="Data Source=.;Initial Catalog=CoderrOSS;Integrated Security=True;Connect Timeout=30;multipleactiveresultsets=true" providerName="System.Data.SqlClient" />

0 commit comments

Comments
 (0)