diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 033f521b..1668e17f 100755 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -8,13 +8,7 @@ // Temp Disable (function() { this.App || (this.App = {}); - - // var hostname = location.hostname; - // var port = location.port; - // var host = hostname + ":" + port + "/cable" - // console.log(host); - // App.cable = ActionCable.createConsumer(); - // console.log(App.cable); + App.cable = ActionCable.createConsumer(); }).call(this); diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 97666e32..b6915b53 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -6,15 +6,20 @@ App.order = App.cable.subscriptions.create('BillChannel', { disconnected: function() {}, received: function(data) { - if($('.table_'+data.table.id).hasClass('blue')){ - $('.table_'+data.table.id).removeClass('blue'); - $('.table_'+data.table.id).addClass('red'); - }else{ - $('.table_'+data.table.id).removeClass('orange'); - $('.table_'+data.table.id).addClass('red'); - } - $('.new_text_'+data.table.id).removeClass('hide'); - $('.new_text_'+data.table.id).text('billed'); + var hostname = location.hostname; + console.log(hostname + "\n" + data.from); + if(data.from == "" || hostname == data.from) + { + if($('.table_'+data.table.id).hasClass('blue')){ + $('.table_'+data.table.id).removeClass('blue'); + $('.table_'+data.table.id).addClass('red'); + }else{ + $('.table_'+data.table.id).removeClass('orange'); + $('.table_'+data.table.id).addClass('red'); + } + $('.new_text_'+data.table.id).removeClass('hide'); + $('.new_text_'+data.table.id).text('billed'); + } } }); diff --git a/app/channels/order_channel.rb b/app/channels/order_channel.rb index d261e48b..6f899707 100755 --- a/app/channels/order_channel.rb +++ b/app/channels/order_channel.rb @@ -1,5 +1,5 @@ class OrderChannel < ApplicationCable::Channel - def subscribed + def subscribed stream_from "order_channel" end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 0c50a5da..3d2c90aa 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -38,10 +38,13 @@ class Origami::RequestBillsController < ApplicationController # Promotion Activation Promotion.promo_activate(@sale) - #bill channel - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "bill_channel",table: table - #end + #bill channel + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "bill_channel",table: table, from: from if order.source == "quick_service" result = {:status=> @status, :data => @sale.sale_id } render :json => result.to_json