Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sage Validation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
Sage Validation
Commits
4c76d393
Commit
4c76d393
authored
2 months ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Add loading spinner and disable button during file upload
parent
99ec3f09
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sage_validation/file_validator/templates/upload.html
+20
-1
20 additions, 1 deletion
sage_validation/file_validator/templates/upload.html
with
20 additions
and
1 deletion
sage_validation/file_validator/templates/upload.html
+
20
−
1
View file @
4c76d393
...
@@ -13,10 +13,21 @@
...
@@ -13,10 +13,21 @@
class=
"w-full border border-gray-300 p-3 rounded-lg focus:outline-none focus:ring focus:ring-blue-400"
>
class=
"w-full border border-gray-300 p-3 rounded-lg focus:outline-none focus:ring focus:ring-blue-400"
>
</div>
</div>
<button
type=
"submit"
<button
id=
"submitBtn"
type=
"submit"
class=
"w-full bg-blue-600 text-white py-3 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring focus:ring-blue-400"
>
class=
"w-full bg-blue-600 text-white py-3 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring focus:ring-blue-400"
>
Upload
Upload
</button>
</button>
<!-- Loading Spinner -->
<div
id=
"loadingSpinner"
class=
"hidden flex justify-center"
>
<svg
class=
"animate-spin h-6 w-6 text-blue-600"
xmlns=
"http://www.w3.org/2000/svg"
fill=
"none"
viewBox=
"0 0 24 24"
>
<circle
class=
"opacity-25"
cx=
"12"
cy=
"12"
r=
"10"
stroke=
"currentColor"
stroke-width=
"4"
></circle>
<path
class=
"opacity-75"
fill=
"currentColor"
d=
"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
/>
</svg>
</div>
</form>
</form>
<!-- Error Display -->
<!-- Error Display -->
...
@@ -45,6 +56,8 @@
...
@@ -45,6 +56,8 @@
e
.
preventDefault
();
e
.
preventDefault
();
const
fileInput
=
document
.
getElementById
(
'
fileInput
'
);
const
fileInput
=
document
.
getElementById
(
'
fileInput
'
);
const
submitBtn
=
document
.
getElementById
(
'
submitBtn
'
);
const
loadingSpinner
=
document
.
getElementById
(
'
loadingSpinner
'
);
const
errorSection
=
document
.
getElementById
(
'
errorSection
'
);
const
errorSection
=
document
.
getElementById
(
'
errorSection
'
);
const
errorList
=
document
.
getElementById
(
'
errorList
'
);
const
errorList
=
document
.
getElementById
(
'
errorList
'
);
const
successSection
=
document
.
getElementById
(
'
successSection
'
);
const
successSection
=
document
.
getElementById
(
'
successSection
'
);
...
@@ -58,6 +71,9 @@
...
@@ -58,6 +71,9 @@
successSection
.
classList
.
add
(
'
hidden
'
);
successSection
.
classList
.
add
(
'
hidden
'
);
downloadSection
.
classList
.
add
(
'
hidden
'
);
downloadSection
.
classList
.
add
(
'
hidden
'
);
submitBtn
.
disabled
=
true
;
loadingSpinner
.
classList
.
remove
(
'
hidden
'
);
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
'
file
'
,
fileInput
.
files
[
0
]);
formData
.
append
(
'
file
'
,
fileInput
.
files
[
0
]);
...
@@ -105,6 +121,9 @@
...
@@ -105,6 +121,9 @@
li
.
textContent
=
'
Failed to connect to the server. Please check your internet connection.
'
;
li
.
textContent
=
'
Failed to connect to the server. Please check your internet connection.
'
;
errorList
.
appendChild
(
li
);
errorList
.
appendChild
(
li
);
errorSection
.
classList
.
remove
(
'
hidden
'
);
errorSection
.
classList
.
remove
(
'
hidden
'
);
}
finally
{
loadingSpinner
.
classList
.
add
(
'
hidden
'
);
submitBtn
.
disabled
=
false
;
}
}
});
});
</script>
</script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment