Skip to content

Commit

Permalink
perf: requirements.txt import
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraZiling committed Feb 3, 2024
1 parent 2d8fb84 commit abdeefc
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 8 deletions.
27 changes: 27 additions & 0 deletions src/PipManager/Languages/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/PipManager/Languages/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,13 @@ Other sources are faster to connect to, but may be incomplete.</value>
<data name="Action_ConsoleOutput_Empty" xml:space="preserve">
<value>No output currently</value>
</data>
<data name="LibraryInstall_Add_Header" xml:space="preserve">
<value>Default</value>
</data>
<data name="LibraryInstall_Requirements_Header" xml:space="preserve">
<value>requirements.txt Import</value>
</data>
<data name="LibraryInstall_Download_Header" xml:space="preserve">
<value>Download Wheel File</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/PipManager/Languages/Lang.zh-cn.resx
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,13 @@
<data name="Action_ConsoleOutput_Empty" xml:space="preserve">
<value>当前无输出</value>
</data>
<data name="LibraryInstall_Add_Header" xml:space="preserve">
<value>默认</value>
</data>
<data name="LibraryInstall_Requirements_Header" xml:space="preserve">
<value>requirement.txt 导入</value>
</data>
<data name="LibraryInstall_Download_Header" xml:space="preserve">
<value>下载 Wheel 文件</value>
</data>
</root>
8 changes: 7 additions & 1 deletion src/PipManager/Models/Action/ActionListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ namespace PipManager.Models.Action;

public partial class ActionListItem : ObservableObject
{
public ActionListItem(ActionType operationType, string operationCommand, bool progressIntermediate = false, int totalSubTaskNumber = 1)
public ActionListItem(ActionType operationType, string operationCommand, string displayCommand = "", bool progressIntermediate = false, int totalSubTaskNumber = 1)
{
OperationType = operationType;
OperationCommand = operationCommand;
ProgressIntermediate = progressIntermediate;
TotalSubTaskNumber = totalSubTaskNumber;
DisplayCommand = displayCommand switch
{
"" => operationCommand,
_ => displayCommand,
};
OperationDescription = operationType switch
{
ActionType.Uninstall => Lang.Action_Operation_Uninstall,
Expand Down Expand Up @@ -47,6 +52,7 @@ public ActionListItem(ActionType operationType, string operationCommand, bool pr
public string OperationDescription { get; set; }
public string OperationTimestamp { get; set; } = DateTime.Now.ToLocalTime().ToString("yyyy-M-d HH:mm:ss");
public string OperationCommand { get; set; }
public string DisplayCommand { get; set; }
public bool ProgressIntermediate { get; set; }
public string BadgeAppearance { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using PipManager.Services.Environment;
using PipManager.Services.Mask;
using PipManager.Services.Toast;
using PipManager.Views.Pages.Action;
using System.Collections.ObjectModel;
using System.IO;
using Wpf.Ui;
Expand All @@ -28,14 +29,16 @@ public record InstalledPackagesMessage(List<LibraryListItem> InstalledPackages);
private readonly IContentDialogService _contentDialogService;
private readonly IEnvironmentService _environmentService;
private readonly IToastService _toastService;
private readonly INavigationService _navigationService;

public LibraryInstallViewModel(IActionService actionService, IMaskService maskService, IContentDialogService contentDialogService, IEnvironmentService environmentService, IToastService toastService)
public LibraryInstallViewModel(IActionService actionService, IMaskService maskService, IContentDialogService contentDialogService, IEnvironmentService environmentService, IToastService toastService, INavigationService navigationService)
{
_actionService = actionService;
_maskService = maskService;
_contentDialogService = contentDialogService;
_environmentService = environmentService;
_toastService = toastService;
_navigationService = navigationService;
WeakReferenceMessenger.Default.Register<InstalledPackagesMessage>(this, Receive);
}

Expand Down Expand Up @@ -153,7 +156,7 @@ private void AddRequirementsTask()
Title = "requirements.txt",
FileName = "requirements.txt",
DefaultExt = ".txt",
Filter = "requirements|requirements.txt",
Filter = "requirements|*.txt",
RestoreDirectory = true
};
var result = openFileDialog.ShowDialog();
Expand All @@ -169,9 +172,11 @@ private void AddRequirementsToAction()
_actionService.AddOperation(new ActionListItem
(
ActionType.InstallByRequirements,
Requirements
Requirements,
displayCommand: "requirements.txt"
));
Requirements = "";
_navigationService.Navigate(typeof(ActionPage));
}

#endregion Requirements Import
Expand Down
2 changes: 1 addition & 1 deletion src/PipManager/Views/Pages/Action/ActionPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
Margin="5,0,0,0"
VerticalAlignment="Center"
FontSize="14"
Text="{Binding OperationCommand}"
Text="{Binding DisplayCommand}"
TextWrapping="WrapWithOverflow" />
</StackPanel>
<StackPanel Margin="0,7,0,0" Orientation="Horizontal">
Expand Down
6 changes: 3 additions & 3 deletions src/PipManager/Views/Pages/Library/LibraryInstallPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Margin="0,0,6,0"
Filled="True"
Symbol="AppsAddIn24" />
<TextBlock Margin="0,0,10,0" Text="Default" />
<TextBlock Margin="0,0,10,0" Text="{I18N {x:Static lang:LangKeys.LibraryInstall_Add_Header}}" />
</StackPanel>
</TabItem.Header>
<Grid Margin="20">
Expand Down Expand Up @@ -118,7 +118,7 @@
Margin="0,0,6,0"
Filled="True"
Symbol="ArrowImport24" />
<TextBlock Margin="0,0,10,0" Text="Requirements.txt Import" />
<TextBlock Margin="0,0,10,0" Text="{I18N {x:Static lang:LangKeys.LibraryInstall_Requirements_Header}}" />
</StackPanel>
</TabItem.Header>
<Grid Margin="20">
Expand Down Expand Up @@ -157,7 +157,7 @@
Margin="0,0,6,0"
Filled="True"
Symbol="ArrowDownload24" />
<TextBlock Margin="0,0,10,0" Text="Download (.whl)" />
<TextBlock Margin="0,0,10,0" Text="{I18N {x:Static lang:LangKeys.LibraryInstall_Download_Header}}" />
</StackPanel>
</TabItem.Header>
</TabItem>
Expand Down

0 comments on commit abdeefc

Please sign in to comment.