arma-server-web-admin/public/js/app/views/servers/info.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-04-04 08:20:13 +00:00
define(function (require) {
2014-04-06 21:09:52 +00:00
2014-04-04 08:20:13 +00:00
"use strict";
2014-04-06 21:09:52 +00:00
2014-04-04 08:20:13 +00:00
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
2014-04-06 21:09:52 +00:00
tpl = require('text!tpl/servers/info.html');
2014-04-04 08:20:13 +00:00
return Marionette.ItemView.extend({
template: _.template(tpl),
2014-04-06 21:09:52 +00:00
events: {
2014-04-06 22:58:17 +00:00
"click #start": "start",
"click #stop": "stop",
2014-04-06 21:09:52 +00:00
},
start: function (event) {
var self = this;
event.preventDefault();
$.ajax({
url: "/api/servers/" + this.model.get('id') + "/start",
type: 'GET',
success: function (resp) {
2014-04-06 22:58:17 +00:00
self.model.set("pid", resp.pid);
self.render();
},
error: $.noop
});
},
stop: function (event) {
var self = this;
event.preventDefault();
$.ajax({
url: "/api/servers/" + this.model.get('id') + "/stop",
type: 'GET',
success: function (resp) {
self.model.set("pid", resp.pid);
self.render();
2014-04-06 21:09:52 +00:00
},
error: $.noop
});
},
2014-04-04 08:20:13 +00:00
});
2014-04-06 21:09:52 +00:00
});