mirror of https://github.com/grafana/grafana
began work on inspection console to visualize metric requests, and other useful troubleshooting info and inspection
parent
21b7c6a2c0
commit
eb9a7267bd
@ -0,0 +1,59 @@ |
|||||||
|
define([ |
||||||
|
'angular', |
||||||
|
'moment', |
||||||
|
], |
||||||
|
function (angular, moment) { |
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var module = angular.module('grafana.controllers'); |
||||||
|
var consoleEnabled = window.localStorage && window.localStorage.grafanaConsole === 'true'; |
||||||
|
|
||||||
|
if (!consoleEnabled) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
var events = []; |
||||||
|
|
||||||
|
function ConsoleEvent(type, title, data) { |
||||||
|
this.type = type; |
||||||
|
this.title = title; |
||||||
|
this.data = data; |
||||||
|
this.time = moment().format('hh:mm:ss'); |
||||||
|
|
||||||
|
if (data.config) { |
||||||
|
this.title = data.config.method + ' ' + this.title; |
||||||
|
this.elapsed = new Date().getTime() - data.config.$grafana_timestamp; |
||||||
|
this.title = this.title + ' (' + this.elapsed + ' ms)'; |
||||||
|
if (data.config.params && data.config.params.q) { |
||||||
|
this.query = data.config.params.q; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.config(function($httpProvider) { |
||||||
|
$httpProvider.interceptors.push(function() { |
||||||
|
return { |
||||||
|
'request': function(config) { |
||||||
|
if (config.inspect) { |
||||||
|
config.$grafana_timestamp = new Date().getTime(); |
||||||
|
} |
||||||
|
return config; |
||||||
|
}, |
||||||
|
'response': function(response) { |
||||||
|
if (response.config.inspect) { |
||||||
|
events.push(new ConsoleEvent(response.config.inspect.type, response.config.url, response)); |
||||||
|
console.log(response); |
||||||
|
} |
||||||
|
return response; |
||||||
|
} |
||||||
|
}; |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
module.controller('ConsoleCtrl', function($scope) { |
||||||
|
|
||||||
|
$scope.events = events; |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
}); |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
<div class="grafana-console" ng-controller="ConsoleCtrl"> |
||||||
|
<div class="grafana-console-header"> |
||||||
|
<span class="grafana-console-title large"><i class="icon-terminal"></i></span> |
||||||
|
</div> |
||||||
|
<div class="grafana-console-body"> |
||||||
|
<div class="grafana-console-item" ng-repeat="item in events"> |
||||||
|
<span class="grafana-console-time" ng-bind="item.time"></span> |
||||||
|
<span class="grafana-console-type"> |
||||||
|
<span class="label label-info" ng-bind="item.type"></span> |
||||||
|
</span> |
||||||
|
<span class="grafana-console-title" ng-bind="item.title"></span> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
.grafana-console { |
||||||
|
position: fixed; |
||||||
|
width: 100%; |
||||||
|
bottom: 0px; |
||||||
|
height: 300px; |
||||||
|
background: @grafanaPanelBackground; |
||||||
|
border-top: 1px solid @fullEditBorder; |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-header { |
||||||
|
background: @fullEditTabsBackground; |
||||||
|
border-top: @fullEditTabsBorder; |
||||||
|
padding: 2px 5px; |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-item { |
||||||
|
.icon-caret-right { |
||||||
|
font-size: 14px; |
||||||
|
color: @blue; |
||||||
|
} |
||||||
|
margin: 2px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-body { |
||||||
|
overflow-y: auto; |
||||||
|
padding-left: 3px; |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-type { |
||||||
|
margin: 0 3px; |
||||||
|
min-width: 75px; |
||||||
|
display: inline-block; |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-time:before { |
||||||
|
content: '('; |
||||||
|
color: rgb(106, 253, 81); |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-time:after { |
||||||
|
content: ')'; |
||||||
|
color: rgb(106, 253, 81); |
||||||
|
} |
||||||
|
|
||||||
|
.grafana-console-time { |
||||||
|
color: rgb(162, 196, 253); |
||||||
|
} |
||||||
|
|
||||||
@ -1,5 +1,6 @@ |
|||||||
// Lint and build CSS
|
// Lint and build CSS
|
||||||
module.exports = function(grunt) { |
module.exports = function(grunt) { |
||||||
grunt.registerTask('default', ['jscs', 'jshint', 'less:src', 'concat:cssDark', 'concat:cssLight']); |
grunt.registerTask('css', ['less:src', 'concat:cssDark', 'concat:cssLight']); |
||||||
|
grunt.registerTask('default', ['jscs', 'jshint', 'css']); |
||||||
grunt.registerTask('test', ['default', 'karma:test']); |
grunt.registerTask('test', ['default', 'karma:test']); |
||||||
}; |
}; |
||||||
|
|||||||
@ -0,0 +1,11 @@ |
|||||||
|
module.exports = function(config) { |
||||||
|
return { |
||||||
|
css: { |
||||||
|
files: [ '<%= srcDir %>/css/**/*.less' ], |
||||||
|
tasks: ['css'], |
||||||
|
options: { |
||||||
|
spawn: false |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
}; |
||||||
Loading…
Reference in new issue