diff --git a/AutotuneWeb/Controllers/HomeController.cs b/AutotuneWeb/Controllers/HomeController.cs index f6d02ca..c4adbb8 100644 --- a/AutotuneWeb/Controllers/HomeController.cs +++ b/AutotuneWeb/Controllers/HomeController.cs @@ -53,6 +53,7 @@ public ActionResult Autotune(Uri nsUrl, decimal? cr, decimal? sens) ModelState.SetModelValue(nameof(nsUrl), nsUrl, nsUrl.ToString()); ViewBag.NSUrl = nsUrl; ViewBag.ProfileActivation = profileActivation; + ViewBag.CanRunAutotuneInCloud = CanRunAutotuneInCloud(); ViewBag.PreviousResults = HasPreviousResults(nsUrl); nsProfile.CarbRatio = CombineAdjacentTimeBlocks(nsProfile.CarbRatio); @@ -90,9 +91,33 @@ public ActionResult Autotune(Uri nsUrl, decimal? cr, decimal? sens) return View("Converted", oapsProfile); } + private bool CanRunAutotuneInCloud() + { + string[] requiredKeys = { + "Storage", + "BatchAccountUrl", + "BatchAccountName", + "BatchAccountKey", + "BatchPoolId", + "SendGridApiKey", + "SendGridFromAddress", + "ResultsCallbackKey", + }; + foreach (var key in requiredKeys) + { + if (String.IsNullOrEmpty(Startup.Configuration[key])) + return false; + } + return true; + } + private bool HasPreviousResults(Uri nsUrl) { var connectionString = Startup.Configuration.GetConnectionString("Storage"); + if (connectionString == null) + { + return false; + } var storageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(connectionString); var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("jobs"); @@ -430,16 +455,23 @@ public async Task About() { // Get the details of the Autotune commit used for the latest job var connectionString = Startup.Configuration.GetConnectionString("Storage"); - var storageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(connectionString); - var tableClient = storageAccount.CreateCloudTableClient(); - var table = tableClient.GetTableReference("settings"); - await table.CreateIfNotExistsAsync(); + if (connectionString != null) + { + var storageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(connectionString); + var tableClient = storageAccount.CreateCloudTableClient(); + var table = tableClient.GetTableReference("settings"); + await table.CreateIfNotExistsAsync(); - var commit = table.CreateQuery() - .Where(s => s.PartitionKey == "Commit" && s.RowKey == "") - .SingleOrDefault(); + var commit = table.CreateQuery() + .Where(s => s.PartitionKey == "Commit" && s.RowKey == "") + .SingleOrDefault(); - ViewBag.Commit = commit?.Value ?? ""; + ViewBag.Commit = commit?.Value ?? ""; + } + else + { + ViewBag.Commit = ""; + } return View(); } @@ -463,6 +495,10 @@ public ActionResult Error() public async Task Delete(string url, string email) { var connectionString = Startup.Configuration.GetConnectionString("Storage"); + if (connectionString == null) + { + return View(0); + } var storageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(connectionString); var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("jobs"); diff --git a/AutotuneWeb/Views/Home/About.cshtml b/AutotuneWeb/Views/Home/About.cshtml index c19f4a3..d327f5d 100644 --- a/AutotuneWeb/Views/Home/About.cshtml +++ b/AutotuneWeb/Views/Home/About.cshtml @@ -66,8 +66,12 @@ exactly what it's doing. You can also take a look at the @Html.ActionLink("privacy policy", "Privacy")
What version of Autotune is it running?
-
The details of the version of Autotune used on any particular run is included in the result email. The latest job ran with version - @ViewBag.Commit
+
The details of the version of Autotune used on any particular run is included in the result email. + @if (ViewBag.Commit != "") + { + @:The latest job ran with version @ViewBag.Commit + } +
Why do I get the same results regardless of whether I tick "Categorize UAM as basal"?
If Autotune detects at least 1 hour of carb absoption, it will assume that all carbs have been entered and so you get the same result as if this diff --git a/AutotuneWeb/Views/Home/Converted.cshtml b/AutotuneWeb/Views/Home/Converted.cshtml index f48e895..6b4d3c9 100644 --- a/AutotuneWeb/Views/Home/Converted.cshtml +++ b/AutotuneWeb/Views/Home/Converted.cshtml @@ -168,117 +168,126 @@

Running Autotune in the Cloud

-

- Complete the remaining fields below to run Autotune on this profile -

- -@using (Html.BeginForm("RunJob", "Home")) +@if (ViewBag.CanRunAutotuneInCloud) { - @Html.Hidden("nsUrl", (Uri)ViewBag.NSUrl) - @Html.Hidden("oapsProfile", profileJson) - @Html.Hidden("units", (string)ViewBag.Units) - @Html.Hidden("timezone", (string)ViewBag.TimeZone)

- Ready to run Autotune now? Enter a few more details, then click Run Now to have us run Autotune for you. + Complete the remaining fields below to run Autotune on this profile

-
-
-
- -
- - mg/dL/5m + @using (Html.BeginForm("RunJob", "Home")) + { + @Html.Hidden("nsUrl", (Uri)ViewBag.NSUrl) + @Html.Hidden("oapsProfile", profileJson) + @Html.Hidden("units", (string)ViewBag.Units) + @Html.Hidden("timezone", (string)ViewBag.TimeZone) +

+ Ready to run Autotune now? Enter a few more details, then click Run Now to have us run Autotune for you. +

+ +
+
+
+ +
+ + mg/dL/5m +
-
-
-
- The minimum amount of the expected carb impact that should be assumed when no carb absorption is identified from the CGM data, - forcing the remaining carbs on board to decay. -
-
-
-
-
-
- -
- - U/h +
+
+ The minimum amount of the expected carb impact that should be assumed when no carb absorption is identified from the CGM data, + forcing the remaining carbs on board to decay.
-
-
- Autotune will likely recommend basals in fractions of a unit that you can't program into your pump, so enter here what - increments your pump can handle (0.1, 0.5 etc.) to get your results rounded for you. +
+
+
+ +
+ + U/h +
+
-
-
-
-
-
- +
+
+ Autotune will likely recommend basals in fractions of a unit that you can't program into your pump, so enter here what + increments your pump can handle (0.1, 0.5 etc.) to get your results rounded for you. +
-
-
- If Autotune sees some sudden rises in your CGM data, it may conclude that there were carbs eaten but not entered into Nightscout. - If you have reliably entered all carbs eaten, tick this box and those rises will be used to recommend changes to the basal rate. +
+
+
+ +
-
-
-
-
- - -
-
-
- Select the type of insulin you use so that Autotune can tell how quickly it acts and decays. +
+
+ If Autotune sees some sudden rises in your CGM data, it may conclude that there were carbs eaten but not entered into Nightscout. + If you have reliably entered all carbs eaten, tick this box and those rises will be used to recommend changes to the basal rate. +
-
-
-
- -
- - days +
+
+ +
-
-
-
- The number of days of data to be processed by Autotune (up to 30) +
+
+ Select the type of insulin you use so that Autotune can tell how quickly it acts and decays. +
-
-
-
-
- +
+
+
- @@ - + + days +
+
+
+
+ The number of days of data to be processed by Autotune (up to 30)
-
-
- Autotune takes a few minutes to run, so we'll email the results to you when they're ready. You should get them in 10 - 20 minutes, - check your spam folder if you don't get it. +
+
+
+ +
+ @@ + +
+
+
+
+
+ Autotune takes a few minutes to run, so we'll email the results to you when they're ready. You should get them in 10 - 20 minutes, + check your spam folder if you don't get it. +
-
+

+ +

+ } +} +else +{

- + This server is not configured to support running Autotune in cloud

}