Skip to content
This repository was archived by the owner on Jun 16, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion localserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var middlewareLayers = [express.static(fileSystem.resolve('src')),
require('./server_modules/cors').middleware,
require('./server_modules/cache').middleware,
require('./server_modules/body_builder').middleware,
require('./server_modules/log').middleware];
require('./server_modules/log').middleware,
require('./server_modules/address').middleware];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to place the closing bracket on its own line, to prevent unnecessary changes to the last line (e.g. how the log line is now changed).


var routers = [views,
fileSystem,
Expand Down
20 changes: 20 additions & 0 deletions server_modules/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var os = require('os');
var args = require('./args')

//shamelessly copied from StackOverflow with only minor changes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is simple code, copying stuff without a clear license may conflict with the license of this project.

var interfaces = os.networkInterfaces();
var serverAddress = "";
for (var i in interfaces) {
for (var j in interfaces[i]) {
var address = interfaces[i][j];//we basically parse over all the addresses for every network interface
if (address.family === 'IPv4' && !address.internal) {//if that address is an IPv4 address, and it is not an internal one, that's the address we are looking for
serverAddress = address.address;
break;
}
}
}

exports.middleware = function (req, res, next) {
req.session.serverAddress = serverAddress + ':' + args.port;
next();
};
2 changes: 2 additions & 0 deletions src/css/elements.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ table {
box-shadow: 0 2px 5px rgba(0,0,0,0.26);
}
.drawer .drawerLead {
text-align: center;
color: darkblue;
/*height: 156px;*/
height: 64px;
/*background-color: red;*/
Expand Down
2 changes: 2 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ define([
$scope.drawerVisible = false;

session.onload(function() {
$scope.serverAddress = session.get('serverAddress');

$scope.user = session.get('user');
if($scope.user === 'admin') {
$scope.pages = [
Expand Down
18 changes: 9 additions & 9 deletions src/views/drawer.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="drawer" ng-class="{visible:drawerVisible}">
<div class="drawerLead">
</div>
<ul class="nav">
<li ng-repeat="page in pages" ng-class="{active: currentPage === page}">
<a ng-click="setPage(page)"><i class="material-icons">{{page.icon}}</i> <span>{{page.title}}</span></a>
</li>
</ul>
</div>
<div class="drawer" ng-class="{visible:drawerVisible}">
<div class="drawerLead">
address: {{serverAddress}}</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong indentation: the text should be indented, the closing tag on its own line.

<ul class="nav">
<li ng-repeat="page in pages" ng-class="{active: currentPage === page}">
<a ng-click="setPage(page)"><i class="material-icons">{{page.icon}}</i> <span>{{page.title}}</span></a>
</li>
</ul>
</div>