Skip to content

Commit

Permalink
Merge pull request #145 from COS301-SE-2023/development
Browse files Browse the repository at this point in the history
Updating deployment with slider changes
  • Loading branch information
jason-dutton authored Oct 20, 2023
2 parents 454fde9 + 211f2af commit 6b47be0
Show file tree
Hide file tree
Showing 21 changed files with 1,560 additions and 284 deletions.
819 changes: 819 additions & 0 deletions src/Blue-Skies.postman_collection.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/Prod.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": "bab9411c-9bf9-46d3-b3d7-8c51b1f5685e",
"name": "Prod",
"values": [
{
"key": "express",
"value": "express-microservice.azurewebsites.net",
"type": "default",
"enabled": true
},
{
"key": "net",
"value": "https://dot-net-api.azurewebsites.net",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2023-10-09T18:50:52.338Z",
"_postman_exported_using": "Postman/10.18.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public BusinessBestSolarPanelsController()
_keysRepository = new KeysRepository();
}

[HttpPost("post")]
[HttpGet("get")]
public async Task<IActionResult> CreateBusinessBestSolarPanels([FromBody] BestSolarPanelsInput bestSolarPanelsInput)
{
try
Expand Down
2 changes: 1 addition & 1 deletion src/apps/api/Controllers/BusinessRequestDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public BusinessRequestDataController()
_keysRepository = new KeysRepository();
}

[HttpPost("post")]
[HttpGet("get")]
public async Task<IActionResult> CreateBusinessRequestData([FromBody] BusinessRequestData businessRequestData)
{
try
Expand Down
11 changes: 1 addition & 10 deletions src/apps/api/Repository/BusinessBestSolarPanelsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ public class BusinessBestSolarPanelsRepository
private DataHandlers.RooftopDataHandler rooftopDataHandler = new DataHandlers.RooftopDataHandler();
private SharedUtils.otherDataClass otherDataClass = new SharedUtils.otherDataClass();
private string locationName = "";
private string express = "http://localhost:3333";
private string? API_PORT = Environment.GetEnvironmentVariable("API_PORT");
public BusinessBestSolarPanelsRepository()
{
var backendexpress = Environment.GetEnvironmentVariable("EXPRESS_BACKEND");
if (backendexpress != null)
{
express = backendexpress;
}
}

public async Task<string> GetProcessedDataAsync(BestSolarPanelsInput bestSolarPanelsInput)
{
LocationDataModel? currentLocationData = new LocationDataModel();
Expand Down
5 changes: 2 additions & 3 deletions src/apps/api/Repository/BusinessRequestDataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ public async Task<string> GetProcessedDataAsync(BusinessRequestData requestData)
var data = requestData.data;
double latitude = requestData.latitude;
double longitude = requestData.longitude;

//create data if not created yet

var client = new HttpClient();
var dataTypeResponse = new HttpResponseMessage();

LocationDataModel? locationData = await locationDataClass.GetLocationData(latitude, longitude);
locationName = await otherDataClass.GetLocationNameFromCoordinates(latitude, longitude);
if (locationData == null)
{
await locationDataClass.CreateLocationData(latitude, longitude, locationName);
}

typeOfData = data!;
switch(data!.ToLower()){
case DataType.SOLAR_SCORE :
Expand Down
8 changes: 4 additions & 4 deletions src/apps/blazor-app/Components/Advanced/BuildYourHome.razor
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<div @onclick='@(() => CustomSystemModal("Panels"))'>
<Appliance css="scale-90 hover:shadow transition-all duration-300 hover:-translate-y-1" imageName="SolarPanels.svg" name="Number of Panels"count="@systems[selectedSystem].numberOfPanels" />
</div>
<input type="range" class="accent-primary-800 cursor-pointer w-full mt-3" min="4" max="20" step="1" value="@systems[selectedSystem].numberOfPanels" @oninput="ResetPanelTimer" @onchange="UpdateSelectedSystem"/>
<input type="range" class="accent-primary-800 cursor-pointer w-full mt-3" min="4" max="40" step="1" value="@systems[selectedSystem].numberOfPanels" @oninput="ResetPanelTimer" @onchange="UpdateSelectedSystem"/>
</div>
<div class="flex gap-2 pr-2 justify-start items-start">
<div class="flex flex-col gap-2 justify-center items-center w-full has-tooltip">
Expand All @@ -284,7 +284,7 @@
<Appliance css="scale-90 hover:shadow transition-all duration-300 hover:-translate-y-1" ImageName="Batteries.svg" name="Number of Batteries" count="@systems[selectedSystem].numberOfBatteries" />
</div>
</div>
<input type="range" class="accent-primary-800 cursor-pointer w-full " min="1" max="6" step="1" value="@systems[selectedSystem].numberOfBatteries" @oninput="ResetBatteryTimer" @onchange="UpdateSelectedSystem"/>
<input type="range" class="accent-primary-800 cursor-pointer w-full " min="1" max="10" step="1" value="@systems[selectedSystem].numberOfBatteries" @oninput="ResetBatteryTimer" @onchange="UpdateSelectedSystem"/>
</div>
}
else
Expand Down Expand Up @@ -523,12 +523,12 @@
/// </summary>
protected override async Task OnInitializedAsync()
{
panelTimer = new Timer(100);
panelTimer = new Timer(200);
panelTimer.Elapsed += SetNumberPanels;
panelTimer.AutoReset = false;
panelTimer.Enabled = true;

batteryTimer = new Timer(100);
batteryTimer = new Timer(200);
batteryTimer.Elapsed += SetNumberOfBatteries;
batteryTimer.AutoReset = false;
batteryTimer.Enabled = true;
Expand Down
52 changes: 24 additions & 28 deletions src/apps/blazor-app/Components/Advanced/Finanace.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,28 @@
@using ChartJs.Blazor.BarChart
@using BlazorApp.Models
@using BlazorApp.Components.Base
@using System.Timers
@implements IDisposable

<Heading css="mb-16 mt-16 max-w-3xl mx-auto">
<Superscript><h1 class="text-center">Potential Savings and</h1></Superscript >
<Header><h1 class="text-center">Solar ROI Calculator</h1></Header>
<Subscript><p class="text-center">All calculations are derived from the monthly bill. Please keep in mind that these calculations are approximate, and costs may vary among different solar installers."</p></Subscript>
</Heading>

<div class="w-full flex">
<div class="flex flex-col gap-2 items-center justify-center p-4 w-full rounded-3xl bg-gradient-to-tr from-primary-400 to-primary-500">
<div class="w-full flex justify-center">
<div class="flex flex-col gap-2 items-center justify-center p-4 w-11/12 rounded-3xl bg-gradient-to-tr from-primary-400 to-primary-500">
<p class="text-center text-white font-semibold">Select your monthly bill:</p>
<h1 class="text-center text-4xl font-black w-fit text-transparent bg-clip-text bg-gradient-to-l from-primary-100 to-primary-200">R @monthlyBill</h1>
<input type="range" class="accent-primary-800 cursor-pointer w-3/4" min="1000" max="7000" step="100" @bind="monthlyBill" @oninput="HandleBillSliderChange" />
<input type="range" class="accent-primary-800 cursor-pointer w-3/4" min="1000" max="7000" step="100" @bind="monthlyBill" @oninput="ResetTimer" />
</div>
<p class="text-2xl text-center text-primary-900 font-black self-center mx-4">OR</p>
<div class="flex flex-col gap-2 items-center justify-center p-4 w-full rounded-3xl bg-gradient-to-tr from-primary-400 to-primary-500">
<p class="text-center text-white font-semibold">Select your monthly electricity usage:</p>
<h1 class="text-center text-4xl font-black w-fit text-transparent bg-clip-text bg-gradient-to-l from-primary-100 to-primary-200">@monthlyUsage kWh</h1>
<input type="range" class="accent-primary-800 cursor-pointer w-3/4" min="400" max="2800" step="20" @bind="monthlyUsage" @oninput="HandleUsageSliderChange" />
</div>
</div>

<div class="flex gap-5 justify-center items-center mt-10">
<div class="w-1/2 h-1/2 mt-10">
<Chart Config="barConfig"></Chart>
</div>
<div class="flex w-1/2 flex-col gap-4 p-2 justify-center">
<div class="flex w-2/5 flex-col gap-4 p-2 justify-center">
<div class="bg-gradient-to-r p-4 flex gap-2 from-primary-400 to-primary-300 shadow w-2/3 h-1/2 rounded-2xl">
<div class="w-full h-full flex flex-col gap-2 justify-center items-center rounded-2xl">
<p class="text-center text-xl font-bold text-primary-100">Potential Payback</p>
Expand All @@ -53,15 +49,19 @@
@code {
private BarConfig? barConfig;
private int monthlyBill = 3500;
private int monthlyUsage = 600;
private BarDataset<double>? dataset;
private string[] colors = { "#d2d2d2", "#d2d2d2", "#d2d2d2", "#d2d2d2" };
private double min = 0;
private SystemInfo? activeSystem;

Timer timer = default!;


protected override void OnInitialized() {
timer = new Timer(10);
timer.Elapsed += HandleBillSliderChange;
timer.AutoReset = true;
timer.Enabled = true;

barConfig = new BarConfig
{
Options = new BarOptions
Expand Down Expand Up @@ -134,26 +134,22 @@
barConfig.Data.Datasets.Add(dataset);
}

private void HandleBillSliderChange(ChangeEventArgs e)
private void ResetTimer(ChangeEventArgs e)
{
if (int.TryParse(e.Value!.ToString(), out int newValue))
{
monthlyBill = newValue;
var round = Math.Round((monthlyBill / 2.5) / 10.0, 0);
monthlyUsage = (int) round * 10;
UpdateGraph();
}
timer.Stop();
int.TryParse(e.Value!.ToString(), out monthlyBill);
timer.Start();
}

private void HandleUsageSliderChange(ChangeEventArgs e)
private void HandleBillSliderChange(Object? source, ElapsedEventArgs e)
{
if (int.TryParse(e.Value!.ToString(), out int newValue))
{
monthlyUsage = newValue;
var round = Math.Round((monthlyUsage * 2.5) / 100.0, 0);
monthlyBill = (int) round * 100;
UpdateGraph();
}
var round = Math.Round((monthlyBill / 2.5) / 10.0, 0);
UpdateGraph();
}

void IDisposable.Dispose()
{
timer.Dispose();
}

private void UpdateGraph(){
Expand Down
89 changes: 43 additions & 46 deletions src/apps/blazor-app/Components/ApplianceEnergyConsumption.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<Chart Config="polarAreaConfig"></Chart>

@code{
@code {

[Parameter]
public List<ReportAllApplianceModel>? reportAllAppliance { get; set; }
Expand All @@ -12,84 +12,81 @@
public bool animated { get; set; } = true;
private PolarAreaConfig polarAreaConfig = new PolarAreaConfig();

string[] backgroundColors = new string[] { "rgba(255,193,8, 1)", "rgba(246,135,18, 1)", "rgba(0,15,82, 1)", "rgba(255,193,8, 1)", "rgba(246,135,18, 1)" };
string[] backgroundColors = new string[] { "rgba(255,193,8, 1)", "rgba(246,135,18, 1)", "rgba(0,15,82, 1)",
"rgba(255,193,8, 1)", "rgba(246,135,18, 1)" };

@* OnInitialized *@
protected override void OnInitialized()
{
polarAreaConfig = new PolarAreaConfig()
{
Options = new PolarAreaOptions
{
Responsive = true,
AspectRatio = 1.5,
Legend = new Legend
{
Display = false,
},
Animation = new ArcAnimation
{
AnimateRotate = animated,
Duration = animated == true ? 2000 : 0,

},
Tooltips = new Tooltips
Options = new PolarAreaOptions
{
Enabled = true,
Mode = InteractionMode.Index,
Intersect = false
},
Hover = new Hover
{
Mode = InteractionMode.Index,
Intersect = false
},
Scale = new LinearRadialAxis
{
Ticks = new LinearRadialTicks
Responsive = true,
AspectRatio = 1.5,
Legend = new Legend
{
Display = false,
}
}
},
Animation = new ArcAnimation
{
AnimateRotate = animated,
Duration = animated == true ? 2000 : 0,

}
};
RenderCharts();
}
},
Tooltips = new Tooltips
{
Enabled = true,
Mode = InteractionMode.Index,
Intersect = false
},
Hover = new Hover
{
Mode = InteractionMode.Index,
Intersect = false
},
Scale = new LinearRadialAxis
{
Ticks = new LinearRadialTicks
{
Display = false,
}
}

@* OnParametersSet *@
protected override void OnParametersSet()
{
}
};
RenderCharts();
}

public void RenderCharts()
{
if(reportAllAppliance is not null)
if (reportAllAppliance is not null)
{
polarAreaConfig.Data.Labels.Clear();
polarAreaConfig.Data.Datasets.Clear();
int[] powerUsageData = new int[reportAllAppliance.Count];
for (int i = 0; i < reportAllAppliance.Count; i++)
{
powerUsageData[i] = reportAllAppliance[i].numberOfAppliances * reportAllAppliance[i].defaultPowerUsage;
polarAreaConfig.Data.Labels.Add(reportAllAppliance[i].type + " - " + reportAllAppliance[i].applianceModel);
polarAreaConfig.Data.Labels.Add(reportAllAppliance[i].type + " - " + reportAllAppliance[i].applianceModel);
}
string[] backgroundColor = new string[reportAllAppliance.Count];
for (int i = 0; i < reportAllAppliance.Count; i++)
{
backgroundColor[i] = backgroundColors[i % backgroundColors.Length];

}
PolarAreaDataset<int> polarDataset = new PolarAreaDataset<int>(powerUsageData)
{
BackgroundColor = backgroundColor,
BorderWidth = 0,
};
{
BackgroundColor = backgroundColor,
BorderWidth = 0,
};

polarAreaConfig.Data.Datasets.Add(polarDataset);
StateHasChanged();
}else{
}
else
{
Console.WriteLine("reportAllAppliance is null");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/blazor-app/Components/Base/Image.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
else
{
<svg class="w-9 h-9 animate-pulse text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
<svg class="w-9 h-9 justify-center items-center animate-pulse text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
fill="currentColor" viewBox="0 0 20 18">
<path
d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z" />
Expand Down
Loading

0 comments on commit 6b47be0

Please sign in to comment.