Files
redash/client/app/components/cancel-query-button/index.js
Arik Fraimovich 56d3be2248 Prettier all the Javascript code & GitHub Action (#4433)
* Prettier all the JS files

* Add GitHub Action to autoformat code pushed to master

* Fix eslint violation due to formatting.

* Remove GitHub actions for styling

* Add restyled.io config
2019-12-11 17:05:38 +02:00

35 lines
923 B
JavaScript

function cancelQueryButton() {
return {
restrict: "E",
scope: {
queryId: "=",
taskId: "=",
},
transclude: true,
template:
'<button class="btn btn-default" ng-disabled="inProgress" ng-click="cancelExecution()"><i class="zmdi zmdi-spinner zmdi-hc-spin" ng-if="inProgress"></i> Cancel</button>',
replace: true,
controller($scope, $http, currentUser, Events) {
$scope.inProgress = false;
$scope.cancelExecution = () => {
$http.delete(`api/jobs/${$scope.taskId}`).success(() => {});
let queryId = $scope.queryId;
if ($scope.queryId === "adhoc") {
queryId = null;
}
Events.record("cancel_execute", "query", queryId, { admin: true });
$scope.inProgress = true;
};
},
};
}
export default function init(ngModule) {
ngModule.directive("cancelQueryButton", cancelQueryButton);
}
init.init = true;