@page "/"
Welcome Back, Waving Hand John Doe, Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod.
In Progress Work Orders @DashboardViewModel.Inprogress

Updated Now

@DashboardViewModel.Sev1 Sev 1
@DashboardViewModel.Sev2 Sev 2
@DashboardViewModel.Sev3 Sev 3
@DashboardViewModel.Sev4 Sev 4
@DashboardViewModel.Sev5 Sev 5
Completed Work Orders @DashboardViewModel.Completed

Updated Now

Open Work Orders @DashboardViewModel.Open

Updated Now

On Hold Work Orders @DashboardViewModel.Onhold

Updated Now

Work Order Status
@*
Orders

Total @DashboardViewModel.Total

*@
Work Orders
@if (DashboardViewModel != null && DashboardViewModel.Dashboardworkorders != null) { foreach (var itm in DashboardViewModel.Dashboardworkorders) { var userNameInitials = ""; if (itm.UserName != null && !string.IsNullOrEmpty(itm.UserName)) { var nameParts = itm.UserName.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (nameParts.Length > 1) { // Take the first letter of the first two words userNameInitials = string.Concat(nameParts[0][0], nameParts[1][0]).ToUpper(); } else { // Take the first letter of the single word userNameInitials = nameParts[0][0].ToString().ToUpper() + nameParts[0][1].ToString().ToUpper(); } } } }
@if (userNameInitials != "" && userNameInitials != null) { @userNameInitials } else { NA }

@itm.Name

@if (itm.Status == "Open") {
Open
} else if (itm.Status == "On Hold") {
On Hold
} else if (itm.Status == "In Progress") {
In Progress
} else if (itm.Status == "Done") {
Done
}
Map

Lorem ipsum is a dummy text

{ { "disableDoubleClickZoom", true } }) Zoom=@zoom Center=@(new GoogleMapPosition() { Lat = 42.6977, Lng = 23.3219 }) MapClick=@OnMapClick> @foreach (var itm in setmappins) { } @if (showMadridMarker) { }
@if (isloading) {
Loading…
} @using GoogleMapsComponents.Maps.Places @using Microsoft.AspNetCore.Authorization @using Radzen @using Radzen.Blazor @using Microsoft.JSInterop @using System.Text.Json @using System.Globalization @using SeaHavenIndustries.Data.IRepository @using SeaHavenIndustries.Helper.ViewModels @using global::Data.SeaHavenIndustries @inject IJSRuntime JSRuntime @attribute [Authorize] @inject NavigationManager Navigation @inject IWorkOrderRepository _service; @inject IAccountRepository _aservice; @inject ISettingsRepository _Seservice; @inject HttpClient Http @inject IConfiguration Configuration @code { private IEnumerable? users { get; set; } private bool isloading = false; private IEnumerable? droplocations { get; set; } private IEnumerable? locationslist { get; set; } private DashboardViewModel DashboardViewModel = new DashboardViewModel(); private ElementReference chartCanvas; protected override async Task OnInitializedAsync() { isloading = true; await Task.Delay(50); DashboardViewModel = await _Seservice.Getdashboarddata(); isloading = false; } RadzenDataGrid grid; int count; int eid; private ElementReference addressBox; private RadzenTextBox? addressBoxRadzenTextBox; private Autocomplete? autocomplete; private string? placeData; private string? formattedAddress; IEnumerable locations; List setmappins = new List(); bool isLoading = false; private Locations model = new Locations(); string mapval = ""; List titles = new List { "Sales Representative", "Vice President, Sales", "Sales Manager", "Inside Sales Coordinator" }; IEnumerable selectedTitles; int zoom = 3; bool showMadridMarker; // EventConsole console; RadzenGoogleMap map; void OnMapClick(GoogleMapClickEventArgs args) { // Check if any marker was clicked var clickedMarker = setmappins.FirstOrDefault(marker => Math.Round(marker.lat, 4) == Math.Round(args.Position.Lat, 4) && Math.Round(marker.lon, 4) == Math.Round(args.Position.Lng, 4)); if (clickedMarker != null) { // Access the title of the clicked marker string clickedTitle = clickedMarker.title; // Perform actions based on the clicked title Console.WriteLine($"Marker with title '{clickedTitle}' clicked."); // Add additional logic as needed } else { // No marker was clicked directly on the map Console.WriteLine("No marker clicked directly on the map."); } } // 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); // } async Task OnSelectedTitlesChange(object value) { if (selectedTitles != null && !selectedTitles.Any()) { selectedTitles = null; } await grid.FirstPage(); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JSRuntime.InvokeVoidAsync("initScripts"); addressBox = addressBoxRadzenTextBox.Element; await SetupGoogleAddressAutoComplete(); await EnsureDataLoadedAndInvokeJS(); } } private async Task EnsureDataLoadedAndInvokeJS() { while (DashboardViewModel.Sev1 == null || DashboardViewModel.Sev1Per == null) { await Task.Delay(10); } // Once data is loaded, call the JavaScript function await JSRuntime.InvokeVoidAsync("CircleGraph", DashboardViewModel.Sev1, DashboardViewModel.Sev1Per); await JSRuntime.InvokeVoidAsync("CircleGraph2", DashboardViewModel.Sev2, DashboardViewModel.Sev2Per); await JSRuntime.InvokeVoidAsync("CircleGraph3", DashboardViewModel.Sev3, DashboardViewModel.Sev3Per); await JSRuntime.InvokeVoidAsync("CircleGraph4", DashboardViewModel.Sev4, DashboardViewModel.Sev4Per); await JSRuntime.InvokeVoidAsync("CircleGraph5", DashboardViewModel.Sev5, DashboardViewModel.Sev5Per); List list = new List(); list.Add(DashboardViewModel.Open.Value); list.Add(DashboardViewModel.Onhold.Value); list.Add(DashboardViewModel.Inprogress.Value); list.Add(DashboardViewModel.Completed.Value); //await JSRuntime.InvokeVoidAsync("ConsumptionGraph", list); await JSRuntime.InvokeVoidAsync("PerformanceChartHome", list); } protected async Task UpdateChart() { await JSRuntime.InvokeVoidAsync("initScripts"); addressBox = addressBoxRadzenTextBox.Element; await SetupGoogleAddressAutoComplete(); await JSRuntime.InvokeVoidAsync("ConsumptionGraph"); await JSRuntime.InvokeVoidAsync("CircleGraph", DashboardViewModel.Sev1, DashboardViewModel.Sev1Per); await JSRuntime.InvokeVoidAsync("CircleGraph2"); await JSRuntime.InvokeVoidAsync("PerformanceChartHome"); } private async Task GoogleAddressAutoComplete() { System.Threading.Thread.Sleep(500); // this is a hack. with no wait place was null first time var place = await this.autocomplete.GetPlace(); var placeDataTest = JsonSerializer.Serialize(place); if (place?.AddressComponents == null) { // this.message = "No results available for " + place?.Name; } else { var placesd = await this.autocomplete.GetPlace(); model.Name = place.FormattedAddress; var placeId = place.PlaceId; var details = await GetLatLng(placeId); var streetNumber = place.AddressComponents.FirstOrDefault(a => a.Types != null && a.Types.Contains("street_number"))?.LongName; var street = place.AddressComponents.FirstOrDefault(a => a.Types != null && (a.Types.Contains("route") || a.Types.Contains("street_address")))?.LongName; var city = place.AddressComponents.FirstOrDefault(a => a.Types != null && (a.Types.Contains("locality") || a.Types.Contains("neighborhood")))?.LongName; var state = place.AddressComponents.FirstOrDefault(a => a.Types != null && a.Types.Contains("administrative_area_level_1"))?.LongName; var country = place.AddressComponents.FirstOrDefault(a => a.Types != null && a.Types.Contains("country"))?.LongName; var postcode = place.AddressComponents.FirstOrDefault(a => a.Types != null && a.Types.Contains("postal_code"))?.LongName; formattedAddress = place.FormattedAddress; // model.Title = place.AddressComponents.FirstOrDefault()?.LongName; //setmappins.Add(new setmappin{title=place.Name,lat=place.l}) placeData = JsonSerializer.Serialize(place); } } private async Task<(double Latitude, double Longitude)> GetLatLng(string placeId) { var apiKey = Configuration["GoogleMaps:ApiKey"]; // Injected from configuration (env var GoogleMaps__ApiKey / user-secrets) //var apiUrl = $"https://places.googleapis.com/v1/places/{placeId}"; var apiUrl = $"https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&language=pt_BR&types=%28cities%29&key={apiKey}"; // var apiUrl = $"https://places.googleapis.com/v1/places/{placeId}?fields=id,displayName&key={apiKey}"; try { var response = await Http.GetFromJsonAsync(apiUrl); if (response?.status == "OK" && response.results?.Count > 0) { var location = response.results[0].geometry?.location; if (location != null) { return (location.lat, location.lng); } } Console.WriteLine($"Error retrieving geocode. Status: {response?.status}"); return default; } catch (Exception ex) { Console.WriteLine($"Error fetching geocode: {ex.Message}"); return default; } } public class GeocodingApiResponse { public string status { get; set; } public List results { get; set; } } public class GeocodingResult { public Geometry geometry { get; set; } } public class Geometry { public Location location { get; set; } } public class Location { public double lat { get; set; } public double lng { get; set; } } private async Task SetupGoogleAddressAutoComplete() { this.autocomplete = await Autocomplete.CreateAsync(JSRuntime, addressBox, new AutocompleteOptions { StrictBounds = false, }); await this.autocomplete.SetFields(new[] { "address_components", "place_id", "formatted_address" }); } @inject NorthwindService service public void Export(string type) { service.Export("locations", type, new Query() { OrderBy = grid.Query.OrderBy, Filter = grid.Query.Filter, Select = string.Join(",", grid.ColumnsCollection.Where(c => c.GetVisible() && !string.IsNullOrEmpty(c.Property)) .Select(c => c.Property.Contains(".") ? $"{c.Property} as {c.Property.Replace(".", "_")}" : c.Property)) }); } public class setmappin { public string title { get; set; } public double lat { get; set; } public double lon { get; set; } } }