Skip to content

Commit bed43d5

Browse files
author
Thomas Rueckstiess
committed
reload collections, and spin button
1 parent eacce18 commit bed43d5

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"ampersand-state",
3131
"scout-server",
3232
"glob",
33-
"electron-squirrel-startup"
33+
"electron-squirrel-startup",
34+
"ipc"
3435
]
3536
},
3637
"fonts": [

src/sidebar/instance-properties.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ div.instance-properties
1010
span.num-collections
1111
strong(data-hook='num-collections')
1212
|  Collections
13-
button.refresh-collections
14-
i.fa.fa-repeat
13+
button.refresh-collections(data-hook='refresh-button')
14+
i.fa(data-hook='refresh-icon')

src/sidebar/instance-properties.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var View = require('ampersand-view');
22
var app = require('ampersand-app');
33
// var debug = require('debug')('scout:sidebar:instace-properties');
4+
var _ = require('lodash');
45

56
var InstancePropertiesView = module.exports = View.extend({
67
template: require('./instance-properties.jade'),
@@ -9,7 +10,11 @@ var InstancePropertiesView = module.exports = View.extend({
910
version: 'string',
1011
numDatabases: 'number',
1112
numCollections: 'number',
12-
instance: 'state'
13+
instance: 'state',
14+
is_fetching: {
15+
type: 'boolean',
16+
default: true
17+
}
1318
},
1419
bindings: {
1520
'instance.host.hostname': {
@@ -27,14 +32,31 @@ var InstancePropertiesView = module.exports = View.extend({
2732
numDatabases: {
2833
type: 'text',
2934
hook: 'num-databases'
35+
},
36+
is_fetching: {
37+
type: 'booleanClass',
38+
hook: 'refresh-icon',
39+
yes: ['fa-refresh', 'fa-spin'],
40+
no: 'fa-repeat'
3041
}
3142
},
43+
events: {
44+
'click button[data-hook=refresh-button]': 'onRefreshButtonClicked'
45+
},
3246
initialize: function() {
3347
this.listenTo(app.instance, 'sync', this.onInstanceFetched);
3448
},
3549
onInstanceFetched: function() {
50+
// delay switching the spinner back to static for 500ms, otherwise the reload is not noticable
51+
_.delay(function() {
52+
this.is_fetching = false;
53+
}.bind(this), 500);
3654
this.numDatabases = app.instance.databases.length;
3755
this.numCollections = app.instance.collections.length;
56+
},
57+
onRefreshButtonClicked: function() {
58+
app.instance.fetch();
59+
this.is_fetching = true;
3860
}
3961
});
4062

0 commit comments

Comments
 (0)