Merge branch 'main' of https://git2.aycode.com/Adam/Mango.Nop.Plugins
This commit is contained in:
commit
7851e8a8ee
|
|
@ -1,20 +1,23 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
using Nop.Web.Areas.Admin.Controllers;
|
||||
//using Nop.Web.Framework.Kendoui;
|
||||
using Nop.Web.Framework;
|
||||
using Nop.Web.Framework.Controllers;
|
||||
using Nop.Web.Framework.Mvc;
|
||||
using Nop.Web.Framework.Mvc.Filters;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Controllers
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||
{
|
||||
|
||||
public class LiveAnnouncementController : BaseAdminController
|
||||
[AutoValidateAntiforgeryToken]
|
||||
[AuthorizeAdmin]
|
||||
[Area(AreaNames.ADMIN)]
|
||||
public class AnnouncementController : BasePluginController
|
||||
{
|
||||
|
||||
#region Field
|
||||
|
|
@ -26,7 +29,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Controllers
|
|||
|
||||
#region Ctr
|
||||
|
||||
public LiveAnnouncementController(
|
||||
public AnnouncementController(
|
||||
IAnnouncementService announcementService,
|
||||
IHubContext<AuctionHub> announcementHubContext)
|
||||
{
|
||||
|
|
@ -41,7 +44,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Controllers
|
|||
public IActionResult GetAnnouncementViewModel()
|
||||
{
|
||||
var model = new AnnouncementViewModel();
|
||||
return View("~/Plugins/Misc.AuctionPlugin/Admin/Views/Announcement.cshtml", model);
|
||||
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Announcement.cshtml", model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
|
@ -74,7 +77,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Controllers
|
|||
|
||||
if (model.IsActive == true)
|
||||
{
|
||||
_announcementHubContext.Clients.All.SendAsync("send", model.Body.ToString());
|
||||
await _announcementHubContext.Clients.All.SendAsync("send", model.Body.ToString());
|
||||
}
|
||||
return RedirectToAction("AnnouncementList");
|
||||
|
||||
|
|
@ -104,7 +107,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Controllers
|
|||
public IActionResult AnnouncementList()
|
||||
{
|
||||
var model = new AnnouncementViewModel();
|
||||
return View("~/Plugins/Widget.LiveAnnouncement/Views/LiveAnnouncementView/AnnouncementList.cshtml", model);
|
||||
return View("~/Plugins/Misc.Auction/Areas/Admin/Views/AnnouncementList.cshtml", model);
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
|
|
@ -2,8 +2,14 @@
|
|||
using Nop.Web.Framework.Controllers;
|
||||
using Nop.Web.Framework.Mvc.Filters;
|
||||
using Nop.Web.Framework;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||
using Nop.Services.Configuration;
|
||||
using Nop.Plugin.Misc.AuctionPlugin;
|
||||
using Nop.Services.Messages;
|
||||
using Nop.Services.Localization;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
||||
|
||||
[AutoValidateAntiforgeryToken]
|
||||
[AuthorizeAdmin]
|
||||
|
|
@ -11,16 +17,53 @@ using Nop.Plugin.Misc.AuctionPlugin.Models;
|
|||
public class AuctionPluginAdminController : BasePluginController
|
||||
{
|
||||
//private readonly SignalRservice _signalRservice;
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly ISettingService _settingService;
|
||||
private readonly AuctionSettings _auctionSettings;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
//public AuctionPluginAdminController(SignalRservice signalRservice)
|
||||
public AuctionPluginAdminController()
|
||||
public AuctionPluginAdminController(ILocalizationService localizationService, INotificationService notificationService, ISettingService settingService, AuctionSettings auctionSettings, ILogger logger)
|
||||
{
|
||||
_localizationService = localizationService;
|
||||
_notificationService = notificationService;
|
||||
_settingService = settingService;
|
||||
_auctionSettings = auctionSettings;
|
||||
//_signalRservice = signalRservice;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Configure(bool showtour = false)
|
||||
{
|
||||
return View("~/Plugins/Misc.AuctionPlugin/Views/Configure.cshtml", new ConfigurationModel());
|
||||
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Configure.cshtml", new ConfigurationModel());
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Configure")]
|
||||
[FormValueRequired("save")]
|
||||
public async Task<IActionResult> Configure(ConfigurationModel model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
|
||||
await _logger.ErrorAsync($"Auction configuration model error: invalid modelstate!");
|
||||
return await Configure();
|
||||
|
||||
}
|
||||
|
||||
if (_auctionSettings.SomeText != model.Test)
|
||||
{
|
||||
_auctionSettings.SomeText = model.Test;
|
||||
await _logger.InformationAsync($"Auction configuration saving: {_auctionSettings.SomeText}");
|
||||
|
||||
}
|
||||
|
||||
await _settingService.SaveSettingAsync(_auctionSettings);
|
||||
await _logger.InformationAsync($"Auction configuration saved: {_auctionSettings.SomeText}");
|
||||
//_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Plugins.Saved"));
|
||||
_notificationService.SuccessNotification("Saved");
|
||||
|
||||
return await Configure();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using Nop.Web.Framework.Models;
|
||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
|
||||
{
|
||||
public record AnnouncementViewModel : BaseNopModel
|
||||
{
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using Nop.Web.Framework.Models;
|
||||
using Nop.Web.Framework.Mvc;
|
||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration model
|
||||
|
|
@ -14,7 +13,7 @@ public record ConfigurationModel : BaseNopModel
|
|||
|
||||
public ConfigurationModel()
|
||||
{
|
||||
Test = "";
|
||||
Test = "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@model Nop.Plugin.Misc.AuctionPlugin.Models.AnnouncementViewModel
|
||||
@model AnnouncementViewModel
|
||||
@using Nop.Core.Infrastructure
|
||||
@using Nop.Web.Framework
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@model Nop.Plugin.Widget.LiveAnnouncement.Models.AnnouncementModel
|
||||
@model AnnouncementViewModel
|
||||
@using Nop.Core.Infrastructure
|
||||
@using Nop.Web.Framework
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
NopHtml.SetActiveMenuItemSystemName("API plugins");
|
||||
}
|
||||
|
||||
<form asp-controller="SignalRApiAdmin" asp-action="Configure" method="post" id="configuration-form">
|
||||
<form asp-controller="AuctionPluginAdmin" asp-action="Configure" method="post" id="configuration-form">
|
||||
<div class="cards-group">
|
||||
<div class="card card-default no-margin">
|
||||
|
||||
|
|
@ -35,9 +35,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<nop-label asp-for="Test" />
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<nop-editor asp-for="Test" asp-required="true" html-attributes="@(new { value = Model.Test })" />
|
||||
<span asp-validation-for="Test"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-9 offset-md-3">
|
||||
<button type="submit" name="credentials" class="btn btn-primary">@T("Admin.Common.Save")</button>
|
||||
<button type="submit" name="save" class="btn btn-primary">@T("Admin.Common.Save")</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -81,29 +91,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// // Send AJAX request to TestHubConnection action
|
||||
// fetch('@Url.Action("TestHubConnection", "SignalRApi")', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'RequestVerificationToken': 'addAntiForgeryToken(postData);'
|
||||
// }
|
||||
// })
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// // Update the result based on response
|
||||
// if (data.success) {
|
||||
// document.getElementById("test-hub-result").innerText = data.message;
|
||||
// } else {
|
||||
// document.getElementById("test-hub-result").innerText = data.message;
|
||||
// }
|
||||
// })
|
||||
// .catch(error => {
|
||||
// document.getElementById("test-hub-result").innerText = "Error: " + error;
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@
|
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@addTagHelper *, Nop.Web.Framework
|
||||
|
||||
@inject INopHtmlHelper NopHtml
|
||||
|
||||
@using Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
@using Nop.Web.Framework.UI
|
||||
@using Nop.Web.Framework.Extensions
|
||||
@using System.Text.Encodings.Web
|
||||
@using Nop.Services.Events
|
||||
@using Nop.Web.Framework.Events
|
||||
@using Nop.Core.Infrastructure
|
||||
@using Nop.Core.Infrastructure
|
||||
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
||||
|
|
@ -26,6 +26,7 @@ public static class AuctionDefaults
|
|||
/// Gets the hub route name
|
||||
/// </summary>
|
||||
public static string AnnouncementRouteName => "Plugin.Misc.AuctionPlugin.Announcement";
|
||||
public static string AnnouncementListRouteName => "Plugin.Misc.AuctionPlugin.AnnouncementList";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of autosuggest component
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
|||
|
||||
public override string GetConfigurationPageUrl()
|
||||
{
|
||||
return _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext).RouteUrl("Plugin.Misc.SignalRApi.Configure");
|
||||
return _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext).RouteUrl(AuctionDefaults.ConfigurationRouteName);
|
||||
}
|
||||
|
||||
public override async Task InstallAsync()
|
||||
|
|
@ -140,12 +140,21 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
|||
rootNode.ChildNodes.Add(liveAnnouncementPluginNode);
|
||||
}
|
||||
|
||||
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||
{
|
||||
Title = await _localizationService.GetResourceAsync("Plugins.Configure"),
|
||||
Visible = true,
|
||||
IconClass = "fa-dot-circle-o",
|
||||
Url = "~/Admin/AuctionPlugin/Configure"
|
||||
|
||||
});
|
||||
|
||||
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||
{
|
||||
Title = await _localizationService.GetResourceAsync("Misc.Announcement"),
|
||||
Visible = true,
|
||||
IconClass = "fa-dot-circle-o",
|
||||
Url = "~/Admin/Announcement"
|
||||
Url = "~/Admin/Announcement/GetAnnouncementViewModel"
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -156,7 +165,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
|||
Title = await _localizationService.GetResourceAsync("Misc.AnnouncementList"),
|
||||
Visible = true,
|
||||
IconClass = "fa-dot-circle-o",
|
||||
Url = "~/Admin/LiveAnnouncement/AnnouncementList"
|
||||
Url = "~/Admin/Announcement/AnnouncementList"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities
|
|||
{
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Body { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public string Body { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,24 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Infrastructure;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
using Nop.Services.Catalog;
|
||||
using Nop.Services.Configuration;
|
||||
using Nop.Services.Localization;
|
||||
using Nop.Web.Framework;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||
{
|
||||
public class PluginNopStartup : INopStartup
|
||||
{
|
||||
|
||||
public int Order => 999;
|
||||
/// <summary>
|
||||
/// Add and configure any of the middleware
|
||||
|
|
@ -30,9 +38,19 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
});
|
||||
|
||||
//register services and interfaces
|
||||
//IRepository<AuctionBid> _customerBidRepository;
|
||||
//protected readonly IShortTermCacheManager _shortTermCacheManager;
|
||||
// protected readonly IStaticCacheManager _staticCacheManager;
|
||||
|
||||
services.AddScoped<ILocalizationService, LocalizationService>();
|
||||
services.AddScoped<ISettingService, SettingService>();
|
||||
services.AddScoped<EventConsumer>();
|
||||
services.AddScoped<IWorkContext, WebWorkContext>();
|
||||
services.AddScoped<IAnnouncementService, AnnouncementService>();
|
||||
services.AddScoped<IAuctionService, AuctionService>();
|
||||
services.AddScoped<EventConsumer>();
|
||||
services.AddScoped<IProductAttributeService, ProductAttributeService>();
|
||||
services.AddScoped<UrlHelperFactory>();
|
||||
services.AddScoped<IActionContextAccessor, ActionContextAccessor>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
|
||||
//announcement admin
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AnnouncementRouteName,
|
||||
pattern: "Admin/AuctionPluginAdmin/Announcement",
|
||||
defaults: new { controller = "Announcement", action = "Announcement", area = AreaNames.ADMIN });
|
||||
pattern: "Admin/Announcement/GetAnnouncementViewModel",
|
||||
defaults: new { controller = "Announcement", action = "GetAnnouncementViewModel" });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AnnouncementListRouteName,
|
||||
pattern: "Admin/Announcement/AnnouncementList",
|
||||
defaults: new { controller = "Announcement", action = "AnnouncementList"});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class AnnouncementBuilder : NopEntityBuilder<Announcement>
|
|||
.NotNullable()
|
||||
.WithColumn(nameof(Announcement.IsActive))
|
||||
.AsBoolean()
|
||||
.NotNullable().WithDefault(0)
|
||||
.NotNullable()
|
||||
.WithColumn(nameof(Announcement.Body))
|
||||
.AsString(500)
|
||||
.NotNullable()
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputPath>..\..\..\..\NopCommerce\Presentation\Nop.Web\Plugins\Nop.Plugin.Misc.AuctionPlugin</OutputPath>
|
||||
<OutputPath>..\..\..\..\NopCommerce\Presentation\Nop.Web\Plugins\Misc.AuctionPlugin</OutputPath>
|
||||
<OutDir>$(OutputPath)</OutDir>
|
||||
<!--Set this parameter to true to get the dlls copied from the NuGet cache to the output of your project.
|
||||
You need to set this parameter to true if your plugin has a nuget package
|
||||
to ensure that the dlls copied from the NuGet cache to the output of your project-->
|
||||
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Areas\Admin\Views\_ViewImports.cshtml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Views\_ViewImports.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
|
@ -80,7 +81,6 @@
|
|||
<Folder Include="Areas\Admin\Components\" />
|
||||
<Folder Include="Areas\Admin\Extensions\" />
|
||||
<Folder Include="Areas\Admin\Factories\" />
|
||||
<Folder Include="Areas\Admin\Models\" />
|
||||
<Folder Include="Areas\Admin\Validators\" />
|
||||
<Folder Include="Extensions\" />
|
||||
<Folder Include="Factories\" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue