Skip to content

Commit 442754d

Browse files
committed
Directory picker & smart grid/single file selection
- Directory picker: you can now open a directory instead of multiple files - Smart grid/single file selection: the preferred view is now saved in the LocalStorage. The single file selection is the default for vertical devices, and the grid for horizontal devices - Columns now can be resized also with buttons
1 parent ecb7fa2 commit 442754d

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

App.razor

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
<FluentButton style="position: absolute; top: 15px; width: fit-content; right: 15px;"
2222
IconStart="@(new Icons.Regular.Size20.Settings())" Appearance="Appearance.Accent"
2323
@onclick='() => {showSettings = true;}'></FluentButton>
24-
<InputFile multiple="true" id="filePicker" style="display: none;" OnChange="GetFiles">
24+
<InputFile directory="@pickFolder" webkitdirectory="@pickFolder" multiple="true" id="filePicker"
25+
style="display: none;" OnChange="GetFiles">
2526
</InputFile>
2627
<FluentToastProvider MaxToastCount="1" />
2728
@if (files.Count != 0)
@@ -44,8 +45,8 @@
4445
<FluentCheckbox @bind-Value="@updateEverything">Update all the
4546
seleted
4647
files</FluentCheckbox><br>
47-
<FluentDataGrid ResizableColumns="true" Items="files.AsQueryable<TagInfoContainer>()"
48-
ItemKey="@(file => file.id)">
48+
<FluentDataGrid ResizableColumns="true" ResizeType="DataGridResizeType.Discrete"
49+
Items="files.AsQueryable<TagInfoContainer>()" ItemKey="@(file => file.id)">
4950
<TemplateColumn Width="@((100 /(gridSelected.Count + 2)) + "%")" Sortable="false" Title="Actions:">
5051
<div class="flexContainer">
5152
<FluentButton IconStart="@(new Icons.Regular.Size20.Image())" @onclick='@(() => {
@@ -220,7 +221,8 @@
220221
{
221222
<FluentCard>
222223
<h2>Choose files:</h2>
223-
<FluentButton @onclick='() => JS.InvokeVoidAsync("clickInput")'>Choose files</FluentButton><br>
224+
<FluentButton @onclick='() => JS.InvokeVoidAsync("clickInput")'>Choose files</FluentButton><br><br>
225+
<FluentCheckbox @bind-Value="pickFolder">Choose a directory</FluentCheckbox><br>
224226
<p>Don't worry. Everything will be elaborated locally</p>
225227
</FluentCard>
226228
}
@@ -336,6 +338,10 @@
336338
/// </summary>
337339
private bool showGrid = true;
338340
/// <summary>
341+
/// Pick a directory instead of multiple files
342+
/// </summary>
343+
private bool pickFolder = false;
344+
/// <summary>
339345
/// A list that contains all the selected tag options
340346
/// </summary>
341347
private List<AvailableProperties.PropertiesObject> gridSelected = new List<PropertiesObject>();
@@ -370,6 +376,7 @@
370376
if (firstRender) // Get the selected theme, and apply it
371377
{
372378
fileSystemAvailable = await JS.InvokeAsync<bool>("getFileSystemAvailability");
379+
showGrid = await JS.InvokeAsync<bool>("getGridUI");
373380
await JS.InvokeVoidAsync("updateColor", [await JS.InvokeAsync<string>("getColor")]);
374381
await JS.InvokeVoidAsync("updateSlider", [(await JS.InvokeAsync<double>("getSliderValue")).ToString()]);
375382
}

Layout/Settings.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
</label>
3636
<br>
3737
<h3>Change metadata view:</h3>
38-
<FluentButton @onclick='() => {showGrid = !showGrid; GridUpdate(showGrid);}'>
38+
<FluentButton @onclick='async () => {
39+
showGrid = !showGrid;
40+
await JS.InvokeVoidAsync("setGridUI", [showGrid]);
41+
GridUpdate(showGrid);
42+
}'>
3943
@if (showGrid)
4044
{
4145
<p>Switch to "single file" view</p>

wwwroot/css/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fluent-design-system-provider {
3434
fluent-select,
3535
fluent-text-field,
3636
fluent-text-area,
37-
fluent-button,
37+
fluent-button:not(.col-options-button),
3838
fluent-listbox {
3939
width: 100%;
4040
width: -webkit-fill-available;

wwwroot/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ <h1>Welcome to TagLibSharp-Web!</h1>
9191
*/
9292
function wakeUp() {
9393

94+
}
95+
function getGridUI() {
96+
return (localStorage.getItem("TagLibWeb-UseGridUI") ?? (window.innerWidth > window.innerHeight ? "a" : "b")) === "a";
97+
}
98+
function setGridUI(grid) {
99+
localStorage.setItem("TagLibWeb-UseGridUI", grid ? "a" : "b");
94100
}
95101
navigator.serviceWorker.register('service-worker.js', { scope: window.location.href.substring(0, window.location.href.lastIndexOf("/") + 1) });
96-
const appVersion = "1.0.0";
102+
const appVersion = "1.0.1";
97103
fetch("./updatecode", { cache: "no-store" }).then((res) => res.text().then((text) => { if (text.replace("\n", "") !== appVersion) if (confirm(`There's a new version of TagLibSharp-Web. Do you want to update? [${appVersion} --> ${text.replace("\n", "")}]`)) { caches.delete("taglibsharpweb-cache"); location.reload(true); } }).catch((e) => { console.error(e) })).catch((e) => console.error(e)); // Check if the application code is the same as the current application version and, if not, ask the user to update
98104
</script>
99105
</body>

wwwroot/updatecode

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.1

0 commit comments

Comments
 (0)