arma-server-web-admin/public/js/app/models/server.js
2019-12-10 15:56:54 +01:00

67 lines
1.3 KiB
JavaScript

var $ = require('jquery')
var Backbone = require('backbone')
module.exports = Backbone.Model.extend({
defaults: {
additionalConfigurationOptions: '',
admin_password: '',
allowed_file_patching: 1,
auto_start: false,
battle_eye: false,
file_patching: false,
forcedDifficulty: '',
max_players: null,
mods: [],
motd: '',
number_of_headless_clients: 0,
parameters: [],
password: '',
persistent: false,
port: 2302,
state: null,
title: '',
von: false,
verify_signatures: false
},
urlRoot: '/api/servers/',
start: function (cb) {
var self = this
$.ajax({
url: '/api/servers/' + self.get('id') + '/start',
type: 'POST',
success: function (resp) {
self.set('pid', resp.pid)
if (cb) {
cb()
}
},
error: function (err) {
if (cb) {
cb(err)
}
}
})
},
stop: function (cb) {
var self = this
$.ajax({
url: '/api/servers/' + self.get('id') + '/stop',
type: 'POST',
success: function (resp) {
self.set('pid', resp.pid)
if (cb) {
cb()
}
},
error: function (err) {
if (cb) {
cb(err)
}
}
})
}
})