Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
refactor: relocate metrics dashboard URL into EndpointConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jul 5, 2019
1 parent 8609c11 commit e510f16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
11 changes: 11 additions & 0 deletions src/EndpointConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export function getMetricsDashboardUrl() {
const matches = window.location.hostname.match('(.*).testnet.solana.com');
let url =
'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now';
if (matches) {
const testnet = matches[1];
url += `&var-testnet=testnet-${testnet}`;
}
return url;
}

let EndpointConfig = {
BLOCK_EXPLORER_API_BASE: `//${window.location.hostname}:3001`,
BLOCK_EXPLORER_RPC_URL: `http://${window.location.hostname}:8899`,
Expand Down
11 changes: 2 additions & 9 deletions src/v1/BxAppBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MapIcon from '@material-ui/icons/Map';
// import AccountCircle from '@material-ui/icons/AccountCircle';
import MoreIcon from '@material-ui/icons/MoreVert';
import Switch from '@material-ui/core/Switch';
import {getMetricsDashboardUrl} from '../EndpointConfig';

class BxAppBar extends React.Component {
state = {
Expand All @@ -23,15 +24,7 @@ class BxAppBar extends React.Component {
};

handleDashboard = event => {
const matches = window.location.hostname.match('(.*).testnet.solana.com');
let url =
'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now';
if (matches) {
const testnet = matches[1];
url += `&var-testnet=testnet-${testnet}`;
}

window.open(url);
window.open(getMetricsDashboardUrl());
};

handleMap = event => {
Expand Down
11 changes: 2 additions & 9 deletions src/v2/Bx2AppBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DashboardIcon from '@material-ui/icons/Dashboard';
import MapIcon from '@material-ui/icons/Map';
import MoreIcon from '@material-ui/icons/MoreVert';
import Switch from '@material-ui/core/Switch';
import {getMetricsDashboardUrl} from '../EndpointConfig';

class Bx2AppBar extends React.Component {
state = {
Expand All @@ -21,15 +22,7 @@ class Bx2AppBar extends React.Component {
};

handleDashboard = event => {
const matches = window.location.hostname.match('(.*).testnet.solana.com');
let url =
'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now';
if (matches) {
const testnet = matches[1];
url += `&var-testnet=testnet-${testnet}`;
}

window.open(url);
window.open(getMetricsDashboardUrl());
};

handleMap = event => {
Expand Down

0 comments on commit e510f16

Please sign in to comment.