JT
1 year ago
committed by
GitHub
97 changed files with 4812 additions and 2855 deletions
@ -1,3 +1,5 @@ |
|||||||
namespace StabilityMatrix.Avalonia.Diagnostics.LogViewer.Core.ViewModels; |
namespace StabilityMatrix.Avalonia.Diagnostics.LogViewer.Core.ViewModels; |
||||||
|
|
||||||
public class ViewModel : ObservableObject { /* skip */ } |
public class ViewModel |
||||||
|
: ObservableObject { /* skip */ |
||||||
|
} |
||||||
|
@ -0,0 +1,11 @@ |
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
|
|
||||||
|
public partial class ConsoleProgressViewModel : ProgressViewModel |
||||||
|
{ |
||||||
|
public ConsoleViewModel Console { get; } = new(); |
||||||
|
|
||||||
|
[ObservableProperty] |
||||||
|
private bool closeWhenFinished; |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
using System; |
||||||
|
using FluentAvalonia.UI.Controls; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
|
|
||||||
|
public class ContentDialogProgressViewModelBase : ConsoleProgressViewModel |
||||||
|
{ |
||||||
|
public event EventHandler<ContentDialogResult>? PrimaryButtonClick; |
||||||
|
public event EventHandler<ContentDialogResult>? SecondaryButtonClick; |
||||||
|
public event EventHandler<ContentDialogResult>? CloseButtonClick; |
||||||
|
|
||||||
|
public virtual void OnPrimaryButtonClick() |
||||||
|
{ |
||||||
|
PrimaryButtonClick?.Invoke(this, ContentDialogResult.Primary); |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void OnSecondaryButtonClick() |
||||||
|
{ |
||||||
|
SecondaryButtonClick?.Invoke(this, ContentDialogResult.Secondary); |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void OnCloseButtonClick() |
||||||
|
{ |
||||||
|
CloseButtonClick?.Invoke(this, ContentDialogResult.None); |
||||||
|
} |
||||||
|
} |
@ -1,8 +1,7 @@ |
|||||||
using System; |
using System; |
||||||
using FluentAvalonia.UI.Controls; |
using FluentAvalonia.UI.Controls; |
||||||
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; |
namespace StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
|
|
||||||
public class ContentDialogViewModelBase : ViewModelBase |
public class ContentDialogViewModelBase : ViewModelBase |
||||||
{ |
{ |
@ -0,0 +1,78 @@ |
|||||||
|
using System; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Avalonia.Threading; |
||||||
|
using FluentAvalonia.UI.Controls; |
||||||
|
using StabilityMatrix.Avalonia.Controls; |
||||||
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
|
using StabilityMatrix.Avalonia.Views.Dialogs; |
||||||
|
using StabilityMatrix.Core.Helper; |
||||||
|
using StabilityMatrix.Core.Models.PackageModification; |
||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.ViewModels.Progress; |
||||||
|
|
||||||
|
public class PackageInstallProgressItemViewModel : ProgressItemViewModelBase |
||||||
|
{ |
||||||
|
private readonly IPackageModificationRunner packageModificationRunner; |
||||||
|
private BetterContentDialog? dialog; |
||||||
|
|
||||||
|
public PackageInstallProgressItemViewModel(IPackageModificationRunner packageModificationRunner) |
||||||
|
{ |
||||||
|
this.packageModificationRunner = packageModificationRunner; |
||||||
|
Id = packageModificationRunner.Id; |
||||||
|
Name = packageModificationRunner.CurrentStep?.ProgressTitle; |
||||||
|
Progress.Value = packageModificationRunner.CurrentProgress.Percentage; |
||||||
|
Progress.Text = packageModificationRunner.ConsoleOutput.LastOrDefault(); |
||||||
|
Progress.IsIndeterminate = packageModificationRunner.CurrentProgress.IsIndeterminate; |
||||||
|
|
||||||
|
Progress.Console.StartUpdates(); |
||||||
|
|
||||||
|
Progress.Console.Post( |
||||||
|
string.Join(Environment.NewLine, packageModificationRunner.ConsoleOutput) |
||||||
|
); |
||||||
|
|
||||||
|
packageModificationRunner.ProgressChanged += PackageModificationRunnerOnProgressChanged; |
||||||
|
} |
||||||
|
|
||||||
|
private void PackageModificationRunnerOnProgressChanged(object? sender, ProgressReport e) |
||||||
|
{ |
||||||
|
Progress.Value = e.Percentage; |
||||||
|
Progress.Description = e.Message; |
||||||
|
Progress.IsIndeterminate = e.IsIndeterminate; |
||||||
|
Progress.Text = packageModificationRunner.CurrentStep?.ProgressTitle; |
||||||
|
Name = packageModificationRunner.CurrentStep?.ProgressTitle; |
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(e.Message) || e.Message.Contains("Downloading...")) |
||||||
|
return; |
||||||
|
|
||||||
|
Progress.Console.PostLine(e.Message); |
||||||
|
EventManager.Instance.OnScrollToBottomRequested(); |
||||||
|
|
||||||
|
if ( |
||||||
|
e is { Message: not null, Percentage: >= 100 } |
||||||
|
&& e.Message.Contains("Package Install Complete") |
||||||
|
&& Progress.CloseWhenFinished |
||||||
|
) |
||||||
|
{ |
||||||
|
Dispatcher.UIThread.Post(() => dialog?.Hide()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public async Task ShowProgressDialog() |
||||||
|
{ |
||||||
|
Progress.CloseWhenFinished = true; |
||||||
|
dialog = new BetterContentDialog |
||||||
|
{ |
||||||
|
MaxDialogWidth = 900, |
||||||
|
MinDialogWidth = 900, |
||||||
|
DefaultButton = ContentDialogButton.Close, |
||||||
|
IsPrimaryButtonEnabled = false, |
||||||
|
IsSecondaryButtonEnabled = false, |
||||||
|
IsFooterVisible = false, |
||||||
|
Content = new PackageModificationDialog { DataContext = Progress } |
||||||
|
}; |
||||||
|
EventManager.Instance.OnToggleProgressFlyout(); |
||||||
|
await dialog.ShowAsync(); |
||||||
|
} |
||||||
|
} |
@ -1,10 +1,8 @@ |
|||||||
using System; |
using StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
using CommunityToolkit.Mvvm.ComponentModel; |
|
||||||
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
||||||
using StabilityMatrix.Core.Helper; |
using StabilityMatrix.Core.Helper; |
||||||
using StabilityMatrix.Core.Models.Progress; |
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.ViewModels; |
namespace StabilityMatrix.Avalonia.ViewModels.Progress; |
||||||
|
|
||||||
public class ProgressItemViewModel : ProgressItemViewModelBase |
public class ProgressItemViewModel : ProgressItemViewModelBase |
||||||
{ |
{ |
@ -1,249 +1,228 @@ |
|||||||
<controls:UserControlBase xmlns="https://github.com/avaloniaui" |
<controls:UserControlBase xmlns="https://github.com/avaloniaui" |
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||||
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls" |
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls" |
||||||
xmlns:ui="using:FluentAvalonia.UI.Controls" |
xmlns:ui="using:FluentAvalonia.UI.Controls" |
||||||
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData" |
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData" |
||||||
xmlns:dialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs" |
xmlns:dialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs" |
||||||
xmlns:packages="clr-namespace:StabilityMatrix.Core.Models.Packages;assembly=StabilityMatrix.Core" |
xmlns:packages="clr-namespace:StabilityMatrix.Core.Models.Packages;assembly=StabilityMatrix.Core" |
||||||
xmlns:models="clr-namespace:StabilityMatrix.Core.Models;assembly=StabilityMatrix.Core" |
xmlns:models="clr-namespace:StabilityMatrix.Core.Models;assembly=StabilityMatrix.Core" |
||||||
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" |
xmlns:database="clr-namespace:StabilityMatrix.Core.Models.Database;assembly=StabilityMatrix.Core" |
||||||
xmlns:database="clr-namespace:StabilityMatrix.Core.Models.Database;assembly=StabilityMatrix.Core" |
x:DataType="dialogs:InstallerViewModel" |
||||||
xmlns:icons="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" |
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="700" |
||||||
x:DataType="dialogs:InstallerViewModel" |
d:DataContext="{x:Static mocks:DesignData.InstallerViewModel}" |
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="500" |
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.InstallerDialog"> |
||||||
d:DataContext="{x:Static mocks:DesignData.InstallerViewModel}" |
|
||||||
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.InstallerDialog"> |
<Grid MaxHeight="900" |
||||||
|
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto" |
||||||
<Grid RowDefinitions="Auto,Auto,Auto,*"> |
ColumnDefinitions="*,Auto"> |
||||||
<!-- Close button --> |
<!-- Title and image --> |
||||||
<Grid HorizontalAlignment="Right"> |
<Grid Grid.Row="0" Grid.Column="0" |
||||||
<Button |
Margin="16, 0, 0, 0" |
||||||
Margin="0,8,8,0" |
RowDefinitions="Auto, Auto, Auto, Auto, Auto"> |
||||||
Classes="transparent" |
<TextBlock Grid.Row="0" Text="{Binding SelectedPackage.DisplayName}" |
||||||
IsEnabled="{Binding !InstallProgress.IsProgressVisible}" |
FontSize="24" |
||||||
Command="{Binding OnCloseButtonClick}" |
Margin="0, 16, 0, 4" /> |
||||||
icons:Attached.Icon="fa-solid fa-xmark"/> |
<TextBlock Grid.Row="1" Text="{Binding SelectedPackage.Blurb}" |
||||||
|
Margin="0, 0, 0, 4" /> |
||||||
|
<TextBlock Grid.Row="2" Text="{Binding SelectedPackage.Disclaimer}" |
||||||
|
Margin="0, 0, 0, 4" |
||||||
|
TextWrapping="Wrap" |
||||||
|
Foreground="{DynamicResource ThemeRedColor}" |
||||||
|
IsVisible="{Binding SelectedPackage.Disclaimer, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" /> |
||||||
|
<controls:BetterAdvancedImage Grid.Row="4" |
||||||
|
Margin="0, 12,0,0" |
||||||
|
Source="{Binding SelectedPackage.PreviewImageUri}" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
MaxHeight="300" |
||||||
|
MaxWidth="600" |
||||||
|
Stretch="UniformToFill" /> |
||||||
</Grid> |
</Grid> |
||||||
<StackPanel |
|
||||||
Grid.Row="1" |
|
||||||
Margin="16,8,16,0" |
|
||||||
Orientation="Vertical" |
|
||||||
DataContext="{Binding InstallProgress}" |
|
||||||
IsVisible="{Binding IsProgressVisible}"> |
|
||||||
|
|
||||||
<TextBlock |
|
||||||
HorizontalAlignment="Center" |
|
||||||
Padding="8" |
|
||||||
Text="{Binding Text}" /> |
|
||||||
<ProgressBar |
|
||||||
IsIndeterminate="{Binding IsIndeterminate}" |
|
||||||
Maximum="100" |
|
||||||
Width="500" |
|
||||||
Value="{Binding Value}" /> |
|
||||||
<TextBlock |
|
||||||
FontSize="10" |
|
||||||
HorizontalAlignment="Center" |
|
||||||
Padding="4" |
|
||||||
Text="{Binding Description}" |
|
||||||
TextWrapping="Wrap" /> |
|
||||||
</StackPanel> |
|
||||||
|
|
||||||
<Grid Grid.Row="2" HorizontalAlignment="Left" ColumnDefinitions="Auto,*,Auto"> |
|
||||||
<ListBox |
|
||||||
Margin="8,16" |
|
||||||
IsEnabled="{Binding !InstallProgress.IsProgressVisible}" |
|
||||||
ItemsSource="{Binding AvailablePackages}" |
|
||||||
SelectedItem="{Binding SelectedPackage, Mode=TwoWay}"> |
|
||||||
|
|
||||||
<!--<ListView.Style> |
|
||||||
<Style TargetType="ListView"> |
|
||||||
<Setter Property="Background" Value="#191919" /> |
|
||||||
</Style> |
|
||||||
</ListView.Style>--> |
|
||||||
|
|
||||||
<ListBox.Template> |
|
||||||
<ControlTemplate> |
|
||||||
<!-- BorderBrush="{KeyboardFocusBorderColorBrush}" --> |
|
||||||
<Border |
|
||||||
BorderThickness="1" |
|
||||||
CornerRadius="5"> |
|
||||||
<ItemsPresenter /> |
|
||||||
</Border> |
|
||||||
</ControlTemplate> |
|
||||||
</ListBox.Template> |
|
||||||
|
|
||||||
<ListBox.ItemTemplate> |
|
||||||
<DataTemplate DataType="{x:Type packages:BasePackage}"> |
|
||||||
<StackPanel Margin="8" VerticalAlignment="Top"> |
|
||||||
<TextBlock Margin="0,5,0,5" Text="{Binding DisplayName}" /> |
|
||||||
<TextBlock Margin="0,0,0,5" Text="{Binding ByAuthor}" /> |
|
||||||
</StackPanel> |
|
||||||
</DataTemplate> |
|
||||||
</ListBox.ItemTemplate> |
|
||||||
</ListBox> |
|
||||||
|
|
||||||
<StackPanel |
<Grid Grid.Column="0" Grid.Row="2" |
||||||
MinWidth="400" |
Grid.ColumnSpan="2" |
||||||
Grid.Column="1" |
Margin="16,0,16,0" |
||||||
Margin="8,16,0,16" |
RowDefinitions="Auto, Auto, Auto, Auto" |
||||||
Orientation="Vertical"> |
HorizontalAlignment="Center" |
||||||
|
ColumnDefinitions="Auto, Auto, Auto, Auto"> |
||||||
|
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" |
||||||
|
Margin="8,0" |
||||||
|
Content="Display Name" /> |
||||||
|
<TextBox Grid.Row="2" Grid.Column="0" |
||||||
|
MinWidth="250" |
||||||
|
Margin="8,0" |
||||||
|
VerticalAlignment="Stretch" |
||||||
|
VerticalContentAlignment="Center" |
||||||
|
Text="{Binding InstallName, Mode=TwoWay}" /> |
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" |
||||||
|
Orientation="Horizontal" |
||||||
|
Margin="8" |
||||||
|
IsVisible="{Binding ShowDuplicateWarning}"> |
||||||
|
<ui:SymbolIcon |
||||||
|
Foreground="{DynamicResource ThemeRedColor}" |
||||||
|
Margin="0,0,8,0" |
||||||
|
Symbol="Alert" /> |
||||||
<TextBlock |
<TextBlock |
||||||
FontSize="24" |
Foreground="{DynamicResource ThemeRedColor}" |
||||||
FontWeight="Bold" |
TextAlignment="Left" |
||||||
Text="{Binding SelectedPackage.DisplayName, FallbackValue=Stable Diffusion Web UI}" /> |
TextWrapping="Wrap"> |
||||||
<TextBlock FontSize="12" Text="{Binding SelectedPackage.ByAuthor, FallbackValue=by Automatic111}" /> |
<Run Text="An installation with this name already exists." /> |
||||||
|
<LineBreak /> |
||||||
<Button |
<Run Text="Please choose a different name or select a different Install Location." /> |
||||||
Background="Transparent" |
</TextBlock> |
||||||
BorderBrush="Transparent" |
</StackPanel> |
||||||
Command="{Binding ShowPreviewCommand}" |
|
||||||
Content="UI Preview" |
|
||||||
Padding="4" |
|
||||||
Margin="0,8,0,0"> |
|
||||||
<!--<Button.Style> |
|
||||||
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="{x:Type Button}"> |
|
||||||
<Setter Property="Foreground"> |
|
||||||
<Setter.Value> |
|
||||||
<SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" /> |
|
||||||
</Setter.Value> |
|
||||||
</Setter> |
|
||||||
</Style> |
|
||||||
</Button.Style>--> |
|
||||||
</Button> |
|
||||||
|
|
||||||
<ui:HyperlinkButton Padding="4" |
|
||||||
NavigateUri="{Binding SelectedPackage.LicenseUrl}"> |
|
||||||
<TextBlock TextWrapping="Wrap"> |
|
||||||
<Run Text="{Binding SelectedPackage.LicenseType, Mode=OneWay}" /> |
|
||||||
<Run Text="License" /> |
|
||||||
</TextBlock> |
|
||||||
</ui:HyperlinkButton> |
|
||||||
|
|
||||||
<ui:HyperlinkButton Padding="4" |
|
||||||
NavigateUri="{Binding SelectedPackage.GithubUrl}"> |
|
||||||
<TextBlock TextWrapping="Wrap"> |
|
||||||
<Run Text="GitHub Page:" /> |
|
||||||
<Run Text="{Binding SelectedPackage.GithubUrl, Mode=OneWay}" TextDecorations="Underline" /> |
|
||||||
</TextBlock> |
|
||||||
</ui:HyperlinkButton> |
|
||||||
|
|
||||||
<TextBlock Text="{Binding SelectedPackage.Disclaimer}" |
|
||||||
Padding="4" |
|
||||||
Foreground="OrangeRed" |
|
||||||
TextWrapping="Wrap" |
|
||||||
IsVisible="{Binding SelectedPackage.Disclaimer, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> |
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,8,0,0" |
<!-- Version Selector --> |
||||||
IsVisible="{Binding IsReleaseModeAvailable}"> |
<Label Grid.Row="1" Grid.Column="1" |
||||||
<ToggleButton |
Content="{Binding ReleaseLabelText}" /> |
||||||
Content="Releases" |
<ui:FAComboBox Grid.Row="2" Grid.Column="1" |
||||||
IsChecked="{Binding IsReleaseMode}" |
ItemsSource="{Binding AvailableVersions}" |
||||||
IsEnabled="{Binding IsReleaseModeAvailable}" /> |
MinWidth="250" |
||||||
<ToggleButton |
VerticalAlignment="Stretch" |
||||||
Content="Branches" |
SelectedItem="{Binding SelectedVersion}"> |
||||||
IsChecked="{Binding !IsReleaseMode}" |
<ui:FAComboBox.ItemTemplate> |
||||||
Margin="8,0,0,0" /> |
<DataTemplate DataType="{x:Type models:PackageVersion}"> |
||||||
</StackPanel> |
<TextBlock |
||||||
|
Name="NameTextBlock" |
||||||
|
VerticalAlignment="Center" |
||||||
|
Text="{Binding TagName}" /> |
||||||
|
</DataTemplate> |
||||||
|
</ui:FAComboBox.ItemTemplate> |
||||||
|
</ui:FAComboBox> |
||||||
|
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Orientation="Horizontal" Margin="0,8,0,8" |
||||||
|
IsVisible="{Binding IsReleaseModeAvailable}"> |
||||||
|
<ToggleButton |
||||||
|
Content="Releases" |
||||||
|
IsChecked="{Binding IsReleaseMode}" |
||||||
|
IsEnabled="{Binding IsReleaseModeAvailable}" /> |
||||||
|
<ToggleButton |
||||||
|
Content="Branches" |
||||||
|
IsChecked="{Binding !IsReleaseMode}" |
||||||
|
Margin="8,0,0,0" /> |
||||||
|
</StackPanel> |
||||||
|
|
||||||
<StackPanel Margin="0,16,0,0" Orientation="Horizontal"> |
<!-- Advanced Options Button --> |
||||||
<StackPanel Orientation="Vertical"> |
<Button Grid.Row="2" Grid.Column="2" VerticalAlignment="Stretch" |
||||||
<Label Content="{Binding ReleaseLabelText}" /> |
Margin="8,0"> |
||||||
<ComboBox |
<ui:SymbolIcon FontSize="16" Margin="4" Symbol="Settings" /> |
||||||
ItemsSource="{Binding AvailableVersions}" |
<Button.Flyout> |
||||||
MinWidth="200" |
<Flyout> |
||||||
SelectedItem="{Binding SelectedVersion}"> |
<!-- Advanced Options --> |
||||||
<ComboBox.ItemTemplate> |
<StackPanel Orientation="Vertical" |
||||||
<DataTemplate DataType="{x:Type models:PackageVersion}"> |
Margin="8" |
||||||
<StackPanel Margin="8,0,0,0" VerticalAlignment="Top"> |
IsVisible="{Binding !IsAdvancedMode}"> |
||||||
|
|
||||||
|
<Label Content="Advanced Options" |
||||||
|
FontSize="18" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Margin="8,0,8,8" /> |
||||||
|
|
||||||
|
<Label Content="Commit" |
||||||
|
Margin="0,0,0,4" |
||||||
|
IsVisible="{Binding !IsReleaseMode}" /> |
||||||
|
<ui:FAComboBox |
||||||
|
IsVisible="{Binding !IsReleaseMode}" |
||||||
|
ItemsSource="{Binding AvailableCommits}" |
||||||
|
MinWidth="200" |
||||||
|
MinHeight="38" |
||||||
|
SelectedItem="{Binding SelectedCommit}"> |
||||||
|
<ui:FAComboBox.ItemTemplate> |
||||||
|
<DataTemplate DataType="{x:Type database:GitCommit}"> |
||||||
<TextBlock |
<TextBlock |
||||||
Margin="0,4,0,4" |
Margin="8,4,0,4" |
||||||
Name="NameTextBlock" |
Name="NameTextBlock" |
||||||
Text="{Binding TagName}" /> |
Text="{Binding ShortSha}" /> |
||||||
</StackPanel> |
</DataTemplate> |
||||||
</DataTemplate> |
</ui:FAComboBox.ItemTemplate> |
||||||
</ComboBox.ItemTemplate> |
</ui:FAComboBox> |
||||||
</ComboBox> |
|
||||||
</StackPanel> |
<Label Content="Shared Model Folder Strategy" |
||||||
|
Margin="0,8,0,4" /> |
||||||
<StackPanel |
<ui:FAComboBox |
||||||
Margin="8,0,0,0" |
ItemsSource="{Binding SelectedPackage.AvailableSharedFolderMethods}" |
||||||
Orientation="Vertical" |
MinWidth="200" |
||||||
IsVisible="{Binding !IsReleaseMode}"> |
MinHeight="38" |
||||||
<Label Content="Commit" /> |
SelectedItem="{Binding SelectedSharedFolderMethod}"> |
||||||
<ComboBox |
<ui:FAComboBox.ItemTemplate> |
||||||
ItemsSource="{Binding AvailableCommits}" |
<DataTemplate DataType="{x:Type models:SharedFolderMethod}"> |
||||||
MinWidth="100" |
|
||||||
SelectedItem="{Binding SelectedCommit}"> |
|
||||||
<ComboBox.ItemTemplate> |
|
||||||
<DataTemplate DataType="{x:Type database:GitCommit}"> |
|
||||||
<StackPanel Margin="8,0,0,0" VerticalAlignment="Top"> |
|
||||||
<TextBlock |
<TextBlock |
||||||
Margin="0,4,0,4" |
Margin="8,4,0,4" |
||||||
Name="NameTextBlock" |
Text="{Binding }" /> |
||||||
Text="{Binding Sha}" /> |
</DataTemplate> |
||||||
</StackPanel> |
</ui:FAComboBox.ItemTemplate> |
||||||
</DataTemplate> |
</ui:FAComboBox> |
||||||
</ComboBox.ItemTemplate> |
|
||||||
</ComboBox> |
<Label Content="PyTorch Version" |
||||||
</StackPanel> |
IsVisible="{Binding ShowTorchVersionOptions}" |
||||||
</StackPanel> |
Margin="0,8,0,4" /> |
||||||
|
<ui:FAComboBox |
||||||
<Label Content="Display Name" Margin="0,16,0,0" /> |
ItemsSource="{Binding SelectedPackage.AvailableTorchVersions}" |
||||||
<StackPanel Orientation="Horizontal" IsVisible="{Binding ShowDuplicateWarning}"> |
MinWidth="200" |
||||||
<ui:SymbolIcon |
MinHeight="38" |
||||||
Foreground="{DynamicResource ThemeRedColor}" |
IsVisible="{Binding ShowTorchVersionOptions}" |
||||||
Margin="8" |
SelectedItem="{Binding SelectedTorchVersion}"> |
||||||
Symbol="Alert" /> |
<ui:FAComboBox.ItemTemplate> |
||||||
<TextBlock |
<DataTemplate DataType="{x:Type models:TorchVersion}"> |
||||||
Foreground="{DynamicResource ThemeRedColor}" |
<TextBlock |
||||||
Margin="0,8,8,8" |
Margin="8,4,0,4" |
||||||
TextAlignment="Left" |
Text="{Binding }" /> |
||||||
TextWrapping="Wrap"> |
</DataTemplate> |
||||||
<Run Text="An installation with this name already exists." /> |
</ui:FAComboBox.ItemTemplate> |
||||||
<LineBreak /> |
</ui:FAComboBox> |
||||||
<Run Text="Please choose a different name or select a different Install Location." /> |
</StackPanel> |
||||||
</TextBlock> |
</Flyout> |
||||||
</StackPanel> |
</Button.Flyout> |
||||||
|
</Button> |
||||||
<TextBox |
|
||||||
Margin="0,0,0,8" |
|
||||||
Text="{Binding InstallName, Mode=TwoWay}" /> |
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal"> |
|
||||||
<Button |
|
||||||
Command="{Binding InstallCommand}" |
|
||||||
Content="Install" |
|
||||||
Classes="success" |
|
||||||
Height="50" |
|
||||||
IsEnabled="{Binding !ShowDuplicateWarning}" |
|
||||||
Margin="0,16,0,0" |
|
||||||
VerticalAlignment="Top" |
|
||||||
Width="100" /> |
|
||||||
<controls:ProgressRing |
|
||||||
Height="25" |
|
||||||
IsIndeterminate="True" |
|
||||||
BorderThickness="4" |
|
||||||
Margin="8,16,0,0" |
|
||||||
VerticalAlignment="Center" |
|
||||||
IsVisible="{Binding InstallProgress.IsProgressVisible}" |
|
||||||
Width="25" /> |
|
||||||
<TextBlock |
|
||||||
Margin="8,16,0,0" |
|
||||||
Text="Installing..." |
|
||||||
VerticalAlignment="Center" |
|
||||||
IsVisible="{Binding InstallProgress.IsProgressVisible}" /> |
|
||||||
</StackPanel> |
|
||||||
</StackPanel> |
|
||||||
<ScrollViewer Grid.Column="2" |
|
||||||
MaxWidth="300" |
|
||||||
Margin="16" |
|
||||||
MaxHeight="600"> |
|
||||||
<mdxaml:MarkdownScrollViewer |
|
||||||
Markdown="{Binding ReleaseNotes, Mode=OneWay}"/> |
|
||||||
</ScrollViewer> |
|
||||||
</Grid> |
</Grid> |
||||||
|
|
||||||
|
<!-- Install Button --> |
||||||
|
<UniformGrid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" |
||||||
|
Columns="2" |
||||||
|
Margin="0,32,0,0" |
||||||
|
HorizontalAlignment="Center"> |
||||||
|
<Button |
||||||
|
Content="Cancel" |
||||||
|
Command="{Binding Cancel}" |
||||||
|
FontSize="20" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Margin="8,0,4,0" |
||||||
|
Padding="16, 8, 16, 8" /> |
||||||
|
<Button |
||||||
|
Content="Install" |
||||||
|
Command="{Binding InstallCommand}" |
||||||
|
FontSize="20" |
||||||
|
IsEnabled="{Binding CanInstall}" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Classes="success" |
||||||
|
Margin="4,0,8,0" |
||||||
|
Padding="16, 8, 16, 8" /> |
||||||
|
</UniformGrid> |
||||||
|
|
||||||
|
<!-- Available Packages --> |
||||||
|
<ListBox Grid.Column="1" Grid.Row="0" |
||||||
|
Margin="8, 16" |
||||||
|
ItemsSource="{Binding AvailablePackages}" |
||||||
|
SelectedItem="{Binding SelectedPackage}"> |
||||||
|
<ListBox.Template> |
||||||
|
<ControlTemplate> |
||||||
|
<ItemsPresenter /> |
||||||
|
</ControlTemplate> |
||||||
|
</ListBox.Template> |
||||||
|
<ListBox.ItemTemplate> |
||||||
|
<DataTemplate DataType="{x:Type packages:BasePackage}"> |
||||||
|
<StackPanel Margin="8"> |
||||||
|
<TextBlock Text="{Binding DisplayName}" /> |
||||||
|
<TextBlock Text="{Binding ByAuthor}" /> |
||||||
|
</StackPanel> |
||||||
|
</DataTemplate> |
||||||
|
</ListBox.ItemTemplate> |
||||||
|
</ListBox> |
||||||
</Grid> |
</Grid> |
||||||
|
|
||||||
</controls:UserControlBase> |
</controls:UserControlBase> |
||||||
|
@ -0,0 +1,56 @@ |
|||||||
|
<controls:UserControlBase xmlns="https://github.com/avaloniaui" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||||
|
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls" |
||||||
|
xmlns:dialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs" |
||||||
|
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit" |
||||||
|
xmlns:base="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Base" |
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||||
|
x:DataType="base:ContentDialogProgressViewModelBase" |
||||||
|
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.PackageModificationDialog"> |
||||||
|
<Grid Margin="8" RowDefinitions="Auto, Auto, Auto, *, Auto, Auto"> |
||||||
|
<TextBlock Grid.Row="0" Text="{Binding Text}" |
||||||
|
FontSize="16" |
||||||
|
Margin="4" |
||||||
|
TextWrapping="WrapWithOverflow" |
||||||
|
TextAlignment="Center" |
||||||
|
HorizontalAlignment="Stretch"/> |
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Text="{Binding Description}" |
||||||
|
Margin="4" |
||||||
|
TextWrapping="WrapWithOverflow" |
||||||
|
TextAlignment="Center" |
||||||
|
IsVisible="{Binding !#Expander.IsExpanded}"/> |
||||||
|
|
||||||
|
<ProgressBar Grid.Row="2" Value="{Binding Value}" |
||||||
|
Margin="8" |
||||||
|
IsIndeterminate="{Binding IsIndeterminate}"/> |
||||||
|
|
||||||
|
<Expander Grid.Row="3" |
||||||
|
Margin="8" |
||||||
|
Header="More Details" x:Name="Expander"> |
||||||
|
<avaloniaEdit:TextEditor |
||||||
|
x:Name="Console" |
||||||
|
Margin="8" |
||||||
|
MaxHeight="400" |
||||||
|
DataContext="{Binding Console}" |
||||||
|
Document="{Binding Document}" |
||||||
|
FontFamily="Cascadia Code,Consolas,Menlo,Monospace" |
||||||
|
IsReadOnly="True" |
||||||
|
LineNumbersForeground="DarkSlateGray" |
||||||
|
ShowLineNumbers="True" |
||||||
|
VerticalScrollBarVisibility="Auto" |
||||||
|
WordWrap="True" /> |
||||||
|
</Expander> |
||||||
|
|
||||||
|
<CheckBox Grid.Row="4" IsChecked="{Binding CloseWhenFinished}" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Margin="4" Content="Close dialog when finished"/> |
||||||
|
|
||||||
|
<Button Grid.Row="5" Content="Close" |
||||||
|
FontSize="20" |
||||||
|
HorizontalAlignment="Center" |
||||||
|
Command="{Binding OnCloseButtonClick}"/> |
||||||
|
</Grid> |
||||||
|
</controls:UserControlBase> |
@ -0,0 +1,51 @@ |
|||||||
|
using System; |
||||||
|
using Avalonia.Controls; |
||||||
|
using Avalonia.Media; |
||||||
|
using Avalonia.Threading; |
||||||
|
using AvaloniaEdit; |
||||||
|
using AvaloniaEdit.TextMate; |
||||||
|
using StabilityMatrix.Avalonia.Controls; |
||||||
|
using StabilityMatrix.Core.Helper; |
||||||
|
using TextMateSharp.Grammars; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.Views.Dialogs; |
||||||
|
|
||||||
|
public partial class PackageModificationDialog : UserControlBase |
||||||
|
{ |
||||||
|
public PackageModificationDialog() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
|
||||||
|
var editor = this.FindControl<TextEditor>("Console"); |
||||||
|
if (editor is not null) |
||||||
|
{ |
||||||
|
var options = new RegistryOptions(ThemeName.DarkPlus); |
||||||
|
|
||||||
|
// Config hyperlinks |
||||||
|
editor.TextArea.Options.EnableHyperlinks = true; |
||||||
|
editor.TextArea.Options.RequireControlModifierForHyperlinkClick = false; |
||||||
|
editor.TextArea.TextView.LinkTextForegroundBrush = Brushes.Coral; |
||||||
|
|
||||||
|
var textMate = editor.InstallTextMate(options); |
||||||
|
var scope = options.GetScopeByLanguageId("log"); |
||||||
|
|
||||||
|
if (scope is null) |
||||||
|
throw new InvalidOperationException("Scope is null"); |
||||||
|
|
||||||
|
textMate.SetGrammar(scope); |
||||||
|
textMate.SetTheme(options.LoadTheme(ThemeName.DarkPlus)); |
||||||
|
} |
||||||
|
|
||||||
|
EventManager.Instance.ScrollToBottomRequested += (_, _) => |
||||||
|
{ |
||||||
|
Dispatcher.UIThread.Invoke(() => |
||||||
|
{ |
||||||
|
var editor = this.FindControl<TextEditor>("Console"); |
||||||
|
if (editor?.Document == null) |
||||||
|
return; |
||||||
|
var line = Math.Max(editor.Document.LineCount - 1, 1); |
||||||
|
editor.ScrollToLine(line); |
||||||
|
}); |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -1,6 +1,11 @@ |
|||||||
namespace StabilityMatrix.Core.Models.Database; |
using System.Text.Json.Serialization; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.Database; |
||||||
|
|
||||||
public class GitCommit |
public class GitCommit |
||||||
{ |
{ |
||||||
public string? Sha { get; set; } |
public string? Sha { get; set; } |
||||||
|
|
||||||
|
[JsonIgnore] |
||||||
|
public string ShortSha => string.IsNullOrWhiteSpace(Sha) ? string.Empty : Sha[..7]; |
||||||
} |
} |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
namespace StabilityMatrix.Core.Models; |
||||||
|
|
||||||
|
public class DownloadPackageVersionOptions |
||||||
|
{ |
||||||
|
public string BranchName { get; set; } |
||||||
|
public string CommitHash { get; set; } |
||||||
|
public string VersionTag { get; set; } |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
using System.Text.Json.Serialization; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models; |
||||||
|
|
||||||
|
public class InstalledPackageVersion |
||||||
|
{ |
||||||
|
public string? InstalledReleaseVersion { get; set; } |
||||||
|
public string? InstalledBranch { get; set; } |
||||||
|
public string? InstalledCommitSha { get; set; } |
||||||
|
|
||||||
|
[JsonIgnore] |
||||||
|
public bool IsReleaseMode => string.IsNullOrWhiteSpace(InstalledBranch); |
||||||
|
|
||||||
|
[JsonIgnore] |
||||||
|
public string DisplayVersion => |
||||||
|
( |
||||||
|
IsReleaseMode |
||||||
|
? InstalledReleaseVersion |
||||||
|
: string.IsNullOrWhiteSpace(InstalledCommitSha) |
||||||
|
? InstalledBranch |
||||||
|
: $"{InstalledBranch}@{InstalledCommitSha[..7]}" |
||||||
|
) ?? string.Empty; |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
using StabilityMatrix.Core.Services; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class AddInstalledPackageStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly ISettingsManager settingsManager; |
||||||
|
private readonly InstalledPackage newInstalledPackage; |
||||||
|
|
||||||
|
public AddInstalledPackageStep( |
||||||
|
ISettingsManager settingsManager, |
||||||
|
InstalledPackage newInstalledPackage |
||||||
|
) |
||||||
|
{ |
||||||
|
this.settingsManager = settingsManager; |
||||||
|
this.newInstalledPackage = newInstalledPackage; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
||||||
|
{ |
||||||
|
if (!string.IsNullOrWhiteSpace(newInstalledPackage.DisplayName)) |
||||||
|
{ |
||||||
|
settingsManager.PackageInstallsInProgress.Remove(newInstalledPackage.DisplayName); |
||||||
|
} |
||||||
|
|
||||||
|
await using var transaction = settingsManager.BeginTransaction(); |
||||||
|
transaction.Settings.InstalledPackages.Add(newInstalledPackage); |
||||||
|
transaction.Settings.ActiveInstalledPackageId = newInstalledPackage.Id; |
||||||
|
} |
||||||
|
|
||||||
|
public string ProgressTitle => $"{newInstalledPackage.DisplayName} Installed"; |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Packages; |
||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class DownloadPackageVersionStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly BasePackage package; |
||||||
|
private readonly string installPath; |
||||||
|
private readonly DownloadPackageVersionOptions downloadOptions; |
||||||
|
|
||||||
|
public DownloadPackageVersionStep( |
||||||
|
BasePackage package, |
||||||
|
string installPath, |
||||||
|
DownloadPackageVersionOptions downloadOptions |
||||||
|
) |
||||||
|
{ |
||||||
|
this.package = package; |
||||||
|
this.installPath = installPath; |
||||||
|
this.downloadOptions = downloadOptions; |
||||||
|
} |
||||||
|
|
||||||
|
public Task ExecuteAsync(IProgress<ProgressReport>? progress = null) => |
||||||
|
package.DownloadPackage(installPath, downloadOptions, progress); |
||||||
|
|
||||||
|
public string ProgressTitle => "Downloading package..."; |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public interface IPackageModificationRunner |
||||||
|
{ |
||||||
|
Task ExecuteSteps(IReadOnlyList<IPackageStep> steps); |
||||||
|
bool IsRunning { get; set; } |
||||||
|
ProgressReport CurrentProgress { get; set; } |
||||||
|
IPackageStep? CurrentStep { get; set; } |
||||||
|
event EventHandler<ProgressReport>? ProgressChanged; |
||||||
|
List<string> ConsoleOutput { get; } |
||||||
|
Guid Id { get; } |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Packages; |
||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
using StabilityMatrix.Core.Processes; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class InstallPackageStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly BasePackage package; |
||||||
|
private readonly TorchVersion torchVersion; |
||||||
|
private readonly string installPath; |
||||||
|
|
||||||
|
public InstallPackageStep(BasePackage package, TorchVersion torchVersion, string installPath) |
||||||
|
{ |
||||||
|
this.package = package; |
||||||
|
this.torchVersion = torchVersion; |
||||||
|
this.installPath = installPath; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
||||||
|
{ |
||||||
|
void OnConsoleOutput(ProcessOutput output) |
||||||
|
{ |
||||||
|
progress?.Report(new ProgressReport { IsIndeterminate = true, Message = output.Text }); |
||||||
|
} |
||||||
|
|
||||||
|
await package |
||||||
|
.InstallPackage(installPath, torchVersion, progress, OnConsoleOutput) |
||||||
|
.ConfigureAwait(false); |
||||||
|
} |
||||||
|
|
||||||
|
public string ProgressTitle => "Installing package..."; |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class PackageModificationRunner : IPackageModificationRunner |
||||||
|
{ |
||||||
|
public async Task ExecuteSteps(IReadOnlyList<IPackageStep> steps) |
||||||
|
{ |
||||||
|
IProgress<ProgressReport> progress = new Progress<ProgressReport>(report => |
||||||
|
{ |
||||||
|
CurrentProgress = report; |
||||||
|
if (!string.IsNullOrWhiteSpace(report.Message)) |
||||||
|
{ |
||||||
|
ConsoleOutput.Add(report.Message); |
||||||
|
} |
||||||
|
|
||||||
|
OnProgressChanged(report); |
||||||
|
}); |
||||||
|
|
||||||
|
IsRunning = true; |
||||||
|
foreach (var step in steps) |
||||||
|
{ |
||||||
|
CurrentStep = step; |
||||||
|
await step.ExecuteAsync(progress).ConfigureAwait(false); |
||||||
|
} |
||||||
|
|
||||||
|
progress.Report( |
||||||
|
new ProgressReport(1f, message: "Package Install Complete", isIndeterminate: false) |
||||||
|
); |
||||||
|
|
||||||
|
IsRunning = false; |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsRunning { get; set; } |
||||||
|
public ProgressReport CurrentProgress { get; set; } |
||||||
|
public IPackageStep? CurrentStep { get; set; } |
||||||
|
public List<string> ConsoleOutput { get; } = new(); |
||||||
|
public Guid Id { get; } = Guid.NewGuid(); |
||||||
|
|
||||||
|
public event EventHandler<ProgressReport>? ProgressChanged; |
||||||
|
|
||||||
|
protected virtual void OnProgressChanged(ProgressReport e) => ProgressChanged?.Invoke(this, e); |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public interface IPackageStep |
||||||
|
{ |
||||||
|
Task ExecuteAsync(IProgress<ProgressReport>? progress = null); |
||||||
|
string ProgressTitle { get; } |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
using StabilityMatrix.Core.Services; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class SetPackageInstallingStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly ISettingsManager settingsManager; |
||||||
|
private readonly string packageName; |
||||||
|
|
||||||
|
public SetPackageInstallingStep(ISettingsManager settingsManager, string packageName) |
||||||
|
{ |
||||||
|
this.settingsManager = settingsManager; |
||||||
|
this.packageName = packageName; |
||||||
|
} |
||||||
|
|
||||||
|
public Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
||||||
|
{ |
||||||
|
settingsManager.PackageInstallsInProgress.Add(packageName); |
||||||
|
return Task.CompletedTask; |
||||||
|
} |
||||||
|
|
||||||
|
public string ProgressTitle => "Starting Package Installation"; |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
using StabilityMatrix.Core.Models.Packages; |
||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class SetupModelFoldersStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly BasePackage package; |
||||||
|
private readonly SharedFolderMethod sharedFolderMethod; |
||||||
|
private readonly string installPath; |
||||||
|
|
||||||
|
public SetupModelFoldersStep( |
||||||
|
BasePackage package, |
||||||
|
SharedFolderMethod sharedFolderMethod, |
||||||
|
string installPath |
||||||
|
) |
||||||
|
{ |
||||||
|
this.package = package; |
||||||
|
this.sharedFolderMethod = sharedFolderMethod; |
||||||
|
this.installPath = installPath; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
||||||
|
{ |
||||||
|
progress?.Report( |
||||||
|
new ProgressReport(-1f, "Setting up shared folder links...", isIndeterminate: true) |
||||||
|
); |
||||||
|
await package.SetupModelFolders(installPath, sharedFolderMethod).ConfigureAwait(false); |
||||||
|
} |
||||||
|
|
||||||
|
public string ProgressTitle => "Setting up shared folder links..."; |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
using StabilityMatrix.Core.Helper; |
||||||
|
using StabilityMatrix.Core.Models.Progress; |
||||||
|
using StabilityMatrix.Core.Python; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Core.Models.PackageModification; |
||||||
|
|
||||||
|
public class SetupPrerequisitesStep : IPackageStep |
||||||
|
{ |
||||||
|
private readonly IPrerequisiteHelper prerequisiteHelper; |
||||||
|
private readonly IPyRunner pyRunner; |
||||||
|
|
||||||
|
public SetupPrerequisitesStep(IPrerequisiteHelper prerequisiteHelper, IPyRunner pyRunner) |
||||||
|
{ |
||||||
|
this.prerequisiteHelper = prerequisiteHelper; |
||||||
|
this.pyRunner = pyRunner; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
||||||
|
{ |
||||||
|
// git, vcredist, etc... |
||||||
|
await prerequisiteHelper.InstallAllIfNecessary(progress).ConfigureAwait(false); |
||||||
|
|
||||||
|
// python stuff |
||||||
|
if (!PyRunner.PipInstalled || !PyRunner.VenvInstalled) |
||||||
|
{ |
||||||
|
progress?.Report( |
||||||
|
new ProgressReport(-1f, "Installing Python prerequisites...", isIndeterminate: true) |
||||||
|
); |
||||||
|
|
||||||
|
await pyRunner.Initialize().ConfigureAwait(false); |
||||||
|
|
||||||
|
if (!PyRunner.PipInstalled) |
||||||
|
{ |
||||||
|
await pyRunner.SetupPip().ConfigureAwait(false); |
||||||
|
} |
||||||
|
if (!PyRunner.VenvInstalled) |
||||||
|
{ |
||||||
|
await pyRunner.InstallPackage("virtualenv").ConfigureAwait(false); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string ProgressTitle => "Installing prerequisites..."; |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
namespace StabilityMatrix.Core.Models.Packages; |
||||||
|
|
||||||
|
public class PackageVersionOptions |
||||||
|
{ |
||||||
|
public IEnumerable<PackageVersion>? AvailableVersions { get; set; } |
||||||
|
public IEnumerable<PackageVersion>? AvailableBranches { get; set; } |
||||||
|
} |
@ -1,3 +1,8 @@ |
|||||||
namespace StabilityMatrix.Core.Models.Progress; |
namespace StabilityMatrix.Core.Models.Progress; |
||||||
|
|
||||||
public record ProgressItem(Guid ProgressId, string Name, ProgressReport Progress, bool Failed = false); |
public record ProgressItem( |
||||||
|
Guid ProgressId, |
||||||
|
string Name, |
||||||
|
ProgressReport Progress, |
||||||
|
bool Failed = false |
||||||
|
); |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
namespace StabilityMatrix.Core.Models; |
||||||
|
|
||||||
|
public enum SharedFolderMethod |
||||||
|
{ |
||||||
|
Symlink, |
||||||
|
Configuration, |
||||||
|
None |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
namespace StabilityMatrix.Core.Models; |
||||||
|
|
||||||
|
public enum TorchVersion |
||||||
|
{ |
||||||
|
Cuda, |
||||||
|
Rocm, |
||||||
|
DirectMl, |
||||||
|
Cpu, |
||||||
|
Mps, |
||||||
|
None |
||||||
|
} |
Loading…
Reference in new issue