Skip to content

Commit

Permalink
Reading service endpoingts from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tschissler committed Oct 3, 2023
1 parent 758cc61 commit bf1b890
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions Shared.Contracts/Configuration/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Common
{
public static string SyncfusionLicenseKey { get; set; }
public static string PVServiceUrl { get; set; }
public static string ChargingServiceUrl { get; set; }

static Common()
{
Expand Down
8 changes: 4 additions & 4 deletions Smarthome.Web/Pages/Charge.razor
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@

public ChargingDataPoints ChargingDataPoints = new ChargingDataPoints();


private Timer refreshTimer;
private ChargingSettingsData settings = new();
private string chargingServiceEndpoint = $"{SharedContracts.Configuration.Common.ChargingServiceUrl}";

protected override void OnInitialized()
{
Expand All @@ -133,7 +133,7 @@
// minimumPVShare = ChargingControlDataPoints.MinimumPVShare.CurrentValue,
// manualCurrency = ChargingControlDataPoints.ManualChargingCurrency.CurrentValue
// };
Http.PostAsJsonAsync("http://localhost:5004/applychargingsettings", settings);
Http.PostAsJsonAsync($"{chargingServiceEndpoint}/applychargingsettings", settings);
}

private void Refresh(object? state)
Expand All @@ -144,7 +144,7 @@
{
using (HttpClient Http = new HttpClient())
{
var jsonString = Http.GetStringAsync("http://localhost:5004/readchargingsettings").Result;
var jsonString = Http.GetStringAsync($"{chargingServiceEndpoint}/readchargingsettings").Result;
settings = JsonConvert.DeserializeObject<ChargingSettingsData>(jsonString);
settings.isInitialized = true;
}
Expand All @@ -159,7 +159,7 @@
{
using (HttpClient Http = new HttpClient())
{
var jsonString = Http.GetStringAsync("http://localhost:5004/readdata").Result;
var jsonString = Http.GetStringAsync($"{chargingServiceEndpoint}/readdata").Result;
ChargingDataPoints = JsonConvert.DeserializeObject<ChargingDataPoints>(jsonString);
InvokeAsync(StateHasChanged);
}
Expand Down
2 changes: 2 additions & 0 deletions Smarthome.Web/Pages/ConsumptionM1.razor
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
{
private Timer refreshTimer;
private ConsumptionDataPoints dataPoints = new();
private string pvServiceEndpoint = $"{SharedContracts.Configuration.Common.PVServiceUrl}/readSensorsdata";
private string chargingServiceEndpoint = $"{SharedContracts.Configuration.Common.ChargingServiceUrl}/readdata";

public HistoryChartDataSeries PowerDevice1Data;
public HistoryChartDataSeries PowerDevice2Data;
Expand Down
3 changes: 2 additions & 1 deletion Smarthome.Web/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

private Timer refreshTimer;
private string pvServiceEndpoint = $"{SharedContracts.Configuration.Common.PVServiceUrl}/readSensorsdata";
private string chargingServiceEndpoint = $"{SharedContracts.Configuration.Common.ChargingServiceUrl}/readdata";

public HistoryChartDataSeries PVProduction;
public HistoryChartDataSeries GridSupply;
Expand Down Expand Up @@ -110,7 +111,7 @@
{
using (HttpClient Http = new HttpClient())
{
var jsonString = Http.GetStringAsync("http://localhost:5004/readdata").Result;
var jsonString = Http.GetStringAsync(chargingServiceEndpoint).Result;
ChargingDataPoints = JsonConvert.DeserializeObject<ChargingDataPoints>(jsonString);
Cleanup(ChargingDataPoints.CurrentChargingPower);
}
Expand Down

0 comments on commit bf1b890

Please sign in to comment.