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
9cce5217
Commit
9cce5217
authored
Oct 23, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: fixed gofmt issue and addd mock response feature
parent
139f0774
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
pkg/api/alerting.go
+1
-2
public/app/features/panel/query_troubleshooter.ts
+33
-1
No files found.
pkg/api/alerting.go
View file @
9cce5217
...
...
@@ -22,8 +22,7 @@ func ValidateOrgAlert(c *middleware.Context) {
if
c
.
OrgId
!=
query
.
Result
.
OrgId
{
c
.
JsonApiErr
(
403
,
"You are not allowed to edit/view alert"
,
nil
)
return
}
}
}
func
GetAlertStatesForDashboard
(
c
*
middleware
.
Context
)
Response
{
...
...
public/app/features/panel/query_troubleshooter.ts
View file @
9cce5217
...
...
@@ -7,6 +7,7 @@ import {coreModule, JsonExplorer} from 'app/core/core';
const
template
=
`
<div class="query-troubleshooter" ng-if="ctrl.isOpen">
<div class="query-troubleshooter__header">
<a class="pointer" ng-click="ctrl.toggleMocking()">Mock Response</a>
<a class="pointer" ng-click="ctrl.toggleExpand()" ng-hide="ctrl.allNodesExpanded">
<i class="fa fa-plus-square-o"></i> Expand All
</a>
...
...
@@ -15,10 +16,18 @@ const template = `
</a>
<a class="pointer" clipboard-button="ctrl.getClipboardText()"><i class="fa fa-clipboard"></i> Copy to Clipboard</a>
</div>
<div class="query-troubleshooter__body">
<div class="query-troubleshooter__body"
ng-hide="ctrl.isMocking"
>
<i class="fa fa-spinner fa-spin" ng-show="ctrl.isLoading"></i>
<div class="query-troubleshooter-json"></div>
</div>
<div class="query-troubleshooter__body" ng-show="ctrl.isMocking">
<div class="gf-form p-l-1">
<div class="gf-form gf-form--v-stretch">
<span class="gf-form-label width-10">Response JSON</span>
<textarea class="gf-form-input width-25" rows="10" ng-model="ctrl.mockedResponse" placeholder="JSON"></textarea>
</div>
</div>
</div>
</div>
`
;
...
...
@@ -32,6 +41,8 @@ export class QueryTroubleshooterCtrl {
onRequestResponseEventListener
:
any
;
hasError
:
boolean
;
allNodesExpanded
:
boolean
;
isMocking
:
boolean
;
mockedResponse
:
string
;
jsonExplorer
:
JsonExplorer
;
/** @ngInject **/
...
...
@@ -51,6 +62,10 @@ export class QueryTroubleshooterCtrl {
appEvents
.
off
(
'ds-request-error'
,
this
.
onRequestErrorEventListener
);
}
toggleMocking
()
{
this
.
isMocking
=
!
this
.
isMocking
;
}
onRequestError
(
err
)
{
// ignore if closed
if
(
!
this
.
isOpen
)
{
...
...
@@ -76,12 +91,29 @@ export class QueryTroubleshooterCtrl {
return
''
;
}
handleMocking
(
data
)
{
var
mockedData
;
try
{
mockedData
=
JSON
.
parse
(
this
.
mockedResponse
);
}
catch
(
err
)
{
appEvents
.
emit
(
'alert-error'
,
[
'Failed to parse mocked response'
]);
return
;
}
data
.
data
=
mockedData
;
}
onRequestResponse
(
data
)
{
// ignore if closed
if
(
!
this
.
isOpen
)
{
return
;
}
if
(
this
.
isMocking
)
{
this
.
handleMocking
(
data
);
return
;
}
this
.
isLoading
=
false
;
data
=
_
.
cloneDeep
(
data
);
...
...
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