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

62 lines
1.2 KiB
JavaScript

var _ = require('underscore')
var Marionette = require('marionette')
var sweetAlert = require('sweet-alert')
var tpl = require('tpl/servers/info.html')
module.exports = Marionette.LayoutView.extend({
template: _.template(tpl),
events: {
'click #start': 'start',
'click #stop': 'stop'
},
start: function (event) {
var self = this
event.preventDefault()
this.model.start(function (err) {
if (err) {
sweetAlert({
title: 'Error',
text: err.responseText,
type: 'error'
})
return
}
self.render()
})
},
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 () {
event.preventDefault()
self.model.stop(function (err) {
if (err) {
sweetAlert({
title: 'Error',
text: err.responseText,
type: 'error'
})
return
}
self.render()
})
})
}
})