nginx-proxy-manager/frontend/js/app/nginx/stream/list/item.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

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: {
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: {
'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: {
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);
}
});