mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Functionality to remove server from manager
This commit is contained in:
parent
957e665ff2
commit
fca9580bd8
31
manager.js
31
manager.js
@ -84,7 +84,10 @@ Server.prototype.stop = function(cb) {
|
||||
if (!handled) {
|
||||
handled = true;
|
||||
self.emit('stopped');
|
||||
cb();
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -94,7 +97,10 @@ Server.prototype.stop = function(cb) {
|
||||
if (!handled) {
|
||||
handled = true;
|
||||
self.emit('stopped');
|
||||
cb();
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
@ -126,6 +132,27 @@ Manager.prototype.addServer = (function (id, title) {
|
||||
return server;
|
||||
});
|
||||
|
||||
Manager.prototype.removeServer = (function (id) {
|
||||
var server = this.serversHash[id];
|
||||
|
||||
if (!server) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var index = this.serversArr.indexOf(server);
|
||||
if (index > -1) {
|
||||
this.serversArr.splice(index, 1);
|
||||
}
|
||||
delete this.serversHash[id];
|
||||
this.save();
|
||||
|
||||
if (server.pid) {
|
||||
server.stop();
|
||||
}
|
||||
|
||||
return server;
|
||||
});
|
||||
|
||||
Manager.prototype._addServer = (function (id, title, port, mods) {
|
||||
var server = new Server(id, title, port, mods);
|
||||
this.serversArr.push(server);
|
||||
|
@ -12,6 +12,14 @@ define(function (require) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: "tr",
|
||||
template: template
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .delete": "delete"
|
||||
},
|
||||
|
||||
delete: function (event) {
|
||||
this.model.destroy({wait: true});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +1,6 @@
|
||||
<td>
|
||||
<a href='#servers/<%-id%>'><%-title%></a>
|
||||
<button type="button" class="btn btn-danger btn-xs delete pull-right">
|
||||
<span class="glyphicon glyphicon-remove"></span> Delete
|
||||
</button>
|
||||
</td>
|
||||
|
@ -67,7 +67,8 @@ exports.update = function(req, res){
|
||||
};
|
||||
|
||||
exports.destroy = function(req, res){
|
||||
res.send('destroy server ' + req.params.server);
|
||||
var server = manager.removeServer(req.params.server);
|
||||
res.send(server);
|
||||
};
|
||||
|
||||
exports.start = function (req, res){
|
||||
|
Loading…
Reference in New Issue
Block a user