mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Mission rotation
This commit is contained in:
parent
7c299a1c00
commit
daaefa4fa1
@ -98,6 +98,7 @@ Manager.prototype.save = (function () {
|
||||
battle_eye: server.battle_eye,
|
||||
headless: server.headless,
|
||||
max_players: server.max_players,
|
||||
missions: server.missions,
|
||||
mods: server.mods,
|
||||
password: server.password,
|
||||
persistent: server.persistent,
|
||||
|
@ -43,6 +43,7 @@ Server.prototype.update = function (options) {
|
||||
this.battle_eye = options.battle_eye;
|
||||
this.headless = options.headless;
|
||||
this.max_players = options.max_players;
|
||||
this.missions = options.missions;
|
||||
this.mods = options.mods || [];
|
||||
this.password = options.password;
|
||||
this.persistent = options.persistent;
|
||||
@ -83,6 +84,7 @@ Server.prototype.start = function() {
|
||||
headlessClients: this.headless ? ["127.0.0.1"] : null,
|
||||
hostname: createServerTitle(this.title),
|
||||
localClient: this.headless ? ["127.0.0.1"] : null,
|
||||
missions: this.missions,
|
||||
mods: this.mods,
|
||||
password: this.password,
|
||||
passwordAdmin: this.admin_password,
|
||||
@ -192,6 +194,7 @@ Server.prototype.toJSON = function () {
|
||||
headless: this.headless,
|
||||
id: this.id,
|
||||
max_players: this.max_players,
|
||||
missions: this.missions,
|
||||
mods: this.mods,
|
||||
password: this.password,
|
||||
persistent: this.persistent,
|
||||
|
14
public/js/app/collections/mission_rotations.js
Normal file
14
public/js/app/collections/mission_rotations.js
Normal file
@ -0,0 +1,14 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
MissionRotation = require('app/models/mission_rotation');
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: MissionRotation,
|
||||
});
|
||||
|
||||
});
|
16
public/js/app/models/mission_rotation.js
Normal file
16
public/js/app/models/mission_rotation.js
Normal file
@ -0,0 +1,16 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone');
|
||||
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
name: '',
|
||||
difficulty: 'recruit',
|
||||
},
|
||||
});
|
||||
|
||||
});
|
@ -74,7 +74,11 @@ define(function (require) {
|
||||
server: function (id) {
|
||||
var server = servers.get(id);
|
||||
if (server) {
|
||||
layoutView.content.show(new ServerView({model: server, mods: mods}));
|
||||
layoutView.content.show(new ServerView({
|
||||
model: server,
|
||||
missions: missions,
|
||||
mods: mods,
|
||||
}));
|
||||
} else {
|
||||
this.navigate("#", true);
|
||||
}
|
||||
|
28
public/js/app/views/servers/missions/available/list.js
Normal file
28
public/js/app/views/servers/missions/available/list.js
Normal file
@ -0,0 +1,28 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
ListItemView = require('app/views/servers/missions/available/list_item'),
|
||||
tpl = require('text!tpl/servers/missions/available/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
buildItemView: function(item, ItemViewType, itemViewOptions){
|
||||
var self = this;
|
||||
var options = _.extend({model: item}, itemViewOptions);
|
||||
var view = new ItemViewType(options);
|
||||
view.on('add', function (model) {
|
||||
self.trigger('add', model);
|
||||
});
|
||||
return view;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
25
public/js/app/views/servers/missions/available/list_item.js
Normal file
25
public/js/app/views/servers/missions/available/list_item.js
Normal file
@ -0,0 +1,25 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/servers/missions/available/list_item.html'),
|
||||
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: "tr",
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .add": "add"
|
||||
},
|
||||
|
||||
add: function () {
|
||||
this.trigger('add', this.model);
|
||||
},
|
||||
});
|
||||
});
|
50
public/js/app/views/servers/missions/index.js
Normal file
50
public/js/app/views/servers/missions/index.js
Normal file
@ -0,0 +1,50 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
MissionRotations = require('app/collections/mission_rotations'),
|
||||
AvailableListView = require('app/views/servers/missions/available/list'),
|
||||
RotationListView = require('app/views/servers/missions/rotation/list'),
|
||||
tpl = require('text!tpl/servers/missions/index.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
regions: {
|
||||
availableView: "#available",
|
||||
rotationView: "#rotation",
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.missions = options.missions;
|
||||
this.server = options.server;
|
||||
|
||||
this.rotationCollection = new MissionRotations(this.server.get('missions'));
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
var self = this;
|
||||
|
||||
var availableListView = new AvailableListView({collection: this.missions});
|
||||
availableListView.on('add', function (model) {
|
||||
self.rotationCollection.add([{
|
||||
name: model.get('name').replace('.pbo', ''),
|
||||
}]);
|
||||
});
|
||||
var rotationListView = new RotationListView({collection: this.rotationCollection});
|
||||
|
||||
this.availableView.show(availableListView);
|
||||
this.rotationView.show(rotationListView);
|
||||
},
|
||||
|
||||
serialize : function() {
|
||||
return {
|
||||
missions: this.rotationCollection.toJSON(),
|
||||
};
|
||||
},
|
||||
});
|
||||
});
|
28
public/js/app/views/servers/missions/rotation/list.js
Normal file
28
public/js/app/views/servers/missions/rotation/list.js
Normal file
@ -0,0 +1,28 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
MissionRotation = require('app/models/mission_rotation'),
|
||||
ListItemView = require('app/views/servers/missions/rotation/list_item'),
|
||||
tpl = require('text!tpl/servers/missions/rotation/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
"click .add-mission": "addMission",
|
||||
},
|
||||
|
||||
addMission: function (e) {
|
||||
e.preventDefault();
|
||||
this.collection.add(new MissionRotation());
|
||||
},
|
||||
});
|
||||
|
||||
});
|
39
public/js/app/views/servers/missions/rotation/list_item.js
Normal file
39
public/js/app/views/servers/missions/rotation/list_item.js
Normal file
@ -0,0 +1,39 @@
|
||||
define(function (require) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/servers/missions/rotation/list_item.html'),
|
||||
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: "tr",
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click button.delete": "delete",
|
||||
"change select#difficulty": "changed",
|
||||
"change input#name": "changed",
|
||||
},
|
||||
|
||||
changed: function (e) {
|
||||
var val = $(e.target).val();
|
||||
this.model.set(e.target.id, val);
|
||||
},
|
||||
|
||||
delete: function (e) {
|
||||
e.preventDefault();
|
||||
this.model.destroy();
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
var difficulty = this.model.get('difficulty');
|
||||
var $option = this.$el.find("#difficulty option[value='" + difficulty + "']");
|
||||
$option.attr("selected", "selected");
|
||||
},
|
||||
});
|
||||
});
|
@ -9,6 +9,7 @@ define(function (require) {
|
||||
Mods = require('app/collections/mods'),
|
||||
FormView = require('app/views/servers/form'),
|
||||
InfoView = require('app/views/servers/info'),
|
||||
MissionsView = require('app/views/servers/missions/index'),
|
||||
ModsListView = require('app/views/servers/mods/list'),
|
||||
PlayersView = require('app/views/servers/players'),
|
||||
tpl = require('text!tpl/servers/view.html');
|
||||
@ -18,6 +19,7 @@ define(function (require) {
|
||||
|
||||
regions: {
|
||||
infoView: "#tab-info",
|
||||
missionsView: "#tab-missions",
|
||||
modsView: "#tab-mods",
|
||||
playersView: "#tab-players",
|
||||
settingsView: "#tab-settings",
|
||||
@ -33,11 +35,13 @@ define(function (require) {
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.missions = options.missions;
|
||||
this.mods = options.mods;
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
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.playersView.show(new PlayersView({model: this.model}));
|
||||
this.settingsView.show(new FormView({model: this.model}));
|
||||
@ -45,6 +49,7 @@ define(function (require) {
|
||||
|
||||
serverUpdated: function() {
|
||||
this.infoView.currentView.render();
|
||||
this.missionsView.currentView.render();
|
||||
this.modsView.currentView.render();
|
||||
this.playersView.currentView.render();
|
||||
this.settingsView.currentView.render();
|
||||
@ -55,6 +60,7 @@ define(function (require) {
|
||||
var self = this;
|
||||
var oldId = this.model.get('id');
|
||||
var data = this.settingsView.currentView.serialize();
|
||||
_.extend(data, this.missionsView.currentView.serialize());
|
||||
_.extend(data, this.modsView.currentView.serialize());
|
||||
this.model.save(data, {
|
||||
success: function() {
|
||||
|
13
public/js/tpl/servers/missions/available/list.html
Normal file
13
public/js/tpl/servers/missions/available/list.html
Normal file
@ -0,0 +1,13 @@
|
||||
<form>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mission</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- want to insert collection items, here -->
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</form>
|
11
public/js/tpl/servers/missions/available/list_item.html
Normal file
11
public/js/tpl/servers/missions/available/list_item.html
Normal file
@ -0,0 +1,11 @@
|
||||
<td>
|
||||
<%-name%>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-xs add pull-right">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
Add
|
||||
</a>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</td>
|
4
public/js/tpl/servers/missions/index.html
Normal file
4
public/js/tpl/servers/missions/index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-push-6" id="rotation"></div>
|
||||
<div class="col-md-6 col-md-pull-6" id="available"></div>
|
||||
</div>
|
17
public/js/tpl/servers/missions/rotation/list.html
Normal file
17
public/js/tpl/servers/missions/rotation/list.html
Normal file
@ -0,0 +1,17 @@
|
||||
<form>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Rotation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- want to insert collection items, here -->
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<a class="btn btn-primary add-mission" href="#">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
Add empty mission
|
||||
</a>
|
31
public/js/tpl/servers/missions/rotation/list_item.html
Normal file
31
public/js/tpl/servers/missions/rotation/list_item.html
Normal file
@ -0,0 +1,31 @@
|
||||
<td>
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-2 control-label">Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="name" placeholder="Name" value="<%- name %>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="difficulty" class="col-sm-2 control-label">Difficulty</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="difficulty" class="form-control">
|
||||
<option value="recruit">Recruit</option>
|
||||
<option value="regular">Regular</option>
|
||||
<option value="veteran">Veteran</option>
|
||||
<option value="mercenary">Mercenary</option>
|
||||
</select>
|
||||
</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>
|
@ -8,6 +8,7 @@
|
||||
<ul class="nav nav-tabs" style="margin-bottom: 15px;">
|
||||
<li class="active"><a href="#tab-info" data-toggle="tab">Info</a></li>
|
||||
<li><a href="#tab-mods" data-toggle="tab">Mods</a></li>
|
||||
<li><a href="#tab-missions" data-toggle="tab">Missions</a></li>
|
||||
<li><a href="#tab-players" data-toggle="tab">Players</a></li>
|
||||
<li><a href="#tab-settings" data-toggle="tab">Settings</a></li>
|
||||
</ul>
|
||||
@ -16,6 +17,7 @@
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab-info"></div>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user