Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
aa03de8e
Commit
aa03de8e
authored
Aug 10, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work on integrated console, with request details
parent
eb9a7267
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
17 deletions
+107
-17
src/app/controllers/console-ctrl.js
+70
-8
src/app/partials/console.html
+9
-4
src/css/less/console.less
+28
-5
No files found.
src/app/controllers/console-ctrl.js
View file @
aa03de8e
define
([
'angular'
,
'lodash'
,
'moment'
,
],
function
(
angular
,
moment
)
{
function
(
angular
,
_
,
moment
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
...
...
@@ -14,6 +15,20 @@ function (angular, moment) {
var
events
=
[];
var
oldLog
=
console
.
log
;
console
.
log
=
function
(
message
)
{
try
{
if
(
_
.
isObject
(
message
))
{
message
=
angular
.
toJson
(
message
);
if
(
message
.
length
>
50
)
{
message
=
message
.
substring
(
0
,
50
);
}
}
events
.
push
(
new
ConsoleEvent
(
'log'
,
message
,
{}));
oldLog
.
apply
(
console
,
arguments
);
}
catch
(
e
)
{
}
};
function
ConsoleEvent
(
type
,
title
,
data
)
{
this
.
type
=
type
;
this
.
title
=
title
;
...
...
@@ -21,17 +36,54 @@ function (angular, moment) {
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)'
;
this
.
method
=
data
.
config
.
method
;
this
.
elapsed
=
(
new
Date
().
getTime
()
-
data
.
config
.
$grafana_timestamp
)
+
' ms'
;
if
(
data
.
config
.
params
&&
data
.
config
.
params
.
q
)
{
this
.
query
=
data
.
config
.
params
.
q
;
this
.
field2
=
data
.
config
.
params
.
q
;
}
if
(
_
.
isString
(
data
.
config
.
data
))
{
this
.
field2
=
data
.
config
.
data
;
}
if
(
data
.
status
!==
200
)
{
this
.
error
=
true
;
this
.
field3
=
data
.
data
;
}
if
(
_
.
isArray
(
data
.
data
))
{
this
.
extractTimeseriesInfo
(
data
.
data
);
}
}
}
module
.
config
(
function
(
$httpProvider
)
{
$httpProvider
.
interceptors
.
push
(
function
()
{
ConsoleEvent
.
prototype
.
extractTimeseriesInfo
=
function
(
series
)
{
if
(
series
.
length
===
0
)
{
return
;
}
var
points
=
0
;
var
ok
=
false
;
if
(
series
[
0
].
datapoints
)
{
points
=
_
.
reduce
(
series
,
function
(
memo
,
val
)
{
return
memo
+
val
.
datapoints
.
length
;
},
0
);
ok
=
true
;
}
if
(
series
[
0
].
columns
)
{
points
=
_
.
reduce
(
series
,
function
(
memo
,
val
)
{
return
memo
+
val
.
points
.
length
;
},
0
);
ok
=
true
;
}
if
(
ok
)
{
this
.
field1
=
'('
+
series
.
length
+
' series'
;
this
.
field1
+=
', '
+
points
+
' points)'
;
}
};
module
.
config
(
function
(
$provide
,
$httpProvider
)
{
$provide
.
factory
(
'mupp'
,
function
(
$q
)
{
return
{
'request'
:
function
(
config
)
{
if
(
config
.
inspect
)
{
...
...
@@ -42,12 +94,22 @@ function (angular, moment) {
'response'
:
function
(
response
)
{
if
(
response
.
config
.
inspect
)
{
events
.
push
(
new
ConsoleEvent
(
response
.
config
.
inspect
.
type
,
response
.
config
.
url
,
response
));
console
.
log
(
response
);
}
return
response
;
},
'requestError'
:
function
(
rejection
)
{
console
.
log
(
'requestError'
,
rejection
);
return
$q
.
reject
(
rejection
);
},
'responseError'
:
function
(
rejection
)
{
var
inspect
=
rejection
.
config
.
inspect
||
{
type
:
'error'
};
events
.
push
(
new
ConsoleEvent
(
inspect
.
type
,
rejection
.
config
.
url
,
rejection
));
return
$q
.
reject
(
rejection
);
}
};
});
$httpProvider
.
interceptors
.
push
(
'mupp'
);
});
module
.
controller
(
'ConsoleCtrl'
,
function
(
$scope
)
{
...
...
src/app/partials/console.html
View file @
aa03de8e
...
...
@@ -3,12 +3,17 @@
<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"
>
<div
class=
"grafana-console-item"
ng-repeat=
"item in events"
ng-class=
"{'grafana-console-error': item.error}"
>
<span
class=
"grafana-console-time
gfc-col
"
ng-bind=
"item.time"
></span>
<span
class=
"grafana-console-type
gfc-col
"
>
<span
class=
"label label-info"
ng-bind=
"item.type"
></span>
</span>
<span
class=
"grafana-console-title"
ng-bind=
"item.title"
></span>
<span
class=
"gfc-col grafana-console-method"
ng-bind=
"item.method"
></span>
<span
class=
"gfc-col grafana-console-title"
ng-bind=
"item.title"
></span>
<span
class=
"gfc-col grafana-console-elapsed"
ng-bind=
"item.elapsed"
></span>
<span
class=
"gfc-col grafana-console-field1"
ng-bind=
"item.field1"
></span>
<span
class=
"gfc-col grafana-console-field2"
ng-bind=
"item.field2"
></span>
<span
class=
"gfc-col grafana-console-field3"
ng-bind=
"item.field3"
></span>
</div>
</div>
</div>
src/css/less/console.less
View file @
aa03de8e
...
...
@@ -19,17 +19,35 @@
color: @blue;
}
margin: 2px 0;
display: table-row;
}
.grafana-console-body {
overflow-y: auto;
padding-left: 3px;
display: table;
width: 100%;
}
.gfc-col {
display: table-cell;
padding: 2px 4px;
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
}
.grafana-console-type {
margin: 0 3px;
min-width: 75px;
display: inline-block;
.grafana-console-method {
text-align: center;
}
.grafana-console-error {
.grafana-console-method {
color: red;
}
}
.grafana-console-field2 {
width: 90%;
}
.grafana-console-time:before {
...
...
@@ -46,3 +64,8 @@
color: rgb(162, 196, 253);
}
.grafana-console-elapsed {
text-align: right;
color: rgb(162, 196, 253);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment