finish healthy check & other sources implemtation
This commit is contained in:
@@ -4,4 +4,5 @@ public static class FeatureTypes
|
||||
{
|
||||
public static string Workspace => "workspace";
|
||||
public static string Tools => "tools";
|
||||
public static string ActionsContextMenu => "cm.actions";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using ModpackUpdater.Apps.Manager.Ui;
|
||||
using ModpackUpdater.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
internal class CheckAllActionsHealthyFeature : PluginFunction, IPluginFeatureProvider<CheckAllActionsHealthyFeature>
|
||||
{
|
||||
public static CheckAllActionsHealthyFeature Instance { get; } = new();
|
||||
|
||||
public CheckAllActionsHealthyFeature() : base(FeatureTypes.Tools, "origin.checkallactionshearlthy", FeatureNamesLangRes.CheckAllActionsHealthy)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.heart_with_pulse, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p
|
||||
|| p.Api.MainWindow is not MainForm mainForm
|
||||
|| mainForm.Controls.Find("radGridView_Actions", true).FirstOrDefault() is not RadGridView gridView
|
||||
|| mainForm.Controls.Find("radWaitingBar_Actions", true).FirstOrDefault() is not RadWaitingBar rwb)
|
||||
return null;
|
||||
|
||||
rwb.StartWaiting();
|
||||
rwb.ShowText = true;
|
||||
var rowsCount = gridView.Rows.Count;
|
||||
rwb.Text = "0 / " + rowsCount;
|
||||
gridView.BeginUpdate();
|
||||
|
||||
var rows = new Dictionary<GridViewRowInfo, InstallAction>();
|
||||
for (var i = 0; i < gridView.Rows.Count; i++)
|
||||
{
|
||||
var row = gridView.Rows[i];
|
||||
var failed = false;
|
||||
|
||||
if (row.Tag is InstallAction action)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var factory = new ModpackFactory();
|
||||
var result = await factory.ResolveSourceUrl(action);
|
||||
failed = string.IsNullOrWhiteSpace(result);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}).Wait();
|
||||
}
|
||||
|
||||
foreach (var c in row.Cells)
|
||||
{
|
||||
c.Style.CustomizeFill = true;
|
||||
c.Style.BackColor = failed ? Color.IndianRed : Color.ForestGreen;
|
||||
}
|
||||
|
||||
rwb.Text = $"{i} / {rowsCount}";
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
gridView.EndUpdate();
|
||||
rwb.ShowText = false;
|
||||
rwb.StopWaiting();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using ModpackUpdater.Apps.Manager.Ui;
|
||||
using ModpackUpdater.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
internal class CheckSingleActionHealthyFeature : PluginFunction, IPluginFeatureProvider<CheckSingleActionHealthyFeature>
|
||||
{
|
||||
public static CheckSingleActionHealthyFeature Instance { get; } = new();
|
||||
|
||||
public CheckSingleActionHealthyFeature() : base(FeatureTypes.ActionsContextMenu, "origin.checksingleactionhearlthy", FeatureNamesLangRes.CheckSingleActionHealthy)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.heart_with_pulse, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p
|
||||
|| p.Api.MainWindow is not MainForm mainForm
|
||||
|| mainForm.Controls.Find("radGridView_Actions", true).FirstOrDefault() is not RadGridView gridView
|
||||
|| gridView.SelectedRows.FirstOrDefault() is not GridViewRowInfo row
|
||||
|| row.Tag is not InstallAction action)
|
||||
return null;
|
||||
|
||||
bool failed = true;
|
||||
string? msg = null;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var factory = new ModpackFactory();
|
||||
var result = await factory.ResolveSourceUrl(action);
|
||||
failed = string.IsNullOrWhiteSpace(result);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
msg = ex.Message;
|
||||
}
|
||||
}).Wait();
|
||||
|
||||
gridView.BeginUpdate();
|
||||
foreach (var c in row.Cells)
|
||||
{
|
||||
c.Style.CustomizeFill = true;
|
||||
c.Style.BackColor = failed ? Color.IndianRed : Color.ForestGreen;
|
||||
}
|
||||
gridView.EndUpdate();
|
||||
|
||||
if (failed && !string.IsNullOrWhiteSpace(msg))
|
||||
MessageBox.Show(msg);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,24 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Check healthy ähnelt.
|
||||
/// </summary>
|
||||
internal static string CheckAllActionsHealthy {
|
||||
get {
|
||||
return ResourceManager.GetString("CheckAllActionsHealthy", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Check healthy ähnelt.
|
||||
/// </summary>
|
||||
internal static string CheckSingleActionHealthy {
|
||||
get {
|
||||
return ResourceManager.GetString("CheckSingleActionHealthy", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die GitLab workspace ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -117,6 +117,12 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="CheckAllActionsHealthy" xml:space="preserve">
|
||||
<value>Check healthy</value>
|
||||
</data>
|
||||
<data name="CheckSingleActionHealthy" xml:space="preserve">
|
||||
<value>Check healthy</value>
|
||||
</data>
|
||||
<data name="GitLabWorkspace" xml:space="preserve">
|
||||
<value>GitLab workspace</value>
|
||||
</data>
|
||||
|
||||
@@ -175,6 +175,7 @@ partial class MainForm
|
||||
radGridView_Actions.UserAddedRow += RadGridView_Actions_UserAddedRow;
|
||||
radGridView_Actions.UserDeletingRow += RadGridView_Actions_UserDeletingRow;
|
||||
radGridView_Actions.CellValueChanged += RadGridView_Actions_CellValueChanged;
|
||||
radGridView_Actions.ContextMenuOpening += RadGridView_Actions_ContextMenuOpening;
|
||||
//
|
||||
// radMenuItem_Workspace
|
||||
//
|
||||
@@ -274,11 +275,11 @@ partial class MainForm
|
||||
// radWaitingBar_Actions
|
||||
//
|
||||
radWaitingBar_Actions.AssociatedControl = radGridView_Actions;
|
||||
radWaitingBar_Actions.ForeColor = Color.Black;
|
||||
radWaitingBar_Actions.Location = new Point(0, 145);
|
||||
radWaitingBar_Actions.Name = "radWaitingBar_Actions";
|
||||
radWaitingBar_Actions.Size = new Size(70, 70);
|
||||
radWaitingBar_Actions.TabIndex = 3;
|
||||
radWaitingBar_Actions.Text = "radWaitingBar2";
|
||||
radWaitingBar_Actions.WaitingIndicators.Add(dotsRingWaitingBarIndicatorElement2);
|
||||
radWaitingBar_Actions.WaitingIndicatorSize = new Size(100, 14);
|
||||
radWaitingBar_Actions.WaitingSpeed = 50;
|
||||
|
||||
@@ -358,6 +358,7 @@ public partial class MainForm : RadForm, IMainApi
|
||||
row.Cells["srctag"].Value = action.SourceTag;
|
||||
row.Cells["side"].Value = action.Side;
|
||||
row.Cells["isextra"].Value = action.IsExtra;
|
||||
row.Cells["website"].Value = action.Website;
|
||||
|
||||
if (action is not UpdateAction uaction)
|
||||
return;
|
||||
@@ -504,6 +505,9 @@ public partial class MainForm : RadForm, IMainApi
|
||||
case "srctag":
|
||||
action.SourceTag = valueNullStr;
|
||||
break;
|
||||
case "website":
|
||||
action.Website = valueNullStr;
|
||||
break;
|
||||
case "side":
|
||||
action.Side = Enum.Parse<Side>(valueStr);
|
||||
break;
|
||||
@@ -587,4 +591,9 @@ public partial class MainForm : RadForm, IMainApi
|
||||
iinfo.Actions.Remove(iaction);
|
||||
}
|
||||
}
|
||||
|
||||
private void RadGridView_Actions_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
|
||||
{
|
||||
PluginFeatureController.Instance.Functions.Get(FeatureTypes.ActionsContextMenu).InsertItemsTo(e.ContextMenu.Items, customClickHandler: RadMenuItem_ToolsItem_Click);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user