diff --git a/backend/migrations/20240917085226_add_remark_to_proxy_host.js b/backend/migrations/20240917085226_add_remark_to_proxy_host.js new file mode 100644 index 000000000..33694f2f8 --- /dev/null +++ b/backend/migrations/20240917085226_add_remark_to_proxy_host.js @@ -0,0 +1,36 @@ +const migrate_name = 'identifier_for_migrate'; +const logger = require('../logger').migrate; + +/** + * Migrate + * + * @see http://knexjs.org/#Schema + * + * @param {Object} knex + * @param {Promise} Promise + * @returns {Promise} + */ +exports.up = function (knex) { + logger.info('[' + migrate_name + '] Migrating Up...'); + + return knex.schema.table('proxy_host', function (table) { + table.string('remark', 100).nullable().defaultTo(''); + logger.info('[' + migrate_name + '] Migrating Up Complete'); + }); +}; + +/** + * Undo Migrate + * + * @param {Object} knex + * @param {Promise} Promise + * @returns {Promise} + */ +exports.down = function (knex) { + logger.info('[' + migrate_name + '] Migrating Down...'); + + return knex.schema.table('proxy_host', function (table) { + table.dropColumn('remark'); + logger.info('[' + migrate_name + '] Migrating Down Complete'); + }); +}; diff --git a/backend/models/proxy_host.js b/backend/models/proxy_host.js index d84181cf1..e5c19c1e3 100644 --- a/backend/models/proxy_host.js +++ b/backend/models/proxy_host.js @@ -46,7 +46,7 @@ class ProxyHost extends Model { } static get jsonAttributes () { - return ['domain_names', 'meta', 'locations']; + return ['domain_names', 'meta', 'locations', 'remark']; } static get relationMappings () { diff --git a/backend/schema/endpoints/proxy-hosts.json b/backend/schema/endpoints/proxy-hosts.json index 9a3fff2fc..28528462a 100644 --- a/backend/schema/endpoints/proxy-hosts.json +++ b/backend/schema/endpoints/proxy-hosts.json @@ -107,6 +107,11 @@ } } } + }, + "remark": { + "type": "string", + "description": "Remark", + "maxLength": 100 } }, "properties": { @@ -169,6 +174,9 @@ }, "locations": { "$ref": "#/definitions/locations" + }, + "remark": { + "$ref": "#/definitions/remark" } }, "links": [ @@ -259,6 +267,9 @@ }, "locations": { "$ref": "#/definitions/locations" + }, + "remark": { + "$ref": "#/definitions/remark" } } }, @@ -332,6 +343,9 @@ }, "locations": { "$ref": "#/definitions/locations" + }, + "remark": { + "$ref": "#/definitions/remark" } } }, diff --git a/frontend/js/app/nginx/proxy/form.ejs b/frontend/js/app/nginx/proxy/form.ejs index 8e7a2a2df..490100693 100644 --- a/frontend/js/app/nginx/proxy/form.ejs +++ b/frontend/js/app/nginx/proxy/form.ejs @@ -90,6 +90,14 @@ + + +
+
+ + +
+
diff --git a/frontend/js/app/nginx/proxy/form.js b/frontend/js/app/nginx/proxy/form.js index 4437a6ddd..2bdc0c15a 100644 --- a/frontend/js/app/nginx/proxy/form.js +++ b/frontend/js/app/nginx/proxy/form.js @@ -24,6 +24,7 @@ module.exports = Mn.View.extend({ form: 'form', domain_names: 'input[name="domain_names"]', forward_host: 'input[name="forward_host"]', + remark: 'input[name="remark"]', buttons: '.modal-footer button', cancel: 'button.cancel', save: 'button.save', @@ -113,7 +114,7 @@ module.exports = Mn.View.extend({ } else { this.ui.dns_provider.prop('required', false); this.ui.dns_provider_credentials.prop('required', false); - this.ui.dns_challenge_content.hide(); + this.ui.dns_challenge_content.hide(); } }, @@ -125,13 +126,13 @@ module.exports = Mn.View.extend({ this.ui.credentials_file_content.show(); } else { this.ui.dns_provider_credentials.prop('required', false); - this.ui.credentials_file_content.hide(); + this.ui.credentials_file_content.hide(); } }, 'click @ui.add_location_btn': function (e) { e.preventDefault(); - + const model = new ProxyLocationModel.Model(); this.locationsCollection.add(model); }, @@ -167,17 +168,17 @@ module.exports = Mn.View.extend({ data.hsts_enabled = !!data.hsts_enabled; data.hsts_subdomains = !!data.hsts_subdomains; data.ssl_forced = !!data.ssl_forced; - + if (typeof data.meta === 'undefined') data.meta = {}; data.meta.letsencrypt_agree = data.meta.letsencrypt_agree == 1; data.meta.dns_challenge = data.meta.dns_challenge == 1; - + if(!data.meta.dns_challenge){ data.meta.dns_provider = undefined; data.meta.dns_provider_credentials = undefined; data.meta.propagation_seconds = undefined; } else { - if(data.meta.propagation_seconds === '') data.meta.propagation_seconds = undefined; + if(data.meta.propagation_seconds === '') data.meta.propagation_seconds = undefined; } if (typeof data.domain_names === 'string' && data.domain_names) { @@ -185,7 +186,7 @@ module.exports = Mn.View.extend({ } // Check for any domain names containing wildcards, which are not allowed with letsencrypt - if (data.certificate_id === 'new') { + if (data.certificate_id === 'new') { let domain_err = false; if (!data.meta.dns_challenge) { data.domain_names.map(function (name) { diff --git a/frontend/js/app/nginx/proxy/list/item.ejs b/frontend/js/app/nginx/proxy/list/item.ejs index a59368048..0db68ee29 100644 --- a/frontend/js/app/nginx/proxy/list/item.ejs +++ b/frontend/js/app/nginx/proxy/list/item.ejs @@ -25,6 +25,9 @@
<%- forward_scheme %>://<%- forward_host %>:<%- forward_port %>
+ +
<%- remark %>
+
<%- certificate && certificate_id ? i18n('ssl', certificate.provider) : i18n('ssl', 'none') %>
@@ -57,4 +60,4 @@ -<% } %> \ No newline at end of file +<% } %> diff --git a/frontend/js/app/nginx/proxy/list/main.ejs b/frontend/js/app/nginx/proxy/list/main.ejs index 6de5b9c68..c022b818f 100644 --- a/frontend/js/app/nginx/proxy/list/main.ejs +++ b/frontend/js/app/nginx/proxy/list/main.ejs @@ -2,6 +2,7 @@   <%- i18n('str', 'source') %> <%- i18n('str', 'destination') %> + <%- i18n('str', 'remark') %> <%- i18n('str', 'ssl') %> <%- i18n('str', 'access') %> <%- i18n('str', 'status') %> diff --git a/frontend/js/i18n/messages.json b/frontend/js/i18n/messages.json index 0bbde4541..18503c52d 100644 --- a/frontend/js/i18n/messages.json +++ b/frontend/js/i18n/messages.json @@ -21,6 +21,7 @@ "choose-file": "Choose file", "source": "Source", "destination": "Destination", + "remark": "Remark", "ssl": "SSL", "access": "Access", "public": "Public", @@ -133,7 +134,8 @@ "allow-websocket-upgrade": "Websockets Support", "ignore-invalid-upstream-ssl": "Ignore Invalid SSL", "custom-forward-host-help": "Add a path for sub-folder forwarding.\nExample: 203.0.113.25/path/", - "search": "Search Host…" + "search": "Search Host…", + "remark": "Remark" }, "redirection-hosts": { "title": "Redirection Hosts", diff --git a/frontend/js/models/proxy-host.js b/frontend/js/models/proxy-host.js index b82d09fef..77d1eaf9b 100644 --- a/frontend/js/models/proxy-host.js +++ b/frontend/js/models/proxy-host.js @@ -9,6 +9,7 @@ const model = Backbone.Model.extend({ created_on: null, modified_on: null, domain_names: [], + remark: '', forward_scheme: 'http', forward_host: '', forward_port: null,