mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
62 lines
1.2 KiB
JavaScript
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()
|
|
})
|
|
})
|
|
}
|
|
})
|