bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/bosun/web/static/js/dashboard.ts (about)

     1  interface IDashboardScope extends IBosunScope {
     2  	error: string;
     3  	loading: string;
     4  	filter: string;
     5  	keydown: any;
     6  }
     7  
     8  bosunControllers.controller('DashboardCtrl', ['$scope', '$http', '$location', function($scope: IDashboardScope, $http: ng.IHttpService, $location: ng.ILocationService) {
     9  	var search = $location.search();
    10  	$scope.loading = 'Loading';
    11  	$scope.error = '';
    12  	$scope.filter = search.filter;
    13  	if (!$scope.filter) {
    14  		$scope.filter = readCookie("filter");
    15  	}
    16  	$location.search('filter', $scope.filter || null);
    17  	reload();
    18  	function reload() {
    19  		$scope.refresh($scope.filter).then(() => {
    20  				$scope.loading = '';
    21  				$scope.error = '';
    22  			}, (err: any) => {
    23  				$scope.loading = '';
    24  				$scope.error = 'Unable to fetch alerts: ' + err;
    25  			});
    26  	}
    27  	$scope.keydown = function($event: any) {
    28  		if ($event.keyCode == 13) {
    29  			createCookie("filter", $scope.filter || "", 1000);
    30  			$location.search('filter', $scope.filter || null);
    31  		}
    32  	}
    33  }]);