diff --git a/CustomAdaptor/CustomAdaptor.Server/Controllers/OrdersController.cs b/CustomAdaptor/CustomAdaptor.Server/Controllers/OrdersController.cs new file mode 100644 index 0000000..3ad639e --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/Controllers/OrdersController.cs @@ -0,0 +1,80 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using ODataV4Adaptor.Server.Models; + +namespace OdataV4Adaptor.Server.Controllers +{ + + public class OrdersController : Controller + { + /// + /// Retrieves all orders. + /// + /// The collection of orders. + [HttpGet] + [EnableQuery] + public IActionResult Get() + { + var data = OrdersDetails.GetAllRecords().AsQueryable(); + return Ok(data); + } + + /// + /// Inserts a new order to the collection. + /// + /// The order to be inserted. + /// It returns the newly inserted record detail. + [HttpPost] + [EnableQuery] + public IActionResult Post([FromBody] OrdersDetails addRecord) + { + if (addRecord == null) + { + return BadRequest("Null order"); + } + OrdersDetails.GetAllRecords().Insert(0, addRecord); + return Json(addRecord); + } + + /// + /// Updates an existing order. + /// + /// The ID of the order to update. + /// The updated order details. + /// It returns the updated order details. + [HttpPatch("{key}")] + public IActionResult Patch(int key, [FromBody] OrdersDetails updateRecord) + { + if (updateRecord == null) + { + return BadRequest("No records"); + } + var existingOrder = OrdersDetails.GetAllRecords().FirstOrDefault(order => order.OrderID == key); + if (existingOrder != null) + { + // If the order exists, update its properties + existingOrder.CustomerID = updateRecord.CustomerID ?? existingOrder.CustomerID; + existingOrder.EmployeeID = updateRecord.EmployeeID ?? existingOrder.EmployeeID; + existingOrder.ShipCountry = updateRecord.ShipCountry ?? existingOrder.ShipCountry; + } + return Json(updateRecord); + } + + /// + /// Deletes an order. + /// + /// The ID of the order to delete. + /// It returns the deleted record detail + [HttpDelete("{key}")] + public IActionResult Delete(int key) + { + var deleteRecord = OrdersDetails.GetAllRecords().FirstOrDefault(order => order.OrderID == key); + if (deleteRecord != null) + { + OrdersDetails.GetAllRecords().Remove(deleteRecord); + } + return Json(deleteRecord); + } + } +} \ No newline at end of file diff --git a/CustomAdaptor/CustomAdaptor.Server/Controllers/WeatherForecastController.cs b/CustomAdaptor/CustomAdaptor.Server/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..3931fb8 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODataV4Adaptor.Server.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/CustomAdaptor/CustomAdaptor.Server/Models/OrdersDetails.cs b/CustomAdaptor/CustomAdaptor.Server/Models/OrdersDetails.cs new file mode 100644 index 0000000..1bb7b03 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/Models/OrdersDetails.cs @@ -0,0 +1,44 @@ +using System.ComponentModel.DataAnnotations; + +namespace ODataV4Adaptor.Server.Models +{ + public class OrdersDetails + { + public static List order = new List(); + public OrdersDetails() + { + + } + public OrdersDetails( + int OrderID, string CustomerId, int EmployeeId, string ShipCountry) + { + this.OrderID = OrderID; + this.CustomerID = CustomerId; + this.EmployeeID = EmployeeId; + this.ShipCountry = ShipCountry; + } + + public static List GetAllRecords() + { + if (order.Count() == 0) + { + int code = 10000; + for (int i = 1; i < 10; i++) + { + order.Add(new OrdersDetails(code + 1, "ALFKI", i + 0, "Denmark")); + order.Add(new OrdersDetails(code + 2, "ANATR", i + 2, "Brazil")); + order.Add(new OrdersDetails(code + 3, "ANTON", i + 1, "Germany")); + order.Add(new OrdersDetails(code + 4, "BLONP", i + 3, "Austria")); + order.Add(new OrdersDetails(code + 5, "BOLID", i + 4, "Switzerland")); + code += 5; + } + } + return order; + } + [Key] + public int? OrderID { get; set; } + public string? CustomerID { get; set; } + public int? EmployeeID { get; set; } + public string? ShipCountry { get; set; } + } +} \ No newline at end of file diff --git a/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj new file mode 100644 index 0000000..f9c460d --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + ..\odatav4adaptor.client + npm run dev + https://localhost:5173 + + + + + + 8.*-* + + + + + + + false + + + + diff --git a/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj.user b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj.user new file mode 100644 index 0000000..9ff5820 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.csproj.user @@ -0,0 +1,6 @@ + + + + https + + \ No newline at end of file diff --git a/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.http b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.http new file mode 100644 index 0000000..4a792e0 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/ODataV4Adaptor.Server.http @@ -0,0 +1,6 @@ +@ODataV4Adaptor.Server_HostAddress = http://localhost:5241 + +GET {{ODataV4Adaptor.Server_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/CustomAdaptor/CustomAdaptor.Server/Program.cs b/CustomAdaptor/CustomAdaptor.Server/Program.cs new file mode 100644 index 0000000..a3384fa --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/Program.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.OData; +using Microsoft.OData.ModelBuilder; +using ODataV4Adaptor.Server.Models; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +var modelBuilder = new ODataConventionModelBuilder(); +modelBuilder.EntitySet("Orders"); + +var recordCount = OrdersDetails.GetAllRecords().Count; + +builder.Services.AddControllers().AddOData( + options => options + .Count() + .OrderBy() + .Filter() + .SetMaxTop(recordCount) + .AddRouteComponents( + "odata", + modelBuilder.GetEdmModel())); + + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +builder.Services.AddCors(options => +{ + options.AddDefaultPolicy(builder => + { + builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); + }); +}); +var app = builder.Build(); +app.UseCors(); + +app.UseDefaultFiles(); +app.UseStaticFiles(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.MapFallbackToFile("/index.html"); + +app.Run(); \ No newline at end of file diff --git a/CustomAdaptor/CustomAdaptor.Server/Properties/launchSettings.json b/CustomAdaptor/CustomAdaptor.Server/Properties/launchSettings.json new file mode 100644 index 0000000..6d3a1b6 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/Properties/launchSettings.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17310", + "sslPort": 44346 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5241", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7215;http://localhost:5241", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } + } + } +} + diff --git a/CustomAdaptor/CustomAdaptor.Server/WeatherForecast.cs b/CustomAdaptor/CustomAdaptor.Server/WeatherForecast.cs new file mode 100644 index 0000000..1b27afe --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace ODataV4Adaptor.Server +{ + 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; } + } +} diff --git a/CustomAdaptor/CustomAdaptor.Server/appsettings.Development.json b/CustomAdaptor/CustomAdaptor.Server/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/CustomAdaptor/CustomAdaptor.Server/appsettings.json b/CustomAdaptor/CustomAdaptor.Server/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/CustomAdaptor/CustomAdaptor.sln b/CustomAdaptor/CustomAdaptor.sln new file mode 100644 index 0000000..0809d7c --- /dev/null +++ b/CustomAdaptor/CustomAdaptor.sln @@ -0,0 +1,33 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataV4Adaptor.Server", "ODataV4Adaptor.Server\ODataV4Adaptor.Server.csproj", "{1C30C5B8-D458-4654-AAC3-D1865BA6B333}" +EndProject +Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "odatav4adaptor.client", "odatav4adaptor.client\odatav4adaptor.client.esproj", "{08AB8A24-B687-420F-824A-830C3AFA5F87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1C30C5B8-D458-4654-AAC3-D1865BA6B333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C30C5B8-D458-4654-AAC3-D1865BA6B333}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C30C5B8-D458-4654-AAC3-D1865BA6B333}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C30C5B8-D458-4654-AAC3-D1865BA6B333}.Release|Any CPU.Build.0 = Release|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Release|Any CPU.Build.0 = Release|Any CPU + {08AB8A24-B687-420F-824A-830C3AFA5F87}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {57156135-2E52-491B-AE1F-B50B2C97612A} + EndGlobalSection +EndGlobal diff --git a/CustomAdaptor/README.md b/CustomAdaptor/README.md new file mode 100644 index 0000000..0fe87e1 --- /dev/null +++ b/CustomAdaptor/README.md @@ -0,0 +1,34 @@ +# Custom Adaptor in Syncfusion Vue Grid Component + +The `CustomAdaptor`, which extends the `ODataV4Adaptor`, enables enhanced data handling capabilities while maintaining full compatibility with OData v4 services in the Syncfusion Vue Grid Component. This guide provides instructions on binding data and performing CRUD (Create, Read, Update, Delete) operations using the extended adaptor in your Vue Grid implementation. + +## Getting Started + +**1. Clone the Repository:** + +Use `git clone` to fetch the repository from GitHub. + +```bash +https://github.com/SyncfusionExamples/Binding-data-from-remote-service-to-vue-data-grid.git +``` + +**2. Open and Build the Project:** + +* Open the project in Visual Studio. +* Build the project to restore dependencies and compile it. +* Run the project + +**3. Explore the Code:** + +* Navigate to vue client folder(~src/app.vue) +* Debug and interact with the code as needed. + +![Adaptors](../assets/images/adaptor-crud-operation.gif) + +## Resources + +You can also refer the below resources to know more details about Syncfusion Vue Grid components. + +* [Demo](https://ej2.syncfusion.com/vue/demos/#/tailwind/grid/over-view) +* [Documentation](https://ej2.syncfusion.com/vue/documentation/grid/getting-started) +* [CustomAdaptor with Syncfusion DataManager](https://ej2.syncfusion.com/vue/documentation/grid/connecting-to-adaptors/custom-adaptor) \ No newline at end of file diff --git a/CustomAdaptor/customadaptor.client/.eslintrc.cjs b/CustomAdaptor/customadaptor.client/.eslintrc.cjs new file mode 100644 index 0000000..15f62d7 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/.eslintrc.cjs @@ -0,0 +1,11 @@ +/* eslint-env node */ +module.exports = { + root: true, + 'extends': [ + 'plugin:vue/vue3-essential', + 'eslint:recommended' + ], + parserOptions: { + ecmaVersion: 'latest' + } +} diff --git a/CustomAdaptor/customadaptor.client/.gitignore b/CustomAdaptor/customadaptor.client/.gitignore new file mode 100644 index 0000000..8ee54e8 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/.gitignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +*.tsbuildinfo diff --git a/CustomAdaptor/customadaptor.client/README.md b/CustomAdaptor/customadaptor.client/README.md new file mode 100644 index 0000000..6bbca3d --- /dev/null +++ b/CustomAdaptor/customadaptor.client/README.md @@ -0,0 +1,35 @@ +# odatav4adaptor.client + +This template should help get you started developing with Vue 3 in Vite. + +## Recommended IDE Setup + +[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). + +## Customize configuration + +See [Vite Configuration Reference](https://vitejs.dev/config/). + +## Project Setup + +```sh +npm install +``` + +### Compile and Hot-Reload for Development + +```sh +npm run dev +``` + +### Compile and Minify for Production + +```sh +npm run build +``` + +### Lint with [ESLint](https://eslint.org/) + +```sh +npm run lint +``` diff --git a/CustomAdaptor/customadaptor.client/index.html b/CustomAdaptor/customadaptor.client/index.html new file mode 100644 index 0000000..99f583a --- /dev/null +++ b/CustomAdaptor/customadaptor.client/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/CustomAdaptor/customadaptor.client/jsconfig.json b/CustomAdaptor/customadaptor.client/jsconfig.json new file mode 100644 index 0000000..5a1f2d2 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/jsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "paths": { + "@/*": ["./src/*"] + } + }, + "exclude": ["node_modules", "dist"] +} diff --git a/CustomAdaptor/customadaptor.client/nuget.config b/CustomAdaptor/customadaptor.client/nuget.config new file mode 100644 index 0000000..6548586 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/nuget.config @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/CustomAdaptor/customadaptor.client/odatav4adaptor.client.esproj b/CustomAdaptor/customadaptor.client/odatav4adaptor.client.esproj new file mode 100644 index 0000000..79bf963 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/odatav4adaptor.client.esproj @@ -0,0 +1,11 @@ + + + npm run dev + .\ + Jest + + false + + $(MSBuildProjectDirectory)\dist + + \ No newline at end of file diff --git a/CustomAdaptor/customadaptor.client/package.json b/CustomAdaptor/customadaptor.client/package.json new file mode 100644 index 0000000..956679a --- /dev/null +++ b/CustomAdaptor/customadaptor.client/package.json @@ -0,0 +1,23 @@ +{ + "name": "odatav4adaptor.client", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" + }, + "dependencies": { + "@syncfusion/ej2-data": "*", + "@syncfusion/ej2-vue-grids": "*", + "vue": "^3.4.29" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.0.5", + "eslint": "^8.57.0", + "eslint-plugin-vue": "^9.23.0", + "vite": "^5.3.1" + } +} diff --git a/CustomAdaptor/customadaptor.client/public/favicon.ico b/CustomAdaptor/customadaptor.client/public/favicon.ico new file mode 100644 index 0000000..df36fcf Binary files /dev/null and b/CustomAdaptor/customadaptor.client/public/favicon.ico differ diff --git a/CustomAdaptor/customadaptor.client/src/App.vue b/CustomAdaptor/customadaptor.client/src/App.vue new file mode 100644 index 0000000..2c6ef88 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/App.vue @@ -0,0 +1,41 @@ + + + diff --git a/CustomAdaptor/customadaptor.client/src/assets/base.css b/CustomAdaptor/customadaptor.client/src/assets/base.css new file mode 100644 index 0000000..8816868 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/assets/base.css @@ -0,0 +1,86 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: + color 0.5s, + background-color 0.5s; + line-height: 1.6; + font-family: + Inter, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + Oxygen, + Ubuntu, + Cantarell, + 'Fira Sans', + 'Droid Sans', + 'Helvetica Neue', + sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/CustomAdaptor/customadaptor.client/src/assets/logo.svg b/CustomAdaptor/customadaptor.client/src/assets/logo.svg new file mode 100644 index 0000000..7565660 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/assets/logo.svg @@ -0,0 +1 @@ + diff --git a/CustomAdaptor/customadaptor.client/src/assets/main.css b/CustomAdaptor/customadaptor.client/src/assets/main.css new file mode 100644 index 0000000..e69de29 diff --git a/CustomAdaptor/customadaptor.client/src/components/HelloWorld.vue b/CustomAdaptor/customadaptor.client/src/components/HelloWorld.vue new file mode 100644 index 0000000..ce1b3ce --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/HelloWorld.vue @@ -0,0 +1,94 @@ + + + + + \ No newline at end of file diff --git a/CustomAdaptor/customadaptor.client/src/components/TheWelcome.vue b/CustomAdaptor/customadaptor.client/src/components/TheWelcome.vue new file mode 100644 index 0000000..dab9536 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/TheWelcome.vue @@ -0,0 +1,88 @@ + + + diff --git a/CustomAdaptor/customadaptor.client/src/components/WelcomeItem.vue b/CustomAdaptor/customadaptor.client/src/components/WelcomeItem.vue new file mode 100644 index 0000000..6d7086a --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/WelcomeItem.vue @@ -0,0 +1,87 @@ + + + diff --git a/CustomAdaptor/customadaptor.client/src/components/icons/IconCommunity.vue b/CustomAdaptor/customadaptor.client/src/components/icons/IconCommunity.vue new file mode 100644 index 0000000..2dc8b05 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/icons/IconCommunity.vue @@ -0,0 +1,7 @@ + diff --git a/CustomAdaptor/customadaptor.client/src/components/icons/IconDocumentation.vue b/CustomAdaptor/customadaptor.client/src/components/icons/IconDocumentation.vue new file mode 100644 index 0000000..6d4791c --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/icons/IconDocumentation.vue @@ -0,0 +1,7 @@ + diff --git a/CustomAdaptor/customadaptor.client/src/components/icons/IconEcosystem.vue b/CustomAdaptor/customadaptor.client/src/components/icons/IconEcosystem.vue new file mode 100644 index 0000000..c3a4f07 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/icons/IconEcosystem.vue @@ -0,0 +1,7 @@ + diff --git a/CustomAdaptor/customadaptor.client/src/components/icons/IconSupport.vue b/CustomAdaptor/customadaptor.client/src/components/icons/IconSupport.vue new file mode 100644 index 0000000..7452834 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/icons/IconSupport.vue @@ -0,0 +1,7 @@ + diff --git a/CustomAdaptor/customadaptor.client/src/components/icons/IconTooling.vue b/CustomAdaptor/customadaptor.client/src/components/icons/IconTooling.vue new file mode 100644 index 0000000..660598d --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/components/icons/IconTooling.vue @@ -0,0 +1,19 @@ + + diff --git a/CustomAdaptor/customadaptor.client/src/customadaptor.js b/CustomAdaptor/customadaptor.client/src/customadaptor.js new file mode 100644 index 0000000..62e3513 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/customadaptor.js @@ -0,0 +1,21 @@ +import { ODataV4Adaptor } from '@syncfusion/ej2-data'; +import { setValue } from '@syncfusion/ej2-base'; +export default class CustomAdaptor extends ODataV4Adaptor { + processQuery(dm, query) { + query.addParams('Syncfusion in Vue Grid', 'true'); // Add the additional parameter + return super.processQuery.apply(this, arguments); + } + beforeSend(dm, request, settings) { + request.headers.set('Authorization', `true`); + super.beforeSend(dm, request, settings); + } + processResponse() { + let i = 0; + const original = super.processResponse.apply(this, arguments); + /* Adding serial number */ + if (original.result) { + original.result.forEach((item) => setValue('SNo', ++i, item)); + } + return original; + } +} diff --git a/CustomAdaptor/customadaptor.client/src/main.js b/CustomAdaptor/customadaptor.client/src/main.js new file mode 100644 index 0000000..0ac3a5f --- /dev/null +++ b/CustomAdaptor/customadaptor.client/src/main.js @@ -0,0 +1,6 @@ +import './assets/main.css' + +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/CustomAdaptor/customadaptor.client/vite.config.js b/CustomAdaptor/customadaptor.client/vite.config.js new file mode 100644 index 0000000..1fa3f28 --- /dev/null +++ b/CustomAdaptor/customadaptor.client/vite.config.js @@ -0,0 +1,57 @@ +import { fileURLToPath, URL } from 'node:url'; + +import { defineConfig } from 'vite'; +import plugin from '@vitejs/plugin-vue'; +import fs from 'fs'; +import path from 'path'; +import child_process from 'child_process'; +import { env } from 'process'; + +const baseFolder = + env.APPDATA !== undefined && env.APPDATA !== '' + ? `${env.APPDATA}/ASP.NET/https` + : `${env.HOME}/.aspnet/https`; + +const certificateName = "odatav4adaptor.client"; +const certFilePath = path.join(baseFolder, `${certificateName}.pem`); +const keyFilePath = path.join(baseFolder, `${certificateName}.key`); + +if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { + if (0 !== child_process.spawnSync('dotnet', [ + 'dev-certs', + 'https', + '--export-path', + certFilePath, + '--format', + 'Pem', + '--no-password', + ], { stdio: 'inherit', }).status) { + throw new Error("Could not create certificate."); + } +} + +const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` : + env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'https://localhost:7215'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [plugin()], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + } + }, + server: { + proxy: { + '^/weatherforecast': { + target, + secure: false + } + }, + port: 5173, + https: { + key: fs.readFileSync(keyFilePath), + cert: fs.readFileSync(certFilePath), + } + } +}) diff --git a/README.md b/README.md index 19c089e..262decf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This repository demonstrates how to bind data from various remote services to a * ODataV4Adaptor * GraphQLAdaptor * RemoteSaveAdaptor +* CustomAdaptor ## Prerequisites