spec/dummy/tmp/cache/assets/development/sprockets/1c55cf24465f311353197ce336df0178 in prosperity-0.0.8 vs spec/dummy/tmp/cache/assets/development/sprockets/1c55cf24465f311353197ce336df0178 in prosperity-0.0.9
- old
+ new
@@ -1,8 +1,8 @@
{I"
class:ETI"BundledAsset; FI"logical_path; TI"prosperity/application.js; TI"
pathname; TI"i/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/application.js.coffee; FI"content_type; TI"application/javascript; TI"
-mtime; Tl+Ò–vSI"length; Ti •I"digest; TI"%b1a3f4f85e8ed65b1f7f5c201c584b80; FI"source; TI" •/*!
+mtime; Tl+!÷‘SI"length; TiÇœI"digest; TI"%14fb42d0ba46cdee2dcd210981087d8b; FI"source; TI"Çœ/*!
* jQuery JavaScript Library v1.11.0
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
@@ -10771,41 +10771,74 @@
}
});
}).call(this);
(function() {
+ $(function() {
+ return $('.destroy-action').click(function(e) {
+ var $hidden, $target, el;
+ e.preventDefault();
+ $target = $(e.target);
+ $hidden = $target.siblings('input[type="hidden"]');
+ $hidden.val('1');
+ el = $target.parents(".deletable-nested-attribute");
+ return el.hide();
+ });
+ });
+
+}).call(this);
+(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 = '%';
}
}
@@ -10849,50 +10882,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')) {
@@ -10919,10 +10982,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++) {
@@ -10959,6 +11023,6 @@
}).render();
});
});
}).call(this);
-; TI"required_assets_digest; TI"%3e4ea6306927fe619a5a66d5a787bf88; FI"
_version; TI"%361c512b9086418778df946c0d278f91; F
+; TI"required_assets_digest; TI"%fa42a19b673279d7e40241b0e306ad43; FI"
_version; TI"%361c512b9086418778df946c0d278f91; F
\ No newline at end of file