Skip to content

Commit

Permalink
Add button to add custom certificate in certificate list
Browse files Browse the repository at this point in the history
  • Loading branch information
badkeyy committed Jan 22, 2025
1 parent 9687e9e commit e6f61e2
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 35 deletions.
8 changes: 6 additions & 2 deletions frontend/js/app/empty/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if (subtitle) { %>
<p class="h4 text-muted font-weight-normal mb-7"><%- subtitle %></p>
<% }
if (link) { %>
<a class="btn btn-<%- btn_color %>" href="#"><%- link %></a>
if (links && links.length) { %>
<% links.forEach(function(link, index) { %>
<div style="margin-bottom: 10px;">
<a class="btn btn-<%- btn_color %>" href="#" data-index="<%- index %>"><%- link %></a>
</div>
<% }); %>
<% } %>
18 changes: 11 additions & 7 deletions frontend/js/app/empty/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = Mn.View.extend({
template: template,

options: {
btn_color: 'teal'
btn_color: 'teal',
links: [], // Added to accept multiple links
actions: [] // Added to accept multiple actions
},

ui: {
Expand All @@ -16,17 +18,19 @@ module.exports = Mn.View.extend({
events: {
'click @ui.action': function (e) {
e.preventDefault();
this.getOption('action')();
const index = $(e.currentTarget).data('index');
this.getOption('actions')[index]();
}
},

templateContext: function () {
return {
title: this.getOption('title'),
subtitle: this.getOption('subtitle'),
link: this.getOption('link'),
action: typeof this.getOption('action') === 'function',
btn_color: this.getOption('btn_color')
title: this.getOption('title'),
subtitle: this.getOption('subtitle'),
links: this.getOption('links'), // Changed to array
actions: this.getOption('actions'), // Changed to array
hasActions: this.getOption('actions').length > 0,
btn_color: this.getOption('btn_color')
};
}

Expand Down
10 changes: 6 additions & 4 deletions frontend/js/app/nginx/access/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
this.showChildView('list_region', new EmptyView({
title: App.i18n('access-lists', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('access-lists', 'add') : null,
links: manage ? [App.i18n('access-lists', 'add')] : [],
btn_color: 'teal',
permission: 'access_lists',
action: function () {
App.Controller.showNginxAccessListForm();
}
actions: [
function () {
App.Controller.showNginxAccessListForm();
}
]
}));
},

Expand Down
14 changes: 9 additions & 5 deletions frontend/js/app/nginx/certificates/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ module.exports = Mn.View.extend({
this.showChildView('list_region', new EmptyView({
title: App.i18n('certificates', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('certificates', 'add') : null,
links: manage ? [App.i18n('certificates', 'add-letsencrypt'), App.i18n('certificates', 'add-custom')] : [],
actions: [
function () {
App.Controller.showNginxCertificateForm();
},
function () {
App.Controller.showNginxCertificateForm(new CertificateModel.Model({provider: 'custom'}));
}],
btn_color: 'pink',
permission: 'certificates',
action: function () {
App.Controller.showNginxCertificateForm();
}
permission: 'certificates'
}));
},

Expand Down
10 changes: 6 additions & 4 deletions frontend/js/app/nginx/dead/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
this.showChildView('list_region', new EmptyView({
title: App.i18n('dead-hosts', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('dead-hosts', 'add') : null,
links: manage ? [App.i18n('dead-hosts', 'add')] : [],
btn_color: 'danger',
permission: 'dead_hosts',
action: function () {
App.Controller.showNginxDeadForm();
}
actions: [
function () {
App.Controller.showNginxDeadForm();
}
]
}));
},

Expand Down
11 changes: 6 additions & 5 deletions frontend/js/app/nginx/proxy/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ module.exports = Mn.View.extend({

showEmpty: function() {
let manage = App.Cache.User.canManage('proxy_hosts');

this.showChildView('list_region', new EmptyView({
title: App.i18n('proxy-hosts', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('proxy-hosts', 'add') : null,
links: manage ? [App.i18n('proxy-hosts', 'add')] : [],
actions: [
function () {
App.Controller.showNginxProxyForm();
}
],
btn_color: 'success',
permission: 'proxy_hosts',
action: function () {
App.Controller.showNginxProxyForm();
}
}));
},

Expand Down
10 changes: 6 additions & 4 deletions frontend/js/app/nginx/redirection/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ module.exports = Mn.View.extend({
this.showChildView('list_region', new EmptyView({
title: App.i18n('redirection-hosts', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('redirection-hosts', 'add') : null,
links: manage ? [App.i18n('redirection-hosts', 'add')] : [],
btn_color: 'yellow',
permission: 'redirection_hosts',
action: function () {
App.Controller.showNginxRedirectionForm();
}
actions: [
function () {
App.Controller.showNginxRedirectionForm();
}
]
}));
},

Expand Down
10 changes: 6 additions & 4 deletions frontend/js/app/nginx/stream/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
this.showChildView('list_region', new EmptyView({
title: App.i18n('streams', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('streams', 'add') : null,
links: manage ? [App.i18n('streams', 'add')] : [],
btn_color: 'blue',
permission: 'streams',
action: function () {
App.Controller.showNginxStreamForm();
}
actions: [
function () {
App.Controller.showNginxStreamForm();
}
]
}));
},

Expand Down
2 changes: 2 additions & 0 deletions frontend/js/i18n/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
"title": "SSL Certificates",
"empty": "There are no SSL Certificates",
"add": "Add SSL Certificate",
"add-letsencrypt": "Add SSL Certificate with Let's Encrypt",
"add-custom": "Add Custom SSL Certificate",
"form-title": "Add {provider, select, letsencrypt{Let's Encrypt} other{Custom}} Certificate",
"delete": "Delete SSL Certificate",
"delete-confirm": "Are you sure you want to delete this SSL Certificate? Any hosts using it will need to be updated later.",
Expand Down

0 comments on commit e6f61e2

Please sign in to comment.