Browse Source

allow download without comfy

pull/629/head
JT 8 months ago
parent
commit
f30181caa8
  1. 15
      StabilityMatrix.Avalonia/ViewModels/Dialogs/OpenArtWorkflowViewModel.cs
  2. 30
      StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs
  3. 3
      StabilityMatrix.Avalonia/Views/Dialogs/OpenArtWorkflowDialog.axaml
  4. 1
      StabilityMatrix.Avalonia/Views/InstalledWorkflowsPage.axaml

15
StabilityMatrix.Avalonia/ViewModels/Dialogs/OpenArtWorkflowViewModel.cs

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.ViewModels.Base;
@ -43,13 +44,18 @@ public partial class OpenArtWorkflowViewModel(
public PackagePair? SelectedPackagePair =>
SelectedPackage is { } package ? packageFactory.GetPackagePair(package) : null;
public IEnumerable<InstalledPackage> AvailablePackages =>
settingsManager.Settings.InstalledPackages.Where(package => package.PackageName == "ComfyUI");
public List<InstalledPackage> AvailablePackages =>
settingsManager
.Settings.InstalledPackages.Where(package => package.PackageName == "ComfyUI")
.ToList();
public List<PackageExtension> MissingNodes { get; } = [];
public override async Task OnLoadedAsync()
{
if (Design.IsDesignMode)
return;
if (settingsManager.Settings.PreferredWorkflowPackage is { } preferredPackage)
{
SelectedPackage = preferredPackage;
@ -59,6 +65,11 @@ public partial class OpenArtWorkflowViewModel(
SelectedPackage = AvailablePackages.FirstOrDefault();
}
if (SelectedPackage == null)
{
InstallRequiredNodes = false;
}
CustomNodes = new ObservableCollection<OpenArtCustomNode>(
await ParseNodes(Workflow.NodesIndex.ToList())
);

30
StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs

@ -154,12 +154,6 @@ public partial class OpenArtBrowserViewModel(
[RelayCommand]
private async Task OpenWorkflow(OpenArtSearchResult workflow)
{
var existingComfy = settingsManager.Settings.InstalledPackages.FirstOrDefault(
x => x.PackageName is "ComfyUI"
);
var comfyPair = packageFactory.GetPackagePair(existingComfy);
var vm = new OpenArtWorkflowViewModel(settingsManager, packageFactory) { Workflow = workflow };
var dialog = new BetterContentDialog
@ -181,26 +175,32 @@ public partial class OpenArtBrowserViewModel(
if (result != ContentDialogResult.Primary)
return;
if (existingComfy == null || comfyPair == null)
{
notificationService.Show(Resources.Label_ComfyRequiredTitle, Resources.Label_ComfyRequiredDetail);
return;
}
List<IPackageStep> steps =
[
new DownloadOpenArtWorkflowStep(openArtApi, vm.Workflow, settingsManager)
];
// Add install steps if missing nodes and preferred
if (vm is { InstallRequiredNodes: true, MissingNodes: { Count: > 0 } missingNodes })
if (
vm is
{
InstallRequiredNodes: true,
MissingNodes: { Count: > 0 } missingNodes,
SelectedPackage: not null,
SelectedPackagePair: not null
}
)
{
var extensionManager = comfyPair.BasePackage.ExtensionManager!;
var extensionManager = vm.SelectedPackagePair.BasePackage.ExtensionManager!;
steps.AddRange(
missingNodes.Select(
extension =>
new InstallExtensionStep(extensionManager, comfyPair.InstalledPackage, extension)
new InstallExtensionStep(
extensionManager,
vm.SelectedPackagePair.InstalledPackage,
extension
)
)
);
}

3
StabilityMatrix.Avalonia/Views/Dialogs/OpenArtWorkflowDialog.axaml

@ -116,7 +116,8 @@
<StackPanel Spacing="4">
<ui:SettingsExpanderItem Content="Install Required Nodes">
<ui:SettingsExpanderItem.Footer>
<CheckBox IsChecked="{Binding InstallRequiredNodes}" />
<CheckBox IsChecked="{Binding InstallRequiredNodes}"
IsEnabled="{Binding AvailablePackages.Count}"/>
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="Target Package">

1
StabilityMatrix.Avalonia/Views/InstalledWorkflowsPage.axaml

@ -239,6 +239,7 @@
Foreground="{DynamicResource TextControlForeground}"
LetterSpacing="0.33"
TextWrapping="Wrap"
MaxWidth="315"
Text="{Binding Workflow.Name}"
ToolTip.Tip="{Binding Workflow.Name}" />
</Border>

Loading…
Cancel
Save