Skip to content

Commit

Permalink
Merge pull request #979 from wazuh/aborted-request-table
Browse files Browse the repository at this point in the history
Aborted request wz-table
  • Loading branch information
Jesús Ángel authored Oct 24, 2018
2 parents 9d8ec5d + b7aef13 commit a2bad87
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Changed some labels to remove the "MD5 sum" expression, it will use "Checksum" instead ([#945](https://github.com/wazuh/wazuh-kibana-app/pull/945)).
- Added word wrapping class to group name in _Management > Groups > Group detail_ tab ([#945](https://github.com/wazuh/wazuh-kibana-app/pull/945)).
- The `wz-table` directive has been refactored ([#953](https://github.com/wazuh/wazuh-kibana-app/pull/953)).
- The `wz-table` directive now checks if a request is aborted ([]()).

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions public/directives/wz-table/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions public/directives/wz-table/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion public/directives/wz-table/lib/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions public/directives/wz-table/lib/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ 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'
}. ${error.message || error}`,
'Data factory'
);
}
if (!$scope.$$phase) $scope.$digest();
return;
}
5 changes: 4 additions & 1 deletion public/directives/wz-table/wz-table-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ app.directive('wzTable', function() {
$scope.searchTable();
return;
} catch (error) {
if(error && !error.data && error.status === -1 && error.xhrStatus === 'abort') {
return Promise.reject('Request took too long, aborted')
}
return Promise.reject(error);
}
};
Expand Down Expand Up @@ -134,7 +137,7 @@ app.directive('wzTable', function() {
} catch (error) {
realTime = false;
$scope.error = `Real time feature aborted - ${error.message ||
error} - Please refresh your browser.`;
error}.`;
errorHandler.handle(
`Real time feature aborted. ${error.message || error}`,
'Data factory'
Expand Down
2 changes: 1 addition & 1 deletion public/directives/wz-table/wz-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</table>
</div>

<div layout="row" ng-if="!wazuh_table_loading && !totalItems">
<div layout="row" ng-if="!error && !wazuh_table_loading && !totalItems">
<div flex class="euiCallOut euiCallOut--warning">
<div class="euiCallOutHeader">
<svg class="euiIcon euiIcon--medium euiCallOutHeader__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><path id="help-a" d="M13.6 12.186l-1.357-1.358c-.025-.025-.058-.034-.084-.056.53-.794.84-1.746.84-2.773a4.977 4.977 0 0 0-.84-2.772c.026-.02.059-.03.084-.056L13.6 3.813a6.96 6.96 0 0 1 0 8.373zM8 15A6.956 6.956 0 0 1 3.814 13.6l1.358-1.358c.025-.025.034-.057.055-.084C6.02 12.688 6.974 13 8 13a4.978 4.978 0 0 0 2.773-.84c.02.026.03.058.056.083l1.357 1.358A6.956 6.956 0 0 1 8 15zm-5.601-2.813a6.963 6.963 0 0 1 0-8.373l1.359 1.358c.024.025.057.035.084.056A4.97 4.97 0 0 0 3 8c0 1.027.31 1.98.842 2.773-.027.022-.06.031-.084.056l-1.36 1.358zm5.6-.187A4 4 0 1 1 8 4a4 4 0 0 1 0 8zM8 1c1.573 0 3.019.525 4.187 1.4l-1.357 1.358c-.025.025-.035.057-.056.084A4.979 4.979 0 0 0 8 3a4.979 4.979 0 0 0-2.773.842c-.021-.027-.03-.059-.055-.084L3.814 2.4A6.957 6.957 0 0 1 8 1zm0-1a8.001 8.001 0 1 0 .003 16.002A8.001 8.001 0 0 0 8 0z"></path></defs><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#help-a" fill-rule="evenodd"></use></svg>
Expand Down

0 comments on commit a2bad87

Please sign in to comment.