-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show progress bars when downloading assets, update README (#257)
* Display download progress for remotely hosted assets * Fix race condition between inputs and available options, avoiding duplicate downloads of the same asset * Show logs for download progress * Update README * Bump app version
- Loading branch information
Showing
6 changed files
with
227 additions
and
7 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
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,60 @@ | ||
import { | ||
OverlayToaster, | ||
Position, | ||
ProgressBar, | ||
Classes, | ||
} from "@blueprintjs/core"; | ||
|
||
import { Tooltip2 } from "@blueprintjs/popover2"; | ||
|
||
import classNames from "classnames"; | ||
|
||
export const DownloadToaster = OverlayToaster.create({ | ||
className: "recipe-toaster", | ||
position: Position.TOP_RIGHT, | ||
}); | ||
|
||
let download_toasters = {}; | ||
|
||
export function setProgress(id, total, progress) { | ||
if (total !== null) { | ||
download_toasters["total"] = total; | ||
download_toasters["progress"] = progress; | ||
} | ||
|
||
if (progress !== null) { | ||
let tprogress = | ||
(Math.round((progress * 100) / download_toasters["total"]) / 100) * 100; | ||
|
||
download_toasters["progress"] = tprogress; | ||
} | ||
} | ||
|
||
export function renderProgress(progress, url) { | ||
return { | ||
icon: "cloud-download", | ||
message: ( | ||
<> | ||
<> | ||
Downloading asset from{" "} | ||
<Tooltip2 | ||
className={Classes.TOOLTIP_INDICATOR} | ||
content={<span>{url}</span>} | ||
minimal={true} | ||
usePortal={false} | ||
> | ||
{new URL(url).hostname} | ||
</Tooltip2> | ||
</> | ||
<ProgressBar | ||
className={classNames("docs-toast-progress", { | ||
[Classes.PROGRESS_NO_STRIPES]: progress >= 100, | ||
})} | ||
intent={progress < 100 ? "primary" : "success"} | ||
value={progress / 100} | ||
/> | ||
</> | ||
), | ||
timeout: progress < 100 ? 0 : 1000, | ||
}; | ||
} |
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
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