Rework the UI

Fix Score
Add Kiouze CSS
Rework the tournaments API
This commit is contained in:
2022-03-22 00:14:46 +01:00
parent 3a86fdbdf4
commit 0150402ca6
17 changed files with 890 additions and 280 deletions

View File

@@ -240,6 +240,9 @@
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\css.css" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

View File

@@ -0,0 +1,343 @@
body {
color: #efefef;
background-color: #141415;
}
:root {
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
}
.table {
width: 100%;
margin-bottom: 1rem;
background-color: transparent;
}
.table th,
.table td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #dee2e6;
}
.table tbody + tbody {
border-top: 2px solid #dee2e6;
}
.table .table {
background-color: #fff;
}
.table-sm th,
.table-sm td {
padding: 0.3rem;
}
.table-bordered {
border: 1px solid #dee2e6;
}
.table-bordered th,
.table-bordered td {
border: 1px solid #dee2e6;
}
.table-bordered thead th,
.table-bordered thead td {
border-bottom-width: 2px;
}
.table-borderless th,
.table-borderless td,
.table-borderless thead th,
.table-borderless tbody + tbody {
border: 0;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.05);
}
.table-hover tbody tr:hover {
background-color: rgba(0, 0, 0, 0.075);
}
.table-primary,
.table-primary > th,
.table-primary > td {
background-color: #b8daff;
}
.table-hover .table-primary:hover {
background-color: #9fcdff;
}
.table-hover .table-primary:hover > td,
.table-hover .table-primary:hover > th {
background-color: #9fcdff;
}
.table-secondary,
.table-secondary > th,
.table-secondary > td {
background-color: #d6d8db;
}
.table-hover .table-secondary:hover {
background-color: #c8cbcf;
}
.table-hover .table-secondary:hover > td,
.table-hover .table-secondary:hover > th {
background-color: #c8cbcf;
}
.table-success,
.table-success > th,
.table-success > td {
background-color: #c3e6cb;
}
.table-hover .table-success:hover {
background-color: #b1dfbb;
}
.table-hover .table-success:hover > td,
.table-hover .table-success:hover > th {
background-color: #b1dfbb;
}
.table-info,
.table-info > th,
.table-info > td {
background-color: #bee5eb;
}
.table-hover .table-info:hover {
background-color: #abdde5;
}
.table-hover .table-info:hover > td,
.table-hover .table-info:hover > th {
background-color: #abdde5;
}
.table-warning,
.table-warning > th,
.table-warning > td {
background-color: #ffeeba;
}
.table-hover .table-warning:hover {
background-color: #ffe8a1;
}
.table-hover .table-warning:hover > td,
.table-hover .table-warning:hover > th {
background-color: #ffe8a1;
}
.table-danger,
.table-danger > th,
.table-danger > td {
background-color: #f5c6cb;
}
.table-hover .table-danger:hover {
background-color: #f1b0b7;
}
.table-hover .table-danger:hover > td,
.table-hover .table-danger:hover > th {
background-color: #f1b0b7;
}
.table-light,
.table-light > th,
.table-light > td {
background-color: #fdfdfe;
}
.table-hover .table-light:hover {
background-color: #ececf6;
}
.table-hover .table-light:hover > td,
.table-hover .table-light:hover > th {
background-color: #ececf6;
}
.table-dark,
.table-dark > th,
.table-dark > td {
background-color: #c6c8ca;
}
.table-hover .table-dark:hover {
background-color: #b9bbbe;
}
.table-hover .table-dark:hover > td,
.table-hover .table-dark:hover > th {
background-color: #b9bbbe;
}
.table-active,
.table-active > th,
.table-active > td {
background-color: rgba(0, 0, 0, 0.075);
}
.table-hover .table-active:hover {
background-color: rgba(0, 0, 0, 0.075);
}
.table-hover .table-active:hover > td,
.table-hover .table-active:hover > th {
background-color: rgba(0, 0, 0, 0.075);
}
.table .thead-dark th {
color: #fff;
background-color: #212529;
border-color: #32383e;
}
.table .thead-light th {
color: #495057;
background-color: #e9ecef;
border-color: #dee2e6;
}
.table-dark {
color: #fff;
background-color: #212529;
}
.table-dark th,
.table-dark td,
.table-dark thead th {
border-color: #32383e;
}
.table-dark.table-bordered {
border: 0;
}
.table-dark.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(255, 255, 255, 0.05);
}
.table-dark.table-hover tbody tr:hover {
background-color: rgba(255, 255, 255, 0.075);
}
@media (max-width: 575.98px) {
.table-responsive-sm {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-sm > .table-bordered {
border: 0;
}
}
@media (max-width: 767.98px) {
.table-responsive-md {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-md > .table-bordered {
border: 0;
}
}
@media (max-width: 991.98px) {
.table-responsive-lg {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-lg > .table-bordered {
border: 0;
}
}
@media (max-width: 1199.98px) {
.table-responsive-xl {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-xl > .table-bordered {
border: 0;
}
}
.table-responsive {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive > .table-bordered {
border: 0;
}
.table {
border-collapse: collapse !important;
}
.table td,
.table th {
/*background-color: #fff !important;*/
}
.table-bordered th,
.table-bordered td {
border: 1px solid #dee2e6 !important;
}
.table-dark {
color: #fff;
background-color: #212529
}
.table-dark th,
.table-dark td,
.table-dark thead th,
.table-dark tbody + tbody {
border-color: #dee2e6;
}
.table .thead-dark th {
color: inherit;
border-color: #dee2e6;
}

View File

@@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Controls;
@@ -26,12 +27,14 @@ namespace LaDOSE.DesktopApp.ViewModels
#region Properties
private string css = "strong { font-weight: 700;} " +
"a { color: #ff9024;}"+
"body { color: #efefef;background-color: #141415; }" +
""+
"a:hover, .entry-meta span a:hover, .comments-link a:hover, body.coldisplay2 #front-columns a:active {color: #cb5920;}"+
"tr td { border: 1px dashed #3D3D3D;} ";
private string css = string.Empty;
//"strong { font-weight: 700;} ". +
// "a { color: #ff9024;}"+
// "body { color: #efefef;background-color: #141415; }" +
// ""+
// "a:hover, .entry-meta span a:hover, .comments-link a:hover, body.coldisplay2 #front-columns a:active {color: #cb5920;}"+
// "tr td { border: 1px dashed #3D3D3D;} ";
private String _selectRegex;
public String SelectRegex
@@ -44,6 +47,17 @@ namespace LaDOSE.DesktopApp.ViewModels
}
}
private String _selectEventRegex;
public String SelectEventRegex
{
get { return _selectEventRegex; }
set
{
_selectEventRegex = value;
NotifyOfPropertyChange(() => SelectEventRegex);
}
}
private string _slug;
public String Slug
{
@@ -108,6 +122,8 @@ namespace LaDOSE.DesktopApp.ViewModels
private TournamentsResultDTO _results;
public List<TournamentDTO> Tournaments { get; set; }
public List<EventDTO> Events { get; set; }
public TournamentsResultDTO Results
{
get => _results;
@@ -118,6 +134,18 @@ namespace LaDOSE.DesktopApp.ViewModels
}
}
private ObservableCollection<EventDTO> _selectedEvents;
public ObservableCollection<EventDTO> SelectedEvents
{
get { return _selectedEvents; }
set
{
_selectedEvents = value;
NotifyOfPropertyChange(() => SelectedEvents);
}
}
private ObservableCollection<TournamentDTO> _selectedTournaments;
public ObservableCollection<TournamentDTO> SelectedTournaments
@@ -178,18 +206,28 @@ namespace LaDOSE.DesktopApp.ViewModels
{
this.RestService = restService;
_selectedTournaments = new ObservableCollection<TournamentDTO>();
_selectedEvents = new ObservableCollection<EventDTO>();
Tournaments = new List<TournamentDTO>();
Events = new List<EventDTO>();
}
protected override void OnInitialize()
{
var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LaDOSE.DesktopApp.Resources.css.css");
using (var sr = new StreamReader(manifestResourceStream))
{
this.css = sr.ReadToEnd();
}
this.To = DateTime.Now;
this.From = DateTime.Now.AddMonths(-1);
this.SelectRegex = "Ranking";
this.Slug = "ranking-1001";
LoadTournaments();
LoadEvents();
base.OnInitialize();
}
@@ -205,6 +243,18 @@ namespace LaDOSE.DesktopApp.ViewModels
});
}
public void LoadEvents()
{
WpfUtil.Await(() =>
{
var eventsDtos = this.RestService
.GetAllEvents().ToList();
this.Events = eventsDtos;
NotifyOfPropertyChange("Events");
});
}
public DataTable GridDataTable
{
get => _gridDataTable;
@@ -219,7 +269,7 @@ namespace LaDOSE.DesktopApp.ViewModels
{
WpfUtil.Await(() =>
{
var tournamentsIds = SelectedTournaments.Select(e => e.ChallongeId).ToList();
var tournamentsIds = SelectedEvents.Select(e => e.Id).ToList();
var resultsDto = this.RestService.GetResults(tournamentsIds);
this.Results = resultsDto;
ComputeDataGrid();
@@ -231,12 +281,30 @@ namespace LaDOSE.DesktopApp.ViewModels
WpfUtil.Await(() =>
{
var resultsDto = this.RestService.GetSmashResults(Slug);
this.Results = resultsDto;
ComputeDataGrid();
ComputeHtml();
var resultsDto = this.RestService.ParseSmash(Slug);
if (!resultsDto)
{
MessageBox.Show("Fail");
}
});
}
public void GetChallonge()
{
WpfUtil.Await(() =>
{
var ids = SelectedTournaments.Select(e => e.ChallongeId).ToList();
var resultsDto = this.RestService.ParseChallonge(ids);
if (!resultsDto)
{
MessageBox.Show("Fail");
}
});
}
public void UpdateEvent()
{
LoadEvents();
}
public void SelectYear()
{
@@ -257,6 +325,13 @@ namespace LaDOSE.DesktopApp.ViewModels
if (selectedTournaments.Count > 0)
selectedTournaments.ForEach(e => this.SelectedTournaments.AddUI(e));
}
public void SelectEvent()
{
var selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList();
this.SelectedEvents.Clear();
if (selectedEvents.Count > 0)
selectedEvents.ForEach(e => this.SelectedEvents.AddUI(e));
}
//This could be simplified the Dictionary was for a previous usage, but i m too lazy to rewrite it.
private void ComputeDataGrid()
{
@@ -344,7 +419,11 @@ namespace LaDOSE.DesktopApp.ViewModels
sb.Append("<table class=\"table table-responsive-md table-dark table-striped mt-lg-4 mt-3\">");
int columns = 0;
foreach (var game in Results.Games)
var distinct = Results.Results.Select(e => e.GameId).Distinct();
var gamePlayed = Results.Games.Where(e=> distinct.Contains(e.Id));
foreach (var game in gamePlayed)
{
List<ResultDTO> enumerable = Results.Results.Where(r => r.GameId == game.Id).ToList();
List<string> top3 = enumerable.OrderBy(e => e.Rank).Take(3).Select(e => e.Player).ToList();
@@ -358,7 +437,15 @@ namespace LaDOSE.DesktopApp.ViewModels
sb.Append("<tr>");
}
columns++;
sb.Append("<td colspan=\"1\" width=\"50%\">" +
var span = 1;
if (columns == gamePlayed.Count())
{
if (columns % 2 != 0)
{
span = 2;
}
}
sb.Append($"<td colspan=\"{span}\" width=\"50%\">" +
"<span style=\"color: #ff0000;\">" +
$"<strong>{game.LongName} ({Results.Results.Count(e => e.GameId == game.Id)} participants) :</strong>" +
"</span>");
@@ -366,7 +453,11 @@ namespace LaDOSE.DesktopApp.ViewModels
if (top3.Count >= 3)
{
sb.AppendLine($"<br> 1/ {top3[0]}<br> 2/ {top3[1]}<br> 3/ {top3[2]} <br>");
sb.AppendLine($"<a href=\"https://challonge.com/fr/{enumerable.First().TournamentUrl}\" target=\"_blank\">https://challonge.com/fr/{enumerable.First().TournamentUrl}</a></p></td>");
//<a href=\"https://challonge.com/fr/{enumerable.First().TournamentUrl}\" target=\"_blank\">https://challonge.com/fr/{enumerable.First().TournamentUrl}</a>
var url = enumerable.FirstOrDefault().TournamentUrl;
url = url.Replace(" ", "-");
url = url.Replace(".", "-");
sb.AppendLine($"<a href=\"https://smash.gg/tournament/ranking-1002/event/{url}\" target=\"_blank\">Voir le Bracket</p></td>");
}

View File

@@ -14,71 +14,136 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid Row="2" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="2*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Label> Date : </Label>
<StackPanel Orientation="Horizontal" Width="210">
<DatePicker SelectedDate="{Binding From}" Width="100" BorderBrush="{x:Null}">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox" Foreground="White"
<Grid Row="0" Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Row="0" Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,5">
<Label>Date :</Label>
<StackPanel Orientation="Horizontal" Width="210">
<DatePicker SelectedDate="{Binding From}" Width="100" BorderBrush="{x:Null}">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox" Foreground="White"
Text="{Binding Path=SelectedDate, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}},StringFormat=d}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
<DatePicker SelectedDate="{Binding To}" Width="100" Margin="5,0,5,0" BorderBrush="{x:Null}">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox" Foreground="White"
<DatePicker SelectedDate="{Binding To}" Width="100" Margin="5,0,5,0" BorderBrush="{x:Null}">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox" Foreground="White"
Text="{Binding Path=SelectedDate, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}},StringFormat=d}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
</StackPanel>
<Label>Usefull :</Label>
<Button Padding="5,0,5,0" x:Name="SelectMonth">Month</Button>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectYear">Year</Button>
</StackPanel>
<Button Grid.Row="1" x:Name="LoadTournaments">Update</Button>
<ListView Grid.Row="2" ItemsSource="{Binding Tournaments}" x:Name="TournamentList" Margin="0,0,0,5"
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
</StackPanel>
<Label>Usefull :</Label>
<Button Padding="5,0,5,0" x:Name="SelectMonth">Month</Button>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectYear">Year</Button>
</StackPanel>
<Button Grid.Row="1" x:Name="LoadTournaments">Update</Button>
<ListView Grid.Row="2" ItemsSource="{Binding Tournaments}" x:Name="TournamentList" Margin="0,0,0,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name"
behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding SelectedTournaments}"
SelectionMode="Multiple">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<DockPanel Grid.Row="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectRegexp">Select</Button>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="GetChallonge">Import</Button>
</DockPanel>
</Grid>
<Grid Row="0" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Margin="0,0,0,6">
<Label> Smash Slug :</Label>
<TextBox Width="200" Text="{Binding Slug}"></TextBox>
<Button Margin="5,0,5,0" x:Name="GetSmash" >Import Smash Event</Button>
</StackPanel>
<Button Grid.Row="1" x:Name="UpdateEvent" >Update Event</Button>
<ListView Grid.Row="2" ItemsSource="{Binding Events}" Margin="0,0,0,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name"
behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding SelectedEvents}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<DockPanel Grid.Row="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectEventRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectEvent">Select</Button>
</DockPanel>
</Grid>
</Grid>
</ListView>
<Grid Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -93,13 +158,13 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0" Grid.ColumnSpan="3" Dock="Left">
<!--<DockPanel Grid.Row="0" Grid.ColumnSpan="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectRegexp">Select</Button>
<Button x:Name="Select" >Get Tournaments Result</Button>
</DockPanel>
</DockPanel>-->
<Button x:Name="Select" Grid.ColumnSpan="3" >Get Tournaments Result</Button>
<StackPanel Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
@@ -165,20 +230,16 @@
</DockPanel>
</TabItem>
<TabItem Header="HTML">
<DockPanel>
<Button x:Name="CopyHtml" DockPanel.Dock="Top"> Copy HTML to clipboard </Button>
<cefSharp:ChromiumWebBrowser behaviors:HtmlBehavior.Html="{Binding Html}" />
<DockPanel>
<Button x:Name="CopyHtml" DockPanel.Dock="Top">Copy HTML to clipboard</Button>
<cefSharp:ChromiumWebBrowser behaviors:HtmlBehavior.Html="{Binding Html}" />
</DockPanel>
</TabItem>
</TabControl>
<Button Grid.Row="4" Grid.ColumnSpan="3" x:Name="Export">Export</Button>
</Grid>
<StackPanel Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock> Slug :</TextBlock>
<TextBox Width="200" Text="{Binding Slug}"></TextBox>
<Button x:Name="GetSmash" >Get Smash Tournaments Result</Button>
</StackPanel>
</Grid>
</UserControl>