”2016-09-06”

This commit is contained in:
Martin Donnelly 2016-09-06 16:45:03 +01:00
parent a2022c5f18
commit f9ab57c2a0
10 changed files with 14946 additions and 56 deletions

View File

@ -1,2 +1,3 @@
node_modules
/sql/
/dist/

View File

@ -75,8 +75,7 @@ app.use(function(req, res, next) {
// Run npm start --production to use dist
var staticDir = isProduction ? 'dist' : 'app';
staticDir = 'app';
var graphFile = isProduction ? 'graph-release' : 'test';
app.use(express.static(path.join(__dirname, staticDir)));
app.use(errorhandler({dumpExceptions: true, showStack: true}));
@ -96,7 +95,7 @@ app.get('/graph', authentication(({
file: 'htpasswd', // Path of file
suppress: true // Suppress throwing Error if wrong user
})), function(req, res) {
res.render('test',{delimiter: '^'});
res.render(graphFile,{delimiter: '^'});
});
app.get('/meeting', function(req, res) {
@ -113,15 +112,6 @@ meetingApi(app);
messageApi(app);
//var mqttClient = require('./lib/mqtt/mqttClient');
var mqtt;
if (isProduction) {
// mqtt = new mqttClient.mqttClient(busEmitter);
}
var port = (process.env.VCAP_APP_PORT || 3011);
var host = (process.env.VCAP_APP_HOST || 'localhost');

View File

@ -1,5 +1,5 @@
{
"name": "Censis Smart Office ",
"name": "Censis MQTT Grapher",
"icons": [
{
"src": "\/fav\/android-chrome-36x36.png",

View File

@ -6,19 +6,8 @@
(function($) {
var GraphView;
var mqttConfig = {
orgId: 'qz0da4',
userName: 'a-qz0da4-dfwwdkmkzr',
appKey: '9txJEf3Cjy7hkSOvkv',
prefix: 'iot-2/type/mDot/id/'
};
var sendAuthentication = function(xhr) {
var user = mqttConfig.userName; // Your actual username
var pass = mqttConfig.appKey; // Your actual password
var token = user.concat(':', pass);
xhr.setRequestHeader('Authorization', ('Basic '.concat(btoa(token))));
};
/*
@ -164,24 +153,8 @@
notification.notify('success', 'Data loaded');
}, decoder: function(data) {
var _obj = {};
// var _data = window.atob(data).split('');
//Var bytes = _data.map(i => i.charCodeAt());
/*
_obj.light = parseInt('0x' + ('0' + bytes[0]).substr(-2) + ('0' + bytes[1]).substr(
-2));
_obj.co2 = parseInt(_data[2] + _data[3] + _data[4] + _data[5] + _data[6],
10);
_obj.temp = (parseInt(_data[7] + _data[8] + _data[9] + _data[10] + _data[11],
10) - 1000) / 10;
_obj.humid = (parseInt(_data[12] + _data[13] + _data[14] + _data[15] + _data[16],
10) / 10);
_obj.noise = parseInt('0x' + ('0' + bytes[17]).substr(-2) + ('0' + bytes[18]).substr(
-2));
_obj.binData = bytes;*/
return _obj;
}, decoder: function() {
return {};
}, dateTime: function($date) {
var dateTime = new Date.create($date);
var date = dateTime.format('{yyyy}-{MM}-{dd}');

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
"backbone": "^1.3.3",
"base64": "^1.0.0",
"notification-js": "^1.1.1",
"amstock3": "^3.20.12"
"amstock3": "^3.20.12",
"requirejs": "^2.3.1"
}
}

View File

@ -28,8 +28,27 @@ gulp.task('appJS', function() {
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('app.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('www/js'));
.pipe(uglify({mangle: true, compress: {sequences: true, // Join consecutive statemets with the “comma operator”
properties: true, // Optimize property access: a["foo"] → a.foo
dead_code: true, // Discard unreachable code
drop_debugger: true, // Discard “debugger” statements
unsafe: false, // Some unsafe optimizations (see below)
conditionals: true, // Optimize if-s and conditional expressions
comparisons: true, // Optimize comparisons
evaluate: true, // Evaluate constant expressions
booleans: true, // Optimize boolean expressions
loops: true, // Optimize loops
unused: true, // Drop unused variables/functions
hoist_funs: true, // Hoist function declarations
hoist_vars: false, // Hoist variable declarations
if_return: true, // Optimize if-s followed by return/continue
join_vars: true, // Join var declarations
cascade: true, // Try to cascade `right` into `left` in sequences
side_effects: true, // Drop side-effect-free statements
warnings: true, // Warn about potentially dangerous optimizations/code
global_defs: {} // global definitions
}}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('vendor', function() {
@ -46,17 +65,17 @@ gulp.task('vendor', function() {
])
.pipe(concat('vendor.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('www/libs'));
.pipe(gulp.dest('dist/js'));
});
gulp.task('styles', function() {
return gulp.src(['src/bower_modules/mui/packages/cdn/css/mui.min.css','app/css/test.css','app/css/style.css','src/bower_modules/notification-js/build/notification.min.js'])
return gulp.src(['src/bower_modules/mui/packages/cdn/css/mui.min.css','app/css/test.css','app/css/style.css','src/bower_modules/notification-js/build/notification.min.css'])
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(cssnano())
.pipe(concat('app.css'))
.pipe(gulp.dest('www/css'));
.pipe(gulp.dest('dist/css'));
});
@ -72,22 +91,23 @@ gulp.task('index', function() {
}))
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true}))
.pipe(gulp.dest('www/'));
.pipe(gulp.dest('dist/'));
});
gulp.task('partials', function() {
gulp.src(['app/partials/**/*']).pipe(gulp.dest('www/partials'));
// gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs'));
gulp.src(['app/fav/**/*']).pipe(gulp.dest('dist/fav'));
gulp.src(['app/lib/images/**/*']).pipe(gulp.dest('dist/amcharts/images'));
// Gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs'));
// gulp.src(['app/libs/microevent.js']).pipe(gulp.dest('dist/libs'));
//gulp.src(['app/fav/**/*']).pipe(size({title: 'Partials'})).pipe(gulp.dest('dist/fav'));
gulp.src(['app/img/logo.png']).pipe(gulp.dest('www/img'));
gulp.src(['app/gfx/**/*']).pipe(gulp.dest('dist/gfx'));
});
gulp.task('copy', function() {
return gulp.src(['app/**/*'])
.pipe(gulp.dest('www'));
.pipe(gulp.dest('dist'));
});
gulp.task('buildJS', function() {
@ -95,7 +115,7 @@ gulp.task('buildJS', function() {
});
gulp.task('clean', function() {
return del(['www']);
return del(['dist']);
});
@ -105,7 +125,7 @@ gulp.task('normal', ['clean'], function() {
});
gulp.task('default', ['clean'], function() {
gulp.start('buildJS','styles','index');
gulp.start('buildJS','styles','index','partials');
});
gulp.task('watch',function() {

View File

@ -78,7 +78,8 @@
},
"scripts": {
"test": "mocha --recursive --reporter spec --bail --check-leaks --timeout 3000",
"start": "node app.js"
"start": "node app.js",
"prepublish" : "gulp default"
},
"author": "Martin Donnelly",
"license": "ISC",

View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Graph</title>
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link href="css/app.css" rel="stylesheet" type="text/css"/>
<link rel="apple-touch-icon" sizes="57x57"
href="/fav/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60"
href="/fav/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72"
href="/fav/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76"
href="/fav/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114"
href="/fav/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120"
href="/fav/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144"
href="/fav/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152"
href="/fav/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180"
href="/fav/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/fav/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/fav/android-chrome-192x192.png"
sizes="192x192">
<link rel="icon" type="image/png" href="/fav/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/fav/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/fav/manifest.json">
<link rel="mask-icon" href="/fav/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/fav/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="/fav/mstile-144x144.png">
<meta name="msapplication-config" content="/fav/browserconfig.xml">
<meta name="theme-color" content="#00aeef">
</head>
<body style="background-color:#171d25" class="mui--no-user-select">
<div class="mui-container">
<div class='mui-row'>
<div class="mui-col-md-3 panel">
<div class='mui-panel' id="main"></div>
<div id="output"></div>
</div>
<div class="mui-col-md-9">
<div class="mui-container">
<div id="chartdiv" style="width:100%; height:600px;"></div>
</div>
</div>
</div>
<script type="text/template" id="loaded-template">
<div
style="background-color: darkred;color: white;font-weight: 900;text-align: center">Loaded
</div>
</script>
<script type="text/template" id="main-template">
<div class="mui-container">
<div class="mui-row">
<div class="mui-select">
<select id="device" name="device">
<option></option>
<option>
HIE-mobile-1
</option>
<option>
HIE-demo
</option>
<option>
HIE-mobile-2
</option>
<option>
HIE-smart-campus-1
</option>
<option>
HIE-smart-campus-2
</option>
<option>
HIE-smart-campus-3
</option>
<option>
HIE-smart-campus-4
</option>
<option>
HIE-smart-campus-5
</option>
<option>
HIE-smart-campus-6
</option>
<option>
HIE-smart-campus-7
</option>
<option>
CENSIS-LoRa-1
</option>
<option>
CENSIS-LoRa-2
</option>
<option>
CENSIS-LoRa-3
</option>
<option>
CENSIS-LoRa-4
</option>
<option>
HIE-mDot-1
</option>
</select> <label>Device</label>
</div>
</div>
</div>
<div class="mui-row">
<div class="mui-col-md-12">
<button id='refresh'
class="mui-btn mui-btn--small mui-btn--primary">Refresh
</button>
</div>
</div>
</script>
<script type="text/template" id="list-template">
<ul></ul>
</script>
<script src="js/vendor.js"></script>
<script src="js/app.js"></script>
</body>
</html>