Save and restore end date in/from url.

This commit is contained in:
Johannes 'fish' Ziemke 2013-03-21 17:06:37 +01:00
parent 1f484b03c7
commit 8e55ff0a8d
2 changed files with 12 additions and 6 deletions

View File

@ -43,7 +43,7 @@
<label for="end{{id}}">End:</label>
<input type="button" value="<<" name="dec_end">
<input type="text" name="end" id="end{{id}}" value="{{end}}">
<input type="text" name="end_input" id="end{{id}}" value="{{end}}">
<input type="button" value=">>" name="inc_end">
<label for="step_input{{id}}">Resolution (s):</label>

View File

@ -76,9 +76,14 @@ Prometheus.Graph.prototype.initialize = function() {
self.spinner = graphWrapper.find(".spinner");
self.evalStats = graphWrapper.find(".eval_stats");
self.endDate = graphWrapper.find("input[name=end]");
self.endDate.appendDtpicker();
self.endDate.val("")
self.endDate = graphWrapper.find("input[name=end_input]");
console.log(self.options)
if (self.options["end_input"]) {
self.endDate.appendDtpicker({"current": self.options["end_input"]})
} else {
self.endDate.appendDtpicker();
self.endDate.val("")
}
self.endDate.change(function() { self.submitQuery() });
self.stacked.change(function() { self.updateGraph(); });
@ -131,7 +136,7 @@ Prometheus.Graph.prototype.getOptions = function() {
var optionInputs = [
"expr",
"range_input",
"end",
"end_input",
"step_input",
"stacked"
];
@ -189,6 +194,7 @@ Prometheus.Graph.prototype.decreaseRange = function() {
};
Prometheus.Graph.prototype.getEndDate = function() {
var self = this
if (!self.endDate || !self.endDate.val()) {
return null;
}
@ -196,6 +202,7 @@ Prometheus.Graph.prototype.getEndDate = function() {
};
Prometheus.Graph.prototype.getOrSetEndDate = function() {
var self = this
var date = self.getEndDate();
if (date) {
return date
@ -239,7 +246,6 @@ Prometheus.Graph.prototype.submitQuery = function() {
var data = self.queryForm.serialize();
var endDate = self.getEndDate()
if (endDate) {
data = data + "&end=" + endDate/1000
}