Skip to content

Commit

Permalink
Merge pull request #4 from madebygps/dotnet-8-upgrade
Browse files Browse the repository at this point in the history
Upgrade to .NET 8
  • Loading branch information
madebygps authored Jan 12, 2024
2 parents dffcc68 + 1319bf5 commit 6296307
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
/DefineTheCloud.csproj.user
10 changes: 5 additions & 5 deletions Client/BlazorBasic.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="6.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="6.12.0" />
</ItemGroup>

</Project>
46 changes: 31 additions & 15 deletions Client/Pages/Definitions.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
@using System.Net


@if (definitions == null)
<MudContainer Class="mt-16">

<MudText Typo="Typo.h3" Align="Align.Center" GutterBottom="true">definition(s) with <i>@SearchTerm.ToLower()</i> in them</MudText>

@if (definitions == null && !definitionNotFound )
{
<MudContainer Class="mt-16">

<MudProgressLinear Color="MudBlazor.Color.Primary" Indeterminate="true" Class="my-4" />
</MudContainer>

}
else
else if (definitions != null )
{
<MudContainer Class="mt-16">

<MudText Typo="Typo.h3" Align="Align.Center" GutterBottom="true">definition(s) with <i>@SearchTerm.ToLower()</i> in them</MudText>


<MudGrid Class="mt-8">
@foreach (var definition in definitions)
Expand All @@ -30,32 +32,46 @@ else
</MudItem>
}
</MudGrid>
</MudContainer>

}

</MudContainer>
@code {

[Parameter]
public string? SearchTerm { get; set; }
private WordDefinition[] definitions;

// Add this to your class
private bool definitionNotFound = false;
protected override async Task OnInitializedAsync()
{
try
{
HttpResponseMessage response = await Http.GetAsync($"https://clouddictionary.azurewebsites.net/api/GetDefinitionsBySearch?code=n4N4kQ2KJfeZqgEpyXz8jUgBxIPo_LytEg46KPacIB0XAzFuu3gzlQ==&searchTerm={SearchTerm}");

Root dataDefinitions = await
Http.GetFromJsonAsync<Root>($"https://clouddictionary.azurewebsites.net/api/GetDefinitionsBySearch?code=n4N4kQ2KJfeZqgEpyXz8jUgBxIPo_LytEg46KPacIB0XAzFuu3gzlQ==&searchTerm={SearchTerm}")
?? new Root { };

definitions = dataDefinitions.Data.ToArray();

if (response.IsSuccessStatusCode)
{
Root dataDefinitions = await response.Content.ReadFromJsonAsync<Root>() ?? new Root { };
definitions = dataDefinitions.Data.ToArray();
}
else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
var errorResponse = await response.Content.ReadFromJsonAsync<ErrorResponse>();
Console.WriteLine(errorResponse.Error);
definitionNotFound = true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

public class ErrorResponse
{
public string Error { get; set; }
}




Expand Down
12 changes: 6 additions & 6 deletions Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
</MudTooltip>
<MudTooltip Text="Submit your own definition">
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="MudBlazor.Color.Inherit"
Link="https://github.com/learntocloud/cloud-dictionary/issues/new/choose" Target="_blank" />
Href="https://github.com/learntocloud/cloud-dictionary/issues/new/choose" Target="_blank" />
</MudTooltip>

</MudHidden>
<MudHidden Breakpoint="MudBlazor.Breakpoint.SmAndDown" Invert="true">
<MudMenu Icon="@Icons.Filled.Settings" Color="MudBlazor.Color.Inherit" Dense="true"
Direction="MudBlazor.Direction.Right" OffsetY="true">
<MudMenu Icon="@Icons.Material.Filled.Settings" Color="MudBlazor.Color.Inherit" Dense="true"
TransformOrigin="MudBlazor.Origin.CenterRight" Origin.OffsetY="true">
<div class="px-2">
<MudIconButton Icon="@Icons.Material.Filled.Brightness4" Color="MudBlazor.Color.Inherit"
OnClick="@((e) => DarkMode())" />
Expand All @@ -49,7 +49,7 @@
</MudContainer>

<MudScrollToTop TopOffset="400">
<MudFab Icon="@Icons.Material.Filled.KeyboardArrowUp" Color="MudBlazor.Color.Primary" />
<MudFab StartIcon="@Icons.Material.Filled.KeyboardArrowUp" Color="MudBlazor.Color.Primary" />
</MudScrollToTop>
</MudMainContent>

Expand Down Expand Up @@ -88,7 +88,7 @@
private readonly MudTheme _defaultTheme =
new MudTheme()
{
Palette = new Palette()
Palette = new PaletteLight()
{
Black = "#272c34",
AppbarBackground = Colors.Blue.Default,
Expand All @@ -97,7 +97,7 @@
private readonly MudTheme _darkTheme =
new MudTheme()
{
Palette = new Palette()
Palette = new PaletteDark()
{
Black = "#27272f",
Background = Colors.Grey.Darken4,
Expand Down

0 comments on commit 6296307

Please sign in to comment.