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

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-07-25 18:23:32 -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',
edit: 'a.edit',
delete: 'a.delete',
host_link: '.host-link'
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.DeadHosts[this.model.get('enabled') ? 'disable' : 'enable'](id)
.then(() => {
return App.Api.Nginx.DeadHosts.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.showNginxDeadForm(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.showNginxDeadDeleteConfirm(this.model);
},
'click @ui.host_link': function (e) {
e.preventDefault();
let win = window.open($(e.currentTarget).attr('rel'), '_blank');
win.focus();
2018-07-08 21:22:10 -04:00
}
},
templateContext: {
canManage: App.Cache.User.canManage('dead_hosts'),
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);
}
});