Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Remove query editor
KrzysztofPajaka08a14e6ffed
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Common/QueryEditor.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Common/QueryEditor.cshtmldeleted file mode 100644index d91798ee4..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Common/QueryEditor.cshtml+++ /dev/null@@ -1,139 +0,0 @@-@model QueryEditor-@inject AdminAreaSettings adminAreaSettings-@{- //page title- ViewBag.Title = Loc["Admin.System.QueryEditor"];-}---<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-sitemap"></i>- @Loc["Admin.System.QueryEditor"]- </div>- <vc:admin-widget widget-zone="queryeditor_buttons" additional-data="null" />- </div>- <div class="x_content form">- <div class="note note-info">- More info about queries you can find: <a target="_blank" href="https://docs.mongodb.com/manual/reference/command/">https://docs.mongodb.com/manual/reference/command/</a>- </div>- <div class="form-horizontal">- <div class="form-body">- <div class="form-group">- <admin-label asp-for="Query" />- <div class="col-4 col-md-8 col-sm-8">- <admin-textarea asp-for="Query" />- </div>- </div>- </div>- <div class="form-actions">- <div class="row">- <div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <button id="btnGenerate" class="btn btn-success filter-submit">- <i class="fa fa-play-circle"></i> @Loc["Admin.Common.RunQuery"]- </button>- <button id="btnScript" class="btn btn-success filter-submit">- <i class="fa fa-caret-square-o-right"></i> @Loc["Admin.Common.RunScript"]- </button>- </div>- </div>- </div>- </div>- </div>- <div class="x_content">- <div id="result"></div>- <div id="queryEditor-grid"></div>- </div>- </div>- </div>-</div>--<script>- $(document).ready(function () {- dataSource = new kendo.data.DataSource({- transport: {- read: {- url: "@Html.Raw(Url.Action("QueryEditor", "Common", new { area = Constants.AreaAdmin }))",- dataType: "json",- data: additionalData,- type: "POST"- }- },- schema:- {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize)- });-- $("#queryEditor-grid").kendoGrid({- autoBind: false,- dataSource: dataSource,- pageable: true,- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false- });- });-- $(document).ready(function () {- $('#btnGenerate').click(function () {- if ($('#@Html.IdFor(model => model.Query)').val().length > 0) {- $('#queryEditor-grid').html('');- $("#queryEditor-grid").kendoGrid({- autoBind: false,- dataSource: dataSource,- pageable: true,- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- });- dataSource.read();- }- });- $('#btnScript').click(function () {- if ($('#@Html.IdFor(model => model.Query)').val().length > 0) {- $.ajax({- cache: false,- type: "POST",- url: "@(Url.Action("RunScript", "Common", new { area = Constants.AreaAdmin }))",- dataType: 'json',- data: additionalData(),- success: function (data) {- if (data.Result == false) {- alert(data.Message);- }- else {- $('#result').html(data.Message);- }- },- error: function () {- alert('Error');- }- });- }- });- });-- function additionalData() {- var data = {- query: $('#@Html.IdFor(model => model.Query)').val()- };- addAntiForgeryToken(data);- return data;- }-</script>diff --git a/src/Web/Grand.Web.Admin/Controllers/CommonController.cs b/src/Web/Grand.Web.Admin/Controllers/CommonController.csindex 80aae8be9..7ea101f14 100644--- a/src/Web/Grand.Web.Admin/Controllers/CommonController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CommonController.cs@@ -55,7 +55,6 @@ namespace Grand.Web.Admin.Controllersprivate readonly IWorkContext _workContext;private readonly ITranslationService _translationService;private readonly IStoreService _storeService;- private readonly IMongoDBContext _mongoDBContext;private readonly IMachineNameProvider _machineNameProvider;private readonly IHostApplicationLifetime _applicationLifetime;private readonly IMediator _mediator;@@ -79,7 +78,6 @@ namespace Grand.Web.Admin.ControllersIWorkContext workContext,ITranslationService translationService,IStoreService storeService,- IMongoDBContext mongoDBContext,IMachineNameProvider machineNameProvider,IHostApplicationLifetime applicationLifetime,IMediator mediator,@@ -103,7 +101,6 @@ namespace Grand.Web.Admin.Controllers_storeService = storeService;_applicationLifetime = applicationLifetime;_appConfig = appConfig;- _mongoDBContext = mongoDBContext;_machineNameProvider = machineNameProvider;_mediaFileStore = mediaFileStore;_mediator = mediator;@@ -424,66 +421,6 @@ namespace Grand.Web.Admin.Controllersreturn Json(gridModel);}- public IActionResult QueryEditor()- {- var model = new QueryEditor();- return View(model);- }-- [HttpPost]- public IActionResult QueryEditor(string query)- {- //https://docs.mongodb.com/manual/reference/command/- if (string.IsNullOrEmpty(query))- return ErrorForKendoGridJson("Empty query");- try- {- var result = _mongoDBContext.RunCommand(query);- var ok = result.Where(x => x.Name == "ok").FirstOrDefault().Value.ToBoolean();- var gridModel = new DataSourceResult();- if (result.Where(x => x.Name == "cursor").ToList().Any())- {- var resultCollection = result["cursor"]["firstBatch"].AsBsonArray.ToList();- var response = _mongoDBContext.Serialize(resultCollection);- gridModel = new DataSourceResult {- Data = response,- Total = response.Count()- };- }- else if (result.Where(x => x.Name == "n").ToList().Any())- {- List<dynamic> n = new List<dynamic>();- var number = result["n"].ToInt64();- n.Add(new { Number = number });- gridModel = new DataSourceResult {- Data = n- };- }- return Json(gridModel);- }- catch (Exception ex)- {- return ErrorForKendoGridJson(ex.Message);- }- }-- [HttpPost]- public IActionResult RunScript(string query)- {- if (string.IsNullOrEmpty(query))- return Json(new { Result = false, Message = "Empty query!" });-- try- {- var result = _mongoDBContext.ExecuteScript(query);- return Json(new { Result = true, Message = result });- }- catch (Exception ex)- {- return Json(new { Result = false, Message = ex.Message });- }- }-public IActionResult SeNames(){var model = new UrlEntityListModel();diff --git a/src/Web/Grand.Web.Admin/Models/Common/QueryEditor.cs b/src/Web/Grand.Web.Admin/Models/Common/QueryEditor.csdeleted file mode 100644index 72cfda60f..000000000--- a/src/Web/Grand.Web.Admin/Models/Common/QueryEditor.cs+++ /dev/null@@ -1,11 +0,0 @@--using Grand.Infrastructure.ModelBinding;--namespace Grand.Web.Admin.Models.Common-{- public partial class QueryEditor- {- [GrandResourceDisplayName("Admin.System.Field.QueryEditor")]- public string Query { get; set; }- }-}diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex fffbf2874..4f54585cd 100644--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml@@ -3864,9 +3864,6 @@<Resource Name="Admin.Common.RunQuery"><Value>Run query</Value></Resource>- <Resource Name="Admin.Common.RunScript">- <Value>Run script (eval)</Value>- </Resource><Resource Name="Admin.Common.Save"><Value>Save</Value></Resource>@@ -11988,9 +11985,6 @@<Resource Name="admin.system.developertools"><Value>Developer Tools</Value></Resource>- <Resource Name="Admin.System.Field.QueryEditor">- <Value>Query</Value>- </Resource><Resource Name="Admin.System.Log"><Value>Log</Value></Resource>@@ -12105,9 +12099,6 @@<Resource Name="Admin.System.Maintenance.DeleteGuests.TotalDeleted"><Value>{0} customers were deleted</Value></Resource>- <Resource Name="Admin.System.QueryEditor">- <Value>Query editor</Value>- </Resource><Resource Name="Admin.System.QueuedEmails"><Value>Message Queue</Value></Resource>