first evented steps

This commit is contained in:
2012-11-27 15:31:31 +01:00
parent e65dc584a4
commit 3da9dc68d7
9 changed files with 53 additions and 24 deletions
@@ -9,6 +9,13 @@ class Quser
formatted += ' '
formatted += utc.substr(11, 5)
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: ->
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
handle_active_list: (callback) ->
@@ -204,6 +211,7 @@ class Quser
h['table_id'] = match[1] if match
for product_id, number of window.active_products_list
h['products['+product_id+']'] = number
debugger
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
handle_response: (res) ->
if(typeof(res) == 'string')
+7 -1
View File
@@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
def layout_by_resource
if devise_controller?
case session[:user_return_to]
when /\/user\// then 'phone'
when /\/user\// then ''
when /obtain_token/ then 'obtain_token'
else 'theme1'
end
@@ -49,4 +49,10 @@ class ApplicationController < ActionController::Base
message = args.first || ''
{ok: true, message: message}.merge(options).to_json
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
+3
View File
@@ -87,6 +87,9 @@ class SupplierController < ApplicationController
def close_list
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
@list.close!
for user_id in @list.user_ids
broadcast_user user_id, 'list_closed', @list
end
render nothing: true
end
+8 -2
View File
@@ -11,6 +11,7 @@ html lang="en"
/[if lt IE 9]
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
= 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-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
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_object: function(){return this.authentication_object_storage || '{}'},
setAuthToken: function(token){
this.auth_token = token;
this.authentication_string_storage = 'auth_token='+token;
this.authentication_object_storage = '{"auth_token": "'+token+'"}'
},
@@ -39,9 +41,13 @@ html lang="en"
goHome: function(){ redirect_to('user_root')},
connection_problem: function(){alert('There is a problem connecting to the server')},
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
.navbar.navbar-fixed-top
+2 -1
View File
@@ -9,6 +9,7 @@
- content_for :footer do
javascript:
$(function(){
Quser.watch_events();
Quser.home_loader();
setInterval("Quser.home_loader()", 7500);
//setInterval("Quser.home_loader()", 7500);
});
@@ -7,25 +7,10 @@
tbody
tr
td= slider_image
table#active-order-table.table.hide
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')
|&nbsp;
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
#active-order-container
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#active-order-template[type="text/html"]= render 'active_order.mustache'
- content_for :footer do
javascript:
jQuery(function(){