-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#435: show spinner indicating page is loading #449
Open
djyotta
wants to merge
16
commits into
sqlpage:main
Choose a base branch
from
djyotta:daniel/435-spinner-to-indicate-page-is-loading
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
397050b
#435: WIP - show spinner indicating page is loading
5201f76
center the spinner
4c1b2a7
use tabler spinner by default
065792d
fix whitespace
6761c4d
add example of progress on it's own
4e4c473
fix whitespace
15f129a
add example of loader without spinner
867641d
fix whitespace
a98b39b
no spinner if not specified
df752bf
improve top-level params of spinner component and add documentation
2a745e7
use http_header component instead of disabling compression everywhere
djyotta d2a3857
remove unnecessary whitespace change
djyotta 23879e0
fix styling when errors while loading and simplify css
djyotta d96525b
Update loader-start.handlebars
djyotta fc91682
always show progress bar at top-level component
djyotta 1c3024a
Merge branch 'main' into daniel/435-spinner-to-indicate-page-is-loading
djyotta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SQLPage display progress | ||
|
||
This is a very simple example of a page that shows a spinner to indicate page is loading. |
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,19 @@ | ||
-- Disable actix-web compression middleware: | ||
-- https://github.com/actix/actix-web/issues/3410 | ||
SELECT 'http_header' AS component, 'Identity' AS "Content-Encoding"; | ||
|
||
SELECT 'shell' AS component, 'light' AS theme; | ||
|
||
-- can disable the spinner to show only progress bar | ||
SELECT 'loader-start' AS component, '' AS spinner; | ||
|
||
SELECT 'progress' AS component, | ||
NULL AS percent, | ||
'sm' AS size, | ||
'yellow' AS color, | ||
'Working on it' AS stage; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
|
||
SELECT 'loader-stop' AS component; | ||
|
||
SELECT 'text' AS component, 'Processing complete.' AS contents; |
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,57 @@ | ||
-- Disable actix-web compression middleware: | ||
-- https://github.com/actix/actix-web/issues/3410 | ||
SELECT 'http_header' AS component, 'Identity' AS "Content-Encoding"; | ||
|
||
SELECT 'shell' AS component, 'dark' AS theme; | ||
|
||
SELECT 'loader-start' AS component, | ||
-- pick from the tabler spinners: https://tabler.io/docs/components/spinners | ||
"spinner-border" spinner, | ||
"sm" AS size, | ||
"red" AS color; | ||
|
||
SELECT 'progress' AS component, | ||
'sm' AS size, | ||
'yellow' AS color, | ||
'0' AS percent, | ||
'Fething data' AS stage; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
|
||
/* percent property is optional */ | ||
SELECT 'progress' AS component, | ||
NULL AS percent, | ||
'sm' AS size, | ||
'yellow' AS color, | ||
'Doing something' AS stage; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
|
||
/* stage property is optional */ | ||
SELECT 'progress' AS component, | ||
'sm' AS size, | ||
'yellow' AS color, | ||
'40' AS percent; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
|
||
/* multiple rows */ | ||
SELECT 'progress' AS component, 'sm' AS size, 'yellow' AS color; | ||
SELECT '70' AS percent, 'Fetching data' AS stage | ||
SELECT sqlpage.fetch('https://example.com'); | ||
SELECT '80' AS percent, 'Fetching more data' AS stage; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
SELECT '90' AS percent, 'Fetching again' AS stage; | ||
SELECT sqlpage.fetch('https://example.com'); | ||
|
||
SELECT '100' AS percent; | ||
|
||
SELECT 'loader-stop' AS component; | ||
|
||
SELECT 'text' AS component, | ||
'It works!' AS title, | ||
TRUE AS center, | ||
'Page is loaded.' AS contents; | ||
|
||
SELECT 'button' AS component; | ||
SELECT 'Go' AS title, './go.sql' AS link; | ||
|
||
-- can use progress on it's own | ||
SELECT 'progress' AS component, 'sm' AS size, 'Waiting for user' AS stage; |
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,6 @@ | ||
<div {{#if id}}id="{{id}}"{{/if}} class="sqlpage-loader-start"> | ||
<div class="sqlpage-loader-container"> | ||
<span class="{{default spinner "spinner-border"}} | ||
{{#if size}}spinner-border-{{size}}{{/if}} | ||
{{#if color}}text-{{color}}{{/if}}"> | ||
</span> |
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,3 @@ | ||
</div> | ||
</div> | ||
<div class="sqlpage-loader-stop"></div> |
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,42 @@ | ||
<div class="sqlpage-progress-container"> | ||
<div class="progress {{~#if size}} progress-{{size}}{{/if}}"> | ||
<div | ||
id="sqlpage-loading-{{default stage "progress"}}" | ||
class="progress-bar | ||
{{~#if (not percent)}} progress-bar-indeterminate{{/if}} | ||
{{~#if color}} bg-{{color}}{{/if}}" | ||
role="progressbar" | ||
aria-valuenow="{{percent}}" | ||
{{~#if percent}}style="width: {{percent}}%; display: block"{{/if}} | ||
aria-valuemin="0" aria-valuemax="100" | ||
{{~#if stage}}aria-label="{{stage}}"{{/if}}> | ||
</div> | ||
</div> | ||
{{~#if stage}} | ||
<br> | ||
<label for="sqlpage-loading-{{default stage "progress"}}">{{stage}}</label> | ||
{{/if}} | ||
</div> | ||
{{#each_row}} | ||
{{#if (or percent stage)}} | ||
<div class="sqlpage-progress-container"> | ||
<div class="progress {{~#if ../size}} progress-{{../size}}{{/if}}"> | ||
<div | ||
id="sqlpage-loading-{{default stage "progress"}}" | ||
class="progress-bar | ||
{{~#if (not percent)}} progress-bar-indeterminate{{/if}} | ||
{{~#if ../color}} bg-{{../color}}{{/if}}" | ||
role="progressbar" | ||
aria-valuenow="{{percent}}" | ||
{{~#if percent}}style="width: {{percent}}%; display: block"{{/if}} | ||
aria-valuemin="0" aria-valuemax="100" | ||
{{~#if stage}}aria-label="{{stage}}"{{/if}}> | ||
</div> | ||
</div> | ||
{{~#if stage}} | ||
<br> | ||
<label for="sqlpage-loading-{{default stage "progress"}}">{{stage}}</label> | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
{{/each_row}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed this whole approach doesn't work inside run_sql for some reason. So I should note that 'loader-start' component should be selected before descending into run_sql.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, run_sql is a function, it returns a single json value all at once, it can't stream its results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought as much but didn't want to assume. It's good to have the clarification.