add audio for order reservation

This commit is contained in:
phyusin
2018-06-01 17:38:59 +06:30
parent 7c35fa48e0
commit 9f24c56e61
4 changed files with 13 additions and 6 deletions

1
.gitignore vendored
View File

@@ -28,6 +28,7 @@ capybara-*.html
/public/uploads/*
/public/swf/*
/public/receipts/
/public/*.mp3
/coverage/
/spec/tmp/*
*.orig

View File

@@ -8,6 +8,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
if(data.from == "" || hostname == data.from){
var shop_code = data.shop_code;
var order = data.data;
var audio = data.audio;
if(order.length > 0){
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
$("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
@@ -16,7 +17,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
if(key==0){
active_class = "tr-active";
if (typeof audioPlayBackground !== 'undefined' && $.isFunction(audioPlayBackground)) {
audioPlayBackground(shop_code);
audioPlayBackground(shop_code,audio);
}
if (typeof showNewOrderAlert !== 'undefined' && $.isFunction(showNewOrderAlert)) {
showNewOrderAlert(order[key],shop_code);

View File

@@ -159,10 +159,10 @@ $(document).ready(function() {
});
/* start order reservation function */
function audioPlayBackground(shop_code){
console.log(shop_code);
function audioPlayBackground(shop_code,audio){
// console.log(shop_code);
//audio play
var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
var audio = new Audio('/'+audio); // define your audio
// setTimeout(function(){
// audio.loop = true;
audio.play();

View File

@@ -65,10 +65,15 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
if flag
shop = Shop.find_by_id(1)
if !shop.shop_code.nil?
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
if !order_audio.nil?
audio = order_audio.image
end
else
shop_code = ''
audio = ''
end
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
@@ -78,7 +83,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
else
from = ""
end
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from,audio:audio
else
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
end