2014-05-01 17:15:33 +00:00
|
|
|
Ember.Handlebars.helper('panelBar', function(status) {
|
|
|
|
var highlightClass;
|
|
|
|
|
|
|
|
if (status == "passing") {
|
|
|
|
highlightClass = "bg-green";
|
|
|
|
} else {
|
|
|
|
highlightClass = "bg-orange";
|
|
|
|
}
|
|
|
|
return new Handlebars.SafeString('<div class="panel-bar ' + highlightClass + '"></div>');
|
|
|
|
});
|
2014-06-05 18:28:40 +00:00
|
|
|
|
|
|
|
Ember.Handlebars.helper('listBar', function(status) {
|
|
|
|
var highlightClass;
|
|
|
|
|
|
|
|
if (status == "passing") {
|
|
|
|
highlightClass = "bg-green";
|
|
|
|
} else {
|
|
|
|
highlightClass = "bg-orange";
|
|
|
|
}
|
|
|
|
return new Handlebars.SafeString('<div class="list-bar-horizontal ' + highlightClass + '"></div>');
|
|
|
|
});
|
2014-06-09 18:58:48 +00:00
|
|
|
|
|
|
|
Ember.Handlebars.helper('sessionName', function(session) {
|
2015-02-12 02:51:30 +00:00
|
|
|
var name;
|
|
|
|
|
2014-06-09 18:58:48 +00:00
|
|
|
if (session.Name === "") {
|
2016-11-01 01:16:43 +00:00
|
|
|
name = '<span>' + Handlebars.Utils.escapeExpression(session.ID) + '</span>';
|
2014-06-09 18:58:48 +00:00
|
|
|
} else {
|
2016-11-01 01:16:43 +00:00
|
|
|
name = '<span>' + Handlebars.Utils.escapeExpression(session.Name) + '</span>' + ' <small>' + Handlebars.Utils.escapeExpression(session.ID) + '</small>';
|
2014-06-09 18:58:48 +00:00
|
|
|
}
|
2015-02-12 02:51:30 +00:00
|
|
|
|
|
|
|
return new Handlebars.SafeString(name);
|
|
|
|
});
|
|
|
|
|
|
|
|
Ember.Handlebars.helper('sessionMeta', function(session) {
|
2016-11-01 01:16:43 +00:00
|
|
|
var meta = '<div class="metadata">' + Handlebars.Utils.escapeExpression(session.Behavior) + ' behavior</div>';
|
2015-02-12 02:51:30 +00:00
|
|
|
|
|
|
|
if (session.TTL !== "") {
|
2016-11-01 01:16:43 +00:00
|
|
|
meta = meta + '<div class="metadata">, ' + Handlebars.Utils.escapeExpression(session.TTL) + ' TTL</div>';
|
2015-02-12 02:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return new Handlebars.SafeString(meta);
|
2014-06-09 18:58:48 +00:00
|
|
|
});
|
2014-06-11 20:54:03 +00:00
|
|
|
|
2014-08-22 19:25:10 +00:00
|
|
|
Ember.Handlebars.helper('aclName', function(name, id) {
|
|
|
|
if (name === "") {
|
|
|
|
return id;
|
|
|
|
} else {
|
2016-11-01 01:16:43 +00:00
|
|
|
return new Handlebars.SafeString(Handlebars.Utils.escapeExpression(name) + ' <small class="pull-right no-case">' + Handlebars.Utils.escapeExpression(id) + '</small>');
|
2014-08-22 19:25:10 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Ember.Handlebars.helper('formatRules', function(rules) {
|
|
|
|
if (rules === "") {
|
|
|
|
return "No rules defined";
|
|
|
|
} else {
|
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-09 00:16:05 +00:00
|
|
|
Ember.Handlebars.helper('limit', function(str, limit) {
|
|
|
|
if (str.length > limit)
|
|
|
|
return str.substring(0, limit) + '...';
|
|
|
|
return str;
|
|
|
|
});
|
2014-08-22 19:25:10 +00:00
|
|
|
|
2014-06-11 20:54:03 +00:00
|
|
|
// We need to do this because of our global namespace properties. The
|
|
|
|
// service.Tags
|
|
|
|
Ember.Handlebars.helper('serviceTagMessage', function(tags) {
|
|
|
|
if (tags === null) {
|
|
|
|
return "No tags";
|
|
|
|
}
|
|
|
|
});
|
2014-08-22 23:03:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Sends a new notification to the UI
|
|
|
|
function notify(message, ttl) {
|
|
|
|
if (window.notifications !== undefined && window.notifications.length > 0) {
|
|
|
|
$(window.notifications).each(function(i, v) {
|
|
|
|
v.dismiss();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
var notification = new NotificationFx({
|
|
|
|
message : '<p>'+ message + '</p>',
|
|
|
|
layout : 'growl',
|
|
|
|
effect : 'slide',
|
|
|
|
type : 'notice',
|
|
|
|
ttl: ttl,
|
|
|
|
});
|
|
|
|
|
|
|
|
// show the notification
|
|
|
|
notification.show();
|
|
|
|
|
|
|
|
// Add the notification to the queue to be closed
|
|
|
|
window.notifications = [];
|
|
|
|
window.notifications.push(notification);
|
|
|
|
}
|
2016-05-15 00:44:28 +00:00
|
|
|
|
|
|
|
// Tomography
|
|
|
|
|
2016-05-18 17:05:16 +00:00
|
|
|
// TODO: not sure how to how do to this more Ember.js-y
|
|
|
|
function tomographyMouseOver(el) {
|
|
|
|
var buf = el.getAttribute('data-node') + ' - ' + el.getAttribute('data-distance') + 'ms';
|
2017-08-30 02:30:46 +00:00
|
|
|
var segment = el.getAttribute('data-segment');
|
|
|
|
if (segment !== "") {
|
|
|
|
buf += ' (Segment: ' + segment + ')';
|
|
|
|
}
|
2017-10-16 16:12:36 +00:00
|
|
|
document.getElementById('tomography-node-info').textContent = buf;
|
2017-08-30 02:30:46 +00:00
|
|
|
|
2016-05-18 17:05:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 00:44:28 +00:00
|
|
|
Ember.Handlebars.helper('tomographyGraph', function(tomography, size) {
|
|
|
|
|
|
|
|
// This is ugly, but I'm working around bugs with Handlebars and templating
|
|
|
|
// parts of svgs. Basically things render correctly the first time, but when
|
|
|
|
// stuff is updated for subsequent go arounds the templated parts don't show.
|
|
|
|
// It appears (based on google searches) that the replaced elements aren't
|
|
|
|
// being interpreted as http://www.w3.org/2000/svg. Anyway, this works and
|
|
|
|
// if/when Handlebars fixes the underlying issues all of this can be cleaned
|
|
|
|
// up drastically.
|
|
|
|
|
2016-05-18 17:05:16 +00:00
|
|
|
var max = -999999999;
|
|
|
|
tomography.distances.forEach(function (d, i) {
|
|
|
|
if (d.distance > max) {
|
|
|
|
max = d.distance;
|
|
|
|
}
|
|
|
|
});
|
2016-05-15 00:44:28 +00:00
|
|
|
var insetSize = size / 2 - 8;
|
|
|
|
var buf = '' +
|
|
|
|
' <svg width="' + size + '" height="' + size + '">' +
|
|
|
|
' <g class="tomography" transform="translate(' + (size / 2) + ', ' + (size / 2) + ')">' +
|
|
|
|
' <g>' +
|
|
|
|
' <circle class="background" r="' + insetSize + '"/>' +
|
|
|
|
' <circle class="axis" r="' + (insetSize * 0.25) + '"/>' +
|
|
|
|
' <circle class="axis" r="' + (insetSize * 0.5) + '"/>' +
|
|
|
|
' <circle class="axis" r="' + (insetSize * 0.75) + '"/>' +
|
|
|
|
' <circle class="border" r="' + insetSize + '"/>' +
|
|
|
|
' </g>' +
|
|
|
|
' <g class="lines">';
|
2016-05-18 16:50:30 +00:00
|
|
|
var distances = tomography.distances;
|
2016-05-17 19:57:02 +00:00
|
|
|
var n = distances.length;
|
2016-05-18 16:50:30 +00:00
|
|
|
if (tomography.n > 360) {
|
|
|
|
// We have more nodes than we want to show, take a random sampling to keep
|
|
|
|
// the number around 360.
|
|
|
|
var sampling = 360 / tomography.n;
|
|
|
|
distances = distances.filter(function (_, i) {
|
|
|
|
return i == 0 || i == n - 1 || Math.random() < sampling
|
|
|
|
});
|
|
|
|
// Re-set n to the filtered size
|
|
|
|
n = distances.length;
|
|
|
|
}
|
2016-05-18 17:05:16 +00:00
|
|
|
distances.forEach(function (d, i) {
|
|
|
|
buf += ' <line transform="rotate(' + (i * 360 / n) + ')" y2="' + (-insetSize * (d.distance / max)) + '" ' +
|
2017-10-16 16:12:36 +00:00
|
|
|
'data-node="' + Handlebars.Utils.escapeExpression(d.node) + '" data-distance="' + d.distance + '" data-segment="' + Handlebars.Utils.escapeExpression(d.segment) + '" onmouseover="tomographyMouseOver(this);"/>';
|
2016-05-15 00:44:28 +00:00
|
|
|
});
|
|
|
|
buf += '' +
|
|
|
|
' </g>' +
|
|
|
|
' <g class="labels">' +
|
|
|
|
' <circle class="point" r="5"/>' +
|
|
|
|
' <g class="tick" transform="translate(0, ' + (insetSize * -0.25 ) + ')">' +
|
|
|
|
' <line x2="70"/>' +
|
2016-05-15 13:30:37 +00:00
|
|
|
' <text x="75" y="0" dy=".32em">' + (max > 0 ? (parseInt(max * 25) / 100) : 0) + 'ms</text>' +
|
2016-05-15 00:44:28 +00:00
|
|
|
' </g>' +
|
|
|
|
' <g class="tick" transform="translate(0, ' + (insetSize * -0.5 ) + ')">' +
|
|
|
|
' <line x2="70"/>' +
|
2016-05-15 13:30:37 +00:00
|
|
|
' <text x="75" y="0" dy=".32em">' + (max > 0 ? (parseInt(max * 50) / 100) : 0)+ 'ms</text>' +
|
2016-05-15 00:44:28 +00:00
|
|
|
' </g>' +
|
|
|
|
' <g class="tick" transform="translate(0, ' + (insetSize * -0.75 ) + ')">' +
|
|
|
|
' <line x2="70"/>' +
|
2016-05-15 13:30:37 +00:00
|
|
|
' <text x="75" y="0" dy=".32em">' + (max > 0 ? (parseInt(max * 75) / 100) : 0) + 'ms</text>' +
|
2016-05-15 00:44:28 +00:00
|
|
|
' </g>' +
|
|
|
|
' <g class="tick" transform="translate(0, ' + (insetSize * -1) + ')">' +
|
|
|
|
' <line x2="70"/>' +
|
2016-05-15 13:30:37 +00:00
|
|
|
' <text x="75" y="0" dy=".32em">' + (max > 0 ? (parseInt(max * 100) / 100) : 0) + 'ms</text>' +
|
2016-05-15 00:44:28 +00:00
|
|
|
' </g>' +
|
|
|
|
' </g>' +
|
|
|
|
' </g>' +
|
|
|
|
' </svg>';
|
|
|
|
|
|
|
|
return new Handlebars.SafeString(buf);
|
|
|
|
});
|