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: {
|
2019-01-03 06:04:11 -05:00
|
|
|
able: 'a.able',
|
2018-10-19 02:51:31 -04:00
|
|
|
edit: 'a.edit',
|
|
|
|
delete: 'a.delete',
|
|
|
|
host_link: '.host-link'
|
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.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);
|
2018-10-19 02:51:31 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
'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: {
|
2018-08-02 05:48:47 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|