Skip to content

Commit

Permalink
Clima Pro updates for Mobile app
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgedevs committed Nov 14, 2022
1 parent 754a513 commit d28f317
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Docs/Clima.Pro/Deploy_Instructions/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
* Install the Meadow Visual Studio Extension(s).
* Create and deploy the Meadow template application to ensure everthing is setup correctly.

### Expected Development version stack (RC-1)
At this point, you should have the following versions on your dev machine and Meadow:
* Meadow.CLI - v.0.90.0
* VS Tools for Meadow - v0.90.0
* Meadow
* Meadow.OS - v0.9.0.2
* Mono Runtime - v0.9.0.2
* ESP32 Coprocessor - v0.9.0.2

### Step 2. - Deploy the Clima App

* **Clone the Clima Repo** - [Clone](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories/cloning-and-forking-repositories-from-github-desktop) the [Clima(this) repository](https://github.com/wildernesslabs/Clima) locally.
Expand Down
17 changes: 1 addition & 16 deletions Source/Clima/CommonContracts/Models/ClimateModel.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
using System.Text.Json.Serialization;

namespace CommonContracts.Models
namespace CommonContracts.Models
{
public class ClimateModel
{
[JsonPropertyName("date")]
public string Date { get; set; }

[JsonPropertyName("temperature")]
public string Temperature { get; set; }

[JsonPropertyName("pressure")]
public string Pressure { get; set; }

[JsonPropertyName("humdity")]
public string Humidity { get; set; }

[JsonPropertyName("rain")]
public string Rain { get; set; }

[JsonPropertyName("windspeed")]
public string WindSpeed { get; set; }

[JsonPropertyName("winddirection")]
public string WindDirection { get; set; }
}
}
6 changes: 1 addition & 5 deletions Source/Clima/CommonContracts/Models/TemperatureModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System.Text.Json.Serialization;

namespace CommonContracts.Models
namespace CommonContracts.Models
{
public class TemperatureModel
{
[JsonPropertyName("Temperature")]
public string Temperature { get; set; }
[JsonPropertyName("DateTime")]
public string DateTime { get; set; }
}
}
15 changes: 12 additions & 3 deletions Source/Clima/MobileClima/View/MaplePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@
</Grid>
</Frame>

<Label Grid.Row="3" Text="Temperature Logs:" TextColor="Black" FontSize="Medium" Margin="0,5" />
<Label Grid.Row="3" TextColor="Black" FontSize="Medium" Margin="0,5">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding IsClimaPro}" Value="true">
<Setter Property="Text" Value="Climate Logs:" />
</DataTrigger>
<DataTrigger TargetType="Label" Binding="{Binding IsClimaPro}" Value="false">
<Setter Property="Text" Value="Temperature Logs:" />
</DataTrigger>
</Label.Triggers>
</Label>

<Frame Grid.Row="4" BackgroundColor="#F5F5F5" BorderColor="Transparent" HasShadow="False" Padding="0">
<Grid>
Expand Down Expand Up @@ -107,11 +116,11 @@
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Border BackgroundColor="#23ABE3" Stroke="Transparent" Padding="10,0">
<Border BackgroundColor="#23ABE3" Stroke="Transparent" Padding="10">
<Border.StrokeShape>
<RoundRectangle CornerRadius="5" />
</Border.StrokeShape>
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto" RowSpacing="0">
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto" RowSpacing="0">
<Label Grid.Row="0" Grid.Column="0" Text="Date" FontSize="Medium"
TextColor="White" VerticalOptions="Center" />
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Date}" FontSize="Medium"
Expand Down
36 changes: 35 additions & 1 deletion Source/Clima/MobileClima/ViewModel/MapleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ public MapleViewModel(bool isClimaPro)

CmdReloadTemperatureLog = new Command(async () =>
{
await GetTemperatureLogs();
if (isClimaPro)
{
await GetClimateLogs();
}
else
{
await GetTemperatureLogs();
}

IsRefreshing = false;
});
Expand Down Expand Up @@ -173,6 +180,33 @@ async Task GetTemperatureLogs()
}
}

async Task GetClimateLogs()
{
try
{
var response = await client.GetAsync(
hostAddress: SelectedServer != null ? SelectedServer.IpAddress : IpAddress,
port: ServerPort,
endpoint: "getclimalogs",
param: null,
value: null);

if (response == null)
return;

var values = System.Text.Json.JsonSerializer.Deserialize<List<ClimateModel>>(response);

foreach (var value in values)
{
WeatherLog.Add(value);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

public async Task LoadData()
{
await GetServers();
Expand Down

0 comments on commit d28f317

Please sign in to comment.