-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Turbulence.Core.ViewModels.Design | ||
{ | ||
public class DesignLogViewModel : LogViewModel | ||
{ | ||
public DesignLogViewModel() | ||
{ | ||
Logs.AddRange(new string[] | ||
{ | ||
"[CDN] Request 1", | ||
"[API] Request 2", | ||
}); | ||
} | ||
|
||
public override void Refresh() | ||
{ | ||
Logs.Add($"[REFRESH] New Request {Logs.Count}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Turbulence.Discord.Services; | ||
|
||
namespace Turbulence.Core.ViewModels; | ||
|
||
public partial class LogViewModel : ViewModelBase | ||
{ | ||
private readonly ILogger _logger = Ioc.Default.GetService<ILogger>()!; | ||
public ObservableList<string> Logs { get; } = new(); | ||
|
||
public LogViewModel() | ||
{ | ||
Refresh(); | ||
} | ||
|
||
[RelayCommand] | ||
public virtual void Refresh() | ||
{ | ||
Logs.ReplaceAll(_logger.GetLogs()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Window xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:vm="clr-namespace:Turbulence.Core.ViewModels;assembly=Turbulence.Core" | ||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="500" | ||
Width="600" Height="500" | ||
MinWidth="600" MinHeight="500" | ||
WindowStartupLocation="CenterOwner" | ||
x:Class="Turbulence.Desktop.LogWindow" | ||
x:DataType="vm:LogViewModel" | ||
Title="Logs" | ||
Background="#313338"> | ||
<Window.DataContext> | ||
<vm:LogViewModel /> | ||
</Window.DataContext> | ||
<DockPanel> | ||
<Menu DockPanel.Dock="Top" Background="#23272A"> | ||
<MenuItem Header="Refresh" Command="{Binding RefreshCommand}" /> | ||
<!--TODO: add filter--> | ||
</Menu> | ||
<ScrollViewer> | ||
<ItemsControl ItemsSource="{Binding Logs}"> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<TextBlock Text="{Binding .}" /> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</ScrollViewer> | ||
</DockPanel> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Avalonia.Controls; | ||
using Turbulence.Core.ViewModels.Design; | ||
|
||
namespace Turbulence.Desktop; | ||
|
||
public partial class LogWindow : Window | ||
{ | ||
public LogWindow() | ||
{ | ||
InitializeComponent(); | ||
if (Design.IsDesignMode) | ||
{ | ||
// Workaround to fix design data context getting overwritten | ||
DataContext = new DesignLogViewModel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using Avalonia.Controls; | ||
|
||
namespace Turbulence.Desktop | ||
namespace Turbulence.Desktop; | ||
|
||
public partial class SettingsWindow : Window | ||
{ | ||
public partial class SettingsWindow : Window | ||
public SettingsWindow() | ||
{ | ||
public SettingsWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Turbulence.Discord.Services; | ||
|
||
public interface ILogger | ||
{ | ||
public void Log(string message); | ||
public IEnumerable<string> GetLogs(); | ||
} | ||
|
||
|
||
public class Logger : ILogger | ||
{ | ||
//TODO: add logging severity/level | ||
//TODO: add logging type | ||
//TODO: add timestamp | ||
private readonly List<string> _log = new(); | ||
|
||
public IEnumerable<string> GetLogs() | ||
{ | ||
return _log; | ||
} | ||
|
||
public void Log(string message) | ||
{ | ||
_log.Add(message); | ||
} | ||
} |