viecomponent logic
This commit is contained in:
parent
e9ac19406e
commit
479914dc8a
|
|
@ -10,7 +10,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Components
|
||||||
{
|
{
|
||||||
// Here you can fetch data for this grid if needed
|
// Here you can fetch data for this grid if needed
|
||||||
// For demo, just pass the model
|
// For demo, just pass the model
|
||||||
return View(model.ViewComponentName +".cshtml", model);
|
return View(model.ViewComponentLocation, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ using System.Text.Json;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Components
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Components
|
||||||
{
|
{
|
||||||
[ViewComponent(Name = "TestChildGrid")]
|
[ViewComponent(Name = "TestGridComponent")]
|
||||||
public class TestChildGridViewComponent : ViewComponent
|
public class TestGridComponent : ViewComponent
|
||||||
{
|
{
|
||||||
public IViewComponentResult Invoke(TestGridModel model)
|
public IViewComponentResult Invoke(TestGridModel model)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
public async Task<IActionResult> OrderList(OrderSearchModel searchModel)
|
public async Task<IActionResult> OrderList(OrderSearchModel searchModel)
|
||||||
{
|
{
|
||||||
//prepare model
|
//prepare model
|
||||||
//var orderListModel = await GetOrderListModelByFilter(searchModel);
|
var orderListModel = await GetOrderListModelByFilter(searchModel);
|
||||||
var orderListModel = new OrderListModel();
|
//var orderListModel = new OrderListModel();
|
||||||
|
|
||||||
var valami = Json(orderListModel);
|
var valami = Json(orderListModel);
|
||||||
Console.WriteLine(valami);
|
Console.WriteLine(valami);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using DevExtreme.AspNet.Mvc.FileManagement;
|
using DevExtreme.AspNet.Mvc.FileManagement;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DevExtreme.NETCore.Demos.Controllers
|
namespace DevExtreme.NETCore.Demos.Controllers
|
||||||
|
|
@ -20,12 +21,15 @@ namespace DevExtreme.NETCore.Demos.Controllers
|
||||||
[Route("api/file-manager-file-system", Name = "FileManagementFileSystemApi")]
|
[Route("api/file-manager-file-system", Name = "FileManagementFileSystemApi")]
|
||||||
public object FileSystem(FileSystemCommand command, string arguments, int orderId)
|
public object FileSystem(FileSystemCommand command, string arguments, int orderId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
string path = Request.Headers["TestHeader"];
|
||||||
|
|
||||||
var valami = new List<int>();
|
var valami = new List<int>();
|
||||||
|
|
||||||
var config = new FileSystemConfiguration
|
var config = new FileSystemConfiguration
|
||||||
{
|
{
|
||||||
Request = Request,
|
Request = Request,
|
||||||
FileSystemProvider = new PhysicalFileSystemProvider(_webHostEnvironment.ContentRootPath + $"/wwwroot/uploads/orders/{orderId}"),
|
FileSystemProvider = new PhysicalFileSystemProvider(_webHostEnvironment.ContentRootPath + $"/wwwroot/uploads/orders/order{path}"),
|
||||||
//uncomment the code below to enable file/folder management
|
//uncomment the code below to enable file/folder management
|
||||||
//AllowCopy = true,
|
//AllowCopy = true,
|
||||||
//AllowCreate = true,
|
//AllowCreate = true,
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,30 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
var testGridModel2 = new TestGridModel();
|
var testGridModel2 = new TestGridModel();
|
||||||
testGridModel2.GridName = "Orders";
|
testGridModel2.GridName = "Orders";
|
||||||
testGridModel2.ViewComponentName = "ShippingDocumentGridComponent";
|
testGridModel2.ViewComponentName = "ShippingDocumentGridComponent";
|
||||||
|
testGridModel2.ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/ShippingDocumentGridComponent.cshtml";
|
||||||
|
testGridModel2.Configuration = new GridConfiguration();
|
||||||
|
testGridModel2.Configuration.ShowChildGridsAsTabs = true;
|
||||||
testGridModel2.ChildGrids = new List<TestGridModel>();
|
testGridModel2.ChildGrids = new List<TestGridModel>();
|
||||||
var childGrid1 = new TestGridModel
|
var childGrid1 = new TestGridModel
|
||||||
{
|
{
|
||||||
GridName = "TestGrid",
|
GridName = "TestGrid",
|
||||||
ViewComponentName = "TestGridComponent",
|
ViewComponentName = "TestGridComponent",
|
||||||
|
ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/TestGridComponent.cshtml",
|
||||||
ParentGridId = testGridModel2.Id,
|
ParentGridId = testGridModel2.Id,
|
||||||
ChildGrids = new List<TestGridModel>()
|
ChildGrids = new List<TestGridModel>()
|
||||||
};
|
};
|
||||||
testGridModel2.Configuration = new GridConfiguration();
|
|
||||||
testGridModel2.Configuration.ShowChildGridsAsTabs = true;
|
|
||||||
testGridModel2.ChildGrids.Add(childGrid1);
|
testGridModel2.ChildGrids.Add(childGrid1);
|
||||||
|
|
||||||
|
var childGrid2 = new TestGridModel
|
||||||
|
{
|
||||||
|
GridName = "Files",
|
||||||
|
ViewComponentName = "FileUploadGridComponent",
|
||||||
|
ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/FileUploadGridComponent.cshtml",
|
||||||
|
ParentGridId = testGridModel2.Id,
|
||||||
|
ChildGrids = new List<TestGridModel>()
|
||||||
|
};
|
||||||
|
testGridModel2.ChildGrids.Add(childGrid2);
|
||||||
|
|
||||||
|
|
||||||
testPageModel.Grids.Add(testGridModel2);
|
testPageModel.Grids.Add(testGridModel2);
|
||||||
|
|
||||||
|
|
@ -72,7 +84,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> LoadChildGrid([FromBody] LoadChildGridRequest request)
|
public IActionResult LoadChildGrid([FromBody] LoadChildGridRequest request)
|
||||||
{
|
{
|
||||||
// request.contextId is the actual row ID (data.Id from DevExtreme)
|
// request.contextId is the actual row ID (data.Id from DevExtreme)
|
||||||
// request.childModel is the full TestGridModel object
|
// request.childModel is the full TestGridModel object
|
||||||
|
|
@ -84,9 +96,17 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
request.ChildModel.DataContext["contextId"] = request.ContextId;
|
request.ChildModel.DataContext["contextId"] = request.ContextId;
|
||||||
|
|
||||||
// Invoke the view component with the full model
|
// Invoke the view component with the full model
|
||||||
return ViewComponent(request.ChildModel.ViewComponentLocation, new { model = request.ChildModel });
|
return ViewComponent(request.ChildModel.ViewComponentName, request.ChildModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request model for deserialization
|
||||||
|
public class LoadChildGridRequest
|
||||||
|
{
|
||||||
|
public int ContextId { get; set; } // The actual row ID from data.Id
|
||||||
|
public TestGridModel ChildModel { get; set; } // The full child grid model
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetShippings()
|
public async Task<IActionResult> GetShippings()
|
||||||
{
|
{
|
||||||
|
|
@ -165,16 +185,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Request model for deserialization
|
|
||||||
public class LoadChildGridRequest
|
|
||||||
{
|
|
||||||
public int ContextId { get; set; } // The actual row ID from data.Id
|
|
||||||
public TestGridModel ChildModel { get; set; } // The full child grid model
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[RequestSizeLimit(10485760)] // 10MB
|
[RequestSizeLimit(10485760)] // 10MB
|
||||||
[RequestFormLimits(MultipartBodyLengthLimit = 10485760)]
|
[RequestFormLimits(MultipartBodyLengthLimit = 10485760)]
|
||||||
|
|
@ -256,7 +266,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
string analysisPrompt = "Extract the document identification number from this document, determine the type of the " +
|
string analysisPrompt = "Extract the document identification number from this document, determine the type of the " +
|
||||||
"document from the available list, and return them as JSON: documentNumber, documentType. " +
|
"document IN ENGLISH from the available list, and return them as JSON: documentNumber, documentType. " +
|
||||||
$"Available filetypes: {nameof(DocumentType.Invoice)}, {nameof(DocumentType.ShippingDocument)} , {nameof(DocumentType.OrderConfirmation)}, {nameof(DocumentType.Unknown)}" +
|
$"Available filetypes: {nameof(DocumentType.Invoice)}, {nameof(DocumentType.ShippingDocument)} , {nameof(DocumentType.OrderConfirmation)}, {nameof(DocumentType.Unknown)}" +
|
||||||
"If you can't find information of any of these, return null value for that field.";
|
"If you can't find information of any of these, return null value for that field.";
|
||||||
|
|
||||||
|
|
@ -266,10 +276,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
var extractedMetaData = ParseMetaDataAIResponse(metaAnalyzis);
|
var extractedMetaData = ParseMetaDataAIResponse(metaAnalyzis);
|
||||||
|
|
||||||
if (extractedMetaData.DocumentNumber != null)
|
if (extractedMetaData.DocumentNumber != null)
|
||||||
|
{
|
||||||
dbFile.RawText = pdfText;
|
dbFile.RawText = pdfText;
|
||||||
dbFile.FileExtension = "pdf";
|
dbFile.FileExtension = "pdf";
|
||||||
dbFile.FileName = extractedMetaData.DocumentNumber;
|
dbFile.FileName = extractedMetaData.DocumentNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// - IF WE DON'T HAVE PARTNERID ALREADY: read partner information
|
// - IF WE DON'T HAVE PARTNERID ALREADY: read partner information
|
||||||
// (check if all 3 refers to the same partner)
|
// (check if all 3 refers to the same partner)
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,30 @@
|
||||||
@using DevExtreme.AspNet.Mvc
|
@using DevExtreme.AspNet.Mvc
|
||||||
|
|
||||||
@{
|
@{
|
||||||
if (Model.DataContext["contextId"] != null)
|
|
||||||
|
|
||||||
|
if (Model.DataContext.ContainsKey("contextId"))
|
||||||
{
|
{
|
||||||
var contextId = Model.DataContext["contextId"];
|
|
||||||
<text>
|
<text>
|
||||||
<h4>contextId</h4>
|
<h4>@Model.DataContext["contextId"]</h4>
|
||||||
</text>
|
</text>
|
||||||
})
|
}
|
||||||
// var gridId = $"dataGrid_{Guid.NewGuid():N}";
|
// var gridId = $"dataGrid_{Guid.NewGuid():N}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@{
|
||||||
|
var contextId = Model.DataContext["contextId"];
|
||||||
|
var fileManagerId = $"fileManager_{contextId}";
|
||||||
|
var beforeAjaxSendFunctionName = $"beforeAjaxSend_{contextId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<p> @Model.DataContext["contextId"], @Model.GridName, @Model.ViewComponentName </p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|
||||||
@Model.DataContext["contextId"], @Model.GridName, @Model.ViewComponentName
|
<form method="post" enctype="multipart/form-data" asp-controller="ManagementPage" asp-action="UploadFile">
|
||||||
@* <form method="post" enctype="multipart/form-data" asp-controller="ManagementPage" asp-action="UploadFile">
|
|
||||||
@(Html.DevExtreme().FileUploader()
|
@(Html.DevExtreme().FileUploader()
|
||||||
.ID("shippingDocumentUploader-" + contextId)
|
.ID("shippingDocumentUploader-" + contextId)
|
||||||
.Name("files")
|
.Name("files")
|
||||||
|
|
@ -26,9 +34,9 @@
|
||||||
.UploadMode(FileUploadMode.UseForm)
|
.UploadMode(FileUploadMode.UseForm)
|
||||||
)
|
)
|
||||||
<input type="hidden" name="ShippingDocumentId" value="@contextId" />
|
<input type="hidden" name="ShippingDocumentId" value="@contextId" />
|
||||||
<% if (data.PartnerId) { %>
|
|
||||||
<input type="hidden" name="PartnerId" value="hello" />
|
<input type="hidden" name="PartnerId" value="hello" />
|
||||||
<% } %>
|
|
||||||
@(Html.DevExtreme().Button()
|
@(Html.DevExtreme().Button()
|
||||||
.Text("Upload Files")
|
.Text("Upload Files")
|
||||||
.Type(ButtonType.Success)
|
.Type(ButtonType.Success)
|
||||||
|
|
@ -39,16 +47,16 @@
|
||||||
<div>
|
<div>
|
||||||
<h4>Selected Files</h4>
|
<h4>Selected Files</h4>
|
||||||
</div>
|
</div>
|
||||||
</div> *@
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
@* @(Html.DevExtreme().FileManager()
|
@(Html.DevExtreme().FileManager()
|
||||||
.ID("fileManager_"+ contextId)
|
.ID(fileManagerId)
|
||||||
.FileSystemProvider(provider => provider.Remote()
|
.FileSystemProvider(provider => provider.Remote()
|
||||||
.Url(Url.RouteUrl("FileManagementFileSystemApi"))
|
.Url(Url.RouteUrl("FileManagementFileSystemApi"))
|
||||||
.BeforeAjaxSend(@<text>
|
.BeforeAjaxSend(@<text>
|
||||||
function(e) {
|
function(arg) {
|
||||||
e.ajaxSettings.data.orderId = data.Id;
|
arg.headers.TestHeader = @Model.DataContext["contextId"];
|
||||||
}
|
}
|
||||||
</text>))
|
</text>))
|
||||||
.Permissions(permissions => {
|
.Permissions(permissions => {
|
||||||
|
|
@ -56,11 +64,9 @@
|
||||||
permissions.Upload(true);
|
permissions.Upload(true);
|
||||||
})
|
})
|
||||||
.AllowedFileExtensions(new[] { ".pdf", ".jpg", ".jpeg" })
|
.AllowedFileExtensions(new[] { ".pdf", ".jpg", ".jpeg" })
|
||||||
) *@
|
)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function fileUploader_valueChanged(e) {
|
function fileUploader_valueChanged(e) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
@model Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.TestGridModel
|
@model Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.TestGridModel
|
||||||
@using DevExtreme.AspNet.Mvc
|
@using DevExtreme.AspNet.Mvc
|
||||||
|
@Html.AntiForgeryToken()
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@(
|
@(
|
||||||
|
|
@ -131,6 +132,9 @@
|
||||||
url: '@Url.Action("LoadChildGrid", "ManagementPage")',
|
url: '@Url.Action("LoadChildGrid", "ManagementPage")',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
|
headers: {
|
||||||
|
'RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
|
||||||
|
},
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
contextId: contextId,
|
contextId: contextId,
|
||||||
childModel: childModel
|
childModel: childModel
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>@kvp.Key</strong></td>
|
<td><strong>@kvp.Key</strong></td>
|
||||||
<td>@kvp.Value</td>
|
<td>@kvp.Value</td>
|
||||||
<td><em>@kvp.Value?.GetType().Name</em></td>
|
<td><em>@kvp.Value.GetType().Name</em></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,11 @@ public class RouteProvider : IRouteProvider
|
||||||
pattern: "Admin/ManagementPage/GetPartners",
|
pattern: "Admin/ManagementPage/GetPartners",
|
||||||
defaults: new { controller = "ManagementPage", action = "GetPartners", area = AreaNames.ADMIN });
|
defaults: new { controller = "ManagementPage", action = "GetPartners", area = AreaNames.ADMIN });
|
||||||
|
|
||||||
|
endpointRouteBuilder.MapControllerRoute(
|
||||||
|
name: "Plugin.FruitBank.Admin.ManagementPage.LoadChildGrid",
|
||||||
|
pattern: "Admin/ManagementPage/LoadChildGrid",
|
||||||
|
defaults: new { controller = "ManagementPage", action = "LoadChildGrid", area = AreaNames.ADMIN });
|
||||||
|
|
||||||
endpointRouteBuilder.MapControllerRoute(
|
endpointRouteBuilder.MapControllerRoute(
|
||||||
name: "Plugin.FruitBank.Admin.Products.List",
|
name: "Plugin.FruitBank.Admin.Products.List",
|
||||||
pattern: "Admin/Product/List",
|
pattern: "Admin/Product/List",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue