Skip to content

Commit

Permalink
Merge pull request #35 from mule/development
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
mule authored Jul 28, 2023
2 parents 4dc7d37 + 4a958fb commit 565bc16
Show file tree
Hide file tree
Showing 24 changed files with 633 additions and 26 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ yarn-error.log*
*.userrules

# Build results
./dist
dist

#Azurite files
__azurite_db_*
78 changes: 78 additions & 0 deletions ChatGptBlazorApp/ChatGptBlazorApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,82 @@
<PackageReference Include="System.IO.Abstractions" Version="19.2.29"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resources\Resource.fi-Fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.fi-Fi.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Shared\MainLayout.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MainLayout.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\en\Resource.en-US.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.en-US.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Shared\MainLayout.fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MainLayout.fi.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Pages\Chat.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Chat.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Pages\Chat.fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Chat.fi.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Components\ChatSessionsList.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ChatSessionsList.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Components\ChatSessionsList.fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ChatSessionsList.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Pages\UserProfile.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>UserProfile.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Pages\UserProfile.fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>UserProfile.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Components\CultureSelector.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CultureSelector.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Components\CultureSelector.fi.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CultureSelector.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Update="Resources\Resource.fi-Fi.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resource.fi-Fi.resx</DependentUpon>
</Compile>
<Compile Update="Resources\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Shared\MainLayout.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>MainLayout.resx</DependentUpon>
</Compile>
<Compile Update="Resources\en\Resource.en-US.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resource.en-US.resx</DependentUpon>
</Compile>
</ItemGroup>

</Project>
30 changes: 30 additions & 0 deletions ChatGptBlazorApp/Components/ChatSessionsList.fi.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="NewChat" xml:space="preserve">
<value>Uusi keskustelu</value>
</data>
</root>
3 changes: 2 additions & 1 deletion ChatGptBlazorApp/Components/ChatSessionsList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
@inject IChatSessionRepository ChatSessionRepository
@inject NavigationManager NavigationManager
@inject IToastService ToastService
@inject IStringLocalizer<ChatSessionsList> Loc

<div class="sidebar">
<div class="nav-scrollable">
<div class="nav-item mb-2">
<button class="btn btn-primary" @onclick="NavigateToNewChat">New chat</button>
<button class="btn btn-primary" @onclick="NavigateToNewChat">@Loc["NewChat"]</button>
</div>
@{
var topicsGroupedByDate = SessionTopics.GroupBy(x => x.Created.Date);
Expand Down
30 changes: 30 additions & 0 deletions ChatGptBlazorApp/Components/ChatSessionsList.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="NewChat" xml:space="preserve">
<value>New chat</value>
</data>
</root>
30 changes: 30 additions & 0 deletions ChatGptBlazorApp/Components/CultureSelector.fi.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="lblLanguage" xml:space="preserve">
<value>Valitse kieli</value>
</data>
</root>
51 changes: 51 additions & 0 deletions ChatGptBlazorApp/Components/CultureSelector.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@using System.Globalization
@inject NavigationManager Navigation
@inject IStringLocalizer<CultureSelector> Loc

<p>
<label>
@Loc["lblLanguage"]
<select @bind="Culture">
@foreach (var culture in supportedCultures)
{
<option value="@culture">@culture.DisplayName</option>
}
</select>
</label>
</p>

@code
{
[Parameter]
public string Id { get; set; }

private CultureInfo[] supportedCultures =
{
new CultureInfo("en-US"),
new CultureInfo("fi-FI")
};

protected override void OnInitialized()
{
Culture = CultureInfo.CurrentCulture;
}

private CultureInfo Culture
{
get => CultureInfo.CurrentCulture;
set
{
if (CultureInfo.CurrentCulture != value)
{
var uri = new Uri(Navigation.Uri)
.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
var cultureEscaped = Uri.EscapeDataString(value.Name);
var uriEscaped = Uri.EscapeDataString(uri);

Navigation.NavigateTo(
$"Culture/Set?culture={cultureEscaped}&redirectUri={uriEscaped}",
true);
}
}
}
}
30 changes: 30 additions & 0 deletions ChatGptBlazorApp/Components/CultureSelector.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="lblLanguage" xml:space="preserve">
<value>Choose locale</value>
</data>
</root>
19 changes: 19 additions & 0 deletions ChatGptBlazorApp/Controllers/CultureController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;

namespace ChatGptBlazorApp.Controllers;

[Route("[controller]/[action]")]
public class CultureController : Controller
{
public IActionResult Set(string culture, string redirectUri)
{
if (culture != null)
HttpContext.Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(
new RequestCulture(culture, culture)));

return LocalRedirect(redirectUri);
}
}
37 changes: 37 additions & 0 deletions ChatGptBlazorApp/Pages/Chat.fi.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="NewTopic" xml:space="preserve">
<value>Uusi aihe</value>
</data>
<data name="TextBoxPlaceHolder" xml:space="preserve">
<value>Kirjoita uusi viesti avustajalle</value>
</data>
<data name="Send" xml:space="preserve">
<value>Lähetä</value>
</data>

</root>
8 changes: 4 additions & 4 deletions ChatGptBlazorApp/Pages/Chat.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject IUserRepository UserRepository
@inject IChatSessionRepository ChatSessionRepository
@inject IStringLocalizer<Chat> Loc


<div class="row">
Expand Down Expand Up @@ -67,12 +68,11 @@

<form onsubmit="@Send">
<div class="mb-3">
<label for="chatInput" class="form-label">User prompt:</label>
<textarea class="form-control" id="chatInput" placeholder="write a message to your assistant" @bind="_currentPrompt"></textarea>
<textarea class="form-control" id="chatInput" placeholder="@Loc["TextBoxPlaceHolder"]" @bind="_currentPrompt"></textarea>
</div>

<div class="col-md-2">
<button type="submit" class="form-control mt-2 btn btn-primary">Send</button>
<button type="submit" class="form-control mt-2 btn btn-primary">@Loc["Send"]</button>
</div>
</form>
@if (_waitingForResponse)
Expand Down Expand Up @@ -295,7 +295,7 @@
UserId = userId,
Entries = new List<ChatEntry>(),
Created = DateTime.Now,
Topic = "New topic",
Topic = Loc["NewTopic"],
Tags = new List<string>()
};

Expand Down
Loading

0 comments on commit 565bc16

Please sign in to comment.