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
27e486d6
Commit
27e486d6
authored
Nov 22, 2017
by
Patrick O'Carroll
Committed by
Carl Bergquist
Nov 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converted 3 .js files to .ts (#9958)
* converted files from .js to .ts
parent
ca940c2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
102 deletions
+111
-102
public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.ts
+14
-15
public/app/plugins/datasource/prometheus/metric_find_query.ts
+73
-62
public/app/plugins/panel/graph/series_overrides_ctrl.ts
+24
-25
No files found.
public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.
j
s
→
public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.
t
s
View file @
27e486d6
define
([
import
angular
from
'angular'
;
'angular'
,
import
_
from
'lodash'
;
'lodash'
,
],
function
(
angular
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
export
class
CloudWatchQueryParameter
{
module
.
directive
(
'cloudwatchQueryParameter'
,
function
()
{
constructor
()
{
return
{
return
{
templateUrl
:
'public/app/plugins/datasource/cloudwatch/partials/query.parameter.html'
,
templateUrl
:
'public/app/plugins/datasource/cloudwatch/partials/query.parameter.html'
,
controller
:
'CloudWatchQueryParameterCtrl'
,
controller
:
'CloudWatchQueryParameterCtrl'
,
...
@@ -18,9 +14,12 @@ function (angular, _) {
...
@@ -18,9 +14,12 @@ function (angular, _) {
onChange
:
"&"
,
onChange
:
"&"
,
}
}
};
};
});
}
}
module
.
controller
(
'CloudWatchQueryParameterCtrl'
,
function
(
$scope
,
templateSrv
,
uiSegmentSrv
,
datasourceSrv
,
$q
)
{
export
class
CloudWatchQueryParameterCtrl
{
constructor
(
$scope
,
templateSrv
,
uiSegmentSrv
,
datasourceSrv
,
$q
)
{
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
var
target
=
$scope
.
target
;
var
target
=
$scope
.
target
;
...
@@ -120,8 +119,7 @@ function (angular, _) {
...
@@ -120,8 +119,7 @@ function (angular, _) {
if
(
segment
.
value
===
$scope
.
removeDimSegment
.
value
)
{
if
(
segment
.
value
===
$scope
.
removeDimSegment
.
value
)
{
$scope
.
dimSegments
.
splice
(
index
,
3
);
$scope
.
dimSegments
.
splice
(
index
,
3
);
}
}
else
if
(
segment
.
type
===
'plus-button'
)
{
else
if
(
segment
.
type
===
'plus-button'
)
{
$scope
.
dimSegments
.
push
(
uiSegmentSrv
.
newOperator
(
'='
));
$scope
.
dimSegments
.
push
(
uiSegmentSrv
.
newOperator
(
'='
));
$scope
.
dimSegments
.
push
(
uiSegmentSrv
.
newFake
(
'select dimension value'
,
'value'
,
'query-segment-value'
));
$scope
.
dimSegments
.
push
(
uiSegmentSrv
.
newFake
(
'select dimension value'
,
'value'
,
'query-segment-value'
));
segment
.
type
=
'key'
;
segment
.
type
=
'key'
;
...
@@ -195,7 +193,8 @@ function (angular, _) {
...
@@ -195,7 +193,8 @@ function (angular, _) {
};
};
$scope
.
init
();
$scope
.
init
();
}
}
});
angular
.
module
(
'grafana.controllers'
).
directive
(
'cloudwatchQueryParameter'
,
CloudWatchQueryParameter
);
angular
.
module
(
'grafana.controllers'
).
controller
(
'CloudWatchQueryParameterCtrl'
,
CloudWatchQueryParameterCtrl
);
});
public/app/plugins/datasource/prometheus/metric_find_query.
j
s
→
public/app/plugins/datasource/prometheus/metric_find_query.
t
s
View file @
27e486d6
define
([
import
_
from
"lodash"
;
'lodash'
],
function
(
_
)
{
'use strict'
;
function
PrometheusMetricFindQuery
(
datasource
,
query
,
timeSrv
)
{
export
default
class
PrometheusMetricFindQuery
{
datasource
:
any
;
query
:
any
;
range
:
any
;
constructor
(
datasource
,
query
,
timeSrv
)
{
this
.
datasource
=
datasource
;
this
.
datasource
=
datasource
;
this
.
query
=
query
;
this
.
query
=
query
;
this
.
range
=
timeSrv
.
timeRange
();
this
.
range
=
timeSrv
.
timeRange
();
}
}
PrometheusMetricFindQuery
.
prototype
.
process
=
function
()
{
process
()
{
var
label_values_regex
=
/^label_values
\((?:(
.+
)
,
\s
*
)?([
a-zA-Z_
][
a-zA-Z0-9_
]
+
)\)
$/
;
var
label_values_regex
=
/^label_values
\((?:(
.+
)
,
\s
*
)?([
a-zA-Z_
][
a-zA-Z0-9_
]
+
)\)
$/
;
var
metric_names_regex
=
/^metrics
\((
.+
)\)
$/
;
var
metric_names_regex
=
/^metrics
\((
.+
)\)
$/
;
var
query_result_regex
=
/^query_result
\((
.+
)\)
$/
;
var
query_result_regex
=
/^query_result
\((
.+
)\)
$/
;
...
@@ -18,7 +19,10 @@ function (_) {
...
@@ -18,7 +19,10 @@ function (_) {
var
label_values_query
=
this
.
query
.
match
(
label_values_regex
);
var
label_values_query
=
this
.
query
.
match
(
label_values_regex
);
if
(
label_values_query
)
{
if
(
label_values_query
)
{
if
(
label_values_query
[
1
])
{
if
(
label_values_query
[
1
])
{
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
label_values_query
[
1
]);
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
label_values_query
[
1
]
);
}
else
{
}
else
{
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
null
);
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
null
);
}
}
...
@@ -36,29 +40,32 @@ function (_) {
...
@@ -36,29 +40,32 @@ function (_) {
// if query contains full metric name, return metric name and label list
// if query contains full metric name, return metric name and label list
return
this
.
metricNameAndLabelsQuery
(
this
.
query
);
return
this
.
metricNameAndLabelsQuery
(
this
.
query
);
}
;
}
PrometheusMetricFindQuery
.
prototype
.
labelValuesQuery
=
function
(
label
,
metric
)
{
labelValuesQuery
(
label
,
metric
)
{
var
url
;
var
url
;
if
(
!
metric
)
{
if
(
!
metric
)
{
// return label values globally
// return label values globally
url
=
'/api/v1/label/'
+
label
+
'/values'
;
url
=
"/api/v1/label/"
+
label
+
"/values"
;
return
this
.
datasource
.
_request
(
'GET'
,
url
).
then
(
function
(
result
)
{
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
return
_
.
map
(
result
.
data
.
data
,
function
(
value
)
{
return
_
.
map
(
result
.
data
.
data
,
function
(
value
)
{
return
{
text
:
value
};
return
{
text
:
value
};
});
});
});
});
}
else
{
}
else
{
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
url
=
'/api/v1/series?match[]='
+
encodeURIComponent
(
metric
)
url
=
+
'&start='
+
start
"/api/v1/series?match[]="
+
+
'&end='
+
end
;
encodeURIComponent
(
metric
)
+
"&start="
+
return
this
.
datasource
.
_request
(
'GET'
,
url
)
start
+
.
then
(
function
(
result
)
{
"&end="
+
end
;
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
var
_labels
=
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
var
_labels
=
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
return
metric
[
label
];
return
metric
[
label
];
});
});
...
@@ -71,58 +78,64 @@ function (_) {
...
@@ -71,58 +78,64 @@ function (_) {
});
});
});
});
}
}
}
;
}
PrometheusMetricFindQuery
.
prototype
.
metricNameQuery
=
function
(
metricFilterPattern
)
{
metricNameQuery
(
metricFilterPattern
)
{
var
url
=
'/api/v1/label/__name__/values'
;
var
url
=
"/api/v1/label/__name__/values"
;
return
this
.
datasource
.
_request
(
'GET'
,
url
)
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
return
_
.
chain
(
result
.
data
.
data
)
return
_
.
chain
(
result
.
data
.
data
)
.
filter
(
function
(
metricName
)
{
.
filter
(
function
(
metricName
)
{
var
r
=
new
RegExp
(
metricFilterPattern
);
var
r
=
new
RegExp
(
metricFilterPattern
);
return
r
.
test
(
metricName
);
return
r
.
test
(
metricName
);
})
})
.
map
(
function
(
matchedMetricName
)
{
.
map
(
function
(
matchedMetricName
)
{
return
{
return
{
text
:
matchedMetricName
,
text
:
matchedMetricName
,
expandable
:
true
expandable
:
true
};
};
})
})
.
value
();
.
value
();
});
});
}
;
}
PrometheusMetricFindQuery
.
prototype
.
queryResultQuery
=
function
(
query
)
{
queryResultQuery
(
query
)
{
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
return
this
.
datasource
.
performInstantQuery
({
expr
:
query
},
end
)
return
this
.
datasource
.
then
(
function
(
result
)
{
.
performInstantQuery
({
expr
:
query
},
end
)
return
_
.
map
(
result
.
data
.
data
.
result
,
function
(
metricData
)
{
.
then
(
function
(
result
)
{
var
text
=
metricData
.
metric
.
__name__
||
''
;
return
_
.
map
(
result
.
data
.
data
.
result
,
function
(
metricData
)
{
delete
metricData
.
metric
.
__name__
;
var
text
=
metricData
.
metric
.
__name__
||
""
;
text
+=
'{'
+
delete
metricData
.
metric
.
__name__
;
_
.
map
(
metricData
.
metric
,
function
(
v
,
k
)
{
return
k
+
'="'
+
v
+
'"'
;
}).
join
(
','
)
+
text
+=
'}'
;
"{"
+
text
+=
' '
+
metricData
.
value
[
1
]
+
' '
+
metricData
.
value
[
0
]
*
1000
;
_
.
map
(
metricData
.
metric
,
function
(
v
,
k
)
{
return
k
+
'="'
+
v
+
'"'
;
}).
join
(
","
)
+
"}"
;
text
+=
" "
+
metricData
.
value
[
1
]
+
" "
+
metricData
.
value
[
0
]
*
1000
;
return
{
return
{
text
:
text
,
text
:
text
,
expandable
:
true
expandable
:
true
};
};
});
});
});
});
}
};
PrometheusMetricFindQuery
.
prototype
.
metricNameAndLabelsQuery
=
function
(
query
)
{
metricNameAndLabelsQuery
(
query
)
{
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
var
url
=
'/api/v1/series?match[]='
+
encodeURIComponent
(
query
)
var
url
=
+
'&start='
+
start
"/api/v1/series?match[]="
+
+
'&end='
+
end
;
encodeURIComponent
(
query
)
+
"&start="
+
start
+
"&end="
+
end
;
var
self
=
this
;
var
self
=
this
;
return
this
.
datasource
.
_request
(
'GET'
,
url
)
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
return
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
return
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
return
{
return
{
text
:
self
.
datasource
.
getOriginalMetricName
(
metric
),
text
:
self
.
datasource
.
getOriginalMetricName
(
metric
),
...
@@ -130,7 +143,5 @@ function (_) {
...
@@ -130,7 +143,5 @@ function (_) {
};
};
});
});
});
});
};
}
}
return
PrometheusMetricFindQuery
;
});
public/app/plugins/panel/graph/series_overrides_ctrl.
j
s
→
public/app/plugins/panel/graph/series_overrides_ctrl.
t
s
View file @
27e486d6
define
([
import
_
from
'lodash'
;
'angular'
,
import
angular
from
'angular'
;
'jquery'
,
'lodash'
,
],
function
(
angular
,
jquery
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
export
class
SeriesOverridesCtrl
{
module
.
controller
(
'SeriesOverridesCtrl'
,
function
(
$scope
,
$element
,
popoverSrv
)
{
/** @ngInject */
constructor
(
$scope
,
$element
,
popoverSrv
)
{
$scope
.
overrideMenu
=
[];
$scope
.
overrideMenu
=
[];
$scope
.
currentOverrides
=
[];
$scope
.
currentOverrides
=
[];
$scope
.
override
=
$scope
.
override
||
{};
$scope
.
override
=
$scope
.
override
||
{};
$scope
.
addOverrideOption
=
function
(
name
,
propertyName
,
values
)
{
$scope
.
addOverrideOption
=
function
(
name
,
propertyName
,
values
)
{
var
option
=
{
};
var
option
=
{
option
.
text
=
name
;
text
:
name
,
option
.
propertyName
=
propertyName
;
propertyName
:
propertyName
,
option
.
index
=
$scope
.
overrideMenu
.
length
;
index
:
$scope
.
overrideMenu
.
lenght
,
option
.
values
=
values
;
values
:
values
,
submenu
:
_
.
map
(
values
,
function
(
value
)
{
option
.
submenu
=
_
.
map
(
values
,
function
(
value
)
{
return
{
text
:
String
(
value
),
value
:
value
};
return
{
text
:
String
(
value
),
value
:
value
};
})
}
)
;
};
$scope
.
overrideMenu
.
push
(
option
);
$scope
.
overrideMenu
.
push
(
option
);
};
};
...
@@ -97,22 +94,24 @@ define([
...
@@ -97,22 +94,24 @@ define([
$scope
.
addOverrideOption
(
'Bars'
,
'bars'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Bars'
,
'bars'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Lines'
,
'lines'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Lines'
,
'lines'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Line fill'
,
'fill'
,
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]);
$scope
.
addOverrideOption
(
'Line fill'
,
'fill'
,
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]);
$scope
.
addOverrideOption
(
'Line width'
,
'linewidth'
,
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]);
$scope
.
addOverrideOption
(
'Line width'
,
'linewidth'
,
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]);
$scope
.
addOverrideOption
(
'Null point mode'
,
'nullPointMode'
,
[
'connected'
,
'null'
,
'null as zero'
]);
$scope
.
addOverrideOption
(
'Null point mode'
,
'nullPointMode'
,
[
'connected'
,
'null'
,
'null as zero'
]);
$scope
.
addOverrideOption
(
'Fill below to'
,
'fillBelowTo'
,
$scope
.
getSeriesNames
());
$scope
.
addOverrideOption
(
'Fill below to'
,
'fillBelowTo'
,
$scope
.
getSeriesNames
());
$scope
.
addOverrideOption
(
'Staircase line'
,
'steppedLine'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Staircase line'
,
'steppedLine'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Dashes'
,
'dashes'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Dashes'
,
'dashes'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Dash Length'
,
'dashLength'
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
]);
$scope
.
addOverrideOption
(
'Dash Length'
,
'dashLength'
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
]);
$scope
.
addOverrideOption
(
'Dash Space'
,
'spaceLength'
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
]);
$scope
.
addOverrideOption
(
'Dash Space'
,
'spaceLength'
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
]);
$scope
.
addOverrideOption
(
'Points'
,
'points'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Points'
,
'points'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Points Radius'
,
'pointradius'
,
[
1
,
2
,
3
,
4
,
5
]);
$scope
.
addOverrideOption
(
'Points Radius'
,
'pointradius'
,
[
1
,
2
,
3
,
4
,
5
]);
$scope
.
addOverrideOption
(
'Stack'
,
'stack'
,
[
true
,
false
,
'A'
,
'B'
,
'C'
,
'D'
]);
$scope
.
addOverrideOption
(
'Stack'
,
'stack'
,
[
true
,
false
,
'A'
,
'B'
,
'C'
,
'D'
]);
$scope
.
addOverrideOption
(
'Color'
,
'color'
,
[
'change'
]);
$scope
.
addOverrideOption
(
'Color'
,
'color'
,
[
'change'
]);
$scope
.
addOverrideOption
(
'Y-axis'
,
'yaxis'
,
[
1
,
2
]);
$scope
.
addOverrideOption
(
'Y-axis'
,
'yaxis'
,
[
1
,
2
]);
$scope
.
addOverrideOption
(
'Z-index'
,
'zindex'
,
[
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
]);
$scope
.
addOverrideOption
(
'Z-index'
,
'zindex'
,
[
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
]);
$scope
.
addOverrideOption
(
'Transform'
,
'transform'
,
[
'negative-Y'
]);
$scope
.
addOverrideOption
(
'Transform'
,
'transform'
,
[
'negative-Y'
]);
$scope
.
addOverrideOption
(
'Legend'
,
'legend'
,
[
true
,
false
]);
$scope
.
addOverrideOption
(
'Legend'
,
'legend'
,
[
true
,
false
]);
$scope
.
updateCurrentOverrides
();
$scope
.
updateCurrentOverrides
();
});
}
});
}
angular
.
module
(
'grafana.controllers'
).
controller
(
'SeriesOverridesCtrl'
,
SeriesOverridesCtrl
);
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