2018-07-24 04:33:00 -04:00
|
|
|
const Mn = require('backbone.marionette');
|
|
|
|
const App = require('../../../main');
|
|
|
|
const template = require('./item.ejs');
|
2018-07-08 21:22:10 -04:00
|
|
|
|
|
|
|
module.exports = Mn.View.extend({
|
|
|
|
template: template,
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
ui: {
|
2019-01-03 06:04:11 -05:00
|
|
|
able: 'a.able',
|
2018-07-24 04:33:00 -04:00
|
|
|
edit: 'a.edit',
|
|
|
|
delete: 'a.delete'
|
2018-07-08 21:22:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
2019-01-03 06:04:11 -05:00
|
|
|
'click @ui.able': function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
let id = this.model.get('id');
|
|
|
|
App.Api.Nginx.Streams[this.model.get('enabled') ? 'disable' : 'enable'](id)
|
|
|
|
.then(() => {
|
|
|
|
return App.Api.Nginx.Streams.get(id)
|
|
|
|
.then(row => {
|
|
|
|
this.model.set(row);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-07-08 21:22:10 -04:00
|
|
|
'click @ui.edit': function (e) {
|
|
|
|
e.preventDefault();
|
2018-07-25 18:23:32 -04:00
|
|
|
App.Controller.showNginxStreamForm(this.model);
|
2018-07-08 21:22:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
'click @ui.delete': function (e) {
|
|
|
|
e.preventDefault();
|
2018-07-25 18:23:32 -04:00
|
|
|
App.Controller.showNginxStreamDeleteConfirm(this.model);
|
2018-07-08 21:22:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
templateContext: {
|
2018-08-02 05:48:47 -04:00
|
|
|
canManage: App.Cache.User.canManage('streams'),
|
|
|
|
|
|
|
|
isOnline: function () {
|
|
|
|
return typeof this.meta.nginx_online === 'undefined' ? null : this.meta.nginx_online;
|
|
|
|
},
|
|
|
|
|
|
|
|
getOfflineError: function () {
|
|
|
|
return this.meta.nginx_err || '';
|
|
|
|
}
|
2018-07-08 21:22:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
|
}
|
|
|
|
});
|