UNPKG

anthtrigger

Version:

Trigger events via http service

53 lines (50 loc) 1.57 kB
(function() { angular.module('anthTrigger').controller('viewLogsController', function($scope, $location, $interval, $http, ansi2html, $sce, id) { var loadLogs, t, _st; $scope.status = _st = {}; $scope.logs = {}; t = null; $scope.autoReload = false; loadLogs = function() { _st.load = 'loading'; return $http.get('/scriptLogs/find/' + id).success(function(result) { $scope.logs = result.data; if ($scope.logs.endAt) { $scope.autoReload = false; $scope.setAuto(false); } return _st.load = 'done'; }); }; loadLogs(); $scope.setAuto = function(auto) { if (auto) { return t = $interval(loadLogs, 1000); } else { if (angular.isDefined(t)) { return $interval.cancel(t); } } }; $scope.$on('$locationChangeStart', function() { if (angular.isDefined(t)) { return $interval.cancel(t); } }); $scope.killScript = function(scriptId, title, index) { if (!confirm("确定要【Kill】脚本:\n\n\t'" + title + "'\n\n的此次执行吗?")) { return; } return $http.post('/scripts/kill/' + scriptId).success(function(result) { if (result.success) { notify("中止脚本 (" + title + ") 成功!"); $scope.logs = result.logs; return $scope.setAuto(false); } else { return notify("中止脚本 (" + title + ") 失败!"); } }); }; }); }).call(this); //# sourceMappingURL=viewLogsController.js.map