update call waiter
This commit is contained in:
61
app/assets/javascripts/channels/call_waiter.js
Normal file
61
app/assets/javascripts/channels/call_waiter.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
console.log(data.table);
|
||||||
|
console.log(data.time);
|
||||||
|
table = data.table
|
||||||
|
// for Notificaiotn message
|
||||||
|
var placementFrom = "top";
|
||||||
|
var placementAlign = "center";
|
||||||
|
var animateEnter = "";
|
||||||
|
var animateExit = "";
|
||||||
|
var colorName = "alert-warning";
|
||||||
|
var text = " Calling Waiter <br> "+table.name ;
|
||||||
|
|
||||||
|
if (text != null || colorName != null){
|
||||||
|
showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
|
||||||
|
if (colorName === null || colorName === '') { colorName = 'bg-black'; }
|
||||||
|
if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
|
||||||
|
if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
|
||||||
|
var allowDismiss = true;
|
||||||
|
$.notify({
|
||||||
|
message: text
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: colorName,
|
||||||
|
newest_on_top: true,
|
||||||
|
allow_dismiss: allowDismiss,
|
||||||
|
newest_on_top: true,
|
||||||
|
timer: 200000000000000,
|
||||||
|
placement: {
|
||||||
|
from: placementFrom,
|
||||||
|
align: placementAlign
|
||||||
|
},
|
||||||
|
animate: {
|
||||||
|
enter: animateEnter,
|
||||||
|
exit: animateExit
|
||||||
|
},
|
||||||
|
template: '<div data-notify="container" style="max-width: 180px !important;" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-30" : "") + '" role="alert">' +
|
||||||
|
'<button type="button" aria-hidden="true" class="close float-right m-l-20 m-t--5" data-notify="dismiss" style="right: -5px;">×</button>' +
|
||||||
|
'<span data-notify="icon"></span> ' +
|
||||||
|
'<span data-notify="title">{1}</span> ' +
|
||||||
|
'<span data-notify="message">{2}</span>' +
|
||||||
|
'<div class="progress" data-notify="progressbar">' +
|
||||||
|
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<a href="{3}" target="{4}" data-notify="url"></a>' +
|
||||||
|
'</div>'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end Notificaiotn message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@@ -265,5 +265,13 @@ section.content {
|
|||||||
color: #F44336;
|
color: #F44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*notification */
|
||||||
|
.alert {
|
||||||
|
padding: .25rem .25rem !important;
|
||||||
|
}
|
||||||
|
.alert-dismissible .close {
|
||||||
|
padding: 0.2rem 0.24rem;
|
||||||
|
}
|
||||||
/* End Reset Theme */
|
/* End Reset Theme */
|
||||||
/* *************************************************** */
|
/* *************************************************** */
|
||||||
@@ -15,4 +15,9 @@ module ApplicationCable
|
|||||||
class BillChannel < ActionCable::Channel::Base
|
class BillChannel < ActionCable::Channel::Base
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Call Waiter Channel
|
||||||
|
class CallWaiterChannel < ActionCable::Channel::Base
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module ApplicationCable
|
module ApplicationCable
|
||||||
class Connection < ActionCable::Connection::Base
|
class Connection < ActionCable::Connection::Base
|
||||||
def connect
|
def connect
|
||||||
logger.add_tags "ActionCable"
|
logger.add_tags "SX-ActionCable"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
14
app/channels/call_waiter_channel.rb
Normal file
14
app/channels/call_waiter_channel.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class CallWaiterChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "call_waiter_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
end
|
||||||
|
|
||||||
|
def order(message)
|
||||||
|
# ToDo
|
||||||
|
end
|
||||||
|
end
|
||||||
12
app/controllers/api/call_waiters_controller.rb
Normal file
12
app/controllers/api/call_waiters_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class Api::CallWaitersController < ActionController::API
|
||||||
|
|
||||||
|
#List all active customers by name
|
||||||
|
def index
|
||||||
|
@table_id = params[:dining_id]
|
||||||
|
@time = params[:time]
|
||||||
|
@table = DiningFacility.find(@table_id)
|
||||||
|
CallWaiterJob.perform_later(@table,@time)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
8
app/jobs/call_waiter_job.rb
Normal file
8
app/jobs/call_waiter_job.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class CallWaiterJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(table,time)
|
||||||
|
ActionCable.server.broadcast "call_waiter_channel",table: table,time:time
|
||||||
|
# Rails.logger.debug "Testing: I'm performing my job with arguments: #{table}"
|
||||||
|
end
|
||||||
|
end
|
||||||
6
app/views/api/call_waiters/index.json.jbuilder
Normal file
6
app/views/api/call_waiters/index.json.jbuilder
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
if (@table)
|
||||||
|
json.table_id @table.id
|
||||||
|
json.name @table.name
|
||||||
|
json.type @table.type
|
||||||
|
json.time @time
|
||||||
|
end
|
||||||
@@ -70,7 +70,10 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
namespace :origami do
|
namespace :origami do
|
||||||
post "check_in/:dining_id" => "check_in_process#check_in_process"
|
post "check_in/:dining_id" => "check_in_process#check_in_process"
|
||||||
post "request_time" => "check_in_process#request_time"
|
post "request_time" => "check_in_process#request_time"
|
||||||
|
post "call_waiter" => "call_waiters#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Cashier ------------#
|
#--------- Cashier ------------#
|
||||||
|
|||||||
5
spec/jobs/call_waiter_job_spec.rb
Normal file
5
spec/jobs/call_waiter_job_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe CallWaiterJob, type: :job do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user