diff --git a/pkg/api/alerting.go b/pkg/api/alerting.go index c01c8b24446..58ea56cc8a7 100644 --- a/pkg/api/alerting.go +++ b/pkg/api/alerting.go @@ -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 { diff --git a/public/app/features/panel/query_troubleshooter.ts b/public/app/features/panel/query_troubleshooter.ts index 1fc0b6a3dc0..39c9cb0055b 100644 --- a/public/app/features/panel/query_troubleshooter.ts +++ b/public/app/features/panel/query_troubleshooter.ts @@ -7,6 +7,7 @@ import {coreModule, JsonExplorer} from 'app/core/core'; const template = `
+ Mock Response Expand All @@ -15,10 +16,18 @@ const template = ` Copy to Clipboard
-
+
+
+
+
+ Response JSON + +
+
+
`; @@ -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);