diff --git a/Components/Pages/Index.razor b/Components/Pages/Index.razor index 68dc2cd..d158f86 100644 --- a/Components/Pages/Index.razor +++ b/Components/Pages/Index.razor @@ -1,6 +1,6 @@ @page "/" @page "/menu/{topic?}" -@inherits SharedDisplayLogic +@inherits MainPageBase @using BLAIzor.Models @using BLAIzor.Services @using BLAIzor.Components.Partials @@ -10,21 +10,15 @@ @using System.Net @using System.Text.Json @using Sidio.Sitemap.Blazor -@* @inject AIService ChatGptService *@ @rendermode InteractiveServer -@* @inject IJSRuntime jsRuntime; *@ -@* @inject IConfiguration configuration *@ @inject ContentService _contentService -@* @inject ContentEditorService _contentEditorService *@ -@* @inject ScopedContentService _scopedContentService *@ -@* @inject IEmailSender _emailService *@ @inject NavigationManager _navigationManager @inject IHttpContextAccessor HttpContextAccessor @inject DesignTemplateService DesignTemplateService @inject CssTemplateService CssTemplateService @inject CssInjectorService CssService -@* @inject HttpClient Http *@ @attribute [Sitemap] +
@@ -264,7 +258,7 @@ // Load the CSS template for the selected brand from the database var designTemplate = await DesignTemplateService.GetByIdAsync((int)SiteInfo.TemplateId!); var cssTemplate = await CssTemplateService.GetByDesignTemplateIdAsync((int)SiteInfo.TemplateId); - CollectionName = designTemplate.QDrandCollectionName; + TemplateCollectionName = designTemplate.QDrandCollectionName; if (cssTemplate != null) { @@ -284,11 +278,11 @@ if(!string.IsNullOrWhiteSpace(topic)) { UserInput = topic; - await ChatGptService.ProcessContentRequest(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, CollectionName, Menu, true); + await ChatGptService.ProcessContentRequest(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, Menu, true); } else { - await ChatGptService.GetChatGptWelcomeMessage(SessionId, SiteId, Menu); + await ChatGptService.GetChatGptWelcomeMessage(SessionId, SiteId, TemplateCollectionName, Menu); } // HtmlContent = await ChatGptService.GetChatGptWelcomeMessage(); // UserInput = "Sumerize for me, what is this website about, and what can I do on this website?"; @@ -413,7 +407,7 @@ var menu = await GetMenuList(SiteId); HtmlContent.Clear(); string input = "Please tell me more about: " + UserInput; - await ChatGptService.ProcessUserIntent(SessionId, input, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu); + await ChatGptService.ProcessUserIntent(SessionId, input, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu); UserInput = string.Empty; } } diff --git a/Components/Pages/SharedDisplayLogic.cs b/Components/Pages/MainPageBase.cs similarity index 94% rename from Components/Pages/SharedDisplayLogic.cs rename to Components/Pages/MainPageBase.cs index 1401d32..3794794 100644 --- a/Components/Pages/SharedDisplayLogic.cs +++ b/Components/Pages/MainPageBase.cs @@ -12,7 +12,7 @@ using UglyToad.PdfPig.DocumentLayoutAnalysis; namespace BLAIzor.Components.Pages { - public class SharedDisplayLogic : ComponentBase + public class MainPageBase : ComponentBase { public string SelectedBrandName = "default"; [Inject] protected ScopedContentService _scopedContentService { get; set; } @@ -22,10 +22,10 @@ namespace BLAIzor.Components.Pages [Inject] protected IJSRuntime jsRuntime { get; set; } [Inject] protected AIService ChatGptService { get; set; } - public static readonly Dictionary _instances = new(); + public static readonly Dictionary _instances = new(); public string SessionId; - public static SharedDisplayLogic myHome; + public static MainPageBase myHome; public int SiteId; public SiteInfo SiteInfo; @@ -33,7 +33,7 @@ namespace BLAIzor.Components.Pages public string TextContent = ""; public string StatusContent = ""; public string UserInput = string.Empty; - public string CollectionName = "html_snippets"; + public string TemplateCollectionName = "html_snippets"; public bool VoiceEnabled; public bool TTSEnabled; @@ -123,9 +123,9 @@ namespace BLAIzor.Components.Pages var requestJson = JsonSerializer.Serialize(requestContent); string voiceId; - if (SiteInfo.voiceId != null) + if (SiteInfo.VoiceId != null) { - voiceId = SiteInfo.voiceId; + voiceId = SiteInfo.VoiceId; } else { @@ -199,7 +199,7 @@ namespace BLAIzor.Components.Pages { HtmlContent.Clear(); var menu = await GetMenuList(SiteId); - await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu); + await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu); UserInput = string.Empty; } } @@ -214,11 +214,11 @@ namespace BLAIzor.Components.Pages var menuItem = (await GetMenuItems(SiteId)).Where(m => m.Name == input).FirstOrDefault(); if (menuItem == null) { - await ChatGptService.ProcessContentRequest(SessionId, input, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu, forceUnmodified); + await ChatGptService.ProcessContentRequest(SessionId, input, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu, forceUnmodified); } else { - await ChatGptService.ProcessContentRequest(SessionId, menuItem, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu, forceUnmodified); + await ChatGptService.ProcessContentRequest(SessionId, menuItem, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu, forceUnmodified); } UserInput = string.Empty; } @@ -302,7 +302,7 @@ namespace BLAIzor.Components.Pages Console.WriteLine("Button clicked!"); var menu = await GetMenuList(SiteId); HtmlContent.Clear(); - await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu); + await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu); UserInput = string.Empty; } diff --git a/Components/Pages/Preview.razor b/Components/Pages/Preview.razor index a60e458..bc0ab3e 100644 --- a/Components/Pages/Preview.razor +++ b/Components/Pages/Preview.razor @@ -1,6 +1,6 @@ @page "/preview/{siteid:int}" @page "/preview/{siteid:int}/{topic?}" -@inherits SharedDisplayLogic +@inherits MainPageBase @using BLAIzor.Models @using BLAIzor.Services @using Google.Cloud.Speech.V1 @@ -10,21 +10,14 @@ @using System.Text.Json @using System.Net -@* @inject AIService ChatGptService *@ @rendermode InteractiveServer -@* @inject IJSRuntime jsRuntime; *@ -@* @inject IConfiguration configuration *@ @inject ContentService _contentService -@* @inject ContentEditorService _contentEditorService *@ -@* @inject ScopedContentService _scopedContentService *@ @inject IEmailSender _emailService @inject NavigationManager _navigationManager @inject IHttpContextAccessor HttpContextAccessor @inject DesignTemplateService DesignTemplateService @inject CssTemplateService CssTemplateService @inject CssInjectorService CssService -@* @inject HttpClient Http *@ -
@@ -99,9 +92,7 @@ @{ if (!string.IsNullOrEmpty(HtmlContent.ToString())) { - //
- // @((MarkupString)HtmlContent.ToString()) - //
+ if (isEmailFormVisible) {
@@ -330,7 +321,7 @@ // Load the CSS template for the selected brand from the database var designTemplate = await DesignTemplateService.GetByIdAsync((int)SiteInfo.TemplateId!); var cssTemplate = await CssTemplateService.GetByDesignTemplateIdAsync((int)SiteInfo.TemplateId); - CollectionName = designTemplate.QDrandCollectionName; + TemplateCollectionName = designTemplate.QDrandCollectionName; if (cssTemplate != null) { @@ -354,11 +345,11 @@ if (!string.IsNullOrWhiteSpace(topic)) { UserInput = topic; - await ChatGptService.ProcessContentRequest(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, CollectionName, Menu, true); + await ChatGptService.ProcessContentRequest(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, Menu, true); } else { - await ChatGptService.GetChatGptWelcomeMessage(SessionId, SiteId, Menu); + await ChatGptService.GetChatGptWelcomeMessage(SessionId, SiteId, TemplateCollectionName, Menu); } } @@ -429,7 +420,7 @@ { HtmlContent.Clear(); var menu = await GetMenuList(SiteId); - await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, CollectionName, menu); + await ChatGptService.ProcessUserIntent(SessionId, UserInput, SiteId, (int)SiteInfo.TemplateId!, TemplateCollectionName, menu); UserInput = string.Empty; } } diff --git a/Components/Partials/GenerateFromDocument.razor b/Components/Partials/GenerateFromDocument.razor index a337b78..d14465a 100644 --- a/Components/Partials/GenerateFromDocument.razor +++ b/Components/Partials/GenerateFromDocument.razor @@ -60,7 +60,7 @@ else if (ExtractedMenuItems.Any()) } } @@ -101,7 +101,7 @@ else if (ExtractedMenuItems.Any())
- + } else if (!string.IsNullOrEmpty(ErrorMessage)) @@ -163,6 +163,7 @@ else if (!string.IsNullOrEmpty(ErrorMessage)) if (selectedPoint != null) { model.Content = selectedPoint.result.payload.content; + model.ContentDescription = selectedPoint.result.payload.description; Console.Write($"Found point: {selectedPoint.result.payload.content}"); } @@ -246,6 +247,7 @@ else if (!string.IsNullOrEmpty(ErrorMessage)) if (item != null) { //item.MenuItem. + item.MenuItem.Name = updatedItem.MenuItem.Name; item.Content = updatedItem.Content; } } @@ -287,10 +289,12 @@ else if (!string.IsNullOrEmpty(ErrorMessage)) foreach (var menuItemToReorder in menuItems) { menuItemToReorder.SortOrder = menuItems.IndexOf(menuItemToReorder); + Console.WriteLine($"{menuItemToReorder.Name}, {menuItemToReorder.SortOrder}"); } foreach (var extractedMenuItemToReorder in ExtractedMenuItems) { extractedMenuItemToReorder.MenuItem.SortOrder = ExtractedMenuItems.IndexOf(extractedMenuItemToReorder); + Console.WriteLine($"{extractedMenuItemToReorder.MenuItem.Name}, {extractedMenuItemToReorder.MenuItem.SortOrder}"); } JSRuntime.InvokeVoidAsync("eval", $"document.querySelector('.my-class').classList.remove('my-class')"); })); diff --git a/Components/Partials/GenerateFromScratch.razor b/Components/Partials/GenerateFromScratch.razor index 174c2d3..d2c6cf8 100644 --- a/Components/Partials/GenerateFromScratch.razor +++ b/Components/Partials/GenerateFromScratch.razor @@ -62,7 +62,7 @@ else if (extractedMenuItems.Any()) } } @@ -77,7 +77,7 @@ else if (extractedMenuItems.Any())
- + } @@ -133,6 +133,7 @@ else if (!string.IsNullOrEmpty(errorMessage)) if (selectedPoint != null) { model.Content = selectedPoint.result.payload.content; + model.ContentDescription = selectedPoint.result.payload.description; Console.Write($"Found point: {selectedPoint.result.payload.content}"); } @@ -182,6 +183,7 @@ else if (!string.IsNullOrEmpty(errorMessage)) var newItem = new MenuItemModel("New menu item", ""); //TODO Fix extractedMenuItems.Add(newItem); + isLoading = false; } diff --git a/Components/Partials/MapsComponent.razor b/Components/Partials/MapsComponent.razor new file mode 100644 index 0000000..c0ba0a9 --- /dev/null +++ b/Components/Partials/MapsComponent.razor @@ -0,0 +1,54 @@ +@using Microsoft.JSInterop +@inject IJSRuntime JSRuntime + + + + + + + + + { { "disableDoubleClickZoom", true } }) + Zoom=@zoom Center=@(new GoogleMapPosition() { Lat = 42.6977, Lng = 23.3219 }) MapClick=@OnMapClick MarkerClick=@OnMarkerClick> + + + + @if (showMadridMarker) + { + + } + + + + + +@code { + int zoom = 3; + bool showMadridMarker; + EventConsole console; + RadzenGoogleMap map; + + void OnMapClick(GoogleMapClickEventArgs args) + { + console.Log($"Map clicked at Lat: {args.Position.Lat}, Lng: {args.Position.Lng}"); + } + + async Task OnMarkerClick(RadzenGoogleMapMarker marker) + { + var message = $"Custom information about {marker.Title}"; + + var code = $@" +var map = Radzen['{map.UniqueID}'].instance; +var marker = map.markers.find(m => m.title == '{marker.Title}'); +if(window.infoWindow) {{window.infoWindow.close();}} +window.infoWindow = new google.maps.InfoWindow({{content: '{message}'}}); +setTimeout(() => window.infoWindow.open(map, marker), 200); +"; + + await JSRuntime.InvokeVoidAsync("eval", code); + } + + // Custom marker label + string Label => "\n\n\n"; + +} \ No newline at end of file diff --git a/Components/Partials/MenuItemContentEditor.razor b/Components/Partials/MenuItemContentEditor.razor index 85499bb..17a4f24 100644 --- a/Components/Partials/MenuItemContentEditor.razor +++ b/Components/Partials/MenuItemContentEditor.razor @@ -6,7 +6,7 @@ @inject CustomAuthenticationStateProvider CustomAuthProvider