Compare commits

..

8 Commits

Author SHA1 Message Date
Julian Gassner
0fe3630d40 Merge e6f61e297f into 79d28f03d0 2025-02-08 23:59:11 +08:00
jc21
79d28f03d0 Merge pull request #4346 from Sander0542/feature/security-schemes-component
All checks were successful
Close stale issues and PRs / stale (push) Successful in 4s
API Schema Improvements
2025-02-07 12:39:49 +10:00
Sander Jochems
df48b835c4 Update order to match others 2025-02-05 22:20:21 +01:00
Sander Jochems
8a1557154a Add certificate fields to boolFields 2025-02-05 22:15:12 +01:00
Sander Jochems
a6af5ec2c7 Remove certificate as required from proxy host 2025-02-05 18:18:50 +01:00
Sander Jochems
14d7c35fd7 Fix whitespaces 2025-02-05 17:31:09 +01:00
Sander Jochems
cfcf78aaee Set bearer auth security component 2025-02-05 17:29:40 +01:00
Julian Gassner
e6f61e297f Add button to add custom certificate in certificate list 2025-01-22 15:33:02 +00:00
13 changed files with 73 additions and 38 deletions

View File

@@ -12,7 +12,11 @@ Model.knex(db);
const boolFields = [
'is_deleted',
'ssl_forced',
'http2_support',
'enabled',
'hsts_enabled',
'hsts_subdomains',
];
class DeadHost extends Model {

View File

@@ -8,8 +8,8 @@ const now = require('./now_helper');
Model.knex(db);
const boolFields = [
'enabled',
'is_deleted',
'enabled',
'tcp_forwarding',
'udp_forwarding',
];

View File

@@ -22,8 +22,7 @@
"enabled",
"locations",
"hsts_enabled",
"hsts_subdomains",
"certificate"
"hsts_subdomains"
],
"additionalProperties": false,
"properties": {

View File

@@ -9,6 +9,15 @@
"url": "http://127.0.0.1:81/api"
}
],
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
},
"paths": {
"/": {
"get": {

View File

@@ -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>
<% }); %>
<% } %>

View File

@@ -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: {
@@ -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')
};
}

View File

@@ -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();
}
]
}));
},

View File

@@ -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'
}));
},

View File

@@ -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();
}
]
}));
},

View File

@@ -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();
}
}));
},

View File

@@ -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();
}
]
}));
},

View File

@@ -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();
}
]
}));
},

View File

@@ -187,6 +187,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.",