spec/dummy/tmp/cache/assets/test/sprockets/f4648036e284d9aa3468f4f7b9bbb967 in prosperity-0.0.8 vs spec/dummy/tmp/cache/assets/test/sprockets/f4648036e284d9aa3468f4f7b9bbb967 in prosperity-0.0.9
- old
+ new
@@ -1,39 +1,58 @@
{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"prosperity/graph.js; FI"
pathname; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"content_type; TI"application/javascript; TI"
-mtime; Tl+Ò–vSI"length; TiÊI"digest; TI"%ef3d45f936196a1a0f5d081845ac46e2; FI"source; TI"Ê(function() {
+mtime; Tl+!÷‘SI"length; TiI"digest; TI"%fced0dfbcac5c41cfc9b5a627fdc6b81; FI"source; TI"(function() {
var Graph, SubGraph, updateMetricOptions,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
SubGraph = (function() {
function SubGraph(options) {
- var chartEl;
+ var chartEl, graphType, hoverCallback;
if (options == null) {
options = {};
}
this["class"] = __bind(this["class"], this);
this.el = $('<div>', {
"class": 'sub-graph'
});
- this.graphType = options.graphType;
+ graphType = this.graphType = options.graphType;
if (options.showTitle) {
this.el.append("<div class='title'>Loading...</div>");
}
this.el.find('.title').html(options.label);
chartEl = $('<div>', {
"class": 'sub-graph-chart'
});
this.el.append(chartEl);
+ hoverCallback = function(index, options, content, data) {
+ var key, sum, t, value;
+ if (graphType === 'area') {
+ data = options.data[index];
+ sum = 0;
+ for (key in data) {
+ value = data[key];
+ if (key !== 'x') {
+ sum += value;
+ }
+ }
+ t = "Total: " + sum;
+ content += t;
+ }
+ return content;
+ };
this.data = [];
this.chartOptions = {
element: chartEl,
series: [],
xkey: "x",
ykeys: [],
labels: [],
smooth: false,
- data: this.data
+ data: this.data,
+ hideHover: true,
+ hoverCallback: hoverCallback,
+ events: [new Date().toISOString()]
};
if (options.key === 'change') {
this.chartOptions.postUnits = '%';
}
}
@@ -77,50 +96,80 @@
this.getSubgraph = __bind(this.getSubgraph, this);
this.render = __bind(this.render, this);
this.url = options.url;
this.el = options.el;
this.$el = $(options.el);
- console.log(this.$el);
}
Graph.prototype.render = function() {
- $.getJSON(this.url, (function(_this) {
- return function(json) {
- var extractor, index, _i, _len, _ref, _results;
- _ref = json.extractors;
- _results = [];
- for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
- extractor = _ref[index];
- _results.push($.get(extractor.url, function(line_json) {
- var subgraph;
- subgraph = _this.getSubgraph({
- label: line_json.label,
- key: line_json.key,
- graphType: json.graph_type
- });
- subgraph.addSeries(line_json);
- if (_this.$el.hasClass('dashboard')) {
- if (subgraph.chartOptions.ykeys.length === json.extractors.length) {
- return subgraph.draw();
+ $.ajax({
+ url: this.url,
+ dataType: 'json',
+ success: (function(_this) {
+ return function(json) {
+ var extractor, index, _i, _len, _ref, _results;
+ _ref = json.extractors;
+ _results = [];
+ for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
+ extractor = _ref[index];
+ _results.push($.ajax({
+ url: extractor.url,
+ dataType: 'json',
+ success: function(line_json) {
+ var subgraph;
+ subgraph = _this.getSubgraph({
+ label: line_json.label,
+ key: line_json.key,
+ graphType: json.graph_type
+ });
+ subgraph.addSeries(line_json);
+ if (_this.$el.hasClass('dashboard')) {
+ if (subgraph.chartOptions.ykeys.length === json.extractors.length) {
+ return subgraph.draw();
+ }
+ } else {
+ return subgraph.draw();
+ }
+ },
+ error: function(xhr) {
+ return _this.displayError(xhr);
}
- } else {
- return subgraph.draw();
- }
- }));
- }
- return _results;
- };
- })(this));
+ }));
+ }
+ return _results;
+ };
+ })(this),
+ error: (function(_this) {
+ return function(xhr) {
+ return _this.displayError(xhr);
+ };
+ })(this)
+ });
return this;
};
+ Graph.prototype.displayError = function(xhr) {
+ var errorMessage, t;
+ errorMessage = null;
+ if (xhr.status >= 400 && xhr.status < 500) {
+ errorMessage = JSON.parse(xhr.responseText).error;
+ }
+ errorMessage || (errorMessage = "An unknown server error has occured.");
+ t = $('<div>', {
+ "class": 'alert alert-danger',
+ text: errorMessage
+ });
+ return this.$el.find('.errors').append(t);
+ };
+
Graph.prototype.getSubgraph = function(options) {
var create;
create = (function(_this) {
return function(options) {
var subgraph;
subgraph = new SubGraph(options);
+ _this.$el.find('.loading').remove();
_this.$el.append(subgraph.el);
return subgraph;
};
})(this);
if (this.$el.hasClass('dashboard')) {
@@ -147,10 +196,11 @@
return;
}
$form = $el.parents('form');
options = $form.data('metric-options');
possibleOptions = options[$el.val()] || [];
+ possibleOptions = possibleOptions.sort();
$optionSelect = $el.parents(".graph-line").find(".metric-option-select select");
selectedOption = $form.find("input[type=\"hidden\"][name=\"" + ($optionSelect.attr('name')) + "\"]").val();
$optionSelect.html('');
_results = [];
for (_i = 0, _len = possibleOptions.length; _i < _len; _i++) {
@@ -173,7 +223,7 @@
return updateMetricOptions(el);
});
});
}).call(this);
-; TI"dependency_digest; TI"%a0521ce1dce2fe8c2c34f47d6fdb2cc5; FI"required_paths; T[I"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"dependency_paths; T[{I" path; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"
-mtime; TI"2014-05-16T15:53:06-07:00; TI"digest; TI"%29586e08099c6d8566d8e573b25836c7; FI"
_version; TI"%2b66aa67c90052d553e0328c249bc9b0; F
+; TI"dependency_digest; TI"%aab6382b91f73c1669548b1e71d4af92; FI"required_paths; T[I"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"dependency_paths; T[{I" path; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"
+mtime; TI"2014-06-06T10:15:13-07:00; TI"digest; TI"%f1ee1186cf6fbea47d156fa7ec755cd8; FI"
_version; TI"%2b66aa67c90052d553e0328c249bc9b0; F
\ No newline at end of file