You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
6.3 KiB
117 lines
6.3 KiB
/*
|
|
* The PMPinboardView is the controller for the collection of pinned entities in the proactive monitoring visualization
|
|
*/
|
|
|
|
define(['/static/app/DA-ITSI-CP-vmware-dashboards/libs/backbone.js',
|
|
"/static/app/DA-ITSI-CP-vmware-dashboards/swc-vmware-cp/index.js",
|
|
"pm/PMEventDispatcher", "pm/PMPinnedDetailView",
|
|
'/static/app/DA-ITSI-CP-vmware-dashboards/libs/underscore.js'],
|
|
function (Backbone, SWCVMware, dispatcher, PinnedDetailView, _) {
|
|
const mvc = SWCVMware.MVC;
|
|
const SearchManager = SWCVMware.SearchManager;
|
|
const TokenUtils = SWCVMware.MVCTokenUtils;
|
|
var Pinboard = Backbone.View.extend({
|
|
tagName: "div",
|
|
className: "proactive-monitoring-pinboard",
|
|
options: {
|
|
sidebar_width: 300,
|
|
min_total_height: 800
|
|
},
|
|
pinned_manifest: {},
|
|
distribution_search_manifest: {},
|
|
initialize: function () {
|
|
Backbone.View.prototype.initialize.apply(this, arguments);
|
|
dispatcher.on("node:pin", this.pinNode, this);
|
|
},
|
|
/*
|
|
* Render all the things!
|
|
*/
|
|
render: function () {
|
|
this.$el.html('<ul class="proactive-monitoring-pinboard-detail-list"></ul>');
|
|
//TODO: handle concertina or sortablity here
|
|
},
|
|
//
|
|
// PIN LOGIC
|
|
//
|
|
pinNode: function (node) {
|
|
var submitted_tokens = mvc.Components.get('submitted');
|
|
var current_metric = submitted_tokens.get("metric");
|
|
var entitytype = submitted_tokens.get("entity_type");
|
|
var earliest = submitted_tokens.get("earliest");
|
|
var latest = submitted_tokens.get("latest");
|
|
|
|
var distribution_search_id = "leaf-performance-distribution-" + [entitytype, current_metric, earliest, latest].join("-");
|
|
var pin_id = node.id + ":" + current_metric;
|
|
|
|
if (this.pinned_manifest.hasOwnProperty(pin_id)) {
|
|
console.log("[PMPinboard] cancelled pin node since node is already pinned with same metric");
|
|
return;
|
|
}
|
|
|
|
//Create static distribution search
|
|
if (!this.distribution_search_manifest.hasOwnProperty(distribution_search_id)) {
|
|
this.distribution_search_manifest[distribution_search_id] = new SearchManager({
|
|
id: distribution_search_id,
|
|
earliest_time: earliest,
|
|
latest_time: latest,
|
|
preview: false,
|
|
cache: 600,
|
|
status_buckets: 0,
|
|
search: TokenUtils.replaceTokens('| mstats span=1m median(_value) as medianValue perc25(_value) as perc25Value ' +
|
|
'perc75(_value) as perc75Value perc95(_value) as perc95Value min(_value) as minValue ' +
|
|
'where metric_name=vsphere.$metric_entity$.$perf_type$.$metric_type$ AND `vmwareperf-metrics-index` AND source="VMPerf:$perf_source$" ' +
|
|
'AND instance="aggregated" AND unit="$unit$" by vmware_metric_aggregation ' +
|
|
'| eval median_$metric_type$_$unit$ =if(vmware_metric_aggregation="$metric_aggregation$",medianValue,NULL) ' +
|
|
'| eval perc25_$metric_type$_$unit$ =if(vmware_metric_aggregation="$metric_aggregation$",perc25Value,NULL) ' +
|
|
'| eval perc75_$metric_type$_$unit$ =if(vmware_metric_aggregation="$metric_aggregation$",perc75Value,NULL) ' +
|
|
'| eval perc95_$metric_type$_$unit$ =if(vmware_metric_aggregation="$metric_aggregation$",perc95Value,NULL) ' +
|
|
'| eval min_$metric_type$_$unit$ =if(vmware_metric_aggregation="$metric_aggregation$",minValue,NULL) ' +
|
|
'| timechart minspan=1m median(median_$metric_type$_$unit$) AS center ' +
|
|
'perc25(perc25_$metric_type$_$unit$) as lower_quartile ' +
|
|
'perc75(perc75_$metric_type$_$unit$) as upper_quartile ' +
|
|
'perc95(perc95_$metric_type$_$unit$) as upper_extreme ' +
|
|
'min(min_$metric_type$_$unit$) as lower_extreme', mvc.Components, {tokenNamespace: "submitted"}),
|
|
time_format: "%s.%Q"
|
|
}, {tokens: false});
|
|
}
|
|
|
|
//Create New Pinned Detail
|
|
var $detail_container = $("<li>").appendTo(".proactive-monitoring-pinboard-detail-list").addClass("pm-pinned-detail-container");
|
|
var pinned_detail = new PinnedDetailView({
|
|
el: $detail_container,
|
|
pinboard_controller: this,
|
|
pin_id: pin_id,
|
|
distribution_search_id: distribution_search_id,
|
|
node: node
|
|
});
|
|
pinned_detail.render();
|
|
|
|
//Add to Pinned Manifest
|
|
this.pinned_manifest[pin_id] = {
|
|
view: pinned_detail,
|
|
metric: current_metric,
|
|
distribution_search_id: distribution_search_id
|
|
};
|
|
|
|
//TODO:Update to sortability here?
|
|
},
|
|
removePin: function (pin_id) {
|
|
if (this.pinned_manifest.hasOwnProperty(pin_id)) {
|
|
//Remove static distribution search if there are no pinned entities that match it
|
|
var distribution_search_id = this.pinned_manifest[pin_id].distribution_search_id;
|
|
if (_.find(this.pinned_manifest, function (pin, id) {
|
|
return (pin.distribution_search_id === distribution_search_id) && (pin_id !== id);
|
|
}) === undefined) {
|
|
var manager = this.distribution_search_manifest[distribution_search_id];
|
|
manager.set("cancelOnUnload", false);
|
|
manager.cancel();
|
|
manager.off();
|
|
mvc.Components.revokeInstance(manager.id);
|
|
}
|
|
delete this.pinned_manifest[pin_id];
|
|
}
|
|
}
|
|
});
|
|
|
|
return Pinboard;
|
|
}); |