Skip to content
Browse files

fixed a bug around modifying the timeframe of a profile and being abl…

…e to copy and paste the resulting url
  • Loading branch information...
1 parent 7793d4d commit 2e40b63715b0f8e916166209d6864ab1bdb38ad1 @jessereynolds jessereynolds committed Jul 16, 2012
Showing with 16 additions and 15 deletions.
  1. +14 −13 lib/visage-app/public/javascripts/builder.js
  2. +2 −2 lib/visage-app/views/builder_form.haml
View
27 lib/visage-app/public/javascripts/builder.js
@@ -418,6 +418,7 @@ var TokenSearch = new Class({
var ChartBuilder = new Class({
Implements: [ Options, Events ],
initialize: function(element, options) {
+
this.setOptions(options);
this.builder = $(element);
@@ -464,18 +465,23 @@ var ChartBuilder = new Class({
this.searchers.metric = searcher;
},
getTimeframe: function() {
+ /* FIXME: note that this.options.timeframe will be overwritten by setOptions(options) at the top
+ * of ChartBuilder with the timeframe specified in the URL hash, if any. Therefore we
+ * shouldn't need to get it out of the URL again here. HOWEVER, setOptions is failing to
+ * urlDecode the timeframe value from the URL, so we still need to do that. There must be a
+ * better way than getting it from the URL again however...
+ */
var optionTimeframe = this.options.timeframe,
urlTimeframe = window.location.hash.split('|').filter(function(parameter) { return parameter.test('^timeframe') })[0];
- if (optionTimeframe && !urlTimeframe) {
- return optionTimeframe
- }
-
if (urlTimeframe) {
return decodeURI(urlTimeframe.split('=')[1]);
+ } else if (optionTimeframe) {
+ return optionTimeframe
} else {
return null;
}
+
},
setupTimeframeSelection: function() {
var currentDate = new Date;
@@ -533,8 +539,6 @@ var ChartBuilder = new Class({
parameters.include(timeframe);
}
- console.log(parameters);
-
var hash = parameters.join('|');
window.location.hash = hash;
},
@@ -557,7 +561,6 @@ var ChartBuilder = new Class({
'2 years': 17520 });
timeframe = this.getTimeframe();
- console.log(timeframe, 'timeframe')
timescales.each(function(hour, label) {
var value = "start={start}".substitute({'start': currentUnixTime - (hour * 3600)});
var html = 'last {label}'.substitute({'label': label });
@@ -589,7 +592,7 @@ var ChartBuilder = new Class({
select.grab(option)
});
- $('profile-options').grab(container, 'bottom');
+ $('profile-settings').grab(container, 'bottom');
container.grab(select)
},
setupPercentileSelection: function() {
@@ -629,7 +632,7 @@ var ChartBuilder = new Class({
container.grab(percentileSelector);
}
- $('profile-options').grab(container, 'bottom');
+ $('profile-settings').grab(container, 'bottom');
},
setupSave: function() {
@@ -677,7 +680,6 @@ var ChartBuilder = new Class({
'percentiles': percentiles,
'timeframe': timeframe
}});
- console.log(timeframe);
}.bind(this)
}
@@ -745,8 +747,8 @@ var ChartBuilder = new Class({
graphs = $('graphs'),
save = this.save,
profile_name = this.profile_name,
- percentiles = this.options.percentiles;
- timeframe = this.options.timeframe,
+ percentiles = this.options.percentiles,
+ timeframe = this.getTimeframe();
graphs.empty();
hosts.each(function(host) {
@@ -769,7 +771,6 @@ var ChartBuilder = new Class({
var element = new Element('div', {'class': 'graph'});
graphs.grab(element);
- console.log('showGraphs: timeframe: ' + timeframe)
var graph = new VisageGraph(element, host, plugin, {
pluginInstance: metrics.join(','),
percentiles: percentiles,
View
4 lib/visage-app/views/builder_form.haml
@@ -9,8 +9,8 @@
%img{:src => link_to("/images/metrics.png"), :class => "icon metrics"}
%div.search
- %div#profile-options.builder.full
- %h2 Profile Options
+ %div#profile-settings.builder.full
+ %h2 Profile Settings
%input#show{:value => "Show graphs", :type => "button", :class => "button"}

0 comments on commit 2e40b63

Please sign in to comment.
Something went wrong with that request. Please try again.