Skip to content

feat: add remark in proxy hosts list #4005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions backend/migrations/20240917085226_add_remark_to_proxy_host.js
Original file line number Diff line number Diff line change
@@ -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');
});
};
2 changes: 1 addition & 1 deletion backend/models/proxy_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
14 changes: 14 additions & 0 deletions backend/schema/endpoints/proxy-hosts.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
}
}
}
},
"remark": {
"type": "string",
"description": "Remark",
"maxLength": 100
}
},
"properties": {
Expand Down Expand Up @@ -169,6 +174,9 @@
},
"locations": {
"$ref": "#/definitions/locations"
},
"remark": {
"$ref": "#/definitions/remark"
}
},
"links": [
Expand Down Expand Up @@ -259,6 +267,9 @@
},
"locations": {
"$ref": "#/definitions/locations"
},
"remark": {
"$ref": "#/definitions/remark"
}
}
},
Expand Down Expand Up @@ -332,6 +343,9 @@
},
"locations": {
"$ref": "#/definitions/locations"
},
"remark": {
"$ref": "#/definitions/remark"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions frontend/js/app/nginx/proxy/form.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
</select>
</div>
</div>

<!-- remark -->
<div class="col-sm-12 col-md-12">
<div class="form-group">
<label class="form-label"><%- i18n('proxy-hosts', 'remark') %></label>
<input type="text" name="remark" class="form-control text-monospace" placeholder="" value="<%- remark %>" autocomplete="off" maxlength="200">
</div>
</div>
</div>
</div>

Expand Down
15 changes: 8 additions & 7 deletions frontend/js/app/nginx/proxy/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
}
},

Expand All @@ -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);
},
Expand Down Expand Up @@ -167,25 +168,25 @@ 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) {
data.domain_names = data.domain_names.split(',');
}

// 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) {
Expand Down
5 changes: 4 additions & 1 deletion frontend/js/app/nginx/proxy/list/item.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<td>
<div class="text-monospace"><%- forward_scheme %>://<%- forward_host %>:<%- forward_port %></div>
</td>
<td>
<div class="text-monospace"><%- remark %></div>
</td>
<td>
<div><%- certificate && certificate_id ? i18n('ssl', certificate.provider) : i18n('ssl', 'none') %></div>
</td>
Expand Down Expand Up @@ -57,4 +60,4 @@
</div>
</div>
</td>
<% } %>
<% } %>
1 change: 1 addition & 0 deletions frontend/js/app/nginx/proxy/list/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<th width="30">&nbsp;</th>
<th><%- i18n('str', 'source') %></th>
<th><%- i18n('str', 'destination') %></th>
<th><%- i18n('str', 'remark') %></th>
<th><%- i18n('str', 'ssl') %></th>
<th><%- i18n('str', 'access') %></th>
<th><%- i18n('str', 'status') %></th>
Expand Down
4 changes: 3 additions & 1 deletion frontend/js/i18n/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"choose-file": "Choose file",
"source": "Source",
"destination": "Destination",
"remark": "Remark",
"ssl": "SSL",
"access": "Access",
"public": "Public",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions frontend/js/models/proxy-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down