show number of pending requests

This commit is contained in:
j 2016-01-13 12:55:15 +05:30
parent 9fe7bcecbf
commit 5cbe139ac9

View file

@ -9,10 +9,10 @@ oml.ui.peersButton = function() {
marginRight: '6px' marginRight: '6px'
}) })
.bindEvent({ .bindEvent({
click: function() { click: open
// ... }),
} count,
}); requests = 0;
Ox.Button({ Ox.Button({
style: 'symbol', style: 'symbol',
@ -23,18 +23,45 @@ oml.ui.peersButton = function() {
float: 'left', float: 'left',
borderRadius: 0 borderRadius: 0
}) })
.bindEvent({
click: open
})
.appendTo(that); .appendTo(that);
Ox.Element() count = Ox.Element()
.addClass('OxLight') .addClass('OxLight')
.css({ .css({
float: 'left', float: 'left',
marginTop: '2px', marginTop: '3px',
fontSize: '9px' fontSize: '9px'
}) })
.html('0') .html('0')
.appendTo(that); .appendTo(that);
oml.bindEvent({
'peering.request': update,
'peering.accept': update,
'peering.reject': update
});
update();
function open() {
oml.UI.set({page: 'users'});
}
function update() {
oml.api.getUsers(function(result) {
requests = result.data.users.filter(function(user) {
return user.pending=="received";
}).length;
count.html(requests);
that.options({
tooltip: Ox._(requests
? Ox.formatCount(requests, 'peering request')
: 'No peering requests')
});
});
}
return that; return that;
}; };