From 5ba324ab957820bc13b1ef3f7fcadfe2b82a8b31 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Fri, 19 May 2017 17:09:04 +1200 Subject: [PATCH 1/4] Surface errors from API calls to user on status page. CRM-20602 --- ang/crmStatusPage.css | 4 ++++ ang/crmStatusPage/StatusPageCtrl.js | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ang/crmStatusPage.css b/ang/crmStatusPage.css index 3166641368a1..7bac7aac30f6 100644 --- a/ang/crmStatusPage.css +++ b/ang/crmStatusPage.css @@ -75,3 +75,7 @@ z-index: 99999; font-weight: normal; } + +.status-debug-information { + font-size: smaller; +} \ No newline at end of file diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index ff1e73527b9c..ba279adc9c06 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -12,8 +12,19 @@ apiCalls = (apiCalls || []).concat([['System', 'check', {sequential: 1}]]); $('#crm-status-list').block(); crmApi(apiCalls, true) - .then(function(result) { - $scope.statuses = result[result.length - 1].values; + .then(function(results) { + $scope.statuses = results[results.length - 1].values; + results.forEach(function(result) { + if (result.is_error) { + var error_message = result.error_message; + if (typeof(result.debug_information) !== 'undefined') { + error_message += '
' + + 'Debug information:
' + + result.debug_information + '
'; + } + CRM.alert(error_message, 'API error', 'error'); + } + }); $('#crm-status-list').unblock(); }); } From fee769110e068f44b797b095c3002fae095e2a7a Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 20 May 2017 08:28:09 +1200 Subject: [PATCH 2/4] Translation for user messages. CRM-20602 --- ang/crmStatusPage/StatusPageCtrl.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index ba279adc9c06..c308d14e2e83 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -16,13 +16,13 @@ $scope.statuses = results[results.length - 1].values; results.forEach(function(result) { if (result.is_error) { - var error_message = result.error_message; + var error_message = ts('result.error_message'); if (typeof(result.debug_information) !== 'undefined') { error_message += '
' + - 'Debug information:
' + + '' + ts('Debug information') + ':
' + result.debug_information + '
'; } - CRM.alert(error_message, 'API error', 'error'); + CRM.alert(error_message, ts('API error'), 'error'); } }); $('#crm-status-list').unblock(); From cca44a9bd081fe0936f37c505deb73849534ee15 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 20 May 2017 09:16:01 +1200 Subject: [PATCH 3/4] Pass title of action(s) to refresh(), to make errors more informative. CRM-20602 --- ang/crmStatusPage/StatusPageCtrl.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index c308d14e2e83..c718910ac895 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -8,7 +8,7 @@ $scope.statuses = statusData.values; // Refresh the list. Optionally execute api calls first. - function refresh(apiCalls) { + function refresh(apiCalls, title) { apiCalls = (apiCalls || []).concat([['System', 'check', {sequential: 1}]]); $('#crm-status-list').block(); crmApi(apiCalls, true) @@ -16,13 +16,13 @@ $scope.statuses = results[results.length - 1].values; results.forEach(function(result) { if (result.is_error) { - var error_message = ts('result.error_message'); + var error_message = ts(result.error_message); if (typeof(result.debug_information) !== 'undefined') { error_message += '
' + '' + ts('Debug information') + ':
' + result.debug_information + '
'; } - CRM.alert(error_message, ts('API error'), 'error'); + CRM.alert(error_message, ts('Operation failed: ' + title), 'error'); } }); $('#crm-status-list').unblock(); @@ -37,7 +37,7 @@ ignore_severity: visible ? 0 : status.severity, hush_until: until }] - ]); + ], 'Set preference'); }; $scope.countVisible = function(visibility) { @@ -54,7 +54,7 @@ break; case 'api3': - refresh([action.params]); + refresh([action.params], action.title); break; } } From abb724f5727a1f0b9fcc80dcb4073710a0120c70 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 20 May 2017 09:19:45 +1200 Subject: [PATCH 4/4] Label an untitled operation as such. CRM-20602 --- ang/crmStatusPage/StatusPageCtrl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index c718910ac895..4abca2ab81ea 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -9,6 +9,7 @@ // Refresh the list. Optionally execute api calls first. function refresh(apiCalls, title) { + title = title || 'Untitled operation'; apiCalls = (apiCalls || []).concat([['System', 'check', {sequential: 1}]]); $('#crm-status-list').block(); crmApi(apiCalls, true)