Use flag icons in network view

This commit is contained in:
joeuhren
2020-11-23 19:09:05 -07:00
parent 781d9ee915
commit e8bb0740ea
3 changed files with 16 additions and 11 deletions
+2 -1
View File
@@ -7,7 +7,8 @@ var PeersSchema = new Schema({
port: { type: String, default: "" },
protocol: { type: String, default: "" },
version: { type: String, default: "" },
country: { type: String, default: "" }
country: { type: String, default: "" },
country_code: { type: String, default: "" }
});
module.exports = mongoose.model('Peers', PeersSchema);
+3 -2
View File
@@ -31,7 +31,7 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni
var rateLimit = new RateLimit(1, 2000, false);
db.find_peer(address, function(peer) {
if (peer) {
if (isNaN(peer['port']) || peer['port'].length < 2 || peer['country'].length < 1) {
if (isNaN(peer['port']) || peer['port'].length < 2 || peer['country'].length < 1 || peer['country_code'].length < 1) {
db.drop_peers(function() {
console.log('Saved peers missing ports or country, dropping peers. Re-run this script afterwards.');
exit();
@@ -47,7 +47,8 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni
port: port,
protocol: body[i].version,
version: body[i].subver.replace('/', '').replace('/', ''),
country: geo.country_name
country: geo.country_name,
country_code: geo.country_code
}, function(){
loop.next();
});
+11 -8
View File
@@ -10,17 +10,20 @@ script.
ajax: {
url: '/ext/connections',
dataSrc: function ( json ) {
/*for ( var i=0;i<json.data.length; i++ ) {
json.data[i]['timestamp'] = new Date((json.data[i]['timestamp']) * 1000).toUTCString();
json.data[i]['txid'] = "<a href='/tx/" + json.data[i]['txid'] + "'>" + json.data[i]['txid'] + "</a>";
json.data[i]['blockindex'] = "<a href='/block/" + json.data[i]['blockhash'] + "'>" + json.data[i]['blockindex'] + "</a>";
var amount = json.data[i]['total'] / 100000000;
json.data[i]['total'] = amount.toFixed(8);
json.data[i]['recipients'] = json.data[i]['vout'].length;
}*/
return json.data;
}
},
rowCallback: function (row, data, index) {
var flagBlock = '';
if (data['country_code'].length > 1) {
flagBlock = '&nbsp;<div class="flag-icon flag-icon-'+data['country_code'].toLowerCase()+'"></div>';
}
$("td:eq(0)", row).html(data['address']);
$("td:eq(1)", row).html(data['protocol']);
$("td:eq(2)", row).html(data['version']);
$("td:eq(3)", row).html(data['country']+flagBlock);
},
columns: [
{ data: 'address', width: '25%' },
{ data: 'protocol', width: '25%' },