-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add selectFolder button and functionality
Adds a button to the UI to select folders and adds them to a list
- Loading branch information
1 parent
a23b38b
commit 8ad405d
Showing
6 changed files
with
126 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package backend | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
"github.com/wailsapp/wails/v2/pkg/runtime" | ||
) | ||
|
||
type DatasetFolder struct { | ||
Id uuid.UUID | ||
Folder string | ||
Cancel context.CancelFunc | ||
} | ||
|
||
// Select a folder using a native menu | ||
func SelectFolder(context context.Context) (DatasetFolder, error) { | ||
dialogOptions := runtime.OpenDialogOptions{ | ||
} | ||
|
||
folder, err := runtime.OpenDirectoryDialog(context, dialogOptions) | ||
if err != nil || folder == "" { | ||
return DatasetFolder{}, err | ||
} | ||
|
||
id := uuid.New() | ||
|
||
runtime.EventsEmit(context, "folder-added", id, folder) | ||
|
||
selected_folder := DatasetFolder{Folder: folder, Id: id} | ||
return selected_folder, nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script> | ||
export let items; | ||
</script> | ||
|
||
<h3>Selected Folders:</h3> | ||
<div style="overflow-y: scroll; height:400px;"> | ||
<ul> | ||
{#each Object.entries(items) as [id, item]} | ||
<li> | ||
<svelte:component this={item.component} {...item} /> | ||
</li> | ||
{/each} | ||
</ul> | ||
</div> | ||
|
||
<style> | ||
ul { | ||
list-style-type: none; | ||
} | ||
li { | ||
display: block; | ||
flex: 0 1 auto; /* Default */ | ||
list-style-type: none; | ||
} | ||
</style> |
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,30 @@ | ||
<script> | ||
export let id; | ||
export let value; | ||
export let status; | ||
export let progress; | ||
</script> | ||
|
||
<div class="listitem"> | ||
<div class="path"> | ||
{value} | ||
</div> | ||
<div> | ||
{status} | ||
</div> | ||
<div> | ||
{progress} % | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.listitem { | ||
display: grid; | ||
grid-template-columns: 5fr 2fr 2fr; | ||
grid-template-rows: auto; | ||
padding-right: 30px; | ||
} | ||
.path { | ||
text-align: left; | ||
} | ||
</style> |
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