Skip to content

Commit

Permalink
Use const/let in statusPage plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
epixa committed Feb 2, 2016
1 parent 4a0396c commit 78cb6aa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/plugins/statusPage/public/lib/formatNumber.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

var moment = require('moment');
var numeral = require('numeral');
const moment = require('moment');
const numeral = require('numeral');

module.exports = function formatNumber(num, which) {
var format = '0.00';
var postfix = '';
let format = '0.00';
let postfix = '';
switch (which) {
case 'time':
return moment(num).format('HH:mm:ss');
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/statusPage/public/lib/makeChartOptions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var formatNumber = require('./formatNumber');
const formatNumber = require('./formatNumber');

module.exports = function makeChartOptions(type) {
return {
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/statusPage/public/lib/readStatData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _ = require('lodash');
const _ = require('lodash');

module.exports = function readStatData(data, seriesNames) {
// Metric Values format
Expand All @@ -13,13 +13,13 @@ module.exports = function readStatData(data, seriesNames) {
// Go through all of the metric values and split the values out.
// returns an array of all of the averages

var metricList = [];
const metricList = [];
seriesNames = seriesNames || [];
data.forEach(function (vector) {
vector = _.flatten(vector);
var x = vector.shift();
const x = vector.shift();
vector.forEach(function (yValue, i) {
var series = seriesNames[i] || '';
const series = seriesNames[i] || '';

if (!metricList[i]) {
metricList[i] = {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/statusPage/public/lib/toTitleCase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _ = require('lodash');
const _ = require('lodash');

// Turns thisIsASentence to
// This Is A Sentence
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/statusPage/public/statusPage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var $ = require('jquery');
var _ = require('lodash');
var notify = require('ui/notify');
const $ = require('jquery');
const _ = require('lodash');
const notify = require('ui/notify');

require('plugins/statusPage/statusPageMetric');
require('plugins/statusPage/statusPage.less');

var chrome = require('ui/chrome')
const chrome = require('ui/chrome')
.setTabs([
{
id: '',
Expand All @@ -15,7 +15,7 @@ var chrome = require('ui/chrome')
])
.setRootTemplate(require('plugins/statusPage/statusPage.html'))
.setRootController('ui', function ($http, $scope) {
var ui = this;
const ui = this;
ui.loading = false;

ui.refresh = function () {
Expand All @@ -31,11 +31,11 @@ var chrome = require('ui/chrome')
ui.fetchError = null;
}

var data = resp.data;
const data = resp.data;
ui.metrics = data.metrics;
ui.statuses = data.status.statuses;

var overall = data.status.overall;
const overall = data.status.overall;
if (!ui.serverState || (ui.serverState !== overall.state)) {
ui.serverState = overall.state;
ui.serverStateMessage = overall.title;
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/statusPage/public/statusPageMetric.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var _ = require('lodash');
var moment = require('moment');
var numeral = require('numeral');
const _ = require('lodash');
const moment = require('moment');
const numeral = require('numeral');

var toTitleCase = require('./lib/toTitleCase');
var formatNumber = require('./lib/formatNumber');
var readStatData = require('./lib/readStatData');
const toTitleCase = require('./lib/toTitleCase');
const formatNumber = require('./lib/formatNumber');
const readStatData = require('./lib/readStatData');

function calcAvg(metricList, metricNumberType) {
return metricList.map(function (data) {
var uglySum = data.values.reduce(function (sumSoFar, vector) {
const uglySum = data.values.reduce(function (sumSoFar, vector) {
return sumSoFar + vector.y;
}, 0);
return formatNumber(uglySum / data.values.length, metricNumberType);
Expand All @@ -27,7 +27,7 @@ require('ui/modules')
},
controllerAs: 'metric',
controller: function ($scope) {
var self = this;
const self = this;

self.name = $scope.name;
self.title = toTitleCase(self.name);
Expand Down Expand Up @@ -56,10 +56,10 @@ require('ui/modules')
self.chartData = readStatData(self.rawData, self.seriesNames);
self.averages = calcAvg(self.chartData, self.numberType);

var unit = '';
let unit = '';
self.averages = self.averages.map(function (average) {
var parts = average.split(' ');
var value = parts.shift();
const parts = average.split(' ');
const value = parts.shift();
unit = parts.join(' ');
return value;
});
Expand Down

0 comments on commit 78cb6aa

Please sign in to comment.