From a2f1d2776ed209beb7042ec92d7d683a05179bde Mon Sep 17 00:00:00 2001 From: "Dr. Jochen Manns" Date: Mon, 2 Feb 2026 10:11:11 +0100 Subject: [PATCH] Moved new flag to the correct model. --- Library/Extensions/SetProgress.cs | 5 ++--- Library/Scripting/Engine/IScriptSite.cs | 3 ++- Library/Scripting/Engine/ProgressDetails.cs | 5 +++++ Library/Scripting/Engine/ProgressManager.cs | 5 +++-- Library/Scripting/Engine/ScriptEngine.Nested.cs | 4 ++-- Library/Scripting/Engine/ScriptEngine.Progress.cs | 4 ++-- Library/Scripting/Generic/GenericProgress.cs | 5 ----- Tests/CoreEx/ProgressManagerTests.cs | 4 ++-- Tests/CoreEx/SetProgressTests.cs | 4 ++-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Library/Extensions/SetProgress.cs b/Library/Extensions/SetProgress.cs index 59d7023..3267887 100644 --- a/Library/Extensions/SetProgress.cs +++ b/Library/Extensions/SetProgress.cs @@ -105,12 +105,10 @@ public class SetProgress : Block var script = context.Engine.MainScript as IGenericScript; var progress = await Values.EvaluateAsync("PROGRESS", context); var name = await Values.EvaluateAsync("NAME", context, false); - var invisible = await Values.EvaluateAsync("NOVISUALIZATION", context, false); context.Engine.ReportProgress( new GenericProgress { - NoVisualisation = invisible, Payload = await Values.EvaluateAsync("PAYLOAD", context, false), PayloadType = await Values.EvaluateAsync("PAYLOADTYPE", context, false), Percentage = progress, @@ -118,7 +116,8 @@ public class SetProgress : Block }, progress / 100d, name, - await Values.EvaluateAsync("ADDESTIMATION", context, false) == true + await Values.EvaluateAsync("ADDESTIMATION", context, false) == true, + await Values.EvaluateAsync("NOVISUALIZATION", context, false) == true ); return await base.EvaluateAsync(context); diff --git a/Library/Scripting/Engine/IScriptSite.cs b/Library/Scripting/Engine/IScriptSite.cs index fdc2225..3a9c809 100644 --- a/Library/Scripting/Engine/IScriptSite.cs +++ b/Library/Scripting/Engine/IScriptSite.cs @@ -37,7 +37,8 @@ public interface IScriptSite /// Progress as a number between 0 and 1. /// Optional display name of the progress. /// If set add time to end estimtation if possible. - void ReportProgress(object info, double? progress, string? name, bool? addEstimation); + /// If set frontend should not display this progress. + void ReportProgress(object info, double? progress, string? name, bool? addEstimation, bool? noVisualisation); /// /// Execute Blockly XML Script and report variables. diff --git a/Library/Scripting/Engine/ProgressDetails.cs b/Library/Scripting/Engine/ProgressDetails.cs index 017399d..fcd387c 100644 --- a/Library/Scripting/Engine/ProgressDetails.cs +++ b/Library/Scripting/Engine/ProgressDetails.cs @@ -25,4 +25,9 @@ public class ProgressDetails /// get to a progress of 1 - in seconds. /// public double? EstimatedRemainingSeconds { get; set; } + + /// + /// Set to hide this progress from the frontend. + /// + public bool? NoVisualisation { get; set; } } diff --git a/Library/Scripting/Engine/ProgressManager.cs b/Library/Scripting/Engine/ProgressManager.cs index fe794ff..6822731 100644 --- a/Library/Scripting/Engine/ProgressManager.cs +++ b/Library/Scripting/Engine/ProgressManager.cs @@ -45,13 +45,14 @@ public void Reset() /// Progress value between 0 and 1. /// Optional name of the progress. /// Set to add time to finish estimation - if possible. - public void Update(object info, double? progress, string? name, bool? addEstimation) + /// Set to hide progress from beeing shown. + public void Update(object info, double? progress, string? name, bool? addEstimation, bool? noVisualisation) { // This is the very first. if (Latest == null) _startProgress = null; // Update as requested. - Latest = new() { Progress = progress ?? 0, Name = name, Info = info }; + Latest = new() { Progress = progress ?? 0, Name = name, Info = info, NoVisualisation = noVisualisation }; // Can not estimate at all. if (Latest.Progress < 0 || Latest.Progress > 1) return; diff --git a/Library/Scripting/Engine/ScriptEngine.Nested.cs b/Library/Scripting/Engine/ScriptEngine.Nested.cs index 9a31877..efbc9c7 100644 --- a/Library/Scripting/Engine/ScriptEngine.Nested.cs +++ b/Library/Scripting/Engine/ScriptEngine.Nested.cs @@ -126,10 +126,10 @@ public Task RunAsync(StartScript request, StartScriptOptions? => _engine.GetUserInputAsync(key, type, delay, required); /// - public void ReportProgress(object info, double? progress, string? name, bool? addEstimation) + public void ReportProgress(object info, double? progress, string? name, bool? addEstimation, bool? noVisualisation) { /* Remember and propagate. */ - _progress.Update(info, progress, name, addEstimation); + _progress.Update(info, progress, name, addEstimation, noVisualisation); _engine.ReportProgress(info, _depth); } diff --git a/Library/Scripting/Engine/ScriptEngine.Progress.cs b/Library/Scripting/Engine/ScriptEngine.Progress.cs index 531be6c..0611164 100644 --- a/Library/Scripting/Engine/ScriptEngine.Progress.cs +++ b/Library/Scripting/Engine/ScriptEngine.Progress.cs @@ -15,9 +15,9 @@ partial class ScriptEngine private readonly ProgressManager _progress = new(); /// - public void ReportProgress(object info, double? progress, string? name, bool? addEstimation) + public void ReportProgress(object info, double? progress, string? name, bool? addEstimation, bool? noVisualisation) { - _progress.Update(info, progress, name, addEstimation); + _progress.Update(info, progress, name, addEstimation, noVisualisation); ReportProgress(info, 0); } diff --git a/Library/Scripting/Generic/GenericProgress.cs b/Library/Scripting/Generic/GenericProgress.cs index 9ae413c..f39d10b 100644 --- a/Library/Scripting/Generic/GenericProgress.cs +++ b/Library/Scripting/Generic/GenericProgress.cs @@ -29,9 +29,4 @@ public class GenericProgress /// [Required, NotNull] public string? ScriptId { get; set; } - - /// - /// Set to hide this progress from the frontend. - /// - public bool? NoVisualisation { get; set; } } \ No newline at end of file diff --git a/Tests/CoreEx/ProgressManagerTests.cs b/Tests/CoreEx/ProgressManagerTests.cs index e002179..c893022 100644 --- a/Tests/CoreEx/ProgressManagerTests.cs +++ b/Tests/CoreEx/ProgressManagerTests.cs @@ -17,7 +17,7 @@ public void Calculate_Progress_Time_To_End(double initial, double next, double? Assert.That(progress.Latest, Is.Null); - progress.Update(false, initial, null, true); + progress.Update(false, initial, null, true, null); Assert.That(progress.Latest, Is.Not.Null); @@ -29,7 +29,7 @@ public void Calculate_Progress_Time_To_End(double initial, double next, double? now = now.AddSeconds(3); - progress.Update(false, next, null, true); + progress.Update(false, next, null, true, null); Assert.That(progress.Latest, Is.Not.Null); diff --git a/Tests/CoreEx/SetProgressTests.cs b/Tests/CoreEx/SetProgressTests.cs index 553df17..f3cc13a 100644 --- a/Tests/CoreEx/SetProgressTests.cs +++ b/Tests/CoreEx/SetProgressTests.cs @@ -26,8 +26,8 @@ public async Task SetProgress_Async() GenericProgress? progress = null; Site - .Setup(e => e.ReportProgress(It.IsAny(), 0.299d, "ZERA", true)) - .Callback((object? p, double? rel, string? name, bool? add) => progress = (GenericProgress)p!); + .Setup(e => e.ReportProgress(It.IsAny(), 0.299d, "ZERA", true, false)) + .Callback((object? p, double? rel, string? name, bool? add, bool? invisible) => progress = (GenericProgress)p!); await block.EnterBlockAsync(new Context(Site.Object));