Browse Source

Show country in mod addrs

pull/126/head
Lal'C Mellk Mal 3 years ago
parent
commit
78b0f8394f
2 changed files with 9 additions and 7 deletions
  1. +3
    -1
      admin/client.js
  2. +6
    -6
      admin/panel.js

+ 3
- 1
admin/client.js View File

@@ -211,7 +211,7 @@ var AddressView = Backbone.View.extend({
render: function () {
var attrs = this.model.attributes;
if (attrs.shallow) {
this.$('.ip').text('Loading...');
this.$('.ip').text(attrs.ip ? attrs.ip + ' "\u2026"' : 'Loading...');
return this;
}
this.$('.ip').text(attrs.ip);
@@ -305,6 +305,8 @@ var AddrView = Backbone.View.extend({
var text = ip_mnemonic(attrs.ip);
if (attrs.name)
text += ' "' + attrs.name + '"';
if (attrs.country)
text += ' ' + attrs.country;
this.$el.attr('title', attrs.ip).text(text);
return this;
},


+ 6
- 6
admin/panel.js View File

@@ -28,8 +28,10 @@ function address_view(addr) {
addr = _.extend({}, addr);
addr.shallow = false;
var clients = STATE.clientsByIP[addr.ip];
if (clients && clients.length)
if (clients) {
addr.count = clients.length;
addr.country = clients[0] && clients[0].country || '';
}
return addr;
}

@@ -42,13 +44,12 @@ okyaku.dispatcher[authcommon.FETCH_ADDRESS] = function (msg, client) {
var key = ip_key(ip);
var addr = ADDRS[key];
if (addr) {
client.send([0, common.COLLECTION_ADD, 'addrs',
address_view(addr)]);
client.send([0, common.COLLECTION_ADD, 'addrs', address_view(addr)]);
return true;
}

// Cache miss
ADDRS[key] = addr = {ip: ip, key: key, shallow: true};
ADDRS[key] = addr = {ip, key, shallow: true};
var r = connect();
r.hgetall('ip:'+key, function (err, info) {
if (err) {
@@ -60,8 +61,7 @@ okyaku.dispatcher[authcommon.FETCH_ADDRESS] = function (msg, client) {
return;

_.extend(addr, info);
client.send([0, common.COLLECTION_ADD, 'addrs',
address_view(addr)]);
client.send([0, common.COLLECTION_ADD, 'addrs', address_view(addr)]);
});
return true;
}


Loading…
Cancel
Save