Archived
0

MCSM: отображение реального списка серверов

This commit is contained in:
2017-05-01 14:42:16 +03:00
parent 26352ef17e
commit c8fc952ffc
5 changed files with 58 additions and 29 deletions

View File

@@ -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'},