Skip to content

Commit

Permalink
Frontend updates & Add large directory warning
Browse files Browse the repository at this point in the history
  • Loading branch information
achhabra2 committed Jun 7, 2022
1 parent fc2e5d8 commit 25f28f7
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 122 deletions.
28 changes: 28 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ func (b *App) OpenDirectoryDialog() ([]string, error) {
return b.selectedFiles, errors.New("invalid selection")
}
b.selectedFiles = []string{selection}

dirSize, err := DirSize(selection)
if err != nil {
runtime.LogError(b.ctx, "Could not get directory size info")
return b.selectedFiles, nil
} else {
runtime.LogInfof(b.ctx, "Directory Size, %v \n", dirSize)
if dirSize > 1000000000 {
buttons := []string{"Ok"}
dialogMessage := fmt.Sprintf("You are attempting to send a large directory ( %v+ GB ). This may take time to compress before sending. Please be patient. ", dirSize/1000000000)
dialogOpts := runtime.MessageDialogOptions{Title: "Large Directory Warning", Message: dialogMessage, Type: runtime.InfoDialog, Buttons: buttons, DefaultButton: "Ok"}
_, _ = runtime.MessageDialog(b.ctx, dialogOpts)
}
}
return b.selectedFiles, nil
}

Expand Down Expand Up @@ -552,3 +566,17 @@ func unzipFile(path string) (string, error) {
}
return dst, nil
}

func DirSize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
size += info.Size()
}
return err
})
return size, err
}
2 changes: 1 addition & 1 deletion frontend/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/dist/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/receiver.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
});
</script>

<div class="flex flex-col justify-items-center content-center m-2">
<div class="flex flex-col justify-center content-center h-full">
<div
class="border-2 border-green-300 rounded-md shadow-md w-72 h-56 p-2 mx-auto receive-icon-container"
>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/sender.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ClearSelectedFiles,
SelectedFilesSend,
CancelWormholeRequest,
GetSelectedFiles
GetSelectedFiles,
} from "../wailsjs/go/main/App";
import Progress from "./progress.svelte";
Expand Down Expand Up @@ -64,7 +64,7 @@
}
function onCancel() {
CancelWormholeRequest()
CancelWormholeRequest();
isSending = false;
sendCode = "";
status = "waiting";
Expand Down Expand Up @@ -118,7 +118,7 @@
});
</script>

<div class="flex flex-col justify-items-center content-center m-2">
<div class="flex flex-col justify-center content-center h-full">
<div
class="border-2 border-green-300 rounded-md shadow-md w-72 h-56 p-2 mx-auto cursor-fix send-icon-container"
>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
notifications = prefs.notifications;
overwrite = prefs.overwrite;
selfUpdate = prefs.selfUpdate;
if (downloadsFolder.includes("Container")) {
downloadsFolder = "~/Downloads"
}
});
GetLogPath().then((path) => {
logPath = path;
Expand Down
44 changes: 22 additions & 22 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,50 @@
// This file is automatically generated. DO NOT EDIT
import {settings} from '../models';

export function ShowErrorDialog(arg1:string):void;
export function CancelWormholeRequest():void;

export function UpdateSendProgress(arg1:number,arg2:number):void;
export function GetLogPath():Promise<string>;

export function AppInstalledFromPackageManager():Promise<boolean>;
export function OpenFile(arg1:string):void;

export function SetOverwriteParam(arg1:boolean):Promise<boolean>;
export function VerifyNotificationIcon():Promise<string>;

export function GetUserPrefs():Promise<settings.UserSettings>;
export function GetReceivedFile():Promise<string>;

export function OpenDirectoryDialog():Promise<Array<string>|Error>;

export function ReceiveFile(arg1:string):void;

export function SetNotificationsParam(arg1:boolean):Promise<boolean>;
export function OpenFilesDialog():Promise<Array<string>|Error>;

export function VerifyNotificationIcon():Promise<string>;
export function SendDirectory(arg1:string):void;

export function GetCurrentVersion():Promise<string>;
export function SetSelfUpdateParam(arg1:boolean):Promise<boolean>;

export function GetReceivedFile():Promise<string>;
export function SelectedFilesSend():void;

export function SendFile(arg1:string):void;

export function SetDownloadsFolder():Promise<string>;
export function AppInstalledFromPackageManager():Promise<boolean>;

export function GetSelectedFiles():Promise<Array<string>>;
export function ClearSelectedFiles():void;

export function PersistUserSettings():void;
export function GetCurrentVersion():Promise<string>;

export function GetLogPath():Promise<string>;
export function GetSelectedFiles():Promise<Array<string>>;

export function OpenFile(arg1:string):void;
export function GetUserPrefs():Promise<settings.UserSettings>;

export function OpenFilesDialog():Promise<Array<string>|Error>;
export function PersistUserSettings():void;

export function SelectedFilesSend():void;
export function SetDownloadsFolder():Promise<string>;

export function SendDirectory(arg1:string):void;
export function SetNotificationsParam(arg1:boolean):Promise<boolean>;

export function SetSelfUpdateParam(arg1:boolean):Promise<boolean>;
export function SetOverwriteParam(arg1:boolean):Promise<boolean>;

export function CancelWormholeRequest():void;
export function ShowErrorDialog(arg1:string):void;

export function ClearSelectedFiles():void;
export function ReceiveFile(arg1:string):void;

export function UpdateCheckUI():void;

export function UpdateSendProgress(arg1:number,arg2:number):void;
88 changes: 44 additions & 44 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,98 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

export function ShowErrorDialog(arg1) {
window['go']['main']['App']['ShowErrorDialog'](arg1);
export function CancelWormholeRequest() {
window['go']['main']['App']['CancelWormholeRequest']();
}

export function UpdateSendProgress(arg1, arg2) {
window['go']['main']['App']['UpdateSendProgress'](arg1, arg2);
export function GetLogPath() {
return window['go']['main']['App']['GetLogPath']();
}

export function AppInstalledFromPackageManager() {
return window['go']['main']['App']['AppInstalledFromPackageManager']();
export function OpenFile(arg1) {
window['go']['main']['App']['OpenFile'](arg1);
}

export function SetOverwriteParam(arg1) {
return window['go']['main']['App']['SetOverwriteParam'](arg1);
export function VerifyNotificationIcon() {
return window['go']['main']['App']['VerifyNotificationIcon']();
}

export function GetUserPrefs() {
return window['go']['main']['App']['GetUserPrefs']();
export function GetReceivedFile() {
return window['go']['main']['App']['GetReceivedFile']();
}

export function OpenDirectoryDialog() {
return window['go']['main']['App']['OpenDirectoryDialog']();
}

export function ReceiveFile(arg1) {
window['go']['main']['App']['ReceiveFile'](arg1);
}

export function SetNotificationsParam(arg1) {
return window['go']['main']['App']['SetNotificationsParam'](arg1);
export function OpenFilesDialog() {
return window['go']['main']['App']['OpenFilesDialog']();
}

export function VerifyNotificationIcon() {
return window['go']['main']['App']['VerifyNotificationIcon']();
export function SendDirectory(arg1) {
window['go']['main']['App']['SendDirectory'](arg1);
}

export function GetCurrentVersion() {
return window['go']['main']['App']['GetCurrentVersion']();
export function SetSelfUpdateParam(arg1) {
return window['go']['main']['App']['SetSelfUpdateParam'](arg1);
}

export function GetReceivedFile() {
return window['go']['main']['App']['GetReceivedFile']();
export function SelectedFilesSend() {
window['go']['main']['App']['SelectedFilesSend']();
}

export function SendFile(arg1) {
window['go']['main']['App']['SendFile'](arg1);
}

export function SetDownloadsFolder() {
return window['go']['main']['App']['SetDownloadsFolder']();
export function AppInstalledFromPackageManager() {
return window['go']['main']['App']['AppInstalledFromPackageManager']();
}

export function GetSelectedFiles() {
return window['go']['main']['App']['GetSelectedFiles']();
export function ClearSelectedFiles() {
window['go']['main']['App']['ClearSelectedFiles']();
}

export function PersistUserSettings() {
window['go']['main']['App']['PersistUserSettings']();
export function GetCurrentVersion() {
return window['go']['main']['App']['GetCurrentVersion']();
}

export function GetLogPath() {
return window['go']['main']['App']['GetLogPath']();
export function GetSelectedFiles() {
return window['go']['main']['App']['GetSelectedFiles']();
}

export function OpenFile(arg1) {
window['go']['main']['App']['OpenFile'](arg1);
export function GetUserPrefs() {
return window['go']['main']['App']['GetUserPrefs']();
}

export function OpenFilesDialog() {
return window['go']['main']['App']['OpenFilesDialog']();
export function PersistUserSettings() {
window['go']['main']['App']['PersistUserSettings']();
}

export function SelectedFilesSend() {
window['go']['main']['App']['SelectedFilesSend']();
export function SetDownloadsFolder() {
return window['go']['main']['App']['SetDownloadsFolder']();
}

export function SendDirectory(arg1) {
window['go']['main']['App']['SendDirectory'](arg1);
export function SetNotificationsParam(arg1) {
return window['go']['main']['App']['SetNotificationsParam'](arg1);
}

export function SetSelfUpdateParam(arg1) {
return window['go']['main']['App']['SetSelfUpdateParam'](arg1);
export function SetOverwriteParam(arg1) {
return window['go']['main']['App']['SetOverwriteParam'](arg1);
}

export function CancelWormholeRequest() {
window['go']['main']['App']['CancelWormholeRequest']();
export function ShowErrorDialog(arg1) {
window['go']['main']['App']['ShowErrorDialog'](arg1);
}

export function ClearSelectedFiles() {
window['go']['main']['App']['ClearSelectedFiles']();
export function ReceiveFile(arg1) {
window['go']['main']['App']['ReceiveFile'](arg1);
}

export function UpdateCheckUI() {
window['go']['main']['App']['UpdateCheckUI']();
}

export function UpdateSendProgress(arg1, arg2) {
window['go']['main']['App']['UpdateSendProgress'](arg1, arg2);
}
2 changes: 1 addition & 1 deletion frontend/wailsjs/runtime/runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function BrowserOpenURL(url: string): void;

// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
// Returns information about the environment
export function Environment(): EnvironmentInfo;
export function Environment(): Promise<EnvironmentInfo>;

// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
// Quits the application.
Expand Down
4 changes: 2 additions & 2 deletions frontend/wailsjs/runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export function EventsOnMultiple(eventName, callback, maxCallbacks) {
}

export function EventsOn(eventName, callback) {
OnMultiple(eventName, callback, -1);
EventsOnMultiple(eventName, callback, -1);
}

export function EventsOff(eventName) {
return window.runtime.EventsOff(eventName);
}

export function EventsOnce(eventName, callback) {
OnMultiple(eventName, callback, 1);
EventsOnMultiple(eventName, callback, 1);
}

export function EventsEmit(eventName) {
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ go 1.17

require (
github.com/blang/semver v3.5.1+incompatible
github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a
github.com/klauspost/compress v1.15.2
github.com/gen2brain/beeep v0.0.0-20220518085355-d7852edf42fc
github.com/klauspost/compress v1.15.6
github.com/psanford/wormhole-william v1.0.6
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/wailsapp/wails/v2 v2.0.0-beta.36
github.com/wailsapp/wails/v2 v2.0.0-beta.37
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/gin-gonic/gin v1.7.7 // indirect
github.com/gin-gonic/gin v1.8.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
Expand All @@ -22,35 +22,35 @@ require (
github.com/google/go-github/v30 v30.1.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo/v4 v4.7.2 // indirect
github.com/labstack/gommon v0.3.1 // indirect
github.com/leaanthony/go-ansi-parser v1.4.0 // indirect
github.com/leaanthony/go-ansi-parser v1.5.0 // indirect
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
github.com/leaanthony/gosod v1.0.3 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
github.com/tkrajina/go-reflector v0.5.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
Expand Down
Loading

0 comments on commit 25f28f7

Please sign in to comment.