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
4f7d3fcc
Commit
4f7d3fcc
authored
Oct 25, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: make sure default template query editor state is propagted to parent angular scope
parent
637b91ab
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
public/app/features/plugins/pluginTemplateQueryComponentLoader.tsx
+7
-13
public/app/features/templating/defaultTemplateQueryCtrl.tsx
+14
-6
public/app/features/templating/editor_ctrl.ts
+8
-2
No files found.
public/app/features/plugins/pluginTemplateQueryComponentLoader.tsx
View file @
4f7d3fcc
import
_
from
'lodash'
;
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
{
importPluginModule
}
from
'./plugin_loader'
;
import
{
importPluginModule
}
from
'./plugin_loader'
;
import
React
from
'react'
;
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
ReactDOM
from
'react-dom'
;
import
{
Provider
}
from
'react-redux'
;
import
DefaultTemplateQueryCtrl
from
'../templating/defaultTemplateQueryCtrl'
;
import
DefaultTemplateQueryCtrl
from
'../templating/defaultTemplateQueryCtrl'
;
function
WrapInProvider
(
Component
,
props
)
{
return
(
<
Provider
>
<
Component
{
...
props
}
/>
</
Provider
>
);
}
async
function
loadComponent
(
module
)
{
async
function
loadComponent
(
module
)
{
const
component
=
await
importPluginModule
(
module
);
const
component
=
await
importPluginModule
(
module
);
if
(
!
component
.
TemplateQueryCtrl
)
{
if
(
!
component
.
TemplateQueryCtrl
)
{
...
@@ -28,9 +18,13 @@ function pluginTemplateQueryComponentLoader(datasourceSrv) {
...
@@ -28,9 +18,13 @@ function pluginTemplateQueryComponentLoader(datasourceSrv) {
return
{
return
{
restrict
:
'E'
,
restrict
:
'E'
,
link
:
async
(
scope
,
elem
)
=>
{
link
:
async
(
scope
,
elem
)
=>
{
const
component
=
await
loadComponent
(
scope
.
currentDatasource
.
meta
.
module
);
const
Component
=
await
loadComponent
(
scope
.
currentDatasource
.
meta
.
module
);
const
props
=
{
datasourceSrv
,
query
:
scope
.
current
.
query
,
isValid
:
scope
.
current
.
isValid
};
const
props
=
{
ReactDOM
.
render
(
WrapInProvider
(
component
,
props
),
elem
[
0
]);
datasourceSrv
,
query
:
scope
.
current
.
query
,
onChange
:
scope
.
onQueryChange
,
};
ReactDOM
.
render
(<
Component
{
...
props
}
/>,
elem
[
0
]);
scope
.
$on
(
'$destroy'
,
()
=>
{
scope
.
$on
(
'$destroy'
,
()
=>
{
ReactDOM
.
unmountComponentAtNode
(
elem
[
0
]);
ReactDOM
.
unmountComponentAtNode
(
elem
[
0
]);
});
});
...
...
public/app/features/templating/defaultTemplateQueryCtrl.tsx
View file @
4f7d3fcc
...
@@ -2,15 +2,23 @@ import React, { PureComponent } from 'react';
...
@@ -2,15 +2,23 @@ import React, { PureComponent } from 'react';
interface
Props
{
interface
Props
{
query
:
string
;
query
:
string
;
onChange
:
(
c
:
string
)
=>
void
;
}
}
export
default
class
DefaultTemplateQueryCtrl
extends
PureComponent
<
Props
>
{
export
default
class
DefaultTemplateQueryCtrl
extends
PureComponent
<
Props
,
any
>
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
value
:
props
.
query
};
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
this
.
handleBlur
=
this
.
handleBlur
.
bind
(
this
);
}
}
componentDidMount
()
{
handleChange
(
event
)
{
console
.
log
(
'componentDidMount'
);
this
.
setState
({
value
:
event
.
target
.
value
});
}
handleBlur
(
event
)
{
this
.
props
.
onChange
(
event
.
target
.
value
);
}
}
render
()
{
render
()
{
...
@@ -20,10 +28,10 @@ export default class DefaultTemplateQueryCtrl extends PureComponent<Props> {
...
@@ -20,10 +28,10 @@ export default class DefaultTemplateQueryCtrl extends PureComponent<Props> {
<
input
<
input
type=
"text"
type=
"text"
className=
"gf-form-input"
className=
"gf-form-input"
ng
-
model=
"current.query"
value=
{
this
.
state
.
value
}
onChange=
{
this
.
handleChange
}
onBlur=
{
this
.
handleBlur
}
placeholder=
"metric name or tags query"
placeholder=
"metric name or tags query"
ng
-
model
-
onblur
ng
-
change=
"runQuery()"
required
required
/>
/>
</
div
>
</
div
>
...
...
public/app/features/templating/editor_ctrl.ts
View file @
4f7d3fcc
...
@@ -106,6 +106,11 @@ export class VariableEditorCtrl {
...
@@ -106,6 +106,11 @@ export class VariableEditorCtrl {
});
});
};
};
$scope
.
onQueryChange
=
value
=>
{
$scope
.
current
.
query
=
value
;
$scope
.
runQuery
();
};
$scope
.
edit
=
variable
=>
{
$scope
.
edit
=
variable
=>
{
$scope
.
current
=
variable
;
$scope
.
current
=
variable
;
$scope
.
currentIsNew
=
false
;
$scope
.
currentIsNew
=
false
;
...
@@ -173,8 +178,9 @@ export class VariableEditorCtrl {
...
@@ -173,8 +178,9 @@ export class VariableEditorCtrl {
};
};
$scope
.
datasourceChanged
=
async
()
=>
{
$scope
.
datasourceChanged
=
async
()
=>
{
$scope
.
currentDatasource
=
await
datasourceSrv
.
get
(
$scope
.
current
.
datasource
);
datasourceSrv
.
get
(
$scope
.
current
.
datasource
).
then
(
ds
=>
{
console
.
log
(
$scope
.
currentDatasource
);
$scope
.
currentDatasource
=
ds
;
});
};
};
}
}
}
}
...
...
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