From 843a370660646499c3007256be953506567f23fb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 17 Oct 2015 12:35:16 +1300 Subject: Add linking and unlinking of devices --- web/app/Application.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/app/Application.js') diff --git a/web/app/Application.js b/web/app/Application.js index e710b7ea2..83ca9e860 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -76,5 +76,24 @@ Ext.define('Traccar.Application', { getPreference: function (key, defaultValue) { return this.getUser().get(key) || this.getServer().get(key) || defaultValue; + }, + + getErrorHandler: function (scope, handler) { + return function (options, success, response) { + var result; + if (success) { + result = Ext.decode(response.responseText); + if (!result.success) { + Ext.Msg.alert(Strings.errorTitle, result.error); + } + handler.call(scope, options, success, response); + } else { + if (response.statusText) { + Ext.Msg.alert(Strings.errorTitle, response.statusText); + } else { + Ext.Msg.alert(Strings.errorTitle, response.status.toString()); // TODO: text message + } + } + } } }); -- cgit v1.2.3