Merge "Logs page selected item in an expanded drop-box behaviour fix"
This commit is contained in:
commit
104bf4194e
|
@ -109,7 +109,8 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
<div className='title'>{i18n('cluster_page.logs_tab.title')}</div>
|
||||
<div className='col-xs-12 content-elements'>
|
||||
<LogFilterBar
|
||||
{... _.pick(this.props, 'cluster', 'selectedLogs', 'changeLogSelection')}
|
||||
{... _.pick(this.props, 'selectedLogs', 'changeLogSelection')}
|
||||
nodes={this.props.cluster.get('nodes')}
|
||||
showLogs={this.showLogs}
|
||||
onShowButtonClick={this.onShowButtonClick}
|
||||
/>
|
||||
|
@ -133,6 +134,8 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
});
|
||||
|
||||
var LogFilterBar = React.createClass({
|
||||
// PureRenderMixin added for prevention the rerender LogFilterBar (because of polling) in Mozilla browser
|
||||
mixins: [React.addons.PureRenderMixin],
|
||||
getInitialState: function() {
|
||||
return _.extend({}, this.props.selectedLogs, {
|
||||
sourcesLoadingState: 'loading',
|
||||
|
@ -142,23 +145,13 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
});
|
||||
},
|
||||
fetchSources: function(type, nodeId) {
|
||||
var cluster = this.props.cluster,
|
||||
nodes = cluster.get('nodes'),
|
||||
var nodes = this.props.nodes,
|
||||
chosenNodeId = nodeId || (nodes.length ? nodes.first().id : null);
|
||||
this.sources = new models.LogSources();
|
||||
if (type == 'remote') {
|
||||
if (chosenNodeId) {
|
||||
this.sources.deferred = this.sources.fetch({url: '/api/logs/sources/nodes/' + chosenNodeId});
|
||||
}
|
||||
} else if (!cluster.get('log_sources')) {
|
||||
this.sources.deferred = this.sources.fetch();
|
||||
this.sources.deferred.done(_.bind(function() {
|
||||
cluster.set('log_sources', this.sources.toJSON());
|
||||
}, this));
|
||||
} else {
|
||||
this.sources.reset(cluster.get('log_sources'));
|
||||
this.sources.deferred = $.Deferred().resolve();
|
||||
}
|
||||
this.sources.deferred = (type == 'remote' && chosenNodeId) ?
|
||||
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');}),
|
||||
chosenSource = _.findWhere(filteredSources, {id: this.state.source}) || _.first(filteredSources),
|
||||
|
@ -283,7 +276,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
},
|
||||
renderTypeSelect: function() {
|
||||
var types = [['local', 'Fuel Master']];
|
||||
if (this.props.cluster.get('nodes').length) {
|
||||
if (this.props.nodes.length) {
|
||||
types.push(['remote', 'Other servers']);
|
||||
}
|
||||
var typeOptions = types.map(function(type) {
|
||||
|
@ -302,7 +295,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
</div>;
|
||||
},
|
||||
renderNodeSelect: function() {
|
||||
var sortedNodes = this.props.cluster.get('nodes').models.sort(_.partialRight(utils.compare, {attr: 'name'})),
|
||||
var sortedNodes = this.props.nodes.models.sort(_.partialRight(utils.compare, {attr: 'name'})),
|
||||
nodeOptions = sortedNodes.map(function(node) {
|
||||
return <option value={node.id} key={node.id}>{node.get('name') || node.get('mac')}</option>;
|
||||
});
|
||||
|
@ -335,7 +328,7 @@ function($, _, i18n, React, utils, models, componentMixins, controls) {
|
|||
</div>;
|
||||
},
|
||||
renderLevelSelect: function() {
|
||||
var levelOptions = {};
|
||||
var levelOptions = [];
|
||||
if (this.state.source && this.state.sources.length) {
|
||||
levelOptions = this.state.sources.get(this.state.source).get('levels').map(function(level) {
|
||||
return <option value={level} key={level}>{level}</option>;
|
||||
|
|
Loading…
Reference in New Issue