KennethScott / SpecOps

SpecOps is a web-based, centralized PowerShell script repository where non-technical users can run scripts via a user-friendly GUI.
Other
97 stars 6 forks source link

Support for hidden input type/parameter with value set in scriptsettings.json #3

Closed SamNeale12 closed 2 years ago

SamNeale12 commented 2 years ago

Trying to create a hidden parameter on a script in scriptsettings.json similar to below, while the element is created the value is not

{
  "Name": "StrHiddenParam",
  "Type": "hidden",
  "Value": "testing",
  "Required": "true"
}

Had a quick look and added the following code which seems to work

\SpecOps-master\SpecOps\Pages\User\Scripts.cshtml In switch statement for the script change event:

case "hidden":
    $('div.parameters').append(`<div class="form-group row">
                                    <div class="col-md-4">
                                        <input type="${parm.type}" class="form-control" id="${parm.name}" name="${parm.name}" value="${parm.value}">
                                    </div>
                                </div>`);
    break;

SpecOps-master\SpecOps\Models\ScriptParameter.cs In ScriptParameter class

        /// <summary>
        /// Parameter Value as it is used in the script
        /// </summary>
        public string Value { get; set; }
KennethScott commented 2 years ago

Yep, that's exactly how you'd want to approach it. It should then serialize and be available for use in the script.

I hope to get everything updated to .NET6 soon. I can add this in with those changes.

KennethScott commented 2 years ago

FYI, I've just committed changes to upgrade to .NET6 and I also included support for the value attribute. I haven't published a prebuilt zip yet, but I will soon.

KennethScott commented 2 years ago

I've published an updated precompiled release v1.0.