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
e698202f
Commit
e698202f
authored
Nov 13, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: use new naming convention for query editor all over
parent
30f9a324
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
51 additions
and
33 deletions
+51
-33
conf/defaults.ini
+1
-1
public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap
+2
-0
public/app/features/plugins/VariableQueryComponentLoader.tsx
+6
-6
public/app/features/plugins/all.ts
+1
-1
public/app/features/templating/DefaultVariableQueryEditor.tsx
+2
-2
public/app/features/templating/partials/editor.html
+2
-2
public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.test.tsx
+7
-7
public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.tsx
+6
-6
public/app/plugins/datasource/stackdriver/components/__snapshots__/VariableQueryEditor.test.tsx.snap
+1
-1
public/app/plugins/datasource/stackdriver/datasource.ts
+5
-0
public/app/plugins/datasource/stackdriver/module.ts
+2
-2
public/app/plugins/datasource/stackdriver/partials/query.editor.html
+6
-1
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+7
-1
public/app/plugins/datasource/stackdriver/types.ts
+1
-1
public/app/types/plugins.ts
+2
-2
No files found.
conf/defaults.ini
View file @
e698202f
...
...
@@ -249,7 +249,7 @@ signout_redirect_url =
#################################### Anonymous Auth ######################
[auth.anonymous]
# enable anonymous access
enabled
=
fals
e
enabled
=
tru
e
# specify organization name that should be used for unauthenticated users
org_name
=
Main Org.
...
...
public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap
View file @
e698202f
...
...
@@ -14,3 +14,4 @@ exports[`PickerOption renders correctly 1`] = `
</div>
</div>
`;
\ No newline at end of file
public/app/features/plugins/
Templat
eQueryComponentLoader.tsx
→
public/app/features/plugins/
Variabl
eQueryComponentLoader.tsx
View file @
e698202f
...
...
@@ -2,19 +2,19 @@ import coreModule from 'app/core/core_module';
import
{
importPluginModule
}
from
'./plugin_loader'
;
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
Default
TemplateQueryComponent
from
'../templating/DefaultTemplateQueryComponent
'
;
import
Default
VariableQueryEditor
from
'../templating/DefaultVariableQueryEditor
'
;
async
function
loadComponent
(
module
)
{
const
component
=
await
importPluginModule
(
module
);
if
(
component
&&
component
.
TemplateQueryComponent
)
{
return
component
.
TemplateQueryComponent
;
if
(
component
&&
component
.
VariableQueryEditor
)
{
return
component
.
VariableQueryEditor
;
}
else
{
return
Default
TemplateQueryComponent
;
return
Default
VariableQueryEditor
;
}
}
/** @ngInject */
function
templateQueryComponent
Loader
()
{
function
variableQueryEditor
Loader
()
{
return
{
restrict
:
'E'
,
link
:
async
(
scope
,
elem
)
=>
{
...
...
@@ -32,4 +32,4 @@ function templateQueryComponentLoader() {
};
}
coreModule
.
directive
(
'
templateQueryComponentLoader'
,
templateQueryComponent
Loader
);
coreModule
.
directive
(
'
variableQueryEditorLoader'
,
variableQueryEditor
Loader
);
public/app/features/plugins/all.ts
View file @
e698202f
...
...
@@ -4,4 +4,4 @@ import './import_list/import_list';
import
'./ds_edit_ctrl'
;
import
'./datasource_srv'
;
import
'./plugin_component'
;
import
'./
Templat
eQueryComponentLoader'
;
import
'./
Variabl
eQueryComponentLoader'
;
public/app/features/templating/Default
TemplateQueryComponent
.tsx
→
public/app/features/templating/Default
VariableQueryEditor
.tsx
View file @
e698202f
import
React
,
{
PureComponent
}
from
'react'
;
import
{
Templat
eQueryProps
}
from
'app/types/plugins'
;
import
{
Variabl
eQueryProps
}
from
'app/types/plugins'
;
export
default
class
Default
TemplateQueryComponent
extends
PureComponent
<
Templat
eQueryProps
,
any
>
{
export
default
class
Default
VariableQueryEditor
extends
PureComponent
<
Variabl
eQueryProps
,
any
>
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
value
:
props
.
query
};
...
...
public/app/features/templating/partials/editor.html
View file @
e698202f
...
...
@@ -200,8 +200,8 @@
</div>
<rebuild-on-change
property=
"currentDatasource"
>
<
template-query-component
-loader>
</
template-query-component
-loader>
<
variable-query-editor
-loader>
</
variable-query-editor
-loader>
</rebuild-on-change>
<div
class=
"gf-form"
>
...
...
public/app/plugins/datasource/stackdriver/components/
TemplateQueryComponent
.test.tsx
→
public/app/plugins/datasource/stackdriver/components/
VariableQueryEditor
.test.tsx
View file @
e698202f
import
React
from
'react'
;
import
renderer
from
'react-test-renderer'
;
import
{
Stackdriver
TemplateQueryComponent
}
from
'./TemplateQueryComponent
'
;
import
{
Templat
eQueryProps
}
from
'app/types/plugins'
;
import
{
Stackdriver
VariableQueryEditor
}
from
'./VariableQueryEditor
'
;
import
{
Variabl
eQueryProps
}
from
'app/types/plugins'
;
import
{
MetricFindQueryTypes
}
from
'../types'
;
jest
.
mock
(
'../functions'
,
()
=>
({
getMetricTypes
:
()
=>
({
metricTypes
:
[],
selectedMetricType
:
''
}),
}));
const
props
:
Templat
eQueryProps
=
{
const
props
:
Variabl
eQueryProps
=
{
onChange
:
(
query
,
definition
)
=>
{},
query
:
{},
datasource
:
{
...
...
@@ -16,9 +16,9 @@ const props: TemplateQueryProps = {
},
};
describe
(
'
StackdriverTemplateQueryComponent
'
,
()
=>
{
describe
(
'
VariableQueryEditor
'
,
()
=>
{
it
(
'renders correctly'
,
()
=>
{
const
tree
=
renderer
.
create
(<
Stackdriver
TemplateQueryComponent
{
...
props
}
/>).
toJSON
();
const
tree
=
renderer
.
create
(<
Stackdriver
VariableQueryEditor
{
...
props
}
/>).
toJSON
();
expect
(
tree
).
toMatchSnapshot
();
});
...
...
@@ -28,7 +28,7 @@ describe('StackdriverTemplateQueryComponent', () => {
expect
(
definition
).
toBe
(
'Stackdriver - Metric Types'
);
done
();
};
renderer
.
create
(<
Stackdriver
TemplateQueryComponent
{
...
props
}
/>).
toJSON
();
renderer
.
create
(<
Stackdriver
VariableQueryEditor
{
...
props
}
/>).
toJSON
();
});
});
...
...
@@ -39,7 +39,7 @@ describe('StackdriverTemplateQueryComponent', () => {
expect
(
definition
).
toBe
(
'Stackdriver - Metric Labels'
);
done
();
};
renderer
.
create
(<
Stackdriver
TemplateQueryComponent
{
...
props
}
/>).
toJSON
();
renderer
.
create
(<
Stackdriver
VariableQueryEditor
{
...
props
}
/>).
toJSON
();
});
});
});
public/app/plugins/datasource/stackdriver/components/
TemplateQueryComponent
.tsx
→
public/app/plugins/datasource/stackdriver/components/
VariableQueryEditor
.tsx
View file @
e698202f
import
React
,
{
PureComponent
}
from
'react'
;
import
uniqBy
from
'lodash/uniqBy'
;
import
{
Templat
eQueryProps
}
from
'app/types/plugins'
;
import
{
Variabl
eQueryProps
}
from
'app/types/plugins'
;
import
SimpleSelect
from
'./SimpleSelect'
;
import
{
getMetricTypes
}
from
'../functions'
;
import
{
MetricFindQueryTypes
,
TemplateQueryComponent
Data
}
from
'../types'
;
import
{
MetricFindQueryTypes
,
VariableQuery
Data
}
from
'../types'
;
export
class
Stackdriver
TemplateQueryComponent
extends
PureComponent
<
TemplateQueryProps
,
TemplateQueryComponent
Data
>
{
export
class
Stackdriver
VariableQueryEditor
extends
PureComponent
<
VariableQueryProps
,
VariableQuery
Data
>
{
queryTypes
:
Array
<
{
value
:
string
;
name
:
string
}
>
=
[
{
value
:
MetricFindQueryTypes
.
MetricTypes
,
name
:
'Metric Types'
},
{
value
:
MetricFindQueryTypes
.
MetricLabels
,
name
:
'Metric Labels'
},
...
...
@@ -16,7 +16,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
{
value
:
MetricFindQueryTypes
.
AlignmentPeriods
,
name
:
'Alignment Periods'
},
];
defaults
:
TemplateQueryComponent
Data
=
{
defaults
:
VariableQuery
Data
=
{
selectedQueryType
:
this
.
queryTypes
[
0
].
value
,
metricDescriptors
:
[],
selectedService
:
''
,
...
...
@@ -27,7 +27,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
services
:
[],
};
constructor
(
props
:
Templat
eQueryProps
)
{
constructor
(
props
:
Variabl
eQueryProps
)
{
super
(
props
);
this
.
handleQueryTypeChange
=
this
.
handleQueryTypeChange
.
bind
(
this
);
this
.
onServiceChange
=
this
.
onServiceChange
.
bind
(
this
);
...
...
@@ -111,7 +111,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
async
getLabels
(
selectedMetricType
,
selectedQueryType
=
this
.
state
.
selectedQueryType
)
{
let
result
=
{
labels
:
this
.
state
.
labels
,
labelKey
:
this
.
state
.
labelKey
};
if
(
selectedMetricType
&&
this
.
isLabelQuery
(
selectedQueryType
))
{
const
refId
=
'Stackdriver
TemplateQueryComponent
'
;
const
refId
=
'Stackdriver
VariableQueryEditor
'
;
const
response
=
await
this
.
props
.
datasource
.
getLabels
(
selectedMetricType
,
refId
);
const
labels
=
Object
.
keys
(
response
.
meta
[
selectedQueryType
]);
const
labelKey
=
labels
.
some
(
l
=>
l
===
this
.
state
.
labelKey
)
?
this
.
state
.
labelKey
:
labels
[
0
];
...
...
public/app/plugins/datasource/stackdriver/components/__snapshots__/
TemplateQueryComponent
.test.tsx.snap
→
public/app/plugins/datasource/stackdriver/components/__snapshots__/
VariableQueryEditor
.test.tsx.snap
View file @
e698202f
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`
StackdriverTemplateQueryComponent
renders correctly 1`] = `
exports[`
VariableQueryEditor
renders correctly 1`] = `
Array [
<div
className="gf-form max-width-21"
...
...
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
e698202f
...
...
@@ -111,6 +111,11 @@ export default class StackdriverDatasource {
return
unit
;
}
async
getProjects
()
{
const
response
=
await
this
.
doRequest
(
`/cloudresourcemanager/v1/projects`
);
return
response
.
data
.
projects
.
map
(
p
=>
({
value
:
p
.
projectId
,
name
:
p
.
name
}));
}
async
query
(
options
)
{
const
result
=
[];
const
data
=
await
this
.
getTimeSeries
(
options
);
...
...
public/app/plugins/datasource/stackdriver/module.ts
View file @
e698202f
...
...
@@ -2,12 +2,12 @@ import StackdriverDatasource from './datasource';
import
{
StackdriverQueryCtrl
}
from
'./query_ctrl'
;
import
{
StackdriverConfigCtrl
}
from
'./config_ctrl'
;
import
{
StackdriverAnnotationsQueryCtrl
}
from
'./annotations_query_ctrl'
;
import
{
Stackdriver
TemplateQueryComponent
}
from
'./components/TemplateQueryComponent
'
;
import
{
Stackdriver
VariableQueryEditor
}
from
'./components/VariableQueryEditor
'
;
export
{
StackdriverDatasource
as
Datasource
,
StackdriverQueryCtrl
as
QueryCtrl
,
StackdriverConfigCtrl
as
ConfigCtrl
,
StackdriverAnnotationsQueryCtrl
as
AnnotationsQueryCtrl
,
Stackdriver
TemplateQueryComponent
as
TemplateQueryComponent
,
Stackdriver
VariableQueryEditor
as
VariableQueryEditor
,
};
public/app/plugins/datasource/stackdriver/partials/query.editor.html
View file @
e698202f
...
...
@@ -13,9 +13,14 @@
</div>
</div>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<
!-- <
div class="gf-form">
<span class="gf-form-label width-9">Project</span>
<input class="gf-form-input" disabled type="text" ng-model='ctrl.target.defaultProject' css-class="min-width-12" />
</div> -->
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-9"
>
Project
</span>
<gf-form-dropdown
class=
"gf-form-input"
type=
"text"
ng-model=
'ctrl.target.defaultProject'
get-options=
"ctrl.projects"
css-class=
"min-width-12"
></gf-form-dropdown>
</div>
<div
class=
"gf-form"
>
<label
class=
"gf-form-label query-keyword"
ng-click=
"ctrl.showHelp = !ctrl.showHelp"
>
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
e698202f
...
...
@@ -52,6 +52,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
metricKind
:
''
,
valueType
:
''
,
};
projects
:
any
;
showHelp
:
boolean
;
showLastQuery
:
boolean
;
...
...
@@ -62,11 +63,16 @@ export class StackdriverQueryCtrl extends QueryCtrl {
constructor
(
$scope
,
$injector
)
{
super
(
$scope
,
$injector
);
_
.
defaultsDeep
(
this
.
target
,
this
.
defaults
);
this
.
setProjects
(
$scope
.
ctrl
.
datasource
);
this
.
panelCtrl
.
events
.
on
(
'data-received'
,
this
.
onDataReceived
.
bind
(
this
),
$scope
);
this
.
panelCtrl
.
events
.
on
(
'data-error'
,
this
.
onDataError
.
bind
(
this
),
$scope
);
}
async
setProjects
(
ds
)
{
this
.
projects
=
await
ds
.
getProjects
();
console
.
log
(
this
.
projects
);
}
onDataReceived
(
dataList
)
{
this
.
lastQueryError
=
null
;
this
.
lastQueryMeta
=
null
;
...
...
public/app/plugins/datasource/stackdriver/types.ts
View file @
e698202f
...
...
@@ -8,7 +8,7 @@ export enum MetricFindQueryTypes {
AlignmentPeriods
=
'alignmentPeriods'
,
}
export
interface
TemplateQueryComponent
Data
{
export
interface
VariableQuery
Data
{
selectedQueryType
:
string
;
metricDescriptors
:
any
[];
selectedService
:
string
;
...
...
public/app/types/plugins.ts
View file @
e698202f
...
...
@@ -6,7 +6,7 @@ export interface PluginExports {
QueryCtrl
?:
any
;
ConfigCtrl
?:
any
;
AnnotationsQueryCtrl
?:
any
;
TemplateQueryComponent
?:
any
;
VariableQueryEditor
?:
any
;
ExploreQueryField
?:
any
;
ExploreStartPage
?:
any
;
...
...
@@ -100,7 +100,7 @@ export interface PluginsState {
dashboards
:
PluginDashboard
[];
}
export
interface
Templat
eQueryProps
{
export
interface
Variabl
eQueryProps
{
query
:
any
;
onChange
:
(
query
:
any
,
definition
:
string
)
=>
void
;
datasource
:
any
;
...
...
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