Skip to content

Commit

Permalink
Merge pull request #836 from ironmansoftware/832
Browse files Browse the repository at this point in the history
Fixes #810
  • Loading branch information
adamdriscoll authored May 26, 2019
2 parents 2922d55 + dd7de59 commit 17b7327
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 22 deletions.
52 changes: 52 additions & 0 deletions src/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"name": "PowerShell Launch Current File in Temporary Console",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"name": "PowerShell Launch Current File w/Args Prompt",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"name": "PowerShell Attach to Host Process",
"type": "PowerShell",
"request": "attach"
},
{
"name": "PowerShell Interactive Session",
"type": "PowerShell",
"request": "launch",
"cwd": ""
},
{
"name": "PowerShell Attach Interactive Session Runspace",
"type": "PowerShell",
"request": "attach",
"processId": "current"
}
]
}
2 changes: 1 addition & 1 deletion src/UniversalDashboard.Materialize/Scripts/grid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function New-UDGrid {

if ($null -ne $Endpoint) {
if ($Endpoint -is [scriptblock]) {
$Endpoint = New-UDEndpoint -Endpoint $Endpoint -Id $Id
$Endpoint = New-UDEndpoint -Endpoint $Endpoint -Id $Id -ArgumentList $ArgumentList
}
elseif ($Endpoint -isnot [UniversalDashboard.Models.Endpoint]) {
throw "Endpoint must be a script block or UDEndpoint"
Expand Down
25 changes: 25 additions & 0 deletions src/UniversalDashboard/Cmdlets/NewEndpointCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Language;
using System.Text.RegularExpressions;
using UniversalDashboard.Models;
using UniversalDashboard.Services;
using System.Linq;

namespace UniversalDashboard.Cmdlets
{
Expand Down Expand Up @@ -44,11 +46,34 @@ protected override void EndProcessing()
ArgumentList = ArgumentList
};

callback.Variables = new Dictionary<string, object>();

try
{
var variables = Endpoint.Ast.FindAll(x => x is VariableExpressionAst, true).Cast<VariableExpressionAst>().Select(m => m.VariablePath.ToString());

foreach (var variableName in variables)
{
var variable = SessionState.InvokeCommand.InvokeScript($"Get-Variable -Name '{variableName}' -ErrorAction SilentlyContinue").Select(m => m.BaseObject).OfType<PSVariable>().FirstOrDefault();
if (variable != null && !variable.Options.HasFlag(ScopedItemOptions.Constant) && !variable.Options.HasFlag(ScopedItemOptions.ReadOnly))
{
if (!callback.Variables.ContainsKey(variable.Name))
callback.Variables.Add(variable.Name, SessionState.PSVariable.GetValue(variable.Name));
}
}
}
catch (Exception ex)
{
WriteWarning(ex.Message);
}


if (EvaluateUrlAsRegex) {
callback.UrlRegEx = new Regex(Url);
}

callback.SessionId = SessionState.PSVariable.Get(Constants.SessionId)?.Value as string;
callback.Page = SessionState.PSVariable.Get(Constants.UDPage)?.Value as Page;

if (callback.Schedule == null)
{
Expand Down
39 changes: 18 additions & 21 deletions src/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17b7327

Please sign in to comment.