Skip to content

Commit b991d76

Browse files
committed
Added a spinner to the OK button on the trace input form.
It turns on when you press OK, and turns off when the processing finishes.
1 parent 7d9a6d9 commit b991d76

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

codepulse/src/main/resources/toserve/pages/TraceInputForm/TraceInputForm.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ $(document).ready(function(){
5252
var traceFile = new Bacon.Model(null)
5353
var traceName = new Bacon.Model('')
5454

55+
var isUploading = new Bacon.Model(false)
56+
5557
/*
5658
* Set the `currentFeedback` to an empty object. As errors and warnings w.r.t.
5759
* the form start appearing, they will be stored in this object, for display.
@@ -142,6 +144,7 @@ $(document).ready(function(){
142144
* encounters an error when trying to contact the server.
143145
*/
144146
function onSubmitError(err){
147+
isUploading.set(false)
145148
alert('Error: ' + (err || '(unknown error)'))
146149
}
147150

@@ -152,6 +155,7 @@ $(document).ready(function(){
152155
* automatically be redirected to that location.
153156
*/
154157
function onSubmitDone(result){
158+
isUploading.set(true)
155159
window.location.href = result.href
156160
}
157161

@@ -293,12 +297,14 @@ $(document).ready(function(){
293297
submissionCriteria
294298
.sampledBy(submitButton.asEventStream('click'))
295299
.filter(canSubmitForm)
300+
.filter(isUploading.property.not())
296301
.onValue(function(criteria){
297302
console.log('allow submission with ', criteria)
298303

299304
var file = criteria.fileData.files[0],
300305
filepath = file.path
301306

307+
isUploading.set(true)
302308
if(CodePulse.isEmbedded && filepath){
303309
// native upload behavior
304310
doNativeUpload(filepath)
@@ -308,6 +314,10 @@ $(document).ready(function(){
308314
}
309315
})
310316

317+
isUploading.property.onValue(function(b){
318+
submitButton.overlay(b ? 'wait' : 'ready')
319+
})
320+
311321
/*
312322
* Ask the server if there will be a name conflict with the given `name`.
313323
* The `callback` is a `function(error, result)` in the style of node.js,

codepulse/src/main/resources/toserve/widgets/overlay/overlay.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
}
2121

2222
.overlay-container {
23-
display: block;
2423
position: relative;
2524
}
2625

codepulse/src/main/webapp/templates-hidden/TraceInputForm.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div id="trace-input-form">
22

33
<lift:head>
4+
<script class="lift:Includes.overlay"></script>
45
<link class="lift:Includes.TraceInputForm"></link>
56
</lift:head>
67

0 commit comments

Comments
 (0)