Merge branch 'main' of https://git2.aycode.com/Adam/Mango.Nop.Plugins
This commit is contained in:
commit
9086ec28c9
|
|
@ -1,9 +1,23 @@
|
||||||
// Define the message handler library
|
$(function () {
|
||||||
|
|
||||||
// SignalR connection setup
|
|
||||||
$(function () {
|
|
||||||
console.log("signalRJs Starts");
|
console.log("signalRJs Starts");
|
||||||
|
|
||||||
|
// AuctionStatus Enum
|
||||||
|
window.AuctionStatus = Object.freeze({
|
||||||
|
None: 0,
|
||||||
|
Active: 1,
|
||||||
|
FirstWarning: 2,
|
||||||
|
SecondWarning: 4,
|
||||||
|
SoldOut: 8,
|
||||||
|
NotSold: 16
|
||||||
|
});
|
||||||
|
|
||||||
|
// HUF Formatter
|
||||||
|
window.HUFFormatter = new Intl.NumberFormat('hu-HU', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'HUF',
|
||||||
|
});
|
||||||
|
|
||||||
|
// SignalR connection setup
|
||||||
var connection = new signalR.HubConnectionBuilder()
|
var connection = new signalR.HubConnectionBuilder()
|
||||||
.withUrl('/auctionhub')
|
.withUrl('/auctionhub')
|
||||||
.build();
|
.build();
|
||||||
|
|
@ -24,6 +38,7 @@ $(function () {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Global function to send a message to the server
|
||||||
window.sendMessageToServer = function (messageType, senderId, data) {
|
window.sendMessageToServer = function (messageType, senderId, data) {
|
||||||
var messageWrapper = {
|
var messageWrapper = {
|
||||||
MessageType: messageType,
|
MessageType: messageType,
|
||||||
|
|
@ -42,94 +57,3 @@ $(function () {
|
||||||
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to send a message to the server
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$(function () {
|
|
||||||
|
|
||||||
// console.log("signalRJs Starts");
|
|
||||||
// var connection = new signalR.HubConnectionBuilder()
|
|
||||||
// .withUrl('/auctionhub')
|
|
||||||
// .build();
|
|
||||||
|
|
||||||
// connection.on('send', data => {
|
|
||||||
// showannouncement(data);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// function start() {
|
|
||||||
// connection.start().catch(function (err) {
|
|
||||||
// setTimeout(function () {
|
|
||||||
// start();
|
|
||||||
// }, 100000);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// connection.onclose(function () {
|
|
||||||
// start();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// start();
|
|
||||||
//});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//function showannouncement(announcemant) {
|
|
||||||
// console.log("announcement arrived!");
|
|
||||||
// if (announcemant) {
|
|
||||||
// toastr.options = {
|
|
||||||
// "closeButton": true,
|
|
||||||
// "debug": false,
|
|
||||||
// "newestOnTop": false,
|
|
||||||
// "progressBar": false,
|
|
||||||
// "positionClass": "toast-bottom-right",
|
|
||||||
// "preventDuplicates": false,
|
|
||||||
// "onclick": null,
|
|
||||||
// "showDuration": 300,
|
|
||||||
// "hideDuration": 10000,
|
|
||||||
// "timeOut": 100000,
|
|
||||||
// "extendedTimeOut": 20000,
|
|
||||||
// "showEasing": "swing",
|
|
||||||
// "hideEasing": "linear",
|
|
||||||
// "showMethod": "fadeIn",
|
|
||||||
// "hideMethod": "fadeOut"
|
|
||||||
// };
|
|
||||||
|
|
||||||
// tostView = '<div class="item announcemantToast">' + announcemant + '</div>'
|
|
||||||
// toastr["info"](tostView);
|
|
||||||
// $('.toast-info').css("background-color", "#008080");
|
|
||||||
|
|
||||||
// toastr.options.onclick = function () {
|
|
||||||
// $("html, body").animate(
|
|
||||||
// { scrollTop: 0 },
|
|
||||||
// 1000);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $(".toast").click(function () {
|
|
||||||
// $("html, body").animate(
|
|
||||||
// { scrollTop: 0 },
|
|
||||||
// 1000);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// $(".toast-info").click(function () {
|
|
||||||
// $("html, body").animate(
|
|
||||||
// { scrollTop: 0 },
|
|
||||||
// 1000);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// toastr.options = {
|
|
||||||
// onclick: function () {
|
|
||||||
// $("html, body").animate(
|
|
||||||
// { scrollTop: 0 },
|
|
||||||
// 1000);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $(".announcemantToast").on("click", function () {
|
|
||||||
// $("html, body").animate(
|
|
||||||
// { scrollTop: 0 },
|
|
||||||
// 1000);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using Nop.Web.Framework.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
using Nop.Web.Framework.Models;
|
||||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||||
|
using Nop.Web.Models.Catalog;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
{
|
{
|
||||||
|
|
@ -8,11 +10,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
public int ProductToAuctionMappingId { get; set; }
|
|
||||||
|
|
||||||
public DateTime StartDate { get; set; }
|
public DateTime StartDate { get; set; }
|
||||||
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
public AuctionDto CurrentAuction { get; set; }
|
||||||
|
|
||||||
|
public ProductDetailsModel ProductDetails { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,33 @@
|
||||||
<div id="publicProductBidBoxAdmin" class="p-3 bg-primary text-white">
|
<div id="publicProductBidBoxAdmin" class="p-3 bg-primary text-white">
|
||||||
<h4>Manage auction!</h4>
|
<h4>Manage auction!</h4>
|
||||||
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
||||||
<button id="signalROpenItemButton" class="btn btn-secondary" style="text-transform: uppercase;" type="button">
|
@{
|
||||||
Activate item
|
if(Model.IsItemActive)
|
||||||
</button>
|
{
|
||||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||||
First warning
|
First warning
|
||||||
</button>
|
</button>
|
||||||
|
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||||
|
First warning
|
||||||
|
</button>
|
||||||
|
<button id="signalRCloseItemButton" class="btn btn-secondary" style="text-transform: uppercase;" type="button">
|
||||||
|
Deactivate item
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
// else if(Model.)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<button id="signalROpenItemButton" class="btn btn-secondary" style="text-transform: uppercase;" type="button">
|
||||||
|
Activate item
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
@ -116,13 +137,16 @@
|
||||||
document.getElementById("signalROpenItemButton").disabled = true;
|
document.getElementById("signalROpenItemButton").disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var openItemMessage = {
|
handleAuctionStatusChange(AuctionStatus.Active);
|
||||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
|
||||||
AdminId: bidBoxPageViewModel.CustomerId
|
return false;
|
||||||
};
|
});
|
||||||
var content = JSON.stringify(openItemMessage);
|
$("#signalRCloseItemButton").on("click", function () {
|
||||||
console.log(content);
|
|
||||||
sendMessageToServer("OpenItemRequestMessage", bidBoxPageViewModel.CustomerId, content);
|
document.getElementById("signalRCloseItemButton").disabled = true;
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
handleAuctionStatusChange(AuctionStatus.SoldOut);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
@ -131,25 +155,48 @@
|
||||||
document.getElementById("signalRFirstWarningButton").disabled = true;
|
document.getElementById("signalRFirstWarningButton").disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var itemFirstWarningMessage = {
|
handleAuctionStatusChange(AuctionStatus.FirstWarning);
|
||||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
|
||||||
AdminId: bidBoxPageViewModel.CustomerId
|
return false;
|
||||||
};
|
});
|
||||||
var content = JSON.stringify(itemFirstWarningMessage);
|
$("#signalRSecondWarningButton").on("click", function () {
|
||||||
console.log(content);
|
|
||||||
sendMessageToServer("FirstWarningMessage", bidBoxPageViewModel.CustomerId, content);
|
document.getElementById("signalRSecondWarningButton").disabled = true;
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
handleAuctionStatusChange(AuctionStatus.SecondWarning);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function handleAuctionStatusChange(auctionStatus) {
|
||||||
|
|
||||||
|
// Create the message object
|
||||||
|
var auctionMessage = {
|
||||||
|
ProductAuctionId: bidBoxPageViewModel.ProductToAuctionId,
|
||||||
|
AuctionStatus: auctionStatus
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert to JSON and log
|
||||||
|
var content = JSON.stringify(auctionMessage);
|
||||||
|
console.log(content);
|
||||||
|
|
||||||
|
// Send the message via SignalR
|
||||||
|
sendMessageToServer("AuctionProductStatusRequest", bidBoxPageViewModel.CustomerId, content);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function refreshPublicBidBox(data) {
|
function refreshPublicBidBox(data) {
|
||||||
|
|
||||||
let HUFFormatter = new Intl.NumberFormat('hu-HU', {
|
// let HUFFormatter = new Intl.NumberFormat('hu-HU', {
|
||||||
style: 'currency',
|
// style: 'currency',
|
||||||
currency: 'HUF',
|
// currency: 'HUF',
|
||||||
});
|
// });
|
||||||
|
|
||||||
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
||||||
var budButtonElement = document.getElementById("signalRBidButton");
|
var budButtonElement = document.getElementById("signalRBidButton");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue