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
44d377b8
Commit
44d377b8
authored
Oct 06, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(prometheus): refactoring and polish of the prometheus editor removing unused/uneeded code
parent
a2bf3e05
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
157 deletions
+54
-157
public/app/plugins/datasource/prometheus/datasource.js
+1
-2
public/app/plugins/datasource/prometheus/partials/query.editor.html
+3
-21
public/app/plugins/datasource/prometheus/queryCtrl.js
+0
-133
public/app/plugins/datasource/prometheus/query_ctrl.js
+50
-0
tasks/options/requirejs.js
+0
-1
No files found.
public/app/plugins/datasource/prometheus/datasource.js
View file @
44d377b8
...
...
@@ -5,7 +5,7 @@ define([
'moment'
,
'app/core/utils/datemath'
,
'./directives'
,
'./query
C
trl'
,
'./query
_c
trl'
,
],
function
(
angular
,
_
,
kbn
,
dateMath
)
{
'use strict'
;
...
...
@@ -22,7 +22,6 @@ function (angular, _, kbn, dateMath) {
var
url
=
datasource
.
url
;
if
(
url
[
url
.
length
-
1
]
===
'/'
)
{
// remove trailing slash
url
=
url
.
substr
(
0
,
url
.
length
-
1
);
}
this
.
url
=
url
;
...
...
public/app/plugins/datasource/prometheus/partials/query.editor.html
View file @
44d377b8
...
...
@@ -48,13 +48,7 @@
placeholder=
"query expression"
data-min-length=
0
data-items=
100
ng-model-onblur
ng-change=
"refreshMetricData()"
>
<a
bs-tooltip=
"target.datasourceErrors.query"
style=
"color: rgb(229, 189, 28)"
ng-show=
"target.datasourceErrors.query"
>
<i
class=
"fa fa-warning"
></i>
</a>
ng-change=
"refreshMetricData()"
>
</li>
<li
class=
"tight-form-item"
>
Metric
...
...
@@ -66,13 +60,7 @@
spellcheck=
'false'
bs-typeahead=
"suggestMetrics"
placeholder=
"metric name"
data-min-length=
0
data-items=
100
>
<a
bs-tooltip=
"target.errors.metric"
style=
"color: rgb(229, 189, 28)"
ng-show=
"target.errors.metric"
>
<i
class=
"fa fa-warning"
></i>
</a>
data-min-length=
0
data-items=
100
>
</li>
</ul>
...
...
@@ -113,7 +101,7 @@
bs-tooltip=
"'Leave blank for auto handling based on time range and panel width'"
data-placement=
"right"
spellcheck=
'false'
placeholder=
"{{
target.calculatedI
nterval}}"
placeholder=
"{{
i
nterval}}"
data-min-length=
0
data-items=
100
ng-model-onblur
ng-change=
"refreshMetricData()"
...
...
@@ -131,12 +119,6 @@
</select>
</li>
<li
class=
"tight-form-item"
>
<a
href=
"{{target.prometheusLink}}"
target=
"_blank"
bs-tooltip=
"'Link to Graph in Prometheus'"
>
<i
class=
"fa fa-share-square-o"
></i>
</a>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
public/app/plugins/datasource/prometheus/queryCtrl.js
deleted
100644 → 0
View file @
a2bf3e05
define
([
'angular'
,
'lodash'
,
'kbn'
,
'app/core/utils/datemath'
,
],
function
(
angular
,
_
,
kbn
,
dateMath
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'PrometheusQueryCtrl'
,
function
(
$scope
)
{
$scope
.
init
=
function
()
{
$scope
.
target
.
errors
=
validateTarget
();
$scope
.
target
.
datasourceErrors
=
{};
if
(
!
$scope
.
target
.
expr
)
{
$scope
.
target
.
expr
=
''
;
}
$scope
.
target
.
metric
=
''
;
$scope
.
resolutions
=
[
{
factor
:
1
,
},
{
factor
:
2
,
},
{
factor
:
3
,
},
{
factor
:
5
,
},
{
factor
:
10
,
},
];
$scope
.
resolutions
=
_
.
map
(
$scope
.
resolutions
,
function
(
r
)
{
r
.
label
=
'1/'
+
r
.
factor
;
return
r
;
});
if
(
!
$scope
.
target
.
intervalFactor
)
{
$scope
.
target
.
intervalFactor
=
2
;
// default resolution is 1/2
}
$scope
.
calculateInterval
();
$scope
.
$on
(
'render'
,
function
()
{
$scope
.
calculateInterval
();
// re-calculate interval when time range is updated
});
$scope
.
target
.
prometheusLink
=
$scope
.
linkToPrometheus
();
$scope
.
$on
(
'typeahead-updated'
,
function
()
{
$scope
.
$apply
(
$scope
.
inputMetric
);
$scope
.
refreshMetricData
();
});
$scope
.
datasource
.
lastErrors
=
{};
$scope
.
$watch
(
'datasource.lastErrors'
,
function
()
{
$scope
.
target
.
datasourceErrors
=
$scope
.
datasource
.
lastErrors
;
},
true
);
};
$scope
.
refreshMetricData
=
function
()
{
$scope
.
target
.
errors
=
validateTarget
(
$scope
.
target
);
$scope
.
calculateInterval
();
$scope
.
target
.
prometheusLink
=
$scope
.
linkToPrometheus
();
// this does not work so good
if
(
!
_
.
isEqual
(
$scope
.
oldTarget
,
$scope
.
target
)
&&
_
.
isEmpty
(
$scope
.
target
.
errors
))
{
$scope
.
oldTarget
=
angular
.
copy
(
$scope
.
target
);
$scope
.
get_data
();
}
};
$scope
.
inputMetric
=
function
()
{
$scope
.
target
.
expr
+=
$scope
.
target
.
metric
;
$scope
.
target
.
metric
=
''
;
};
$scope
.
moveMetricQuery
=
function
(
fromIndex
,
toIndex
)
{
_
.
move
(
$scope
.
panel
.
targets
,
fromIndex
,
toIndex
);
};
$scope
.
suggestMetrics
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
performSuggestQuery
(
query
)
.
then
(
callback
);
};
$scope
.
linkToPrometheus
=
function
()
{
var
from
=
dateMath
.
parse
(
$scope
.
dashboard
.
time
.
from
,
false
);
var
to
=
dateMath
.
parse
(
$scope
.
dashboard
.
time
.
to
,
true
);
if
(
$scope
.
panel
.
timeFrom
)
{
from
=
dateMath
.
parseDateMath
(
'-'
+
$scope
.
panel
.
timeFrom
,
to
,
false
);
}
if
(
$scope
.
panel
.
timeShift
)
{
from
=
dateMath
.
parseDateMath
(
'-'
+
$scope
.
panel
.
timeShift
,
from
,
false
);
to
=
dateMath
.
parseDateMath
(
'-'
+
$scope
.
panel
.
timeShift
,
to
,
true
);
}
var
range
=
Math
.
ceil
((
to
.
valueOf
()
-
from
.
valueOf
())
/
1000
);
var
endTime
=
to
.
format
(
'YYYY-MM-DD HH:MM'
);
var
step
=
kbn
.
interval_to_seconds
(
this
.
target
.
calculatedInterval
);
if
(
step
!==
0
&&
range
/
step
>
11000
)
{
step
=
Math
.
floor
(
range
/
11000
);
}
var
expr
=
{
expr
:
$scope
.
target
.
expr
,
range_input
:
range
+
's'
,
end_input
:
endTime
,
//step_input: step,
step_input
:
''
,
stacked
:
$scope
.
panel
.
stack
,
tab
:
0
};
var
hash
=
encodeURIComponent
(
JSON
.
stringify
([
expr
]));
return
$scope
.
datasource
.
url
+
'/graph#'
+
hash
;
};
$scope
.
calculateInterval
=
function
()
{
var
interval
=
$scope
.
target
.
interval
||
$scope
.
interval
;
var
calculatedInterval
=
$scope
.
datasource
.
calculateInterval
(
interval
,
$scope
.
target
.
intervalFactor
);
$scope
.
target
.
calculatedInterval
=
kbn
.
secondsToHms
(
calculatedInterval
);
};
// TODO: validate target
function
validateTarget
()
{
var
errs
=
{};
return
errs
;
}
$scope
.
init
();
});
});
public/app/plugins/datasource/prometheus/query_ctrl.js
0 → 100644
View file @
44d377b8
define
([
'angular'
,
'lodash'
,
],
function
(
angular
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'PrometheusQueryCtrl'
,
function
(
$scope
)
{
$scope
.
init
=
function
()
{
var
target
=
$scope
.
target
;
target
.
expr
=
target
.
expr
||
''
;
target
.
intervalFactor
=
target
.
intervalFactor
||
2
;
$scope
.
metric
=
''
;
$scope
.
resolutions
=
_
.
map
([
1
,
2
,
3
,
4
,
5
,
10
],
function
(
f
)
{
return
{
factor
:
f
,
label
:
'1/'
+
f
};
});
$scope
.
$on
(
'typeahead-updated'
,
function
()
{
$scope
.
$apply
(
$scope
.
inputMetric
);
$scope
.
refreshMetricData
();
});
};
$scope
.
refreshMetricData
=
function
()
{
if
(
!
_
.
isEqual
(
$scope
.
oldTarget
,
$scope
.
target
))
{
$scope
.
oldTarget
=
angular
.
copy
(
$scope
.
target
);
$scope
.
get_data
();
}
};
$scope
.
inputMetric
=
function
()
{
$scope
.
target
.
expr
+=
$scope
.
target
.
metric
;
$scope
.
metric
=
''
;
};
$scope
.
suggestMetrics
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
performSuggestQuery
(
query
)
.
then
(
callback
);
};
$scope
.
init
();
});
});
tasks/options/requirejs.js
View file @
44d377b8
...
...
@@ -63,7 +63,6 @@ module.exports = function(config,grunt) {
'app/plugins/datasource/grafana/datasource'
,
'app/plugins/datasource/graphite/datasource'
,
'app/plugins/datasource/influxdb/datasource'
,
'app/plugins/datasource/prometheus/datasource'
,
]
},
];
...
...
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