This commit is contained in:
Aung Myo
2017-09-01 16:55:51 +06:30
parent 2be93e413d
commit fc5192157b
11 changed files with 55 additions and 38 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();
});
});

View File

@@ -7,7 +7,7 @@ module ApplicationCable
end
# Order Queue Station Channel
class OQSChannel < ActionCable::Channel::Base
class OrderQueueStationChannel < ActionCable::Channel::Base
end

View File

@@ -1,4 +1,7 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
def connect
logger.add_tags "ActionCable"
end
end
end

View File

@@ -4,6 +4,7 @@ class OrderQueueStationChannel < ApplicationCable::Channel
end
def unsubscribed
stop_all_streams
# Any cleanup needed when channel is unsubscribed
end

View File

@@ -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

View File

@@ -12,6 +12,9 @@
<% end %>
</div>
<div class="col-md-6">
<p data-be="message" id="test"></p>
</div>
</div>
<hr>
<!-- Column One -->

View File

@@ -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

View File

@@ -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

View File

@@ -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'