Refreshing the scope even if the request failed

This commit is contained in:
Jesús Ángel 2018-10-24 10:11:12 +02:00
parent 1923ea63b6
commit 999a78353c
4 changed files with 7 additions and 7 deletions

View File

@ -29,7 +29,7 @@ export async function searchData(
} catch (error) {
$scope.wazuh_table_loading = false;
$scope.error = `Error searching - ${error.message ||
error} - Please refresh your browser.`;
error}.`;
errorHandler.handle(
`Error searching. ${error.message || error}`,
'Data factory'
@ -65,7 +65,7 @@ export async function filterData(
$scope.wazuh_table_loading = false;
$scope.error = `Error filtering by ${
filter ? filter.value : 'undefined'
} - ${error.message || error} - Please refresh your browser.`;
} - ${error.message || error}.`;
errorHandler.handle(
`Error filtering by ${
filter ? filter.value : 'undefined'

View File

@ -50,15 +50,15 @@ export async function initTable(
await fetch();
wzTableFilter.set(instance.filters);
$scope.wazuh_table_loading = false;
if (!$scope.$$phase) $scope.$digest();
} catch (error) {
$scope.wazuh_table_loading = false;
$scope.error = `Error while init table - ${error.message ||
error} - Please refresh your browser.`;
error}.`;
errorHandler.handle(
`Error while init table. ${error.message || error}`,
'Data factory'
);
}
if (!$scope.$$phase) $scope.$digest();
return;
}

View File

@ -28,7 +28,7 @@ export async function nextPage(currentPage, $scope, errorHandler, fetch) {
} catch (error) {
$scope.wazuh_table_loading = false;
$scope.error = `Error paginating table - ${error.message ||
error} - Please refresh your browser.`;
error}.`;
errorHandler.handle(
`Error paginating table due to ${error.message || error}`,
'Data factory'

View File

@ -19,12 +19,11 @@ export async function sort(field, $scope, instance, fetch, errorHandler) {
$scope.sortDir = instance.sortDir;
await fetch();
$scope.wazuh_table_loading = false;
if (!$scope.$$phase) $scope.$digest();
} catch (error) {
$scope.wazuh_table_loading = false;
$scope.error = `Error sorting table by ${
field ? field.value : 'undefined'
} - ${error.message || error} - Please refresh your browser.`;
} - ${error.message || error}.`;
errorHandler.handle(
`Error sorting table by ${
field ? field.value : 'undefined'
@ -32,5 +31,6 @@ export async function sort(field, $scope, instance, fetch, errorHandler) {
'Data factory'
);
}
if (!$scope.$$phase) $scope.$digest();
return;
}