-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported Json Web Token Encoder Decoder to DevToys 2.0 (#1078)
* added jwt decode helper and started working on the decode ui * added support for claims * added JsonWebTokenEncodeHelper * work in progress on encode * added missing resx * code cleanup * added ui fixes and small changes * updated following comments --------- Co-authored-by: Etienne Baudoux <[email protected]>
- Loading branch information
Showing
92 changed files
with
6,498 additions
and
66 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
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 |
---|---|---|
@@ -1,18 +1,107 @@ | ||
namespace DevToys.Api; | ||
using static System.Runtime.InteropServices.JavaScript.JSType; | ||
|
||
namespace DevToys.Api; | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <typeparam name="T">Type of the result</typeparam> | ||
/// <param name="Data">The resulting data or the task</param> | ||
/// <param name="HasSucceeded">Whether the task succeeded</param> | ||
public record ResultInfo<T>(T Data, bool HasSucceeded = true); | ||
public record ResultInfo<T> | ||
{ | ||
/// <summary> | ||
/// The resulting data or the task | ||
/// </summary> | ||
public T? Data { get; } | ||
|
||
/// <summary> | ||
/// Whether the task succeeded | ||
/// </summary> | ||
public bool HasSucceeded { get; } | ||
|
||
/// <summary> | ||
/// Error message to display | ||
/// </summary> | ||
public string? ErrorMessage { get; } | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <param name="data">The resulting data or the task</param> | ||
/// <param name="hasSucceeded">Whether the task succeeded</param> | ||
public ResultInfo(T data, bool hasSucceeded = true) | ||
{ | ||
Data = data; | ||
HasSucceeded = hasSucceeded; | ||
} | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <param name="data">The resulting data or the task</param> | ||
/// <param name="errorMessage">The error message</param> | ||
/// <param name="hasSucceeded">Whether the task succeeded</param> | ||
public ResultInfo(T data, string errorMessage, bool hasSucceeded = false) | ||
{ | ||
Data = data; | ||
HasSucceeded = hasSucceeded; | ||
ErrorMessage = errorMessage; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <typeparam name="T">Type of the result</typeparam> | ||
/// <typeparam name="U">Type of the severity</typeparam> | ||
/// <param name="Data">The resulting data or the task</param> | ||
/// <param name="Severity">The severity of the result</param> | ||
public record ResultInfo<T, U>(T Data, U Severity); | ||
/// <typeparam name="ResultInfoSeverity">The severity of the result</typeparam> | ||
public record ResultInfo<T, ResultInfoSeverity> | ||
{ | ||
/// <summary> | ||
/// The resulting data or the task | ||
/// </summary> | ||
public T? Data { get; } | ||
|
||
/// <summary> | ||
/// Severity of the result | ||
/// </summary> | ||
public ResultInfoSeverity Severity { get; } | ||
|
||
/// <summary> | ||
/// Error message to display | ||
/// </summary> | ||
public string? ErrorMessage { get; } | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <param name="data">The resulting data or the task</param> | ||
/// <param name="severity">The severity of the result</param> | ||
public ResultInfo(T data, ResultInfoSeverity severity) | ||
{ | ||
Data = data; | ||
Severity = severity; | ||
} | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <param name="errorMessage">The error message</param> | ||
/// <param name="severity">The severity of the result</param> | ||
public ResultInfo(string errorMessage, ResultInfoSeverity severity) | ||
{ | ||
Severity = severity; | ||
ErrorMessage = errorMessage; | ||
} | ||
|
||
/// <summary> | ||
/// Record to contain both whether the task was a success and the resulting data | ||
/// </summary> | ||
/// <param name="data">The resulting data or the task</param> | ||
/// <param name="errorMessage">The error message</param> | ||
/// <param name="severity">The severity of the result</param> | ||
public ResultInfo(T data, string errorMessage, ResultInfoSeverity severity) | ||
{ | ||
Data = data; | ||
Severity = severity; | ||
ErrorMessage = errorMessage; | ||
} | ||
} |
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,8 @@ | ||
namespace DevToys.Api; | ||
|
||
public enum ResultInfoSeverity | ||
{ | ||
Success, | ||
Warning, | ||
Error | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/app/dev/DevToys.Api/Tool/GUI/Components/UIHoverTooltip.cs
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,26 @@ | ||
namespace DevToys.Api; | ||
|
||
/// <summary> | ||
/// Represents the Tooltip to display on hover | ||
/// </summary> | ||
public record UIHoverTooltip | ||
{ | ||
/// <summary> | ||
/// Contain the position of the span to search | ||
/// </summary> | ||
public TextSpan Span { get; } | ||
|
||
/// <summary> | ||
/// Contain the information we want to display on hover | ||
/// </summary> | ||
public string Description { get; } | ||
|
||
/// <summary> | ||
/// Create a new isntance of the <see cref="UIHoverTooltip"/> class. | ||
/// </summary> | ||
public UIHoverTooltip(TextSpan span, string description) | ||
{ | ||
Span = span; | ||
Description = description; | ||
} | ||
} |
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
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
21 changes: 20 additions & 1 deletion
21
src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor.cs
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 |
---|---|---|
@@ -1,7 +1,26 @@ | ||
namespace DevToys.Blazor.Components.UIElements; | ||
using DevToys.Api; | ||
|
||
namespace DevToys.Blazor.Components.UIElements; | ||
|
||
public partial class UIGridPresenter : ComponentBase | ||
{ | ||
[Parameter] | ||
public IUIGrid UIGrid { get; set; } = default!; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
|
||
UIGrid.CellsChanged += UIGrid_CellsChanged; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
UIGrid.CellsChanged += UIGrid_CellsChanged; | ||
} | ||
|
||
private void UIGrid_CellsChanged(object? sender, EventArgs e) | ||
{ | ||
StateHasChanged(); | ||
} | ||
} |
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
Oops, something went wrong.