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

59 lines
1.5 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'),
swal = require('sweet-alert'),
2014-04-06 21:09:52 +00:00
tpl = require('text!tpl/servers/info.html');
2014-04-08 21:49:40 +00:00
return Marionette.Layout.extend({
2014-04-04 08:20:13 +00:00
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();
sweetAlert({
title: "Are you sure?",
text: "The server will stopped.",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-warning",
confirmButtonText: "Yes, stop it!",
},
function(){
$.ajax({
url: "/api/servers/" + self.model.get('id') + "/stop",
type: 'GET',
success: function (resp) {
self.model.set("pid", resp.pid);
self.render();
},
error: $.noop
});
2014-04-06 21:09:52 +00:00
});
},
2014-04-04 08:20:13 +00:00
});
2014-04-06 21:09:52 +00:00
});