MCSM: отображение реального списка серверов
This commit is contained in:
@@ -14,8 +14,22 @@ var ContentModule = React.createClass({
|
||||
style.onerror = fnError;
|
||||
document.body.appendChild(style);
|
||||
},
|
||||
requestServerList: function() {
|
||||
var _this = this;
|
||||
fetch('/mcsmanager/servers.json')
|
||||
.then(function(response) {
|
||||
response.json().then(function(data) {
|
||||
console.debug(data);
|
||||
_this.setState({serverList: data})
|
||||
});
|
||||
})
|
||||
.catch(function(err){
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
getInitialState: function(){return{
|
||||
nvScriptReady: 0
|
||||
nvScriptReady: 0,
|
||||
serverList: []
|
||||
}},
|
||||
componentWillMount: function(){
|
||||
var _this = this;
|
||||
@@ -36,12 +50,19 @@ var ContentModule = React.createClass({
|
||||
},
|
||||
function(){ _this.setState({nvScriptReady: -5}); console.error('d3 - error'); }
|
||||
);
|
||||
|
||||
this.requestServerList();
|
||||
},
|
||||
render: function(){
|
||||
var element;
|
||||
if (this.state.nvScriptReady === 3) {
|
||||
var serverListItems = [];
|
||||
this.state.serverList.forEach(function(item){
|
||||
serverListItems.push(ce(ServerListItem, {title: item}));
|
||||
});
|
||||
|
||||
element = ce('div', {className: 'row'},
|
||||
ce('div', {className: 'col-md-4'}, ce(ServerList)),
|
||||
ce('div', {className: 'col-md-4'}, ce(ServerList, null, serverListItems)),
|
||||
ce('div', {className: 'col-md-8'},
|
||||
ce('div', {className: 'pull-right'},
|
||||
ce('div', {className: 'btn-group'},
|
||||
|
||||
Reference in New Issue
Block a user