first evented steps
This commit is contained in:
+3
-3
@@ -108,9 +108,9 @@ GEM
|
|||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
i18n (0.6.1)
|
i18n (0.6.1)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
jquery-rails (2.1.3)
|
jquery-rails (2.1.4)
|
||||||
railties (>= 3.1.0, < 5.0)
|
railties (>= 3.0, < 5.0)
|
||||||
thor (~> 0.14)
|
thor (>= 0.14, < 2.0)
|
||||||
json (1.6.7)
|
json (1.6.7)
|
||||||
kaminari (0.14.1)
|
kaminari (0.14.1)
|
||||||
actionpack (>= 3.0.0)
|
actionpack (>= 3.0.0)
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ class Quser
|
|||||||
formatted += ' '
|
formatted += ' '
|
||||||
formatted += utc.substr(11, 5)
|
formatted += utc.substr(11, 5)
|
||||||
formatted
|
formatted
|
||||||
|
watch_events: ->
|
||||||
|
faye = new Faye.Client('http://localhost:9292/faye')
|
||||||
|
faye.subscribe "/user/"+QMobile.user_id(), (e)->
|
||||||
|
debugger
|
||||||
|
if(e.event == 'list_closed')
|
||||||
|
redirect_to 'user_root', {list_closed: 'true'}
|
||||||
|
console.log(data)
|
||||||
home_loader: ->
|
home_loader: ->
|
||||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
||||||
handle_active_list: (callback) ->
|
handle_active_list: (callback) ->
|
||||||
@@ -204,6 +211,7 @@ class Quser
|
|||||||
h['table_id'] = match[1] if match
|
h['table_id'] = match[1] if match
|
||||||
for product_id, number of window.active_products_list
|
for product_id, number of window.active_products_list
|
||||||
h['products['+product_id+']'] = number
|
h['products['+product_id+']'] = number
|
||||||
|
debugger
|
||||||
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
|
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
|
||||||
handle_response: (res) ->
|
handle_response: (res) ->
|
||||||
if(typeof(res) == 'string')
|
if(typeof(res) == 'string')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
|
|||||||
def layout_by_resource
|
def layout_by_resource
|
||||||
if devise_controller?
|
if devise_controller?
|
||||||
case session[:user_return_to]
|
case session[:user_return_to]
|
||||||
when /\/user\// then 'phone'
|
when /\/user\// then ''
|
||||||
when /obtain_token/ then 'obtain_token'
|
when /obtain_token/ then 'obtain_token'
|
||||||
else 'theme1'
|
else 'theme1'
|
||||||
end
|
end
|
||||||
@@ -49,4 +49,10 @@ class ApplicationController < ActionController::Base
|
|||||||
message = args.first || ''
|
message = args.first || ''
|
||||||
{ok: true, message: message}.merge(options).to_json
|
{ok: true, message: message}.merge(options).to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def broadcast_user(uid, event, data = {})
|
||||||
|
message = {channel: channel, data: {event: event, data: data}}
|
||||||
|
uri = URI.parse("http://localhost:9292/faye")
|
||||||
|
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ class SupplierController < ApplicationController
|
|||||||
def close_list
|
def close_list
|
||||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
||||||
@list.close!
|
@list.close!
|
||||||
|
for user_id in @list.user_ids
|
||||||
|
broadcast_user user_id, 'list_closed', @list
|
||||||
|
end
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ html lang="en"
|
|||||||
/[if lt IE 9]
|
/[if lt IE 9]
|
||||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||||
= stylesheet_link_tag "user/application", :media => "all"
|
= stylesheet_link_tag "user/application", :media => "all"
|
||||||
|
= javascript_include_tag 'http://localhost:9292/faye.js'
|
||||||
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||||
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||||
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||||
@@ -31,6 +32,7 @@ html lang="en"
|
|||||||
authentication_string: function(){return this.authentication_string_storage || ''},
|
authentication_string: function(){return this.authentication_string_storage || ''},
|
||||||
authentication_object: function(){return this.authentication_object_storage || '{}'},
|
authentication_object: function(){return this.authentication_object_storage || '{}'},
|
||||||
setAuthToken: function(token){
|
setAuthToken: function(token){
|
||||||
|
this.auth_token = token;
|
||||||
this.authentication_string_storage = 'auth_token='+token;
|
this.authentication_string_storage = 'auth_token='+token;
|
||||||
this.authentication_object_storage = '{"auth_token": "'+token+'"}'
|
this.authentication_object_storage = '{"auth_token": "'+token+'"}'
|
||||||
},
|
},
|
||||||
@@ -39,9 +41,13 @@ html lang="en"
|
|||||||
goHome: function(){ redirect_to('user_root')},
|
goHome: function(){ redirect_to('user_root')},
|
||||||
connection_problem: function(){alert('There is a problem connecting to the server')},
|
connection_problem: function(){alert('There is a problem connecting to the server')},
|
||||||
locale: function(){ return $locale || ($locale = 'en')},
|
locale: function(){ return $locale || ($locale = 'en')},
|
||||||
setLocale: function(locale){$locale = locale; return locale}
|
setLocale: function(locale){$locale = locale; return locale},
|
||||||
|
token: function(){return this.auth_token},
|
||||||
|
setUserId: function(id){ this.stored_user_id = id},
|
||||||
|
user_id: function(){return this.stored_user_id }
|
||||||
});
|
});
|
||||||
//QMobile.setAuthToken('i5brDZ1HS1okoEq3pMyh');
|
QMobile.setAuthToken('#{current_user.authentication_token}');
|
||||||
|
QMobile.setUserId('#{current_user.id}');
|
||||||
|
|
||||||
body class=action_name
|
body class=action_name
|
||||||
.navbar.navbar-fixed-top
|
.navbar.navbar-fixed-top
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
- content_for :footer do
|
- content_for :footer do
|
||||||
javascript:
|
javascript:
|
||||||
$(function(){
|
$(function(){
|
||||||
|
Quser.watch_events();
|
||||||
Quser.home_loader();
|
Quser.home_loader();
|
||||||
setInterval("Quser.home_loader()", 7500);
|
//setInterval("Quser.home_loader()", 7500);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,25 +7,10 @@
|
|||||||
tbody
|
tbody
|
||||||
tr
|
tr
|
||||||
td= slider_image
|
td= slider_image
|
||||||
table#active-order-table.table.hide
|
#active-order-container
|
||||||
thead
|
|
||||||
tr
|
|
||||||
th= Product.model_name.human
|
|
||||||
th #
|
|
||||||
th.currency Total
|
|
||||||
th
|
|
||||||
tbody
|
|
||||||
tfoot
|
|
||||||
tr
|
|
||||||
td colspan=2
|
|
||||||
button class="btn btn-primary" onClick="Quser.order_selected_products()" data-t="selected_products.order"= t('selected_products.order')
|
|
||||||
|
|
|
||||||
button class="btn btn btn-warning" onClick="Quser.clear_selected_products()" data-t="selected_products.clear"= t('selected_products.clear')
|
|
||||||
td.currency
|
|
||||||
strong#active-order-total
|
|
||||||
td
|
|
||||||
script#products-category-template[type="text/html"]= render 'products_category.mustache'
|
script#products-category-template[type="text/html"]= render 'products_category.mustache'
|
||||||
script#products-category-for-order-template[type="text/html"]= render 'products_category_for_order.mustache'
|
script#products-category-for-order-template[type="text/html"]= render 'products_category_for_order.mustache'
|
||||||
|
script#active-order-template[type="text/html"]= render 'active_order.mustache'
|
||||||
- content_for :footer do
|
- content_for :footer do
|
||||||
javascript:
|
javascript:
|
||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# This file is used by Rack-based servers to start the application.
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
require ::File.expand_path('../config/environment', __FILE__)
|
require ::File.expand_path('../config/environment', __FILE__)
|
||||||
|
#require 'faye'
|
||||||
|
#use Faye::RackAdapter, :mount => '/faye', :timeout => 25
|
||||||
run Qrammer::Application
|
run Qrammer::Application
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
require 'faye'
|
||||||
|
#require File.expand_path('../config/initializers/faye_token.rb', __FILE__)
|
||||||
|
|
||||||
|
class ServerAuth
|
||||||
|
def incoming(message, callback)
|
||||||
|
if message['channel'] !~ %r{^/meta/}
|
||||||
|
if false && message['ext']['auth_token'] != FAYE_TOKEN
|
||||||
|
message['error'] = 'Invalid authentication token'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
callback.call(message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
faye_server = Faye::RackAdapter.new(mount: '/faye', timeout: 45)
|
||||||
|
faye_server.listen 9292
|
||||||
|
faye_server.add_extension(ServerAuth.new)
|
||||||
|
run faye_server
|
||||||
Reference in New Issue
Block a user