Skip to content

Commit

Permalink
Implement Execute
Browse files Browse the repository at this point in the history
  • Loading branch information
thsmi committed Jun 1, 2020
1 parent 3ccd99c commit 61e11c8
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 20 deletions.
30 changes: 26 additions & 4 deletions src/common/libSieve/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
"pipe.tab.home" : "Pipe",
"pipe.tab.help" : "Help",
"pipe.program.label" : "Pipe the message to the program",
"pipe.program.placeholder" : "The program which should be executed",
"pipe.program.placeholder" : "The program to be executed",
"pipe.program.invalid" : "The program name is invalid.",
"pipe.arguments.label" : "Pass arguments",
"pipe.arguments.text" : "Command line arguments to be passed to the external program.",
Expand All @@ -602,10 +602,32 @@
"filter.tab.home" : "Filter",
"filter.tab.help" : "Help",
"filter.program.label" : "Run message through filter program",
"filter.program.placeholder" : "The program which should be executed",
"filter.program.placeholder" : "The program to be executed",
"filter.program.invalid" : "The program name is invalid.",
"filter.arguments.label" : "Pass arguments",
"filter.arguments.text" : "Command line arguments to be passed to the external program.",
"filter.help" : "",
"filter.summary" : "Run message through filter program"
"filter.help" : "The filter action executes an external program. The current message is forwarded to the program to process it. The ouput replaces the old message.\n\nThe filter action does not affect the implicit keep.\n\nIn case the program terminates with an error, the message it left unchanged.",
"filter.summary" : "Run message through filter program",
"filter.summary.test.pre" : "Message ran through filter program ",
"filter.summary.test.post" : " without errors",

"execute.tab.home" : "Execute",
"execute.tab.help" : "Help",
"execute.program.label" : "Execute external program",
"execute.program.placeholder" : "The program to be executed",
"execute.program.invalid" : "The program name is invalid.",
"execute.arguments.label" : "Pass arguments",
"execute.arguments.text" : "Command line arguments to be passed to the external program.",
"execute.input.label" : "Pass data to the program",
"execute.input.input.title" : "Use custom string",
"execute.input.placeholder" : "Custom data to be passed.",
"execute.input.input.text" : "The string may contain variable subsitutions which will be resolved before passing the data.",
"execute.input.pipe.title" : "Use current message",
"execute.output.label" : "Capture output to variable",
"execute.output.text" : "The programs output will be stored into a sieve variable when the program exected finished without an error.",
"execute.output.placeholder" : "Variable name which stores the output.",
"execute.help" : "Executes an external program.\n\nThe optional input can be forwarded to the program as well as output can be returned from the script.",
"execute.summary" : "Run program ",
"execute.summary.test.pre" : "Program",
"execute.summary.test.post" : "ran without errors"
}
11 changes: 6 additions & 5 deletions src/common/libSieve/pipe/logic/SievePipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@
type: "execute/",

token: ":output",
requires : "variables",

properties: [{
id: "parameters",

elements: [{
id: "varname",
id: "name",
type: "string",

value: '""'
Expand All @@ -187,19 +188,19 @@
type: "execute/output"
}]
}, {
id: "program",
id: "parameters",

elements: [{
id: "name",
id: "program",
type: "string",
value: '""'
value: '"example"'
}]
}, {
id: "arguments",
optional: true,

elements: [{
id: "names",
id: "arguments",
type: "stringlist",
value: '""'
}]
Expand Down
79 changes: 79 additions & 0 deletions src/common/libSieve/pipe/templates/SieveExecuteUI.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<div>
<ul id="template-tabs">
<li class="nav-item">
<a data-i18n="execute.tab.home" class="nav-link active" data-toggle="tab" href="#sieve-widget-execute"
role="tab"></a>
</li>
<li class="nav-item">
<a data-i18n="execute.tab.help" class="nav-link" data-toggle="tab" href="#sieve-widget-help" role="tab"></a>
</li>
</ul>

<div id="template-content">
<div class="tab-content m-2">
<div class="tab-pane fade show active" id="sieve-widget-execute" role="tabpanel">
<div class="form-group">
<label data-i18n="execute.program.label"></label>
<form class="was-validated" novalidate="novalidate">
<input id="sivExecuteProgram" type="text" class="form-control col-lg-8" data-i18n="execute.program.placeholder"
required="required" />
<div class="invalid-feedback" data-i18n="execute.program.invalid"></div>
</form>

<br />

<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sivExecuteArgumentsCbx" />
<label class="custom-control-label" for="sivExecuteArgumentsCbx" data-i18n="execute.arguments.label"></label>

<small class="form-text text-muted" data-i18n="execute.arguments.text"></small>

<div id="sivExecuteArguments"></div>
</div>

<br />
<div class="custom-control custom-checkbox">

<input type="checkbox" class="custom-control-input" id="sivExecuteInputCbx" />
<label class="custom-control-label" for="sivExecuteInputCbx" data-i18n="execute.input.label"></label>

<div id="sivExecuteInputCbxContent" class="d-none">

<div class="custom-control custom-radio">
<input type="radio" id="sivExecutePipeRb" name="sieve-execute-input" class="custom-control-input" value="execute/input/pipe" checked/>
<label data-i18n="execute.input.pipe.title" class="custom-control-label" for="sivExecutePipeRb"></label>
</div>

<div class="custom-control custom-radio">
<input type="radio" id="sivExecuteInputRb" name="sieve-execute-input" class="custom-control-input" value="execute/input/input"/>
<label data-i18n="execute.input.input.title" class="custom-control-label" for="sivExecuteInputRb"></label>

<small data-i18n="execute.input.input.text" class="form-text text-muted"></small>

<input id="sivExecuteInputName" type="text" class="form-control col-lg-8" data-i18n="execute.input.placeholder"
value="Example" />
</div>
</div>
</div>

<br />

<div id="sivExecuteOutput" class="d-none">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sivExecuteOutputCbx" />
<label class="custom-control-label" for="sivExecuteOutputCbx" data-i18n="execute.output.label"></label>

<div id="sivExecuteOutputCbxContent" class="d-none">
<small class="form-text text-muted" data-i18n="execute.output.text"></small>
<input id="sivExecuteOutputName" type="text" class="form-control col-lg-8"
data-i18n="execute.output.placeholder" value="Example" />
</div>
</div>
</div>
</div>
</div>
<div data-i18n="execute.help" style="white-space: pre-line" class="tab-pane fade" id="sieve-widget-help"
role="tabpanel"></div>
</div>
</div>
</div>
14 changes: 8 additions & 6 deletions src/common/libSieve/pipe/templates/SievePipeUI.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@

<small class="form-text text-muted" data-i18n="pipe.try.text"></small>
</div>
</div>

<div id="sivPipeCopy" class="d-none">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sivPipeCopyCheckbox" />
<label class="custom-control-label" for="sivPipeCopyCheckbox" data-i18n="pipe.copy.label"></label>
<div id="sivPipeCopy" class="d-none">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sivPipeCopyCheckbox" />
<label class="custom-control-label" for="sivPipeCopyCheckbox" data-i18n="pipe.copy.label"></label>

<small class="form-text text-muted" data-i18n="pipe.copy.text"></small>
<small class="form-text text-muted" data-i18n="pipe.copy.text"></small>
</div>
</div>
</div>


</div>
<div data-i18n="pipe.help" style="white-space: pre-line" class="tab-pane fade" id="sieve-widget-help"
role="tabpanel"></div>
Expand Down
Loading

0 comments on commit 61e11c8

Please sign in to comment.