|
@@ -27,35 +27,61 @@ App.SliderAppSummaryView = Ember.View.extend({
|
|
* [
|
|
* [
|
|
* {
|
|
* {
|
|
* id: string,
|
|
* id: string,
|
|
|
|
+ * dataExists: bool,
|
|
|
|
+ * metricName: string,
|
|
* view: App.AppMetricView
|
|
* view: App.AppMetricView
|
|
* },
|
|
* },
|
|
* {
|
|
* {
|
|
* id: string,
|
|
* id: string,
|
|
|
|
+ * dataExists: bool,
|
|
|
|
+ * metricName: string,
|
|
* view: App.AppMetricView
|
|
* view: App.AppMetricView
|
|
* },
|
|
* },
|
|
* ....
|
|
* ....
|
|
* ]
|
|
* ]
|
|
* </code>
|
|
* </code>
|
|
- * @type {{object}[][]}
|
|
|
|
|
|
+ * @type {{object}[]}
|
|
*/
|
|
*/
|
|
graphs: [],
|
|
graphs: [],
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Determine if at least one graph contains some data to show
|
|
|
|
+ * @type {bool}
|
|
|
|
+ */
|
|
|
|
+ graphsNotEmpty: function () {
|
|
|
|
+ return this.get('graphs').isAny('dataExists', true);
|
|
|
|
+ }.property('graphs.@each.dataExists'),
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Ganglia url
|
|
|
|
+ * If <code>model.quickLinks</code> has `app.ganglia` element, it's used
|
|
|
|
+ * Otherwise - <code>App.gangliaHost</code> is used
|
|
|
|
+ * @type {string}
|
|
|
|
+ */
|
|
|
|
+ gangliaUrl: function () {
|
|
|
|
+ var g = this.get('controller.model.quickLinks').findBy('label', 'app.ganglia');
|
|
|
|
+ if (g) {
|
|
|
|
+ return g.get('url');
|
|
|
|
+ }
|
|
|
|
+ return 'http://' + App.get('gangliaHost') + '/ganglia';
|
|
|
|
+ }.property('App.gangliaHost', 'controller.model.quickLinks.@each.url'),
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Update <code>graphs</code>-list when <code>model</code> is updated
|
|
* Update <code>graphs</code>-list when <code>model</code> is updated
|
|
* New metrics are pushed to <code>graphs</code> (not set new list to <code>graphs</code>!) to prevent page flickering
|
|
* New metrics are pushed to <code>graphs</code> (not set new list to <code>graphs</code>!) to prevent page flickering
|
|
* @method updateGraphs
|
|
* @method updateGraphs
|
|
*/
|
|
*/
|
|
- updateGraphs: function() {
|
|
|
|
|
|
+ updateGraphs: function () {
|
|
var model = this.get('controller.model'),
|
|
var model = this.get('controller.model'),
|
|
existingGraphs = this.get('graphs'),
|
|
existingGraphs = this.get('graphs'),
|
|
graphsBeenChanged = false;
|
|
graphsBeenChanged = false;
|
|
|
|
|
|
if (model) {
|
|
if (model) {
|
|
- var currentGraphIds = [];
|
|
|
|
- var supportedMetrics = model.get('supportedMetricNames');
|
|
|
|
|
|
+ var currentGraphIds = [],
|
|
|
|
+ supportedMetrics = model.get('supportedMetricNames');
|
|
if (supportedMetrics) {
|
|
if (supportedMetrics) {
|
|
var appId = model.get('id');
|
|
var appId = model.get('id');
|
|
- supportedMetrics.split(',').forEach(function(metricName) {
|
|
|
|
|
|
+ supportedMetrics.split(',').forEach(function (metricName) {
|
|
var graphId = metricName + '_' + appId;
|
|
var graphId = metricName + '_' + appId;
|
|
currentGraphIds.push(graphId);
|
|
currentGraphIds.push(graphId);
|
|
if (!existingGraphs.isAny('id', graphId)) {
|
|
if (!existingGraphs.isAny('id', graphId)) {
|
|
@@ -64,17 +90,19 @@ App.SliderAppSummaryView = Ember.View.extend({
|
|
app: model,
|
|
app: model,
|
|
metricName: metricName
|
|
metricName: metricName
|
|
});
|
|
});
|
|
- existingGraphs.push({
|
|
|
|
- id : graphId,
|
|
|
|
- view : view
|
|
|
|
- });
|
|
|
|
|
|
+ existingGraphs.push(Em.Object.create({
|
|
|
|
+ id: graphId,
|
|
|
|
+ view: view,
|
|
|
|
+ dataExists: false,
|
|
|
|
+ metricName: metricName
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
// Delete not existed graphs
|
|
// Delete not existed graphs
|
|
- existingGraphs = existingGraphs.filter(function(existingGraph) {
|
|
|
|
- graphsBeenChanged = graphsBeenChanged || !currentGraphIds.contains(existingGraph.id);
|
|
|
|
- return currentGraphIds.contains(existingGraph.id);
|
|
|
|
|
|
+ existingGraphs = existingGraphs.filter(function (existingGraph) {
|
|
|
|
+ graphsBeenChanged = graphsBeenChanged || !currentGraphIds.contains(existingGraph.get('id'));
|
|
|
|
+ return currentGraphIds.contains(existingGraph.get('id'));
|
|
});
|
|
});
|
|
if (graphsBeenChanged) {
|
|
if (graphsBeenChanged) {
|
|
this.set('graphs', existingGraphs);
|
|
this.set('graphs', existingGraphs);
|
|
@@ -82,23 +110,9 @@ App.SliderAppSummaryView = Ember.View.extend({
|
|
}
|
|
}
|
|
}.observes('controller.model.supportedMetricNames'),
|
|
}.observes('controller.model.supportedMetricNames'),
|
|
|
|
|
|
- /**
|
|
|
|
- * Ganglia url
|
|
|
|
- * If <code>model.quickLinks</code> has `app.ganglia` element, it's used
|
|
|
|
- * Otherwise - <code>App.gangliaHost</code> is used
|
|
|
|
- * @type {string}
|
|
|
|
- */
|
|
|
|
- gangliaUrl: function () {
|
|
|
|
- var g = this.get('controller.model.quickLinks').findBy('label', 'app.ganglia');
|
|
|
|
- if (g) {
|
|
|
|
- return g.get('url');
|
|
|
|
- }
|
|
|
|
- return 'http://' + App.get('gangliaHost') + '/ganglia';
|
|
|
|
- }.property('App.gangliaHost', 'controller.model.quickLinks.@each.url'),
|
|
|
|
-
|
|
|
|
- didInsertElement: function() {
|
|
|
|
|
|
+ didInsertElement: function () {
|
|
var self = this;
|
|
var self = this;
|
|
- Em.run.next(function() {
|
|
|
|
|
|
+ Em.run.next(function () {
|
|
self.fitPanels();
|
|
self.fitPanels();
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -109,10 +123,10 @@ App.SliderAppSummaryView = Ember.View.extend({
|
|
*/
|
|
*/
|
|
fitPanels: function () {
|
|
fitPanels: function () {
|
|
var panelSummary = this.$('.panel-summary'),
|
|
var panelSummary = this.$('.panel-summary'),
|
|
- panelSummaryBody = panelSummary.find('.panel-body'),
|
|
|
|
- columnRight = this.$('.column-right'),
|
|
|
|
- panelAlerts = columnRight.find('.panel-alerts'),
|
|
|
|
- panelComponents = columnRight.find('.panel-components');
|
|
|
|
|
|
+ panelSummaryBody = panelSummary.find('.panel-body'),
|
|
|
|
+ columnRight = this.$('.column-right'),
|
|
|
|
+ panelAlerts = columnRight.find('.panel-alerts'),
|
|
|
|
+ panelComponents = columnRight.find('.panel-components');
|
|
if (panelSummary.height() < panelSummaryBody.height()) {
|
|
if (panelSummary.height() < panelSummaryBody.height()) {
|
|
panelSummary.height(panelSummaryBody.height());
|
|
panelSummary.height(panelSummaryBody.height());
|
|
}
|
|
}
|