-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add export to json file (#105)
- Loading branch information
Showing
4 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/AzureAppConfigurationEmulator/Components/ImportExportTargetTypeInputSelect.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@using System.Linq.Expressions | ||
|
||
<AzureInputSelect AdditionalAttributes="@AdditionalAttributes" TValue="@string" Value="@Value" ValueChanged="@HandleValueChanged" ValueExpression="@ValueExpression"> | ||
<option checked="@(Value is null)" hidden value="">Please select a target service</option> | ||
<option checked="@(Value is TargetType.AzureAppConfiguration)" disabled value="@TargetType.AzureAppConfiguration">App Configuration</option> | ||
<option checked="@(Value is TargetType.AzureAppService)" disabled value="@TargetType.AzureAppService">App Service</option> | ||
<option checked="@(Value is TargetType.ConfigurationFile)" value="@TargetType.ConfigurationFile">Configuration file</option> | ||
</AzureInputSelect> | ||
|
||
@code { | ||
[Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, object>? AdditionalAttributes { get; set; } | ||
|
||
[Parameter] public string? Value { get; set; } | ||
|
||
[Parameter] public EventCallback<string?> ValueChanged { get; set; } | ||
|
||
[Parameter] public Expression<Func<string?>>? ValueExpression { get; set; } | ||
|
||
private async Task HandleValueChanged(string? value) | ||
{ | ||
await ValueChanged.InvokeAsync(!string.IsNullOrEmpty(value) ? value : null); | ||
} | ||
|
||
public static class TargetType | ||
{ | ||
public const string AzureAppConfiguration = nameof(AzureAppConfiguration); | ||
|
||
public const string AzureAppService = nameof(AzureAppService); | ||
|
||
public const string ConfigurationFile = nameof(ConfigurationFile); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/AzureAppConfigurationEmulator/Components/Pages/ImportExport.razor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function download(name, bytes) { | ||
const element = document.createElement("a"); | ||
|
||
element.download = name; | ||
element.href = "data:application/octet-stream;base64," + bytes; | ||
|
||
window.document.body.appendChild(element); | ||
|
||
element.click(); | ||
|
||
window.document.body.removeChild(element); | ||
} |