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
33123c7e
Unverified
Commit
33123c7e
authored
May 06, 2020
by
Torkel Ödegaard
Committed by
GitHub
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PanelEdit: Fixed re-using query result after leaving panel edit (#24340)
parent
8de6ef47
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
19 deletions
+25
-19
public/app/features/dashboard/components/PanelEditor/state/actions.ts
+1
-4
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+0
-4
public/app/features/dashboard/state/PanelModel.test.ts
+13
-0
public/app/features/dashboard/state/PanelModel.ts
+2
-6
public/app/features/dashboard/state/PanelQueryRunner.ts
+9
-5
No files found.
public/app/features/dashboard/components/PanelEditor/state/actions.ts
View file @
33123c7e
...
...
@@ -58,10 +58,7 @@ export function panelEditorCleanUp(): ThunkResult<void> {
// Resend last query result on source panel query runner
// But do this after the panel edit editor exit process has completed
setTimeout
(()
=>
{
const
lastResult
=
panel
.
getQueryRunner
().
getLastResult
();
if
(
lastResult
)
{
sourcePanel
.
getQueryRunner
().
pipeDataToSubject
(
lastResult
);
}
sourcePanel
.
getQueryRunner
().
useLastResultFrom
(
panel
.
getQueryRunner
());
},
20
);
}
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
33123c7e
...
...
@@ -235,10 +235,6 @@ export class PanelChrome extends PureComponent<Props, State> {
return
panel
.
snapshotData
&&
panel
.
snapshotData
.
length
;
}
panelHasLastResult
=
()
=>
{
return
!!
this
.
props
.
panel
.
getQueryRunner
().
getLastResult
();
};
get
wantsQueryExecution
()
{
return
!
(
this
.
props
.
plugin
.
meta
.
skipDataQuery
||
this
.
hasPanelSnapshot
);
}
...
...
public/app/features/dashboard/state/PanelModel.test.ts
View file @
33123c7e
...
...
@@ -6,8 +6,10 @@ import {
PanelProps
,
standardEditorsRegistry
,
standardFieldConfigEditorRegistry
,
PanelData
,
}
from
'@grafana/data'
;
import
{
ComponentClass
}
from
'react'
;
import
{
PanelQueryRunner
}
from
'./PanelQueryRunner'
;
class
TablePanelCtrl
{}
...
...
@@ -336,5 +338,16 @@ describe('PanelModel', () => {
expect
(
model
.
thresholds
).
toBeUndefined
();
});
});
describe
(
'destroy'
,
()
=>
{
it
(
'Should still preserve last query result'
,
()
=>
{
model
.
getQueryRunner
().
useLastResultFrom
({
getLastResult
:
()
=>
({}
as
PanelData
),
}
as
PanelQueryRunner
);
model
.
destroy
();
expect
(
model
.
getQueryRunner
().
getLastResult
()).
toBeDefined
();
});
});
});
});
public/app/features/dashboard/state/PanelModel.ts
View file @
33123c7e
...
...
@@ -422,11 +422,8 @@ export class PanelModel implements DataConfigSource {
clone
.
isEditing
=
true
;
const
sourceQueryRunner
=
this
.
getQueryRunner
();
// pipe last result to new clone query runner
const
lastResult
=
sourceQueryRunner
.
getLastResult
();
if
(
lastResult
)
{
clone
.
getQueryRunner
().
pipeDataToSubject
(
lastResult
);
}
// Copy last query result
clone
.
getQueryRunner
().
useLastResultFrom
(
sourceQueryRunner
);
return
clone
;
}
...
...
@@ -469,7 +466,6 @@ export class PanelModel implements DataConfigSource {
if
(
this
.
queryRunner
)
{
this
.
queryRunner
.
destroy
();
this
.
queryRunner
=
null
;
}
}
...
...
public/app/features/dashboard/state/PanelQueryRunner.ts
View file @
33123c7e
...
...
@@ -190,11 +190,6 @@ export class PanelQueryRunner {
});
}
pipeDataToSubject
=
(
data
:
PanelData
)
=>
{
this
.
subject
.
next
(
data
);
this
.
lastResult
=
data
;
};
resendLastResult
=
()
=>
{
if
(
this
.
lastResult
)
{
this
.
subject
.
next
(
this
.
lastResult
);
...
...
@@ -215,6 +210,15 @@ export class PanelQueryRunner {
}
}
useLastResultFrom
(
runner
:
PanelQueryRunner
)
{
this
.
lastResult
=
runner
.
getLastResult
();
if
(
this
.
lastResult
)
{
// The subject is a replay subject so anyone subscribing will get this last result
this
.
subject
.
next
(
this
.
lastResult
);
}
}
getLastResult
():
PanelData
{
return
this
.
lastResult
;
}
...
...
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