item.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const Mn = require('backbone.marionette');
  2. const moment = require('moment');
  3. const App = require('../../../main');
  4. const template = require('./item.ejs');
  5. const dns_providers = require('../../../../../../utils/certbot-dns-plugins')
  6. module.exports = Mn.View.extend({
  7. template: template,
  8. tagName: 'tr',
  9. ui: {
  10. host_link: '.host-link',
  11. renew: 'a.renew',
  12. delete: 'a.delete'
  13. },
  14. events: {
  15. 'click @ui.renew': function (e) {
  16. e.preventDefault();
  17. App.Controller.showNginxCertificateRenew(this.model);
  18. },
  19. 'click @ui.delete': function (e) {
  20. e.preventDefault();
  21. App.Controller.showNginxCertificateDeleteConfirm(this.model);
  22. },
  23. 'click @ui.host_link': function (e) {
  24. e.preventDefault();
  25. let win = window.open($(e.currentTarget).attr('rel'), '_blank');
  26. win.focus();
  27. }
  28. },
  29. templateContext: {
  30. canManage: App.Cache.User.canManage('certificates'),
  31. isExpired: function () {
  32. return moment(this.expires_on).isBefore(moment());
  33. },
  34. dns_providers: dns_providers
  35. },
  36. initialize: function () {
  37. this.listenTo(this.model, 'change', this.render);
  38. }
  39. });