item.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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('../../../../../../global/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. download: 'a.download'
  14. },
  15. events: {
  16. 'click @ui.renew': function (e) {
  17. e.preventDefault();
  18. App.Controller.showNginxCertificateRenew(this.model);
  19. },
  20. 'click @ui.delete': function (e) {
  21. e.preventDefault();
  22. App.Controller.showNginxCertificateDeleteConfirm(this.model);
  23. },
  24. 'click @ui.host_link': function (e) {
  25. e.preventDefault();
  26. let win = window.open($(e.currentTarget).attr('rel'), '_blank');
  27. win.focus();
  28. },
  29. 'click @ui.download': function (e) {
  30. e.preventDefault();
  31. App.Api.Nginx.Certificates.download(this.model.get('id'))
  32. }
  33. },
  34. templateContext: {
  35. canManage: App.Cache.User.canManage('certificates'),
  36. isExpired: function () {
  37. return moment(this.expires_on).isBefore(moment());
  38. },
  39. dns_providers: dns_providers
  40. },
  41. initialize: function () {
  42. this.listenTo(this.model, 'change', this.render);
  43. }
  44. });