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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
82 deletions
+91
-82
public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.ts
+14
-15
public/app/plugins/datasource/prometheus/metric_find_query.ts
+54
-43
public/app/plugins/panel/graph/series_overrides_ctrl.ts
+23
-24
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
([
'angular'
,
'lodash'
,
],
function
(
angular
,
_
)
{
'use strict'
;
import
angular
from
'angular'
;
import
_
from
'lodash'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
export
class
CloudWatchQueryParameter
{
module
.
directive
(
'cloudwatchQueryParameter'
,
function
()
{
constructor
()
{
return
{
templateUrl
:
'public/app/plugins/datasource/cloudwatch/partials/query.parameter.html'
,
controller
:
'CloudWatchQueryParameterCtrl'
,
...
...
@@ -18,9 +14,12 @@ function (angular, _) {
onChange
:
"&"
,
}
};
});
}
}
module
.
controller
(
'CloudWatchQueryParameterCtrl'
,
function
(
$scope
,
templateSrv
,
uiSegmentSrv
,
datasourceSrv
,
$q
)
{
export
class
CloudWatchQueryParameterCtrl
{
constructor
(
$scope
,
templateSrv
,
uiSegmentSrv
,
datasourceSrv
,
$q
)
{
$scope
.
init
=
function
()
{
var
target
=
$scope
.
target
;
...
...
@@ -120,8 +119,7 @@ function (angular, _) {
if
(
segment
.
value
===
$scope
.
removeDimSegment
.
value
)
{
$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
.
newFake
(
'select dimension value'
,
'value'
,
'query-segment-value'
));
segment
.
type
=
'key'
;
...
...
@@ -195,7 +193,8 @@ function (angular, _) {
};
$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
([
'lodash'
],
function
(
_
)
{
'use strict'
;
import
_
from
"lodash"
;
function
PrometheusMetricFindQuery
(
datasource
,
query
,
timeSrv
)
{
export
default
class
PrometheusMetricFindQuery
{
datasource
:
any
;
query
:
any
;
range
:
any
;
constructor
(
datasource
,
query
,
timeSrv
)
{
this
.
datasource
=
datasource
;
this
.
query
=
query
;
this
.
range
=
timeSrv
.
timeRange
();
}
PrometheusMetricFindQuery
.
prototype
.
process
=
function
()
{
process
()
{
var
label_values_regex
=
/^label_values
\((?:(
.+
)
,
\s
*
)?([
a-zA-Z_
][
a-zA-Z0-9_
]
+
)\)
$/
;
var
metric_names_regex
=
/^metrics
\((
.+
)\)
$/
;
var
query_result_regex
=
/^query_result
\((
.+
)\)
$/
;
...
...
@@ -18,7 +19,10 @@ function (_) {
var
label_values_query
=
this
.
query
.
match
(
label_values_regex
);
if
(
label_values_query
)
{
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
{
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
null
);
}
...
...
@@ -36,29 +40,32 @@ function (_) {
// if query contains full metric name, return metric name and label list
return
this
.
metricNameAndLabelsQuery
(
this
.
query
);
}
;
}
PrometheusMetricFindQuery
.
prototype
.
labelValuesQuery
=
function
(
label
,
metric
)
{
labelValuesQuery
(
label
,
metric
)
{
var
url
;
if
(
!
metric
)
{
// 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
{
text
:
value
};
return
{
text
:
value
};
});
});
}
else
{
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
url
=
'/api/v1/series?match[]='
+
encodeURIComponent
(
metric
)
+
'&start='
+
start
+
'&end='
+
end
;
return
this
.
datasource
.
_request
(
'GET'
,
url
)
.
then
(
function
(
result
)
{
url
=
"/api/v1/series?match[]="
+
encodeURIComponent
(
metric
)
+
"&start="
+
start
+
"&end="
+
end
;
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
var
_labels
=
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
return
metric
[
label
];
});
...
...
@@ -71,13 +78,12 @@ function (_) {
});
});
}
}
;
}
PrometheusMetricFindQuery
.
prototype
.
metricNameQuery
=
function
(
metricFilterPattern
)
{
var
url
=
'/api/v1/label/__name__/values'
;
metricNameQuery
(
metricFilterPattern
)
{
var
url
=
"/api/v1/label/__name__/values"
;
return
this
.
datasource
.
_request
(
'GET'
,
url
)
.
then
(
function
(
result
)
{
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
return
_
.
chain
(
result
.
data
.
data
)
.
filter
(
function
(
metricName
)
{
var
r
=
new
RegExp
(
metricFilterPattern
);
...
...
@@ -91,19 +97,23 @@ function (_) {
})
.
value
();
});
}
;
}
PrometheusMetricFindQuery
.
prototype
.
queryResultQuery
=
function
(
query
)
{
queryResultQuery
(
query
)
{
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
return
this
.
datasource
.
performInstantQuery
({
expr
:
query
},
end
)
return
this
.
datasource
.
performInstantQuery
({
expr
:
query
},
end
)
.
then
(
function
(
result
)
{
return
_
.
map
(
result
.
data
.
data
.
result
,
function
(
metricData
)
{
var
text
=
metricData
.
metric
.
__name__
||
''
;
var
text
=
metricData
.
metric
.
__name__
||
""
;
delete
metricData
.
metric
.
__name__
;
text
+=
'{'
+
_
.
map
(
metricData
.
metric
,
function
(
v
,
k
)
{
return
k
+
'="'
+
v
+
'"'
;
}).
join
(
','
)
+
'}'
;
text
+=
' '
+
metricData
.
value
[
1
]
+
' '
+
metricData
.
value
[
0
]
*
1000
;
text
+=
"{"
+
_
.
map
(
metricData
.
metric
,
function
(
v
,
k
)
{
return
k
+
'="'
+
v
+
'"'
;
}).
join
(
","
)
+
"}"
;
text
+=
" "
+
metricData
.
value
[
1
]
+
" "
+
metricData
.
value
[
0
]
*
1000
;
return
{
text
:
text
,
...
...
@@ -111,18 +121,21 @@ function (_) {
};
});
});
}
;
}
PrometheusMetricFindQuery
.
prototype
.
metricNameAndLabelsQuery
=
function
(
query
)
{
metricNameAndLabelsQuery
(
query
)
{
var
start
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
from
,
false
);
var
end
=
this
.
datasource
.
getPrometheusTime
(
this
.
range
.
to
,
true
);
var
url
=
'/api/v1/series?match[]='
+
encodeURIComponent
(
query
)
+
'&start='
+
start
+
'&end='
+
end
;
var
url
=
"/api/v1/series?match[]="
+
encodeURIComponent
(
query
)
+
"&start="
+
start
+
"&end="
+
end
;
var
self
=
this
;
return
this
.
datasource
.
_request
(
'GET'
,
url
)
.
then
(
function
(
result
)
{
return
this
.
datasource
.
_request
(
"GET"
,
url
).
then
(
function
(
result
)
{
return
_
.
map
(
result
.
data
.
data
,
function
(
metric
)
{
return
{
text
:
self
.
datasource
.
getOriginalMetricName
(
metric
),
...
...
@@ -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
([
'angular'
,
'jquery'
,
'lodash'
,
],
function
(
angular
,
jquery
,
_
)
{
'use strict'
;
import
_
from
'lodash'
;
import
angular
from
'angular'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
export
class
SeriesOverridesCtrl
{
module
.
controller
(
'SeriesOverridesCtrl'
,
function
(
$scope
,
$element
,
popoverSrv
)
{
/** @ngInject */
constructor
(
$scope
,
$element
,
popoverSrv
)
{
$scope
.
overrideMenu
=
[];
$scope
.
currentOverrides
=
[];
$scope
.
override
=
$scope
.
override
||
{};
$scope
.
addOverrideOption
=
function
(
name
,
propertyName
,
values
)
{
var
option
=
{};
option
.
text
=
name
;
option
.
propertyName
=
propertyName
;
option
.
index
=
$scope
.
overrideMenu
.
length
;
option
.
values
=
values
;
option
.
submenu
=
_
.
map
(
values
,
function
(
value
)
{
var
option
=
{
text
:
name
,
propertyName
:
propertyName
,
index
:
$scope
.
overrideMenu
.
lenght
,
values
:
values
,
submenu
:
_
.
map
(
values
,
function
(
value
)
{
return
{
text
:
String
(
value
),
value
:
value
};
});
})
};
$scope
.
overrideMenu
.
push
(
option
);
};
...
...
@@ -97,22 +94,24 @@ define([
$scope
.
addOverrideOption
(
'Bars'
,
'bars'
,
[
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 width'
,
'linewidth'
,
[
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
(
'Null point mode'
,
'nullPointMode'
,
[
'connected'
,
'null'
,
'null as zero'
]);
$scope
.
addOverrideOption
(
'Fill below to'
,
'fillBelowTo'
,
$scope
.
getSeriesNames
());
$scope
.
addOverrideOption
(
'Staircase line'
,
'steppedLine'
,
[
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 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 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
(
'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
(
'Color'
,
'color'
,
[
'change'
]);
$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
(
'Legend'
,
'legend'
,
[
true
,
false
]);
$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