Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix versioning issues #85

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

# Build applications
- name: Build win-x86
run: dotnet publish Source\mqttMultimeter.csproj -r win-x86 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r win-x86 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip win-x86 build
uses: vimtor/action-zip@v1
Expand All @@ -44,7 +44,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-windows-x86.zip

- name: Build win-x64
run: dotnet publish Source\mqttMultimeter.csproj -r win-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r win-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip win-x64 build
uses: vimtor/action-zip@v1
Expand All @@ -59,7 +59,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-windows-x64.zip

- name: Build win-arm64
run: dotnet publish Source\mqttMultimeter.csproj -r win-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r win-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip win-arm64 build
uses: vimtor/action-zip@v1
Expand All @@ -74,7 +74,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-windows-arm64.zip

- name: Build osx-x64
run: dotnet publish Source\mqttMultimeter.csproj -r osx-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r osx-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip osx-x64 build
uses: vimtor/action-zip@v1
Expand All @@ -89,7 +89,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-macOS-x64.zip

- name: Build osx-arm64
run: dotnet publish Source\mqttMultimeter.csproj -r osx-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r osx-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip osx-arm64 build
uses: vimtor/action-zip@v1
Expand All @@ -104,7 +104,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-macOS-arm64.zip

- name: Build linux-x64
run: dotnet publish Source\mqttMultimeter.csproj -r linux-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r linux-x64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip linux-x64 build
uses: vimtor/action-zip@v1
Expand All @@ -119,7 +119,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-linux-x64.zip

- name: Build linux-arm
run: dotnet publish Source\mqttMultimeter.csproj -r linux-arm -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r linux-arm -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip linux-arm build
uses: vimtor/action-zip@v1
Expand All @@ -134,7 +134,7 @@ jobs:
path: ${{ github.workspace }}\mqttMultimeter-linux-arm.zip

- name: Build linux-arm64
run: dotnet publish Source\mqttMultimeter.csproj -r linux-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -property:Version=${{ env.VERSION }}
run: dotnet publish Source\mqttMultimeter.csproj -r linux-arm64 -p:Configuration=Release -p:PublishSingleFile=true -p:PublishReadyToRun=false -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true -p:Version=${{ env.VERSION }} -p:AssemblyVersion=${{ env.VERSION }}

- name: Zip linux-arm64 build
uses: vimtor/action-zip@v1
Expand Down
4 changes: 3 additions & 1 deletion Source/Main/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@
Margin="10,0,-10,0"
Padding="10,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{CompiledBinding InfoPage.CurrentAppVersion, StringFormat={}v{0}}" />
<TextBlock Text="{CompiledBinding InfoPage.CurrentAppVersion, StringFormat={}v{0}, Mode=OneTime}" />
<TextBlock Margin="10,0,0,0"
Cursor="Hand"
PointerPressed="OnUpdateAvailableNotificationPressed"
IsVisible="{CompiledBinding InfoPage.IsUpdateAvailable}"
Text="Update available" />
</StackPanel>
Expand Down
10 changes: 8 additions & 2 deletions Source/Main/MainView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;

namespace mqttMultimeter.Main;
Expand All @@ -26,14 +27,14 @@ void OnActivatePageRequested(object? sender, EventArgs e)
{
return;
}

foreach (TabItem? tabItem in sidebar.Items)
{
if (tabItem == null)
{
continue;
}

if (ReferenceEquals(sender, tabItem.Content))
{
sidebar.SelectedItem = tabItem;
Expand All @@ -52,4 +53,9 @@ void OnDataContextChanged(object? sender, EventArgs e)

viewModel.ActivatePageRequested += OnActivatePageRequested;
}

void OnUpdateAvailableNotificationPressed(object? _, PointerPressedEventArgs __)
{
((MainViewModel)DataContext!).InfoPage.OpenReleasesUrl();
}
}
15 changes: 8 additions & 7 deletions Source/Main/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Threading.Tasks;
using Avalonia.Threading;
using mqttMultimeter.Common;
using mqttMultimeter.Pages.Connection;
using mqttMultimeter.Pages.Inflight;
Expand All @@ -10,7 +10,6 @@
using mqttMultimeter.Pages.Subscriptions;
using mqttMultimeter.Pages.TopicExplorer;
using mqttMultimeter.Services.Mqtt;
using MQTTnet.Client;
using ReactiveUI;

namespace mqttMultimeter.Main;
Expand All @@ -33,7 +32,6 @@ public MainViewModel(ConnectionPageViewModel connectionPage,
MqttClientService mqttClientService)
{
_mqttClientService = mqttClientService ?? throw new ArgumentNullException(nameof(mqttClientService));
_mqttClientService.ApplicationMessageReceived += IncreaseCounter;

ConnectionPage = AttachEvents(connectionPage);
PublishPage = AttachEvents(publishPage);
Expand All @@ -46,6 +44,10 @@ public MainViewModel(ConnectionPageViewModel connectionPage,

InflightPage.RepeatMessageRequested += item => PublishPage.RepeatMessage(item);
topicExplorerPage.RepeatMessageRequested += item => PublishPage.RepeatMessage(item);

// Update the counter with a timer. There is no need to trigger a binding
// for each counter increment.
DispatcherTimer.Run(UpdateCounter, TimeSpan.FromSeconds(1));
}

public event EventHandler? ActivatePageRequested;
Expand Down Expand Up @@ -84,10 +86,9 @@ TPage AttachEvents<TPage>(TPage page) where TPage : BasePageViewModel
return page;
}

Task IncreaseCounter(MqttApplicationMessageReceivedEventArgs _)
bool UpdateCounter()
{
Counter++;

return Task.CompletedTask;
Counter = _mqttClientService.ReceivedMessagesCount;
return true;
}
}
8 changes: 4 additions & 4 deletions Source/Pages/Inflight/InflightPageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<TextBlock Margin="5,0"
HorizontalAlignment="Right"
Classes="code_text"
Text="{CompiledBinding Number, Mode=OneTime}" />
Text="{CompiledBinding Number}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand All @@ -86,7 +86,7 @@
<DataTemplate>
<TextBlock Margin="5,0"
Classes="code_text"
Text="{CompiledBinding Topic, Mode=OneTime}" />
Text="{CompiledBinding Topic}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand All @@ -99,7 +99,7 @@
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="5,0">
<Border IsVisible="{CompiledBinding Retain, Mode=OneTime}"
<Border IsVisible="{CompiledBinding Retain}"
Classes="badge badge_retain"
Margin="0,3">
<TextBlock />
Expand All @@ -117,7 +117,7 @@
<TextBlock Margin="5,0,10,0"
HorizontalAlignment="Right"
Classes="code_text"
Text="{CompiledBinding Length, StringFormat={}{0} bytes, Mode=OneTime}" />
Text="{CompiledBinding Length, StringFormat={}{0} bytes}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand Down
2 changes: 1 addition & 1 deletion Source/Pages/Info/InfoPageView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void Launch(string fileName)

void OnLatestVersionClicked(object? sender, PointerPressedEventArgs e)
{
Launch("https://github.com/chkr1011/mqttMultimeter/releases");
((InfoPageViewModel)DataContext!).OpenReleasesUrl();
}

void OnOpenHomepage(object? sender, RoutedEventArgs e)
Expand Down
15 changes: 15 additions & 0 deletions Source/Pages/Info/InfoPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using Avalonia.Controls;
using Avalonia.Threading;
using mqttMultimeter.Common;
Expand Down Expand Up @@ -47,6 +48,11 @@ public string LatestAppVersion

public string MqttNetVersion { get; }

public void OpenReleasesUrl()
{
Launch("https://github.com/chkr1011/mqttMultimeter/releases");
}

bool CheckForUpdates()
{
LatestAppVersion = _appUpdateService.LatestVersion?.ToString() ?? string.Empty;
Expand All @@ -55,4 +61,13 @@ bool CheckForUpdates()
// Keep timer running.
return true;
}

static void Launch(string fileName)
{
Process.Start(new ProcessStartInfo
{
FileName = fileName,
UseShellExecute = true
});
}
}
10 changes: 5 additions & 5 deletions Source/Pages/PacketInspector/PacketInspectorPageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
HorizontalAlignment="Right"
Classes="code_text"
x:DataType="packetInspector:PacketViewModel"
Text="{CompiledBinding Number, Mode=OneTime}" />
Text="{CompiledBinding Number}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand All @@ -62,7 +62,7 @@
<Grid Margin="10,0,0,0"
x:DataType="packetInspector:PacketViewModel">
<StackPanel Orientation="Horizontal"
IsVisible="{CompiledBinding IsInbound, Mode=OneTime}">
IsVisible="{CompiledBinding IsInbound}">
<PathIcon Width="16"
Height="16"
Data="{StaticResource arrow_download_regular}" />
Expand All @@ -71,7 +71,7 @@
Text="Inbound" />
</StackPanel>
<StackPanel Orientation="Horizontal"
IsVisible="{CompiledBinding !IsInbound, Mode=OneTime}">
IsVisible="{CompiledBinding !IsInbound}">
<PathIcon Width="16"
Height="16"
Data="{StaticResource arrow_upload_regular}" />
Expand All @@ -92,7 +92,7 @@
<TextBlock Margin="5,0"
Classes="code_text"
x:DataType="packetInspector:PacketViewModel"
Text="{CompiledBinding Type, Mode=OneTime}" />
Text="{CompiledBinding Type}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand All @@ -106,7 +106,7 @@
HorizontalAlignment="Right"
Classes="code_text"
x:DataType="packetInspector:PacketViewModel"
Text="{CompiledBinding Length, StringFormat={}{0} bytes, Mode=OneTime}" />
Text="{CompiledBinding Length, StringFormat={}{0} bytes}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand Down
29 changes: 16 additions & 13 deletions Source/Pages/PacketInspector/PacketInspectorPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Avalonia.Threading;
using mqttMultimeter.Common;
using mqttMultimeter.Services.Mqtt;
Expand Down Expand Up @@ -85,25 +86,25 @@ static string GetControlPacketType(byte data)
}
}

void ProcessPacket(InspectMqttPacketEventArgs eventArgs)
Task ProcessPacket(InspectMqttPacketEventArgs eventArgs)
{
if (!_isRecordingEnabled)
{
return;
return Task.CompletedTask;
}

var number = _number++;
var viewModel = new PacketViewModel
{
Number = number,
Type = GetControlPacketType(eventArgs.Buffer[0]),
Data = eventArgs.Buffer,
Length = eventArgs.Buffer.Length,
IsInbound = eventArgs.Direction == MqttPacketFlowDirection.Inbound
};


Dispatcher.UIThread.Invoke(() =>
{
var number = _number++;
var viewModel = new PacketViewModel
{
Number = number,
Type = GetControlPacketType(eventArgs.Buffer[0]),
Data = eventArgs.Buffer,
Length = eventArgs.Buffer.Length,
IsInbound = eventArgs.Direction == MqttPacketFlowDirection.Inbound
};

Packets.Add(viewModel);

// TODO: Move to configuration.
Expand All @@ -112,5 +113,7 @@ void ProcessPacket(InspectMqttPacketEventArgs eventArgs)
Packets.RemoveAt(0);
}
});

return Task.CompletedTask;
}
}
4 changes: 2 additions & 2 deletions Source/Pages/TopicExplorer/TopicExplorerItemMessageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<StackPanel Orientation="Horizontal"
Margin="10">
<TextBlock Classes="code_text"
Text="{CompiledBinding Timestamp, StringFormat={}{0:HH:mm:ss.fff}, Mode=OneTime}" />
Text="{CompiledBinding Timestamp, StringFormat={}{0:HH:mm:ss.fff}}" />
<TextBlock Classes="code_text"
Margin="10,0"
Text="="
FontStyle="Italic" />
<TextBlock Classes="code_text"
Margin="0,0,10,0"
FontStyle="Italic"
Text="{CompiledBinding Payload, Mode=OneTime}" />
Text="{CompiledBinding Payload}" />
</StackPanel>

</UserControl>
Loading
Loading