diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 095ae4e0..a27b4afd 100644 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -276,6 +276,7 @@ $(function(){ disabled = "" status =""; + if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){ status = "selected-attribute"; } @@ -417,7 +418,7 @@ $(function(){ }); //End Add Icon Click function show_item_detail(data){ - console.log(data) + qty = parseInt(data.attr('data-qty')); append = 0; price = parseFloat(data.attr('data-price')).toFixed(2); @@ -599,7 +600,7 @@ $(function(){ var item_row = $('.summary-items tbody tr'); $(item_row).each(function(i){ var order_item = {}; - console.log($(item_row[i]).attr('data-options')); + order_item.order_item_id = $(item_row[i]).attr('data-row'); order_item.item_instance_code = $(item_row[i]).attr('data-instance-code'); order_item.quantity = $(item_row[i]).children('#item_qty').text(); diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index ce5ac871..55bfd46b 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -1,14 +1,14 @@ // Action Cable provides the framework to deal with WebSockets in Rails. // You can generate new channels where WebSocket features live using the `rails generate channel` command. -// + //= require action_cable //= require_self //= require_tree ./channels // Temp Disable -// (function() { -// this.App || (this.App = {}); +(function() { + this.App || (this.App = {}); -// App.cable = ActionCable.createConsumer(); + App.cable = ActionCable.createConsumer(); -// }).call(this); +}).call(this); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index 85706bb5..79708e36 100644 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -1,24 +1,29 @@ -// App.order_queue_station = App.cable.subscriptions.create("OrderQueueStationChannel", { -// connected: function() {}, +App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChannel', { +// App.messages = App.cable.subscriptions.create('MessagesChannel', { -// disconnected: function() {}, + connected: function() {}, -// received: function(message) { -// alert(message); -// }, + disconnected: function() {}, -// order: function(message) { -// return this.perform('order', { -// message: message -// }); -// } -// }); + received: function(data) { + console.log(data); + alert(data); + console.log("hiiiiiiiiiiii"); + $('#test').append(data); + }, -// $(function(){ -// $("#submit_order").on('click', function(event) { -// var orderData=$("#new_order").serializeObject(); -// App.order_station.order(orderData); -// //orderData=''; -// return event.preventDefault(); -// }); -// }); + order: function(message) { + return this.perform('order', { + message: message + }); + } +}); + +$(function(){ + $("#submit_order").on('click', function(event) { + var orderData=$("#new_order").serializeObject(); + App.order_station.order(orderData); + //orderData=''; + return event.preventDefault(); + }); +}); diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index a66bc071..a087eaec 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -7,7 +7,7 @@ module ApplicationCable end # Order Queue Station Channel - class OQSChannel < ActionCable::Channel::Base + class OrderQueueStationChannel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442f..9da60bf4 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,4 +1,7 @@ module ApplicationCable class Connection < ActionCable::Connection::Base + def connect + logger.add_tags "ActionCable" + end end end diff --git a/app/channels/order_queue_station_channel.rb b/app/channels/order_queue_station_channel.rb index 8206c64b..b815a446 100644 --- a/app/channels/order_queue_station_channel.rb +++ b/app/channels/order_queue_station_channel.rb @@ -4,6 +4,7 @@ class OrderQueueStationChannel < ApplicationCable::Channel end def unsubscribed + stop_all_streams # Any cleanup needed when channel is unsubscribed end diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index 5b3423dc..4a6d2862 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -4,8 +4,9 @@ class OrderQueueProcessorJob < ApplicationJob def perform(order_id, table_id) # Do something later #Order ID - order = Order.find(order_id) + order = Order.find(order_id) + ActionCable.server.broadcast "order_queue_station_channel",message: order #Loop through the order stations and process the items #Execute orders and send to order stations if order @@ -13,5 +14,8 @@ class OrderQueueProcessorJob < ApplicationJob oqs.process_order(order, table_id) end + + + end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 824618e6..ca52292e 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -12,6 +12,9 @@ <% end %> +
+

+

diff --git a/config/cable.yml b/config/cable.yml index 0bbde6f7..a383c5af 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,9 +1,7 @@ -development: - adapter: async - -test: - adapter: async - -production: +redis: &redis adapter: redis url: redis://localhost:6379/1 + +production: *redis +development: *redis +test: *redis \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 4d8fc580..4c681ee6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -45,6 +45,8 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true + config.web_console.whiny_requests = false + # Raises error for missing translations # config.action_view.raise_on_missing_translations = true @@ -53,5 +55,5 @@ Rails.application.configure do config.file_watcher = ActiveSupport::EventedFileUpdateChecker # Set Cable URL - # config.action_cable.url = "ws://192.168.1.140:3002/cable" + config.action_cable.url = "ws://192.168.1.39:3002/cable" end diff --git a/config/routes.rb b/config/routes.rb index 1efacd83..7b8f7ea4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,7 @@ Rails.application.routes.draw do mount Sidekiq::Web => '/kiq' # Action Cable Creation - # mount ActionCable.server => "/cable" + mount ActionCable.server => "/cable" #--------- SmartSales Installation ------------# get 'install' => 'install#index'