8 Commits

Author SHA1 Message Date
ddc7206a73 optim(redmine): hour stats are also improved 2026-01-15 20:03:45 +01:00
d152b62cc4 optim(redmine): made most requests async 2026-01-15 16:31:53 +01:00
0b6df0c508 bump 0.2.2 2025-12-17 12:34:27 +01:00
ec077240a4 fix update button, bump 0.2.1 2025-12-17 12:32:24 +01:00
56fd7a6da7 bump 0.2.0 2025-12-17 12:23:56 +01:00
db063e61b1 add commenting on issues 2025-12-17 12:23:29 +01:00
a86ad23774 add loading progress to hours window 2025-12-17 12:23:21 +01:00
b68c43af38 bump 0.1.9 2025-12-16 21:58:22 +01:00
8 changed files with 328 additions and 92 deletions

View File

@@ -1,5 +1,8 @@
using Blueberry.Redmine.Dto; using Blueberry.Redmine.Dto;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -76,7 +79,7 @@ namespace Blueberry.Redmine
throw new RedmineApiException("Redmine API Unreachable"); throw new RedmineApiException("Redmine API Unreachable");
} }
/*
private async Task<List<TReturn>> SendRequestWithPagingAsync<TResponse, TReturn>(HttpMethod method, string endpoint, int limit, Func<TResponse, List<TReturn>> itemParser, private async Task<List<TReturn>> SendRequestWithPagingAsync<TResponse, TReturn>(HttpMethod method, string endpoint, int limit, Func<TResponse, List<TReturn>> itemParser,
IProgress<(int current, int total)>? progress = null, object? payload = null, CancellationToken? token = null) where TResponse : IResponseList IProgress<(int current, int total)>? progress = null, object? payload = null, CancellationToken? token = null) where TResponse : IResponseList
{ {
@@ -84,6 +87,8 @@ namespace Blueberry.Redmine
List<TReturn> returnList = []; List<TReturn> returnList = [];
_logger.LogDebug("Starting paged request to {Endpoint} with limit {Limit}", endpoint, limit);
while (true) while (true)
{ {
var path = ""; var path = "";
@@ -110,6 +115,106 @@ namespace Blueberry.Redmine
return returnList; return returnList;
} }
*/
private async Task<List<TReturn>> SendRequestWithPagingAsync<TResponse, TReturn>(HttpMethod method, string endpoint, int limit, Func<TResponse, List<TReturn>> itemParser,
IProgress<(int current, int total)>? progress = null, object? payload = null, CancellationToken? token = null) where TResponse : IResponseList
{
var sw = new Stopwatch();
sw.Start();
var offset = 0;
List<TReturn> returnList = [];
_logger.LogDebug("Starting paged request to {Endpoint} with limit {Limit}", endpoint.Split('?')[0], limit);
var path = "";
if (endpoint.Contains('?'))
path = $"{endpoint}&limit={limit}&offset={offset}";
else
path = $"{endpoint}?limit={limit}&offset={offset}";
var responseList = await SendRequestAsync<TResponse>(HttpMethod.Get, path, token: token)
?? throw new NullReferenceException();
var total = responseList.TotalCount;
returnList.AddRange(itemParser(responseList));
offset += limit;
if (offset >= responseList.TotalCount)
{
_logger.LogDebug(" + Single request retrieved all {TotalItems} items", returnList.Count);
return returnList;
}
var remain = total - offset;
var tasks = new Task[(int)Math.Ceiling((double)remain / limit)];
List<(int id, IEnumerable<TReturn> items)> responses = [];
var preparationTime = sw.ElapsedMilliseconds;
sw.Restart();
for (int i = 0; i < tasks.Length; i++)
{
var id = i;
var o = offset;
tasks[i] = Task.Run(async () =>
{
if (endpoint.Contains('?'))
path = $"{endpoint}&limit={limit}&offset={o}";
else
path = $"{endpoint}?limit={limit}&offset={o}";
var responseList = await SendRequestAsync<TResponse>(HttpMethod.Get, path, token: token)
?? throw new NullReferenceException();
responses.Add((id, itemParser(responseList)));
});
offset += limit;
}
while (tasks.Any(t => !t.IsCompleted))
{
if (progress != null)
{
var current = Math.Min(tasks.Count(x=>x.IsCompletedSuccessfully), tasks.Length);
progress.Report((current, tasks.Length));
}
await Task.Delay(250);
}
await Task.WhenAll(tasks);
await Task.Delay(50);
var executionTime = sw.ElapsedMilliseconds;
sw.Restart();
foreach (var resp in responses.OrderBy(x => x.id))
{
returnList.AddRange(resp.items);
}
_logger.LogDebug(" + Aggregated total of {TotalItems} items from {Count} responses", returnList.Count, responses.Count);
var aggregationTime = sw.ElapsedMilliseconds;
sw.Stop();
// log times
_logger.LogDebug(" + Paging completed in:\n Preparation: {Preparation}ms\n Execution: {Execution}ms\n Aggregation: {Aggregation}ms\n Total: {Total}ms"
, preparationTime, executionTime, aggregationTime, preparationTime + executionTime + aggregationTime);
// log avarege time per task and per item, round them to whole ms
_logger.LogDebug(" + Average time per task: {AvgTask}ms, Average time per item: {AvgItem}ms",
Math.Round((double)(preparationTime + executionTime) / tasks.Length + 1),
Math.Round((double)(executionTime) / returnList.Count));
return returnList;
}
public async Task<List<StatusList.IssueStatus>> GetStatusesAsync(CancellationToken? token = null) public async Task<List<StatusList.IssueStatus>> GetStatusesAsync(CancellationToken? token = null)
{ {
@@ -364,7 +469,7 @@ namespace Blueberry.Redmine
{ {
var path = "users.json"; var path = "users.json";
return await SendRequestWithPagingAsync<UserList.Root, UserInfo.User>(HttpMethod.Get, path, limit, (x) => x.Users, progress, token); return [.. (await SendRequestWithPagingAsync<UserList.Root, UserInfo.User>(HttpMethod.Get, path, limit, (x) => x.Users, progress, token)).OrderBy(x => x.FullName)];
} }
public async Task SetIssueStatusAsync(int issueId, int statusId, CancellationToken? token = null) public async Task SetIssueStatusAsync(int issueId, int statusId, CancellationToken? token = null)
@@ -390,20 +495,11 @@ namespace Blueberry.Redmine
{ {
issue = new issue = new
{ {
notes = comment notes = comment,
} private_notes = isPrivate
};
var privatePayload = new
{
issue = new
{
private_notes = comment
} }
}; };
if(isPrivate)
await SendRequestAsync<object>(HttpMethod.Put, path, privatePayload, token: token);
else
await SendRequestAsync<object>(HttpMethod.Put, path, payload, token: token); await SendRequestAsync<object>(HttpMethod.Put, path, payload, token: token);
} }

View File

@@ -2,6 +2,7 @@
using Blueberry.Redmine; using Blueberry.Redmine;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.IO; using System.IO;
@@ -33,10 +34,16 @@ namespace BlueMine
}); });
//services.AddTransient<RedmineAuthHandler>(); //services.AddTransient<RedmineAuthHandler>();
services.AddHttpClient<RedmineManager>(client => client.BaseAddress = new Uri("http://localhost/")); //services.AddHttpClient("client", client => client.BaseAddress = new Uri("http://localhost/")).RemoveAllLoggers();
services.AddHttpClient("client").RemoveAllLoggers();
services.Configure<LoggerFilterOptions>(opts =>
{
opts.AddFilter("System.Net.Http.HttpClient", LogLevel.Warning);
});
// .AddHttpMessageHandler<RedmineAuthHandler>(); // .AddHttpMessageHandler<RedmineAuthHandler>();
services.AddSingleton<RedmineManager>(); services.AddSingleton<RedmineManager>();
services.AddSingleton<HoursWindow>();
services.AddSingleton<MainWindow>(); services.AddSingleton<MainWindow>();
}).Build(); }).Build();

View File

@@ -1,10 +1,12 @@
using Blueberry.Redmine; using Blueberry.Redmine;
using Blueberry.Redmine.Dto; using Blueberry.Redmine.Dto;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Threading.Tasks; using System.Diagnostics;
using System.Windows; using System.Windows;
using Wpf.Ui.Controls; using Wpf.Ui.Controls;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Blueberry namespace Blueberry
{ {
@@ -17,37 +19,92 @@ namespace Blueberry
private readonly RedmineManager _manager; private readonly RedmineManager _manager;
private readonly RedmineConfig _config; private readonly RedmineConfig _config;
private readonly ConcurrentDictionary<int, string> _issueNames = []; private readonly ConcurrentDictionary<int, string> _issueNames = [];
private readonly ILogger _logger;
public ObservableCollection<DisplayHours> Hours { get; set; } = []; public ObservableCollection<DisplayHours> Hours { get; set; } = [];
public HoursWindow(RedmineManager manager, RedmineConfig config) public HoursWindow(RedmineManager manager, RedmineConfig config, ILogger<HoursWindow> logger)
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
_manager = manager; _manager = manager;
_config = config; _config = config;
_logger = logger;
} }
private async void FluentWindow_Loaded(object sender, System.Windows.RoutedEventArgs e) private async void FluentWindow_Loaded(object sender, RoutedEventArgs e)
{ {
var u = await _manager.GetUsersAsync(); userComboBox.IsEnabled =
searchButton.IsEnabled =
dateButton.IsEnabled = false;
var u = await _manager.GetUsersAsync(progress: UpdateProgress());
var current = await _manager.GetCurrentUserAsync(); var current = await _manager.GetCurrentUserAsync();
hoursProgress.Visibility = Visibility.Hidden; hoursProgress.Visibility = Visibility.Hidden;
hoursProgress.IsIndeterminate = true;
_users.Clear(); _users.Clear();
_users.AddRange(u); _users.AddRange(u);
userComboBox.Items.Clear(); userComboBox.Items.Clear();
foreach (var user in u) foreach (var user in u)
userComboBox.Items.Add(user); userComboBox.Items.Add(user);
userComboBox.SelectedItem = current; userComboBox.SelectedItem = _users.First(x=>x.Id == current.Id);
userComboBox.IsEnabled =
searchButton.IsEnabled =
dateButton.IsEnabled = true;
} }
private void dateButton_Click(object sender, System.Windows.RoutedEventArgs e) private IProgress<(int, int)> UpdateProgress()
{
var p = new Progress<(int current, int total)>((x) =>
{
Dispatcher.Invoke(() =>
{
hoursProgress.IsIndeterminate = false;
var percent = (int)((double)x.current / x.total * 100);
hoursProgress.Progress = percent;
});
});
return p;
}
private void dateButton_Click(object sender, RoutedEventArgs e)
{ {
calendarFlyout.IsOpen = true; calendarFlyout.IsOpen = true;
} }
private async void searchButton_Click(object sender, System.Windows.RoutedEventArgs e) private void UpdateProgressI()
{
Dispatcher.Invoke(() =>
{
var percent = (int)((double)loadI / totalI * 100);
lock (_lock)
{
hoursProgress.Progress = percent;
}
});
}
private int loadInternalI = 0;
private object _lock = new();
private int loadI { get
{
var result = 0;
lock(_lock)
{
result = loadInternalI;
}
return result;
}
set
{
lock (_lock)
{
loadInternalI = value;
}
}
}
private int totalI = 0;
private async void searchButton_Click(object sender, RoutedEventArgs e)
{ {
var user = userComboBox.SelectedItem as UserInfo.User; var user = userComboBox.SelectedItem as UserInfo.User;
if(user is null) if(user is null)
@@ -61,13 +118,33 @@ namespace Blueberry
Task[] tasks = new Task[selectedDates.Count]; Task[] tasks = new Task[selectedDates.Count];
Hours.Clear(); Hours.Clear();
hoursProgress.Visibility= Visibility.Visible; hoursProgress.Visibility= Visibility.Visible;
var firstDate = userCalendar.SelectedDates.First();
var lastDate = userCalendar.SelectedDates.Last();
for (int i = 0; i < selectedDates.Count; i++) var newTicketTask = _manager.GetIssuesAsync(user.Id, createdFrom: selectedDates.First(), createdTo: selectedDates.Last());
var closedTicketTask = _manager.GetIssuesAsync(user.Id, isOpen: false, updatedFrom: selectedDates.First(), updatedTo: selectedDates.Last());
var currentTicketTask = _manager.GetUserOpenIssuesAsync(user.Id);
var h = await _manager.GetTimeForUserAsync(user.Id, firstDate, lastDate);
var list = new List<string>();
foreach (var item in h)
if (await GetIssueNameAsync(item.Issue.Id, download: false) == "")
list.Add(item.Issue.Id.ToString());
if (list.Count > 0)
{ {
var date = selectedDates[i]; list = [.. list.Distinct()];
tasks[i] = Task.Run(async () => _logger.LogDebug("Downloading issue names for {count} issues", list.Count);
var ts = new Task[list.Count];
for (int y = 0; y < list.Count; y++)
{ {
var h = await _manager.GetTimeForUserAsync(user.Id, date, date); string? id = list[y];
ts[y] = GetIssueNameAsync(int.Parse(id));
}
await Task.WhenAll(ts);
}
foreach (var item in h) foreach (var item in h)
{ {
var dh = new DisplayHours() var dh = new DisplayHours()
@@ -75,7 +152,7 @@ namespace Blueberry
ProjectName = item.Project.Name, ProjectName = item.Project.Name,
IssueName = await GetIssueNameAsync(item.Issue.Id), IssueName = await GetIssueNameAsync(item.Issue.Id),
IssueId = item.Issue.Id.ToString(), IssueId = item.Issue.Id.ToString(),
Date = date, Date = DateTime.Parse(item.SpentOn),
CreatedOn = item.CreatedOn, CreatedOn = item.CreatedOn,
Hours = item.Hours.ToString(), Hours = item.Hours.ToString(),
Comments = item.Comments, Comments = item.Comments,
@@ -83,15 +160,34 @@ namespace Blueberry
}; };
hours.Add(dh); hours.Add(dh);
} }
});
await Task.Delay(10); var orderedHours = hours.OrderByDescending(h => h.CreatedOn).OrderBy(h => h.Date).ToList();
var previousDate = DateTime.MinValue;
for (int i = 0; i < orderedHours.Count; i++)
{
if (orderedHours[i].Date.Date > previousDate)
{
var ttl = orderedHours.Where(x => x.Date.Date == orderedHours[i].Date.Date).Sum(x => double.Parse(x.Hours));
var dh = new DisplayHours()
{
IsSeparator = true,
SeparatorText = orderedHours[i].Date.ToString("yyyy-MM-dd") + " | Összesen: " + ttl + " óra"
};
orderedHours.Insert(i, dh);
previousDate = orderedHours[i + 1].Date.Date;
}
} }
await Task.WhenAll(tasks); hoursProgress.Visibility = Visibility.Hidden;
var newTickets = await _manager.GetIssuesAsync(user.Id, createdFrom: selectedDates.First(), createdTo: selectedDates.Last()); foreach (var item in orderedHours)
var closedTickets = await _manager.GetIssuesAsync(user.Id, isOpen: false, updatedFrom: selectedDates.First(), updatedTo: selectedDates.Last()); Hours.Add(item);
var currentTickets = await _manager.GetUserOpenIssuesAsync(user.Id);
await Task.WhenAll(newTicketTask, closedTicketTask, currentTicketTask);
var newTickets = newTicketTask.Result;
var closedTickets = closedTicketTask.Result;
var currentTickets = currentTicketTask.Result;
var total = hours.Sum(x => double.Parse(x.Hours)); var total = hours.Sum(x => double.Parse(x.Hours));
totalHoursTextBlock.Text = total.ToString(); totalHoursTextBlock.Text = total.ToString();
@@ -114,40 +210,23 @@ namespace Blueberry
avgTicketAgeTextBlock.Text = Math.Round(currentTickets.Average(x => (DateTime.Now - x.CreatedOn).TotalDays), 2) + " nap"; avgTicketAgeTextBlock.Text = Math.Round(currentTickets.Average(x => (DateTime.Now - x.CreatedOn).TotalDays), 2) + " nap";
var ages = currentTickets.Select(x => (DateTime.Now - x.CreatedOn).TotalDays).Order().ToList(); var ages = currentTickets.Select(x => (DateTime.Now - x.CreatedOn).TotalDays).Order().ToList();
medianTicketAgeTextBlock.Text = Math.Round(ages[ages.Count / 2], 2) + " nap"; medianTicketAgeTextBlock.Text = Math.Round(ages[ages.Count / 2], 2) + " nap";
var orderedHours = hours.OrderByDescending(h => h.CreatedOn).OrderBy(h => h.Date).ToList();
var previousDate = DateTime.MinValue;
for (int i = 0; i < orderedHours.Count; i++)
{
if(orderedHours[i].Date.Date > previousDate)
{
total = orderedHours.Where(x => x.Date.Date == orderedHours[i].Date.Date).Sum(x => double.Parse(x.Hours));
var dh = new DisplayHours()
{
IsSeparator = true,
SeparatorText = orderedHours[i].Date.ToString("yyyy-MM-dd") + " | Összesen: " + total + " óra"
};
orderedHours.Insert(i, dh);
previousDate = orderedHours[i+1].Date.Date;
}
} }
hoursProgress.Visibility = Visibility.Hidden; private async Task<string> GetIssueNameAsync(int issueId, bool download = true)
foreach (var item in orderedHours)
Hours.Add(item);
}
private async Task<string> GetIssueNameAsync(int issueId)
{ {
try try
{ {
if (_issueNames.ContainsKey(issueId)) if (_issueNames.ContainsKey(issueId))
return _issueNames[issueId]; return _issueNames[issueId];
if(download)
{
var name = (await _manager.GetSimpleIssueAsync(issueId)).Subject; var name = (await _manager.GetSimpleIssueAsync(issueId)).Subject;
_issueNames.TryAdd(issueId, name); _issueNames.TryAdd(issueId, name);
return name; return name;
} else
{
return "";
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -189,5 +268,6 @@ namespace Blueberry
} }
} }
} }
} }
} }

View File

@@ -79,6 +79,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="1*" /> <RowDefinition Height="1*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" /> <ColumnDefinition Width="1*" />
@@ -130,7 +131,14 @@
<ColumnDefinition Width="Auto" SharedSizeGroup="y" /> <ColumnDefinition Width="Auto" SharedSizeGroup="y" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Height="4" Margin="0, 0, 0, 4" RadiusX="2" RadiusY="2" HorizontalAlignment="Stretch" Fill="{Binding NameColor}" /> <Rectangle Grid.Row="0" Height="4" Margin="0, 0, 0, 4" RadiusX="2" RadiusY="2" HorizontalAlignment="Stretch" Fill="{Binding NameColor}" />
<ui:TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding User}" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" FontWeight="Bold" /> <Grid Grid.Row="1" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Column="0" Text="{Binding User}" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" FontWeight="Bold" />
<ui:SymbolIcon Symbol="LockClosed24" Grid.Column="1" Visibility="{Binding LockVisibility}" Margin="5, 0, 0, 0" FontSize="12" Foreground="Orange" VerticalAlignment="Top" />
</Grid>
<ui:TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding Date}" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" /> <ui:TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding Date}" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" />
<ui:TextBlock Grid.Row="2" Grid.ColumnSpan="3" Text="{Binding Content}" Foreground="{Binding StatusColor}" TextWrapping="Wrap" FontSize="12" /> <ui:TextBlock Grid.Row="2" Grid.ColumnSpan="3" Text="{Binding Content}" Foreground="{Binding StatusColor}" TextWrapping="Wrap" FontSize="12" />
</Grid> </Grid>
@@ -140,6 +148,23 @@
</ui:ListView> </ui:ListView>
</Grid> </Grid>
</ui:Card> </ui:Card>
<Grid Grid.Row="2" Grid.ColumnSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBox Grid.RowSpan="2" Margin="10, 10, 5, 10" x:Name="commentTextBox" AcceptsReturn="True" MinLines="2" />
<ui:Button Grid.Column="1" Content="Küldés" Margin="5, 10, 10, 5" x:Name="commentButton" Click="commentButton_Click">
<ui:Button.Icon>
<ui:SymbolIcon Symbol="Send24" />
</ui:Button.Icon>
</ui:Button>
<ui:ToggleSwitch x:Name="privateToggle" Grid.Row="1" Grid.Column="1" OnContent="Privát" OffContent="Privát" Margin="5, 5, 10, 10" />
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</ui:FluentWindow> </ui:FluentWindow>

View File

@@ -2,6 +2,7 @@
using Blueberry.Redmine.Dto; using Blueberry.Redmine.Dto;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using Windows.Networking.NetworkOperators; using Windows.Networking.NetworkOperators;
@@ -14,7 +15,7 @@ namespace Blueberry
/// </summary> /// </summary>
public partial class IssueWindow : FluentWindow public partial class IssueWindow : FluentWindow
{ {
private readonly DetailedIssue.Issue _issue; private DetailedIssue.Issue _issue;
private readonly RedmineManager _manager; private readonly RedmineManager _manager;
private readonly RedmineConfig _config; private readonly RedmineConfig _config;
private readonly List<JournalDisplay> _journalDisplays = []; private readonly List<JournalDisplay> _journalDisplays = [];
@@ -38,13 +39,25 @@ namespace Blueberry
iCreatedTextBox.Text = _issue.CreatedOn.ToString("yyyy-MM-dd"); iCreatedTextBox.Text = _issue.CreatedOn.ToString("yyyy-MM-dd");
iUpdatedTextBox.Text = _issue.UpdatedOn.ToString("yyyy-MM-dd"); iUpdatedTextBox.Text = _issue.UpdatedOn.ToString("yyyy-MM-dd");
iSpentTimeTextBox.Text = _issue.SpentHours.ToString(); iSpentTimeTextBox.Text = _issue.SpentHours.ToString();
await DownloadJournals();
}
private async Task DownloadJournals()
{
Journals.Clear();
journalProgressRing.Visibility = Visibility.Visible; journalProgressRing.Visibility = Visibility.Visible;
List<TimeOnIssue.TimeEntry> hours = []; List<TimeOnIssue.TimeEntry> hours = [];
try try
{ {
var id = _issue.Id;
var newIssue = await _manager.GetIssueAsync(id);
if(newIssue != null)
_issue = newIssue;
hours = await _manager.GetTimeOnIssue(_issue.Id, progress: UpdateProgress(), token: _tokenSource.Token); hours = await _manager.GetTimeOnIssue(_issue.Id, progress: UpdateProgress(), token: _tokenSource.Token);
} catch { } }
catch { }
_journalDisplays.Clear();
_journalDisplays.AddRange(await ProcessJournal(_issue.Journals, hours)); _journalDisplays.AddRange(await ProcessJournal(_issue.Journals, hours));
if (!_journalDisplays.Any(x => !x.IsData)) if (!_journalDisplays.Any(x => !x.IsData))
detailsToggleSwitch.IsChecked = true; detailsToggleSwitch.IsChecked = true;
@@ -98,6 +111,19 @@ namespace Blueberry
{ {
_tokenSource.Cancel(); _tokenSource.Cancel();
} }
private async void commentButton_Click(object sender, RoutedEventArgs e)
{
var comment = commentTextBox.Text;
if (string.IsNullOrWhiteSpace(comment))
return;
var isPrivate = privateToggle.IsChecked ?? false;
await _manager.AddComment(_issue.Id, comment, isPrivate);
commentTextBox.Text = "";
await DownloadJournals();
}
} }
public partial class IssueWindow public partial class IssueWindow
@@ -252,6 +278,7 @@ namespace Blueberry
return Application.Current.TryFindResource(resourceKey) as Brush; return Application.Current.TryFindResource(resourceKey) as Brush;
} }
} }
public Visibility LockVisibility => IsPrivate ? Visibility.Visible : Visibility.Hidden;
public SolidColorBrush NameColor => StringToColorConverter.GetColorFromName(User); public SolidColorBrush NameColor => StringToColorConverter.GetColorFromName(User);
} }

View File

@@ -113,8 +113,11 @@
<RowDefinition Height="3*"/> <RowDefinition Height="3*"/>
<RowDefinition Height="2*"/> <RowDefinition Height="2*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Center" FontSize="20" FontFamily="/Resources/Inter.ttf#Inter" <ui:Button Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Center" x:Name="openIssueButton"
Margin="5, 0, 10, 0" Text="{Binding Id}" /> Click="openTicketButton_Click" Margin="5, 0, 10, 0" HorizontalAlignment="Stretch">
<TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Center" FontSize="18" FontFamily="/Resources/Inter.ttf#Inter" Text="{Binding Id}" />
</ui:Button>
<TextBlock Grid.Column="1" Grid.Row="0" Grid.RowSpan="1" VerticalAlignment="Center" FontSize="14" <TextBlock Grid.Column="1" Grid.Row="0" Grid.RowSpan="1" VerticalAlignment="Center" FontSize="14"
Text="{Binding Subject}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Subject}" ToolTipService.InitialShowDelay="500" /> Text="{Binding Subject}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Subject}" ToolTipService.InitialShowDelay="500" />
<TextBlock Grid.Column="1" Grid.Row="1" Grid.RowSpan="1" VerticalAlignment="Center" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" <TextBlock Grid.Column="1" Grid.Row="1" Grid.RowSpan="1" VerticalAlignment="Center" FontSize="10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
@@ -122,13 +125,8 @@
<TextBlock Grid.Column="2" Grid.Row="0" Grid.RowSpan="1" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="12" <TextBlock Grid.Column="2" Grid.Row="0" Grid.RowSpan="1" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="12"
Margin="20, 0, 10, 0" Text="{Binding StatusName}" /> Margin="20, 0, 10, 0" Text="{Binding StatusName}" />
<TextBlock Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="10" <TextBlock Grid.Column="2" Grid.Row="1" Grid.RowSpan="1" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="10"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" Margin="20, 0, 0, 0" Text="{Binding LastUpdate}" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" Margin="20, 0, 10, 0" Text="{Binding LastUpdate}"
ToolTip="{Binding UpdatedOn}" ToolTipService.InitialShowDelay="200" /> ToolTip="{Binding UpdatedOn}" ToolTipService.InitialShowDelay="200" />
<ui:Button x:Name="openTicketButton" Grid.RowSpan="2" Grid.Column="3" Margin="10, 0, 10, 0" Click="openTicketButton_Click">
<ui:Button.Icon>
<ui:SymbolIcon Symbol="Open24" />
</ui:Button.Icon>
</ui:Button>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ui:ListView.ItemTemplate> </ui:ListView.ItemTemplate>
@@ -262,7 +260,7 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ui:Button x:Name="updateButton" Content="Frissítés" Grid.Column="1" Margin="2" Visibility="Hidden" Click="updateButton_Click" /> <ui:Button x:Name="updateButton" Content="Frissítés" FontSize="8" Grid.Column="1" Margin="2" Visibility="Hidden" Click="updateButton_Click" />
<ui:TextBlock x:Name="versionTextBlock" Grid.Column="2" HorizontalAlignment="Right" FontSize="8" Text="0.0.0" Margin="10" /> <ui:TextBlock x:Name="versionTextBlock" Grid.Column="2" HorizontalAlignment="Right" FontSize="8" Text="0.0.0" Margin="10" />
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -1,6 +1,7 @@
using Blueberry; using Blueberry;
using Blueberry.Redmine; using Blueberry.Redmine;
using Blueberry.Redmine.Dto; using Blueberry.Redmine.Dto;
using Microsoft.Extensions.Logging;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -19,16 +20,18 @@ namespace BlueMine
private readonly RedmineSettingsManager _settings; private readonly RedmineSettingsManager _settings;
private readonly RedmineConfig _config; private readonly RedmineConfig _config;
private List<IssueList.Issue> _issues = []; private List<IssueList.Issue> _issues = [];
private readonly ILoggerFactory _loggerFactory;
public ObservableCollection<IssueList.Issue> IssuesList { get; set; } = []; public ObservableCollection<IssueList.Issue> IssuesList { get; set; } = [];
public ObservableCollection<StatusList.IssueStatus> StatusList { get; set; } = []; public ObservableCollection<StatusList.IssueStatus> StatusList { get; set; } = [];
public MainWindow(RedmineManager manager, RedmineSettingsManager settings, RedmineConfig config) public MainWindow(RedmineManager manager, RedmineSettingsManager settings, RedmineConfig config, ILoggerFactory loggerFactory)
{ {
_settings = settings; _settings = settings;
_config = config; _config = config;
_manager = manager; _manager = manager;
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
_loggerFactory = loggerFactory;
} }
private async void WindowLoaded(object sender, RoutedEventArgs e) private async void WindowLoaded(object sender, RoutedEventArgs e)
@@ -368,7 +371,7 @@ namespace BlueMine
private async void hoursButton_Click(object sender, RoutedEventArgs e) private async void hoursButton_Click(object sender, RoutedEventArgs e)
{ {
var hoursWindow = new HoursWindow(_manager, _config); var hoursWindow = new HoursWindow(_manager, _config, _loggerFactory.CreateLogger<HoursWindow>());
hoursWindow.Show(); hoursWindow.Show();
} }

View File

@@ -8,7 +8,7 @@ namespace Blueberry
public static class UpdateManager public static class UpdateManager
{ {
private const string releaseUrl = "https://git.technopunk.space/api/v1/repos/tomi/Blueberry/releases/latest"; private const string releaseUrl = "https://git.technopunk.space/api/v1/repos/tomi/Blueberry/releases/latest";
public const string CurrentVersion = "0.1.8"; public const string CurrentVersion = "0.2.6";
private static readonly string appDir = AppDomain.CurrentDomain.BaseDirectory; private static readonly string appDir = AppDomain.CurrentDomain.BaseDirectory;
private static readonly string zipPath = Path.Combine(appDir, "blueberry_update.zip"); private static readonly string zipPath = Path.Combine(appDir, "blueberry_update.zip");
private static readonly HttpClient client = new(); private static readonly HttpClient client = new();