Last active
March 11, 2018 21:49
-
-
Save jezhalford/f689eb5b5cca129b3875e9cfe7c734cf to your computer and use it in GitHub Desktop.
Revisions
-
jezhalford revised this gist
Dec 15, 2016 . No changes.There are no files selected for viewing
-
jezhalford created this gist
Dec 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ <!-- Heavily based on https://github.com/grafana/grafana/issues/1816#issuecomment-137827966, with some simplification and modifications for newer version of Grafana --> <div> <script type="text/javascript"> (function() { // get a reference to the result container (this is a div at the bottom of this script) var elem = $('#myPanel') function refreshMyPanel() { $.ajax({ // api url and options... url: "http://example.com/api/query", jsonp: "callback", dataType: "jsonp", success: function( response ) { // show loading spinner... elem.parent().closest(".panel-container").find('.panel-loading').removeClass("ng-hide"); // handle the response... elem.text(response); // hide loading spinner... setTimeout(function() { elem.parent().closest(".panel-container").find('.panel-loading').addClass("ng-hide"); }, 1000); } }) } $(document).ready(function() { // initial load refreshMyPanel() // hook into the dashboard refresh event angular.element(elem).injector().get('$rootScope').$on('refresh', function() { refreshMyPanel() }) }); })(); </script> <div id="myPanel" /> </div>