Skip to content

Commit 3a8b36d

Browse files
committed
Fixed handup in GitScanner
Fixed encoing issue on JSON formatter Switched to Tabler icons
1 parent ebb77b6 commit 3a8b36d

51 files changed

Lines changed: 13604 additions & 211 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h3>ApiTester</h3>
2+
<hr />
3+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace TowerSoft.DevToolkit.Components.ApiTester {
8+
public partial class ApiTester {
9+
private string url;
10+
private bool useDefaultCreds = true;
11+
}
12+
}

TowerSoft.DevToolkit/Components/Diff/Diff.razor

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11

22
<div class="d-flex flex-column h-100">
33
<div class="row">
4-
<div class="col-auto">
5-
<h3>Diff</h3>
6-
</div>
4+
<div class="col">
5+
<h3 class="d-inline-block pe-4">Diff</h3>
76

8-
<div class="col-auto">
9-
<div class="form-check-inline pt-1">
7+
<div class="form-check-inline">
108
<label class="form-check-label">
119
<InputCheckbox @bind-Value="wordWrap" class="form-check-input" /> Word Wrap
1210
</label>
1311
</div>
1412
</div>
13+
<div class="col-auto">
14+
@if (showInputs) {
15+
<button type="button" class="btn btn-primary w-100" @onclick="CheckDiff">Check Diff</button>
16+
} else {
17+
<button @onclick="Reset" class="btn btn-info">Reset</button>
18+
}
19+
</div>
20+
<div class="col">
1521

16-
@if (!showInputs) {
17-
<div class="col-auto">
18-
<button @onclick="Reset" class="btn btn-link">Reset</button>
19-
</div>
20-
}
22+
</div>
2123
</div>
24+
2225
@if (showInputs) {
2326
<div class="flex-grow-1">
2427
<div class="row g-2 h-100 pb-1">
2528
<div class="col d-flex flex-column">
2629
<label>Old Text</label>
2730
<InputTextArea @bind-Value="oldText" class="form-control flex-grow-1 no-resize font-monospace" wrap="@(wordWrap ? "on": "off")" />
2831
</div>
29-
<div class="col-auto d-flex flex-column">
30-
<br />
31-
<div class="mb-3">
32-
<button type="button" class="btn btn-primary w-100" @onclick="CheckDiff">Check Diff</button>
33-
</div>
34-
</div>
3532
<div class="col d-flex flex-column">
3633
<label>New Text</label>
3734
<InputTextArea @bind-Value="newText" class="form-control flex-grow-1 no-resize font-monospace" wrap="@(wordWrap ? "on": "off")" />

TowerSoft.DevToolkit/Components/Formatter/Formatter.razor.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using NUglify;
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
using NUglify;
24
using NUglify.Css;
35
using NUglify.Html;
46
using NUglify.JavaScript;
5-
using System.Text.Json;
67
using TowerSoft.DevToolkit.Models;
78

89
namespace TowerSoft.DevToolkit.Components.Formatter {
@@ -138,16 +139,13 @@ await Task.Run(() => {
138139
}
139140

140141
private async Task<FormatterResult> FormatJson(bool minify) {
141-
JsonSerializerOptions options = new();
142-
if (!minify)
143-
options.WriteIndented = true;
142+
Formatting formatting = minify ? Formatting.None : Formatting.Indented;
144143

145144
FormatterResult result = new();
146145
try {
147-
//Built-in async methods do not work strings and JsonDocuments
148146
await Task.Run(() => {
149-
using JsonDocument jDoc = JsonDocument.Parse(inputText);
150-
result.Output = JsonSerializer.Serialize(jDoc, options);
147+
var obj = JsonConvert.DeserializeObject<JObject>(inputText);
148+
result.Output = JsonConvert.SerializeObject(obj, formatting);
151149
});
152150
} catch (Exception ex) {
153151
result.ErrorOccurred = true;

TowerSoft.DevToolkit/Components/GitScanner/GitRepoDisplay.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<div class="mb-3">
44
<div>
55
<span class="h5">@GetRelativePath(Model.RepoDirectory.FullName)</span>
6-
<a href="#" @onclick="() => OpenFolder(Model.RepoDirectory.FullName)" class="ps-1">
7-
<span class="mdi mdi-fw mdi-folder-open-outline" title="Open Folder"></span>
6+
<a href="#" @onclick="() => OpenFolder(Model.RepoDirectory.FullName)" class="ps-1" title="Open Folder">
7+
<IconFolderOpen />
88
</a>
99
</div>
1010

TowerSoft.DevToolkit/Components/GitScanner/GitScanner.razor

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<p>
33
This tool scans all subdirectories in a location for any uncommitted changes, stashed changes, and if the local repository is ahead of the remote repository.
44
</p>
5-
<hr />
5+
<div class="row">
6+
<hr />
7+
</div>
68

79
<div class="row mb-3">
810
<div class="col">
@@ -22,10 +24,11 @@
2224

2325
@if (scanning) {
2426
<h4 class="text-center">
25-
<span class="mdi mdi-fw mdi-loading mdi-spin-fast"></span> Scanning for changes...
27+
<IconLoader /> Scanning for changes...
2628
</h4>
2729
@if (!string.IsNullOrWhiteSpace(scanningProgress)) {
2830
<h4 class="text-center">@scanningProgress</h4>
31+
<h5>@scanningFolder</h5>
2932
}
3033
} else if (error) {
3134
<div class="text-danger">@errorMessage</div>

TowerSoft.DevToolkit/Components/GitScanner/GitScanner.razor.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public partial class GitScanner {
77
private string folder;
88
private bool scanning = false;
99
private string scanningProgress;
10+
private string scanningFolder;
1011
private bool error;
1112
private string errorMessage;
1213
private bool includeReposWithoutChanges = false;
@@ -19,7 +20,9 @@ protected override void OnInitialized() {
1920
private async Task StartScan() {
2021
Progress<string> progressReporter = new Progress<string>();
2122
progressReporter.ProgressChanged += (prop, data) => {
22-
scanningProgress = data;
23+
var parts = data.Split(["||"], StringSplitOptions.RemoveEmptyEntries);
24+
scanningProgress = parts[0];
25+
scanningFolder = parts[1];
2326
StateHasChanged();
2427
};
2528
await Scan(progressReporter);
@@ -47,7 +50,7 @@ await Task.Run(() => {
4750
int currentRepoCount = 1;
4851

4952
foreach (string dir in directories) {
50-
progress.Report($"{currentRepoCount} / {directories.Length}");
53+
progress.Report($"{currentRepoCount} / {directories.Length}||{dir}");
5154

5255
if (dir.Contains("node_modules")) continue;
5356
DirectoryInfo di = new(dir);
@@ -81,15 +84,15 @@ await Task.Run(() => {
8184
}
8285

8386
// Check if repo is ahead of remote
84-
ProcessResult statusResult = await ProcessUtilities.GetOutput("git.exe", "status -sb", di.Parent.FullName);
85-
if (!string.IsNullOrWhiteSpace(statusResult.Error)) {
86-
info.ErrorOccurred = true;
87-
info.ErrorMessage = statusResult.Error;
88-
} else {
89-
if (statusResult.Output.Contains("ahead", StringComparison.OrdinalIgnoreCase)) {
90-
info.LocalAheadOfRemote = true;
91-
}
87+
string output = await ProcessUtilities.GetStandardOutputTest("git.exe", "status -sb", di.Parent.FullName);
88+
//if (!string.IsNullOrWhiteSpace(statusResult.Error)) {
89+
// info.ErrorOccurred = true;
90+
// info.ErrorMessage = statusResult.Error;
91+
//} else {
92+
if (output.Contains("ahead", StringComparison.OrdinalIgnoreCase)) {
93+
info.LocalAheadOfRemote = true;
9294
}
95+
//}
9396

9497
gitRepoInfos.Add(info);
9598
currentRepoCount++;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+

2+
namespace TowerSoft.DevToolkit.Components.Icons {
3+
public class IconAdd : IconBase {
4+
protected override List<string> Paths => [
5+
"M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z",
6+
"M15 12h-6",
7+
"M12 9v6"
8+
];
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
<svg @attributes="@Attributes"
3+
viewBox="0 0 24 24">
4+
5+
@foreach (ISvgSubElement part in Parts) {
6+
@part.ToHtml()
7+
}
8+
</svg>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using Microsoft.AspNetCore.Components;
2+
using System.Web;
3+
4+
namespace TowerSoft.DevToolkit.Components.Icons {
5+
public abstract partial class IconAdvancedBase {
6+
private readonly string additionalClasses;
7+
8+
public IconAdvancedBase() { }
9+
10+
public IconAdvancedBase(string additionalClasses) {
11+
this.additionalClasses = additionalClasses;
12+
}
13+
14+
protected abstract List<ISvgSubElement> Parts { get; }
15+
16+
[Parameter]
17+
public Dictionary<string, object> Attributes { get; set; }
18+
19+
20+
protected override void OnParametersSet() {
21+
if (Attributes == null) Attributes = [];
22+
23+
string classList = "tabler-icon";
24+
if (!string.IsNullOrWhiteSpace(additionalClasses))
25+
classList += " " + additionalClasses;
26+
27+
if (Attributes.TryGetValue("class", out var classes)) {
28+
classList += " " + classes;
29+
Attributes["class"] = classList;
30+
} else {
31+
Attributes.Add("class", classList);
32+
}
33+
}
34+
}
35+
36+
public interface ISvgSubElement {
37+
string ElementName { get; }
38+
39+
public MarkupString ToHtml();
40+
}
41+
42+
public class SvgPath(string d) : ISvgSubElement {
43+
public string ElementName => "path";
44+
45+
public string D { get; } = d;
46+
47+
public MarkupString ToHtml() {
48+
return new MarkupString($"<{ElementName} d=\"{D}\" />");
49+
}
50+
51+
public static SvgPath New(string d) {
52+
return new SvgPath(d);
53+
}
54+
}
55+
56+
public class SvgRect(int x, int y, int width, int height) : ISvgSubElement {
57+
public string ElementName => "rect";
58+
59+
public int X { get; } = x;
60+
public int Y { get; } = y;
61+
public int Width { get; } = width;
62+
public int Height { get; } = height;
63+
64+
public MarkupString ToHtml() {
65+
return new MarkupString($"<{ElementName} x=\"{X}\" y=\"{Y}\" width=\"{Width}\" height=\"{Height}\" />");
66+
}
67+
68+
public static SvgRect New(int x, int y, int width, int height) {
69+
return new SvgRect(x, y, width, height);
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)