Skip to content

Commit

Permalink
Fix #140 by using URL prefix passed in as part of options (#165)
Browse files Browse the repository at this point in the history
* Fix #140 by using URL prefix passed in as part of options

* Update AUTHORS.md
  • Loading branch information
achingbrain authored and tobespc committed Oct 25, 2018
1 parent bfd0ba5 commit c828419
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Authors ordered by first contribution:
- Vajahath Ahmed (https://github.com/vajahath)
- Jonathan Spruce (https://github.com/jonathan-spruce)
- Andreas Opferkuch (https://github.com/s-h-a-d-o-w)
- Alex Potsides (https://github.com/achingbrain)
4 changes: 2 additions & 2 deletions lib/appmetrics-dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ exports.monitor = function(options) {
var app = express();
server = require('http').Server(app);
// Specify a path, to not collide with user's socket.io.
io = require('socket.io')(server, { path: '/appmetrics-dash/socket.io' });
io = require('socket.io')(server, { path: url + '/socket.io' });

app.use(middleware);

Expand All @@ -168,7 +168,7 @@ exports.monitor = function(options) {
// Don't patch socket.io, it already knows to ignore requests that are not
// its own.
debug('listen for socket.io');
io = require('socket.io')(server, { path: '/appmetrics-dash/socket.io' });
io = require('socket.io')(server, { path: url + '/socket.io' });

debug('patch new request listeners...');
server.on('newListener', function(eventName, listener) {
Expand Down
10 changes: 4 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<body>
<!--<h1>Application Metrics Dashboard for Node.js</h1>-->
<!-- load the d3.js library -->
<script src="/appmetrics-dash/socket.io/socket.io.js"></script>
<script src="socket.io/socket.io.js"></script>
<script src="graphmetrics/d3/d3.v3.min.js"></script>
<script src="graphmetrics/jquery/jquery-3.1.1.min.js"></script>
<script src="graphmetrics/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
Expand Down Expand Up @@ -165,12 +165,10 @@ <h4 class="modal-title" font-color=black>Heap Snapshot</h4>
tallerGraphHeight = canvasHeight - margin.top - margin.shortBottom,
graphHeight = canvasHeight - margin.top - margin.bottom;

let hostname = location.host;
let pathname = location.pathname
// User may have requested appmetrics-dash/index.html
let dashboardRoot = "/" + pathname.split('/')[1];
let dashboardRoot = location.pathname.split('index.html')[0] || '/';

var socket = io.connect(hostname, { path: '/appmetrics-dash/socket.io' });
var socket = io.connect(location.host, { path: dashboardRoot + 'socket.io' });

function getTimeFormat() {
var currentTime = new Date()
Expand Down Expand Up @@ -206,7 +204,7 @@ <h4 class="modal-title" font-color=black>Heap Snapshot</h4>
<script>

let summary = {cpu:{}, gc:{}, memoryPools:{}};

let hostname = location.host.split(':')[0];
let envTable = new TextTable('#envDiv', '#summary', localizedStrings.envTitle);
let summaryTable = new TextTable('#summaryDiv', '#summary', localizedStrings.summaryTitle);
let httpSummary = new HttpSummary('#httpSummaryDiv', '#summary', localizedStrings.httpSummaryTitle);
Expand Down

0 comments on commit c828419

Please sign in to comment.