[Upgrading to ES 2015 syntax] Arrow callbacks
also replaced _.bind with () => {} where possible Change-Id: Iaa7a85b4298b35ec2e9ca9946a332a2e771eb1e3
This commit is contained in:
parent
7b9c732f58
commit
cd52d7c318
|
@ -143,7 +143,7 @@
|
|||
no-this-before-super: 2
|
||||
no-var: 0
|
||||
object-shorthand: [2, methods]
|
||||
prefer-arrow-callback: 0
|
||||
prefer-arrow-callback: 2
|
||||
prefer-const: 0
|
||||
prefer-spread: 2
|
||||
prefer-template: 0
|
||||
|
|
|
@ -42,7 +42,7 @@ define(
|
|||
'bootstrap',
|
||||
'./styles/main.less'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, ReactDOM, utils, models, KeystoneClient, RootComponent, dialogs, LoginPage, WelcomePage, ClusterPage, ClustersPage, EquipmentPage, ReleasesPage, PluginsPage, NotificationsPage, SupportPage, CapacityPage) {
|
||||
($, _, i18n, Backbone, React, ReactDOM, utils, models, KeystoneClient, RootComponent, dialogs, LoginPage, WelcomePage, ClusterPage, ClustersPage, EquipmentPage, ReleasesPage, PluginsPage, NotificationsPage, SupportPage, CapacityPage) => {
|
||||
'use strict';
|
||||
|
||||
class Router extends Backbone.Router {
|
||||
|
|
|
@ -23,7 +23,7 @@ define([
|
|||
'react',
|
||||
'react-dom',
|
||||
'react.backbone'
|
||||
], function($, _, Backbone, utils, i18n, dispatcher, React, ReactDOM) {
|
||||
], ($, _, Backbone, utils, i18n, dispatcher, React, ReactDOM) => {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
|
@ -63,7 +63,7 @@ define([
|
|||
isSavingPossible: _.result(this, 'isSavingPossible'),
|
||||
applyChanges: this.applyChanges,
|
||||
revertChanges: this.revertChanges
|
||||
}).done(function() {
|
||||
}).done(() => {
|
||||
app.navigate(href, {trigger: true});
|
||||
});
|
||||
}
|
||||
|
@ -137,13 +137,13 @@ define([
|
|||
},
|
||||
startRenaming(e) {
|
||||
e.preventDefault();
|
||||
$('html').on(this.state.renamingMixinEventName, _.bind(function(e) {
|
||||
$('html').on(this.state.renamingMixinEventName, (e) => {
|
||||
if (e && !$(e.target).closest(ReactDOM.findDOMNode(this.refs[refname])).length) {
|
||||
this.endRenaming();
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
this.setState({isRenaming: true});
|
||||
},
|
||||
endRenaming() {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
define(['underscore', 'backbone'], function(_, Backbone) {
|
||||
define(['underscore', 'backbone'], (_, Backbone) => {
|
||||
'use strict';
|
||||
|
||||
var dispatcher = _.clone(Backbone.Events);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
define(['underscore', 'expression/parser', 'expression/objects'], function(_, ExpressionParser, expressionObjects) {
|
||||
define(['underscore', 'expression/parser', 'expression/objects'], (_, ExpressionParser, expressionObjects) => {
|
||||
'use strict';
|
||||
|
||||
function Expression(expressionText, models, options) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
define(['underscore', 'expression/parser'], function(_, ExpressionParser) {
|
||||
define(['underscore', 'expression/parser'], (_, ExpressionParser) => {
|
||||
'use strict';
|
||||
|
||||
function ModelPath(path) {
|
||||
|
|
|
@ -17,7 +17,7 @@ define([
|
|||
'underscore',
|
||||
'i18next-client',
|
||||
'./translations/core.json'
|
||||
], function(_, i18next, translations) {
|
||||
], (_, i18next, translations) => {
|
||||
'use strict';
|
||||
|
||||
var defaultLocale = 'en-US';
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
define(['jquery', 'underscore', 'js-cookie'], function($, _, Cookies) {
|
||||
define(['jquery', 'underscore', 'js-cookie'], ($, _, Cookies) => {
|
||||
'use strict';
|
||||
|
||||
class KeystoneClient {
|
||||
|
|
|
@ -23,7 +23,7 @@ define([
|
|||
'expression/objects',
|
||||
'views/custom_controls',
|
||||
'deep-model'
|
||||
], function($, _, i18n, Backbone, utils, Expression, expressionObjects, customControls) {
|
||||
], ($, _, i18n, Backbone, utils, Expression, expressionObjects, customControls) => {
|
||||
'use strict';
|
||||
|
||||
var models = {};
|
||||
|
@ -44,7 +44,7 @@ define([
|
|||
|
||||
var collectionMixin = {
|
||||
getByIds(ids) {
|
||||
return this.filter(function(model) {return _.contains(ids, model.id);});
|
||||
return this.filter((model) => _.contains(ids, model.id));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@ define([
|
|||
'partition'
|
||||
];
|
||||
|
||||
_.each(collectionMethods, function(method) {
|
||||
_.each(collectionMethods, (method) => {
|
||||
collectionMixin[method] = function() {
|
||||
var args = _.toArray(arguments),
|
||||
source = args[0];
|
||||
|
@ -88,9 +88,9 @@ define([
|
|||
sync() {
|
||||
var deferred = this._super('sync', arguments);
|
||||
if (this.cacheFor) {
|
||||
deferred.done(_.bind(function() {
|
||||
deferred.done(() => {
|
||||
this.lastSyncTime = new Date();
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
return deferred;
|
||||
},
|
||||
|
@ -200,7 +200,7 @@ define([
|
|||
|
||||
// Check the overridden limit types
|
||||
messages = _.chain(overrides)
|
||||
.map(function(override) {
|
||||
.map((override) => {
|
||||
var exp = evaluateExpressionHelper(override.condition, models).value;
|
||||
|
||||
if (exp) {
|
||||
|
@ -212,7 +212,7 @@ define([
|
|||
.value();
|
||||
// Now check the global, not-overridden limit types
|
||||
messages = messages.concat(_.chain(limitTypes)
|
||||
.map(function(limitType) {
|
||||
.map((limitType) => {
|
||||
if (checkedLimitTypes[limitType]) {
|
||||
return;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ define([
|
|||
// message, i.e. for 'min' and 'recommended' types we
|
||||
// pick one with maximal value, for 'max' type we pick
|
||||
// the minimal one.
|
||||
messages = _.map(limitTypes, function(limitType) {
|
||||
messages = _.map(limitTypes, (limitType) => {
|
||||
var message = _.chain(messages)
|
||||
.filter({type: limitType})
|
||||
.sortBy('value')
|
||||
|
@ -290,9 +290,7 @@ define([
|
|||
roleName = role.get('name');
|
||||
|
||||
if (roleConflicts == '*') {
|
||||
role.conflicts = _.map(this.reject({name: roleName}), function(role) {
|
||||
return role.get('name');
|
||||
});
|
||||
role.conflicts = _.map(this.reject({name: roleName}), (role) => role.get('name'));
|
||||
} else {
|
||||
role.conflicts = _.chain(role.conflicts)
|
||||
.union(roleConflicts)
|
||||
|
@ -400,11 +398,11 @@ define([
|
|||
} else if (resourceName == 'ht_cores') {
|
||||
resource = this.get('meta').cpu.total;
|
||||
} else if (resourceName == 'hdd') {
|
||||
resource = _.reduce(this.get('meta').disks, function(hdd, disk) {return _.isNumber(disk.size) ? hdd + disk.size : hdd;}, 0);
|
||||
resource = _.reduce(this.get('meta').disks, (hdd, disk) => _.isNumber(disk.size) ? hdd + disk.size : hdd, 0);
|
||||
} else if (resourceName == 'ram') {
|
||||
resource = this.get('meta').memory.total;
|
||||
} else if (resourceName == 'disks') {
|
||||
resource = _.pluck(this.get('meta').disks, 'size').sort(function(a, b) {return a - b;});
|
||||
resource = _.pluck(this.get('meta').disks, 'size').sort((a, b) => a - b);
|
||||
} else if (resourceName == 'disks_amount') {
|
||||
resource = this.get('meta').disks.length;
|
||||
} else if (resourceName == 'interfaces') {
|
||||
|
@ -414,7 +412,7 @@ define([
|
|||
return _.isNaN(resource) ? 0 : resource;
|
||||
},
|
||||
sortedRoles(preferredOrder) {
|
||||
return _.union(this.get('roles'), this.get('pending_roles')).sort(function(a, b) {
|
||||
return _.union(this.get('roles'), this.get('pending_roles')).sort((a, b) => {
|
||||
return _.indexOf(preferredOrder, a) - _.indexOf(preferredOrder, b);
|
||||
});
|
||||
},
|
||||
|
@ -441,7 +439,7 @@ define([
|
|||
return status == 'discover' || status == 'error' || status == 'provisioned';
|
||||
},
|
||||
getRolesSummary(releaseRoles) {
|
||||
return _.map(this.sortedRoles(releaseRoles.pluck('name')), function(role) {
|
||||
return _.map(this.sortedRoles(releaseRoles.pluck('name')), (role) => {
|
||||
return releaseRoles.findWhere({name: role}).get('label');
|
||||
}).join(', ');
|
||||
},
|
||||
|
@ -500,14 +498,14 @@ define([
|
|||
return _.any(this.invoke('hasChanges'));
|
||||
},
|
||||
nodesAfterDeployment() {
|
||||
return this.filter(function(node) {return !node.get('pending_deletion');});
|
||||
return this.filter((node) => {return !node.get('pending_deletion');});
|
||||
},
|
||||
nodesAfterDeploymentWithRole(role) {
|
||||
return _.filter(this.nodesAfterDeployment(), function(node) {return node.hasRole(role);});
|
||||
return _.filter(this.nodesAfterDeployment(), (node) => {return node.hasRole(role);});
|
||||
},
|
||||
resources(resourceName) {
|
||||
var resources = this.map(function(node) {return node.resource(resourceName);});
|
||||
return _.reduce(resources, function(sum, n) {return sum + n;}, 0);
|
||||
var resources = this.map((node) => {return node.resource(resourceName);});
|
||||
return _.reduce(resources, (sum, n) => {return sum + n;}, 0);
|
||||
},
|
||||
getLabelValues(label) {
|
||||
return this.invoke('getLabel', label);
|
||||
|
@ -516,7 +514,7 @@ define([
|
|||
if (!this.length) return false;
|
||||
var roles = _.union(this.at(0).get('roles'), this.at(0).get('pending_roles')),
|
||||
disks = this.at(0).resource('disks');
|
||||
return !this.any(function(node) {
|
||||
return !this.any((node) => {
|
||||
var roleConflict = _.difference(roles, _.union(node.get('roles'), node.get('pending_roles'))).length;
|
||||
return roleConflict || !_.isEqual(disks, node.resource('disks'));
|
||||
});
|
||||
|
@ -595,7 +593,7 @@ define([
|
|||
comparator: 'id',
|
||||
filterTasks(filters) {
|
||||
return _.flatten(_.map(this.model.prototype.extendGroups(filters), function(name) {
|
||||
return this.filter(function(task) {
|
||||
return this.filter((task) => {
|
||||
return task.match(_.extend(_.omit(filters, 'group'), {name: name}));
|
||||
});
|
||||
}, this));
|
||||
|
@ -780,7 +778,7 @@ define([
|
|||
getUnallocatedSpace(options) {
|
||||
options = options || {};
|
||||
var volumes = options.volumes || this.get('volumes');
|
||||
var allocatedSpace = volumes.reduce(function(sum, volume) {return volume.get('name') == options.skip ? sum : sum + volume.get('size');}, 0);
|
||||
var allocatedSpace = volumes.reduce((sum, volume) => {return volume.get('name') == options.skip ? sum : sum + volume.get('size');}, 0);
|
||||
return this.get('size') - allocatedSpace;
|
||||
},
|
||||
validate(attrs) {
|
||||
|
@ -848,14 +846,14 @@ define([
|
|||
getSlaveInterfaces() {
|
||||
if (!this.isBond()) {return [this];}
|
||||
var slaveInterfaceNames = _.pluck(this.get('slaves'), 'name');
|
||||
return this.collection.filter(function(slaveInterface) {
|
||||
return this.collection.filter((slaveInterface) => {
|
||||
return _.contains(slaveInterfaceNames, slaveInterface.get('name'));
|
||||
});
|
||||
},
|
||||
validate(attrs) {
|
||||
var errors = [];
|
||||
var networks = new models.Networks(this.get('assigned_networks').invoke('getFullNetwork', attrs.networks));
|
||||
var untaggedNetworks = networks.filter(function(network) { return _.isNull(network.getVlanRange(attrs.networkingParameters)); });
|
||||
var untaggedNetworks = networks.filter((network) => _.isNull(network.getVlanRange(attrs.networkingParameters)));
|
||||
var ns = 'cluster_page.nodes_tab.configure_interfaces.validation.';
|
||||
// public and floating networks are allowed to be assigned to the same interface
|
||||
var maxUntaggedNetworksCount = networks.any({name: 'public'}) && networks.any({name: 'floating'}) ? 2 : 1;
|
||||
|
@ -978,7 +976,7 @@ define([
|
|||
var currentNetworks = new models.Networks(networks.where({group_id: nodeNetworkGroup.id}));
|
||||
var nodeNetworkGroupErrors = {};
|
||||
// validate networks
|
||||
currentNetworks.each(function(network) {
|
||||
currentNetworks.each((network) => {
|
||||
var networkErrors = {};
|
||||
if (network.get('meta').configurable) {
|
||||
var cidr = network.get('cidr');
|
||||
|
@ -1000,7 +998,7 @@ define([
|
|||
//FIXME (morale): same VLAN IDs are not permitted for nova-network for now
|
||||
var forbiddenVlans = [];
|
||||
if (novaNetManager) {
|
||||
forbiddenVlans = currentNetworks.map(function(net) {
|
||||
forbiddenVlans = currentNetworks.map((net) => {
|
||||
return net.id != network.id ? net.get('vlan_start') : null;
|
||||
});
|
||||
}
|
||||
|
@ -1048,7 +1046,7 @@ define([
|
|||
networkingParametersErrors.fixed_networks_amount = i18n(ns + 'need_more_vlan');
|
||||
}
|
||||
var vlanIntersection = false;
|
||||
_.each(_.compact(networks.pluck('vlan_start')), function(vlan) {
|
||||
_.each(_.compact(networks.pluck('vlan_start')), (vlan) => {
|
||||
if (utils.validateVlanRange(fixedVlan, fixedVlan + fixedAmount - 1, vlan)) {
|
||||
vlanIntersection = true;
|
||||
}
|
||||
|
@ -1077,7 +1075,7 @@ define([
|
|||
} else if (idStart == idEnd) {
|
||||
idRangeErrors[0] = idRangeErrors[1] = i18n(ns + 'not_enough_id');
|
||||
} else if (segmentation == 'vlan') {
|
||||
_.each(_.compact(networks.pluck('vlan_start')), function(vlan) {
|
||||
_.each(_.compact(networks.pluck('vlan_start')), (vlan) => {
|
||||
if (utils.validateVlanRange(idStart, idEnd, vlan)) {
|
||||
idRangeErrors[0] = i18n(ns + 'vlan_intersection');
|
||||
}
|
||||
|
@ -1145,7 +1143,7 @@ define([
|
|||
}
|
||||
}
|
||||
var nameserverErrors = [];
|
||||
_.each(networkParameters.get('dns_nameservers'), function(nameserver) {
|
||||
_.each(networkParameters.get('dns_nameservers'), (nameserver) => {
|
||||
nameserverErrors.push(!utils.validateIP(nameserver) ? i18n(ns + 'invalid_nameserver') : null);
|
||||
});
|
||||
if (_.compact(nameserverErrors).length) {
|
||||
|
@ -1224,7 +1222,7 @@ define([
|
|||
if (locallyStoredValue) {
|
||||
this.set(attribute, locallyStoredValue);
|
||||
}
|
||||
this.on('change:' + attribute, function(model, value) {
|
||||
this.on('change:' + attribute, (model, value) => {
|
||||
if (_.isUndefined(value)) {
|
||||
localStorage.removeItem(attribute);
|
||||
} else {
|
||||
|
@ -1249,9 +1247,9 @@ define([
|
|||
constructorName: 'WizardModel',
|
||||
parseConfig(config) {
|
||||
var result = {};
|
||||
_.each(config, _.bind(function(paneConfig, paneName) {
|
||||
_.each(config, (paneConfig, paneName) => {
|
||||
result[paneName] = {};
|
||||
_.each(paneConfig, function(attributeConfig, attribute) {
|
||||
_.each(paneConfig, (attributeConfig, attribute) => {
|
||||
var attributeConfigValue = attributeConfig.value;
|
||||
if (_.isUndefined(attributeConfigValue)) {
|
||||
switch (attributeConfig.type) {
|
||||
|
@ -1269,7 +1267,7 @@ define([
|
|||
}
|
||||
result[paneName][attribute] = attributeConfigValue;
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
return result;
|
||||
},
|
||||
processConfig(config) {
|
||||
|
@ -1277,11 +1275,11 @@ define([
|
|||
},
|
||||
restoreDefaultValues(panesToRestore) {
|
||||
var result = {};
|
||||
_.each(this.defaults, _.bind(function(paneConfig, paneName) {
|
||||
_.each(this.defaults, (paneConfig, paneName) => {
|
||||
if (_.contains(panesToRestore, paneName)) {
|
||||
result[paneName] = this.defaults[paneName];
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
this.set(result);
|
||||
},
|
||||
validate(attrs, options) {
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'i18n',
|
||||
'./styles.less'
|
||||
],
|
||||
function(VmWareTab, vmWareModels, translations, i18n) {
|
||||
(VmWareTab, vmWareModels, translations, i18n) => {
|
||||
'use strict';
|
||||
|
||||
i18n.addTranslations(translations);
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'backbone',
|
||||
'models'
|
||||
],
|
||||
function($, _, i18n, Backbone, models) {
|
||||
($, _, i18n, Backbone, models) => {
|
||||
'use strict';
|
||||
|
||||
function isRegularField(field) {
|
||||
|
@ -107,7 +107,7 @@ function($, _, i18n, Backbone, models) {
|
|||
return this.validationError;
|
||||
},
|
||||
validate() {
|
||||
var errors = _.compact(this.models.map(function(model) {
|
||||
var errors = _.compact(this.models.map((model) => {
|
||||
model.isValid();
|
||||
return model.validationError;
|
||||
}));
|
||||
|
@ -186,7 +186,7 @@ function($, _, i18n, Backbone, models) {
|
|||
result.metadata = metadata;
|
||||
|
||||
// regular fields
|
||||
_.each(metadata, function(field) {
|
||||
_.each(metadata, (field) => {
|
||||
if (isRegularField(field)) {
|
||||
result[field.name] = response[field.name];
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ function($, _, i18n, Backbone, models) {
|
|||
// nova_computes
|
||||
var novaMetadata = _.find(metadata, {name: 'nova_computes'});
|
||||
var novaValues = _.clone(response.nova_computes);
|
||||
novaValues = _.map(novaValues, function(value) {
|
||||
novaValues = _.map(novaValues, (value) => {
|
||||
value.metadata = novaMetadata.fields;
|
||||
return new NovaCompute(value);
|
||||
});
|
||||
|
@ -244,7 +244,7 @@ function($, _, i18n, Backbone, models) {
|
|||
// Availability Zone(s)
|
||||
var azMetadata = _.find(metadata, {name: 'availability_zones'});
|
||||
var azValues = _.clone(value.availability_zones);
|
||||
azValues = _.map(azValues, function(value) {
|
||||
azValues = _.map(azValues, (value) => {
|
||||
value.metadata = azMetadata.fields;
|
||||
return value;
|
||||
});
|
||||
|
@ -307,12 +307,12 @@ function($, _, i18n, Backbone, models) {
|
|||
var availabilityZones = this.get('availability_zones') || [];
|
||||
availabilityZones.each(function(zone) {
|
||||
var novaComputes = zone.get('nova_computes') || [];
|
||||
novaComputes.each(function(compute) {
|
||||
novaComputes.each((compute) => {
|
||||
var targetNode = compute.get('target_node');
|
||||
assignedNodes[targetNode.current.id] = targetNode.current.label;
|
||||
}, this);
|
||||
}, this);
|
||||
var unassignedNodes = restrictionModels.cluster.get('nodes').filter(function(node) {
|
||||
var unassignedNodes = restrictionModels.cluster.get('nodes').filter((node) => {
|
||||
return _.contains(node.get('pending_roles'), 'compute-vmware') && !assignedNodes[node.get('hostname')];
|
||||
});
|
||||
if (unassignedNodes.length > 0) {
|
||||
|
|
|
@ -25,7 +25,7 @@ define(
|
|||
'views/controls',
|
||||
'component_mixins',
|
||||
'plugins/vmware/vmware_models'
|
||||
], function(React, $, i18n, _, dispatcher, utils, controls, componentMixins, vmwareModels) {
|
||||
], (React, $, i18n, _, dispatcher, utils, controls, componentMixins, vmwareModels) => {
|
||||
'use strict';
|
||||
|
||||
var Field = React.createClass({
|
||||
|
@ -39,7 +39,7 @@ define(
|
|||
}
|
||||
this.props.model.set(name, currentValue);
|
||||
this.setState({model: this.props.model});
|
||||
_.defer(function() {dispatcher.trigger('vcenter_model_update');});
|
||||
_.defer(() => {dispatcher.trigger('vcenter_model_update');});
|
||||
},
|
||||
render() {
|
||||
var metadata = this.props.metadata,
|
||||
|
@ -54,7 +54,7 @@ define(
|
|||
disabled={this.props.disabled}
|
||||
error={(this.props.model.validationError || {})[metadata.name]}
|
||||
>
|
||||
{metadata.type == 'select' && value.options.map(function(value) {
|
||||
{metadata.type == 'select' && value.options.map((value) => {
|
||||
return <option key={value.id} value={value.id}>{value.label}</option>;
|
||||
})}
|
||||
</controls.Input>
|
||||
|
@ -110,9 +110,7 @@ define(
|
|||
|
||||
// add nodes of 'compute-vmware' type to targetNode select
|
||||
var targetNode = this.props.model.get('target_node') || {};
|
||||
var nodes = this.props.cluster.get('nodes').filter(function(node) {
|
||||
return node.hasRole('compute-vmware');
|
||||
});
|
||||
var nodes = this.props.cluster.get('nodes').filter((node) => node.hasRole('compute-vmware'));
|
||||
|
||||
targetNode.options = [];
|
||||
if (targetNode.current.id == 'controllers' || !this.props.isLocked) {
|
||||
|
@ -120,7 +118,7 @@ define(
|
|||
} else {
|
||||
targetNode.options.push({id: 'invalid', label: 'Select node'});
|
||||
}
|
||||
nodes.forEach(function(node) {
|
||||
nodes.forEach((node) => {
|
||||
targetNode.options.push({
|
||||
id: node.get('hostname'),
|
||||
label: node.get('name') + ' (' + node.get('mac').substr(9) + ')'
|
||||
|
@ -136,7 +134,7 @@ define(
|
|||
<button
|
||||
className='btn btn-link'
|
||||
disabled={this.props.disabled}
|
||||
onClick={_.bind(function() {this.props.onAdd(this.props.model);}, this)}
|
||||
onClick={() => {this.props.onAdd(this.props.model);}}
|
||||
>
|
||||
<i className='glyphicon glyphicon-plus-sign' />
|
||||
</button>
|
||||
|
@ -144,7 +142,7 @@ define(
|
|||
<button
|
||||
className='btn btn-link'
|
||||
disabled={this.props.disabled}
|
||||
onClick={_.bind(function() {this.props.onRemove(this.props.model);}, this)}
|
||||
onClick={() => {this.props.onRemove(this.props.model);}}
|
||||
>
|
||||
<i className='glyphicon glyphicon-minus-sign' />
|
||||
</button>
|
||||
|
@ -171,13 +169,13 @@ define(
|
|||
collection.add(newItem, {at: index + 1});
|
||||
collection.parseRestrictions();
|
||||
this.setState({model: this.props.model});
|
||||
_.defer(function() {dispatcher.trigger('vcenter_model_update'); });
|
||||
_.defer(() => {dispatcher.trigger('vcenter_model_update'); });
|
||||
},
|
||||
removeNovaCompute(current) {
|
||||
var collection = this.props.model.get('nova_computes');
|
||||
collection.remove(current);
|
||||
this.setState({model: this.props.model});
|
||||
_.defer(function() { dispatcher.trigger('vcenter_model_update'); });
|
||||
_.defer(() => { dispatcher.trigger('vcenter_model_update'); });
|
||||
},
|
||||
renderFields() {
|
||||
var model = this.props.model,
|
||||
|
@ -258,10 +256,12 @@ define(
|
|||
</div>
|
||||
<ul className='unassigned-node-list'>
|
||||
{
|
||||
this.props.errors.unassigned_nodes.map(function(node) {
|
||||
this.props.errors.unassigned_nodes.map((node) => {
|
||||
return (
|
||||
<li className='unassigned-node'>
|
||||
<span className='unassigned-node-name'>{node.get('name')}</span>
|
||||
<li key={node.id}
|
||||
className='unassigned-node'>
|
||||
<span
|
||||
className='unassigned-node-name'>{node.get('name')}</span>
|
||||
|
||||
({node.get('mac')})
|
||||
</li>
|
||||
|
@ -319,11 +319,11 @@ define(
|
|||
});
|
||||
|
||||
this.onModelSync();
|
||||
dispatcher.on('vcenter_model_update', _.bind(function() {
|
||||
dispatcher.on('vcenter_model_update', () => {
|
||||
if (this.isMounted()) {
|
||||
this.forceUpdate();
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
componentWillUnmount() {
|
||||
this.model.off('sync', null, this);
|
||||
|
@ -337,9 +337,9 @@ define(
|
|||
},
|
||||
onLoadDefaults() {
|
||||
this.model.loadDefaults = true;
|
||||
this.model.fetch().done(_.bind(function() {
|
||||
this.model.fetch().done(() => {
|
||||
this.model.loadDefaults = false;
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
applyChanges() {
|
||||
return this.model.save();
|
||||
|
@ -358,13 +358,13 @@ define(
|
|||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
var oldData = JSON.stringify(old, function(key, data) {
|
||||
var oldData = JSON.stringify(old, (key, data) => {
|
||||
if (key == 'target_node') {
|
||||
delete data.options;
|
||||
}
|
||||
return data;
|
||||
});
|
||||
var currentData = JSON.stringify(current, function(key, data) {
|
||||
var currentData = JSON.stringify(current, (key, data) => {
|
||||
if (key == 'target_node') {
|
||||
delete data.options;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ define([
|
|||
'expression/objects',
|
||||
'react',
|
||||
'ip'
|
||||
], function(require, $, _, i18n, Backbone, classNames, naturalSort, Expression, expressionObjects, React, IP) {
|
||||
], (require, $, _, i18n, Backbone, classNames, naturalSort, Expression, expressionObjects, React, IP) => {
|
||||
'use strict';
|
||||
|
||||
var utils = {
|
||||
|
@ -37,14 +37,10 @@ define([
|
|||
cidr: /^(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\/([1-9]|[1-2]\d|3[0-2])$/
|
||||
},
|
||||
serializeTabOptions(options) {
|
||||
return _.map(options, function(value, key) {
|
||||
return key + ':' + value;
|
||||
}).join(';');
|
||||
return _.map(options, (value, key) => key + ':' + value).join(';');
|
||||
},
|
||||
deserializeTabOptions(serializedOptions) {
|
||||
return _.object(_.map((serializedOptions || '').split(';'), function(option) {
|
||||
return option.split(':');
|
||||
}));
|
||||
return _.object(_.map((serializedOptions || '').split(';'), (option) => option.split(':')));
|
||||
},
|
||||
getNodeListFromTabOptions(options) {
|
||||
var nodeIds = utils.deserializeTabOptions(options.screenOptions[0]).nodes,
|
||||
|
@ -151,9 +147,7 @@ define([
|
|||
return Math.pow(2, 32 - parseInt(_.last(cidr.split('/')), 10));
|
||||
},
|
||||
formatNumber(n) {
|
||||
return String(n).replace(/\d/g, function(c, i, a) {
|
||||
return i > 0 && c !== '.' && (a.length - i) % 3 === 0 ? ',' + c : c;
|
||||
});
|
||||
return String(n).replace(/\d/g, (c, i, a) => i > 0 && c !== '.' && (a.length - i) % 3 === 0 ? ',' + c : c);
|
||||
},
|
||||
floor(n, decimals) {
|
||||
return Math.floor(n * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
||||
|
@ -281,7 +275,7 @@ define([
|
|||
sortEntryProperties(entry, sortOrder) {
|
||||
sortOrder = sortOrder || ['name'];
|
||||
var properties = _.keys(entry);
|
||||
return _.sortBy(properties, function(property) {
|
||||
return _.sortBy(properties, (property) => {
|
||||
var index = _.indexOf(sortOrder, property);
|
||||
return index == -1 ? properties.length : index;
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/controls'
|
||||
],
|
||||
function(_, i18n, React, models, componentMixins, controls) {
|
||||
(_, i18n, React, models, componentMixins, controls) => {
|
||||
'use strict';
|
||||
|
||||
var CapacityPage = React.createClass({
|
||||
|
@ -36,9 +36,8 @@ function(_, i18n, React, models, componentMixins, controls) {
|
|||
breadcrumbsPath: [['home', '#'], ['support', '#support'], 'capacity'],
|
||||
fetchData() {
|
||||
var task = new models.Task();
|
||||
return task.save({}, {url: '/api/capacity/', method: 'PUT'}).then(function() {
|
||||
return {capacityLog: new models.CapacityLog()};
|
||||
});
|
||||
return task.save({}, {url: '/api/capacity/', method: 'PUT'})
|
||||
.then(() => ({capacityLog: new models.CapacityLog()}));
|
||||
}
|
||||
},
|
||||
shouldDataBeFetched() {
|
||||
|
|
|
@ -33,7 +33,7 @@ define(
|
|||
'views/cluster_page_tabs/healthcheck_tab',
|
||||
'plugins/vmware/vmware'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins, dialogs, DashboardTab, NodesTab, NetworkTab, SettingsTab, LogsTab, HealthCheckTab, vmWare) {
|
||||
($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins, dialogs, DashboardTab, NodesTab, NetworkTab, SettingsTab, LogsTab, HealthCheckTab, vmWare) => {
|
||||
'use strict';
|
||||
|
||||
var ClusterPage = React.createClass({
|
||||
|
@ -129,7 +129,7 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
cluster.fetchRelated('tasks'),
|
||||
nodeNetworkGroups.fetch({cache: true})
|
||||
)
|
||||
.then(function() {
|
||||
.then(() => {
|
||||
var networkConfiguration = new models.NetworkConfiguration();
|
||||
networkConfiguration.url = _.result(cluster, 'url') + '/network_configuration/' + cluster.get('net_provider');
|
||||
cluster.set({
|
||||
|
@ -138,7 +138,7 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
});
|
||||
return $.when(cluster.get('networkConfiguration').fetch(), cluster.get('release').fetch());
|
||||
})
|
||||
.then(function() {
|
||||
.then(() => {
|
||||
var useVcenter = cluster.get('settings').get('common.use_vcenter.value');
|
||||
if (!useVcenter) {
|
||||
return true;
|
||||
|
@ -147,11 +147,11 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
cluster.set({vcenter: vcenter});
|
||||
return vcenter.fetch();
|
||||
})
|
||||
.then(function() {
|
||||
.then(() => {
|
||||
return tab.fetchData ? tab.fetchData({cluster: cluster, tabOptions: tabOptions}) : $.Deferred().resolve();
|
||||
});
|
||||
}
|
||||
return promise.then(function(data) {
|
||||
return promise.then((data) => {
|
||||
return {
|
||||
cluster: cluster,
|
||||
nodeNetworkGroups: nodeNetworkGroups,
|
||||
|
@ -200,12 +200,12 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
var task = this.props.cluster.task({group: 'deployment', active: true});
|
||||
if (task) {
|
||||
return task.fetch()
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
if (task.match({active: false})) dispatcher.trigger('deploymentTaskFinished');
|
||||
}, this))
|
||||
.then(_.bind(function() {
|
||||
return this.props.cluster.fetchRelated('nodes');
|
||||
}, this));
|
||||
})
|
||||
.then(() =>
|
||||
this.props.cluster.fetchRelated('nodes')
|
||||
);
|
||||
} else {
|
||||
task = this.props.cluster.task({name: 'verify_networks', active: true});
|
||||
return task ? task.fetch() : $.Deferred().resolve();
|
||||
|
@ -222,9 +222,9 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
componentWillMount() {
|
||||
this.props.cluster.on('change:release_id', function() {
|
||||
var release = new models.Release({id: this.props.cluster.get('release_id')});
|
||||
release.fetch().done(_.bind(function() {
|
||||
release.fetch().done(() => {
|
||||
this.props.cluster.set({release: release});
|
||||
}, this));
|
||||
});
|
||||
}, this);
|
||||
this.updateLogSettings();
|
||||
},
|
||||
|
@ -248,9 +248,8 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
this.setState({selectedLogs: selectedLogs});
|
||||
},
|
||||
getAvailableTabs(cluster) {
|
||||
return _.filter(this.constructor.getTabs(), function(tabData) {
|
||||
return !tabData.tab.isVisible || tabData.tab.isVisible(cluster);
|
||||
});
|
||||
return _.filter(this.constructor.getTabs(),
|
||||
(tabData) => !tabData.tab.isVisible || tabData.tab.isVisible(cluster));
|
||||
},
|
||||
pickDefaultSettingGroup() {
|
||||
return _.first(this.props.cluster.get('settings').getGroupList());
|
||||
|
@ -266,7 +265,7 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
|
|||
selectNodes(ids, checked) {
|
||||
if (ids && ids.length) {
|
||||
var nodeSelection = this.state.selectedNodeIds;
|
||||
_.each(ids, function(id) {
|
||||
_.each(ids, (id) => {
|
||||
if (checked) {
|
||||
nodeSelection[id] = true;
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/controls'
|
||||
],
|
||||
function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, componentMixins, controls) {
|
||||
(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, componentMixins, controls) => {
|
||||
'use strict';
|
||||
|
||||
var namespace = 'cluster_page.dashboard_tab.';
|
||||
|
@ -341,9 +341,7 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
return _.reduce(
|
||||
this.validations,
|
||||
function(accumulator, validator) {
|
||||
return _.merge(accumulator, validator.call(this, cluster), function(a, b) {
|
||||
return a.concat(_.compact(b));
|
||||
});
|
||||
return _.merge(accumulator, validator.call(this, cluster), (a, b) => a.concat(_.compact(b)));
|
||||
},
|
||||
{blocker: [], error: [], warning: []},
|
||||
this
|
||||
|
@ -411,35 +409,27 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
function(cluster) {
|
||||
var configModels = this.getConfigModels(),
|
||||
roleModels = cluster.get('roles'),
|
||||
validRoleModels = roleModels.filter(function(role) {
|
||||
return !role.checkRestrictions(configModels).result;
|
||||
}),
|
||||
limitValidations = _.zipObject(validRoleModels.map(function(role) {
|
||||
return [role.get('name'), role.checkLimits(configModels, cluster.get('nodes'))];
|
||||
})),
|
||||
limitRecommendations = _.zipObject(validRoleModels.map(function(role) {
|
||||
return [role.get('name'), role.checkLimits(configModels, cluster.get('nodes'), true, ['recommended'])];
|
||||
}));
|
||||
validRoleModels = roleModels.filter((role) => !role.checkRestrictions(configModels).result),
|
||||
limitValidations = _.zipObject(validRoleModels.map((role) => [role.get('name'), role.checkLimits(configModels, cluster.get('nodes'))])),
|
||||
limitRecommendations = _.zipObject(validRoleModels.map((role) => [role.get('name'), role.checkLimits(configModels, cluster.get('nodes'), true, ['recommended'])]));
|
||||
return {
|
||||
blocker: roleModels.map(_.bind(
|
||||
function(role) {
|
||||
blocker: roleModels.map((role) => {
|
||||
var name = role.get('name'),
|
||||
limits = limitValidations[name];
|
||||
return limits && !limits.valid && limits.message;
|
||||
}, this)),
|
||||
warning: roleModels.map(_.bind(
|
||||
function(role) {
|
||||
}),
|
||||
warning: roleModels.map((role) => {
|
||||
var name = role.get('name'),
|
||||
recommendation = limitRecommendations[name];
|
||||
return recommendation && !recommendation.valid && recommendation.message;
|
||||
}, this))
|
||||
})
|
||||
};
|
||||
},
|
||||
// check cluster network configuration
|
||||
function(cluster) {
|
||||
if (this.props.nodeNetworkGroups.where({cluster_id: cluster.id}).length > 1) return null;
|
||||
var networkVerificationTask = cluster.task('verify_networks'),
|
||||
makeComponent = _.bind(function(text, isError) {
|
||||
makeComponent = (text, isError) => {
|
||||
var span = (
|
||||
<span key='invalid_networks'>
|
||||
{text}
|
||||
|
@ -450,7 +440,7 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
</span>
|
||||
);
|
||||
return isError ? {error: [span]} : {warning: [span]};
|
||||
}, this);
|
||||
};
|
||||
if (_.isUndefined(networkVerificationTask)) {
|
||||
return makeComponent(i18n(this.ns + 'verification_not_performed'));
|
||||
} else if (networkVerificationTask.match({status: 'error'})) {
|
||||
|
@ -622,7 +612,7 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
ram = 0,
|
||||
ns = namespace + 'cluster_info_fields.';
|
||||
|
||||
this.props.cluster.get('nodes').each(function(node) {
|
||||
this.props.cluster.get('nodes').each((node) => {
|
||||
cores += node.resource('ht_cores');
|
||||
hdds += node.resource('hdd');
|
||||
ram += node.resource('ram');
|
||||
|
@ -819,7 +809,7 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
if (deferred) {
|
||||
this.setState({disabled: true});
|
||||
deferred
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
if (response.status == 409) {
|
||||
this.setState({error: utils.getResponseText(response)});
|
||||
} else {
|
||||
|
@ -828,14 +818,14 @@ function(_, i18n, $, React, ReactDOM, utils, models, dispatcher, dialogs, compon
|
|||
response: response
|
||||
});
|
||||
}
|
||||
}, this))
|
||||
.done(function() {
|
||||
})
|
||||
.done(() => {
|
||||
dispatcher.trigger('updatePageLayout');
|
||||
})
|
||||
.always(_.bind(function() {
|
||||
.always(() => {
|
||||
this.setState({disabled: false});
|
||||
if (!(this.state && this.state.error)) this.props.endRenaming();
|
||||
}, this));
|
||||
});
|
||||
} else if (cluster.validationError) {
|
||||
this.setState({error: cluster.validationError.name});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/controls'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, models, utils, componentMixins, controls) {
|
||||
($, _, i18n, Backbone, React, models, utils, componentMixins, controls) => {
|
||||
'use strict';
|
||||
|
||||
var HealthCheckTab = React.createClass({
|
||||
|
@ -47,12 +47,11 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
ostf.tests.url = _.result(ostf.tests, 'url') + '/' + clusterId;
|
||||
ostf.testruns = new models.TestRuns();
|
||||
ostf.testruns.url = _.result(ostf.testruns, 'url') + '/last/' + clusterId;
|
||||
return $.when(ostf.testsets.fetch(), ostf.tests.fetch(), ostf.testruns.fetch()).then(function() {
|
||||
return $.when(ostf.testsets.fetch(), ostf.tests.fetch(), ostf.testruns.fetch()).then(() => {
|
||||
options.cluster.set({ostf: ostf});
|
||||
return {};
|
||||
}, function() {
|
||||
return $.Deferred().resolve();
|
||||
});
|
||||
}, () => $.Deferred().resolve()
|
||||
);
|
||||
}
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
|
@ -101,7 +100,7 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
return {
|
||||
actionInProgress: false,
|
||||
credentialsVisible: null,
|
||||
credentials: _.transform(this.props.cluster.get('settings').get('access'), function(result, value, key) {result[key] = value.value;})
|
||||
credentials: _.transform(this.props.cluster.get('settings').get('access'), (result, value, key) => {result[key] = value.value;})
|
||||
};
|
||||
},
|
||||
isLocked() {
|
||||
|
@ -134,17 +133,17 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
}), 'id');
|
||||
if (testsToRun.length) {
|
||||
var testrunConfig = {tests: testsToRun},
|
||||
addCredentials = _.bind(function(obj) {
|
||||
addCredentials = (obj) => {
|
||||
obj.ostf_os_access_creds = {
|
||||
ostf_os_username: this.state.credentials.user,
|
||||
ostf_os_tenant_name: this.state.credentials.tenant,
|
||||
ostf_os_password: this.state.credentials.password
|
||||
};
|
||||
return obj;
|
||||
}, this);
|
||||
};
|
||||
|
||||
if (this.props.testruns.where({testset: testsetId}).length) {
|
||||
_.each(this.props.testruns.where({testset: testsetId}), function(testrun) {
|
||||
_.each(this.props.testruns.where({testset: testsetId}), (testrun) => {
|
||||
_.extend(testrunConfig, addCredentials({
|
||||
id: testrun.id,
|
||||
status: 'restarted'
|
||||
|
@ -172,15 +171,15 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
requests.push(Backbone.sync('update', oldTestruns));
|
||||
}
|
||||
$.when(...requests)
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.startPolling(true);
|
||||
}, this))
|
||||
.fail(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
utils.showErrorDialog({response: response});
|
||||
})
|
||||
.always(_.bind(function() {
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
getActiveTestRuns() {
|
||||
return this.props.testruns.where({status: 'running'});
|
||||
|
@ -191,14 +190,14 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
this.setState({actionInProgress: true});
|
||||
testruns.invoke('set', {status: 'stopped'});
|
||||
testruns.toJSON = function() {
|
||||
return this.map(function(testrun) {
|
||||
return _.pick(testrun.attributes, 'id', 'status');
|
||||
});
|
||||
return this.map((testrun) =>
|
||||
_.pick(testrun.attributes, 'id', 'status')
|
||||
);
|
||||
};
|
||||
Backbone.sync('update', testruns).done(_.bind(function() {
|
||||
Backbone.sync('update', testruns).done(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
this.startPolling(true);
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
render() {
|
||||
|
@ -255,7 +254,7 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
<div className='alert alert-warning'>{i18n('cluster_page.healthcheck_tab.deploy_alert')}</div>
|
||||
}
|
||||
<div key='testsets'>
|
||||
{this.props.testsets.map(_.bind(function(testset) {
|
||||
{this.props.testsets.map((testset) => {
|
||||
return <TestSet
|
||||
key={testset.id}
|
||||
testset={testset}
|
||||
|
@ -263,7 +262,7 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
|
|||
tests={new Backbone.Collection(this.props.tests.where({testset: testset.id}))}
|
||||
disabled={disabledState || hasRunningTests}
|
||||
/>;
|
||||
}, this))}
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -26,7 +26,7 @@ define(
|
|||
'react-addons-pure-render-mixin',
|
||||
'react-addons-create-fragment'
|
||||
],
|
||||
function($, _, i18n, React, utils, models, componentMixins, controls, PureRenderMixin, ReactFragment) {
|
||||
($, _, i18n, React, utils, models, componentMixins, controls, PureRenderMixin, ReactFragment) => {
|
||||
'use strict';
|
||||
|
||||
var LogsTab = React.createClass({
|
||||
|
@ -42,13 +42,13 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
from = this.state.from,
|
||||
to = this.state.to;
|
||||
request = this.fetchLogs({from: from, to: to})
|
||||
.done(_.bind(function(data) {
|
||||
.done((data) => {
|
||||
this.setState({
|
||||
logsEntries: data.entries.concat(logsEntries),
|
||||
from: data.from,
|
||||
to: data.to
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
return $.when(request);
|
||||
},
|
||||
getInitialState() {
|
||||
|
@ -77,7 +77,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
app.navigate('#cluster/' + this.props.cluster.id + '/logs/' + utils.serializeTabOptions(logOptions), {trigger: false, replace: true});
|
||||
params = params || {};
|
||||
this.fetchLogs(params)
|
||||
.done(_.bind(function(data) {
|
||||
.done((data) => {
|
||||
var logsEntries = this.state.logsEntries || [];
|
||||
this.setState({
|
||||
showMoreLogsLink: data.has_more || false,
|
||||
|
@ -87,7 +87,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
to: data.to
|
||||
});
|
||||
this.startPolling();
|
||||
}, this))
|
||||
})
|
||||
.fail((response) => {
|
||||
this.setState({
|
||||
logsEntries: undefined,
|
||||
|
@ -154,8 +154,8 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
this.sources.fetch({url: '/api/logs/sources/nodes/' + chosenNodeId})
|
||||
:
|
||||
this.sources.fetch();
|
||||
this.sources.deferred.done(_.bind(function() {
|
||||
var filteredSources = this.sources.filter(function(source) {return source.get('remote') == (type != 'local');}),
|
||||
this.sources.deferred.done(() => {
|
||||
var filteredSources = this.sources.filter((source) => source.get('remote') == (type != 'local')),
|
||||
chosenSource = _.findWhere(filteredSources, {id: this.state.source}) || _.first(filteredSources),
|
||||
chosenLevelId = chosenSource ? _.contains(chosenSource.get('levels'), this.state.level) ? this.state.level : _.first(chosenSource.get('levels')) : null;
|
||||
this.setState({
|
||||
|
@ -167,7 +167,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
level: chosenLevelId,
|
||||
locked: false
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
this.sources.deferred.fail((response) => {
|
||||
this.setState({
|
||||
type: type,
|
||||
|
@ -181,10 +181,10 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
},
|
||||
componentDidMount() {
|
||||
this.fetchSources(this.state.type, this.state.node)
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.setState({locked: true});
|
||||
this.props.showLogs();
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
onTypeChange(name, value) {
|
||||
this.fetchSources(value);
|
||||
|
@ -205,7 +205,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
this.setState(data);
|
||||
},
|
||||
getLocalSources() {
|
||||
return this.state.sources.map(function(source) {
|
||||
return this.state.sources.map((source) => {
|
||||
if (!source.get('remote')) {
|
||||
return <option value={source.id} key={source.id}>{source.get('name')}</option>;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
sourcesByGroup = {'': []},
|
||||
sources = this.state.sources;
|
||||
if (sources.length) {
|
||||
sources.each(function(source) {
|
||||
sources.each((source) => {
|
||||
var group = source.get('group') || '';
|
||||
if (!_.has(sourcesByGroup, group)) {
|
||||
sourcesByGroup[group] = [];
|
||||
|
@ -225,11 +225,11 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
}
|
||||
sourcesByGroup[group].push(source);
|
||||
});
|
||||
_.each(groups, function(group) {
|
||||
_.each(groups, (group) => {
|
||||
if (sourcesByGroup[group].length) {
|
||||
var option = sourcesByGroup[group].map(function(source) {
|
||||
var option = sourcesByGroup[group].map((source) => {
|
||||
return <option value={source.id} key={source.id}>{source.get('name')}</option>;
|
||||
}, this);
|
||||
});
|
||||
options[group] = group ? <optgroup label={group}>{option}</optgroup> : option;
|
||||
}
|
||||
}, this);
|
||||
|
@ -281,7 +281,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
if (this.props.nodes.length) {
|
||||
types.push(['remote', 'Other servers']);
|
||||
}
|
||||
var typeOptions = types.map(function(type) {
|
||||
var typeOptions = types.map((type) => {
|
||||
return <option value={type[0]} key={type[0]}>{type[1]}</option>;
|
||||
});
|
||||
return <div className='col-md-2 col-sm-3'>
|
||||
|
@ -298,7 +298,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
},
|
||||
renderNodeSelect() {
|
||||
var sortedNodes = this.props.nodes.models.sort(_.partialRight(utils.compare, {attr: 'name'})),
|
||||
nodeOptions = sortedNodes.map(function(node) {
|
||||
nodeOptions = sortedNodes.map((node) => {
|
||||
return <option value={node.id} key={node.id}>{node.get('name') || node.get('mac')}</option>;
|
||||
});
|
||||
|
||||
|
@ -332,9 +332,9 @@ function($, _, i18n, React, utils, models, componentMixins, controls, PureRender
|
|||
renderLevelSelect() {
|
||||
var levelOptions = [];
|
||||
if (this.state.source && this.state.sources.length) {
|
||||
levelOptions = this.state.sources.get(this.state.source).get('levels').map(function(level) {
|
||||
levelOptions = this.state.sources.get(this.state.source).get('levels').map((level) => {
|
||||
return <option value={level} key={level}>{level}</option>;
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
return <div className='col-md-2 col-sm-3'>
|
||||
<controls.Input
|
||||
|
|
|
@ -30,7 +30,7 @@ define(
|
|||
'views/cluster_page_tabs/setting_section',
|
||||
'react-addons-transition-group'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialogs, componentMixins, controls, SettingSection, CSSTransitionGroup) {
|
||||
($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialogs, componentMixins, controls, SettingSection, CSSTransitionGroup) => {
|
||||
'use strict';
|
||||
|
||||
var parametersNS = 'cluster_page.network_tab.networking_parameters.',
|
||||
|
@ -616,10 +616,10 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
},
|
||||
prepareIpRanges() {
|
||||
var removeEmptyRanges = function(ranges) {
|
||||
return _.filter(ranges, function(range) {return _.compact(range).length;});
|
||||
return _.filter(ranges, (range) => _.compact(range).length);
|
||||
},
|
||||
networkConfiguration = this.props.cluster.get('networkConfiguration');
|
||||
networkConfiguration.get('networks').each(function(network) {
|
||||
networkConfiguration.get('networks').each((network) => {
|
||||
if (network.get('meta').notation == 'ip_ranges') {
|
||||
network.set({ip_ranges: removeEmptyRanges(network.get('ip_ranges'))});
|
||||
}
|
||||
|
@ -729,9 +729,8 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
if (this.isNetworkSettingsChanged()) {
|
||||
// collecting data to save
|
||||
var settings = this.props.cluster.get('settings'),
|
||||
dataToSave = this.props.cluster.isAvailableForSettingsChanges() ? settings.attributes : _.pick(settings.attributes, function(group) {
|
||||
return (group.metadata || {}).always_editable;
|
||||
});
|
||||
dataToSave = this.props.cluster.isAvailableForSettingsChanges() ? settings.attributes :
|
||||
_.pick(settings.attributes, (group) => (group.metadata || {}).always_editable);
|
||||
|
||||
var options = {url: settings.url, patch: true, wait: true, validate: false},
|
||||
deferred = new models.Settings(_.cloneDeep(dataToSave)).save(null, options);
|
||||
|
@ -797,13 +796,13 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
fieldsWithVerificationErrors = [];
|
||||
// @TODO(morale): soon response format will be changed and this part should be rewritten
|
||||
if (task && task.get('result').length) {
|
||||
_.each(task.get('result'), function(verificationError) {
|
||||
_.each(verificationError.ids, function(networkId) {
|
||||
_.each(verificationError.errors, function(field) {
|
||||
_.each(task.get('result'), (verificationError) => {
|
||||
_.each(verificationError.ids, (networkId) => {
|
||||
_.each(verificationError.errors, (field) => {
|
||||
fieldsWithVerificationErrors.push({network: networkId, field: field});
|
||||
}, this);
|
||||
}, this);
|
||||
}, this);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
return fieldsWithVerificationErrors;
|
||||
},
|
||||
|
@ -1331,7 +1330,7 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
<controls.Input
|
||||
{...this.composeProps('fixed_network_size', false, true)}
|
||||
type='select'
|
||||
children={_.map(fixedNetworkSizeValues, function(value) {
|
||||
children={_.map(fixedNetworkSizeValues, (value) => {
|
||||
return <option key={value} value={value}>{value}</option>;
|
||||
})}
|
||||
inputClassName='pull-left'
|
||||
|
@ -1560,13 +1559,13 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
<div className='verification-router'></div>
|
||||
</div>
|
||||
<div className='animation-box'>
|
||||
{_.times(3, function(index) {
|
||||
{_.times(3, (index) => {
|
||||
++index;
|
||||
return <div key={index} className={this.getConnectionStatus(task, index == 1) + ' connect-' + index}></div>;
|
||||
}, this)}
|
||||
})}
|
||||
</div>
|
||||
<div className='nodes-box'>
|
||||
{_.times(3, function(index) {
|
||||
{_.times(3, (index) => {
|
||||
++index;
|
||||
return <div key={index} className={'verification-node-' + index}></div>;
|
||||
})}
|
||||
|
@ -1577,9 +1576,9 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
<div className='row'>
|
||||
<div className='verification-text-placeholder col-xs-12'>
|
||||
<ol className='verification-description'>
|
||||
{_.times(5, function(index) {
|
||||
{_.times(5, (index) => {
|
||||
return <li key={index}>{i18n(ns + 'step_' + index)}</li>;
|
||||
}, this)}
|
||||
})}
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1617,12 +1616,11 @@ function($, _, i18n, Backbone, React, ReactDOM, models, dispatcher, utils, dialo
|
|||
<controls.Table
|
||||
tableClassName='table table-condensed enable-selection'
|
||||
noStripes
|
||||
head={_.map(['node_name', 'node_mac_address', 'node_interface', 'expected_vlan'], function(attr) {
|
||||
return {label: i18n(ns + attr)};
|
||||
})}
|
||||
head={_.map(['node_name', 'node_mac_address', 'node_interface', 'expected_vlan'],
|
||||
(attr) => ({label: i18n(ns + attr)}))}
|
||||
body={
|
||||
_.map(task.get('result'), function(node) {
|
||||
var absentVlans = _.map(node.absent_vlans, function(vlan) {
|
||||
_.map(task.get('result'), (node) => {
|
||||
var absentVlans = _.map(node.absent_vlans, (vlan) => {
|
||||
return vlan || i18n(networkTabNS + 'untagged');
|
||||
});
|
||||
return [node.name || 'N/A', node.mac || 'N/A', node.interface, absentVlans.join(', ')];
|
||||
|
|
|
@ -27,7 +27,7 @@ define(
|
|||
'views/cluster_page_tabs/nodes_tab_screens/edit_node_interfaces_screen',
|
||||
'react-addons-transition-group'
|
||||
],
|
||||
function($, _, React, ReactDOM, controls, ClusterNodesScreen, AddNodesScreen, EditNodesScreen, EditNodeDisksScreen, EditNodeInterfacesScreen, ReactTransitionGroup) {
|
||||
($, _, React, ReactDOM, controls, ClusterNodesScreen, AddNodesScreen, EditNodesScreen, EditNodeDisksScreen, EditNodeInterfacesScreen, ReactTransitionGroup) => {
|
||||
'use strict';
|
||||
|
||||
var NodesTab = React.createClass({
|
||||
|
@ -62,15 +62,15 @@ function($, _, React, ReactDOM, controls, ClusterNodesScreen, AddNodesScreen, Ed
|
|||
cluster: this.props.cluster,
|
||||
screenOptions: screenOptions || this.state.screenOptions
|
||||
})
|
||||
.done(_.bind(function(data) {
|
||||
.done((data) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
screenData: data || {}
|
||||
});
|
||||
}, this))
|
||||
.fail(_.bind(function() {
|
||||
})
|
||||
.fail(() => {
|
||||
app.navigate('#cluster/' + this.props.cluster.id + '/nodes', {trigger: true, replace: true});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
getScreen(props) {
|
||||
return (props || this.props).tabOptions[0] || 'list';
|
||||
|
|
|
@ -21,7 +21,7 @@ define(
|
|||
'models',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/node_list_screen'
|
||||
],
|
||||
function($, _, React, models, NodeListScreen) {
|
||||
($, _, React, models, NodeListScreen) => {
|
||||
'use strict';
|
||||
|
||||
var AddNodesScreen = React.createClass({
|
||||
|
@ -31,9 +31,8 @@ function($, _, React, models, NodeListScreen) {
|
|||
nodes.fetch = function(options) {
|
||||
return this.constructor.__super__.fetch.call(this, _.extend({data: {cluster_id: ''}}, options));
|
||||
};
|
||||
return $.when(nodes.fetch(), options.cluster.get('roles').fetch(), options.cluster.get('settings').fetch({cache: true})).then(function() {
|
||||
return {nodes: nodes};
|
||||
});
|
||||
return $.when(nodes.fetch(), options.cluster.get('roles').fetch(),
|
||||
options.cluster.get('settings').fetch({cache: true})).then(() => ({nodes: nodes}));
|
||||
}
|
||||
},
|
||||
render() {
|
||||
|
|
|
@ -20,7 +20,7 @@ define(
|
|||
'models',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/node_list_screen'
|
||||
],
|
||||
function(_, React, models, NodeListScreen) {
|
||||
(_, React, models, NodeListScreen) => {
|
||||
'use strict';
|
||||
|
||||
var ClusterNodesScreen = React.createClass({
|
||||
|
|
|
@ -26,7 +26,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/controls'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins, controls) {
|
||||
($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins, controls) => {
|
||||
'use strict';
|
||||
|
||||
var EditNodeDisksScreen = React.createClass({
|
||||
|
@ -46,11 +46,11 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
|
||||
var volumes = new models.Volumes();
|
||||
volumes.url = _.result(nodes.at(0), 'url') + '/volumes';
|
||||
return $.when(...nodes.map(function(node) {
|
||||
return $.when(...nodes.map((node) => {
|
||||
node.disks = new models.Disks();
|
||||
return node.disks.fetch({url: _.result(node, 'url') + '/disks'});
|
||||
}, this).concat(volumes.fetch()))
|
||||
.then(function() {
|
||||
.then(() => {
|
||||
var disks = new models.Disks(_.cloneDeep(nodes.at(0).disks.toJSON()), {parse: true});
|
||||
return {
|
||||
disks: disks,
|
||||
|
@ -79,16 +79,16 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
loadDefaults() {
|
||||
this.setState({actionInProgress: true});
|
||||
this.props.disks.fetch({url: _.result(this.props.nodes.at(0), 'url') + '/disks/defaults/'})
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
var ns = 'cluster_page.nodes_tab.configure_disks.configuration_error.';
|
||||
utils.showErrorDialog({
|
||||
title: i18n(ns + 'title'),
|
||||
message: utils.getResponseText(response) || i18n(ns + 'load_defaults_warning')
|
||||
});
|
||||
}, this))
|
||||
.always(_.bind(function() {
|
||||
})
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
revertChanges() {
|
||||
this.props.disks.reset(_.cloneDeep(this.state.initialDisks), {parse: true});
|
||||
|
@ -104,16 +104,16 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
return Backbone.sync('update', node.disks, {url: _.result(node, 'url') + '/disks'});
|
||||
}, this))
|
||||
.done(this.updateInitialData)
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
var ns = 'cluster_page.nodes_tab.configure_disks.configuration_error.';
|
||||
utils.showErrorDialog({
|
||||
title: i18n(ns + 'title'),
|
||||
message: utils.getResponseText(response) || i18n(ns + 'saving_warning')
|
||||
});
|
||||
}, this))
|
||||
.always(_.bind(function() {
|
||||
})
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
getDiskMetaData(disk) {
|
||||
var result,
|
||||
|
@ -122,9 +122,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
// if at least one entry presents both in disk and metadata entry,
|
||||
// this metadata entry is for our disk
|
||||
var extra = disk.get('extra') || [];
|
||||
result = _.find(disksMetaData, function(diskMetaData) {
|
||||
return _.isArray(diskMetaData.extra) && _.intersection(diskMetaData.extra, extra).length;
|
||||
}, this);
|
||||
result = _.find(disksMetaData, (diskMetaData) =>
|
||||
_.isArray(diskMetaData.extra) && _.intersection(diskMetaData.extra, extra).length
|
||||
);
|
||||
// if matching "extra" fields doesn't work, try to search by disk id
|
||||
if (!result) {
|
||||
result = _.find(disksMetaData, {disk: disk.id});
|
||||
|
@ -157,9 +157,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
return disk.get('size') ? utils.floor(size / disk.get('size') * 100, 2) : 0;
|
||||
},
|
||||
hasErrors() {
|
||||
return this.props.disks.any(function(disk) {
|
||||
return disk.get('volumes').any('validationError');
|
||||
});
|
||||
return this.props.disks.any((disk) =>
|
||||
disk.get('volumes').any('validationError')
|
||||
);
|
||||
},
|
||||
isSavingPossible() {
|
||||
return !this.state.actionInProgress && this.hasChanges() && !this.hasErrors();
|
||||
|
@ -293,7 +293,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, ComponentMixins,
|
|||
<div>
|
||||
<h5>{i18n(ns + 'disk_information')}</h5>
|
||||
<div className='form-horizontal disk-info-box'>
|
||||
{_.map(utils.sortEntryProperties(diskMetaData, sortOrder), function(propertyName) {
|
||||
{_.map(utils.sortEntryProperties(diskMetaData, sortOrder), (propertyName) => {
|
||||
return (
|
||||
<div className='form-group' key={'property_' + propertyName}>
|
||||
<label className='col-xs-2'>{propertyName.replace(/_/g, ' ')}</label>
|
||||
|
|
|
@ -29,7 +29,7 @@ define(
|
|||
'react-dnd',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/offloading_modes_control'
|
||||
],
|
||||
function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, controls, ComponentMixins, DND, OffloadingModes) {
|
||||
($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, controls, ComponentMixins, DND, OffloadingModes) => {
|
||||
'use strict';
|
||||
|
||||
var ns = 'cluster_page.nodes_tab.configure_interfaces.';
|
||||
|
@ -64,7 +64,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
networksMetadata.fetch({
|
||||
url: '/api/releases/' + cluster.get('release_id') + '/networks'
|
||||
})]))
|
||||
.then(_.bind(function() {
|
||||
.then(() => {
|
||||
var interfaces = new models.Interfaces();
|
||||
interfaces.set(_.cloneDeep(nodes.at(0).interfaces.toJSON()), {parse: true});
|
||||
return {
|
||||
|
@ -77,7 +77,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
settings: cluster.get('settings')
|
||||
}
|
||||
};
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
getInitialState() {
|
||||
|
@ -132,16 +132,16 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
this.setState({actionInProgress: true});
|
||||
$.when(this.props.interfaces.fetch({
|
||||
url: _.result(this.props.nodes.at(0), 'url') + '/interfaces/default_assignment', reset: true
|
||||
}, this)).done(_.bind(function() {
|
||||
}, this)).done(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this)).fail(_.bind(function(response) {
|
||||
}).fail((response) => {
|
||||
var errorNS = ns + 'configuration_error.';
|
||||
utils.showErrorDialog({
|
||||
title: i18n(errorNS + 'title'),
|
||||
message: i18n(errorNS + 'load_defaults_warning'),
|
||||
response: response
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
revertChanges() {
|
||||
this.props.interfaces.reset(_.cloneDeep(this.state.initialInterfaces), {parse: true});
|
||||
|
@ -167,15 +167,15 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
return $.when(...nodes.map(function(node) {
|
||||
var oldNodeBonds, nodeBonds;
|
||||
// removing previously configured bonds
|
||||
oldNodeBonds = node.interfaces.filter(function(ifc) {return ifc.isBond();});
|
||||
oldNodeBonds = node.interfaces.filter((ifc) => ifc.isBond());
|
||||
node.interfaces.remove(oldNodeBonds);
|
||||
// creating node-specific bonds without slaves
|
||||
nodeBonds = _.map(bonds, function(bond) {
|
||||
nodeBonds = _.map(bonds, (bond) => {
|
||||
return new models.Interface(_.omit(bond.toJSON(), 'slaves'), {parse: true});
|
||||
}, this);
|
||||
});
|
||||
node.interfaces.add(nodeBonds);
|
||||
// determining slaves using bonding map
|
||||
_.each(nodeBonds, function(bond, bondIndex) {
|
||||
_.each(nodeBonds, (bond, bondIndex) => {
|
||||
var slaveIndexes = bondingMap[bondIndex],
|
||||
slaveInterfaces = _.map(slaveIndexes, node.interfaces.at, node.interfaces);
|
||||
bond.set({slaves: _.invoke(slaveInterfaces, 'pick', 'name')});
|
||||
|
@ -202,11 +202,11 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
|
||||
return Backbone.sync('update', node.interfaces, {url: _.result(node, 'url') + '/interfaces'});
|
||||
}, this))
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.setState({initialInterfaces: _.cloneDeep(this.interfacesToJSON(this.props.interfaces))});
|
||||
dispatcher.trigger('networkConfigurationUpdated');
|
||||
}, this))
|
||||
.fail(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
var errorNS = ns + 'configuration_error.';
|
||||
|
||||
utils.showErrorDialog({
|
||||
|
@ -214,9 +214,9 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
message: i18n(errorNS + 'saving_warning'),
|
||||
response: response
|
||||
});
|
||||
}).always(_.bind(function() {
|
||||
}).always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
configurationTemplateExists() {
|
||||
return !_.isEmpty(this.props.cluster.get('networkConfiguration').get('networking_parameters').get('configuration_template'));
|
||||
|
@ -252,25 +252,15 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
this);
|
||||
},
|
||||
getIntersectedOffloadingModes(interfaces) {
|
||||
var offloadingModes = interfaces.map(function(ifc) {
|
||||
return ifc.get('offloading_modes') || [];
|
||||
});
|
||||
var offloadingModes = interfaces.map((ifc) => ifc.get('offloading_modes') || []);
|
||||
if (!offloadingModes.length) return [];
|
||||
|
||||
return offloadingModes.reduce(
|
||||
(function(result, modes) {
|
||||
return this.findOffloadingModesIntersection(result, modes);
|
||||
}).bind(this)
|
||||
);
|
||||
return offloadingModes.reduce((result, modes) => this.findOffloadingModesIntersection(result, modes));
|
||||
},
|
||||
bondInterfaces() {
|
||||
this.setState({actionInProgress: true});
|
||||
var interfaces = this.props.interfaces.filter(function(ifc) {
|
||||
return ifc.get('checked') && !ifc.isBond();
|
||||
}),
|
||||
bonds = this.props.interfaces.find(function(ifc) {
|
||||
return ifc.get('checked') && ifc.isBond();
|
||||
}),
|
||||
var interfaces = this.props.interfaces.filter((ifc) => ifc.get('checked') && !ifc.isBond()),
|
||||
bonds = this.props.interfaces.find((ifc) => ifc.get('checked') && ifc.isBond()),
|
||||
bondingProperties = this.props.bondingConfig.properties;
|
||||
|
||||
if (!bonds) {
|
||||
|
@ -300,7 +290,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
// remove the bond to add it later and trigger re-rendering
|
||||
this.props.interfaces.remove(bonds, {silent: true});
|
||||
}
|
||||
_.each(interfaces, function(ifc) {
|
||||
_.each(interfaces, (ifc) => {
|
||||
bonds.get('assigned_networks').add(ifc.get('assigned_networks').models);
|
||||
ifc.get('assigned_networks').reset();
|
||||
ifc.set({checked: false});
|
||||
|
@ -319,17 +309,15 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
var networks = this.props.cluster.get('networkConfiguration').get('networks'),
|
||||
bond = this.props.interfaces.find({name: bondName}),
|
||||
slaves = bond.get('slaves'),
|
||||
bondHasUnmovableNetwork = bond.get('assigned_networks').any(
|
||||
function(interfaceNetwork) {
|
||||
return interfaceNetwork.getFullNetwork(networks).get('meta').unmovable;
|
||||
}
|
||||
),
|
||||
bondHasUnmovableNetwork = bond.get('assigned_networks').any((interfaceNetwork) => {
|
||||
return interfaceNetwork.getFullNetwork(networks).get('meta').unmovable;
|
||||
}),
|
||||
slaveInterfaceNames = _.pluck(slaves, 'name'),
|
||||
targetInterface = bond;
|
||||
|
||||
// if PXE interface is being removed - place networks there
|
||||
if (bondHasUnmovableNetwork) {
|
||||
var pxeInterface = this.props.interfaces.find(function(ifc) {
|
||||
var pxeInterface = this.props.interfaces.find((ifc) => {
|
||||
return ifc.get('pxe') && _.contains(slaveInterfaceNames, ifc.get('name'));
|
||||
});
|
||||
if (!slaveInterfaceName || pxeInterface && pxeInterface.get('name') == slaveInterfaceName) {
|
||||
|
@ -341,9 +329,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
if (slaveInterfaceName) {
|
||||
var slavesUpdated = _.reject(slaves, {name: slaveInterfaceName}),
|
||||
names = _.pluck(slavesUpdated, 'name'),
|
||||
bondSlaveInterfaces = this.props.interfaces.filter(function(ifc) {
|
||||
return _.contains(names, ifc.get('name'));
|
||||
});
|
||||
bondSlaveInterfaces = this.props.interfaces.filter((ifc) => _.contains(names, ifc.get('name')));
|
||||
|
||||
bond.set({
|
||||
slaves: slavesUpdated,
|
||||
|
@ -380,7 +366,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
if (!this.props.interfaces) {
|
||||
return;
|
||||
}
|
||||
this.props.interfaces.each(_.bind(function(ifc) {
|
||||
this.props.interfaces.each((ifc) => {
|
||||
validationResult = ifc.validate({
|
||||
networkingParameters: networkingParameters,
|
||||
networks: networks
|
||||
|
@ -388,7 +374,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
if (validationResult.length) {
|
||||
interfaceErrors[ifc.get('name')] = validationResult.join(' ');
|
||||
}
|
||||
}), this);
|
||||
});
|
||||
if (!_.isEqual(this.state.interfaceErrors, interfaceErrors)) {
|
||||
this.setState({interfaceErrors: interfaceErrors});
|
||||
}
|
||||
|
@ -429,8 +415,8 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
locked = this.isLocked(),
|
||||
bondingAvailable = this.bondingAvailable(),
|
||||
configurationTemplateExists = this.configurationTemplateExists(),
|
||||
checkedInterfaces = interfaces.filter(function(ifc) {return ifc.get('checked') && !ifc.isBond();}),
|
||||
checkedBonds = interfaces.filter(function(ifc) {return ifc.get('checked') && ifc.isBond();}),
|
||||
checkedInterfaces = interfaces.filter((ifc) => ifc.get('checked') && !ifc.isBond()),
|
||||
checkedBonds = interfaces.filter((ifc) => ifc.get('checked') && ifc.isBond()),
|
||||
creatingNewBond = checkedInterfaces.length >= 2 && !checkedBonds.length,
|
||||
addingInterfacesToExistingBond = !!checkedInterfaces.length && checkedBonds.length == 1,
|
||||
bondingPossible = creatingNewBond || addingInterfacesToExistingBond,
|
||||
|
@ -479,7 +465,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
</div>
|
||||
}
|
||||
<div className='ifc-list col-xs-12'>
|
||||
{interfaces.map(_.bind(function(ifc, index) {
|
||||
{interfaces.map((ifc, index) => {
|
||||
var ifcName = ifc.get('name');
|
||||
if (!_.contains(slaveInterfaceNames, ifcName)) return (
|
||||
<NodeInterfaceDropTarget {...this.props}
|
||||
|
@ -497,7 +483,7 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
interfaceNames={interfaceNames[index]}
|
||||
/>
|
||||
);
|
||||
}, this))}
|
||||
})}
|
||||
</div>
|
||||
<div className='col-xs-12 page-buttons content-elements'>
|
||||
<div className='well clearfix'>
|
||||
|
@ -577,13 +563,13 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
var configModels = _.clone(this.props.configModels);
|
||||
var availableModes = [];
|
||||
var interfaces = this.props.interface.isBond() ? this.props.interface.getSlaveInterfaces() : [this.props.interface];
|
||||
_.each(interfaces, function(ifc) {
|
||||
_.each(interfaces, (ifc) => {
|
||||
configModels.interface = ifc;
|
||||
availableModes.push(_.reduce(modes, function(result, modeSet) {
|
||||
availableModes.push(_.reduce(modes, (result, modeSet) => {
|
||||
if (modeSet.condition && !utils.evaluateExpression(modeSet.condition, configModels).value) return result;
|
||||
return result.concat(modeSet.values);
|
||||
}, [], this));
|
||||
}, this);
|
||||
}, []));
|
||||
});
|
||||
return _.intersection(...availableModes);
|
||||
},
|
||||
getBondPropertyValues(propertyName, value) {
|
||||
|
@ -620,12 +606,13 @@ function($, _, Backbone, React, i18n, utils, models, dispatcher, dialogs, contro
|
|||
this.updateBondProperties({lacp_rate: value});
|
||||
},
|
||||
getBondingOptions(bondingModes, attributeName) {
|
||||
return _.map(bondingModes, function(mode) {
|
||||
return _.map(bondingModes, (mode) => {
|
||||
return (
|
||||
<option key={'option-' + mode} value={mode}>
|
||||
{i18n(ns + attributeName + '.' + mode.replace('.', '_'))}
|
||||
</option>);
|
||||
}, this);
|
||||
</option>
|
||||
);
|
||||
});
|
||||
},
|
||||
toggleOffloading() {
|
||||
var interfaceProperties = this.props.interface.get('interface_properties'),
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'utils',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/node_list_screen'
|
||||
],
|
||||
function($, _, React, models, utils, NodeListScreen) {
|
||||
($, _, React, models, utils, NodeListScreen) => {
|
||||
'use strict';
|
||||
|
||||
var EditNodesScreen = React.createClass({
|
||||
|
@ -41,9 +41,8 @@ function($, _, React, models, utils, NodeListScreen) {
|
|||
nodes.parse = function() {
|
||||
return this.getByIds(nodes.pluck('id'));
|
||||
};
|
||||
return $.when(options.cluster.get('roles').fetch(), cluster.get('settings').fetch({cache: true})).then(function() {
|
||||
return {nodes: nodes};
|
||||
});
|
||||
return $.when(options.cluster.get('roles').fetch(),
|
||||
cluster.get('settings').fetch({cache: true})).then(() => ({nodes: nodes}));
|
||||
}
|
||||
},
|
||||
render() {
|
||||
|
|
|
@ -27,7 +27,7 @@ define(
|
|||
'views/dialogs',
|
||||
'component_mixins'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, dialogs, componentMixins) {
|
||||
($, _, i18n, Backbone, React, utils, models, dispatcher, controls, dialogs, componentMixins) => {
|
||||
'use strict';
|
||||
|
||||
var Node = React.createClass({
|
||||
|
@ -79,12 +79,12 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, dialo
|
|||
var node = new models.Node(this.props.node.attributes),
|
||||
data = {pending_deletion: false};
|
||||
node.save(data, {patch: true})
|
||||
.done(_.bind(function() {
|
||||
this.props.cluster.fetchRelated('nodes').done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.props.cluster.fetchRelated('nodes').done(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
}, this))
|
||||
.fail(function(response) {
|
||||
});
|
||||
})
|
||||
.fail((response) => {
|
||||
utils.showErrorDialog({
|
||||
title: i18n('cluster_page.nodes_tab.node.cant_discard'),
|
||||
response: response
|
||||
|
@ -255,7 +255,7 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, dialo
|
|||
if (_.isEmpty(labels)) return null;
|
||||
return (
|
||||
<ul>
|
||||
{_.map(_.keys(labels).sort(_.partialRight(utils.natsort, {insensitive: true})), function(key) {
|
||||
{_.map(_.keys(labels).sort(_.partialRight(utils.natsort, {insensitive: true})), (key) => {
|
||||
var value = labels[key];
|
||||
return (
|
||||
<li key={key + value} className='label'>
|
||||
|
|
|
@ -29,7 +29,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/node'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, controls, dialogs, componentMixins, Node) {
|
||||
($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, controls, dialogs, componentMixins, Node) => {
|
||||
'use strict';
|
||||
var NodeListScreen, MultiSelectControl, NumberRangeControl, ManagementPanel, NodeLabelsPanel, RolePanel, SelectAllMixin, NodeList, NodeGroup;
|
||||
|
||||
|
@ -280,7 +280,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
this.updateSorting(_.map(this.props.defaultSorting, _.partial(Sorter.fromObject, _, false)));
|
||||
},
|
||||
changeSortingOrder(sorterToChange) {
|
||||
this.updateSorting(this.state.activeSorters.map(function(sorter) {
|
||||
this.updateSorting(this.state.activeSorters.map((sorter) => {
|
||||
if (sorter.name == sorterToChange.name && sorter.isLabel == sorterToChange.isLabel) {
|
||||
return new Sorter(sorter.name, sorter.order == 'asc' ? 'desc' : 'asc', sorter.isLabel);
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
switch (filter.name) {
|
||||
case 'status':
|
||||
var os = this.props.cluster && this.props.cluster.get('release').get('operating_system') || 'OS';
|
||||
options = this.props.statusesToFilter.map(function(status) {
|
||||
options = this.props.statusesToFilter.map((status) => {
|
||||
return {
|
||||
name: status,
|
||||
label: i18n('cluster_page.nodes_tab.node.status.' + status, {os: os})
|
||||
|
@ -331,7 +331,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
});
|
||||
break;
|
||||
case 'manufacturer':
|
||||
options = _.uniq(this.props.nodes.pluck('manufacturer')).map(function(manufacturer) {
|
||||
options = _.uniq(this.props.nodes.pluck('manufacturer')).map((manufacturer) => {
|
||||
manufacturer = manufacturer || '';
|
||||
return {
|
||||
name: manufacturer.replace(/\s/g, '_'),
|
||||
|
@ -343,7 +343,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
options = this.props.roles.invoke('pick', 'name', 'label');
|
||||
break;
|
||||
case 'group_id':
|
||||
options = _.uniq(this.props.nodes.pluck('group_id')).map(function(groupId) {
|
||||
options = _.uniq(this.props.nodes.pluck('group_id')).map((groupId) => {
|
||||
var nodeNetworkGroup = this.props.nodeNetworkGroups.get(groupId);
|
||||
return {
|
||||
name: groupId,
|
||||
|
@ -352,24 +352,24 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
:
|
||||
i18n('common.not_specified')
|
||||
};
|
||||
}, this);
|
||||
});
|
||||
break;
|
||||
case 'cluster':
|
||||
options = _.uniq(this.props.nodes.pluck('cluster')).map(function(clusterId) {
|
||||
options = _.uniq(this.props.nodes.pluck('cluster')).map((clusterId) => {
|
||||
return {
|
||||
name: clusterId,
|
||||
label: clusterId ? this.props.clusters.get(clusterId).get('name') : i18n('cluster_page.nodes_tab.node.unallocated')
|
||||
};
|
||||
}, this);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// sort option list
|
||||
options.sort(_.bind(function(option1, option2) {
|
||||
options.sort((option1, option2) => {
|
||||
// sort Node Network Group filter options by node network group id
|
||||
if (this.props.name == 'group_id') return option1.name - option2.name;
|
||||
return utils.natsort(option1.label, option2.label, {insensitive: true});
|
||||
}, this));
|
||||
});
|
||||
|
||||
return options;
|
||||
},
|
||||
|
@ -377,7 +377,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
this.updateFilters(this.state.activeFilters.concat(filter));
|
||||
},
|
||||
changeFilter(filterToChange, values) {
|
||||
this.updateFilters(this.state.activeFilters.map(function(filter) {
|
||||
this.updateFilters(this.state.activeFilters.map((filter) => {
|
||||
if (filter.name == filterToChange.name && filter.isLabel == filterToChange.isLabel) {
|
||||
var changedFilter = new Filter(filter.name, values, filter.isLabel);
|
||||
changedFilter.limits = filter.limits;
|
||||
|
@ -438,15 +438,13 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
// search field
|
||||
if (this.state.search) {
|
||||
var search = this.state.search.toLowerCase();
|
||||
if (!_.any(node.pick('name', 'mac', 'ip'), function(attribute) {
|
||||
return _.contains((attribute || '').toLowerCase(), search);
|
||||
})) {
|
||||
if (!_.any(node.pick('name', 'mac', 'ip'), (attribute) => _.contains((attribute || '').toLowerCase(), search))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// filters
|
||||
return _.all(this.state.activeFilters, function(filter) {
|
||||
return _.all(this.state.activeFilters, (filter) => {
|
||||
if (!filter.values.length) return true;
|
||||
|
||||
if (filter.isLabel) {
|
||||
|
@ -456,7 +454,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
var result;
|
||||
switch (filter.name) {
|
||||
case 'roles':
|
||||
result = _.any(filter.values, function(role) {return node.hasRole(role);});
|
||||
result = _.any(filter.values, (role) => node.hasRole(role));
|
||||
break;
|
||||
case 'status':
|
||||
result = _.contains(filter.values, node.getStatusSummary());
|
||||
|
@ -493,8 +491,8 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
{... _.pick(this, 'toggleLabelsPanel')}
|
||||
{... _.pick(this, 'changeSearch', 'clearSearchField')}
|
||||
{... _.pick(this, 'changeViewMode')}
|
||||
labelSorters={screenNodesLabels.map(function(name) {return new Sorter(name, 'asc', true);})}
|
||||
labelFilters={screenNodesLabels.map(function(name) {return new Filter(name, [], true);})}
|
||||
labelSorters={screenNodesLabels.map((name) => new Sorter(name, 'asc', true))}
|
||||
labelFilters={screenNodesLabels.map((name) => new Filter(name, [], true))}
|
||||
nodes={selectedNodes}
|
||||
screenNodes={nodes}
|
||||
filteredNodes={filteredNodes}
|
||||
|
@ -579,14 +577,14 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
labels = groupedOptions.true || [];
|
||||
}
|
||||
|
||||
var optionProps = _.bind(function(option) {
|
||||
var optionProps = (option) => {
|
||||
return {
|
||||
key: option.name,
|
||||
type: 'checkbox',
|
||||
name: option.name,
|
||||
label: option.title
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
|
||||
var classNames = {
|
||||
'btn-group multiselect': true,
|
||||
|
@ -774,21 +772,21 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
return data;
|
||||
}, this));
|
||||
return Backbone.sync('update', nodes)
|
||||
.done(_.bind(function() {
|
||||
$.when(this.props.cluster.fetch(), this.props.cluster.fetchRelated('nodes')).always(_.bind(function() {
|
||||
.done(() => {
|
||||
$.when(this.props.cluster.fetch(), this.props.cluster.fetchRelated('nodes')).always(() => {
|
||||
if (this.props.mode == 'add') {
|
||||
dispatcher.trigger('updateNodeStats networkConfigurationUpdated labelsConfigurationUpdated');
|
||||
this.props.selectNodes();
|
||||
}
|
||||
}, this));
|
||||
}, this))
|
||||
.fail(_.bind(function(response) {
|
||||
});
|
||||
})
|
||||
.fail((response) => {
|
||||
this.setState({actionInProgress: false});
|
||||
utils.showErrorDialog({
|
||||
message: i18n('cluster_page.nodes_tab.node_management_panel.node_management_error.saving_warning'),
|
||||
response: response
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
applyAndRedirect() {
|
||||
this.applyChanges().done(this.changeScreen);
|
||||
|
@ -805,11 +803,11 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
},
|
||||
activateSearch() {
|
||||
this.setState({activeSearch: true});
|
||||
$('html').on('click.search', _.bind(function(e) {
|
||||
$('html').on('click.search', (e) => {
|
||||
if (!this.props.search && this.refs.search && !$(e.target).closest(ReactDOM.findDOMNode(this.refs.search)).length) {
|
||||
this.setState({activeSearch: false});
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
onSearchKeyDown(e) {
|
||||
if (e.key == 'Escape') {
|
||||
|
@ -920,34 +918,26 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
interfaceConflict = !this.props.nodes.areInterfacesConfigurable();
|
||||
}
|
||||
|
||||
var managementButtonClasses = _.bind(function(isActive, className) {
|
||||
var managementButtonClasses = (isActive, className) => {
|
||||
var classes = {
|
||||
'btn btn-default pull-left': true,
|
||||
active: isActive
|
||||
};
|
||||
classes[className] = true;
|
||||
return classes;
|
||||
}, this);
|
||||
};
|
||||
|
||||
var inactiveSorters, canResetSorters;
|
||||
var inactiveFilters, appliedFilters;
|
||||
if (this.props.mode != 'edit') {
|
||||
var checkSorter = _.bind(function(sorter, isLabel) {
|
||||
return !_.any(this.props.activeSorters, {name: sorter.name, isLabel: isLabel});
|
||||
}, this);
|
||||
var checkSorter = (sorter, isLabel) => !_.any(this.props.activeSorters, {name: sorter.name, isLabel: isLabel});
|
||||
inactiveSorters = _.union(_.filter(this.props.availableSorters, _.partial(checkSorter, _, false)), _.filter(this.props.labelSorters, _.partial(checkSorter, _, true)))
|
||||
.sort(function(sorter1, sorter2) {
|
||||
return utils.natsort(sorter1.title, sorter2.title, {insensitive: true});
|
||||
});
|
||||
.sort((sorter1, sorter2) => utils.natsort(sorter1.title, sorter2.title, {insensitive: true}));
|
||||
canResetSorters = _.any(this.props.activeSorters, {isLabel: true}) || !_(this.props.activeSorters).where({isLabel: false}).map(Sorter.toObject).isEqual(this.props.defaultSorting);
|
||||
|
||||
var checkFilter = _.bind(function(filter, isLabel) {
|
||||
return !_.any(this.props.activeFilters, {name: filter.name, isLabel: isLabel});
|
||||
}, this);
|
||||
var checkFilter = (filter, isLabel) => !_.any(this.props.activeFilters, {name: filter.name, isLabel: isLabel});
|
||||
inactiveFilters = _.union(_.filter(this.props.availableFilters, _.partial(checkFilter, _, false)), _.filter(this.props.labelFilters, _.partial(checkFilter, _, true)))
|
||||
.sort(function(filter1, filter2) {
|
||||
return utils.natsort(filter1.title, filter2.title, {insensitive: true});
|
||||
});
|
||||
.sort((filter1, filter2) => utils.natsort(filter1.title, filter2.title, {insensitive: true}));
|
||||
appliedFilters = _.reject(this.props.activeFilters, (filter) => !filter.values.length);
|
||||
}
|
||||
|
||||
|
@ -1046,10 +1036,10 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
<button
|
||||
className='btn btn-default'
|
||||
disabled={this.state.actionInProgress}
|
||||
onClick={_.bind(function() {
|
||||
onClick={() => {
|
||||
this.props.revertChanges();
|
||||
this.changeScreen();
|
||||
}, this)}
|
||||
}}
|
||||
>
|
||||
{i18n('common.cancel_button')}
|
||||
</button>
|
||||
|
@ -1415,14 +1405,14 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
);
|
||||
|
||||
return Backbone.sync('update', nodes)
|
||||
.done(_.bind(function() {
|
||||
this.props.screenNodes.fetch().always(_.bind(function() {
|
||||
.done(() => {
|
||||
this.props.screenNodes.fetch().always(() => {
|
||||
dispatcher.trigger('labelsConfigurationUpdated');
|
||||
this.props.screenNodes.trigger('change');
|
||||
this.props.toggleLabelsPanel();
|
||||
}, this));
|
||||
}, this))
|
||||
.fail(function(response) {
|
||||
});
|
||||
})
|
||||
.fail((response) => {
|
||||
utils.showErrorDialog({
|
||||
message: i18n('cluster_page.nodes_tab.node_management_panel.node_management_error.labels_warning'),
|
||||
response: response
|
||||
|
@ -1556,9 +1546,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
roles = this.props.cluster.get('roles'),
|
||||
conflicts = _.chain(this.props.selectedRoles)
|
||||
.union(this.props.indeterminateRoles)
|
||||
.map(function(role) {
|
||||
return roles.find({name: role}).conflicts;
|
||||
})
|
||||
.map((role) => roles.find({name: role}).conflicts)
|
||||
.flatten()
|
||||
.uniq()
|
||||
.value(),
|
||||
|
@ -1639,14 +1627,12 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
var diskSizes = node.resource('disks');
|
||||
return i18n('node_details.disks_amount', {
|
||||
count: diskSizes.length,
|
||||
size: diskSizes.map(function(size) {
|
||||
return utils.showDiskSize(size) + ' ' + i18n('node_details.hdd');
|
||||
}).join(', ')
|
||||
size: diskSizes.map((size) => utils.showDiskSize(size) + ' ' + i18n('node_details.hdd')).join(', ')
|
||||
});
|
||||
};
|
||||
|
||||
var labelNs = 'cluster_page.nodes_tab.node_management_panel.labels.',
|
||||
getLabelValue = function(node, label) {
|
||||
getLabelValue = (node, label) => {
|
||||
var labelValue = node.getLabel(label);
|
||||
return labelValue === false ?
|
||||
i18n(labelNs + 'not_assigned_label', {label: label})
|
||||
|
@ -1657,7 +1643,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
label + ' "' + labelValue + '"';
|
||||
};
|
||||
|
||||
var groupingMethod = _.bind(function(node) {
|
||||
var groupingMethod = (node) => {
|
||||
return _.compact(_.map(this.props.activeSorters, function(sorter) {
|
||||
if (_.contains(uniqValueSorters, sorter.name)) return;
|
||||
|
||||
|
@ -1705,28 +1691,28 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
}
|
||||
return result;
|
||||
}, this)).join('; ');
|
||||
}, this);
|
||||
};
|
||||
var groups = _.pairs(_.groupBy(this.props.nodes, groupingMethod));
|
||||
|
||||
// sort grouped nodes by name, mac or ip
|
||||
var formattedSorters = _.compact(_.map(this.props.activeSorters, function(sorter) {
|
||||
var formattedSorters = _.compact(_.map(this.props.activeSorters, (sorter) => {
|
||||
if (_.contains(uniqValueSorters, sorter.name)) {
|
||||
return {attr: sorter.name, desc: sorter.order == 'desc'};
|
||||
}
|
||||
}));
|
||||
if (formattedSorters.length) {
|
||||
_.each(groups, function(group) {
|
||||
group[1].sort(function(node1, node2) {
|
||||
return utils.multiSort(node1, node2, formattedSorters);
|
||||
});
|
||||
_.each(groups, (group) => {
|
||||
group[1].sort((node1, node2) =>
|
||||
utils.multiSort(node1, node2, formattedSorters)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// sort grouped nodes by other applied sorters
|
||||
var preferredRolesOrder = this.props.roles.pluck('name');
|
||||
return groups.sort(_.bind(function(group1, group2) {
|
||||
return groups.sort((group1, group2) => {
|
||||
var result;
|
||||
_.each(this.props.activeSorters, function(sorter) {
|
||||
_.each(this.props.activeSorters, (sorter) => {
|
||||
var node1 = group1[1][0], node2 = group2[1][0];
|
||||
|
||||
if (sorter.isLabel) {
|
||||
|
@ -1784,9 +1770,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
result = result * -1;
|
||||
}
|
||||
return !_.isUndefined(result) && !result;
|
||||
}, this);
|
||||
});
|
||||
return result;
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
render() {
|
||||
var groups = this.groupNodes(),
|
||||
|
@ -1832,10 +1818,10 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
NodeGroup = React.createClass({
|
||||
mixins: [SelectAllMixin],
|
||||
render() {
|
||||
var availableNodes = this.props.nodes.filter(function(node) {return node.isSelectable();}),
|
||||
nodesWithRestrictionsIds = _.pluck(_.filter(availableNodes, function(node) {
|
||||
return _.any(this.props.rolesWithLimitReached, function(role) {return !node.hasRole(role);}, this);
|
||||
}, this), 'id');
|
||||
var availableNodes = this.props.nodes.filter((node) => node.isSelectable()),
|
||||
nodesWithRestrictionsIds = _.pluck(_.filter(availableNodes, (node) => {
|
||||
return _.any(this.props.rolesWithLimitReached, (role) => !node.hasRole(role));
|
||||
}), 'id');
|
||||
return (
|
||||
<div className='nodes-group'>
|
||||
<div className='row node-group-header'>
|
||||
|
|
|
@ -21,7 +21,7 @@ define(
|
|||
'i18n',
|
||||
'utils'
|
||||
],
|
||||
function($, _, React, i18n, utils) {
|
||||
($, _, React, i18n, utils) => {
|
||||
'use strict';
|
||||
|
||||
var ns = 'cluster_page.nodes_tab.configure_interfaces.',
|
||||
|
@ -42,14 +42,13 @@ function($, _, React, i18n, utils) {
|
|||
_.each(mode.sub, function(mode) {this.setModeState(mode, state);}, this);
|
||||
},
|
||||
checkModes(mode, sub) {
|
||||
var changedState = sub.reduce(
|
||||
(function(state, childMode) {
|
||||
if (!_.isEmpty(childMode.sub)) {
|
||||
this.checkModes(childMode, childMode.sub);
|
||||
}
|
||||
return (state === 0 || state === childMode.state) ? childMode.state : -1;
|
||||
}).bind(this),
|
||||
0
|
||||
var changedState = sub.reduce((state, childMode) => {
|
||||
if (!_.isEmpty(childMode.sub)) {
|
||||
this.checkModes(childMode, childMode.sub);
|
||||
}
|
||||
return (state === 0 || state === childMode.state) ? childMode.state : -1;
|
||||
},
|
||||
0
|
||||
),
|
||||
oldState;
|
||||
|
||||
|
@ -123,11 +122,11 @@ function($, _, React, i18n, utils) {
|
|||
return excerpt;
|
||||
},
|
||||
renderChildModes(modes, level) {
|
||||
return modes.map((function(mode) {
|
||||
return modes.map((mode) => {
|
||||
var lines = [
|
||||
<tr key={mode.name} className={'level' + level}>
|
||||
<td>{mode.name}</td>
|
||||
{[true, false, null].map((function(modeState) {
|
||||
{[true, false, null].map((modeState) => {
|
||||
var styles = {
|
||||
'btn-link': true,
|
||||
active: mode.state === modeState
|
||||
|
@ -142,14 +141,14 @@ function($, _, React, i18n, utils) {
|
|||
</button>
|
||||
</td>
|
||||
);
|
||||
}).bind(this))}
|
||||
})}
|
||||
</tr>
|
||||
];
|
||||
if (mode.sub) {
|
||||
return _.union([lines, this.renderChildModes(mode.sub, level + 1)]);
|
||||
}
|
||||
return lines;
|
||||
}).bind(this));
|
||||
});
|
||||
},
|
||||
render() {
|
||||
var modes = [],
|
||||
|
|
|
@ -23,7 +23,7 @@ define(
|
|||
'views/controls',
|
||||
'views/custom_controls'
|
||||
],
|
||||
function(_, i18n, utils, React, Expression, controls, customControls) {
|
||||
(_, i18n, utils, React, Expression, controls, customControls) => {
|
||||
'use strict';
|
||||
|
||||
var SettingSection = React.createClass({
|
||||
|
@ -103,14 +103,14 @@ function(_, i18n, utils, React, Expression, controls, customControls) {
|
|||
currentSetting = this.props.settings.get(path);
|
||||
if (!this.areCalculationsPossible(currentSetting)) return [];
|
||||
var dependentRestrictions = {};
|
||||
var addDependentRestrictions = _.bind(function(pathToCheck, label) {
|
||||
var result = _.filter(this.props.settings.expandedRestrictions[pathToCheck], function(restriction) {
|
||||
var addDependentRestrictions = (pathToCheck, label) => {
|
||||
var result = _.filter(this.props.settings.expandedRestrictions[pathToCheck], (restriction) => {
|
||||
return restriction.action == 'disable' && _.contains(restriction.condition, 'settings:' + path);
|
||||
});
|
||||
if (result.length) {
|
||||
dependentRestrictions[label] = result.concat(dependentRestrictions[label] || []);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
// collect dependencies
|
||||
_.each(this.props.settings.attributes, function(section, sectionName) {
|
||||
// don't take into account hidden dependent settings
|
||||
|
@ -133,14 +133,14 @@ function(_, i18n, utils, React, Expression, controls, customControls) {
|
|||
pathToCheck = this.props.makePath(path, valueAttribute),
|
||||
valuesToCheck = this.getValuesToCheck(currentSetting, valueAttribute),
|
||||
checkValues = _.partial(this.checkValues, valuesToCheck, pathToCheck, currentSetting[valueAttribute]);
|
||||
return _.compact(_.map(dependentRestrictions, function(restrictions, label) {
|
||||
return _.compact(_.map(dependentRestrictions, (restrictions, label) => {
|
||||
if (_.any(restrictions, checkValues)) return label;
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
},
|
||||
composeOptions(values) {
|
||||
return _.map(values, function(value, index) {
|
||||
return _.map(values, (value, index) => {
|
||||
return (
|
||||
<option key={index} value={value.data} disabled={value.disabled}>
|
||||
{value.label}
|
||||
|
|
|
@ -25,7 +25,7 @@ define(
|
|||
'views/cluster_page_tabs/setting_section',
|
||||
'react-addons-transition-group'
|
||||
],
|
||||
function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSSTransitionGroup) {
|
||||
($, _, i18n, React, utils, models, componentMixins, SettingSection, CSSTransitionGroup) => {
|
||||
'use strict';
|
||||
|
||||
var SettingsTab = React.createClass({
|
||||
|
@ -47,9 +47,8 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
],
|
||||
statics: {
|
||||
fetchData(options) {
|
||||
return $.when(options.cluster.get('settings').fetch({cache: true}), options.cluster.get('networkConfiguration').fetch({cache: true})).then(function() {
|
||||
return {};
|
||||
});
|
||||
return $.when(options.cluster.get('settings').fetch({cache: true}),
|
||||
options.cluster.get('networkConfiguration').fetch({cache: true})).then(() => ({}));
|
||||
}
|
||||
},
|
||||
getInitialState() {
|
||||
|
@ -82,28 +81,27 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
|
||||
// collecting data to save
|
||||
var settings = this.props.cluster.get('settings'),
|
||||
dataToSave = this.props.cluster.isAvailableForSettingsChanges() ? settings.attributes : _.pick(settings.attributes, function(group) {
|
||||
return (group.metadata || {}).always_editable;
|
||||
});
|
||||
dataToSave = this.props.cluster.isAvailableForSettingsChanges() ? settings.attributes :
|
||||
_.pick(settings.attributes, (group) => (group.metadata || {}).always_editable);
|
||||
var options = {url: settings.url, patch: true, wait: true, validate: false},
|
||||
deferred = new models.Settings(_.cloneDeep(dataToSave)).save(null, options);
|
||||
if (deferred) {
|
||||
this.setState({actionInProgress: true});
|
||||
deferred
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.setState({initialAttributes: _.cloneDeep(settings.attributes)});
|
||||
// some networks may have restrictions which are processed by nailgun,
|
||||
// so networks need to be refetched after updating cluster attributes
|
||||
this.props.cluster.get('networkConfiguration').cancelThrottling();
|
||||
}, this))
|
||||
.always(_.bind(function() {
|
||||
})
|
||||
.always(() => {
|
||||
this.setState({
|
||||
actionInProgress: false,
|
||||
key: _.now()
|
||||
});
|
||||
this.props.cluster.fetch();
|
||||
}, this))
|
||||
.fail(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
utils.showErrorDialog({
|
||||
title: i18n('cluster_page.settings_tab.settings_error.title'),
|
||||
message: i18n('cluster_page.settings_tab.settings_error.saving_warning'),
|
||||
|
@ -125,7 +123,7 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
.done(() => {
|
||||
_.each(settings.attributes, (section, sectionName) => {
|
||||
if ((!lockedCluster || section.metadata.always_editable) && section.metadata.group != 'network') {
|
||||
_.each(section, function(setting, settingName) {
|
||||
_.each(section, (setting, settingName) => {
|
||||
// do not update hidden settings (hack for #1442143),
|
||||
// the same for settings with group network
|
||||
if (setting.type == 'hidden' || setting.group == 'network') return;
|
||||
|
@ -141,13 +139,13 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
key: _.now()
|
||||
});
|
||||
})
|
||||
.fail(
|
||||
(response) => utils.showErrorDialog({
|
||||
.fail((response) => {
|
||||
utils.showErrorDialog({
|
||||
title: i18n('cluster_page.settings_tab.settings_error.title'),
|
||||
message: i18n('cluster_page.settings_tab.settings_error.load_defaults_warning'),
|
||||
response: response
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
revertChanges() {
|
||||
|
@ -185,7 +183,7 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
settingsGroupList = settings.getGroupList(),
|
||||
locked = this.state.actionInProgress || !!cluster.task({group: 'deployment', active: true}),
|
||||
lockedCluster = !cluster.isAvailableForSettingsChanges(),
|
||||
someSettingsEditable = _.any(settings.attributes, function(group) {return group.metadata.always_editable;}),
|
||||
someSettingsEditable = _.any(settings.attributes, (group) => group.metadata.always_editable),
|
||||
hasChanges = this.hasChanges(),
|
||||
allocatedRoles = _.uniq(_.flatten(_.union(cluster.get('nodes').pluck('roles'), cluster.get('nodes').pluck('pending_roles')))),
|
||||
classes = {
|
||||
|
@ -194,7 +192,7 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
};
|
||||
|
||||
var invalidSections = {};
|
||||
_.each(settings.validationError, function(error, key) {
|
||||
_.each(settings.validationError, (error, key) => {
|
||||
invalidSections[_.first(key.split('.'))] = true;
|
||||
});
|
||||
|
||||
|
@ -234,7 +232,7 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
!this.checkRestrictions('hide', settings.makePath(sectionName, settingName)).result
|
||||
) return settingName;
|
||||
}, this)),
|
||||
hasErrors = _.any(pickedSettings, function(settingName) {
|
||||
hasErrors = _.any(pickedSettings, (settingName) => {
|
||||
return (settings.validationError || {})[settings.makePath(sectionName, settingName)];
|
||||
});
|
||||
if (!_.isEmpty(pickedSettings)) {
|
||||
|
@ -262,9 +260,7 @@ function($, _, i18n, React, utils, models, componentMixins, SettingSection, CSST
|
|||
{_.map(groupedSettings, function(selectedGroup, groupName) {
|
||||
if (groupName != this.props.activeSettingsSectionName) return null;
|
||||
|
||||
var sortedSections = _.sortBy(_.keys(selectedGroup), function(name) {
|
||||
return settings.get(name + '.metadata.weight');
|
||||
});
|
||||
var sortedSections = _.sortBy(_.keys(selectedGroup), (name) => settings.get(name + '.metadata.weight'));
|
||||
return (
|
||||
<div className={'col-xs-10 forms-box ' + groupName} key={groupName}>
|
||||
{_.map(sortedSections, function(sectionName) {
|
||||
|
|
|
@ -25,7 +25,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/wizard'
|
||||
],
|
||||
function($, _, i18n, React, models, utils, dispatcher, componentMixins, CreateClusterWizard) {
|
||||
($, _, i18n, React, models, utils, dispatcher, componentMixins, CreateClusterWizard) => {
|
||||
'use strict';
|
||||
var ClustersPage, ClusterList, Cluster;
|
||||
|
||||
|
@ -38,14 +38,12 @@ function($, _, i18n, React, models, utils, dispatcher, componentMixins, CreateCl
|
|||
var clusters = new models.Clusters();
|
||||
var nodes = new models.Nodes();
|
||||
var tasks = new models.Tasks();
|
||||
return $.when(clusters.fetch(), nodes.fetch(), tasks.fetch()).done(_.bind(function() {
|
||||
clusters.each(function(cluster) {
|
||||
return $.when(clusters.fetch(), nodes.fetch(), tasks.fetch()).done(() => {
|
||||
clusters.each((cluster) => {
|
||||
cluster.set('nodes', new models.Nodes(nodes.where({cluster: cluster.id})));
|
||||
cluster.set('tasks', new models.Tasks(tasks.where({cluster: cluster.id})));
|
||||
}, this);
|
||||
}, this)).then(function() {
|
||||
return {clusters: clusters};
|
||||
});
|
||||
}).then(() => ({clusters: clusters}));
|
||||
}
|
||||
},
|
||||
render() {
|
||||
|
@ -68,7 +66,7 @@ function($, _, i18n, React, models, utils, dispatcher, componentMixins, CreateCl
|
|||
render() {
|
||||
return (
|
||||
<div className='row'>
|
||||
{this.props.clusters.map(function(cluster) {
|
||||
{this.props.clusters.map((cluster) => {
|
||||
return <Cluster key={cluster.id} cluster={cluster} />;
|
||||
}, this)}
|
||||
<div key='create-cluster' className='col-xs-3'>
|
||||
|
@ -105,23 +103,23 @@ function($, _, i18n, React, models, utils, dispatcher, componentMixins, CreateCl
|
|||
var deletionTask = this.props.cluster.task('cluster_deletion');
|
||||
if (deletionTask) {
|
||||
request = deletionTask.fetch();
|
||||
request.fail(_.bind(function(response) {
|
||||
request.fail((response) => {
|
||||
if (response.status == 404) {
|
||||
this.props.cluster.collection.remove(this.props.cluster);
|
||||
dispatcher.trigger('updateNodeStats');
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
requests.push(request);
|
||||
}
|
||||
var deploymentTask = this.props.cluster.task({group: 'deployment', active: true});
|
||||
if (deploymentTask) {
|
||||
request = deploymentTask.fetch();
|
||||
request.done(_.bind(function() {
|
||||
request.done(() => {
|
||||
if (deploymentTask.match({active: false})) {
|
||||
this.props.cluster.fetch();
|
||||
dispatcher.trigger('updateNodeStats');
|
||||
}
|
||||
}, this));
|
||||
});
|
||||
requests.push(request);
|
||||
}
|
||||
return $.when(...requests);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
**/
|
||||
|
||||
define(['i18n', 'jquery', 'underscore', 'react', 'react-dom', 'utils', 'component_mixins'],
|
||||
function(i18n, $, _, React, ReactDOM, utils, componentMixins) {
|
||||
(i18n, $, _, React, ReactDOM, utils, componentMixins) => {
|
||||
'use strict';
|
||||
|
||||
var controls = {};
|
||||
|
@ -289,7 +289,7 @@ define(['i18n', 'jquery', 'underscore', 'react', 'react-dom', 'utils', 'componen
|
|||
<table className={utils.classNames(tableClasses)}>
|
||||
<thead>
|
||||
<tr>
|
||||
{_.map(this.props.head, function(column, index) {
|
||||
{_.map(this.props.head, (column, index) => {
|
||||
var classes = {};
|
||||
classes[column.className] = column.className;
|
||||
return <th key={index} className={utils.classNames(classes)}>{column.label}</th>;
|
||||
|
@ -297,9 +297,9 @@ define(['i18n', 'jquery', 'underscore', 'react', 'react-dom', 'utils', 'componen
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{_.map(this.props.body, function(row, rowIndex) {
|
||||
{_.map(this.props.body, (row, rowIndex) => {
|
||||
return <tr key={rowIndex}>
|
||||
{_.map(row, function(column, columnIndex) {
|
||||
{_.map(row, (column, columnIndex) => {
|
||||
return <td key={columnIndex} className='enable-selection'>{column}</td>;
|
||||
})}
|
||||
</tr>;
|
||||
|
|
|
@ -21,7 +21,7 @@ define([
|
|||
'react',
|
||||
'utils',
|
||||
'views/controls'
|
||||
], function($, _, i18n, React, utils, controls) {
|
||||
], ($, _, i18n, React, utils, controls) => {
|
||||
'use strict';
|
||||
|
||||
var customControls = {};
|
||||
|
@ -53,7 +53,7 @@ define([
|
|||
return _.compact(errors).length ? errors : null;
|
||||
},
|
||||
repoToString(repo, os) {
|
||||
var repoData = _.compact(this.defaultProps.repoAttributes[os].map(function(attribute) {return repo[attribute];}));
|
||||
var repoData = _.compact(this.defaultProps.repoAttributes[os].map((attribute) => repo[attribute]));
|
||||
if (!repoData.length) return ''; // in case of new repo
|
||||
return repoData.join(' ');
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ define([
|
|||
var repo = repos[index],
|
||||
match = value.match(this.props.repoRegexes[os]);
|
||||
if (match) {
|
||||
_.each(this.props.repoAttributes[os], function(attribute, index) {
|
||||
_.each(this.props.repoAttributes[os], (attribute, index) => {
|
||||
repo[attribute] = match[index + 1] || '';
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,7 @@ define(
|
|||
'component_mixins',
|
||||
'react-addons-linked-state-mixin'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, controls, componentMixins, LinkedStateMixin) {
|
||||
($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, controls, componentMixins, LinkedStateMixin) => {
|
||||
'use strict';
|
||||
|
||||
var dialogs = {};
|
||||
|
@ -179,7 +179,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
error = jsonObj.message;
|
||||
if (_.isObject(form)) {
|
||||
form.validationError = {};
|
||||
_.each(jsonObj.errors, function(value, name) {
|
||||
_.each(jsonObj.errors, (value, name) => {
|
||||
form.validationError['credentials.' + name] = value;
|
||||
});
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
},
|
||||
discardNodeChanges() {
|
||||
this.setState({actionInProgress: true});
|
||||
var nodes = new models.Nodes(this.props.nodes.map(function(node) {
|
||||
var nodes = new models.Nodes(this.props.nodes.map((node) => {
|
||||
if (node.get('pending_deletion')) return {
|
||||
id: node.id,
|
||||
pending_deletion: false
|
||||
|
@ -358,10 +358,10 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
dispatcher.trigger('deploymentTasksUpdated');
|
||||
var task = new models.Task();
|
||||
task.save({}, {url: _.result(this.props.cluster, 'url') + '/changes', type: 'PUT'})
|
||||
.done(function() {
|
||||
.done(() => {
|
||||
this.close();
|
||||
dispatcher.trigger('deploymentTaskStarted');
|
||||
}.bind(this))
|
||||
})
|
||||
.fail(this.showError);
|
||||
},
|
||||
renderBody() {
|
||||
|
@ -416,16 +416,16 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
this.setState({actionInProgress: true});
|
||||
var task = new models.Task();
|
||||
task.save({}, {url: _.result(this.props.cluster, 'url') + '/spawn_vms', type: 'PUT'})
|
||||
.done(function() {
|
||||
.done(() => {
|
||||
this.close();
|
||||
dispatcher.trigger('deploymentTaskStarted');
|
||||
}.bind(this))
|
||||
.fail(_.bind(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
this.showError(response, i18n('dialog.provision_vms.provision_vms_error'));
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
renderBody() {
|
||||
var vmsCount = this.props.cluster.get('nodes').where(function(node) {
|
||||
var vmsCount = this.props.cluster.get('nodes').where((node) => {
|
||||
return node.get('pending_addition') && node.hasRole('virt');
|
||||
}).length;
|
||||
return i18n('dialog.provision_vms.text', {count: vmsCount});
|
||||
|
@ -445,13 +445,13 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
this.setState({actionInProgress: true});
|
||||
var task = new models.Task();
|
||||
task.save({}, {url: _.result(this.props.cluster, 'url') + '/stop_deployment', type: 'PUT'})
|
||||
.done(function() {
|
||||
.done(() => {
|
||||
this.close();
|
||||
dispatcher.trigger('deploymentTaskStarted');
|
||||
}.bind(this))
|
||||
.fail(_.bind(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
this.showError(response, i18n('dialog.stop_deployment.stop_deployment_error.stop_deployment_warning'));
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
renderBody() {
|
||||
return (
|
||||
|
@ -560,10 +560,10 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
dispatcher.trigger('deploymentTasksUpdated');
|
||||
var task = new models.Task();
|
||||
task.save({}, {url: _.result(this.props.cluster, 'url') + '/reset', type: 'PUT'})
|
||||
.done(function() {
|
||||
.done(() => {
|
||||
this.close();
|
||||
dispatcher.trigger('deploymentTaskStarted');
|
||||
}.bind(this))
|
||||
})
|
||||
.fail(this.showError);
|
||||
},
|
||||
renderBody() {
|
||||
|
@ -581,9 +581,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
type='text'
|
||||
name='name'
|
||||
disabled={this.state.actionInProgress}
|
||||
onChange={_.bind(function(name, value) {
|
||||
onChange={(name, value) => {
|
||||
this.setState({confirmationError: value != clusterName});
|
||||
}, this)}
|
||||
}}
|
||||
onPaste={function(e) {e.preventDefault();}}
|
||||
autoFocus
|
||||
/>
|
||||
|
@ -641,22 +641,22 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
case 'memory':
|
||||
if (_.isArray(meta.memory.devices) && meta.memory.devices.length) {
|
||||
var sizes = _.countBy(_.pluck(meta.memory.devices, 'size'), utils.showMemorySize);
|
||||
summary = _.map(_.keys(sizes).sort(), function(size) {return sizes[size] + ' x ' + size;}).join(', ');
|
||||
summary = _.map(_.keys(sizes).sort(), (size) => sizes[size] + ' x ' + size).join(', ');
|
||||
summary += ', ' + utils.showMemorySize(meta.memory.total) + ' ' + i18n('dialog.show_node.total');
|
||||
} else summary = utils.showMemorySize(meta.memory.total) + ' ' + i18n('dialog.show_node.total');
|
||||
break;
|
||||
case 'disks':
|
||||
summary = meta.disks.length + ' ';
|
||||
summary += i18n('dialog.show_node.drive', {count: meta.disks.length});
|
||||
summary += ', ' + utils.showDiskSize(_.reduce(_.pluck(meta.disks, 'size'), function(sum, n) {return sum + n;}, 0)) + ' ' + i18n('dialog.show_node.total');
|
||||
summary += ', ' + utils.showDiskSize(_.reduce(_.pluck(meta.disks, 'size'), (sum, n) => sum + n, 0)) + ' ' + i18n('dialog.show_node.total');
|
||||
break;
|
||||
case 'cpu':
|
||||
var frequencies = _.countBy(_.pluck(meta.cpu.spec, 'frequency'), utils.showFrequency);
|
||||
summary = _.map(_.keys(frequencies).sort(), function(frequency) {return frequencies[frequency] + ' x ' + frequency;}).join(', ');
|
||||
summary = _.map(_.keys(frequencies).sort(), (frequency) => frequencies[frequency] + ' x ' + frequency).join(', ');
|
||||
break;
|
||||
case 'interfaces':
|
||||
var bandwidths = _.countBy(_.pluck(meta.interfaces, 'current_speed'), utils.showBandwidth);
|
||||
summary = _.map(_.keys(bandwidths).sort(), function(bandwidth) {return bandwidths[bandwidth] + ' x ' + bandwidth;}).join(', ');
|
||||
summary = _.map(_.keys(bandwidths).sort(), (bandwidth) => bandwidths[bandwidth] + ' x ' + bandwidth).join(', ');
|
||||
break;
|
||||
}
|
||||
} catch (ignore) {}
|
||||
|
@ -694,12 +694,12 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
VMsConfModel.url = _.result(this.props.node, 'url') + '/vms_conf';
|
||||
this.setProps({VMsConfModel: VMsConfModel});
|
||||
this.setState({actionInProgress: true});
|
||||
VMsConfModel.fetch().always(_.bind(function() {
|
||||
VMsConfModel.fetch().always(() => {
|
||||
this.setState({
|
||||
actionInProgress: false,
|
||||
VMsConf: JSON.stringify(VMsConfModel.get('vms_conf'))
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
setDialogTitle() {
|
||||
|
@ -708,9 +708,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
},
|
||||
assignAccordionEvents() {
|
||||
$('.panel-collapse', ReactDOM.findDOMNode(this))
|
||||
.on('show.bs.collapse', function(e) {$(e.currentTarget).siblings('.panel-heading').find('i').removeClass('glyphicon-plus').addClass('glyphicon-minus');})
|
||||
.on('hide.bs.collapse', function(e) {$(e.currentTarget).siblings('.panel-heading').find('i').removeClass('glyphicon-minus').addClass('glyphicon-plus');})
|
||||
.on('hidden.bs.collapse', function(e) {e.stopPropagation();});
|
||||
.on('show.bs.collapse', (e) => {$(e.currentTarget).siblings('.panel-heading').find('i').removeClass('glyphicon-plus').addClass('glyphicon-minus');})
|
||||
.on('hide.bs.collapse', (e) => {$(e.currentTarget).siblings('.panel-heading').find('i').removeClass('glyphicon-minus').addClass('glyphicon-plus');})
|
||||
.on('hidden.bs.collapse', (e) => {e.stopPropagation();});
|
||||
},
|
||||
toggle(groupIndex) {
|
||||
$(ReactDOM.findDOMNode(this.refs['togglable_' + groupIndex])).collapse('toggle');
|
||||
|
@ -728,12 +728,12 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
if (parsedVMsConf) {
|
||||
this.setState({actionInProgress: true});
|
||||
this.props.VMsConfModel.save({vms_conf: parsedVMsConf}, {method: 'PUT'})
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
this.setState({VMsConfValidationError: utils.getResponseText(response)});
|
||||
}, this))
|
||||
.always(_.bind(function() {
|
||||
})
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
startHostnameRenaming(e) {
|
||||
|
@ -1046,7 +1046,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
},
|
||||
deleteNodes() {
|
||||
this.setState({actionInProgress: true});
|
||||
var nodes = new models.Nodes(this.props.nodes.map(function(node) {
|
||||
var nodes = new models.Nodes(this.props.nodes.map((node) => {
|
||||
// mark deployed node as pending deletion
|
||||
if (node.get('status') == 'ready') return {
|
||||
id: node.id,
|
||||
|
@ -1061,17 +1061,17 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
};
|
||||
}));
|
||||
Backbone.sync('update', nodes)
|
||||
.then(_.bind(function() {
|
||||
.then(() => {
|
||||
return this.props.cluster.fetchRelated('nodes');
|
||||
}, this))
|
||||
.done(_.bind(function() {
|
||||
})
|
||||
.done(() => {
|
||||
dispatcher.trigger('updateNodeStats networkConfigurationUpdated labelsConfigurationUpdated');
|
||||
this.state.result.resolve();
|
||||
this.close();
|
||||
}, this))
|
||||
.fail(_.bind(function(response) {
|
||||
})
|
||||
.fail((response) => {
|
||||
this.showError(response, i18n('cluster_page.nodes_tab.node_deletion_error.node_deletion_warning'));
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1166,15 +1166,15 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
var keystoneClient = app.keystoneClient;
|
||||
this.setState({actionInProgress: true});
|
||||
keystoneClient.changePassword(this.state.currentPassword, this.state.newPassword)
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
dispatcher.trigger(this.state.newPassword == keystoneClient.DEFAULT_PASSWORD ? 'showDefaultPasswordWarning' : 'hideDefaultPasswordWarning');
|
||||
app.user.set({token: keystoneClient.token});
|
||||
this.close();
|
||||
}, this))
|
||||
.fail(_.bind(function() {
|
||||
})
|
||||
.fail(() => {
|
||||
this.setState({validationError: true, actionInProgress: false});
|
||||
$(this.refs.currentPassword.getInputDOMNode()).focus();
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1200,15 +1200,15 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
componentDidMount() {
|
||||
var registrationForm = this.props.registrationForm;
|
||||
registrationForm.fetch()
|
||||
.then(null, function() {
|
||||
.then(null, () => {
|
||||
registrationForm.url = registrationForm.nailgunUrl;
|
||||
return registrationForm.fetch();
|
||||
})
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
this.showResponseErrors(response);
|
||||
this.setState({connectionError: true});
|
||||
}, this))
|
||||
.always(_.bind(function() {this.setState({loading: false});}, this));
|
||||
})
|
||||
.always(() => {this.setState({loading: false});});
|
||||
},
|
||||
onChange(inputName, value) {
|
||||
var registrationForm = this.props.registrationForm,
|
||||
|
@ -1217,7 +1217,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
registrationForm.set(name, value);
|
||||
},
|
||||
composeOptions(values) {
|
||||
return _.map(values, function(value, index) {
|
||||
return _.map(values, (value, index) => {
|
||||
return (
|
||||
<option key={index} value={value.data}>
|
||||
{value.label}
|
||||
|
@ -1246,7 +1246,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
var registrationForm = this.props.registrationForm;
|
||||
this.setState({actionInProgress: true});
|
||||
registrationForm.save(registrationForm.attributes, {type: 'POST'})
|
||||
.done(_.bind(function(response) {
|
||||
.done((response) => {
|
||||
var currentAttributes = _.cloneDeep(this.props.settings.attributes);
|
||||
|
||||
var collector = function(path) {
|
||||
|
@ -1258,16 +1258,16 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
_.each(['email', 'password'], collector('tracking'), this);
|
||||
|
||||
this.props.saveSettings(currentAttributes)
|
||||
.done(_.bind(function() {
|
||||
.done(() => {
|
||||
this.props.tracking.set(this.props.settings.attributes);
|
||||
this.props.setConnected();
|
||||
this.close();
|
||||
}, this));
|
||||
}, this))
|
||||
.fail(_.bind(function(response) {
|
||||
});
|
||||
})
|
||||
.fail((response) => {
|
||||
this.setState({actionInProgress: false});
|
||||
this.showResponseErrors(response, registrationForm);
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
checkCountry() {
|
||||
var country = this.props.registrationForm.attributes.credentials.country.value;
|
||||
|
@ -1281,7 +1281,7 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
error = this.state.error,
|
||||
sortedFields = _.chain(_.keys(fieldsList))
|
||||
.without('metadata')
|
||||
.sortBy(function(inputName) {return fieldsList[inputName].weight;})
|
||||
.sortBy((inputName) => fieldsList[inputName].weight)
|
||||
.value(),
|
||||
halfWidthField = ['first_name', 'last_name', 'company', 'phone', 'country', 'region'];
|
||||
return (
|
||||
|
@ -1360,15 +1360,15 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
componentDidMount() {
|
||||
var remoteRetrievePasswordForm = this.props.remoteRetrievePasswordForm;
|
||||
remoteRetrievePasswordForm.fetch()
|
||||
.then(null, function() {
|
||||
.then(null, () => {
|
||||
remoteRetrievePasswordForm.url = remoteRetrievePasswordForm.nailgunUrl;
|
||||
return remoteRetrievePasswordForm.fetch();
|
||||
})
|
||||
.fail(_.bind(function(response) {
|
||||
.fail((response) => {
|
||||
this.showResponseErrors(response);
|
||||
this.setState({connectionError: true});
|
||||
}, this))
|
||||
.always(_.bind(function() {this.setState({loading: false});}, this));
|
||||
})
|
||||
.always(() => {this.setState({loading: false});});
|
||||
},
|
||||
onChange(inputName, value) {
|
||||
var remoteRetrievePasswordForm = this.props.remoteRetrievePasswordForm;
|
||||
|
@ -1382,9 +1382,9 @@ function($, _, i18n, Backbone, React, ReactDOM, utils, models, dispatcher, contr
|
|||
remoteRetrievePasswordForm.save()
|
||||
.done(this.passwordSent)
|
||||
.fail(this.showResponseErrors)
|
||||
.always(_.bind(function() {
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
passwordSent() {
|
||||
|
|
|
@ -23,7 +23,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/cluster_page_tabs/nodes_tab_screens/node_list_screen'
|
||||
],
|
||||
function($, _, i18n, React, models, componentMixins, NodeListScreen) {
|
||||
($, _, i18n, React, models, componentMixins, NodeListScreen) => {
|
||||
'use strict';
|
||||
|
||||
var EquipmentPage, PluginLinks;
|
||||
|
|
|
@ -26,7 +26,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/dialogs'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, utils, models, controls, componentMixins, dialogs) {
|
||||
($, _, i18n, Backbone, React, utils, models, controls, componentMixins, dialogs) => {
|
||||
'use strict';
|
||||
|
||||
var components = {};
|
||||
|
@ -42,14 +42,14 @@ function($, _, i18n, Backbone, React, utils, models, controls, componentMixins,
|
|||
componentMixins.pollingMixin(20)
|
||||
],
|
||||
togglePopover(popoverName) {
|
||||
return _.memoize(_.bind(function(visible) {
|
||||
this.setState(function(previousState) {
|
||||
return _.memoize((visible) => {
|
||||
this.setState((previousState) => {
|
||||
var nextState = {};
|
||||
var key = popoverName + 'PopoverVisible';
|
||||
nextState[key] = _.isBoolean(visible) ? visible : !previousState[key];
|
||||
return nextState;
|
||||
});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
setActive(url) {
|
||||
this.setState({activeElement: url});
|
||||
|
@ -291,7 +291,7 @@ function($, _, i18n, Backbone, React, utils, models, controls, componentMixins,
|
|||
if (notificationsToMark.length) {
|
||||
this.setState({unreadNotificationsIds: notificationsToMark.pluck('id')});
|
||||
notificationsToMark.toJSON = function() {
|
||||
return notificationsToMark.map(function(notification) {
|
||||
return notificationsToMark.map((notification) => {
|
||||
notification.set({status: 'read'});
|
||||
return _.pick(notification.attributes, 'id', 'status');
|
||||
}, this);
|
||||
|
@ -379,7 +379,7 @@ function($, _, i18n, Backbone, React, utils, models, controls, componentMixins,
|
|||
render() {
|
||||
return (
|
||||
<ol className='breadcrumb'>
|
||||
{_.map(this.state.path, function(breadcrumb, index) {
|
||||
{_.map(this.state.path, (breadcrumb, index) => {
|
||||
if (!_.isArray(breadcrumb)) breadcrumb = [breadcrumb, null, {active: true}];
|
||||
var text = breadcrumb[0];
|
||||
var link = breadcrumb[1];
|
||||
|
|
|
@ -23,7 +23,7 @@ define(
|
|||
'dispatcher',
|
||||
'utils'
|
||||
],
|
||||
function($, _, i18n, React, ReactDOM, dispatcher, utils) {
|
||||
($, _, i18n, React, ReactDOM, dispatcher, utils) => {
|
||||
'use strict';
|
||||
|
||||
var LoginPage = React.createClass({
|
||||
|
@ -114,9 +114,9 @@ function($, _, i18n, React, ReactDOM, dispatcher, utils) {
|
|||
this.setState({actionInProgress: true});
|
||||
|
||||
this.login(username, password)
|
||||
.fail(_.bind(function() {
|
||||
.fail(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
render() {
|
||||
var httpsUsed = location.protocol == 'https:';
|
||||
|
|
|
@ -23,7 +23,7 @@ define(
|
|||
'views/dialogs',
|
||||
'component_mixins'
|
||||
],
|
||||
function(_, i18n, React, utils, models, dialogs, componentMixins) {
|
||||
(_, i18n, React, utils, models, dialogs, componentMixins) => {
|
||||
'use strict';
|
||||
|
||||
var NotificationsPage, Notification;
|
||||
|
@ -36,9 +36,9 @@ function(_, i18n, React, utils, models, dialogs, componentMixins) {
|
|||
breadcrumbsPath: [['home', '#'], 'notifications'],
|
||||
fetchData() {
|
||||
var notifications = app.notifications;
|
||||
return notifications.fetch().then(function() {
|
||||
return {notifications: notifications};
|
||||
});
|
||||
return notifications.fetch().then(() =>
|
||||
({notifications: notifications})
|
||||
);
|
||||
}
|
||||
},
|
||||
checkDateIsToday(date) {
|
||||
|
@ -59,12 +59,12 @@ function(_, i18n, React, utils, models, dialogs, componentMixins) {
|
|||
<div className='title col-xs-12'>
|
||||
{this.checkDateIsToday(date) ? i18n('notifications_page.today') : date}
|
||||
</div>
|
||||
{_.map(notifications, function(notification) {
|
||||
{_.map(notifications, (notification) => {
|
||||
return <Notification
|
||||
key={notification.id}
|
||||
notification={notification}
|
||||
/>;
|
||||
}, this)}
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}, this)}
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'models',
|
||||
'utils'
|
||||
],
|
||||
function($, _, i18n, React, models, utils) {
|
||||
($, _, i18n, React, models, utils) => {
|
||||
'use strict';
|
||||
|
||||
var PluginsPage = React.createClass({
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'views/controls',
|
||||
'component_mixins'
|
||||
],
|
||||
function(_, i18n, React, models, controls, componentMixins) {
|
||||
(_, i18n, React, models, controls, componentMixins) => {
|
||||
'use strict';
|
||||
|
||||
var ReleasesPage = React.createClass({
|
||||
|
@ -40,7 +40,7 @@ function(_, i18n, React, models, controls, componentMixins) {
|
|||
}
|
||||
},
|
||||
getReleaseData(release) {
|
||||
return _.map(this.props.columns, function(attr) {
|
||||
return _.map(this.props.columns, (attr) => {
|
||||
if (attr == 'state') {
|
||||
return i18n('release_page.release.' + (release.get(attr)));
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ function(_, i18n, React, models, controls, componentMixins) {
|
|||
<div className='row'>
|
||||
<div className='col-xs-12 content-elements'>
|
||||
<controls.Table
|
||||
head={_.map(this.props.columns, function(column) {
|
||||
return {label: i18n('release_page.' + column), className: column};
|
||||
head={_.map(this.props.columns, (column) => {
|
||||
return ({label: i18n('release_page.' + column), className: column});
|
||||
})}
|
||||
body={this.props.releases.map(this.getReleaseData)}
|
||||
/>
|
||||
|
|
|
@ -23,7 +23,7 @@ define([
|
|||
'component_mixins',
|
||||
'react-dnd',
|
||||
'react-dnd-html5-backend'
|
||||
], function(_, i18n, React, utils, layoutComponents, dispatcher, componentMixins, DND, HTML5Backend) {
|
||||
], (_, i18n, React, utils, layoutComponents, dispatcher, componentMixins, DND, HTML5Backend) => {
|
||||
'use strict';
|
||||
|
||||
var RootComponent = React.createClass({
|
||||
|
|
|
@ -22,7 +22,7 @@ define([
|
|||
'models',
|
||||
'views/dialogs',
|
||||
'views/controls'
|
||||
], function($, _, i18n, React, utils, models, dialogs, controls) {
|
||||
], ($, _, i18n, React, utils, models, dialogs, controls) => {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
|
@ -49,13 +49,13 @@ define([
|
|||
var settings = this.props.settings;
|
||||
this.setState({actionInProgress: true});
|
||||
return settings.save(null, {patch: true, wait: true, validate: false})
|
||||
.fail(function(response) {
|
||||
.fail((response) => {
|
||||
if (initialAttributes) settings.set(initialAttributes);
|
||||
utils.showErrorDialog({response: response});
|
||||
})
|
||||
.always(_.bind(function() {
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
prepareStatisticsToSave() {
|
||||
var currentAttributes = _.cloneDeep(this.props.settings.attributes);
|
||||
|
@ -100,16 +100,16 @@ define([
|
|||
if (this.props.tracking.isValid({models: this.configModels})) {
|
||||
var remoteLoginForm = this.state.remoteLoginForm;
|
||||
this.setState({actionInProgress: true});
|
||||
_.each(tracking, function(data, inputName) {
|
||||
_.each(tracking, (data, inputName) => {
|
||||
var name = remoteLoginForm.makePath('credentials', inputName, 'value');
|
||||
remoteLoginForm.set(name, tracking[inputName].value);
|
||||
}, this);
|
||||
});
|
||||
remoteLoginForm.save()
|
||||
.done(this.prepareTrackingToSave)
|
||||
.fail(this.showResponseErrors)
|
||||
.always(_.bind(function() {
|
||||
.always(() => {
|
||||
this.setState({actionInProgress: false});
|
||||
}, this));
|
||||
});
|
||||
}
|
||||
},
|
||||
checkRestrictions(name, action) {
|
||||
|
@ -156,7 +156,7 @@ define([
|
|||
<div key={key}>
|
||||
{i18n('statistics.' + key + '_title')}
|
||||
<ul>
|
||||
{_.map(list, function(item) {
|
||||
{_.map(list, (item) => {
|
||||
return <li key={item}>{i18n('statistics.' + key + '.' + item)}</li>;
|
||||
})}
|
||||
</ul>
|
||||
|
@ -228,7 +228,7 @@ define([
|
|||
if (!this.state.isConnected) {
|
||||
var tracking = this.props.tracking,
|
||||
initialData = this.props.settings.get('tracking');
|
||||
_.each(tracking.get('tracking'), function(data, name) {
|
||||
_.each(tracking.get('tracking'), (data, name) => {
|
||||
var path = tracking.makePath('tracking', name, 'value');
|
||||
tracking.set(path, initialData[name].value);
|
||||
});
|
||||
|
@ -239,7 +239,7 @@ define([
|
|||
var tracking = model.get('tracking'),
|
||||
sortedFields = _.chain(_.keys(tracking))
|
||||
.without('metadata')
|
||||
.sortBy(function(inputName) {return tracking[inputName].weight;})
|
||||
.sortBy((inputName) => tracking[inputName].weight)
|
||||
.value();
|
||||
return (
|
||||
<div>
|
||||
|
|
|
@ -25,7 +25,7 @@ define(
|
|||
'models',
|
||||
'views/statistics_mixin'
|
||||
],
|
||||
function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisticsMixin) {
|
||||
($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisticsMixin) => {
|
||||
'use strict';
|
||||
|
||||
var SupportPage = React.createClass({
|
||||
|
@ -38,7 +38,7 @@ function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisti
|
|||
breadcrumbsPath: [['home', '#'], 'support'],
|
||||
fetchData() {
|
||||
var tasks = new models.Tasks();
|
||||
return $.when(app.fuelSettings.fetch({cache: true}), tasks.fetch()).then(function() {
|
||||
return $.when(app.fuelSettings.fetch({cache: true}), tasks.fetch()).then(() => {
|
||||
var tracking = new models.FuelSettings(_.cloneDeep(app.fuelSettings.attributes)),
|
||||
statistics = new models.FuelSettings(_.cloneDeep(app.fuelSettings.attributes));
|
||||
return {
|
||||
|
@ -71,7 +71,7 @@ function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisti
|
|||
<h1 className='title'>{i18n('support_page.title')}</h1>
|
||||
</div>
|
||||
<div className='content-box'>
|
||||
{_.reduce(elements, function(result, element, index) {
|
||||
{_.reduce(elements, (result, element, index) => {
|
||||
if (index) result.push(<hr key={index} />);
|
||||
result.push(element);
|
||||
return result;
|
||||
|
@ -170,7 +170,7 @@ function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisti
|
|||
hasChanges() {
|
||||
var initialData = this.props.settings.get('statistics'),
|
||||
currentData = this.props.statistics.get('statistics');
|
||||
return _.any(this.props.statsCheckboxes, function(field) {
|
||||
return _.any(this.props.statsCheckboxes, (field) => {
|
||||
return !_.isEqual(initialData[field].value, currentData[field].value);
|
||||
});
|
||||
},
|
||||
|
@ -184,7 +184,7 @@ function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisti
|
|||
var statistics = this.props.statistics.get('statistics'),
|
||||
sortedSettings = _.chain(_.keys(statistics))
|
||||
.without('metadata')
|
||||
.sortBy(function(settingName) {return statistics[settingName].weight;}, this)
|
||||
.sortBy((settingName) => statistics[settingName].weight)
|
||||
.value();
|
||||
return (
|
||||
<SupportPageElement
|
||||
|
@ -242,9 +242,9 @@ function($, _, i18n, Backbone, React, dialogs, componentMixins, models, statisti
|
|||
return this.isDumpTaskActive();
|
||||
},
|
||||
fetchData() {
|
||||
return this.props.task.fetch().done(_.bind(function() {
|
||||
return this.props.task.fetch().done(() => {
|
||||
if (!this.isDumpTaskActive()) this.setState({generating: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
isDumpTaskActive() {
|
||||
return this.props.task && this.props.task.match({active: true});
|
||||
|
|
|
@ -22,7 +22,7 @@ define(
|
|||
'component_mixins',
|
||||
'views/statistics_mixin'
|
||||
],
|
||||
function(_, i18n, React, models, componentMixins, statisticsMixin) {
|
||||
(_, i18n, React, models, componentMixins, statisticsMixin) => {
|
||||
'use strict';
|
||||
|
||||
var WelcomePage = React.createClass({
|
||||
|
@ -34,7 +34,7 @@ function(_, i18n, React, models, componentMixins, statisticsMixin) {
|
|||
title: i18n('welcome_page.title'),
|
||||
hiddenLayout: true,
|
||||
fetchData() {
|
||||
return app.fuelSettings.fetch().then(function() {
|
||||
return app.fuelSettings.fetch().then(() => {
|
||||
var tracking = new models.FuelSettings(_.cloneDeep(app.fuelSettings.attributes));
|
||||
tracking.processRestrictions();
|
||||
return {
|
||||
|
@ -54,13 +54,13 @@ function(_, i18n, React, models, componentMixins, statisticsMixin) {
|
|||
this.setState({locked: true});
|
||||
this.props.settings.set(this.props.tracking.attributes);
|
||||
this.saveSettings(currentAttributes)
|
||||
.done(function() {
|
||||
.done(() => {
|
||||
app.navigate('', {trigger: true});
|
||||
})
|
||||
.fail(_.bind(function() {
|
||||
.fail(() => {
|
||||
statistics.user_choice_saved.value = false;
|
||||
this.setState({locked: false});
|
||||
}, this));
|
||||
});
|
||||
},
|
||||
render() {
|
||||
var ns = 'welcome_page.',
|
||||
|
|
|
@ -27,7 +27,7 @@ define(
|
|||
'views/dialogs',
|
||||
'views/controls'
|
||||
],
|
||||
function($, _, i18n, React, ReactDOM, Backbone, utils, models, componentMixins, dialogs, controls) {
|
||||
($, _, i18n, React, ReactDOM, Backbone, utils, models, componentMixins, dialogs, controls) => {
|
||||
'use strict';
|
||||
|
||||
var AVAILABILITY_STATUS_ICONS = {
|
||||
|
@ -308,7 +308,7 @@ function($, _, i18n, React, ReactDOM, Backbone, utils, models, componentMixins,
|
|||
onChange={this.props.onChange}
|
||||
>
|
||||
{
|
||||
releases.map(function(release) {
|
||||
releases.map((release) => {
|
||||
if (!release.get('is_deployable')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -554,18 +554,18 @@ function($, _, i18n, React, ReactDOM, Backbone, utils, models, componentMixins,
|
|||
this.wizard.set({cluster: this.cluster, clusters: this.props.clusters});
|
||||
},
|
||||
componentDidMount() {
|
||||
this.releases.fetch().done(_.bind(function() {
|
||||
this.releases.fetch().done(() => {
|
||||
var defaultRelease = this.releases.findWhere({is_deployable: true});
|
||||
this.wizard.set('release', defaultRelease.id);
|
||||
this.selectRelease(defaultRelease.id);
|
||||
this.setState({loading: false});
|
||||
}, this));
|
||||
});
|
||||
|
||||
this.updateState({activePaneIndex: 0});
|
||||
},
|
||||
getListOfTypesToRestore(currentIndex, maxIndex) {
|
||||
var panesTypes = [];
|
||||
_.each(clusterWizardPanes, function(pane, paneIndex) {
|
||||
_.each(clusterWizardPanes, (pane, paneIndex) => {
|
||||
if ((paneIndex <= maxIndex) && (paneIndex > currentIndex) && pane.componentType) {
|
||||
panesTypes.push(pane.componentType);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue