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
86ce3d5e
Commit
86ce3d5e
authored
May 17, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: in app query request & response troubleshooting
parent
87f52229
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
6 deletions
+57
-6
public/app/core/services/backend_srv.ts
+7
-1
public/app/features/panel/metrics_ds_selector.ts
+49
-4
public/app/features/panel/metrics_panel_ctrl.ts
+1
-1
No files found.
public/app/core/services/backend_srv.ts
View file @
86ce3d5e
...
...
@@ -4,6 +4,7 @@ import angular from 'angular';
import
_
from
'lodash'
;
import
config
from
'app/core/config'
;
import
coreModule
from
'app/core/core_module'
;
import
appEvents
from
'app/core/app_events'
;
export
class
BackendSrv
{
inFlightRequests
=
{};
...
...
@@ -150,7 +151,10 @@ export class BackendSrv {
}
}
return
this
.
$http
(
options
).
catch
(
err
=>
{
return
this
.
$http
(
options
).
then
(
response
=>
{
appEvents
.
emit
(
'ds-request-response'
,
response
);
return
response
;
}).
catch
(
err
=>
{
if
(
err
.
status
===
this
.
HTTP_REQUEST_CANCELLED
)
{
throw
{
err
,
cancelled
:
true
};
}
...
...
@@ -179,7 +183,9 @@ export class BackendSrv {
err
.
data
.
message
=
err
.
data
.
error
;
}
appEvents
.
emit
(
'ds-request-error'
,
err
);
throw
err
;
}).
finally
(()
=>
{
// clean up
if
(
options
.
requestId
)
{
...
...
public/app/features/panel/metrics_ds_selector.ts
View file @
86ce3d5e
...
...
@@ -2,10 +2,24 @@
import
angular
from
'angular'
;
import
_
from
'lodash'
;
import
appEvents
from
'app/core/app_events'
;
var
module
=
angular
.
module
(
'grafana.directives'
);
var
template
=
`
<div class="gf-form-group" ng-if="ctrl.lastError">
<div class="gf-form">
<pre class="gf-form-pre alert alert-error">{{ctrl.lastError}}</pre>
</div>
</div>
<div class="gf-form-group" ng-if="ctrl.showResponse">
<div class="gf-form">
<pre class="gf-form-pre alert alert-info">{{ctrl.lastResponse}}</pre>
</div>
</div>
<div class="gf-form-group">
<div class="gf-form-inline">
<div class="gf-form">
...
...
@@ -22,9 +36,9 @@ var template = `
</div>
<div class="gf-form gf-form--offset-1">
<button class="btn btn-
secondary
gf-form-btn" ng-click="ctrl.addDataQuery()" ng-hide="ctrl.current.meta.mixed">
<button class="btn btn-
inverse
gf-form-btn" ng-click="ctrl.addDataQuery()" ng-hide="ctrl.current.meta.mixed">
<i class="fa fa-plus"></i>
Add
q
uery
Add
Q
uery
</button>
<div class="dropdown" ng-if="ctrl.current.meta.mixed">
...
...
@@ -33,6 +47,14 @@ var template = `
on-change="ctrl.mixedDatasourceChanged()"></metric-segment>
</div>
</div>
<div class="gf-form gf-form--offset-1">
<button class="btn btn-secondary gf-form-btn" ng-click="ctrl.toggleShowResponse()" ng-show="ctrl.lastResponse">
<i class="fa fa-info"></i>
Show Response
</button>
</div>
</div>
</div>
`
;
...
...
@@ -45,9 +67,12 @@ export class MetricsDsSelectorCtrl {
panelCtrl
:
any
;
datasources
:
any
[];
current
:
any
;
lastResponse
:
any
;
lastError
:
any
;
showResponse
:
boolean
;
/** @ngInject */
constructor
(
private
uiSegmentSrv
,
datasourceSrv
)
{
constructor
(
$scope
,
private
uiSegmentSrv
,
datasourceSrv
)
{
this
.
datasources
=
datasourceSrv
.
getMetricSources
();
var
dsValue
=
this
.
panelCtrl
.
panel
.
datasource
||
null
;
...
...
@@ -63,7 +88,25 @@ export class MetricsDsSelectorCtrl {
}
this
.
dsSegment
=
uiSegmentSrv
.
newSegment
({
value
:
this
.
current
.
name
,
selectMode
:
true
});
this
.
mixedDsSegment
=
uiSegmentSrv
.
newSegment
({
value
:
'Add query'
,
selectMode
:
true
});
this
.
mixedDsSegment
=
uiSegmentSrv
.
newSegment
({
value
:
'Add Query'
,
selectMode
:
true
});
appEvents
.
on
(
'ds-request-response'
,
this
.
onRequestResponse
.
bind
(
this
),
$scope
);
appEvents
.
on
(
'ds-request-error'
,
this
.
onRequestError
.
bind
(
this
),
$scope
);
}
onRequestResponse
(
data
)
{
console
.
log
(
data
);
this
.
lastResponse
=
JSON
.
stringify
(
data
,
null
,
2
);
this
.
lastError
=
null
;
}
toggleShowResponse
()
{
this
.
showResponse
=
!
this
.
showResponse
;
}
onRequestError
(
err
)
{
console
.
log
(
err
);
this
.
lastError
=
JSON
.
stringify
(
err
,
null
,
2
);
}
getOptions
(
includeBuiltin
)
{
...
...
@@ -79,6 +122,8 @@ export class MetricsDsSelectorCtrl {
if
(
ds
)
{
this
.
current
=
ds
;
this
.
panelCtrl
.
setDatasource
(
ds
);
this
.
lastError
=
null
;
this
.
lastResponse
=
null
;
}
}
...
...
public/app/features/panel/metrics_panel_ctrl.ts
View file @
86ce3d5e
...
...
@@ -256,7 +256,7 @@ class MetricsPanelCtrl extends PanelCtrl {
result
=
{
data
:
[]};
}
return
this
.
events
.
emit
(
'data-received'
,
result
.
data
);
this
.
events
.
emit
(
'data-received'
,
result
.
data
);
}
handleDataStream
(
stream
)
{
...
...
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