-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from BalaVigneshRaviChandran/ES-890869-RemoteData
890869: UG samples for remote data using various data adapters
- Loading branch information
Showing
140 changed files
with
6,014 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
13 changes: 13 additions & 0 deletions
13
UG-Samples/DataBinding/RemoteData/ODataAdaptor/BlazorServer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Blazor" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
UG-Samples/DataBinding/RemoteData/ODataAdaptor/BlazorServer.csproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ActiveDebugProfile>https</ActiveDebugProfile> | ||
</PropertyGroup> | ||
</Project> |
25 changes: 25 additions & 0 deletions
25
UG-Samples/DataBinding/RemoteData/ODataAdaptor/BlazorServer.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34616.47 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServer", "BlazorServer.csproj", "{923B1AE0-4DE6-4174-B440-05D0FFE2F511}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{923B1AE0-4DE6-4174-B440-05D0FFE2F511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{923B1AE0-4DE6-4174-B440-05D0FFE2F511}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{923B1AE0-4DE6-4174-B440-05D0FFE2F511}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{923B1AE0-4DE6-4174-B440-05D0FFE2F511}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {39B1047F-18F1-49AD-A601-4871C3497563} | ||
EndGlobalSection | ||
EndGlobal |
13 changes: 13 additions & 0 deletions
13
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Data/WeatherForecast.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace BlazorServer.Data | ||
{ | ||
public class WeatherForecast | ||
{ | ||
public DateOnly Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
||
public string? Summary { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Data/WeatherForecastService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace BlazorServer.Data | ||
{ | ||
public class WeatherForecastService | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate) | ||
{ | ||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = startDate.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray()); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/Counter.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@page "/counter" | ||
|
||
<PageTitle>Counter</PageTitle> | ||
|
||
<h1>Counter</h1> | ||
|
||
<p role="status">Current count: @currentCount</p> | ||
|
||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> | ||
|
||
@code { | ||
private int currentCount = 0; | ||
|
||
private void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/Error.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@page | ||
@model BlazorServer.Pages.ErrorModel | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>Error</title> | ||
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" /> | ||
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" /> | ||
</head> | ||
|
||
<body> | ||
<div class="main"> | ||
<div class="content px-4"> | ||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
27 changes: 27 additions & 0 deletions
27
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/Error.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using System.Diagnostics; | ||
|
||
namespace BlazorServer.Pages | ||
{ | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string? RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/FetchData.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@page "/fetchdata" | ||
@using BlazorServer.Data | ||
@inject WeatherForecastService ForecastService | ||
|
||
<PageTitle>Weather forecast</PageTitle> | ||
|
||
<h1>Weather forecast</h1> | ||
|
||
<p>This component demonstrates fetching data from a service.</p> | ||
|
||
@if (forecasts == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Date</th> | ||
<th>Temp. (C)</th> | ||
<th>Temp. (F)</th> | ||
<th>Summary</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var forecast in forecasts) | ||
{ | ||
<tr> | ||
<td>@forecast.Date.ToShortDateString()</td> | ||
<td>@forecast.TemperatureC</td> | ||
<td>@forecast.TemperatureF</td> | ||
<td>@forecast.Summary</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private WeatherForecast[]? forecasts; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/Index.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
@page "/" | ||
@page "/DiagramOData" | ||
@using Syncfusion.Blazor.Internal | ||
@using Syncfusion.Blazor.Diagram | ||
@using Syncfusion.Blazor.Data | ||
@inject HttpClient Http | ||
|
||
|
||
<div id="diagram-space" class="content-wrapper"> | ||
<SfDiagramComponent Height="400px" NodeCreating="OnNodeCreating" ConnectorCreating="OnConnectorCreating"> | ||
<DataSourceSettings Id="EmployeeID" ParentId="ReportsTo" Query="Query"> | ||
<SfDataManager Url="https://blazor.syncfusion.com/services/development/odata/DiagramOData" Adaptor="Syncfusion.Blazor.Adaptors.ODataAdaptor"></SfDataManager> | ||
</DataSourceSettings> | ||
<SnapSettings Constraints="SnapConstraints.None"></SnapSettings> | ||
<Layout HorizontalSpacing="100" VerticalSpacing="100" Type="LayoutType.HierarchicalTree"></Layout> | ||
</SfDiagramComponent> | ||
</div> | ||
|
||
@code { | ||
SfDiagramComponent Diagrams; | ||
private float x = 100; | ||
private float y = 100; | ||
|
||
public class Employee | ||
{ | ||
public int? EmployeeID { get; set; } | ||
public string FirstName { get; set; } | ||
public int? ReportsTo { get; set; } | ||
} | ||
|
||
private Query Query = new Query().Select(new List<string>() { "EmployeeID", "ReportsTo", "FirstName" }).Take(9); | ||
|
||
private void OnNodeCreating(IDiagramObject obj) | ||
{ | ||
Node node = obj as Node; | ||
node.OffsetX = x; | ||
node.OffsetY = y; | ||
node.Width = 80; | ||
node.Height = 40; | ||
node.Shape = new BasicShape() { Type = Syncfusion.Blazor.Diagram.NodeShapes.Basic, Shape = NodeBasicShapes.Rectangle, CornerRadius = 8 }; | ||
node.Style = new ShapeStyle() { StrokeWidth = 0, Fill = "" }; | ||
x += 100; | ||
|
||
Dictionary<string, object> data = node.Data as Dictionary<string, object>; | ||
node.Annotations = new DiagramObjectCollection<ShapeAnnotation>() { | ||
new ShapeAnnotation() { | ||
Content = data["FirstName"].ToString(), | ||
Style = new TextStyle() { Color = "white" } | ||
} | ||
}; | ||
|
||
switch (data["FirstName"].ToString()) | ||
{ | ||
case "Andrew": | ||
node.Style.Fill = "#3A4857"; | ||
break; | ||
case "Nancy": | ||
node.Style.Fill = "#2B8C68"; | ||
break; | ||
case "Janet": | ||
node.Style.Fill = "#488CC1"; | ||
break; | ||
case "Margaret": | ||
node.Style.Fill = "#4C888F"; | ||
break; | ||
case "Steven": | ||
node.Style.Fill = "#8E4DB4"; | ||
break; | ||
case "Laura": | ||
node.Style.Fill = "#CD6A32"; | ||
break; | ||
default: | ||
node.Style.Fill = "#8E4DB4"; | ||
break; | ||
} | ||
} | ||
|
||
private void OnConnectorCreating(IDiagramObject obj) | ||
{ | ||
Connector connector = obj as Connector; | ||
connector.Style.StrokeColor = "#048785"; | ||
connector.Type = ConnectorSegmentType.Orthogonal; | ||
connector.TargetDecorator.Shape = DecoratorShape.None; | ||
connector.SourceDecorator.Shape = DecoratorShape.None; | ||
connector.Style = new ShapeStyle() { StrokeColor = "#3A4857", Fill = "#3A4857", StrokeWidth = 1, StrokeDashArray = "3,3" }; | ||
} | ||
} | ||
|
||
|
36 changes: 36 additions & 0 deletions
36
UG-Samples/DataBinding/RemoteData/ODataAdaptor/Pages/_Host.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@page "/" | ||
@using Microsoft.AspNetCore.Components.Web | ||
@namespace BlazorServer.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<base href="~/" /> | ||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> | ||
<link href="css/site.css" rel="stylesheet" /> | ||
<link href="BlazorServer.styles.css" rel="stylesheet" /> | ||
<link rel="icon" type="image/png" href="favicon.png" /> | ||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> | ||
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" /> | ||
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
<component type="typeof(App)" render-mode="ServerPrerendered" /> | ||
|
||
<div id="blazor-error-ui"> | ||
<environment include="Staging,Production"> | ||
An error has occurred. This application may no longer respond until reloaded. | ||
</environment> | ||
<environment include="Development"> | ||
An unhandled exception has occurred. See browser dev tools for details. | ||
</environment> | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
|
||
<script src="_framework/blazor.server.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using BlazorServer.Data; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Syncfusion.Blazor; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
builder.Services.AddRazorPages(); | ||
builder.Services.AddServerSideBlazor(); | ||
builder.Services.AddSingleton<WeatherForecastService>(); | ||
builder.Services.AddSyncfusionBlazor(); | ||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (!app.Environment.IsDevelopment()) | ||
{ | ||
app.UseExceptionHandler("/Error"); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseStaticFiles(); | ||
|
||
app.UseRouting(); | ||
|
||
app.MapBlazorHub(); | ||
app.MapFallbackToPage("/_Host"); | ||
|
||
app.Run(); |
Oops, something went wrong.