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
307248f7
Commit
307248f7
authored
Aug 04, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clear row button
- clears the content of a query row
parent
00f04f4e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
57 deletions
+67
-57
public/app/containers/Explore/Explore.tsx
+48
-48
public/app/containers/Explore/QueryRows.tsx
+18
-8
public/sass/pages/_explore.scss
+1
-1
No files found.
public/app/containers/Explore/Explore.tsx
View file @
307248f7
...
@@ -166,7 +166,7 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -166,7 +166,7 @@ export class Explore extends React.Component<any, IExploreState> {
supportsTable
,
supportsTable
,
datasourceLoading
:
false
,
datasourceLoading
:
false
,
},
},
()
=>
datasourceError
===
null
&&
this
.
handle
Submit
()
()
=>
datasourceError
===
null
&&
this
.
on
Submit
()
);
);
}
}
...
@@ -174,7 +174,7 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -174,7 +174,7 @@ export class Explore extends React.Component<any, IExploreState> {
this
.
el
=
el
;
this
.
el
=
el
;
};
};
handle
AddQueryRow
=
index
=>
{
on
AddQueryRow
=
index
=>
{
const
{
queries
}
=
this
.
state
;
const
{
queries
}
=
this
.
state
;
const
nextQueries
=
[
const
nextQueries
=
[
...
queries
.
slice
(
0
,
index
+
1
),
...
queries
.
slice
(
0
,
index
+
1
),
...
@@ -184,7 +184,7 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -184,7 +184,7 @@ export class Explore extends React.Component<any, IExploreState> {
this
.
setState
({
queries
:
nextQueries
});
this
.
setState
({
queries
:
nextQueries
});
};
};
handle
ChangeDatasource
=
async
option
=>
{
on
ChangeDatasource
=
async
option
=>
{
this
.
setState
({
this
.
setState
({
datasource
:
null
,
datasource
:
null
,
datasourceError
:
null
,
datasourceError
:
null
,
...
@@ -197,10 +197,10 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -197,10 +197,10 @@ export class Explore extends React.Component<any, IExploreState> {
this
.
setDatasource
(
datasource
);
this
.
setDatasource
(
datasource
);
};
};
handleChangeQuery
=
(
value
,
index
)
=>
{
onChangeQuery
=
(
value
:
string
,
index
:
number
,
override
?:
boolean
)
=>
{
const
{
queries
}
=
this
.
state
;
const
{
queries
}
=
this
.
state
;
const
prevQuery
=
queries
[
index
];
const
prevQuery
=
queries
[
index
];
const
edited
=
prevQuery
.
query
!==
value
;
const
edited
=
override
?
false
:
prevQuery
.
query
!==
value
;
const
nextQuery
=
{
const
nextQuery
=
{
...
queries
[
index
],
...
queries
[
index
],
edited
,
edited
,
...
@@ -211,50 +211,71 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -211,50 +211,71 @@ export class Explore extends React.Component<any, IExploreState> {
this
.
setState
({
queries
:
nextQueries
});
this
.
setState
({
queries
:
nextQueries
});
};
};
handle
ChangeTime
=
nextRange
=>
{
on
ChangeTime
=
nextRange
=>
{
const
range
=
{
const
range
=
{
from
:
nextRange
.
from
,
from
:
nextRange
.
from
,
to
:
nextRange
.
to
,
to
:
nextRange
.
to
,
};
};
this
.
setState
({
range
},
()
=>
this
.
handle
Submit
());
this
.
setState
({
range
},
()
=>
this
.
on
Submit
());
};
};
handleClickCloseSplit
=
()
=>
{
onClickClear
=
()
=>
{
this
.
setState
({
graphResult
:
null
,
logsResult
:
null
,
queries
:
ensureQueries
(),
tableResult
:
null
,
});
};
onClickCloseSplit
=
()
=>
{
const
{
onChangeSplit
}
=
this
.
props
;
const
{
onChangeSplit
}
=
this
.
props
;
if
(
onChangeSplit
)
{
if
(
onChangeSplit
)
{
onChangeSplit
(
false
);
onChangeSplit
(
false
);
}
}
};
};
handle
ClickGraphButton
=
()
=>
{
on
ClickGraphButton
=
()
=>
{
this
.
setState
(
state
=>
({
showingGraph
:
!
state
.
showingGraph
}));
this
.
setState
(
state
=>
({
showingGraph
:
!
state
.
showingGraph
}));
};
};
handle
ClickLogsButton
=
()
=>
{
on
ClickLogsButton
=
()
=>
{
this
.
setState
(
state
=>
({
showingLogs
:
!
state
.
showingLogs
}));
this
.
setState
(
state
=>
({
showingLogs
:
!
state
.
showingLogs
}));
};
};
handle
ClickSplit
=
()
=>
{
on
ClickSplit
=
()
=>
{
const
{
onChangeSplit
}
=
this
.
props
;
const
{
onChangeSplit
}
=
this
.
props
;
if
(
onChangeSplit
)
{
if
(
onChangeSplit
)
{
onChangeSplit
(
true
,
this
.
state
);
onChangeSplit
(
true
,
this
.
state
);
}
}
};
};
handle
ClickTableButton
=
()
=>
{
on
ClickTableButton
=
()
=>
{
this
.
setState
(
state
=>
({
showingTable
:
!
state
.
showingTable
}));
this
.
setState
(
state
=>
({
showingTable
:
!
state
.
showingTable
}));
};
};
handleRemoveQueryRow
=
index
=>
{
onClickTableCell
=
(
columnKey
:
string
,
rowValue
:
string
)
=>
{
const
{
datasource
,
queries
}
=
this
.
state
;
if
(
datasource
&&
datasource
.
modifyQuery
)
{
const
nextQueries
=
queries
.
map
(
q
=>
({
...
q
,
edited
:
false
,
query
:
datasource
.
modifyQuery
(
q
.
query
,
{
addFilter
:
{
key
:
columnKey
,
value
:
rowValue
}
}),
}));
this
.
setState
({
queries
:
nextQueries
},
()
=>
this
.
onSubmit
());
}
};
onRemoveQueryRow
=
index
=>
{
const
{
queries
}
=
this
.
state
;
const
{
queries
}
=
this
.
state
;
if
(
queries
.
length
<=
1
)
{
if
(
queries
.
length
<=
1
)
{
return
;
return
;
}
}
const
nextQueries
=
[...
queries
.
slice
(
0
,
index
),
...
queries
.
slice
(
index
+
1
)];
const
nextQueries
=
[...
queries
.
slice
(
0
,
index
),
...
queries
.
slice
(
index
+
1
)];
this
.
setState
({
queries
:
nextQueries
},
()
=>
this
.
handle
Submit
());
this
.
setState
({
queries
:
nextQueries
},
()
=>
this
.
on
Submit
());
};
};
handle
Submit
=
()
=>
{
on
Submit
=
()
=>
{
const
{
showingLogs
,
showingGraph
,
showingTable
,
supportsGraph
,
supportsLogs
,
supportsTable
}
=
this
.
state
;
const
{
showingLogs
,
showingGraph
,
showingTable
,
supportsGraph
,
supportsLogs
,
supportsTable
}
=
this
.
state
;
if
(
showingTable
&&
supportsTable
)
{
if
(
showingTable
&&
supportsTable
)
{
this
.
runTableQuery
();
this
.
runTableQuery
();
...
@@ -267,27 +288,6 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -267,27 +288,6 @@ export class Explore extends React.Component<any, IExploreState> {
}
}
};
};
onClickClear
=
()
=>
{
this
.
setState
({
graphResult
:
null
,
logsResult
:
null
,
queries
:
ensureQueries
(),
tableResult
:
null
,
});
};
onClickTableCell
=
(
columnKey
:
string
,
rowValue
:
string
)
=>
{
const
{
datasource
,
queries
}
=
this
.
state
;
if
(
datasource
&&
datasource
.
modifyQuery
)
{
const
nextQueries
=
queries
.
map
(
q
=>
({
...
q
,
edited
:
false
,
query
:
datasource
.
modifyQuery
(
q
.
query
,
{
addFilter
:
{
key
:
columnKey
,
value
:
rowValue
}
}),
}));
this
.
setState
({
queries
:
nextQueries
},
()
=>
this
.
handleSubmit
());
}
};
onQuerySuccess
(
datasourceId
:
string
,
queries
:
any
[]):
void
{
onQuerySuccess
(
datasourceId
:
string
,
queries
:
any
[]):
void
{
// save queries to history
// save queries to history
let
{
datasource
,
history
}
=
this
.
state
;
let
{
datasource
,
history
}
=
this
.
state
;
...
@@ -450,7 +450,7 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -450,7 +450,7 @@ export class Explore extends React.Component<any, IExploreState> {
</
div
>
</
div
>
)
:
(
)
:
(
<
div
className=
"navbar-buttons explore-first-button"
>
<
div
className=
"navbar-buttons explore-first-button"
>
<
button
className=
"btn navbar-button"
onClick=
{
this
.
handle
ClickCloseSplit
}
>
<
button
className=
"btn navbar-button"
onClick=
{
this
.
on
ClickCloseSplit
}
>
Close Split
Close Split
</
button
>
</
button
>
</
div
>
</
div
>
...
@@ -460,7 +460,7 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -460,7 +460,7 @@ export class Explore extends React.Component<any, IExploreState> {
<
Select
<
Select
className=
"datasource-picker"
className=
"datasource-picker"
clearable=
{
false
}
clearable=
{
false
}
onChange=
{
this
.
handle
ChangeDatasource
}
onChange=
{
this
.
on
ChangeDatasource
}
options=
{
datasources
}
options=
{
datasources
}
placeholder=
"Loading datasources..."
placeholder=
"Loading datasources..."
value=
{
selectedDatasource
}
value=
{
selectedDatasource
}
...
@@ -470,19 +470,19 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -470,19 +470,19 @@ export class Explore extends React.Component<any, IExploreState> {
<
div
className=
"navbar__spacer"
/>
<
div
className=
"navbar__spacer"
/>
{
position
===
'left'
&&
!
split
?
(
{
position
===
'left'
&&
!
split
?
(
<
div
className=
"navbar-buttons"
>
<
div
className=
"navbar-buttons"
>
<
button
className=
"btn navbar-button"
onClick=
{
this
.
handle
ClickSplit
}
>
<
button
className=
"btn navbar-button"
onClick=
{
this
.
on
ClickSplit
}
>
Split
Split
</
button
>
</
button
>
</
div
>
</
div
>
)
:
null
}
)
:
null
}
<
TimePicker
range=
{
range
}
onChangeTime=
{
this
.
handle
ChangeTime
}
/>
<
TimePicker
range=
{
range
}
onChangeTime=
{
this
.
on
ChangeTime
}
/>
<
div
className=
"navbar-buttons"
>
<
div
className=
"navbar-buttons"
>
<
button
className=
"btn navbar-button navbar-button--no-icon"
onClick=
{
this
.
onClickClear
}
>
<
button
className=
"btn navbar-button navbar-button--no-icon"
onClick=
{
this
.
onClickClear
}
>
Clear All
Clear All
</
button
>
</
button
>
</
div
>
</
div
>
<
div
className=
"navbar-buttons relative"
>
<
div
className=
"navbar-buttons relative"
>
<
button
className=
"btn navbar-button--primary"
onClick=
{
this
.
handle
Submit
}
>
<
button
className=
"btn navbar-button--primary"
onClick=
{
this
.
on
Submit
}
>
Run Query
<
i
className=
"fa fa-level-down run-icon"
/>
Run Query
<
i
className=
"fa fa-level-down run-icon"
/>
</
button
>
</
button
>
{
loading
||
latency
?
<
ElapsedTime
time=
{
latency
}
className=
"text-info"
/>
:
null
}
{
loading
||
latency
?
<
ElapsedTime
time=
{
latency
}
className=
"text-info"
/>
:
null
}
...
@@ -505,26 +505,26 @@ export class Explore extends React.Component<any, IExploreState> {
...
@@ -505,26 +505,26 @@ export class Explore extends React.Component<any, IExploreState> {
history=
{
history
}
history=
{
history
}
queries=
{
queries
}
queries=
{
queries
}
request=
{
this
.
request
}
request=
{
this
.
request
}
onAddQueryRow=
{
this
.
handle
AddQueryRow
}
onAddQueryRow=
{
this
.
on
AddQueryRow
}
onChangeQuery=
{
this
.
handle
ChangeQuery
}
onChangeQuery=
{
this
.
on
ChangeQuery
}
onExecuteQuery=
{
this
.
handle
Submit
}
onExecuteQuery=
{
this
.
on
Submit
}
onRemoveQueryRow=
{
this
.
handle
RemoveQueryRow
}
onRemoveQueryRow=
{
this
.
on
RemoveQueryRow
}
/>
/>
{
queryError
&&
!
loading
?
<
div
className=
"text-warning m-a-2"
>
{
queryError
}
</
div
>
:
null
}
{
queryError
&&
!
loading
?
<
div
className=
"text-warning m-a-2"
>
{
queryError
}
</
div
>
:
null
}
<
div
className=
"result-options"
>
<
div
className=
"result-options"
>
{
supportsGraph
?
(
{
supportsGraph
?
(
<
button
className=
{
`btn navbar-button ${graphButtonActive}`
}
onClick=
{
this
.
handle
ClickGraphButton
}
>
<
button
className=
{
`btn navbar-button ${graphButtonActive}`
}
onClick=
{
this
.
on
ClickGraphButton
}
>
Graph
Graph
</
button
>
</
button
>
)
:
null
}
)
:
null
}
{
supportsTable
?
(
{
supportsTable
?
(
<
button
className=
{
`btn navbar-button ${tableButtonActive}`
}
onClick=
{
this
.
handle
ClickTableButton
}
>
<
button
className=
{
`btn navbar-button ${tableButtonActive}`
}
onClick=
{
this
.
on
ClickTableButton
}
>
Table
Table
</
button
>
</
button
>
)
:
null
}
)
:
null
}
{
supportsLogs
?
(
{
supportsLogs
?
(
<
button
className=
{
`btn navbar-button ${logsButtonActive}`
}
onClick=
{
this
.
handle
ClickLogsButton
}
>
<
button
className=
{
`btn navbar-button ${logsButtonActive}`
}
onClick=
{
this
.
on
ClickLogsButton
}
>
Logs
Logs
</
button
>
</
button
>
)
:
null
}
)
:
null
}
...
...
public/app/containers/Explore/QueryRows.tsx
View file @
307248f7
...
@@ -3,28 +3,35 @@ import React, { PureComponent } from 'react';
...
@@ -3,28 +3,35 @@ import React, { PureComponent } from 'react';
import
QueryField
from
'./PromQueryField'
;
import
QueryField
from
'./PromQueryField'
;
class
QueryRow
extends
PureComponent
<
any
,
{}
>
{
class
QueryRow
extends
PureComponent
<
any
,
{}
>
{
handle
ChangeQuery
=
value
=>
{
on
ChangeQuery
=
value
=>
{
const
{
index
,
onChangeQuery
}
=
this
.
props
;
const
{
index
,
onChangeQuery
}
=
this
.
props
;
if
(
onChangeQuery
)
{
if
(
onChangeQuery
)
{
onChangeQuery
(
value
,
index
);
onChangeQuery
(
value
,
index
);
}
}
};
};
handle
ClickAddButton
=
()
=>
{
on
ClickAddButton
=
()
=>
{
const
{
index
,
onAddQueryRow
}
=
this
.
props
;
const
{
index
,
onAddQueryRow
}
=
this
.
props
;
if
(
onAddQueryRow
)
{
if
(
onAddQueryRow
)
{
onAddQueryRow
(
index
);
onAddQueryRow
(
index
);
}
}
};
};
handleClickRemoveButton
=
()
=>
{
onClickClearButton
=
()
=>
{
const
{
index
,
onChangeQuery
}
=
this
.
props
;
if
(
onChangeQuery
)
{
onChangeQuery
(
''
,
index
,
true
);
}
};
onClickRemoveButton
=
()
=>
{
const
{
index
,
onRemoveQueryRow
}
=
this
.
props
;
const
{
index
,
onRemoveQueryRow
}
=
this
.
props
;
if
(
onRemoveQueryRow
)
{
if
(
onRemoveQueryRow
)
{
onRemoveQueryRow
(
index
);
onRemoveQueryRow
(
index
);
}
}
};
};
handle
PressEnter
=
()
=>
{
on
PressEnter
=
()
=>
{
const
{
onExecuteQuery
}
=
this
.
props
;
const
{
onExecuteQuery
}
=
this
.
props
;
if
(
onExecuteQuery
)
{
if
(
onExecuteQuery
)
{
onExecuteQuery
();
onExecuteQuery
();
...
@@ -36,20 +43,23 @@ class QueryRow extends PureComponent<any, {}> {
...
@@ -36,20 +43,23 @@ class QueryRow extends PureComponent<any, {}> {
return
(
return
(
<
div
className=
"query-row"
>
<
div
className=
"query-row"
>
<
div
className=
"query-row-tools"
>
<
div
className=
"query-row-tools"
>
<
button
className=
"btn navbar-button navbar-button--tight"
onClick=
{
this
.
handle
ClickAddButton
}
>
<
button
className=
"btn navbar-button navbar-button--tight"
onClick=
{
this
.
on
ClickAddButton
}
>
<
i
className=
"fa fa-plus"
/>
<
i
className=
"fa fa-plus"
/>
</
button
>
</
button
>
<
button
className=
"btn navbar-button navbar-button--tight"
onClick=
{
this
.
handle
ClickRemoveButton
}
>
<
button
className=
"btn navbar-button navbar-button--tight"
onClick=
{
this
.
on
ClickRemoveButton
}
>
<
i
className=
"fa fa-minus"
/>
<
i
className=
"fa fa-minus"
/>
</
button
>
</
button
>
<
button
className=
"btn navbar-button navbar-button--tight"
onClick=
{
this
.
onClickClearButton
}
>
<
i
className=
"fa fa-times"
/>
</
button
>
</
div
>
</
div
>
<
div
className=
"slate-query-field-wrapper"
>
<
div
className=
"slate-query-field-wrapper"
>
<
QueryField
<
QueryField
initialQuery=
{
edited
?
null
:
query
}
initialQuery=
{
edited
?
null
:
query
}
history=
{
history
}
history=
{
history
}
portalPrefix=
"explore"
portalPrefix=
"explore"
onPressEnter=
{
this
.
handle
PressEnter
}
onPressEnter=
{
this
.
on
PressEnter
}
onQueryChange=
{
this
.
handle
ChangeQuery
}
onQueryChange=
{
this
.
on
ChangeQuery
}
request=
{
request
}
request=
{
request
}
/>
/>
</
div
>
</
div
>
...
...
public/sass/pages/_explore.scss
View file @
307248f7
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
}
}
.query-row-tools
{
.query-row-tools
{
width
:
4
rem
;
width
:
6
rem
;
}
}
.explore
{
.explore
{
...
...
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