|
|
@@ -25,6 +25,8 @@ module.exports = Mn.View.extend({
|
|
|
certificate_select: 'select[name="certificate_id"]',
|
|
|
access_list_select: 'select[name="access_list_id"]',
|
|
|
ssl_forced: 'input[name="ssl_forced"]',
|
|
|
+ hsts_enabled: 'input[name="hsts_enabled"]',
|
|
|
+ hsts_subdomains: 'input[name="hsts_subdomains"]',
|
|
|
http2_support: 'input[name="http2_support"]',
|
|
|
forward_scheme: 'select[name="forward_scheme"]',
|
|
|
letsencrypt: '.letsencrypt'
|
|
|
@@ -40,10 +42,44 @@ module.exports = Mn.View.extend({
|
|
|
}
|
|
|
|
|
|
let enabled = id === 'new' || parseInt(id, 10) > 0;
|
|
|
- this.ui.ssl_forced.add(this.ui.http2_support)
|
|
|
+
|
|
|
+ let inputs = this.ui.ssl_forced.add(this.ui.http2_support);
|
|
|
+ inputs
|
|
|
.prop('disabled', !enabled)
|
|
|
.parents('.form-group')
|
|
|
.css('opacity', enabled ? 1 : 0.5);
|
|
|
+
|
|
|
+ if (!enabled) {
|
|
|
+ inputs.prop('checked', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ inputs.trigger('change');
|
|
|
+ },
|
|
|
+
|
|
|
+ 'change @ui.ssl_forced': function () {
|
|
|
+ let checked = this.ui.ssl_forced.prop('checked');
|
|
|
+ this.ui.hsts_enabled
|
|
|
+ .prop('disabled', !checked)
|
|
|
+ .parents('.form-group')
|
|
|
+ .css('opacity', checked ? 1 : 0.5);
|
|
|
+
|
|
|
+ if (!checked) {
|
|
|
+ this.ui.hsts_enabled.prop('checked', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.ui.hsts_enabled.trigger('change');
|
|
|
+ },
|
|
|
+
|
|
|
+ 'change @ui.hsts_enabled': function () {
|
|
|
+ let checked = this.ui.hsts_enabled.prop('checked');
|
|
|
+ this.ui.hsts_subdomains
|
|
|
+ .prop('disabled', !checked)
|
|
|
+ .parents('.form-group')
|
|
|
+ .css('opacity', checked ? 1 : 0.5);
|
|
|
+
|
|
|
+ if (!checked) {
|
|
|
+ this.ui.hsts_subdomains.prop('checked', false);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
'click @ui.save': function (e) {
|
|
|
@@ -63,14 +99,9 @@ module.exports = Mn.View.extend({
|
|
|
data.caching_enabled = !!data.caching_enabled;
|
|
|
data.allow_websocket_upgrade = !!data.allow_websocket_upgrade;
|
|
|
data.http2_support = !!data.http2_support;
|
|
|
-
|
|
|
- if (typeof data.ssl_forced !== 'undefined' && data.ssl_forced === '1') {
|
|
|
- data.ssl_forced = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (typeof data.http2_support !== 'undefined') {
|
|
|
- data.http2_support = !!data.http2_support;
|
|
|
- }
|
|
|
+ data.hsts_enabled = !!data.hsts_enabled;
|
|
|
+ data.hsts_subdomains = !!data.hsts_subdomains;
|
|
|
+ data.ssl_forced = !!data.ssl_forced;
|
|
|
|
|
|
if (typeof data.domain_names === 'string' && data.domain_names) {
|
|
|
data.domain_names = data.domain_names.split(',');
|
|
|
@@ -132,6 +163,9 @@ module.exports = Mn.View.extend({
|
|
|
onRender: function () {
|
|
|
let view = this;
|
|
|
|
|
|
+ this.ui.ssl_forced.trigger('change');
|
|
|
+ this.ui.hsts_enabled.trigger('change');
|
|
|
+
|
|
|
// Domain names
|
|
|
this.ui.domain_names.selectize({
|
|
|
delimiter: ',',
|