User app error handling upgrades
This commit is contained in:
@@ -12,3 +12,4 @@ App.Router.map ->
|
||||
@resource 'join_requests'
|
||||
@resource 'lists', ->
|
||||
@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').then (res) =>
|
||||
#@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: ->
|
||||
<% 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'
|
||||
events: ->
|
||||
error: (error)->
|
||||
debugger
|
||||
<% end %>
|
||||
@@ -0,0 +1,2 @@
|
||||
.row: h2=t 'app.error.title'
|
||||
.row: p=t 'app.error.body'
|
||||
@@ -1,10 +1,17 @@
|
||||
class DashboardController < ApplicationController
|
||||
layout 'theme1'
|
||||
before_action :allow_all_origins, only: :error_report
|
||||
|
||||
def demo_both
|
||||
render layout: 'demo-both'
|
||||
end
|
||||
|
||||
def user_app_log
|
||||
log = UserAppLog.new(params: params[:log])
|
||||
log.user = current_user
|
||||
log.save
|
||||
end
|
||||
|
||||
# Testing action
|
||||
def select_qrcode
|
||||
#@tables = Table.all.sample(2) | List.active.map(&:table)
|
||||
|
||||
@@ -22,6 +22,8 @@ class User
|
||||
|
||||
validates_uniqueness_of :email
|
||||
before_save :ensure_authentication_token
|
||||
|
||||
has_many :error_logs
|
||||
|
||||
view :by_authentication_token, key: :authentication_token
|
||||
view :by_email, key: :email
|
||||
|
||||
@@ -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"
|
||||
= stylesheet_link_tag "user/foundation/application"
|
||||
= javascript_include_tag "user/flat/application"
|
||||
- if ENV['QWAITER_MOBILE_EXPORT'] == 'yes'
|
||||
- if Rails.env.user_app?
|
||||
javascript:
|
||||
var QMobile, Qwaiter, Quser;
|
||||
var $data_host = 'http://data.mozo.bar';
|
||||
@@ -18,7 +18,7 @@ html lang="en"
|
||||
Qstorage.setItem('root_url', '##root_url##');
|
||||
var $platform = '##platform##';
|
||||
var $obtain_token_url = 'http://mozo.bar/user/obtain_token';
|
||||
|
||||
var $log = function(params){$.post('http://log.mozo.bar/user_app', {log: params})};
|
||||
- else
|
||||
javascript:
|
||||
var QMobile, Qwaiter, Quser;
|
||||
@@ -29,5 +29,6 @@ html lang="en"
|
||||
#{user_dynamic_root_url};
|
||||
#{user_dynamic_obtain_token_url};
|
||||
var $platform = 'web'
|
||||
var $log = function(params){console.log('App log:'); console.log(params);console.log('=======================================')};
|
||||
body
|
||||
#ember-app-container
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
Qstorage = window.localStorage;
|
||||
Qstorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||
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}';
|
||||
// localStorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||
// localStorage.setItem('user_id', '#{current_user.id}');
|
||||
|
||||
@@ -90,3 +90,13 @@ en:
|
||||
closed: 'Closed'
|
||||
lists:
|
||||
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'
|
||||
lists:
|
||||
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'
|
||||
end
|
||||
|
||||
post '/user_app' => 'dashboard#user_app_log' #TODO: separate high speed app at log.mozo.bar
|
||||
|
||||
# SUPPLIER
|
||||
get '/supplier' => 'supplier#home', as: :supplier_root
|
||||
get '/supplier/active_orders' => 'supplier#active_orders', as: :supplier_active_orders
|
||||
|
||||
Reference in New Issue
Block a user