This commit is contained in:
Yan
2018-05-18 14:38:31 +06:30
parent 39e7269fc1
commit 0d2f609b07
4 changed files with 23 additions and 21 deletions

View File

@@ -9,12 +9,6 @@
(function() { (function() {
this.App || (this.App = {}); 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(); App.cable = ActionCable.createConsumer();
}).call(this); }).call(this);

View File

@@ -6,6 +6,10 @@ App.order = App.cable.subscriptions.create('BillChannel', {
disconnected: function() {}, disconnected: function() {},
received: function(data) { received: function(data) {
var hostname = location.hostname;
console.log(hostname + "\n" + data.from);
if(data.from == "" || hostname == data.from)
{
if($('.table_'+data.table.id).hasClass('blue')){ if($('.table_'+data.table.id).hasClass('blue')){
$('.table_'+data.table.id).removeClass('blue'); $('.table_'+data.table.id).removeClass('blue');
$('.table_'+data.table.id).addClass('red'); $('.table_'+data.table.id).addClass('red');
@@ -16,5 +20,6 @@ App.order = App.cable.subscriptions.create('BillChannel', {
$('.new_text_'+data.table.id).removeClass('hide'); $('.new_text_'+data.table.id).removeClass('hide');
$('.new_text_'+data.table.id).text('billed'); $('.new_text_'+data.table.id).text('billed');
} }
}
}); });

View File

@@ -39,9 +39,12 @@ class Origami::RequestBillsController < ApplicationController
# Promotion Activation # Promotion Activation
Promotion.promo_activate(@sale) Promotion.promo_activate(@sale)
#bill channel #bill channel
#if ENV["SERVER_MODE"] != 'cloud' if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "bill_channel",table: table from = request.subdomain + "." + request.domain
#end else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table, from: from
if order.source == "quick_service" if order.source == "quick_service"
result = {:status=> @status, :data => @sale.sale_id } result = {:status=> @status, :data => @sale.sale_id }
render :json => result.to_json render :json => result.to_json