show number of pending requests

This commit is contained in:
j 2016-01-13 12:55:15 +05:30
parent 9fe7bcecbf
commit 5cbe139ac9
1 changed files with 34 additions and 7 deletions

View File

@ -9,10 +9,10 @@ oml.ui.peersButton = function() {
marginRight: '6px'
})
.bindEvent({
click: function() {
// ...
}
});
click: open
}),
count,
requests = 0;
Ox.Button({
style: 'symbol',
@ -23,18 +23,45 @@ oml.ui.peersButton = function() {
float: 'left',
borderRadius: 0
})
.bindEvent({
click: open
})
.appendTo(that);
Ox.Element()
count = Ox.Element()
.addClass('OxLight')
.css({
float: 'left',
marginTop: '2px',
marginTop: '3px',
fontSize: '9px'
})
.html('0')
.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;
};
};