diff --git a/src/rockstor/storageadmin/models/rockon.py b/src/rockstor/storageadmin/models/rockon.py index 0555fcc1a..7ed0dfa04 100644 --- a/src/rockstor/storageadmin/models/rockon.py +++ b/src/rockstor/storageadmin/models/rockon.py @@ -227,7 +227,7 @@ class DContainerEnv(models.Model): val = models.CharField(max_length=1024, null=True) description = models.CharField(max_length=2048, null=True) label = models.CharField(max_length=64, null=True) - + default_val = models.CharField(max_length=1024, null=True) class DContainerDevice(models.Model): container = models.ForeignKey(DContainer, on_delete=models.CASCADE) diff --git a/src/rockstor/storageadmin/static/storageadmin/js/templates/rockons/cc_form.jst b/src/rockstor/storageadmin/static/storageadmin/js/templates/rockons/cc_form.jst index 2fc4460b3..0c54f1cd5 100644 --- a/src/rockstor/storageadmin/static/storageadmin/js/templates/rockons/cc_form.jst +++ b/src/rockstor/storageadmin/static/storageadmin/js/templates/rockons/cc_form.jst @@ -16,7 +16,21 @@ {{else}} type="text" {{/if}} - id="{{this.id}}" name="{{this.id}}" value="{{#unless null}}{{this.val}}{{/unless}}"> + id="{{this.id}}" name="{{this.id}}" + value=" + {{~#if (isNull this.val)~}} + {{~#unless (isNull this.default_val)~}} + {{~this.default_val~}} + {{~/unless~}} + {{~else~}} + {{~this.val~}} + {{~/if~}} + " + placeholder=" + {{~#unless (isNull this.default_val)~}} + {{~this.default_val~}} + {{~/unless~}} + ">    diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js b/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js index fc9618ba0..7a05b6ca4 100644 --- a/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js +++ b/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js @@ -736,6 +736,11 @@ RockonCustomChoice = RockstorWizardPage.extend({ } return false; }); + + Handlebars.registerHelper('isNull', function(fieldValue) { + return _.isNull(fieldValue) || _.isUndefined(fieldValue); + }); + } }); diff --git a/src/rockstor/storageadmin/views/rockon.py b/src/rockstor/storageadmin/views/rockon.py index a93020e52..cedf92500 100644 --- a/src/rockstor/storageadmin/views/rockon.py +++ b/src/rockstor/storageadmin/views/rockon.py @@ -465,7 +465,11 @@ def _update_env(self, co, c_d): cc_d = c_d.get("environment", {}) for k in self._sorted_keys(cc_d): ccc_d = cc_d[k] + defaults = {"description": ccc_d["description"], "label": ccc_d["label"]} + if "default_value" in ccc_d: + defaults["default_val"] = ccc_d["default_value"]; + cco, created = DContainerEnv.objects.get_or_create( container=co, key=k, defaults=defaults )