new flow elements

This commit is contained in:
John Andrews
2024-08-08 17:39:27 +12:00
parent 621e515805
commit ff4ad4d257
28 changed files with 1791 additions and 5 deletions

View File

@@ -34,7 +34,6 @@ public class Delete : Node
/// </summary>
[TextVariable(1)] public string FileName { get; set; }
/// <summary>
/// Executes the flow element
/// </summary>
@@ -46,7 +45,6 @@ public class Delete : Node
if (string.IsNullOrEmpty(path))
path = args.WorkingFile;
if (args.FileService.DirectoryExists(path).Is(true))
{
try

View File

@@ -1,3 +1,4 @@
using System.Text.RegularExpressions;
using FileFlows.Plugin;
namespace FileFlows.BasicNodes.File;
@@ -5,7 +6,7 @@ namespace FileFlows.BasicNodes.File;
/// <summary>
/// Basic Input file, the default input node
/// </summary>
public class InputFile : Node
public partial class InputFile : Node
{
/// <summary>
/// Gets the number of outputs
@@ -31,6 +32,11 @@ public class InputFile : Node
/// <returns>the output to call next</returns>
public override int Execute(NodeParameters args)
{
if (UrlRegex().IsMatch(args.WorkingFile))
{
args.Logger?.ILog("URL Detected: " + args.WorkingFile);
return 1;
}
try
{
if(args.FileService.FileExists(args.WorkingFile).Is(true) == false)
@@ -49,4 +55,11 @@ public class InputFile : Node
return -1;
}
}
/// <summary>
/// Regex to detect a URL
/// </summary>
/// <returns>the URL regex</returns>
[GeneratedRegex("^http(s)://", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
private static partial Regex UrlRegex();
}

View File

@@ -0,0 +1,25 @@
using FileFlows.Plugin;
namespace FileFlows.BasicNodes.Functions;
/// <summary>
/// A flow element that simply completes/finishes a flow
/// </summary>
public class CompleteFlow : Node
{
/// <inheritdoc />
public override int Inputs => 1;
/// <inheritdoc />
public override FlowElementType Type => FlowElementType.Logic;
/// <inheritdoc />
public override string Icon => "fas fa-check-square";
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/complete-flow";
/// <inheritdoc />
public override string CustomColor => "var(--success)";
/// <inheritdoc />
public override int Execute(NodeParameters args)
=> 0;
}

View File

@@ -0,0 +1,46 @@
using System.ComponentModel;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
using System.ComponentModel.DataAnnotations;
namespace FileFlows.BasicNodes.Functions;
/// <summary>
/// A special flow element that iterates all strings in a list and process them through a sub flow
/// </summary>
public class ListIterator : Node
{
/// <inheritdoc />
public override int Inputs => 1;
/// <inheritdoc />
public override int Outputs => 1;
/// <inheritdoc />
public override FlowElementType Type => FlowElementType.Process;
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/list-iterator";
/// <inheritdoc />
public override string Icon => "fas fa-sitemap";
/// <inheritdoc />
public override string CustomColor => "var(--flow-subflow)";
/// <summary>
/// Gets or sets the flow to execute
/// </summary>
[Select("SUB_FLOW_LIST", 1)]
public ObjectReference? Flow { get; set; }
/// <summary>
/// Gets or sets the list to iterate
/// </summary>
[Required]
[TextVariable(2)]
[DefaultValue("{CurrentList}")]
public string? List { get; set; }
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
args.Logger?.ELog("Should not be called here, but directly from the runner.");
return -1;
}
}

View File

@@ -23,6 +23,13 @@ public class WebRequest : Node
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/web-request";
/// <inheritdoc />
public override bool Obsolete => true;
/// <inheritdoc />
public override string ObsoleteMessage =>
"This flow element has been replaced by the Web Request flow element in the Web plugin. This flow element will be removed in a future update.";
/// <summary>
/// Gets or sets the URL
/// </summary>

View File

@@ -97,6 +97,9 @@
"Code": "Code"
}
},
"CompleteFlow": {
"Description": "Completes/ends the flow as successful"
},
"CopyFile": {
"Description": "Copies a file to the destination folder",
"Outputs": {
@@ -245,6 +248,18 @@
"Recursive-Help": "If files in all sub directories should also be iterated, or if only the top level files should be iterated."
}
},
"ListIterator": {
"Description": "Iterates all strings in a given list and executes those strings against a sub flow.",
"Outputs": {
"1": "List iterated"
},
"Fields": {
"Flow": "Flow",
"Flow-Help": "The sub flow to execute the strings against.",
"List": "List",
"List-Help": "A name of a variable containing the list to iterate."
}
},
"FailFlow": {
"Description": "Fails a flow immediately, useful if you want a certain path to just fail.",
"Fields": {