Skip to content

Commit

Permalink
HTML Regex Tool 1.1
Browse files Browse the repository at this point in the history
CSS fixes
Event hooks
Config for all by Parse Complex
Installer fix
  • Loading branch information
jdunkerley committed Mar 14, 2017
1 parent f13ac97 commit a6ce1fd
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 139 deletions.
3 changes: 2 additions & 1 deletion OmnibusRegex/Install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Write-Host "Finding Alteryx User Install Location..."
$reg = Get-ItemProperty HKCU:\SOFTWARE\SRC\Alteryx -ErrorAction SilentlyContinue
if ($reg -ne $null) {
$bin = $reg.InstallDir64 + '\HtmlPlugins\OmnibusRegex'
New-Item -Path $bin -ItemType SymbolicLink -Value $root
$cmd = "/c mklink /J ""$bin"" ""$root"""
Start-Process cmd -ArgumentList $cmd -wait
}

Pop-Location
38 changes: 33 additions & 5 deletions OmnibusRegex/OmnibusHTMLHelper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
window.PlugInHelper = (() => { return { Create: (alteryx, manager, window) => {
const metaInfo = manager.metaInfo
window.PlugInHelper = (() => { return { Create: (alteryx, manager, AlteryxDataItems, window) => {
const formulaConstants = []

const jsEvent = (obj) => alteryx.JsEvent(JSON.stringify(obj))
Expand All @@ -26,10 +25,10 @@ window.PlugInHelper = (() => { return { Create: (alteryx, manager, window) => {
})})

// Get Connections
const connectionNames = Array(metaInfo.Count).fill().map((_, i) => metaInfo.Get(i).ConnectionName)
const connectionNames = Array(manager.metaInfo.Count).fill().map((_, i) => manager.metaInfo.Get(i).ConnectionName)
const connections = {}
connectionNames.forEach((n, i) => {
const fields = metaInfo.Get(i)._GetFields().map((f, j) => { return { name: f.strName, type: f.strType, size: f.nSize, scale: f.nScale, description: f.strDescription, index: j } })
const fields = manager.metaInfo.Get(i)._GetFields().map((f, j) => { return { name: f.strName, type: f.strType, size: f.nSize, scale: f.nScale, description: f.strDescription, index: j } })
connections[n] = fields
})

Expand Down Expand Up @@ -77,7 +76,34 @@ window.PlugInHelper = (() => { return { Create: (alteryx, manager, window) => {
      callbackmakeCallback(callback),
      expressionspreviewObject
    })
}

function truncateString(input, length = 30) {
return input.length > length ? `${input.substring(0, 27)}...` : input
}

function createDataItem(dataName, value, suppressed = false) {
let output
switch (typeof(value)) {
case "boolean":
output = new AlteryxDataItems.SimpleBool({dataname: dataName, id: dataName})
break
case "string":
output = value.match(/^\d{4}-\d{2}-\d{2}$/)
? new AlteryxDataItems.SimpleDate({dataname: dataName, id: dataName})
: new AlteryxDataItems.SimpleString({dataname: dataName, id: dataName})
break
case "number":
output = value % 1
? new AlteryxDataItems.SimpleFloat({dataname: dataName, id: dataName})
: new AlteryxDataItems.SimpleInt({dataname: dataName, id: dataName})
break;
}

output.suppressed = suppressed
output.setValue(value)
manager.AddDataItem(output)
return output
}

return {
Expand All @@ -90,6 +116,8 @@ window.PlugInHelper = (() => { return { Create: (alteryx, manager, window) => {
getInputDataArray,
setFormulaConstantsCallback: (callback) => formulaConstantsCallback = callback,
testExpression,
formulaPreview
formulaPreview,
truncateString,
createDataItem
}
} } })()
91 changes: 53 additions & 38 deletions OmnibusRegex/OmnibusRegEx.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,76 @@
<script src="codemirror-regex.js"></script>
<link rel="stylesheet" href="codemirror.css">
<link rel="stylesheet" href="codemirror-regex.css">
<style>
.CodeMirror {
line-height: 1.2em;
height: 1.7em;
min-height: 0
}

.alteryx-toggle-switch-outer {
position: absolute;
right: 4px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend class='blueTitle'>Output Method</legend>
<div>
<label for="regexType">Mode</label>
<alteryx-pluginwidget type="DropDown" id="method" dataName="Method"></alteryx-pluginwidget>
</div>

<label for="regexType">Mode</label>
<alteryx-pluginwidget type="DropDown" id="method" dataName="MethodTemp"></alteryx-pluginwidget>
</fieldset>
<fieldset>
<legend class='blueTitle'>Input Field</legend>
<div>
<label for="fieldSelector">Name</label>
<alteryx-pluginwidget type="DropDown" dataType="FieldSelector" id="fieldSelector" dataName="Field" connectionNumber="0" inputNumber="0" fieldType="StringOrDate"></alteryx-pluginwidget>
</div>
<div>
<alteryx-pluginwidget type="CheckBox" id="showPreview" showAsToggle="true" text="Show Preview" dataName="showPreview"></alteryx-pluginwidget>
<pre id="preview" style="background-color: #f7f7f7">&nbsp;</pre>
</div>

<label for="fieldSelector">Name</label>
<alteryx-pluginwidget type="DropDown" dataType="FieldSelector" id="fieldSelector" dataName="Field" connectionNumber="0" inputNumber="0" fieldType="StringOrDate"></alteryx-pluginwidget>

<alteryx-pluginwidget type="CheckBox" id="showPreview" showAsToggle="true" text="Show Preview?" dataName="showPreview"></alteryx-pluginwidget>
<pre id="preview" style="background-color: #d2d2d2; border-color: #999;">&nbsp;</pre>
</fieldset>
<fieldset>
<legend class='blueTitle'>Regular Expression</legend>
<div>
<!--DataName RegExExpression-->
<label for="regularExpression">Expression</label>
<textarea id="regularExpression" style="height: 1.5em"></textarea>
</div>
<div>
<alteryx-pluginwidget type="CheckBox" id="caseInsensitive" dataName="CaseInsensitive" showAsToggle="true" text="Case Insensitive"></alteryx-pluginwidget>
</div>
<div id="previewRegex">
<label for="previewResult">Preview</label>
<pre id="previewResult" style="background-color: #f7f7f7">&nbsp;</pre>
</div>

<!--DataName RegExExpression-->
<label for="regularExpression">Expression</label>
<textarea id="regularExpression" style="height: 1.5em"></textarea>

<alteryx-pluginwidget type="CheckBox" id="caseInsensitive" dataName="CaseInsensitiveTemp" showAsToggle="true" text="Case Insensitive"></alteryx-pluginwidget>
</fieldset>
<fieldset id="MatchFieldSet">
<legend class='blueTitle'>Match Field</legend>
<div>
<label for="matchField">Name</label>
<alteryx-pluginwidget type="TextBox" id="matchField" dataName="MatchField"></alteryx-pluginwidget>
</div>
<div>
<alteryx-pluginwidget type="CheckBox" id="errorUnmatched" dataName="ErrorUnmatched" showAsToggle="true" text="Error if not matched"></alteryx-pluginwidget>
</div>

<label for="matchField">Name</label>
<alteryx-pluginwidget type="TextBox" id="matchField" dataName="MatchField"></alteryx-pluginwidget>

<alteryx-pluginwidget type="CheckBox" id="errorUnmatched" dataName="ErrorUnmatched" showAsToggle="true" text="Error if not matched"></alteryx-pluginwidget>
</fieldset>
<fieldset id="ReplaceFieldSet">
<legend class='blueTitle'>Replace</legend>
<div>
<label for="replaceExpression">Expression</label>
<alteryx-pluginwidget type="TextBox" id="replaceExpression" dataName="ReplaceExpression"></alteryx-pluginwidget>
</div>
<!--<div>
<alteryx-pluginwidget type="CheckBox" id="copyUnmatched" dataName="CopyUnmatched" showAsToggle="true" text="Copy unmatched text to output"></alteryx-pluginwidget>
</div>-->

<label for="replaceExpression">Expression</label>
<alteryx-pluginwidget type="TextBox" id="replaceExpression" dataName="ReplaceExpression"></alteryx-pluginwidget>

<alteryx-pluginwidget type="CheckBox" id="copyUnmatched" dataName="CopyUnmatched" showAsToggle="true" text="Copy unmatched text to output"></alteryx-pluginwidget>
</fieldset>
<fieldset id="ColumnFieldSet">
<legend class='blueTitle'>Output Columns</legend>

<label for="numberFields">Number of Fields</label>
<alteryx-pluginwidget type="NumericSpinner" min="1" max="1000" id="numberFields" dataName="NumFields"></alteryx-pluginwidget>

<label for="extraColumns">Action on Extra Columns</label>
<alteryx-pluginwidget type="DropDown" id="extraColumns" dataName="ParseColumnError"></alteryx-pluginwidget>

<label for="rootName">Root Name</label>
<alteryx-pluginwidget type="TextBox" id="rootName" dataName="RootName"></alteryx-pluginwidget>
</fieldset>
<fieldset id="previewRegex">
<legend for="previewResult">Regex Result:</legend>
<pre id="previewResult" style="background-color: #d2d2d2; border-color: #999;">&nbsp;</pre>
</fieldset>
</form>
<script type="text/javascript" src="OmnibusHTMLHelper.js"></script>
Expand Down
Loading

0 comments on commit a6ce1fd

Please sign in to comment.