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

@@ -8,13 +8,7 @@
// Temp Disable // Temp Disable
(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,15 +6,20 @@ App.order = App.cable.subscriptions.create('BillChannel', {
disconnected: function() {}, disconnected: function() {},
received: function(data) { received: function(data) {
if($('.table_'+data.table.id).hasClass('blue')){ var hostname = location.hostname;
$('.table_'+data.table.id).removeClass('blue'); console.log(hostname + "\n" + data.from);
$('.table_'+data.table.id).addClass('red'); if(data.from == "" || hostname == data.from)
}else{ {
$('.table_'+data.table.id).removeClass('orange'); if($('.table_'+data.table.id).hasClass('blue')){
$('.table_'+data.table.id).addClass('red'); $('.table_'+data.table.id).removeClass('blue');
} $('.table_'+data.table.id).addClass('red');
$('.new_text_'+data.table.id).removeClass('hide'); }else{
$('.new_text_'+data.table.id).text('billed'); $('.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');
}
} }
}); });

View File

@@ -1,5 +1,5 @@
class OrderChannel < ApplicationCable::Channel class OrderChannel < ApplicationCable::Channel
def subscribed def subscribed
stream_from "order_channel" stream_from "order_channel"
end end

View File

@@ -38,10 +38,13 @@ 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