Skip to content

Commit 98512d4

Browse files
committed
INT-708 new spinner, progress bar improvements
1 parent cebb8eb commit 98512d4

File tree

5 files changed

+94
-57
lines changed

5 files changed

+94
-57
lines changed

src/bugsnag.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ var _ = require('lodash');
1414
var debug = require('debug')('scout:bugsnag');
1515

1616
var TOKEN = '0d11ab5f4d97452cc83d3365c21b491c';
17-
1817
// @todo (imlucas): use mongodb-redact
1918
function beforeNotify(d) {
2019
app.sendMessage('show bugsnag OS notification', d.message);
20+
app.statusbar.hide();
2121

2222
d.stacktrace = redact(d.stacktrace);
2323
d.context = redact(d.context);
2424
d.file = redact(d.file);
2525
d.message = redact(d.message);
2626
d.url = redact(d.url);
2727
d.name = redact(d.name);
28-
d.file = redact(d.file);
2928
d.metaData = redact(d.metaData);
3029
debug('redacted bugsnag report\n', JSON.stringify(d, null, 2));
3130
}

src/models/sampled-schema.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ module.exports = Schema.extend({
165165
}
166166
model.documents.reset(docs);
167167
model.documents.trigger('sync');
168-
app.statusbar.hide();
168+
app.statusbar.hide(true);
169169

170170
// @note (imlucas): Any other metrics? Feedback on `Schema *`?
171171
var totalTime = new Date() - start;
@@ -201,9 +201,11 @@ module.exports = Schema.extend({
201201
return onEmpty();
202202
}
203203

204-
debug('creating sample stream');
205204
var status = 0;
206205
var counter = 0;
206+
var numSamples = Math.min(options.size, count.count);
207+
var stepSize = Math.ceil(Math.max(1, numSamples / 10));
208+
207209
app.statusbar.show('Sampling collection...');
208210
app.statusbar.width = 1;
209211
app.statusbar.trickle(true);
@@ -216,8 +218,9 @@ module.exports = Schema.extend({
216218
})
217219
.on('data', function() {
218220
counter ++;
219-
if (counter % 7 === 0) {
220-
var inc = (100 - status) * 7 / options.size;
221+
if (counter % stepSize === 0) {
222+
var inc = (100 - status) * stepSize / numSamples;
223+
debug(inc);
221224
app.statusbar.width += inc;
222225
}
223226
})

src/statusbar/index.jade

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
.progress-bar.progress-bar-striped.active(data-hook='inner-bar')
44
ul.message-background.with-sidebar.centered(data-hook='message-container'): li
55
p(data-hook='message')
6-
.spinner-circles(data-hook='loading')
7-
.circle-1
8-
.circle-2
6+
.spinner(data-hook='loading')
7+
.rect1
8+
.rect2
9+
.rect3
10+
.rect4
11+
.rect5

src/statusbar/index.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var View = require('ampersand-view');
2-
var debug = require('debug')('scout:statusbar:index');
2+
var _ = require('lodash');
3+
// var debug = require('debug')('scout:statusbar:index');
34

45
var StatusbarView = View.extend({
56
props: {
@@ -11,14 +12,18 @@ var StatusbarView = View.extend({
1112
message: {
1213
type: 'string'
1314
},
14-
loading: {
15+
loadingIndicator: {
1516
type: 'boolean',
1617
default: true
18+
},
19+
visible: {
20+
type: 'boolean',
21+
default: false
1722
}
1823
},
1924
template: require('./index.jade'),
2025
bindings: {
21-
loading: {
26+
loadingIndicator: {
2227
hook: 'loading',
2328
type: 'booleanClass',
2429
yes: 'visible',
@@ -49,9 +54,14 @@ var StatusbarView = View.extend({
4954
},
5055
{
5156
type: 'booleanClass',
57+
hook: 'outer-bar',
5258
no: 'hidden'
5359
}
54-
]
60+
],
61+
visible: {
62+
type: 'booleanClass',
63+
no: 'hidden'
64+
}
5565
},
5666
derived: {
5767
/**
@@ -82,9 +92,11 @@ var StatusbarView = View.extend({
8292
this.hide();
8393
},
8494
fatal: function(err) {
85-
this.loading = false;
95+
this.visible = true;
96+
this.loadingIndicator = false;
8697
this.message = 'Fatal Error: ' + err.message;
87-
this.width = 100;
98+
this.width = 0;
99+
this.trickle(false);
88100
clearInterval(this.trickleTimer);
89101
},
90102
trickle: function(bool) {
@@ -97,19 +109,26 @@ var StatusbarView = View.extend({
97109
}
98110
},
99111
show: function(message) {
112+
this.visible = true;
100113
this.message = message || '';
101114
this.width = 100;
102-
this.loading = true;
115+
this.loadingIndicator = true;
103116
},
104-
hide: function() {
105-
this.width = 100;
117+
hide: function(completed) {
106118
this.message = '';
107-
this.loading = false;
119+
this.loadingIndicator = false;
108120
clearInterval(this.trickleTimer);
109-
var model = this;
110-
_.delay(function() {
111-
model.width = 0;
112-
}, 1000);
121+
if (completed) {
122+
this.width = 100;
123+
var model = this;
124+
_.delay(function() {
125+
model.width = 0;
126+
model.visible = false;
127+
}, 1000);
128+
} else {
129+
this.width = 0;
130+
this.visible = false;
131+
}
113132
}
114133
});
115134

src/statusbar/index.less

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,58 @@
2424
}
2525
}
2626
.message-background {
27-
.spinner-circles {
28-
width: 40px;
29-
height: 40px;
30-
position: relative;
31-
margin: 40px auto;
27+
.spinner {
28+
margin: 50px auto;
29+
width: 65px;
30+
height: 60px;
31+
text-align: center;
32+
font-size: 10px;
33+
}
3234

33-
.circle-1, .circle-2 {
34-
width: 100%;
35-
height: 100%;
36-
border-radius: 50%;
37-
background-color: @mc-blue0;
38-
opacity: 0.6;
39-
position: absolute;
40-
top: 0;
41-
left: 0;
35+
.spinner > div {
36+
background-color: rgba(0, 0, 0, 0.2);;
37+
margin: 0 3px 0 0;
38+
height: 100%;
39+
width: 10px;
40+
display: inline-block;
4241

43-
-webkit-animation: bounce 2.0s infinite ease-in-out;
44-
animation: bounce 2.0s infinite ease-in-out;
45-
}
42+
-webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
43+
animation: sk-stretchdelay 1.2s infinite ease-in-out;
44+
}
4645

47-
.circle-2 {
48-
-webkit-animation-delay: -1.0s;
49-
animation-delay: -1.0s;
50-
}
46+
.spinner .rect2 {
47+
-webkit-animation-delay: -1.1s;
48+
animation-delay: -1.1s;
49+
}
5150

52-
@-webkit-keyframes bounce {
53-
0%, 100% { -webkit-transform: scale(0.0) }
54-
50% { -webkit-transform: scale(1.0) }
55-
}
51+
.spinner .rect3 {
52+
-webkit-animation-delay: -1.0s;
53+
animation-delay: -1.0s;
54+
}
55+
56+
.spinner .rect4 {
57+
-webkit-animation-delay: -0.9s;
58+
animation-delay: -0.9s;
59+
}
60+
61+
.spinner .rect5 {
62+
-webkit-animation-delay: -0.8s;
63+
animation-delay: -0.8s;
64+
}
65+
66+
@-webkit-keyframes sk-stretchdelay {
67+
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
68+
20% { -webkit-transform: scaleY(1.0) }
69+
}
5670

57-
@keyframes bounce {
58-
0%, 100% {
59-
transform: scale(0.0);
60-
-webkit-transform: scale(0.0);
61-
} 50% {
62-
transform: scale(1.0);
63-
-webkit-transform: scale(1.0);
64-
}
71+
@keyframes sk-stretchdelay {
72+
0%, 40%, 100% {
73+
transform: scaleY(0.4);
74+
-webkit-transform: scaleY(0.4);
75+
} 20% {
76+
transform: scaleY(1.0);
77+
-webkit-transform: scaleY(1.0);
6578
}
6679
}
6780
}
68-
}
81+
}

0 commit comments

Comments
 (0)