Commit f7ed3aab authored by Miguel Tavares's avatar Miguel Tavares
Browse files

app updated, as like README

parent 05de8798

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -13,7 +13,7 @@ RUN chmod +x entrypoint.sh
EXPOSE 4201
LABEL vf-OS=true
LABEL vf-OS.frontendUri=/efpfhtmlapp/
LABEL vf-OS.frontendUri=/efpfaccelerometerapp/
LABEL vf-OS.icon=img/2.png
LABEL vf-OS.urlprefixReplace=true
LABEL vf-OS.compose.0.depends_on.0="rabbitmq"
......
......@@ -13,24 +13,70 @@ This application is a sample that aims to show that is possible to develop an ap
```
{
"data": [
"{\"timestamp\":\"2022-06-01T15:41:12.762Z\",\"temperature\":41}",
"{\"timestamp\":\"2022-06-01T15:42:12.793Z\",\"temperature\":36}",
"{\"timestamp\":\"2022-06-01T15:43:12.806Z\",\"temperature\":21}",
"{\"timestamp\":\"2022-06-01T15:44:12.832Z\",\"temperature\":59}",
"{\"timestamp\":\"2022-06-01T15:45:12.863Z\",\"temperature\":57}",
"{\"timestamp\":\"2022-06-01T15:46:12.865Z\",\"temperature\":46}",
"{\"timestamp\":\"2022-06-01T15:47:12.889Z\",\"temperature\":43}",
"{\"timestamp\":\"2022-06-01T15:48:12.894Z\",\"temperature\":30}",
"{\"timestamp\":\"2022-06-01T15:49:12.924Z\",\"temperature\":29}",
"{\"timestamp\":\"2022-06-01T15:50:12.932Z\",\"temperature\":45}",
"{\"timestamp\":\"2022-06-01T15:51:12.958Z\",\"temperature\":29}",
"{\"timestamp\":\"2022-06-01T15:52:12.973Z\",\"temperature\":46}",
"{\"timestamp\":\"2022-06-01T15:53:12.975Z\",\"temperature\":34}",
"{\"timestamp\":\"2022-06-01T15:54:12.977Z\",\"temperature\":48}",
"{\"timestamp\":\"2022-06-01T15:55:12.979Z\",\"temperature\":27}",
"{\"timestamp\":\"2022-06-01T15:56:12.981Z\",\"temperature\":20}",
"{\"timestamp\":\"2022-06-01T15:57:12.983Z\",\"temperature\":39}"
]
"list_of_rows":[
{
"name":"x",
"series":[
{
"value":371,
"name":"2022-06-30T09:22:41.050Z"
},
{
"value":399,
"name":"2022-06-30T09:24:41.054Z"
},
{
"value":362,
"name":"2022-06-30T09:29:24.765Z"
},
{
"value":300,
"name":"2022-06-30T09:31:24.783Z"
}
]
},
{
"name":"y",
"series":[
{
"value":238,
"name":"2022-06-30T09:22:41.050Z"
},
{
"value":274,
"name":"2022-06-30T09:24:41.054Z"
},
{
"value":249,
"name":"2022-06-30T09:29:24.765Z"
},
{
"value":315,
"name":"2022-06-30T09:31:24.783Z"
}
]
},
{
"name":"z",
"series":[
{
"value":386,
"name":"2022-06-30T09:22:41.050Z"
},
{
"value":119,
"name":"2022-06-30T09:24:41.054Z"
},
{
"value":183,
"name":"2022-06-30T09:29:24.765Z"
},
{
"value":178,
"name":"2022-06-30T09:31:24.783Z"
}
]
}
]
}
```
......@@ -8,7 +8,7 @@ amqp = require('amqplib');
* Enable the logging of messages to the console
* Disable in production!
*/
const DEBUG = false;
const DEBUG = true;
/*
* Logging function
......@@ -54,8 +54,8 @@ function createChannel(connection){
* - To send or publishing messages
* - To receive or consume messages
*/
function connect(commObj, config) {
return commObj.loginPromise = amqp.connect(config)
function connect(commObj, server) {
return commObj.loginPromise = amqp.connect(server)
.then(function(conn){
process.once('SIGINT', function() {
logDebug("Closing AMQP connection");
......@@ -241,7 +241,7 @@ function processMessage(msg){
* vfosMessagingPubsub Class
*
*/
class vfosMessagingPubsub {
class vfosMessagingPubsub{
/*
* Class constructor
......@@ -250,7 +250,7 @@ class vfosMessagingPubsub {
* Login
* Register
*/
constructor(server='localhost', username='guest', password='guest', keys=["#"], vhost='eu.vfos', ssl=false) {
constructor(server='localhost', username='guest', password='guest', keys=["#"], vhost=null, ssl=false) {
this.protocol = ssl ? 'amqps' : 'amqp';
this.username = username;
this.server = server;
......@@ -275,12 +275,7 @@ class vfosMessagingPubsub {
var messagingChannel, pubsubChannel, announcementChannel;
// Login and register automatically when creating an instance
Promise.all([
this.login(this.protocol, server, this.prefix, username, password).catch(e => e),
this.register(keys).catch(e => e),
this.messageRegistration().catch(e => e),
this.pubSubRegistration(keys).catch(e => e)
])
Promise.all([this.login(this.username, password).catch(e => e), this.register(keys).catch(e => e), this.messageRegistration().catch(e => e), this.pubSubRegistration(keys).catch(e => e)])
.catch(function(err){
errLog(err);
})
......@@ -315,9 +310,12 @@ class vfosMessagingPubsub {
* Create one input and one output channels
* Send a notification to the system
*/
login(protocol, hostname, vhost, username, password){
login(username, password){
let commObj = this;
return connect(commObj, { protocol: protocol, hostname: hostname, username: username, password: password, vhost: vhost })
return connect(commObj, {
protocol: this.protocol, hostname: this.server, username: this.username, password:
password, vhost: (this.prefix == '' || this.prefix == null) ? null : this.prefix
})
.then(function(){
logDebug("Logged in to the Messaging/PubSub system as " + commObj.username);
commObj.sendPublicationAnnouncement("login", "");
......
# path
This is an exact copy of the NodeJS ’path’ module published to the NPM registry.
[Documentation](http://nodejs.org/docs/latest/api/path.html)
## Install
```sh
$ npm install --save path
```
## License
MIT
{
"_from": "path@^0.12.7",
"_id": "path@0.12.7",
"_inBundle": false,
"_integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"_location": "/path",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "path@^0.12.7",
"name": "path",
"escapedName": "path",
"rawSpec": "^0.12.7",
"saveSpec": null,
"fetchSpec": "^0.12.7"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"_shasum": "d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f",
"_spec": "path@^0.12.7",
"_where": "/projects/efpfhtmlapp/bin/libs/vfos-sdk/components/vfos-messaging",
"author": {
"name": "Joyent",
"url": "http://www.joyent.com"
},
"bugs": {
"url": "https://github.com/jinder/path/issues"
},
"bundleDependencies": false,
"dependencies": {
"process": "^0.11.1",
"util": "^0.10.3"
},
"deprecated": false,
"description": "Node.JS path module",
"homepage": "http://nodejs.org/docs/latest/api/path.html",
"keywords": [
"ender",
"path"
],
"license": "MIT",
"main": "./path.js",
"name": "path",
"repository": {
"type": "git",
"url": "git://github.com/jinder/path.git"
},
"version": "0.12.7"
}
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
var isWindows = process.platform === 'win32';
var util = require('util');
// resolves . and .. elements in a path array with directory names there
// must be no slashes or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
var res = [];
for (var i = 0; i < parts.length; i++) {
var p = parts[i];
// ignore empty parts
if (!p || p === '.')
continue;
if (p === '..') {
if (res.length && res[res.length - 1] !== '..') {
res.pop();
} else if (allowAboveRoot) {
res.push('..');
}
} else {
res.push(p);
}
}
return res;
}
// returns an array with empty elements removed from either end of the input
// array or the original array if no elements need to be removed
function trimArray(arr) {
var lastIndex = arr.length - 1;
var start = 0;
for (; start <= lastIndex; start++) {
if (arr[start])
break;
}
var end = lastIndex;
for (; end >= 0; end--) {
if (arr[end])
break;
}
if (start === 0 && end === lastIndex)
return arr;
if (start > end)
return [];
return arr.slice(start, end + 1);
}
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
var win32 = {};
// Function to split a filename into [root, dir, basename, ext]
function win32SplitPath(filename) {
// Separate device+slash from tail
var result = splitDeviceRe.exec(filename),
device = (result[1] || '') + (result[2] || ''),
tail = result[3] || '';
// Split the tail into dir, basename and extension
var result2 = splitTailRe.exec(tail),
dir = result2[1],
basename = result2[2],
ext = result2[3];
return [device, dir, basename, ext];
}
function win32StatPath(path) {
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = !!device && device[1] !== ':';
return {
device: device,
isUnc: isUnc,
isAbsolute: isUnc || !!result[2], // UNC paths are always absolute
tail: result[3]
};
}
function normalizeUNCRoot(device) {
return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\');
}
// path.resolve([from ...], to)
win32.resolve = function() {
var resolvedDevice = '',
resolvedTail = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path;
if (i >= 0) {
path = arguments[i];
} else if (!resolvedDevice) {
path = process.cwd();
} else {
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive. We're sure the device is not
// an unc path at this points, because unc paths are always absolute.
path = process.env['=' + resolvedDevice];
// Verify that a drive-local cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
if (!path || path.substr(0, 3).toLowerCase() !==
resolvedDevice.toLowerCase() + '\\') {
path = resolvedDevice + '\\';
}
}
// Skip empty and invalid entries
if (!util.isString(path)) {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
var result = win32StatPath(path),
device = result.device,
isUnc = result.isUnc,
isAbsolute = result.isAbsolute,
tail = result.tail;
if (device &&
resolvedDevice &&
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
// This path points to another device so it is not applicable
continue;
}
if (!resolvedDevice) {
resolvedDevice = device;
}
if (!resolvedAbsolute) {
resolvedTail = tail + '\\' + resolvedTail;
resolvedAbsolute = isAbsolute;
}
if (resolvedDevice && resolvedAbsolute) {
break;
}
}
// Convert slashes to backslashes when `resolvedDevice` points to an UNC
// root. Also squash multiple slashes into a single one where appropriate.
if (isUnc) {
resolvedDevice = normalizeUNCRoot(resolvedDevice);
}
// At this point the path should be resolved to a full absolute path,
// but handle relative paths to be safe (might happen when process.cwd()
// fails)
// Normalize the tail path
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/),
!resolvedAbsolute).join('\\');
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
'.';
};
win32.normalize = function(path) {
var result = win32StatPath(path),
device = result.device,
isUnc = result.isUnc,
isAbsolute = result.isAbsolute,
tail = result.tail,
trailingSlash = /[\\\/]$/.test(tail);
// Normalize the tail path
tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\');
if (!tail && !isAbsolute) {
tail = '.';
}
if (tail && trailingSlash) {
tail += '\\';
}
// Convert slashes to backslashes when `device` points to an UNC root.
// Also squash multiple slashes into a single one where appropriate.
if (isUnc) {
device = normalizeUNCRoot(device);
}
return device + (isAbsolute ? '\\' : '') + tail;
};
win32.isAbsolute = function(path) {
return win32StatPath(path).isAbsolute;
};
win32.join = function() {
var paths = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!util.isString(arg)) {
throw new TypeError('Arguments to path.join must be strings');
}
if (arg) {
paths.push(arg);
}
}
var joined = paths.join('\\');
// Make sure that the joined path doesn't start with two slashes, because
// normalize() will mistake it for an UNC path then.
//
// This step is skipped when it is very clear that the user actually
// intended to point at an UNC path. This is assumed when the first
// non-empty string arguments starts with exactly two slashes followed by
// at least one more non-slash character.
//
// Note that for normalize() to treat a path as an UNC path it needs to
// have at least 2 components, so we don't filter for that here.
// This means that the user can use join to construct UNC paths from
// a server name and a share name; for example:
// path.join('//server', 'share') -> '\\\\server\\share\')
if (!/^[\\\/]{2}[^\\\/]/.test(paths[0])) {
joined = joined.replace(/^[\\\/]{2,}/, '\\');
}
return win32.normalize(joined);
};
// path.relative(from, to)
// it will solve the relative path from 'from' to 'to', for instance:
// from = 'C:\\orandea\\test\\aaa'
// to = 'C:\\orandea\\impl\\bbb'
// The output of the function should be: '..\\..\\impl\\bbb'
win32.relative = function(from, to) {
from = win32.resolve(from);
to = win32.resolve(to);
// windows is not case sensitive
var lowerFrom = from.toLowerCase();
var lowerTo = to.toLowerCase();
var toParts = trimArray(to.split('\\'));
var lowerFromParts = trimArray(lowerFrom.split('\\'));
var lowerToParts = trimArray(lowerTo.split('\\'));
var length = Math.min(lowerFromParts.length, lowerToParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (lowerFromParts[i] !== lowerToParts[i]) {
samePartsLength = i;
break;
}
}
if (samePartsLength == 0) {
return to;
}
var outputParts = [];
for (var i = samePartsLength; i < lowerFromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('\\');
};
win32._makeLong = function(path) {
// Note: this will *probably* throw somewhere.
if (!util.isString(path))
return path;
if (!path) {
return '';
}
var resolvedPath = win32.resolve(path);
if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
// path is local filesystem path, which needs to be converted
// to long UNC path.
return '\\\\?\\' + resolvedPath;
} else if (/^\\\\[^?.]/.test(resolvedPath)) {
// path is network UNC path, which needs to be converted
// to long UNC path.
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
}
return path;
};
win32.dirname = function(path) {
var result = win32SplitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;