Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ager.Web into develop
  • Loading branch information
SSchulze1989 committed Feb 27, 2024
2 parents e48c6b8 + 468eb42 commit 6fd1e60
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
Label="@Label"
HelperText="@HelperText"
Variant="Variant"
AnchorOrigin="Origin.BottomCenter">
AnchorOrigin="Origin.BottomCenter"
ToStringFunc="ToStringFunc">
@if (ItemTemplate is not null)
{
@foreach (var item in Items)
Expand Down
6 changes: 6 additions & 0 deletions src/iRLeagueManager.Web/Components/DisplayMarkdown.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
@inject MarkdownPipeline Pipeline
@inject HtmlSanitizer Sanitizer

<div class="@Class" style="@Style">
@((MarkupString)RenderBody())
</div>

@code {
[Parameter, EditorRequired]
public string Text { get; set; } = string.Empty;
[Parameter]
public string Class { get; set; } = string.Empty;
[Parameter]
public string Style { get; set; } = string.Empty;

private string RenderBody()
{
Expand Down
30 changes: 14 additions & 16 deletions src/iRLeagueManager.Web/Components/InputMarkdown.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
@inherits InputBase<string>

<div class="@CssClass" @attributes=AdditionalAttributes>
<nav>
<div class="nav nav-tabs" id="nav-tab-@uuid" role="tablist">
<button class="nav-link active" data-bs-toggle="tab" id="nav-edit-tab-@uuid" data-bs-target="#nav-edit-@uuid" type="button" role="tab" aria-controls="nav-edit-@uuid" aria-selected="true">Edit</button>
<button class="nav-link" data-bs-toggle="tab" id="nav-preview-tab-@uuid" data-bs-target="#nav-preview-@uuid" type="button" role="tab" aria-controls="nav-preview-@uuid" aria-selected="false">Preview</button>
</div>
</nav>
<div class="tab-content" id="nav-content-@uuid">
<div class="tab-pane tab-pane-keep-space show active" id="nav-edit-@uuid" role="tabpanel" aria-labelledby="nav-edit-tab-@uuid">
<textarea @bind=CurrentValueAsString class="form-control" style="height: 400px"/>
</div>
<div class="tab-pane" id="nav-preview-@uuid" role="tabpanel" aria-labelledby="nav-preview-tab-@uuid">
<div class="form-control" style="position: absolute; top: 0; left: 0; height: 100%;">
<DisplayMarkdown Text=@Value />
</div>
</div>
</div>
<MudTabs>
<MudTabPanel Text="Edit">
<MudTextField @bind-Value="CurrentValueAsString"
Variant="Variant.Outlined"
Lines="25"
FullWidth="true"
Style="font-family: 'Consolas', 'Lucida Console'"/>
</MudTabPanel>
<MudTabPanel Text="Preview">
<MudField Variant="Variant.Outlined">
<DisplayMarkdown Text=@Value Style="width: 100%; overflow: auto;" />
</MudField>
</MudTabPanel>
</MudTabs>
</div>

@code {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@namespace iRLeagueManager.Web.Components
@using Ganss.Xss
@using iRLeagueManager.Web.Components
@using iRLeagueApiCore.Common.Models
@inherits PromptDialog<string>
@inject HtmlSanitizer Sanitizer

<MudDialog>
<DialogContent>
<EditForm Model=Value>
<InputMarkdown @bind-Value="Value" />
</EditForm>
</DialogContent>
<DialogActions>
<PromptDialogButtons OkText="Ok" OkClick="Submit" CancelText="Cancel" CancelClick="Cancel" />
</DialogActions>
</MudDialog>

@code {
protected override async Task Submit()
{
// sanitize input before saving
Value = Sanitizer.Sanitize(Value);
await base.Submit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
</SettingsSection>
}
}
@{
var sourceHelperText = Config.SourceResultConfig != null ? $"Reuse results calculated in {Config.SourceResultConfig.ChampionshipName} - {Config.SourceResultConfig.Name}" : "Use uploaded result data";
}
<SettingsSelectPrompt Label="Source"
HelperText="@sourceHelperText"
@bind-Value="Config.SourceResultConfig"
Items="Config.AvailableResultConfigs"
ToStringFunc="@(config => config != null ? $"{config.ChampionshipName} - {config.Name}" : "Raw Result")">
<ItemTemplate Context="sourceConfig">
@sourceConfig?.ChampionshipName - @sourceConfig?.Name
</ItemTemplate>
</SettingsSelectPrompt>
</SettingsTopSection>

<SettingsTopSection Header="Sessions">
Expand Down Expand Up @@ -64,8 +76,8 @@
{
<SettingsItem Text="Delete Point Configuration"
Color="Color.Error"
Icon="@Icons.Material.Outlined.Delete"
OnClick="DeleteConfigClick"/>
Icon="@Icons.Material.Outlined.Delete"
OnClick="DeleteConfigClick" />
}
</SettingsTopSection>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
<label class="mud-input-label mud-input-label-text" style="font-size: 0.75em">@Label</label>
}
<MudText Color="Color">
<MudText Color="Color" Style="width: 100%">
@if (ChildContent is null)
{
@Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@inject IDialogService DialogService

<SettingsItem Class="@Class"
Label="@Label"
Text="@ValueString"
HelperText="@HelperText"
ChildContent="ChildContent!"
Expand Down Expand Up @@ -39,12 +40,13 @@
{ x => x.HelperText, HelperText },
{ x => x.Items, Items },
{ x => x.ItemTemplate, ItemTemplate },
{ x => x.ToStringFunc, ToStringFunc },
};

var options = new DialogOptions()
{
NoHeader = string.IsNullOrEmpty(DialogHeader),
};
{
NoHeader = string.IsNullOrEmpty(DialogHeader),
};

var result = await DialogService.Show<SelectPromptDialog<T>>(DialogHeader, parameters: parameters, options: options).Result;
if (!result.Canceled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
await ChampSeason.LoadResultConfigs(CancellationToken);
}
SelectedResultConfig = ChampSeason.ResultConfigViewModels.FirstOrDefault(x => x.ResultConfigId == ResultConfigId) ?? SelectedResultConfig;
if (SelectedResultConfig is not null)
{
await SelectedResultConfig.LoadAvailableResultConfigs(CancellationToken);
}
else if (ChampSeason.ResultConfigViewModels.Any())
{
await ChampSeason.ResultConfigViewModels.First().LoadAvailableResultConfigs(CancellationToken);
}
LeagueMembers = (await MemberService.GetLeagueMembers(CancellationToken)).Content ?? Enumerable.Empty<MemberModel>();
Teams = (await MemberService.GetLeagueTeams(CancellationToken)).Content ?? Enumerable.Empty<TeamModel>();
UpdateBreadCrumb();
Expand Down
33 changes: 9 additions & 24 deletions src/iRLeagueManager.Web/Pages/Settings/LeagueSettings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@
<SettingsTopSection Header="General">
<SettingsTextPrompt Label="Display Name"
@bind-Value="League.NameFull" />
<MudListItem>
<MudField Label="Description"
OnAdornmentClick="@(() => EditDescriptionClick(League))"
Variant="Variant.Text"
DisableUnderLine="true">
<div style="overflow-x: clip; overflow-y: auto; min-height: 4em; max-height: 12em;">
@((MarkupString)RenderDescriptionPreview(League.Description))
</div>
</MudField>
</MudListItem>
<SettingsPromptItem Label="Description"
HelperText="Enter a description displayed on your league home page. Supports Markdown"
T="string"
TDialog="LeagueDescriptionDialog"
@bind-Value="League.Description">
<MudElement HtmlTag="div" Style="overflow-x: clip; overflow-y: auto; min-height: 4em; max-height: 20em; width: 100%;">
@((MarkupString)RenderDescriptionPreview(League.Description))
</MudElement>
</SettingsPromptItem>
</SettingsTopSection>

<SettingsTopSection Header="Seasons">
Expand Down Expand Up @@ -162,20 +161,6 @@
}
}

private async Task EditDescriptionClick(LeagueViewModel league)
{
var parameters = new DialogParameters<EditLeagueDescriptionDialog>()
{
{x => x.Model, league.CopyModel()},
{x => x.OnSubmit, (vm, cancellation) => vm.SaveChangesAsync(cancellation)},
};
var result = await DialogService.Show<EditLeagueDescriptionDialog>("Edit description", parameters).Result;
if (result.Canceled == false && result.Data is LeagueModel model)
{
league.SetModel(model);
}
}

private string RenderDescriptionPreview(string markdown)
{
return Markdig.Markdown.ToHtml(markdown, MarkdownPipeline);
Expand Down
16 changes: 7 additions & 9 deletions src/iRLeagueManager.Web/ViewModels/ResultConfigViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using iRLeagueApiCore.Common.Enums;
using iRLeagueApiCore.Common.Models;
using iRLeagueApiCore.Common.Models;
using iRLeagueManager.Web.Data;
using iRLeagueManager.Web.Extensions;
using Microsoft.Extensions.Configuration.EnvironmentVariables;
using MudBlazor.Charts;
using System.Runtime.CompilerServices;

namespace iRLeagueManager.Web.ViewModels;

Expand Down Expand Up @@ -36,7 +32,7 @@ public ResultConfigViewModel(ILoggerFactory loggerFactory, LeagueApiService apiS
public long SourceResultConfigId
{
get => SourceResultConfig?.ResultConfigId ?? 0;
set => SetP(SourceResultConfig, value => SourceResultConfig = value, GetConfigInfoModel(AvailableResultConfigs.FirstOrDefault(x => x.ResultConfigId == value)));
set => SetP(SourceResultConfig, value => SourceResultConfig = value, AvailableResultConfigs.FirstOrDefault(x => x.ResultConfigId == value));
}
public bool CalculateCombinedResult
{
Expand Down Expand Up @@ -74,8 +70,8 @@ public IEnumerable<FilterConditionModel> FiltersForPoints
private ObservableCollection<ResultFilterViewModel> filtersForResult;
public ObservableCollection<ResultFilterViewModel> FiltersForResult { get => filtersForResult; set => Set(ref filtersForResult, value); }

private ObservableCollection<ResultConfigModel> availableResultConfigs;
public ObservableCollection<ResultConfigModel> AvailableResultConfigs { get => availableResultConfigs; set => Set(ref availableResultConfigs, value); }
private ObservableCollection<ResultConfigInfoModel> availableResultConfigs;
public ObservableCollection<ResultConfigInfoModel> AvailableResultConfigs { get => availableResultConfigs; set => Set(ref availableResultConfigs, value); }

private ObservableCollection<MemberModel> leagueMembers;
public ObservableCollection<MemberModel> LeagueMembers { get => leagueMembers; set => Set(ref leagueMembers, value); }
Expand Down Expand Up @@ -166,7 +162,7 @@ public async Task<StatusResult> LoadAvailableResultConfigs(CancellationToken can
var result = await request;
if (result.Success && result.Content is not null)
{
AvailableResultConfigs = new(result.Content);
AvailableResultConfigs = new(result.Content.Select(GetConfigInfoModel).NotNull());
}

return result.ToStatusResult();
Expand Down Expand Up @@ -281,6 +277,8 @@ private void UpdateModelScorings()

return new()
{
ChampionshipName = model.ChampionshipName,
ChampSeasonId = model.ChampSeasonId,
Name = model.Name,
DisplayName = model.DisplayName,
LeagueId = model.LeagueId,
Expand Down
4 changes: 2 additions & 2 deletions src/iRLeagueManager.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
}
},
"AllowedHosts": "*",
"APIServer": "http://localhost:5000",
//"APIServer": "https://irleaguemanager.net/api/",
//"APIServer": "http://localhost:5000",
"APIServer": "https://irleaguemanager.net/api/",
"DefaultUser": "testuser",
"DefaultPassword": "TestPass123!"
}

0 comments on commit 6fd1e60

Please sign in to comment.