diff --git a/server_manager/model/server.ts b/server_manager/model/server.ts index 381649f61a..49edaa5af3 100644 --- a/server_manager/model/server.ts +++ b/server_manager/model/server.ts @@ -39,8 +39,8 @@ export interface Server { // Returns stats for bytes transferred across all access keys of this server. getDataUsage(): Promise; - // Returns tunnel time by location - getTunnelTimeByLocation(): Promise; + // Returns server metrics + getServerMetrics(): Promise; // Adds a new access key to this server. addAccessKey(): Promise; @@ -197,11 +197,25 @@ export interface DataLimit { readonly bytes: number; } -export type TunnelTimeSecondsByLocation = { - location: string; - asn: number; - asorg: string; - tunnel_time: { - seconds: number; - }; -}[]; +export type ServerMetricsJson = { + servers: { + location: string; + asn: number; + asOrg: string; + tunnelTime: { + seconds: number; + }; + dataTransferred: { + bytes: number; + }; + }[]; + accessKeys: { + accessKeyId: number; + tunnelTime: { + seconds: number; + }; + dataTransferred: { + bytes: number; + }; + }[]; +}; diff --git a/server_manager/www/app.ts b/server_manager/www/app.ts index f834b708fa..7c71925a1e 100644 --- a/server_manager/www/app.ts +++ b/server_manager/www/app.ts @@ -1079,12 +1079,12 @@ export class App { selectedServer: server_model.Server, serverView: ServerView ) { - const tunnelTimeByLocation = await selectedServer.getTunnelTimeByLocation(); + const serverMetrics = await selectedServer.getServerMetrics(); let sum = 0; for (const { - tunnel_time: {seconds}, - } of tunnelTimeByLocation) { + tunnelTime: {seconds}, + } of serverMetrics.servers) { sum += seconds / (60 * 60); } diff --git a/server_manager/www/shadowbox_server.ts b/server_manager/www/shadowbox_server.ts index 47a65c1064..7fd391ca56 100644 --- a/server_manager/www/shadowbox_server.ts +++ b/server_manager/www/shadowbox_server.ts @@ -161,26 +161,54 @@ export class ShadowboxServer implements server.Server { return usageMap; } - async getTunnelTimeByLocation(): Promise { + async getServerMetrics(): Promise { //TODO - return [ - { - location: 'CA', - asn: 1, - asorg: 'IDK', - tunnel_time: { - seconds: 10000, + return { + servers: [ + { + location: 'CA', + asn: 1, + asOrg: 'IDK', + tunnelTime: { + seconds: 10000, + }, + dataTransferred: { + bytes: 10000, + }, }, - }, - { - location: 'US', - asn: 2, - asorg: 'WHATEVER', - tunnel_time: { - seconds: 200000, + { + location: 'US', + asn: 2, + asOrg: 'WHATEVER', + tunnelTime: { + seconds: 200000, + }, + dataTransferred: { + bytes: 200000, + }, }, - }, - ]; + ], + accessKeys: [ + { + accessKeyId: 0, + tunnelTime: { + seconds: 10000, + }, + dataTransferred: { + bytes: 10000, + }, + }, + { + accessKeyId: 1, + tunnelTime: { + seconds: 200000, + }, + dataTransferred: { + bytes: 200000, + }, + }, + ], + }; } getName(): string { diff --git a/server_manager/www/testing/models.ts b/server_manager/www/testing/models.ts index b29513d480..b47ecfc692 100644 --- a/server_manager/www/testing/models.ts +++ b/server_manager/www/testing/models.ts @@ -168,8 +168,33 @@ export class FakeServer implements server.Server { getDataUsage() { return Promise.resolve(new Map()); } - getTunnelTimeByLocation() { - return Promise.resolve([]); + getServerMetrics() { + return Promise.resolve({ + servers: [ + { + location: '', + asn: 0, + asOrg: '', + tunnelTime: { + seconds: 0, + }, + dataTransferred: { + bytes: 0, + }, + }, + ], + accessKeys: [ + { + accessKeyId: 0, + tunnelTime: { + seconds: 0, + }, + dataTransferred: { + bytes: 0, + }, + }, + ], + }); } addAccessKey() { const accessKey = {