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
|
||||
|
||||
// SignalR connection setup
|
||||
$(function () {
|
||||
$(function () {
|
||||
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()
|
||||
.withUrl('/auctionhub')
|
||||
.build();
|
||||
|
|
@ -19,11 +33,12 @@ $(function () {
|
|||
}, 100000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
connection.onclose(function () {
|
||||
start();
|
||||
});
|
||||
|
||||
// Global function to send a message to the server
|
||||
window.sendMessageToServer = function (messageType, senderId, data) {
|
||||
var messageWrapper = {
|
||||
MessageType: messageType,
|
||||
|
|
@ -42,94 +57,3 @@ $(function () {
|
|||
|
||||
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.Models.Catalog;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||
{
|
||||
|
|
@ -8,11 +10,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
|||
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int ProductToAuctionMappingId { get; set; }
|
||||
|
||||
public DateTime StartDate { 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">
|
||||
<h4>Manage auction!</h4>
|
||||
<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
|
||||
</button>
|
||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||
First warning
|
||||
</button>
|
||||
@{
|
||||
if(Model.IsItemActive)
|
||||
{
|
||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||
First warning
|
||||
</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>
|
||||
}
|
||||
|
|
@ -116,13 +137,16 @@
|
|||
document.getElementById("signalROpenItemButton").disabled = true;
|
||||
event.preventDefault();
|
||||
|
||||
var openItemMessage = {
|
||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
||||
AdminId: bidBoxPageViewModel.CustomerId
|
||||
};
|
||||
var content = JSON.stringify(openItemMessage);
|
||||
console.log(content);
|
||||
sendMessageToServer("OpenItemRequestMessage", bidBoxPageViewModel.CustomerId, content);
|
||||
handleAuctionStatusChange(AuctionStatus.Active);
|
||||
|
||||
return false;
|
||||
});
|
||||
$("#signalRCloseItemButton").on("click", function () {
|
||||
|
||||
document.getElementById("signalRCloseItemButton").disabled = true;
|
||||
event.preventDefault();
|
||||
|
||||
handleAuctionStatusChange(AuctionStatus.SoldOut);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
|
@ -131,25 +155,48 @@
|
|||
document.getElementById("signalRFirstWarningButton").disabled = true;
|
||||
event.preventDefault();
|
||||
|
||||
var itemFirstWarningMessage = {
|
||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
||||
AdminId: bidBoxPageViewModel.CustomerId
|
||||
};
|
||||
var content = JSON.stringify(itemFirstWarningMessage);
|
||||
console.log(content);
|
||||
sendMessageToServer("FirstWarningMessage", bidBoxPageViewModel.CustomerId, content);
|
||||
handleAuctionStatusChange(AuctionStatus.FirstWarning);
|
||||
|
||||
return false;
|
||||
});
|
||||
$("#signalRSecondWarningButton").on("click", function () {
|
||||
|
||||
document.getElementById("signalRSecondWarningButton").disabled = true;
|
||||
event.preventDefault();
|
||||
|
||||
handleAuctionStatusChange(AuctionStatus.SecondWarning);
|
||||
|
||||
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) {
|
||||
|
||||
let HUFFormatter = new Intl.NumberFormat('hu-HU', {
|
||||
style: 'currency',
|
||||
currency: 'HUF',
|
||||
});
|
||||
// let HUFFormatter = new Intl.NumberFormat('hu-HU', {
|
||||
// style: 'currency',
|
||||
// currency: 'HUF',
|
||||
// });
|
||||
|
||||
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
||||
var budButtonElement = document.getElementById("signalRBidButton");
|
||||
|
|
|
|||
Loading…
Reference in New Issue