Skip to content

Commit

Permalink
Merge pull request #160 from EasyAbp/switch-to-local
Browse files Browse the repository at this point in the history
Support the ABP CLI `switch-to-local` command
  • Loading branch information
gdlcf88 committed May 4, 2023
2 parents d39d2e7 + dde9578 commit 35c105a
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ namespace EasyAbp.AbpHelper.Gui.AbpCli.Proxy.Dtos
[Serializable]
public class AbpGenerateRemoveJavaScriptProxyInput : InputDtoWithDirectory
{
public virtual ProxyType Type { get; set; }
public virtual ProxyType Type => ProxyType.JavaScript;

[Required]
[NotNull]
public virtual string Url { get; set; }

[CanBeNull]
public virtual string Module { get; set; }

[CanBeNull]
public virtual string Output { get; set; }

public AbpGenerateRemoveJavaScriptProxyInput()
{
}

public AbpGenerateRemoveJavaScriptProxyInput(ProxyType type, [NotNull] string url, [CanBeNull] string module,
public AbpGenerateRemoveJavaScriptProxyInput([NotNull] string url, [CanBeNull] string module,
[CanBeNull] string output)
{
Type = type;
Url = url;
Module = module;
Output = output;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using EasyAbp.AbpHelper.Gui.Shared.Dtos;
using JetBrains.Annotations;

namespace EasyAbp.AbpHelper.Gui.AbpCli.Switch.Dtos
{
[Serializable]
public class AbpSwitchToLocalInput : InputDtoWithDirectory
{
public string Paths { get; set; }

public AbpSwitchToLocalInput()
{
}

public AbpSwitchToLocalInput([NotNull] string directory) : base(directory)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace EasyAbp.AbpHelper.Gui.AbpCli.Switch
public interface IAbpCliSwitchAppService : IApplicationService
{
Task<ServiceExecutionResult> SwitchToPreviewAsync(AbpSwitchToPreviewInput input);

Task<ServiceExecutionResult> SwitchToNightlyAsync(AbpSwitchToNightlyInput input);

Task<ServiceExecutionResult> SwitchToStableAsync(AbpSwitchToStableInput input);

Task<ServiceExecutionResult> SwitchToLocalAsync(AbpSwitchToLocalInput input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
"AbpCli_Switch:SwitchToPreview": "To preview",
"AbpCli_Switch:SwitchToNightly": "To nightly",
"AbpCli_Switch:SwitchToStable": "To stable",
"AbpCli_Switch:SwitchToLocal": "To local",
"AbpCli_Switch:Paths": "Paths",
"AbpCli_Login:Login": "Login",
"AbpCli_Login:Logout": "Logout",
"AbpCli_Login:Username": "Username",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
"AbpCli_Switch:SwitchToPreview": "切换为 Preview 版",
"AbpCli_Switch:SwitchToNightly": "切换为 Nightly 版",
"AbpCli_Switch:SwitchToStable": "切换为 Stable 版",
"AbpCli_Switch:SwitchToLocal": "切换为 Local 版",
"AbpCli_Switch:Paths": "路径 - Paths",
"AbpCli_Translate:CreateTranslationFile": "创建翻译文件",
"AbpCli_Translate:ApplyChanges": "应用变更项",
"AbpCli_Translate:Culture": "区域代号 - Culture",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
"AbpCli_Switch:SwitchToPreview": "切換為 Preview 版",
"AbpCli_Switch:SwitchToNightly": "切換為 Nightly 版",
"AbpCli_Switch:SwitchToStable": "切換為 Stable 版",
"AbpCli_Switch:SwitchToLocal": "切換為 Local 版",
"AbpCli_Switch:Paths": "路徑 - Paths",
"AbpCli_Login:Login": "登錄",
"AbpCli_Login:Logout": "登出",
"AbpCli_Login:Username": "用戶名 - Username",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Threading.Tasks;
using EasyAbp.AbpHelper.Gui.AbpCli.Proxy;
using EasyAbp.AbpHelper.Gui.AbpCli.Proxy.Dtos;
using EasyAbp.AbpHelper.Gui.AbpCli.Switch.Dtos;
using EasyAbp.AbpHelper.Gui.Common;
using EasyAbp.AbpHelper.Gui.Shared.Dtos;
Expand Down Expand Up @@ -62,5 +60,17 @@ public virtual async Task<ServiceExecutionResult> SwitchToStableAsync(AbpSwitchT

return new ServiceExecutionResult(true);
}

public virtual async Task<ServiceExecutionResult> SwitchToLocalAsync(AbpSwitchToLocalInput input)
{
var args = CreateCommandLineArgs(input, "abp switch-to-local");

using (_currentDirectoryHelper.Change(input.Directory))
{
await _switchToStableCommand.ExecuteAsync(args);
}

return new ServiceExecutionResult(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@using Volo.Abp.AspNetCore.Components.Web
@using EasyAbp.AbpHelper.Gui.Localization
@using EasyAbp.AbpHelper.Gui.AbpCli.Switch.Dtos;
@using EasyAbp.AbpHelper.Gui.Blazor.Pages.Shared;
@inherits ExecutableComponentBaseWithDirectory<AbpSwitchToLocalInput>
@inject AbpBlazorMessageLocalizerHelper<GuiResource> Lh

<Card Class="mb-4">
<CardBody>
<Alert Color="Color.Info" Visible>
<AlertDescription>
<Icon Name="IconName.QuestionCircle" /> @L["Info:FunctionIsBasedOnAbpCliPart1"]
</AlertDescription>
<AlertMessage>
<Icon Name="IconName.ExternalLinkSquareAlt"/>
<Link To="https://docs.abp.io/en/abp/latest/CLI#switch-to-local" Target="Target.Blank" Style="text-decoration: none">
@L["Info:FunctionIsBasedOnAbpCliPart2_Document"]
</Link>
</AlertMessage>
<AlertDescription>
@L["Info:FunctionIsBasedOnAbpCliPart3"]
</AlertDescription>
</Alert>
<Form>
<Validations @ref="ValidationsRef" Model="Input" ValidateOnLoad="false">
<Validation MessageLocalizer="@Lh.Localize">
<Field>
<Field>
<FieldLabel>@L["AbpCli_Switch:Paths"]</FieldLabel>
<TextEdit @bind-Text="Input.Paths" Autofocus="true">
<Feedback>
<ValidationError/>
</Feedback>
</TextEdit>
</Field>
<FieldLabel>@L["Directory"]</FieldLabel>
<TextEdit @bind-Text="Input.Directory">
<Feedback>
<ValidationError/>
</Feedback>
</TextEdit>
</Field>
</Validation>

<SubmitButton Block="true" Clicked="@ExecuteAsync" SaveResourceKey="Button:Execute" />
</Validations>
</Form>
</CardBody>
</Card>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Threading.Tasks;
using EasyAbp.AbpHelper.Gui.AbpCli.Switch;
using Microsoft.AspNetCore.Components;

namespace EasyAbp.AbpHelper.Gui.Blazor.Pages.AbpCli.Components.Switch
{
public partial class SwitchToLocal
{
[Inject]
private IAbpCliSwitchAppService Service { get; set; }

protected override async Task InternalExecuteAsync()
{
await Service.SwitchToLocalAsync(Input);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<Tab Name="SwitchToPreview">@L["AbpCli_Switch:SwitchToPreview"]</Tab>
<Tab Name="SwitchToNightly">@L["AbpCli_Switch:SwitchToNightly"]</Tab>
<Tab Name="SwitchToStable">@L["AbpCli_Switch:SwitchToStable"]</Tab>
<Tab Name="SwitchToLocal">@L["AbpCli_Switch:SwitchToLocal"]</Tab>
</Items>
<Content>
<TabPanel Name="SwitchToPreview">
Expand All @@ -144,6 +145,9 @@
<TabPanel Name="SwitchToStable">
<SwitchToStable></SwitchToStable>
</TabPanel>
<TabPanel Name="SwitchToLocal">
<SwitchToLocal></SwitchToLocal>
</TabPanel>
</Content>
</Tabs>
</TabPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,12 @@ public Task<ServiceExecutionResult> SwitchToStableAsync(AbpSwitchToStableInput i
{
return _service.SwitchToStableAsync(input);
}

[HttpPost]
[Route("to-local")]
public Task<ServiceExecutionResult> SwitchToLocalAsync(AbpSwitchToLocalInput input)
{
return _service.SwitchToLocalAsync(input);
}
}
}

0 comments on commit 35c105a

Please sign in to comment.