[Node page] Add link to node list per country/isp in node page

This commit is contained in:
nymkappa 2022-07-26 12:26:44 +02:00
parent 65cd708295
commit 6341839de4
No known key found for this signature in database
GPG key ID: E155910B16E8BD04
4 changed files with 24 additions and 4 deletions

View file

@ -5,7 +5,7 @@ class NodesApi {
public async $getNode(public_key: string): Promise<any> { public async $getNode(public_key: string): Promise<any> {
try { try {
const query = ` const query = `
SELECT nodes.*, geo_names_as.names as as_organization, geo_names_city.names as city, SELECT nodes.*, geo_names_iso.names as iso_code, geo_names_as.names as as_organization, geo_names_city.names as city,
geo_names_country.names as country, geo_names_subdivision.names as subdivision, geo_names_country.names as country, geo_names_subdivision.names as subdivision,
(SELECT Count(*) (SELECT Count(*)
FROM channels FROM channels
@ -24,6 +24,7 @@ class NodesApi {
LEFT JOIN geo_names geo_names_city on geo_names_city.id = city_id LEFT JOIN geo_names geo_names_city on geo_names_city.id = city_id
LEFT JOIN geo_names geo_names_subdivision on geo_names_subdivision.id = subdivision_id LEFT JOIN geo_names geo_names_subdivision on geo_names_subdivision.id = subdivision_id
LEFT JOIN geo_names geo_names_country on geo_names_country.id = country_id LEFT JOIN geo_names geo_names_country on geo_names_country.id = country_id
LEFT JOIN geo_names geo_names_iso ON geo_names_iso.id = nodes.country_id AND geo_names_iso.type = 'country_iso_code'
WHERE public_key = ? WHERE public_key = ?
`; `;
const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key]); const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key, public_key]);

View file

@ -43,11 +43,23 @@
</tr> </tr>
<tr *ngIf="node.country && node.city && node.subdivision"> <tr *ngIf="node.country && node.city && node.subdivision">
<td i18n="location">Location</td> <td i18n="location">Location</td>
<td>{{ node.city.en }}, {{ node.subdivision.en }}<br>{{ node.country.en }}</td> <td>
<span>{{ node.city.en }}, {{ node.subdivision.en }}</span>
<br>
<a class="d-flex align-items-center" [routerLink]="['/lightning/nodes/country' | relativeUrl, node.iso_code]">
<span class="link">{{ node.country.en }}</span>
&nbsp;
<span class="flag">{{ node.flag }}</span>
</a>
</td>
</tr> </tr>
<tr *ngIf="node.country && !node.city"> <tr *ngIf="node.country && !node.city">
<td i18n="location">Location</td> <td i18n="location">Location</td>
<td>{{ node.country.en }}</td> <td>
<a [routerLink]="['/lightning/nodes/country' | relativeUrl, node.iso_code]">
{{ node.country.en }} {{ node.flag }}
</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -77,7 +89,9 @@
<tr *ngIf="node.country"> <tr *ngIf="node.country">
<td i18n="isp">ISP</td> <td i18n="isp">ISP</td>
<td> <td>
{{ node.as_organization }} [ASN {{node.as_number}}] <a [routerLink]="['/lightning/nodes/isp' | relativeUrl, node.as_number]">
{{ node.as_organization }} [ASN {{node.as_number}}]
</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -3,6 +3,7 @@ import { ActivatedRoute, ParamMap } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators'; import { catchError, map, switchMap } from 'rxjs/operators';
import { SeoService } from 'src/app/services/seo.service'; import { SeoService } from 'src/app/services/seo.service';
import { getFlagEmoji } from 'src/app/shared/graphs.utils';
import { LightningApiService } from '../lightning-api.service'; import { LightningApiService } from '../lightning-api.service';
@Component({ @Component({
@ -51,6 +52,7 @@ export class NodeComponent implements OnInit {
} else if (socket.indexOf('onion') > -1) { } else if (socket.indexOf('onion') > -1) {
label = 'Tor'; label = 'Tor';
} }
node.flag = getFlagEmoji(node.iso_code);
socketsObject.push({ socketsObject.push({
label: label, label: label,
socket: node.public_key + '@' + socket, socket: node.public_key + '@' + socket,

View file

@ -92,6 +92,9 @@ export function detectWebGL() {
} }
export function getFlagEmoji(countryCode) { export function getFlagEmoji(countryCode) {
if (!countryCode) {
return '';
}
const codePoints = countryCode const codePoints = countryCode
.toUpperCase() .toUpperCase()
.split('') .split('')