User app error handling upgrades
This commit is contained in:
@@ -12,3 +12,4 @@ App.Router.map ->
|
|||||||
@resource 'join_requests'
|
@resource 'join_requests'
|
||||||
@resource 'lists', ->
|
@resource 'lists', ->
|
||||||
@resource 'list', path: ':list_id'
|
@resource 'list', path: ':list_id'
|
||||||
|
@route 'error'
|
||||||
|
|||||||
+42
-3
@@ -41,8 +41,47 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
Ember.$.post '/user/needs_help.json'
|
Ember.$.post '/user/needs_help.json'
|
||||||
#Ember.$.post('/user/needs_help.json').then (res) =>
|
#Ember.$.post('/user/needs_help.json').then (res) =>
|
||||||
#@set('list.needs_help', true) # also done by faye
|
#@set('list.needs_help', true) # also done by faye
|
||||||
|
error: (error, transition, klass)->
|
||||||
|
message = null
|
||||||
|
if error.status is 404
|
||||||
|
if klass.routeName is 'table'
|
||||||
|
message = t('errors.404.model.message', model: t("models.#{klass.routeName}"), id: transition.state.params.table.table_id)
|
||||||
|
else
|
||||||
|
message = t('errors.404.general.message')
|
||||||
|
@transitionTo('index').then (route)->
|
||||||
|
route.get('controller.controllers.application').set 'notice', message
|
||||||
|
|
||||||
scanQr: ->
|
scanQr: ->
|
||||||
|
<% if Rails.env.user_app? %>
|
||||||
|
ar = @
|
||||||
|
scanner = cordova.require("cordova/plugin/BarcodeScanner")
|
||||||
|
scanner.scan (result)->
|
||||||
|
if result.cancelled
|
||||||
|
ar.transitionTo('index')
|
||||||
|
$log
|
||||||
|
action: 'qrscan'
|
||||||
|
result: 'cancel'
|
||||||
|
else
|
||||||
|
table_id_index = result.text.indexOf('s?t=');
|
||||||
|
if table_id_index > -1
|
||||||
|
table_id = result.text.substr(table_id_index + 4);
|
||||||
|
ar.transitionTo 'table', table_id
|
||||||
|
else
|
||||||
|
ar.transitionTo('index').then (route)->
|
||||||
|
route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id"
|
||||||
|
$log
|
||||||
|
action: 'qrscan'
|
||||||
|
error: 'cannot extract table id'
|
||||||
|
info: result.text
|
||||||
|
|
||||||
|
, (error)->
|
||||||
|
$log
|
||||||
|
action: 'qrscan'
|
||||||
|
error: 'scan failed'
|
||||||
|
info: error
|
||||||
|
ar.transitionTo('index').then (route)->
|
||||||
|
route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}"
|
||||||
|
<% else %>
|
||||||
|
# @transitionTo 'table', 'abc'
|
||||||
@transitionTo 'select_qrcode'
|
@transitionTo 'select_qrcode'
|
||||||
events: ->
|
<% end %>
|
||||||
error: (error)->
|
|
||||||
debugger
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.row: h2=t 'app.error.title'
|
||||||
|
.row: p=t 'app.error.body'
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
class DashboardController < ApplicationController
|
class DashboardController < ApplicationController
|
||||||
layout 'theme1'
|
layout 'theme1'
|
||||||
|
before_action :allow_all_origins, only: :error_report
|
||||||
|
|
||||||
def demo_both
|
def demo_both
|
||||||
render layout: 'demo-both'
|
render layout: 'demo-both'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_app_log
|
||||||
|
log = UserAppLog.new(params: params[:log])
|
||||||
|
log.user = current_user
|
||||||
|
log.save
|
||||||
|
end
|
||||||
|
|
||||||
# Testing action
|
# Testing action
|
||||||
def select_qrcode
|
def select_qrcode
|
||||||
#@tables = Table.all.sample(2) | List.active.map(&:table)
|
#@tables = Table.all.sample(2) | List.active.map(&:table)
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class User
|
|||||||
validates_uniqueness_of :email
|
validates_uniqueness_of :email
|
||||||
before_save :ensure_authentication_token
|
before_save :ensure_authentication_token
|
||||||
|
|
||||||
|
has_many :error_logs
|
||||||
|
|
||||||
view :by_authentication_token, key: :authentication_token
|
view :by_authentication_token, key: :authentication_token
|
||||||
view :by_email, key: :email
|
view :by_email, key: :email
|
||||||
view :by_facebook, key: [:provider, :uid]
|
view :by_facebook, key: [:provider, :uid]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class UserAppLog
|
||||||
|
include SimplyStored::Couch
|
||||||
|
belongs_to :user
|
||||||
|
property :params
|
||||||
|
end
|
||||||
@@ -8,7 +8,7 @@ html lang="en"
|
|||||||
= javascript_include_tag "vendor/modernizr"
|
= javascript_include_tag "vendor/modernizr"
|
||||||
= stylesheet_link_tag "user/foundation/application"
|
= stylesheet_link_tag "user/foundation/application"
|
||||||
= javascript_include_tag "user/flat/application"
|
= javascript_include_tag "user/flat/application"
|
||||||
- if ENV['QWAITER_MOBILE_EXPORT'] == 'yes'
|
- if Rails.env.user_app?
|
||||||
javascript:
|
javascript:
|
||||||
var QMobile, Qwaiter, Quser;
|
var QMobile, Qwaiter, Quser;
|
||||||
var $data_host = 'http://data.mozo.bar';
|
var $data_host = 'http://data.mozo.bar';
|
||||||
@@ -18,7 +18,7 @@ html lang="en"
|
|||||||
Qstorage.setItem('root_url', '##root_url##');
|
Qstorage.setItem('root_url', '##root_url##');
|
||||||
var $platform = '##platform##';
|
var $platform = '##platform##';
|
||||||
var $obtain_token_url = 'http://mozo.bar/user/obtain_token';
|
var $obtain_token_url = 'http://mozo.bar/user/obtain_token';
|
||||||
|
var $log = function(params){$.post('http://log.mozo.bar/user_app', {log: params})};
|
||||||
- else
|
- else
|
||||||
javascript:
|
javascript:
|
||||||
var QMobile, Qwaiter, Quser;
|
var QMobile, Qwaiter, Quser;
|
||||||
@@ -29,5 +29,6 @@ html lang="en"
|
|||||||
#{user_dynamic_root_url};
|
#{user_dynamic_root_url};
|
||||||
#{user_dynamic_obtain_token_url};
|
#{user_dynamic_obtain_token_url};
|
||||||
var $platform = 'web'
|
var $platform = 'web'
|
||||||
|
var $log = function(params){console.log('App log:'); console.log(params);console.log('=======================================')};
|
||||||
body
|
body
|
||||||
#ember-app-container
|
#ember-app-container
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Qstorage = window.localStorage;
|
Qstorage = window.localStorage;
|
||||||
Qstorage.setItem('auth_token', '#{current_user.authentication_token}');
|
Qstorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||||
Qstorage.setItem('user_id', '#{current_user.id}');
|
Qstorage.setItem('user_id', '#{current_user.id}');
|
||||||
if(window.opener && window.opener != window) window.close();
|
if(!window.opener || window.opener != window) window.close();
|
||||||
// window.location = (Qstorage.getItem('root_url') || '/user/index.html') + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}';
|
// window.location = (Qstorage.getItem('root_url') || '/user/index.html') + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}';
|
||||||
// localStorage.setItem('auth_token', '#{current_user.authentication_token}');
|
// localStorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||||
// localStorage.setItem('user_id', '#{current_user.id}');
|
// localStorage.setItem('user_id', '#{current_user.id}');
|
||||||
|
|||||||
@@ -90,3 +90,13 @@ en:
|
|||||||
closed: 'Closed'
|
closed: 'Closed'
|
||||||
lists:
|
lists:
|
||||||
show_more: Show more
|
show_more: Show more
|
||||||
|
app:
|
||||||
|
error:
|
||||||
|
title: There is a problem with the application
|
||||||
|
body: Please try to restart
|
||||||
|
errors:
|
||||||
|
404:
|
||||||
|
model:
|
||||||
|
message: Cannot find %{model} with id %{id}
|
||||||
|
general:
|
||||||
|
message: Cannot find resource
|
||||||
|
|||||||
@@ -88,3 +88,14 @@ nl:
|
|||||||
closed: 'Afgesloten'
|
closed: 'Afgesloten'
|
||||||
lists:
|
lists:
|
||||||
show_more: Meer tonen
|
show_more: Meer tonen
|
||||||
|
app:
|
||||||
|
error:
|
||||||
|
title: Er is een probleem met de applicatie
|
||||||
|
body: Herstart de applicatie om het op te lossen
|
||||||
|
|
||||||
|
errors:
|
||||||
|
404:
|
||||||
|
model:
|
||||||
|
message: %{model} met id %{id} kan niet worden gevonden
|
||||||
|
general:
|
||||||
|
message: Data niet beschikbaar
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ Qwaiter::Application.routes.draw do
|
|||||||
root to: 'users#index'
|
root to: 'users#index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post '/user_app' => 'dashboard#user_app_log' #TODO: separate high speed app at log.mozo.bar
|
||||||
|
|
||||||
# SUPPLIER
|
# SUPPLIER
|
||||||
get '/supplier' => 'supplier#home', as: :supplier_root
|
get '/supplier' => 'supplier#home', as: :supplier_root
|
||||||
get '/supplier/active_orders' => 'supplier#active_orders', as: :supplier_active_orders
|
get '/supplier/active_orders' => 'supplier#active_orders', as: :supplier_active_orders
|
||||||
|
|||||||
Reference in New Issue
Block a user