diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Images/wallpaper.jpg b/Nop.Plugin.Misc.AuctionPlugin/Content/Images/wallpaper.jpg new file mode 100644 index 0000000..e697db2 Binary files /dev/null and b/Nop.Plugin.Misc.AuctionPlugin/Content/Images/wallpaper.jpg differ diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js index 4b7fdd1..ccfdd5c 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js +++ b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js @@ -4,74 +4,95 @@ const handlers = { announcement: function (data) { var myObject = JSON.parse(data); - toastr.info(`
${myObject.message}
`, myObject.title, { - "closeButton": true, - "positionClass": "toast-bottom-right", - "newestOnTop": true, - "progressBar": true, - "preventDuplicates": false, - "onclick": null, - "showDuration": "30000", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": animation, - "hideMethod": "fadeOut" - }); - $('.toast-info').css("background-color", "#008080"); + + var liveScreen = document.getElementById("auctionProductLiveScreenBox"); + if (!liveScreen) { + toastr.info(`
${myObject.message}
`, myObject.title, { + "closeButton": true, + "positionClass": "toast-bottom-right", + "newestOnTop": true, + "progressBar": true, + "preventDuplicates": false, + "onclick": null, + "showDuration": "30000", + "hideDuration": "1000", + "timeOut": "5000", + "extendedTimeOut": "1000", + "showEasing": "swing", + "hideEasing": "linear", + "showMethod": animation, + "hideMethod": "fadeOut" + }); + $('.toast-info').css("background-color", "#008080"); + } + }, bidNotification: function (data) { console.log(data); - var myObject = JSON.parse(data); - toastr.success(`

${myObject.currentPrice}

${myObject.productName}

`, "New bid arrived", { - "closeButton": true, - "positionClass": "toast-bottom-right", - "newestOnTop": true, - "progressBar": true, - "preventDuplicates": false, - "onclick": null, - "showDuration": "30000", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": animation, - "hideMethod": "fadeOut" - }); - $('.toast-success').css("background-color", "#4caf50"); - + var myObject = JSON.parse(data); + console.log(myObject); var publicProductBidBox = document.getElementById("publicProductBidBox"); + var liveScreen = document.getElementById("auctionProductLiveScreenBox"); if (publicProductBidBox) { refreshPublicBidBox(myObject); } + if (liveScreen) + { + reloadOnUpdate(); + } + if (!liveScreen) { + toastr.success(`

${myObject.currentPrice}

${myObject.productName}

`, "New bid arrived", { + "closeButton": true, + "positionClass": "toast-bottom-right", + "newestOnTop": true, + "progressBar": true, + "preventDuplicates": false, + "onclick": null, + "showDuration": "30000", + "hideDuration": "1000", + "timeOut": "5000", + "extendedTimeOut": "1000", + "showEasing": "swing", + "hideEasing": "linear", + "showMethod": animation, + "hideMethod": "fadeOut" + }); + $('.toast-success').css("background-color", "#4caf50"); + } }, ProductToAuctionStatusNotification: function (data) { console.log(data); var myObject = JSON.parse(data); var auctionDto = myObject.auctionDto; var productToAuctionDto = myObject.auctionDto.productToAuctionDtos[0]; - - toastr.success(`

${productToAuctionDto.auctionStatus}

${productToAuctionDto.id}

`, "Status changed", { - "closeButton": true, - "positionClass": "toast-bottom-right", - "newestOnTop": true, - "progressBar": true, - "preventDuplicates": false, - "onclick": null, - "showDuration": "30000", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": animation, - "hideMethod": "fadeOut" - }); - $('.toast-success').css("background-color", "#4caf50"); + var publicProductBidBox = document.getElementById("publicProductBidBox"); + var liveScreen = document.getElementById("auctionProductLiveScreenBox"); + if (!liveScreen) { + toastr.success(`

${productToAuctionDto.auctionStatus}

${productToAuctionDto.id}

`, "Status changed", { + "closeButton": true, + "positionClass": "toast-bottom-right", + "newestOnTop": true, + "progressBar": true, + "preventDuplicates": false, + "onclick": null, + "showDuration": "30000", + "hideDuration": "1000", + "timeOut": "5000", + "extendedTimeOut": "1000", + "showEasing": "swing", + "hideEasing": "linear", + "showMethod": animation, + "hideMethod": "fadeOut" + }); + $('.toast-success').css("background-color", "#4caf50"); + } + //if (publicProductBidBox) { + // refreshPublicBidBox(myObject); + //} + if (liveScreen) { + reloadOnUpdate(); + } // var publicProductBidBox = document.getElementById("publicProductBidBox"); // if (publicProductBidBox) diff --git a/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs b/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs index 462a082..72646a9 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs @@ -77,18 +77,15 @@ public class AuctionController : BasePluginController public async Task LiveScreen(int auctionId) { - var auctionDto = await _auctionService.GetAuctionDtoByIdAsync(auctionId, true); + var auctionDto = await _auctionService.GetAuctionDtoWithAuctionBids(auctionId, true); + var activeMapping = auctionDto?.ProductToAuctionDtos.MinBy(x => x.SortIndex); + var isAnyItemLive = activeMapping != null; - //var auctionDto = _auctionService.GetAuctionDtoWithAuctionBids(int auctionId, bool activeProductOnly) - - //auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings); - - bool isAnyItemLive = auctionDto.ProductToAuctionDtos.Any(x => x.AuctionStatus == AuctionStatus.Active); var model = new LiveScreenViewModel(auctionDto); Product product; ProductDetailsModel productDetailsModel; - ProductToAuctionDto activeMapping; + int activeProductId = 0; int activeProductToAuctionId = 0; decimal basePrice = 0; diff --git a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs index 2641800..1d26f5a 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs @@ -8,13 +8,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models { public record LiveScreenViewModel : BaseNopModel { - - [JsonIgnore] - [System.Text.Json.Serialization.JsonIgnore] public AuctionDto AuctionDto { get; set; } - - [JsonIgnore] - [System.Text.Json.Serialization.JsonIgnore] public ProductToAuctionDto CurrentProductToAuction { get; set; } public ProductDetailsModel ActiveProductDetails { get; set; } diff --git a/Nop.Plugin.Misc.AuctionPlugin/Nop.Plugin.Misc.AuctionPlugin.csproj b/Nop.Plugin.Misc.AuctionPlugin/Nop.Plugin.Misc.AuctionPlugin.csproj index 9f36c44..418b6c8 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Nop.Plugin.Misc.AuctionPlugin.csproj +++ b/Nop.Plugin.Misc.AuctionPlugin/Nop.Plugin.Misc.AuctionPlugin.csproj @@ -27,6 +27,7 @@ + @@ -80,6 +81,11 @@ Always + + true + PreserveNewest + Always + Always @@ -124,6 +130,9 @@ Always + + Always + Always diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/Auction/LiveScreenRoot.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/Auction/LiveScreenRoot.cshtml index bcdcf04..32e99c2 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/Auction/LiveScreenRoot.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/Auction/LiveScreenRoot.cshtml @@ -13,7 +13,7 @@
-
+
@RenderBody()
diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml index 4acfec9..3a65eee 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml @@ -11,41 +11,17 @@ IStoreContext _storeContext = EngineContext.Current.Resolve(); NopHtml.AddScriptParts(ResourceLocation.Head, "~/Plugins/Misc.AuctionPlugin/Content/Js/signalr.js"); + NopHtml.AddScriptParts(ResourceLocation.Footer, "https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.js"); + // NopHtml.AddScriptParts(ResourceLocation.Footer, "https://cdn.datatables.net/scroller/2.4.3/js/dataTables.scroller.js"); + // NopHtml.AddScriptParts(ResourceLocation.Footer, "https://cdn.datatables.net/scroller/2.4.3/js/scroller.dataTables.js"); NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/MgMessageHandler.js"); NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js"); NopHtml.AddCssFileParts("~/Plugins/Misc.AuctionPlugin/Content/Css/toastr.min.css"); + NopHtml.AddCssFileParts("https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css"); NopHtml.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Misc.AuctionPlugin/Content/Js/toastr.js"); } -@* *@ - -@* *@
\ No newline at end of file diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml index 670dae3..7e3887a 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml @@ -1,6 +1,7 @@ @model LiveScreenViewModel @using Nop.Core.Infrastructure @using Nop.Web.Framework +@using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos; @{ var defaultGridPageSize = EngineContext.Current.Resolve().DefaultGridPageSize; @@ -14,7 +15,7 @@ if (Model.IsAnyItemActive) { -
+
@@ -23,17 +24,16 @@
Bid History
-
- - +
+
+ - - + - +
#Bidder Bid AmountDateAccount
@@ -44,34 +44,35 @@
+
+
+
+

@Model.ActiveProductDetails.Name

+

Created by: @Model.ActiveProductDetails.ProductManufacturers.FirstOrDefault().Name

+
+
+

Item no.: @Model.CurrentProductToAuction.SortIndex

+
+
+
-

@Model.ActiveProductDetails.Name

-

Created by: @Model.ActiveProductDetails.ProductManufacturers.FirstOrDefault().Name

-

Item no.: @Model.CurrentProductToAuction.SortIndex

+
  • - Base price - @(String.Format("{0:c}", Model.BasePrice)) +
    + @await Html.PartialAsync("Product/_ProductSpecifications.cshtml", Model.ActiveProductDetails.ProductSpecificationModel) +
    +
    + Base price + @(String.Format("{0:c}", Model.BasePrice)) +
    +
    + Actual licit step + @(String.Format("{0:c}", Model.LicitStep)) +
  • -
  • - Actual licit step - @(String.Format("{0:c}", Model.LicitStep)) -
  • -
  • - @await Html.PartialAsync("../../../Views/Product/_ProductSpecifications.cshtml", Model.ActiveProductDetails.ProductSpecificationModel) - @* @{ - var dataDictAttributes = new ViewDataDictionary(ViewData); - dataDictAttributes.TemplateInfo.HtmlFieldPrefix = $"attributes_{Model.ProductDetails.Id}"; - @await Html.PartialAsync("../../../Views/Product/_ProductAttributes.cshtml", Model.ProductDetails, dataDictAttributes) - } - *@ -
  • - @*
  • - Material - Oil on Canvas -
  • *@
  • Description:

    @@ -80,9 +81,11 @@

- @@ -94,7 +97,7 @@
-

@Model.AuctionDto.AuctionName

+

@Model.AuctionDto.AuctionName

@@ -102,25 +105,60 @@ } - - - diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/Product/_ProductSpecifications.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/Product/_ProductSpecifications.cshtml new file mode 100644 index 0000000..8ad484d --- /dev/null +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/Product/_ProductSpecifications.cshtml @@ -0,0 +1,73 @@ +@model ProductSpecificationModel + +@using Nop.Core.Domain.Catalog; +@using Nop.Web.Models.Catalog + +@if (Model.Groups.SelectMany(g => g.Attributes).ToList().Count > 0) +{ +
+
+ @T("Products.Specs") +
+
+ + @* + + + + + *@ + + @foreach (var group in Model.Groups) + { + @if (group.Attributes.Count > 0) + { + @if (group.Id > 0) + { + + + + } + + @for (int i = 0; i < group.Attributes.Count; i++) + { + var attr = group.Attributes[i]; + + + + + + } + } + } + +
@T("Products.Specs.AttributeName")@T("Products.Specs.AttributeValue")
+ @group.Name +
+ @attr.Name + + @for (int j = 0; j < attr.Values.Count; j++) + { + var value = attr.Values[j]; + + @if (!string.IsNullOrEmpty(value.ColorSquaresRgb) && (value.AttributeTypeId == (int)SpecificationAttributeType.Option)) + { +
+ +   + +
+ } + else + { + @Html.Raw(value.ValueRaw) + if (j != attr.Values.Count - 1) + { + + } + } + } +
+
+
+} \ No newline at end of file