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
e754bcdc
Unverified
Commit
e754bcdc
authored
May 14, 2020
by
Andrej Ocenas
Committed by
GitHub
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CloudWatch: Unify look of query mode select between dashboard and explore (#24648)
parent
abfa1b5d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
70 deletions
+14
-70
public/app/plugins/datasource/cloudwatch/components/CombinedMetricsEditor.tsx
+0
-48
public/app/plugins/datasource/cloudwatch/components/PanelQueryEditor.tsx
+13
-20
public/app/plugins/datasource/cloudwatch/module.tsx
+1
-2
No files found.
public/app/plugins/datasource/cloudwatch/components/CombinedMetricsEditor.tsx
deleted
100644 → 0
View file @
abfa1b5d
import
React
,
{
PureComponent
}
from
'react'
;
import
{
ExploreQueryFieldProps
}
from
'@grafana/data'
;
import
{
RadioButtonGroup
}
from
'@grafana/ui'
;
import
{
CloudWatchQuery
}
from
'../types'
;
import
{
CloudWatchDatasource
}
from
'../datasource'
;
import
LogsQueryEditor
from
'./LogsQueryEditor'
;
import
{
MetricsQueryEditor
}
from
'./MetricsQueryEditor'
;
import
{
cx
,
css
}
from
'emotion'
;
export
type
Props
=
ExploreQueryFieldProps
<
CloudWatchDatasource
,
CloudWatchQuery
>
;
export
class
CombinedMetricsEditor
extends
PureComponent
<
Props
>
{
renderMetricsEditor
()
{
return
<
MetricsQueryEditor
{
...
this
.
props
}
/>;
}
renderLogsEditor
()
{
return
<
LogsQueryEditor
{
...
this
.
props
}
/>;
}
render
()
{
const
{
query
}
=
this
.
props
;
const
apiMode
=
query
.
apiMode
??
query
.
queryMode
??
'Metrics'
;
return
(
<>
<
div
className=
{
cx
(
css
`
margin-bottom: 4px;
`
)
}
>
<
RadioButtonGroup
options=
{
[
{
label
:
'Metrics API'
,
value
:
'Metrics'
},
{
label
:
'Logs API'
,
value
:
'Logs'
},
]
}
value=
{
apiMode
}
onChange=
{
(
v
:
'Metrics'
|
'Logs'
)
=>
this
.
props
.
onChange
({
...
query
,
apiMode
:
v
})
}
/>
</
div
>
{
apiMode
===
'Metrics'
?
this
.
renderMetricsEditor
()
:
this
.
renderLogsEditor
()
}
</>
);
}
}
public/app/plugins/datasource/cloudwatch/components/PanelQueryEditor.tsx
View file @
e754bcdc
...
...
@@ -9,35 +9,28 @@ import LogsQueryEditor from './LogsQueryEditor';
export
type
Props
=
ExploreQueryFieldProps
<
CloudWatchDatasource
,
CloudWatchQuery
>
;
interface
State
{
queryMode
:
ExploreMode
;
}
export
class
PanelQueryEditor
extends
PureComponent
<
Props
,
State
>
{
state
:
State
=
{
queryMode
:
(
this
.
props
.
query
.
queryMode
as
ExploreMode
)
??
ExploreMode
.
Metrics
};
onQueryModeChange
(
mode
:
ExploreMode
)
{
this
.
setState
({
queryMode
:
mode
,
});
}
const
apiModes
=
{
Metrics
:
{
label
:
'CloudWatch Metrics'
,
value
:
'Metrics'
},
Logs
:
{
label
:
'CloudWatch Logs'
,
value
:
'Logs'
},
};
export
class
PanelQueryEditor
extends
PureComponent
<
Props
>
{
render
()
{
const
{
queryMode
}
=
this
.
state
;
const
{
query
}
=
this
.
props
;
const
apiMode
=
query
.
apiMode
??
query
.
queryMode
??
'Metrics'
;
return
(
<>
<
QueryInlineField
label=
"Query Mode"
>
<
Segment
value=
{
queryMode
}
options=
{
[
{
label
:
'Metrics'
,
value
:
ExploreMode
.
Metrics
},
{
label
:
'Logs'
,
value
:
ExploreMode
.
Logs
},
]
}
onChange=
{
({
value
})
=>
this
.
onQueryModeChange
(
value
??
ExploreMode
.
Metrics
)
}
value=
{
apiModes
[
apiMode
]
}
options=
{
Object
.
values
(
apiModes
)
}
onChange=
{
({
value
})
=>
this
.
props
.
onChange
({
...
query
,
apiMode
:
(
value
as
'Metrics'
|
'Logs'
)
??
'Metrics'
})
}
/>
</
QueryInlineField
>
{
query
Mode
===
ExploreMode
.
Logs
?
<
LogsQueryEditor
{
...
this
.
props
}
/>
:
<
MetricsQueryEditor
{
...
this
.
props
}
/>
}
{
api
Mode
===
ExploreMode
.
Logs
?
<
LogsQueryEditor
{
...
this
.
props
}
/>
:
<
MetricsQueryEditor
{
...
this
.
props
}
/>
}
</>
);
}
...
...
public/app/plugins/datasource/cloudwatch/module.tsx
View file @
e754bcdc
...
...
@@ -7,7 +7,6 @@ import { CloudWatchJsonData, CloudWatchQuery } from './types';
import
{
CloudWatchLogsQueryEditor
}
from
'./components/LogsQueryEditor'
;
import
{
PanelQueryEditor
}
from
'./components/PanelQueryEditor'
;
import
LogsCheatSheet
from
'./components/LogsCheatSheet'
;
import
{
CombinedMetricsEditor
}
from
'./components/CombinedMetricsEditor'
;
export
const
plugin
=
new
DataSourcePlugin
<
CloudWatchDatasource
,
CloudWatchQuery
,
CloudWatchJsonData
>
(
CloudWatchDatasource
...
...
@@ -15,6 +14,6 @@ export const plugin = new DataSourcePlugin<CloudWatchDatasource, CloudWatchQuery
.
setExploreStartPage
(
LogsCheatSheet
)
.
setConfigEditor
(
ConfigEditor
)
.
setQueryEditor
(
PanelQueryEditor
)
.
setExploreMetricsQueryField
(
CombinedMetrics
Editor
)
.
setExploreMetricsQueryField
(
PanelQuery
Editor
)
.
setExploreLogsQueryField
(
CloudWatchLogsQueryEditor
)
.
setAnnotationQueryCtrl
(
CloudWatchAnnotationsQueryCtrl
);
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