YARN-5866. Fix few issues reported by jshint in new YARN UI. Contributed by Akhil P B.

This commit is contained in:
Sunil G 2017-01-31 14:18:31 +05:30
parent 87852b6ef4
commit 4c6bae5a22
71 changed files with 313 additions and 356 deletions

View File

@ -2,7 +2,10 @@
"predef": [
"document",
"window",
"-Promise"
"-Promise",
"d3",
"$",
"moment"
],
"browser": true,
"boss": true,

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import Ember from 'ember';
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
address: null, //Must be set by inheriting classes

View File

@ -24,7 +24,7 @@ export default AbstractAdapter.extend({
serverName: "RM",
// Any cluster-info specific adapter changes must be added here
pathForType(modelName) {
pathForType(/*modelName*/) {
return ''; // move to some common place, return path by modelname.
},
}
});

View File

@ -24,7 +24,7 @@ export default AbstractAdapter.extend({
serverName: "RM",
// Any cluster-metric specific adapter changes must be added here
pathForType(modelName) {
pathForType(/*modelName*/) {
return ''; // move to some common place, return path by modelname.
},
}
});

View File

@ -24,12 +24,12 @@ export default AbstractAdapter.extend({
restNameSpace: "cluster",
serverName: "RM",
urlForQuery(query, modelName) {
urlForQuery(query/*, modelName*/) {
var url = this._buildURL();
return url + '/apps/' + query.appId + "/appattempts";
},
urlForFindRecord(id, modelName, snapshot) {
urlForFindRecord(id/*, modelName, snapshot*/) {
var url = this._buildURL();
return url + '/apps/' +
Converter.attemptIdToAppId(id) + "/appattempts/" + id;

View File

@ -23,7 +23,7 @@ export default AbstractAdapter.extend({
restNameSpace: "cluster",
serverName: "RM",
urlForQuery(query, modelName) {
urlForQuery(query/*, modelName*/) {
var url = this._buildURL();
if (query.state) {
url = url + '/apps/?state=' + query.state;
@ -31,13 +31,13 @@ export default AbstractAdapter.extend({
return url;
},
urlForFindRecord(id, modelName, snapshot) {
urlForFindRecord(id/*, modelName, snapshot*/) {
var url = this._buildURL();
url = url + '/apps/' + id;
return url;
},
pathForType(modelName) {
pathForType(/*modelName*/) {
return 'apps'; // move to some common place, return path by modelname.
},
});

View File

@ -37,7 +37,7 @@ export default DS.RESTAdapter.extend({
return this.get(`env.app.namespaces.node`);
}),
urlForFindRecord(id, modelName, snapshot) {
urlForFindRecord(id/*, modelName, snapshot*/) {
var splits = Converter.splitForContainerLogs(id);
var nodeHttpAddr = splits[0];
var containerId = splits[1];
@ -68,7 +68,7 @@ export default DS.RESTAdapter.extend({
hash.context = this;
var headers = Ember.get(this, 'headers');
if (headers != undefined) {
if (headers !== undefined) {
hash.beforeSend = function (xhr) {
Object.keys(headers).forEach(function (key) {
return xhr.setRequestHeader(key, headers[key]);

View File

@ -25,14 +25,14 @@ export default DS.JSONAPIAdapter.extend({
},
host: function() {
return undefined
return undefined;
}.property(),
namespace: function() {
return undefined
return undefined;
}.property(),
urlForQuery(query, modelName) {
urlForQuery(query/*, modelName*/) {
var rmHosts = this.get(`hosts.rmWebAddress`);
var tsHosts = this.get(`hosts.timelineWebAddress`);
var rmNamespaces = this.get(`env.app.namespaces.cluster`);
@ -47,8 +47,8 @@ export default DS.JSONAPIAdapter.extend({
}
var url = this._buildURL();
url = url + '/apps/' + Converter.attemptIdToAppId(query.app_attempt_id)
+ "/appattempts/" + query.app_attempt_id + "/containers";
url = url + '/apps/' + Converter.attemptIdToAppId(query.app_attempt_id) +
"/appattempts/" + query.app_attempt_id + "/containers";
console.log(url);
return url;
},
@ -58,6 +58,6 @@ export default DS.JSONAPIAdapter.extend({
hash.crossDomain = true;
hash.xhrFields = {withCredentials: true};
hash.targetServer = "RM";
return this._super(url, method, hash);
return this._super(url, method, hash);
}
});

View File

@ -24,10 +24,10 @@ export default AbstractAdapter.extend({
restNameSpace: "node",
serverName: "NM",
urlForFindRecord(id, modelName, snapshot) {
urlForFindRecord(id/*, modelName, snapshot*/) {
var url = this._buildURL();
url = url.replace("{nodeAddress}", id);
return url;
},
}
});

View File

@ -23,8 +23,8 @@ export default AbstractAdapter.extend({
restNameSpace: "cluster",
serverName: "RM",
pathForType(modelName) {
pathForType(/*modelName*/) {
return 'scheduler'; // move to some common place, return path by modelname.
},
}
});

View File

@ -23,14 +23,14 @@ export default AbstractAdapter.extend({
restNameSpace: "cluster",
serverName: "RM",
pathForType(modelName) {
pathForType(/*modelName*/) {
return 'nodes';
},
urlForFindRecord(id, modelName, snapshot) {
urlForFindRecord(id/*, modelName, snapshot*/) {
var url = this._buildURL();
url = url + "/nodes/" + id;
return url;
},
}
});

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import Ember from 'ember';
import DonutChart from 'yarn-ui/components/donut-chart';
import BaseUsageDonutChart from 'yarn-ui/components/base-usage-donut-chart';
import ColorUtils from 'yarn-ui/utils/color-utils';
import HrefAddressUtils from 'yarn-ui/utils/href-address-utils';
@ -52,11 +50,11 @@ export default BaseUsageDonutChart.extend({
usageByApps.push({
label: "Available",
value: avail.toFixed(4)
})
});
this.colors = ColorUtils.getColors(usageByApps.length, ["others", "good"], true);
this.renderDonutChart(usageByApps, this.get("title"), this.get("showLabels"),
this.get("middleLabel"), "100%", "%");
},
})
});

View File

@ -55,17 +55,15 @@ export default BaseChartComponent.extend({
.domain([0, maxValue])
.range([0, maxBarWidth]);
var getBarText = function(i) {
return data[i].label;
};
// show bar text
for (var i = 0; i < data.length; i++) {
for (i = 0; i < data.length; i++) {
g.append("text")
.text(
function() {
return data[i].label;
})
.attr("y", function() {
return layout.y1 + singleBarHeight / 2 + layout.margin + (gap +
singleBarHeight) * i + 30;
})
.text(getBarText(i))
.attr("y", layout.y1 + singleBarHeight / 2 + layout.margin +
(gap + singleBarHeight) * i + 30)
.attr("x", layout.x1 + layout.margin);
}
@ -96,17 +94,15 @@ export default BaseChartComponent.extend({
return w;
});
var getBarValue = function(i) {
return data[i].value;
};
// show bar value
for (var i = 0; i < data.length; i++) {
for (i = 0; i < data.length; i++) {
g.append("text")
.text(
function() {
return data[i].value;
})
.attr("y", function() {
return layout.y1 + singleBarHeight / 2 + layout.margin + (gap +
singleBarHeight) * i + 30;
})
.text(getBarValue(i))
.attr("y", layout.y1 + singleBarHeight / 2 + layout.margin +
(gap + singleBarHeight) * i + 30)
.attr("x", layout.x1 + layout.margin + textWidth + 15 + xScaler(data[i].value));
}
},
@ -123,5 +119,5 @@ export default BaseChartComponent.extend({
didInsertElement: function() {
this.initChart();
this.draw();
},
})
}
});

View File

@ -96,7 +96,7 @@ export default Ember.Component.extend({
},
bindTooltip: function(d) {
d.on("mouseover", function(d) {
d.on("mouseover", function() {
this.tooltip
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
@ -108,16 +108,16 @@ export default Ember.Component.extend({
data = d.data;
}
this.tooltip.style("opacity", .9);
this.tooltip.style("opacity", 0.9);
var value = data.value;
if (this.get("type") == "memory") {
if (this.get("type") === "memory") {
value = Converter.memoryToSimpliedUnit(value);
}
this.tooltip.html(data.label + " = " + value)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
}.bind(this))
.on("mouseout", function(d) {
.on("mouseout", function() {
this.tooltip.style("opacity", 0);
}.bind(this));
},

View File

@ -16,7 +16,6 @@
* limitations under the License.
*/
import Ember from 'ember';
import DonutChart from 'yarn-ui/components/donut-chart';
export default DonutChart.extend({
@ -29,15 +28,15 @@ export default DonutChart.extend({
var others = {
label: "Used by others",
value: 0
}
};
for (var i = nItemsKept; i < usages.length; i++) {
for (i = nItemsKept; i < usages.length; i++) {
others.value += Number(usages[i].value);
}
others.value = others.value.toFixed(2);
arr.push(others)
arr.push(others);
return arr;
},
})
}
});

View File

@ -41,7 +41,7 @@ export default BaseChartComponent.extend({
}
if (!middleValue) {
if (this.get("type") == "memory") {
if (this.get("type") === "memory") {
middleValue = Converter.memoryToSimpliedUnit(total);
} else {
middleValue = total;
@ -111,7 +111,7 @@ export default BaseChartComponent.extend({
if (allZero) {
return this.colors[i];
}
}.bind(this))
}.bind(this));
this.bindTooltip(path);
path.on("click", function (d) {
var data = d.data;
@ -119,7 +119,7 @@ export default BaseChartComponent.extend({
this.tooltip.remove();
document.location.href = data.link;
}
}.bind(this))
}.bind(this));
// Show labels
if (showLabels) {
@ -147,7 +147,7 @@ export default BaseChartComponent.extend({
})
.text(function(d) {
var value = d.value;
if (this.get("type") == "memory") {
if (this.get("type") === "memory") {
value = Converter.memoryToSimpliedUnit(value);
}
return d.label + ' = ' + value + suffix;
@ -190,4 +190,4 @@ export default BaseChartComponent.extend({
this.initChart();
this.draw();
},
})
});

View File

@ -17,7 +17,6 @@
*/
import BaseChartComponent from 'yarn-ui/components/base-chart-component';
import Mock from 'yarn-ui/utils/mock';
export default BaseChartComponent.extend({
CELL_WIDTH: 250,
@ -39,7 +38,7 @@ export default BaseChartComponent.extend({
// Handle pie chart case
var text = element.attr("tooltiptext");
this.tooltip.style("opacity", .9);
this.tooltip.style("opacity", 0.9);
this.tooltip.html(text)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
@ -82,10 +81,10 @@ export default BaseChartComponent.extend({
2 * this.CELL_MARGIN;
var sampleYOffset = layout.margin * 2;
for (var i = 1; i <= 5; i++) {
for (i = 1; i <= 5; i++) {
var ratio = i * 0.2 - 0.1;
var rect = g.append("rect")
g.append("rect")
.attr("x", sampleXOffset)
.attr("y", sampleYOffset)
.attr("fill", colorFunc(ratio))
@ -101,14 +100,14 @@ export default BaseChartComponent.extend({
var chartXOffset = -1;
for (var i = 0; i < racksArray.length; i++) {
for (i = 0; i < racksArray.length; i++) {
var text = g.append("text")
.text(racksArray[i])
.attr("y", yOffset + this.CELL_HEIGHT / 2 + 5)
.attr("x", layout.margin)
.attr("class", "heatmap-rack");
if (-1 == chartXOffset) {
if (-1 === chartXOffset) {
chartXOffset = layout.margin + text.node().getComputedTextLength() + 30;
}
@ -118,10 +117,10 @@ export default BaseChartComponent.extend({
var rack = data[j].get("rack");
var host = data[j].get("nodeHostName");
if (rack == racksArray[i]) {
if (rack === racksArray[i]) {
if (!rack.includes(this.filter) && !host.includes(this.filter)) {
this.addNode(g, xOffset, yOffset, colorFunc, data[j], false);
var text = g.append("text")
g.append("text")
.text(host)
.attr("y", yOffset + this.CELL_HEIGHT / 2 + 5)
.attr("x", xOffset + this.CELL_WIDTH / 2)
@ -151,7 +150,7 @@ export default BaseChartComponent.extend({
xOffset += this.CELL_MARGIN + this.CELL_WIDTH;
}
if (xOffset != chartXOffset) {
if (xOffset !== chartXOffset) {
xOffset = chartXOffset;
yOffset += this.CELL_MARGIN + this.CELL_HEIGHT;
}
@ -182,7 +181,7 @@ export default BaseChartComponent.extend({
},
addPlaceholderNode: function(g, xOffset, yOffset) {
var rect = g.append("rect")
g.append("rect")
.attr("y", yOffset)
.attr("x", xOffset)
.attr("height", this.CELL_HEIGHT)
@ -206,4 +205,4 @@ export default BaseChartComponent.extend({
this.didInsertElement();
}
}
})
});

View File

@ -28,7 +28,7 @@ export default StackedBarchart.extend({
{
used: Number(n.get("usedMemoryMB")),
avail: Number(n.get("availMemoryMB"))
}
};
});
containers.forEach(function(c) {
@ -85,4 +85,4 @@ export default StackedBarchart.extend({
data, this.get("title"), ["Used by this app", "Used by other apps",
"Available"]);
},
})
});

View File

@ -29,7 +29,7 @@ export default StackedBarchart.extend({
containers.forEach(function(c) {
var nodeId = c.get("assignedNodeId");
var n = nodeToContainers[nodeId];
if (undefined != n) {
if (undefined !== n) {
nodeToContainers[nodeId] += 1;
}
});
@ -64,4 +64,4 @@ export default StackedBarchart.extend({
this.show(
data, this.get("title"), ["Running containers from this app"]);
},
})
});

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import Ember from 'ember';
import DonutChart from 'yarn-ui/components/donut-chart';
import BaseUsageDonutChart from 'yarn-ui/components/base-usage-donut-chart';
import ColorUtils from 'yarn-ui/utils/color-utils';
import HrefAddressUtils from 'yarn-ui/utils/href-address-utils';
@ -66,4 +64,4 @@ export default BaseUsageDonutChart.extend({
this.initChart();
this.draw();
},
})
});

View File

@ -92,7 +92,7 @@ export default Ember.Component.extend(ChartUtilsMixin, {
circle.on('mouseover', function () {
}.bind(this));
circle.on('mouseout', function () {
if (circle != this.queues.selectedQueueCircle) {
if (circle !== this.queues.selectedQueueCircle) {
circle.style("fill", this.queueColors[0]);
}
}.bind(this));
@ -143,7 +143,6 @@ export default Ember.Component.extend(ChartUtilsMixin, {
// render queues
this.queues.dataGroup = this.canvas.svg.append("g")
.attr("id", "queues-g");
var rootQueue = undefined;
if (this.queues.data) {
this.renderQueue(this.queues.data['root'], 0, 0);
@ -185,7 +184,7 @@ export default Ember.Component.extend(ChartUtilsMixin, {
/*
* data = [{label="xx", value=},{...}]
*/
renderTable: function (data, title, layout) {
renderTable: function (data) {
d3.select("#main-svg")
.append('table')
.selectAll('tr')
@ -254,7 +253,7 @@ export default Ember.Component.extend(ChartUtilsMixin, {
for (var queueName in this.queues.data) {
var q = this.queues.data[queueName];
if ((!q.get("children")) || q.get("children")
.length == 0) {
.length === 0) {
// it's a leafqueue
leafQueueUsedCaps.push({
label: q.get("name"),
@ -274,10 +273,10 @@ export default Ember.Component.extend(ChartUtilsMixin, {
var queue = this.queues.data[queueName];
var idx = 0;
if (queue.get("name") == "root") {
if (queue.get("name") === "root") {
this.renderLeafQueueUsedCapacities(this.getLayout(idx++));
}
if (queue.get("name") != "root") {
if (queue.get("name") !== "root") {
this.renderQueueCapacities(queue, this.getLayout(idx++));
}
if (queue.get("children") && queue.get("children")

View File

@ -48,11 +48,11 @@ export default Ember.Component.extend({
var cols = this.get("colsOrder").split(' ');
for (i = 0; i < cols.length; i++) {
var col = cols[i].split(',');
if (col.length != 2) {
if (col.length !== 2) {
continue;
}
var order = col[1].trim();
if (order != 'asc' && order != 'desc') {
if (order !== 'asc' && order !== 'desc') {
continue;
}
var colOrder = [];
@ -61,7 +61,7 @@ export default Ember.Component.extend({
orderArr.push(colOrder);
}
}
if (orderArr.length == 0) {
if (orderArr.length === 0) {
var defaultOrder = [0, 'asc'];
orderArr.push(defaultOrder);
}

View File

@ -17,7 +17,6 @@
*/
import BaseChartComponent from 'yarn-ui/components/base-chart-component';
import Mock from 'yarn-ui/utils/mock';
export default BaseChartComponent.extend({
MAX_BAR_HEIGHT: 120,
@ -37,7 +36,7 @@ export default BaseChartComponent.extend({
// Handle pie chart case
var text = element.attr("tooltiptext");
this.tooltip.style("opacity", .9);
this.tooltip.style("opacity", 0.9);
this.tooltip.html(text)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
@ -99,9 +98,13 @@ export default BaseChartComponent.extend({
var maxValue = 0;
var maxN = 0;
for (var i = 0; i < data.length; i++) {
var i = 0;
var j = 0;
for (i = 0; i < data.length; i++) {
var total = 0;
for (var j = 0; j < data[i].length; j++) {
for (j = 0; j < data[i].length; j++) {
total += data[i][j].value;
}
@ -121,14 +124,14 @@ export default BaseChartComponent.extend({
return b[0].value - a[0].value;
});
for (var i = 0; i < data.length; i++) {
if (i % nBarPerRow == 0) {
for (i = 0; i < data.length; i++) {
if (i % nBarPerRow === 0) {
xOffset = layout.margin;
yOffset += layout.margin + height;
}
var leftTopY = yOffset;
for (var j = 0; j < data[i].length; j++) {
for (j = 0; j < data[i].length; j++) {
var dy = data[i][j].value * height / maxValue;
if (dy > 0) {
leftTopY = leftTopY - dy;
@ -148,7 +151,7 @@ export default BaseChartComponent.extend({
}
}
if (data[i].length == 1) {
if (data[i].length === 1) {
g.append("text")
.text(data[i][0].value)
.attr("y", leftTopY - 10)
@ -165,7 +168,7 @@ export default BaseChartComponent.extend({
this.renderTitleAndBG(g, title, layout, false);
},
draw: function(data, title, textWidth) {
draw: function() {
this.initChart(true);
//Mock.initMockNodesData(this);
@ -195,4 +198,4 @@ export default BaseChartComponent.extend({
this.didInsertElement();
}
}
})
});

View File

@ -41,13 +41,15 @@ export default Ember.Component.extend({
}.property(),
setSelected: function(d) {
if (this._selected == d) {
var dom;
if (this._selected === d) {
return;
}
// restore color
if (this._selected) {
var dom = d3.select("#timeline-bar-" + this._selected.get("id"));
dom = d3.select("#timeline-bar-" + this._selected.get("id"));
dom.attr("fill", this.colors[0]);
}
@ -164,19 +166,19 @@ export default Ember.Component.extend({
.attr("y", function(d, i) {
return border + (gap + singleBarHeight) * i;
})
.attr("x", function(d, i) {
.attr("x", function(d) {
return border + textWidth + xScaler(d.get("startTs"));
})
.attr("height", singleBarHeight)
.attr("fill", function(d, i) {
.attr("fill", function() {
return this.colors[0];
}.bind(this))
.attr("width", function(d, i) {
.attr("width", function(d) {
var finishedTs = xScaler(d.get("finishedTs"));
finishedTs = finishedTs > 0 ? finishedTs : xScaler(end);
return finishedTs - xScaler(d.get("startTs"));
})
.attr("id", function(d, i) {
.attr("id", function(d) {
return "timeline-bar-" + d.get("id");
});
bar.on("click", function(d) {
@ -198,18 +200,18 @@ export default Ember.Component.extend({
},
bindTooltip: function(d) {
d.on("mouseover", function(d) {
d.on("mouseover", function() {
this.tooltip
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
}.bind(this))
.on("mousemove", function(d) {
this.tooltip.style("opacity", .9);
this.tooltip.style("opacity", 0.9);
this.tooltip.html(d.get("tooltipLabel"))
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
}.bind(this))
.on("mouseout", function(d) {
.on("mouseout", function() {
this.tooltip.style("opacity", 0);
}.bind(this));
},
@ -244,7 +246,7 @@ export default Ember.Component.extend({
}.bind(this));
}
if(this.modelArr.length == 0) {
if(this.modelArr.length === 0) {
return;
}
@ -254,8 +256,9 @@ export default Ember.Component.extend({
return tsA - tsB;
});
var begin = 0;
if (this.modelArr.length > 0) {
var begin = this.modelArr[0].get("startTs");
begin = this.modelArr[0].get("startTs");
}
var end = 0;
for (var i = 0; i < this.modelArr.length; i++) {

View File

@ -51,7 +51,7 @@ export default Ember.Component.extend({
this.map[o.id] = o;
}.bind(this));
var selected = this.get("selected");
// var selected = this.get("selected");
this.initQueue("root", 1, this.treeData);
},
@ -125,9 +125,9 @@ export default Ember.Component.extend({
// Enter any new nodes at the parent's previous position.
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("mouseover", function(d,i){
if (d.queueData.get("name") != this.get("selected")) {
.attr("transform", function() { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("mouseover", function(d){
if (d.queueData.get("name") !== this.get("selected")) {
document.location.href = "#/yarn-queues/" + d.queueData.get("name");
}
@ -161,10 +161,10 @@ export default Ember.Component.extend({
// append percentage
nodeEnter.append("text")
.attr("x", function(d) { return 0; })
.attr("x", function() { return 0; })
.attr("dy", ".35em")
.attr("fill", "white")
.attr("text-anchor", function(d) { return "middle"; })
.attr("text-anchor", function() { return "middle"; })
.text(function(d) {
var usedCap = d.queueData.get("usedCapacity");
if (usedCap >= 100.0) {
@ -195,14 +195,14 @@ export default Ember.Component.extend({
return "#/yarn-queues/" + d.queueData.get("name");
})
.style("stroke-width", function(d) {
if (d.queueData.get("name") == this.get("selected")) {
if (d.queueData.get("name") === this.get("selected")) {
return 7;
} else {
return 2;
}
}.bind(this))
.style("stroke", function(d) {
if (d.queueData.get("name") == this.get("selected")) {
if (d.queueData.get("name") === this.get("selected")) {
return "gray";
} else {
return "gray";
@ -215,7 +215,7 @@ export default Ember.Component.extend({
// Transition exiting nodes to the parent's new position.
var nodeExit = node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.attr("transform", function() { return "translate(" + source.y + "," + source.x + ")"; })
.remove();
nodeExit.select("circle")
@ -231,9 +231,9 @@ export default Ember.Component.extend({
// Enter any new links at the parent's previous position.
link.enter().insert("path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
.attr("d", function() {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
});
// Transition links to their new position.
@ -244,9 +244,9 @@ export default Ember.Component.extend({
// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
.attr("d", function() {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
})
.remove();
@ -265,7 +265,6 @@ export default Ember.Component.extend({
var treeHeight = this.numOfLeafQueue * INBETWEEN_HEIGHT;
var width = treeWidth + margin.left + margin.right;
var height = treeHeight + margin.top + margin.bottom;
var layout = { };
if (this.mainSvg) {
this.mainSvg.remove();
@ -287,7 +286,7 @@ export default Ember.Component.extend({
root.x0 = height / 2;
root.y0 = 0;
d3.select(self.frameElement).style("height", height);
d3.select(window.frameElement).style("height", height);
this.update(root, root, tree, diagonal);
},

View File

@ -29,22 +29,22 @@ export default Ember.Controller.extend({
outputMainMenu: function(){
var path = this.get('currentPath');
var html = '<li';
if (path == 'yarn-queue') {
if (path === 'yarn-queue') {
html = html + ' class="active"';
}
html = html + '><a href="yarn-queue/root">Queues<span class="sr-only">' +
'(current)</span></a></li><li';
if (path.lastIndexOf('yarn-app', 0) == 0) {
if (path.lastIndexOf('yarn-app', 0) === 0) {
html = html + ' class="active"';
}
html = html + '><a href="yarn-apps">Applications<span class="sr-only">' +
'(current)</span></a></li><li';
if (path == 'cluster-overview') {
if (path === 'cluster-overview') {
html = html + ' class="active"';
}
html = html + '><a href="cluster-overview">Cluster Overview<span class=' +
'"sr-only">(current)</span></a></li><li';
if (path.lastIndexOf('yarn-node', 0) == 0) {
if (path.lastIndexOf('yarn-node', 0) === 0) {
html = html + ' class="active"';
}
html = html + '><a href="yarn-nodes">Nodes<span class="sr-only">' +

View File

@ -24,7 +24,7 @@ import Ember from 'ember';
export default Ember.Helper.helper(function(params,hash) {
var num = hash.num;
var den = hash.den;
if (den == 0) {
if (den === 0) {
return 0;
}
return Math.floor(num/den);

View File

@ -27,19 +27,18 @@ export default Ember.Helper.helper(function(params,hash) {
return "";
}
var logFilesLen = logFiles.length;
if (logFilesLen == 0) {
if (logFilesLen === 0) {
return "";
}
var nodeId = hash.nodeId;
var nodeAddr = hash.nodeAddr;
var containerId = hash.containerId;
var html = '<td>';
var logFilesCommaSeparated = "";
for (var i = 0; i < logFilesLen; i++) {
html = html + '<a href="#/yarn-container-log/' + nodeId + '/' +
nodeAddr + '/' + containerId + '/' + logFiles[i] + '">' + logFiles[i] +
'</a>';
if (i != logFilesLen - 1) {
if (i !== logFilesLen - 1) {
html = html + ",";
}
}

View File

@ -26,7 +26,7 @@ export default Ember.Helper.helper(function(params,hash) {
var nodeHTTPAddress = hash.nodeHTTPAddress;
var nodeId = hash.nodeId;
var html = '<td>';
if (nodeState == "SHUTDOWN" || nodeState == "LOST") {
if (nodeState === "SHUTDOWN" || nodeState === "LOST") {
html = html + nodeHTTPAddress;
} else {
html = html + '<a href="#/yarn-node/' + nodeId + "/" + nodeHTTPAddress + '">' +

View File

@ -25,7 +25,7 @@ export default Ember.Helper.helper(function(params,hash) {
// Place a menu within a panel inside col-md-2 container.
var nodeIdSplitAtPort = hash.nodeId;
var portIndex = nodeIdSplitAtPort.indexOf(':');
if (portIndex != -1) {
if (portIndex !== -1) {
nodeIdSplitAtPort = nodeIdSplitAtPort.substring(0, portIndex) +
':&#8203;' + nodeIdSplitAtPort.substring(portIndex + 1);
}
@ -35,7 +35,7 @@ export default Ember.Helper.helper(function(params,hash) {
var len = splitsAlongDots.length;
for (var i = 0; i < len; i++) {
normalizedNodeId = normalizedNodeId + splitsAlongDots[i];
if (i != len - 1) {
if (i !== len - 1) {
normalizedNodeId = normalizedNodeId + '.&#8203;';
}
}
@ -47,17 +47,17 @@ export default Ember.Helper.helper(function(params,hash) {
'<div class="panel-heading"><h4>Node Manager<br>(' + normalizedNodeId + ')</h4></div>'+
'<div class="panel-body"><ul class="nav nav-pills nav-stacked" id="stacked-menu">' +
'<ul class="nav nav-pills nav-stacked collapse in"><li';
if (hash.path == 'yarn-node') {
if (hash.path === 'yarn-node') {
html = html + ' class="active"';
}
html = html + '><a href="#/yarn-node/' + hash.nodeId + '/' + hash.nodeAddr +
'">Node Information</a></li><li';
if (hash.path == 'yarn-node-apps') {
if (hash.path === 'yarn-node-apps') {
html = html + ' class="active"';
}
html = html + '><a href="#/yarn-node-apps/' + hash.nodeId + '/' + hash.nodeAddr +
'">List of Applications</a></li><li';
if (hash.path == 'yarn-node-containers') {
if (hash.path === 'yarn-node-containers') {
html = html + ' class="active"';
}
html = html + '><a href="#/yarn-node-containers/' +hash.nodeId + '/' + hash.nodeAddr +

View File

@ -23,7 +23,7 @@ export function nodeName(params/*, hash*/) {
console.log('nodes-uid', params[0]);
var nodeIdSplitAtPort = params[0];
var portIndex = nodeIdSplitAtPort.indexOf(':');
if (portIndex != -1) {
if (portIndex !== -1) {
nodeIdSplitAtPort = nodeIdSplitAtPort.substring(0, portIndex) +
':&#8203;' + nodeIdSplitAtPort.substring(portIndex + 1);
}
@ -33,7 +33,7 @@ export function nodeName(params/*, hash*/) {
var len = splitsAlongDots.length;
for (var i = 0; i < len; i++) {
normalizedNodeId = normalizedNodeId + splitsAlongDots[i];
if (i != len - 1) {
if (i !== len - 1) {
normalizedNodeId = normalizedNodeId + '.&#8203;';
}
}

View File

@ -16,8 +16,11 @@
* limitations under the License.
*/
/* globals ENV: true */
function getTimeLineURL(parameters) {
import Ember from 'ember';
function getTimeLineURL() {
return '/conf?name=yarn.timeline-service.webapp.address';
}
@ -37,7 +40,6 @@ function updateConfigs(application) {
}
if(!ENV.hosts.timelineWebAddress) {
var result = [];
var timelinehost = "";
$.ajax({
type: 'GET',
@ -54,7 +56,7 @@ function updateConfigs(application) {
Ember.Logger.log("Timeline Address from RM:" + address + ":" + port);
if(address == "0.0.0.0" || address == "localhost") {
if(address === "0.0.0.0" || address === "localhost") {
var updatedAddress = hostname + ":" + port;
/* Timeline v2 is not supporting CORS, so make as default*/

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import Ember from 'ember';
import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
@ -45,8 +46,8 @@ export default DS.Model.extend({
attemptStartedTime: function() {
var startTime = this.get("startTime");
// If startTime variable is not present, get from startedTime
if (startTime == undefined ||
startTime == "Invalid date") {
if (startTime === undefined ||
startTime === "Invalid date") {
startTime = this.get("startedTime");
}
@ -80,7 +81,7 @@ export default DS.Model.extend({
appMasterContainerId: function() {
var id = this.get("containerId");
// If containerId variable is not present, get from amContainerId
if (id == undefined) {
if (id === undefined) {
id = this.get("amContainerId");
}
return id;
@ -89,16 +90,16 @@ export default DS.Model.extend({
IsAmNodeUrl: function() {
var url = this.get("nodeHttpAddress");
// If nodeHttpAddress variable is not present, hardcode it.
if (url == undefined) {
if (url === undefined) {
url = "Not Available";
}
return url != "Not Available";
return url !== "Not Available";
}.property("nodeHttpAddress"),
amNodeId : function() {
var id = this.get("nodeId");
// If nodeId variable is not present, get from host
if (id == undefined) {
if (id === undefined) {
id = this.get("hosts");
}
return id;
@ -107,10 +108,10 @@ export default DS.Model.extend({
IsLinkAvailable: function() {
var url = this.get("logsLink");
// If logsLink variable is not present, hardcode its.
if (url == undefined) {
if (url === undefined) {
url = "Not Available";
}
return url != "Not Available";
return url !== "Not Available";
}.property("logsLink"),
elapsedTime: function() {

View File

@ -54,7 +54,7 @@ export default DS.Model.extend({
applicationExpiryTime: DS.attr('string'),
isFailed: function() {
return this.get('finalStatus') == "FAILED"
return this.get('finalStatus') == "FAILED";
}.property("finalStatus"),
validatedFinishedTs: function() {
@ -91,11 +91,11 @@ export default DS.Model.extend({
var finalStatus = this.get("finalStatus");
var style = "";
if (finalStatus == "KILLED") {
if (finalStatus === "KILLED") {
style = "warning";
} else if (finalStatus == "FAILED") {
} else if (finalStatus === "FAILED") {
style = "danger";
} else if (finalStatus == "SUCCEEDED") {
} else if (finalStatus === "SUCCEEDED") {
style = "success";
} else {
style = "default";

View File

@ -27,16 +27,16 @@ export default DS.Model.extend({
* Indicates no rows were retrieved from backend
*/
isDummyApp: function() {
return this.get('id') == "dummy";
return this.get('id') === "dummy";
}.property("id"),
appStateStyle: function() {
var style = "default";
var appState = this.get("state");
if (appState == "RUNNING" || appState == "FINISHING_CONTAINERS_WAIT" ||
appState == "APPLICATION_RESOURCES_CLEANINGUP") {
if (appState === "RUNNING" || appState === "FINISHING_CONTAINERS_WAIT" ||
appState === "APPLICATION_RESOURCES_CLEANINGUP") {
style = "primary";
} else if (appState == "FINISHED") {
} else if (appState === "FINISHED") {
style = "success";
}
return "label label-" + style;

View File

@ -32,24 +32,24 @@ export default DS.Model.extend({
* Indicates that there was no container retrieved from backend.
*/
isDummyContainer: function() {
return this.get('id') == "dummy";
return this.get('id') === "dummy";
}.property("id"),
containerStateStyle: function() {
var style = "primary";
var containerState = this.get('state');
var containerExitCode = this.get('exitCode');
if (containerState == "DONE") {
if (containerExitCode == "0") {
if (containerState === "DONE") {
if (parseInt(containerExitCode) === 0) {
style = "success";
} else if (containerExitCode != "N/A") {
} else if (containerExitCode !== "N/A") {
style = "danger";
}
}
if (containerState == "EXITED_WITH_SUCCESS") {
if (containerState === "EXITED_WITH_SUCCESS") {
style = "success";
}
if (containerState == "EXITED_WITH_FAILURE") {
if (containerState === "EXITED_WITH_FAILURE") {
style = "danger";
}
return "label label-" + style;

View File

@ -48,17 +48,17 @@ export default DS.Model.extend({
return [
{
label: "Absolute Capacity",
value: this.get("name") == "root" ? 100 : this.get("absCapacity")
value: this.get("name") === "root" ? 100 : this.get("absCapacity")
},
{
label: "Absolute Used",
value: this.get("name") == "root" ? this.get("usedCapacity") : this.get("absUsedCapacity")
value: this.get("name") === "root" ? this.get("usedCapacity") : this.get("absUsedCapacity")
},
{
label: "Absolute Max Capacity",
value: this.get("name") == "root" ? 100 : this.get("absMaxCapacity")
value: this.get("name") === "root" ? 100 : this.get("absMaxCapacity")
}
]
];
}.property("absCapacity", "absUsedCapacity", "absMaxCapacity"),
userUsagesDonutChartData: function() {
@ -68,7 +68,7 @@ export default DS.Model.extend({
data.push({
label: o.get("name"),
value: o.get("usedMemoryMB")
})
});
});
}
@ -89,6 +89,6 @@ export default DS.Model.extend({
label: "Active Apps",
value: this.get("numActiveApplications") || 0
}
]
}.property(),
];
}.property()
});

View File

@ -47,18 +47,18 @@ export default DS.Model.extend({
* Indicates no rows were retrieved from backend
*/
isDummyNode: function() {
return this.get('id') == "dummy";
return this.get('id') === "dummy";
}.property("id"),
nodeStateStyle: function() {
var style = "default";
var nodeState = this.get("state");
if (nodeState == "REBOOTED") {
if (nodeState === "REBOOTED") {
style = "warning";
} else if (nodeState == "UNHEALTHY" || nodeState == "DECOMMISSIONED" ||
nodeState == "LOST" || nodeState == "SHUTDOWN") {
} else if (nodeState === "UNHEALTHY" || nodeState === "DECOMMISSIONED" ||
nodeState === "LOST" || nodeState === "SHUTDOWN") {
style = "danger";
} else if (nodeState == "RUNNING") {
} else if (nodeState === "RUNNING") {
style = "success";
}
return "label label-" + style;

View File

@ -23,4 +23,4 @@ export default DS.Model.extend({
queueName: DS.attr('string'),
usedMemoryMB: DS.attr('number'),
usedVCore: DS.attr('number')
})
});

View File

@ -29,8 +29,7 @@ export default Ember.Route.extend({
error: function (error) {
Ember.Logger.log(error.stack);
if (error && error.errors[0] &&
error.errors[0].status == 404) {
if (error && error.errors[0] && parseInt(error.errors[0].status) === 404) {
this.intermediateTransitionTo('/notfound');
} else {
this.intermediateTransitionTo('/error');

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import Ember from 'ember';
import AbstractRoute from './abstract';
export default AbstractRoute.extend({

View File

@ -25,7 +25,7 @@ export default AbstractRoute.extend({
return Ember.RSVP.hash({
app: this.store.find('yarn-app', param.app_id),
rmContainers: this.store.find('yarn-app', param.app_id).then(function(app) {
rmContainers: this.store.find('yarn-app', param.app_id).then(function() {
return this.store.query('yarn-app-attempt', {appId: param.app_id}).then(function (attempts) {
if (attempts && attempts.get('firstObject')) {
var appAttemptId = attempts.get('firstObject').get('appAttemptId');

View File

@ -49,7 +49,7 @@ export default AbstractRoute.extend({
afterModel(model) {
// Handle errors and redirect if promise is rejected.
if (model.errors && model.errors[0]) {
if (model.errors[0].status == 404) {
if (parseInt(model.errors[0].status) === 404) {
this.replaceWith('/notfound');
} else {
this.replaceWith('/error');

View File

@ -16,6 +16,8 @@
* limitations under the License.
*/
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
this.transitionTo('yarn-queues.root');

View File

@ -20,13 +20,12 @@ import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
internalNormalizeSingleResponse(store, primaryModelClass, payload) {
if (payload.appAttempt) {
payload = payload.appAttempt;
payload = payload.appAttempt;
}
var fixedPayload = {
id: payload.appAttemptId,
type: primaryModelClass.modelName, // yarn-app
@ -48,15 +47,13 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload, id, requestType);
normalizeSingleResponse(store, primaryModelClass, payload/*, id, requestType*/) {
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// return expected is { data: [ {}, {} ] }
var normalizedArrayResponse = {};
@ -65,11 +62,11 @@ export default DS.JSONAPISerializer.extend({
// need some error handling for ex apps or app may not be defined.
normalizedArrayResponse.data = payload.appAttempts.appAttempt.map(singleApp => {
return this.internalNormalizeSingleResponse(store, primaryModelClass,
singleApp, singleApp.id, requestType);
singleApp);
}, this);
} else {
normalizedArrayResponse.data = [];
}
return normalizedArrayResponse;
}
});
});

View File

@ -20,8 +20,7 @@ import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
internalNormalizeSingleResponse(store, primaryModelClass, payload, id) {
if (payload.app) {
payload = payload.app;
}
@ -76,15 +75,13 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload, id, requestType);
primaryModelClass, payload, id);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// return expected is { data: [ {}, {} ] }
var normalizedArrayResponse = {};
@ -93,7 +90,7 @@ export default DS.JSONAPISerializer.extend({
if(payload.apps && payload.apps.app) {
normalizedArrayResponse.data = payload.apps.app.map(singleApp => {
return this.internalNormalizeSingleResponse(store, primaryModelClass,
singleApp, singleApp.id, requestType);
singleApp, singleApp.id);
}, this);
} else {
normalizedArrayResponse.data = [];

View File

@ -20,8 +20,7 @@ import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
// Convert plain text response into JSON.
// ID is of the form nodeAddress!containerId!fileName
var splits = Converter.splitForContainerLogs(id);

View File

@ -20,9 +20,8 @@ import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
internalNormalizeSingleResponse(store, primaryModelClass, payload) {
var fixedPayload = {
id: payload.containerId,
type: primaryModelClass.modelName, // yarn-app
@ -44,15 +43,13 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload, id, requestType);
normalizeSingleResponse(store, primaryModelClass, payload/*, id, requestType*/) {
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// return expected is { data: [ {}, {} ] }
var normalizedArrayResponse = {};
@ -62,12 +59,11 @@ export default DS.JSONAPISerializer.extend({
// need some error handling for ex apps or app may not be defined.
normalizedArrayResponse.data = payload.container.map(singleContainer => {
return this.internalNormalizeSingleResponse(store, primaryModelClass,
singleContainer, singleContainer.id, requestType);
singleContainer);
}, this);
} else {
normalizedArrayResponse.data = [this.internalNormalizeSingleResponse(
store, primaryModelClass, payload.container, payload.container.id,
requestType)];
store, primaryModelClass, payload.container)];
}
return normalizedArrayResponse;
} else {
@ -76,4 +72,4 @@ export default DS.JSONAPISerializer.extend({
return normalizedArrayResponse;
}
});
});

View File

@ -15,26 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DS from 'ember-data';
import Ember from 'ember';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload) {
@ -55,16 +37,14 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// payload is of the form {"app":{}}
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// expected return response is of the form { data: [ {}, {} ] }
var normalizedArrayResponse = {};
// payload is of the form { "apps" : { "app": [ {},{},{} ] } }

View File

@ -17,7 +17,6 @@
*/
import DS from 'ember-data';
import Ember from 'ember';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload) {
@ -42,16 +41,14 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// payload is of the form {"container":{}}
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// expected return response is of the form { data: [ {}, {} ] }
var normalizedArrayResponse = {};
if (payload.containers && payload.containers.container) {

View File

@ -20,8 +20,7 @@ import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
export default DS.JSONAPISerializer.extend({
internalNormalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
internalNormalizeSingleResponse(store, primaryModelClass, payload, id) {
if (payload.nodeInfo) {
payload = payload.nodeInfo;
}
@ -46,11 +45,10 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
// payload is of the form {"nodeInfo":{}}
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload, id, requestType);
primaryModelClass, payload, id);
return { data: p };
},
});

View File

@ -49,7 +49,7 @@ export default DS.JSONAPISerializer.extend({
relationshipUserData.push({
type: "YarnUser",
id: u.username + "_" + payload.queueName,
})
});
});
}
@ -85,12 +85,12 @@ export default DS.JSONAPISerializer.extend({
return {
queue: this._super(store, primaryModelClass, fixedPayload, id, requestType),
includedData: includedData
}
};
},
handleQueue(store, primaryModelClass, payload, id, requestType) {
var data = [];
var includedData = []
var includedData = [];
var result = this.normalizeSingleResponse(store, primaryModelClass,
payload, id, requestType);
@ -112,8 +112,8 @@ export default DS.JSONAPISerializer.extend({
return {
data: data,
includedData, includedData
}
includedData: includedData
};
},
normalizeArrayResponse(store, primaryModelClass, payload, id,

View File

@ -16,7 +16,6 @@
* limitations under the License.
*/
import Ember from 'ember';
import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';
@ -48,16 +47,14 @@ export default DS.JSONAPISerializer.extend({
return fixedPayload;
},
normalizeSingleResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
// payload is of the form {"nodeInfo":{}}
var p = this.internalNormalizeSingleResponse(store,
primaryModelClass, payload, id);
return { data: p };
},
normalizeArrayResponse(store, primaryModelClass, payload, id,
requestType) {
normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) {
// expected response is of the form { data: [ {}, {} ] }
var normalizedArrayResponse = {};
if (payload.nodes) {

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import Constants from 'yarn-ui/constants';
export default {
preDefinedColors : ["#1f77b4", "#aec7e8", "#ffbb78",
"#98df8a", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b",
@ -43,14 +41,14 @@ export default {
startIdx = Math.max(nColors - colorsTarget.length, 0);
}
for (var i = 0; i < colorsTarget.length; i++) {
for (i = 0; i < colorsTarget.length; i++) {
if (i + startIdx < nColors) {
colors[i + startIdx] = this.getColorByTarget(colorsTarget[i]);
}
}
var idx = 0;
for (var i = 0; i < nColors; i++) {
for (i = 0; i < nColors; i++) {
if (!colors[i]) {
colors[i] = this.preDefinedColors[i % this.preDefinedColors.length];
idx ++;

View File

@ -110,7 +110,7 @@ export default {
}
},
memoryToSimpliedUnit: function(mb) {
var unit = "MB"
var unit = "MB";
var value = mb;
if (value / 1024 >= 0.9) {
value = value / 1024;

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import Constants from 'yarn-ui/constants';
export default {
getApplicationLink: function(applicationId) {
return "#/yarn-app/" + applicationId;

View File

@ -32,5 +32,5 @@ export default {
}
ref.set("model", data);
},
}
}
};

View File

@ -51,19 +51,19 @@ export default {
*/
function naturalSort(a, b) {
var diff = a.length - b.length;
if (diff != 0) {
if (diff !== 0) {
var splitA = a.split("_");
var splitB = b.split("_");
if (splitA.length != splitB.length) {
if (splitA.length !== splitB.length) {
return a.localeCompare(b);
}
for (var i = 1; i < splitA.length; i++) {
var splitdiff = splitA[i].length - splitB[i].length;
if (splitdiff != 0) {
if (splitdiff !== 0) {
return splitdiff;
}
var splitCompare = splitA[i].localeCompare(splitB[i]);
if (splitCompare != 0) {
if (splitCompare !== 0) {
return splitCompare;
}
}

View File

@ -22,7 +22,7 @@ var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
hinting: false
hinting: true
});
app.import("bower_components/datatables/media/css/jquery.dataTables.min.css");

View File

@ -17,6 +17,7 @@
*/
import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';
moduleForModel('yarn-container-log', 'Unit | Model | ContainerLog', {
// Specify the other units that are required for this test.

View File

@ -17,6 +17,7 @@
*/
import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';
moduleForModel('yarn-node-app', 'Unit | Model | NodeApp', {
// Specify the other units that are required for this test.

View File

@ -17,6 +17,7 @@
*/
import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';
moduleForModel('yarn-node-container', 'Unit | Model | NodeContainer', {
// Specify the other units that are required for this test.

View File

@ -17,6 +17,7 @@
*/
import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';
moduleForModel('yarn-node', 'Unit | Model | Node', {
// Specify the other units that are required for this test.

View File

@ -17,6 +17,7 @@
*/
import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';
moduleForModel('yarn-rm-node', 'Unit | Model | RMNode', {
// Specify the other units that are required for this test.

View File

@ -17,7 +17,7 @@
*/
import { moduleFor, test } from 'ember-qunit';
import Constants from 'yarn-ui/constants';
import Ember from 'ember';
moduleFor('route:yarn-container-log', 'Unit | Route | ContainerLog', {
});
@ -34,11 +34,11 @@ test('Test getting container log', function(assert) {
containerID: "container_e32_1456000363780_0002_01_000001",
logFileName: "syslog"};
var store = {
findRecord: function(type) {
findRecord: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response);
}
)}
});
}
};
assert.expect(6);
var route = this.subject();
@ -67,11 +67,11 @@ test('Test non HTTP error while getting container log', function(assert) {
containerID: "container_e32_1456000363780_0002_01_000001",
logFileName: "syslog"};
var store = {
findRecord: function(type) {
findRecord: function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
reject(error);
}
)}
});
}
};
assert.expect(6);
var route = this.subject();
@ -92,16 +92,12 @@ test('Test non HTTP error while getting container log', function(assert) {
test('Test HTTP error while getting container log', function(assert) {
var error = {errors: [{status: 404, responseText: 'Not Found'}]};
var response = {
logs: "",
containerID: "container_e32_1456000363780_0002_01_000001",
logFileName: "syslog"};
var store = {
findRecord: function(type) {
findRecord: function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
reject(error);
}
)}
});
}
};
assert.expect(5);
var route = this.subject();

View File

@ -17,6 +17,7 @@
*/
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
moduleFor('route:yarn-node-app', 'Unit | Route | NodeApp', {
});
@ -31,7 +32,7 @@ test('Test getting specific app on a node', function(assert) {
var response =
{id:"application_1456251210105_0001", state:"FINISHED", user:"root"};
var store = {
queryRecord: function(type, query) {
queryRecord: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response);
});
@ -40,17 +41,16 @@ test('Test getting specific app on a node', function(assert) {
assert.expect(6);
var route = this.subject();
route.set('store', store);
var model =
route.model({node_id:"localhost:64318", node_addr:"localhost:8042",
app_id:"application_1456251210105_0001"}).
then(
function(value){
assert.ok(value);
assert.ok(value.nodeApp);
assert.deepEqual(value.nodeApp, response);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
route.model({node_id:"localhost:64318", node_addr:"localhost:8042",
app_id:"application_1456251210105_0001"})
.then(
function(value){
assert.ok(value);
assert.ok(value.nodeApp);
assert.deepEqual(value.nodeApp, response);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
});

View File

@ -17,6 +17,7 @@
*/
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
moduleFor('route:yarn-node-apps', 'Unit | Route | NodeApps', {
});
@ -34,7 +35,7 @@ test('Test getting apps on a node', function(assert) {
containerids:["container_e38_1456251210105_0002_01_000001",
"container_e38_1456251210105_0002_01_000002"]}];
var store = {
query: function(type, query) {
query: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response.slice());
});
@ -43,18 +44,17 @@ test('Test getting apps on a node', function(assert) {
assert.expect(8);
var route = this.subject();
route.set('store', store);
var model =
route.model({node_id:"localhost:64318", node_addr:"localhost:8042"}).
then(
function(value){
assert.ok(value);
assert.ok(value.apps);
assert.equal(value.apps.length, 2);
assert.deepEqual(response[0], value.apps[0]);
assert.deepEqual(response[1], value.apps[1]);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
route.model({node_id:"localhost:64318", node_addr:"localhost:8042"})
.then(
function(value){
assert.ok(value);
assert.ok(value.apps);
assert.equal(value.apps.length, 2);
assert.deepEqual(response[0], value.apps[0]);
assert.deepEqual(response[1], value.apps[1]);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
});

View File

@ -17,6 +17,7 @@
*/
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
moduleFor('route:yarn-node-container', 'Unit | Route | NodeContainer', {
});
@ -36,7 +37,7 @@ test('Test getting specific container on a node', function(assert) {
nodeId: "localhost:64318", containerLogFiles:["syslog","stderr",
"stdout"]};
var store = {
queryRecord: function(type, query) {
queryRecord: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response);
});
@ -45,17 +46,16 @@ test('Test getting specific container on a node', function(assert) {
assert.expect(6);
var route = this.subject();
route.set('store', store);
var model =
route.model({node_id:"localhost:64318", node_addr:"localhost:8042",
container_id:"container_e32_1456000363780_0002_01_000001"}).
then(
function(value){
assert.ok(value);
assert.ok(value.nodeContainer);
assert.deepEqual(value.nodeContainer, response);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
route.model({node_id:"localhost:64318", node_addr:"localhost:8042",
container_id:"container_e32_1456000363780_0002_01_000001"})
.then(
function(value){
assert.ok(value);
assert.ok(value.nodeContainer);
assert.deepEqual(value.nodeContainer, response);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
});

View File

@ -17,6 +17,7 @@
*/
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
moduleFor('route:yarn-node-containers', 'Unit | Route | NodeContainers', {
});
@ -42,7 +43,7 @@ test('Test getting apps on a node', function(assert) {
nodeId:"localhost:64318",containerLogFiles:["syslog","stderr",
"syslog.shuffle","stdout"]}];
var store = {
query: function(type, query) {
query: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response.slice());
});
@ -51,18 +52,17 @@ test('Test getting apps on a node', function(assert) {
assert.expect(8);
var route = this.subject();
route.set('store', store);
var model =
route.model({node_id:"localhost:64318", node_addr:"localhost:8042"}).
then(
function(value){
assert.ok(value);
assert.ok(value.containers);
assert.equal(value.containers.length, 2);
assert.deepEqual(value.containers[0], response[0]);
assert.deepEqual(value.containers[1], response[1]);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
route.model({node_id:"localhost:64318", node_addr:"localhost:8042"})
.then(
function(value){
assert.ok(value);
assert.ok(value.containers);
assert.equal(value.containers.length, 2);
assert.deepEqual(value.containers[0], response[0]);
assert.deepEqual(value.containers[1], response[1]);
assert.ok(value.nodeInfo);
assert.equal(value.nodeInfo.addr, 'localhost:8042');
assert.equal(value.nodeInfo.id, 'localhost:64318');
}
);
});

View File

@ -61,11 +61,11 @@ test('Test getting a node', function(assert) {
// Create store which returns appropriate responses.
var store = {
findRecord: function(type) {
if (type == 'yarnNode') {
if (type === 'yarnNode') {
return new Ember.RSVP.Promise(function(resolve) {
resolve(nodeResponse);
});
} else if (type == 'yarnRmNode') {
} else if (type === 'yarnRmNode') {
return new Ember.RSVP.Promise(function(resolve) {
resolve(rmNodeResponse);
});

View File

@ -57,7 +57,7 @@ test('Test getting nodes', function(assert) {
containersCPUUsage: 0
}}];
var store = {
findAll: function(type) {
findAll: function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(response);
});