mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Merge pull request #26 from Dahlgren/feature/startup-parameters
Startup Parameters
This commit is contained in:
commit
cac9a7f15c
@ -44,7 +44,11 @@ path | Folder path to game server
|
||||
port | Web port to use
|
||||
host | IP or Hostname to listen on
|
||||
type | Which kind of server to use, can be 'linux', 'windows' or 'wine'
|
||||
parameters | Extra startup parameters added to servers and headless clients
|
||||
serverMods | Mods that always and only will be used by the game servers
|
||||
auth | If both username and password is set, HTTP Basic Auth will be used
|
||||
prefix | Text prepended to all game servers name
|
||||
suffix | Text appended to all game servers name
|
||||
|
||||
## How to Use
|
||||
|
||||
|
@ -4,6 +4,10 @@ module.exports = {
|
||||
port: 3000,
|
||||
host: '0.0.0.0', // Can be either an IP or a Hostname
|
||||
type: 'linux', // Can be either linux, windows or wine
|
||||
parameters: [ // Additional startup parameters used by all servers
|
||||
'-noSound',
|
||||
'-world=empty'
|
||||
],
|
||||
serverMods: [ // Mods used exclusively by server and not shared with clients
|
||||
'@mod1',
|
||||
'@mod2',
|
||||
|
@ -101,6 +101,7 @@ Manager.prototype.save = (function () {
|
||||
max_players: server.max_players,
|
||||
missions: server.missions,
|
||||
mods: server.mods,
|
||||
parameters: server.parameters,
|
||||
password: server.password,
|
||||
persistent: server.persistent,
|
||||
port: server.port,
|
||||
|
@ -47,6 +47,7 @@ Server.prototype.update = function (options) {
|
||||
this.missions = options.missions;
|
||||
this.mods = options.mods || [];
|
||||
this.password = options.password;
|
||||
this.parameters = options.parameters;
|
||||
this.persistent = options.persistent;
|
||||
this.port = options.port || 2302;
|
||||
this.title = options.title;
|
||||
@ -85,6 +86,16 @@ Server.prototype.queryStatus = function() {
|
||||
};
|
||||
|
||||
Server.prototype.start = function() {
|
||||
var parameters = [];
|
||||
|
||||
if (config.parameters && Array.isArray(config.parameters)) {
|
||||
parameters = parameters.concat(config.parameters);
|
||||
}
|
||||
|
||||
if (this.parameters && Array.isArray(this.parameters)) {
|
||||
parameters = parameters.concat(this.parameters);
|
||||
}
|
||||
|
||||
var server = new ArmaServer.Server({
|
||||
battleEye: this.battle_eye ? 1 : 0,
|
||||
config: this.id,
|
||||
@ -95,6 +106,7 @@ Server.prototype.start = function() {
|
||||
localClient: this.headless ? ["127.0.0.1"] : null,
|
||||
missions: this.missions,
|
||||
mods: this.mods,
|
||||
parameters: parameters,
|
||||
password: this.password,
|
||||
passwordAdmin: this.admin_password,
|
||||
path: this.config.path,
|
||||
@ -151,6 +163,7 @@ Server.prototype.start = function() {
|
||||
game: config.game,
|
||||
host: "127.0.0.1",
|
||||
mods: this.mods,
|
||||
parameters: parameters,
|
||||
password: this.password,
|
||||
path: this.config.path,
|
||||
platform: this.config.type,
|
||||
@ -220,6 +233,7 @@ Server.prototype.toJSON = function () {
|
||||
max_players: this.max_players,
|
||||
missions: this.missions,
|
||||
mods: this.mods,
|
||||
parameters: this.parameters,
|
||||
password: this.password,
|
||||
persistent: this.persistent,
|
||||
pid: this.pid,
|
||||
|
14
public/js/app/collections/parameters.js
Normal file
14
public/js/app/collections/parameters.js
Normal file
@ -0,0 +1,14 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Parameter = require('app/models/parameter');
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: Parameter,
|
||||
});
|
||||
|
||||
});
|
15
public/js/app/models/parameter.js
Normal file
15
public/js/app/models/parameter.js
Normal file
@ -0,0 +1,15 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone');
|
||||
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
parameter: ''
|
||||
},
|
||||
});
|
||||
|
||||
});
|
@ -13,6 +13,7 @@ define(function (require) {
|
||||
headless: false,
|
||||
max_players: null,
|
||||
mods: [],
|
||||
parameters: [],
|
||||
password: '',
|
||||
persistent: false,
|
||||
port: 2302,
|
||||
|
47
public/js/app/views/servers/parameters/list.js
Normal file
47
public/js/app/views/servers/parameters/list.js
Normal file
@ -0,0 +1,47 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
Parameter = require('app/models/parameter'),
|
||||
Parameters = require('app/collections/parameters'),
|
||||
ListItemView = require('app/views/servers/parameters/list_item'),
|
||||
tpl = require('text!tpl/servers/parameters/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
"click .add-parameter": "addParameter",
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.model = options.server;
|
||||
|
||||
this.collection = new Parameters(this.model.get('parameters').map(function (parameter) {
|
||||
return new Parameter({
|
||||
parameter: parameter,
|
||||
});
|
||||
}));
|
||||
},
|
||||
|
||||
addParameter: function (e) {
|
||||
e.preventDefault();
|
||||
this.collection.add(new Parameter());
|
||||
},
|
||||
|
||||
serialize : function() {
|
||||
return {
|
||||
parameters: this.collection.map(function (parameter) {
|
||||
return parameter.get('parameter');
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
});
|
32
public/js/app/views/servers/parameters/list_item.js
Normal file
32
public/js/app/views/servers/parameters/list_item.js
Normal file
@ -0,0 +1,32 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/servers/parameters/list_item.html'),
|
||||
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: "tr",
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click button.delete": "delete",
|
||||
"change input#parameter": "changed",
|
||||
},
|
||||
|
||||
changed: function (e) {
|
||||
var val = $(e.target).val();
|
||||
this.model.set(e.target.id, val);
|
||||
},
|
||||
|
||||
delete: function (e) {
|
||||
e.preventDefault();
|
||||
this.model.destroy();
|
||||
},
|
||||
});
|
||||
});
|
@ -11,6 +11,7 @@ define(function (require) {
|
||||
InfoView = require('app/views/servers/info'),
|
||||
MissionsView = require('app/views/servers/missions/index'),
|
||||
ModsListView = require('app/views/servers/mods/list'),
|
||||
ParametersListView = require('app/views/servers/parameters/list'),
|
||||
PlayersView = require('app/views/servers/players'),
|
||||
tpl = require('text!tpl/servers/view.html');
|
||||
|
||||
@ -21,8 +22,9 @@ define(function (require) {
|
||||
infoView: "#tab-info",
|
||||
missionsView: "#tab-missions",
|
||||
modsView: "#tab-mods",
|
||||
parametersView: "#parameters",
|
||||
playersView: "#tab-players",
|
||||
settingsView: "#tab-settings",
|
||||
settingsView: "#settings",
|
||||
},
|
||||
|
||||
events: {
|
||||
@ -43,6 +45,7 @@ define(function (require) {
|
||||
this.infoView.show(new InfoView({model: this.model}));
|
||||
this.missionsView.show(new MissionsView({missions: this.missions, server: this.model}));
|
||||
this.modsView.show(new ModsListView({collection: this.mods, server: this.model}));
|
||||
this.parametersView.show(new ParametersListView({server: this.model}));
|
||||
this.playersView.show(new PlayersView({model: this.model}));
|
||||
this.settingsView.show(new FormView({model: this.model}));
|
||||
},
|
||||
@ -50,6 +53,7 @@ define(function (require) {
|
||||
serverUpdated: function() {
|
||||
this.infoView.currentView.render();
|
||||
this.modsView.currentView.render();
|
||||
this.parametersView.currentView.render();
|
||||
this.playersView.currentView.render();
|
||||
this.settingsView.currentView.render();
|
||||
},
|
||||
@ -61,6 +65,7 @@ define(function (require) {
|
||||
var data = this.settingsView.currentView.serialize();
|
||||
_.extend(data, this.missionsView.currentView.serialize());
|
||||
_.extend(data, this.modsView.currentView.serialize());
|
||||
_.extend(data, this.parametersView.currentView.serialize());
|
||||
this.model.save(data, {
|
||||
success: function() {
|
||||
var newId = self.model.get('id');
|
||||
|
26
public/js/tpl/servers/parameters/list.html
Normal file
26
public/js/tpl/servers/parameters/list.html
Normal file
@ -0,0 +1,26 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<a class="btn btn-primary btn-xs add-parameter pull-right" href="#">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
Add new parameter
|
||||
</a>
|
||||
<span>Startup Parameters</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- want to insert collection items, here -->
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<p>The following startup parameters are used by the Web UI:</p>
|
||||
<ul>
|
||||
<li>-config (Required to set title among others)</li>
|
||||
<li>-mod</li>
|
||||
<li>-port</li>
|
||||
<li>-serverMod</li>
|
||||
</ul>
|
||||
</div>
|
19
public/js/tpl/servers/parameters/list_item.html
Normal file
19
public/js/tpl/servers/parameters/list_item.html
Normal file
@ -0,0 +1,19 @@
|
||||
<td>
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-2 control-label">Parameter</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="parameter" placeholder="Parameter" value="<%- parameter %>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button class="btn btn-xs btn-danger delete">
|
||||
<span class="glyphicon glyphicon-minus"></span>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
@ -22,5 +22,8 @@
|
||||
<div class="tab-pane" id="tab-mods"></div>
|
||||
<div class="tab-pane" id="tab-missions"></div>
|
||||
<div class="tab-pane" id="tab-players"></div>
|
||||
<div class="tab-pane" id="tab-settings"></div>
|
||||
<div class="tab-pane" id="tab-settings">
|
||||
<div id="settings"></div>
|
||||
<div id="parameters"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user