Skip to content

Commit

Permalink
Merge pull request #4 from gjmwolmarans/syncfusion
Browse files Browse the repository at this point in the history
Syncfusion
  • Loading branch information
gjmwolmarans authored Aug 7, 2024
2 parents ce2b8c8 + 7bab659 commit 7c97758
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 31 deletions.
2 changes: 1 addition & 1 deletion me.shared/Converters/TimeSpanJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TimeSpanJsonConverter : JsonConverter<TimeSpan>
{
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var split = reader.GetString().Split(",")[0].Split(":").Select(s => int.Parse(s))
var split = reader.GetString().Split(".")[0].Split(":").Select(s => int.Parse(s))
.ToArray();
return new TimeSpan(split[0], split[1], split[2], split[3]);
}
Expand Down
118 changes: 91 additions & 27 deletions me/Components/Resource/ResourceList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,76 @@

@if (Resources != null)
{
<SfGrid DataSource=Resources AllowPaging=true AllowSorting=true AllowMultiSorting=true AllowFiltering=true>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>
<SfGrid DataSource="@Resources.AsQueryable()" AllowPaging=true AllowSorting=true AllowMultiSorting=true AllowFiltering=true >
<GridFilterSettings>
<GridFilterColumns>
<GridFilterColumn Field="Provider.Title" Operator="Syncfusion.Blazor.Operator.Contains" Predicate="and" Value="@ProviderTitleValue" />
<GridFilterColumn Field=@nameof(Resource.Title) Operator="Syncfusion.Blazor.Operator.Contains" Predicate="and" Value="@TitleValue" />
<GridFilterColumn Field=@nameof(Resource.Type) Operator="Syncfusion.Blazor.Operator.Contains" Predicate="and" Value="@TypeValue" />
</GridFilterColumns>
</GridFilterSettings>
<GridSortSettings>
<GridSortColumns>
<GridSortColumn Field=@nameof(Resource.Id) Direction="@Syncfusion.Blazor.Grids.SortDirection.Descending" />
</GridSortColumns>
</GridSortSettings>
<GridPageSettings PageSize=50></GridPageSettings>
<GridTemplates>
<RowTemplate>
@{
var resource = (context as Resource)!;
<td colspan="7" style="width: 100%;">
<FluentGrid Style="padding: 0.5rem; width: auto;" Justify="@JustifyContent.FlexStart">
<FluentGridItem xs="4" sm="3" lg="2" Justify="@JustifyContent.Center">
<FluentPersona Initials="@resource.ProviderId" ImageSize="96px"/>
</FluentGridItem>
<FluentGridItem xs="8" sm="9" lg="10">
<FluentStack Orientation="Orientation.Vertical">
<FluentStack Orientation="Orientation.Horizontal">
<h2>@resource.Provider.Title | @resource.Title @if (resource.Url.StartsWith("http")) {

<a href="@resource.Url" target="_blank">
<FluentIcon Value="@(new Icons.Regular.Size48.Link())" />
</a>
}</h2>
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentBadge Appearance="Appearance.Accent">
@resource.Experience.ToString("N2") xp
</FluentBadge>
<FluentBadge Appearance="Appearance.Accent">
@GetLevelString(resource.Level)
</FluentBadge>
<FluentBadge Appearance="Appearance.Accent">
@GetDurationString(resource.Duration)
</FluentBadge>
<FluentBadge Appearance="Appearance.Accent">
@resource.Type
</FluentBadge>
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
@foreach (var resourceTag in resource.ResourceTags)
{
<FluentBadge>
@resourceTag.Tag.Title
</FluentBadge>
}
</FluentStack>
</FluentStack>
</FluentGridItem>
</FluentGrid>
</td>
}
</RowTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field="@nameof(Resource.Id)" IsPrimaryKey=true HeaderText="ID" TextAlign=TextAlign.Right Width=72 />
<GridColumn Field="@nameof(Resource.Title)" HeaderText="Title">
<Template>
@{
var resource = context as Resource;
@if (resource.Url.StartsWith("http"))
{
<a href="@resource.Url" target="_blank">@resource.Title</a>
}
else
{
<span>@resource.Title</span>
}
}
</Template>
</GridColumn>
<GridColumn Field="@nameof(Resource.Id)" AllowFiltering=false IsPrimaryKey=true HeaderText="ID" TextAlign=TextAlign.Right Width=72 />
<GridColumn Field="Provider.Title" HeaderText="Provider" />
<GridColumn Field="@nameof(Resource.Title)" HeaderText="Title" />
<GridColumn Field="@nameof(Resource.Type)" HeaderText="Type" />
<GridColumn Field="@nameof(Resource.Experience)" HeaderText="Experience" Type=ColumnType.Double Format="N2" />
<GridColumn Field="@nameof(Resource.Duration)" HeaderText="Duration">
<Template>
@{
var resource = context as Resource;
<span>@GetDurationString(resource.Duration)</span>
}
</Template>
</GridColumn>
<GridColumn Field="@nameof(Resource.Experience)" AllowFiltering=false HeaderText="Experience" Type=ColumnType.Double Format="N2" />
<GridColumn Field="@nameof(Resource.Level)" AllowFiltering=false HeaderText="Level" Type=ColumnType.Integer />
<GridColumn Field="@nameof(Resource.Duration)" AllowFiltering=false HeaderText="Duration" />
</GridColumns>
</SfGrid>
}
Expand All @@ -47,6 +87,10 @@
[Parameter] public ICollection<Resource> Resources { get; set; } = new List<Resource>();
[Parameter] public EventCallback<ICollection<Resource>> ResourcesChanged { get; set; }

public string ProviderTitleValue = string.Empty;
public string TitleValue = string.Empty;
public string TypeValue = string.Empty;

protected override async Task OnInitializedAsync()
{
Resources = await Data.GetResourcesAsync();
Expand All @@ -67,4 +111,24 @@

return stringBuilder.ToString();
}

private string GetLevelString(int level)
{
if (level == 100)
{
return "Beginner";
}
else if (level == 200)
{
return "Intermediate";
}
else if (level == 300)
{
return "Advanced";
}
else
{
return "Unknown";
}
}
}
2 changes: 1 addition & 1 deletion me/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
</FluentBodyContent>
</FluentStack>
<FluentFooter>
<span@(DateTime.UtcNow.Year) - Gabriël J. M. Wolmarans</span>
<span>Gabriël J. M. Wolmarans - © @(DateTime.UtcNow.Year) All Rights Reserved.</span>
</FluentFooter>
</FluentLayout>
4 changes: 3 additions & 1 deletion me/Pages/AboutMe.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

<h2>Competency Matrix</h2>

<iframe width="1154" height="642" frameborder="0" scrolling="no" src="https://onedrive.live.com/embed?resid=F9480B74B852B3B7%21251307&authkey=%21ALWOWl3ShAlVT70&em=2&wdAllowInteractivity=False&Item=ClusterExperience&wdDownloadButton=True&wdInConfigurator=True&wdInConfigurator=True&edesNext=false&resen=false&ed1JS=false"></iframe>
<div style="overflow: auto">
<iframe width="1154" height="642" frameborder="0" scrolling="no" src="https://onedrive.live.com/embed?resid=F9480B74B852B3B7%21251307&authkey=%21ALWOWl3ShAlVT70&em=2&wdAllowInteractivity=False&Item=ClusterExperience&wdDownloadButton=True&wdInConfigurator=True&wdInConfigurator=True&edesNext=false&resen=false&ed1JS=false"></iframe>
</div>

<ResourceList />

Expand Down
12 changes: 12 additions & 0 deletions me/Services/ExcelFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public async Task<Data> LoadData()
{
Converters = { new TimeSpanJsonConverter() }
});

foreach (var resourceTag in Data.ResourceTags)
{
resourceTag.Resource = Data.Resources.FirstOrDefault(r => r.Id == resourceTag.ResourceId);
resourceTag.Tag = Data.Tags.FirstOrDefault(t => t.Id == resourceTag.TagId);
}

foreach (var resource in Data.Resources)
{
resource.Provider = Data.Providers.FirstOrDefault(p => p.Id == resource.ProviderId);
resource.ResourceTags = Data.ResourceTags.Where(rt => rt.ResourceId == resource.Id).ToList();
}
}

return Data;
Expand Down
2 changes: 1 addition & 1 deletion me/wwwroot/data/data.json

Large diffs are not rendered by default.

0 comments on commit 7c97758

Please sign in to comment.