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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,5 @@ public enum AppSymbols
|
||||
search,
|
||||
eye,
|
||||
invisible,
|
||||
heart_with_pulse,
|
||||
}
|
||||
|
||||
11
ModpackUpdater.Apps/Symbols/heart_with_pulse.svg
Normal file
11
ModpackUpdater.Apps/Symbols/heart_with_pulse.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="240" height="240">
|
||||
<linearGradient id="o5BohGJy0xHajxWpIzsAMa" x1="15.595" x2="35.333" y1="4.867" y2="35.264" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#f44f5a" />
|
||||
<stop offset=".443" stop-color="#ee3d4a" />
|
||||
<stop offset="1" stop-color="#e52030" />
|
||||
</linearGradient>
|
||||
<path fill="url(#o5BohGJy0xHajxWpIzsAMa)" d="M24,12.25c0,0,4.701-5.25,10.5-5.25S45,11.765,45,17.5c0,9.869-15.466,21.138-19.853,24.135c-0.695,0.475-1.599,0.475-2.294,0C18.466,38.638,3,27.369,3,17.5C3,11.765,7.701,7,13.5,7S24,12.25,24,12.25z" />
|
||||
<path fill="#ffebee" d="M26.67,28.236c0.111,0.362,0.419,0.63,0.793,0.691c0.369,0.058,0.751-0.095,0.973-0.401L30.261,26H34.5c0.553,0,1-0.448,1-1s-0.447-1-1-1h-4.75c-0.321,0-0.622,0.154-0.811,0.415l-0.951,1.316l-1.783-5.767c-0.126-0.41-0.5-0.693-0.929-0.704c-0.425-0.017-0.816,0.251-0.965,0.654l-3.192,8.659L19.24,15.483c-0.065-0.456-0.434-0.807-0.891-0.853c-0.466-0.049-0.888,0.227-1.042,0.66l-3.214,9.045l-2.641-3.896c-0.198-0.291-0.536-0.461-0.882-0.438c-0.351,0.019-0.665,0.22-0.829,0.529L7.898,24H4.903c0.365,0.671,0.772,1.338,1.216,2H8.5c0.37,0,0.71-0.204,0.883-0.531l1.347-2.534l2.817,4.158c0.211,0.312,0.571,0.481,0.955,0.431c0.374-0.047,0.689-0.302,0.815-0.657l2.519-7.09l1.865,12.99c0.065,0.453,0.43,0.804,0.885,0.853c0.036,0.003,0.071,0.005,0.106,0.005c0.414,0,0.791-0.258,0.938-0.654l3.537-9.595L26.67,28.236z" />
|
||||
<path fill="#ffebee" d="M35,23c-1.105,0-2,0.895-2,2s0.895,2,2,2s2-0.895,2-2S36.105,23,35,23z" />
|
||||
</svg>
|
||||
@@ -7,7 +7,7 @@ namespace ModpackUpdater.Manager;
|
||||
public class ModpackFactory
|
||||
{
|
||||
private readonly GitHubClient github = new(new ProductHeaderValue("MinecraftModpackUpdater"));
|
||||
private readonly CurseForge.APIClient.ApiClient curseForge = new("b67bd218-e011-4963-ac8a-ffd025e1091f", "pilzinsel64@gmx.de");
|
||||
private readonly CurseForge.APIClient.ApiClient curseForge = new("$2a$10$pE4dD09gmr7IcOe8hjWhleWWjXopJcDNpq1P9FlrDMCBw05pCyAXa", "pilzinsel64@gmx.de"); // b67bd218-e011-4963-ac8a-ffd025e1091f
|
||||
private readonly ModrinthClient modrinth = new(new ModrinthClientConfig
|
||||
{
|
||||
ModrinthToken = "mrp_zUlDSET5actMUdTU3FK242TXgvlWgaErSSEFuegNG7thLgkC50IiK2NCGOzW",
|
||||
|
||||
Reference in New Issue
Block a user