Skip to content
This repository was archived by the owner on Sep 15, 2021. 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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ git push origin my-changes-heroku
# https://heroku.com/deploy?template=https://github.com/my-github-user/simulator/tree/my-changes-heroku
```

#### Updating Data-Flow Dependencies (habanero)

Since [data flow](https://www.npmjs.com/package/node-red-habanero) is a seperate application, to obtain updates from that repository, you can run the following commands to force a rebuild,
replacing `my-changes-heroku` with the branch of the simulator you are using.

```sh
heroku config:set NODE_MODULES_CACHE=false
git commit -am 'disable node_modules cache force rebuild' --allow-empty
git push heroku my-changes-heroku:master --force
```

### Developer Scripts

There are a handful of npm scripts to aid in development.
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"xively:test",
"heroku-postgresql:hobby-dev",
"heroku-redis:hobby-dev",
"cloudinary:starter"
"herokuconnect:demo"
],
"scripts": {
"postdeploy": "npm run provision"
Expand Down
4 changes: 2 additions & 2 deletions client/app/common/devices.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function devicesFactory ($log, $http, $q, mqttService, blueprintService, timeser
/**
* Get devices from Blueprint and subscribe for MQTT updates
* @return {Promise}
*/
*/
getDevices () {
return blueprintService.getV1('devices', { pageSize: 100 })
return blueprintService.getV1('devices', { pageSize: 1000 })
.then((response) => response.data.devices.results)
.then((devices) => {
devices.forEach((device) => this.addDevice(device))
Expand Down
12 changes: 10 additions & 2 deletions client/app/devices/device-demo.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function deviceDemoRoute ($stateProvider) {
</select>
</div>
</div>
<div class="device-container" style="width: {{ ::demo.config.width }}px" ng-if="demo.config.image">
<div class="device-container" style="width: {{ ::demo.config.width }}px; height: {{ ::demo.config.height }}px" ng-if="demo.config.image">
<div ng-repeat="(name, sensor) in ::demo.config.sensors">
<tooltip ng-if="sensor.tooltip"
options="sensor"
Expand Down Expand Up @@ -174,11 +174,19 @@ function deviceDemoRoute ($stateProvider) {
return fieldName.toLowerCase()
})

this.sensorsNotConfigured = _.pullAll(Object.keys(device.sensors), Object.keys(this.config.sensors || {}))
this.sensorsNotConfigured = _.reduce(device.sensors, (sensors, sensor, name) => {
const configured = this.config.sensors && this.config.sensors[name] && (this.config.sensors[name].tooltip || this.config.sensors[name].widget)
if (!configured) {
sensors.push(name)
}
return sensors
}, [])

this.sensors = this.sensorsNotConfigured.reduce((sensors, key) => {
sensors[key] = 50
return sensors
}, {})

$scope.$watch(() => device.sensors, (sensors) => {
_.forEach(sensors, (sensor, name) => { this.sensors[name] = sensor.numericValue })
}, true)
Expand Down
10 changes: 6 additions & 4 deletions client/app/devices/device-demo.route.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import '../style/variables.less';

@width: 680px;
@row-height: 30px;
@border: 2px solid @light-gray;
@navigation-height: 70px;
Expand Down Expand Up @@ -173,11 +172,14 @@

.device-container {
position: relative;
width: @width;
width: 800px;
margin: 0 auto;

.device-image {
width: 100%;
display: block;
max-width: 100%;
max-height: 800px;
margin: 0 auto;
border-radius: 20px;
user-select: none;
}
Expand All @@ -192,7 +194,7 @@
}

.device-control-sliders {
width: @width;
width: 800px;
margin: 0 auto;
margin-top: 50px;
color: @light-gray;
Expand Down
6 changes: 4 additions & 2 deletions client/app/devices/device-panel.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const devicePanelComponent = {

const EXCLUDED_INFO_FIELDS = ['excludedInfoFields', 'simulate', 'subscribe', 'template', 'update', 'sensors', 'ok', 'channels']
this.device.excludedInfoFields = EXCLUDED_INFO_FIELDS
.concat(DEVICES_CONFIG.excludedDeviceInfoFields, this.config.excludedDeviceInfoFields)
.concat(DEVICES_CONFIG.general.excludedDeviceInfoFields, this.config.excludedDeviceInfoFields)
.filter(Boolean)
.map((fieldName) => {
return fieldName.toLowerCase()
Expand Down Expand Up @@ -141,7 +141,9 @@ const devicePanelComponent = {

this.cancelInfoFieldsEditing = () => {
this.editingInfoFields = false
this.device = deviceCopy
Object.keys(this.device).forEach((key) => {
this.device[key] = deviceCopy[key]
})
}

this.updateInfoFields = () => {
Expand Down
2 changes: 1 addition & 1 deletion client/app/devices/share-modal.component.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.share-modal {
position: absolute;
max-width: 400px;
height: 450px;
height: 480px;
top: 70px;
left: 0;
right: 0;
Expand Down
2 changes: 1 addition & 1 deletion client/app/devices/tooltip.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const tooltipComponent = {
controllerAs: 'tooltip',
/* @ngInject */
controller ($element, $rootScope, $scope, socketService, EVENTS) {
Object.assign(this.options, this.options.tooltip)
Object.assign(this.options, { direction: 'top', distance: 100 }, this.options.tooltip)

$scope.$watch(() => {
return this.value
Expand Down
2 changes: 1 addition & 1 deletion client/app/settings/device-config.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const deviceConfig = {
let tooltipOrWidget
if (this.config.sensors[sensor.text].widget) {
tooltipOrWidget = 'widget'
} else if (this.config.sensors[sensor.text].tooltip) {
} else if (this.config.sensors[sensor.text].tooltip || (sensor.top && sensor.left)) {
tooltipOrWidget = 'tooltip'
}
if (tooltipOrWidget) {
Expand Down
19 changes: 12 additions & 7 deletions client/app/settings/image-upload.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const imageUploadComponent = {
ngf-select ngf-drop
ngf-drag-over-class="{pattern: 'image/*', accept:'accept', reject:'reject', delay:100}"
ngf-accept="'image/*'" accept="image/*">
Select or Drop Image
<span>Click to select or Drop Image</span>
<img ng-show="imageUpload.newFile" ngf-src="imageUpload.newFile"/>
</div>
<div class="buttons">
<button class="button" ng-disabled="!imageUpload.newFile" ng-click="imageUpload.uploadImage()">Upload</button>
Expand Down Expand Up @@ -49,12 +50,16 @@ const imageUploadComponent = {
}

this.uploadImage = () => {
Upload.base64DataUrl(this.newFile)
.then(settingsService.uploadImage)
.then((response) => {
this.image = response.imageUrl
this.closeModal()
})
Upload.upload({
url: '/api/images',
data: {
file: this.newFile
}
})
.then((response) => {
this.image = response.data.imageUrl
this.closeModal()
})
}

this.applyImage = () => {
Expand Down
13 changes: 13 additions & 0 deletions client/app/settings/image-upload.component.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ image-upload {
}

.drop-box {
position: relative;
background: #F8F8F8;
border: 2px dashed #DDD;
width: 170px;
text-align: center;
padding: 50px 10px;
margin: 10px auto;
cursor: pointer;
overflow: hidden;

&.accept {
border-color: @navy-blue;
Expand All @@ -52,6 +54,17 @@ image-upload {
&.reject {
border-color: @error-color;
}

img {
position: absolute;
max-width: 100%;
max-height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
}

.input-field {
Expand Down
13 changes: 0 additions & 13 deletions client/app/settings/settings.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ function settingsFactory ($log, $http, utils) {
$log.error('settingsService#getOriginalDeviceConfig error:', err)
throw err
})
},

uploadImage (deviceImage) {
return $http({
method: 'POST',
url: '/api/upload',
data: { deviceImage }
})
.then((res) => res.data || {})
.catch((err) => {
$log.error('settingsService#uploadImage error:', err)
throw err
})
}
}

Expand Down
60 changes: 0 additions & 60 deletions config/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,66 +379,6 @@ const config = {
}
}
},
Jacket: {
image: '/devices/images/jacket.png',
width: 510,
sensors: {
core: {
min: 50,
max: 100,
wiggle: true,
unit: '°F',
tooltip: {
position: {
left: 256,
top: 475
},
labelPosition: {
top: 12,
left: -20
},
distance: 100,
direction: 'top'
}
},
'left-arm': {
min: 50,
max: 100,
wiggle: true,
unit: '°F',
tooltip: {
position: {
top: 400,
left: 60
},
labelPosition: {
top: 12,
left: -20
},
distance: 100,
direction: 'top'
}
},
'right-arm': {
min: 50,
max: 100,
wiggle: true,
unit: '°F',
tooltip: {
position: {
top: 400,
left: 445
},
labelPosition: {
top: 12,
left: -20
},
distance: 100,
direction: 'top'
}
}
}
},
'Solar Panel': {
image: '/devices/images/solar-panel.png',
width: 790,
Expand Down
42 changes: 2 additions & 40 deletions config/provision.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const map = require('./map')
const NAMES = {
HOME_ORG_TEMPLATE: 'Home',
HOME_AIR_PUTIFIER: 'Home Air Purifier',
JACKET: 'Jacket',
SOLAR_PANEL: 'Solar Panel',
HOME_USER: 'Home User',
WAREHOUSE_ORG_TEMPLATE: 'Warehouse',
Expand All @@ -23,7 +22,6 @@ const NAMES = {
const DEVICES_PER_ORGANIZATION = {
HOME_AIR_PUTIFIER: 3,
INDUSTRIAL_HVAC: 10,
JACKET: 1,
SOLAR_PANEL: 1
}

Expand Down Expand Up @@ -78,18 +76,6 @@ const commercialDeviceFields = _.map({
deviceTemplate: NAMES.INDUSTRIAL_HVAC
}))

const jacketDeviceFields = _.map({
hardwareVersion: 'string',
includedSensors: 'string',
color: 'string',
productionRun: 'string',
activatedDate: 'datetime'
}, (fieldType, name) => ({
name,
fieldType,
deviceTemplate: NAMES.JACKET
}))

const solarPanelDeviceFields = _.map({
hardwareVersion: 'string',
includedSensors: 'string',
Expand Down Expand Up @@ -137,18 +123,6 @@ const commercialDeviceChannels = _.map({
deviceTemplate: NAMES.INDUSTRIAL_HVAC
}))

const jacketDeviceChannels = _.map({
control: 'simple',
core: 'timeSeries',
'left-arm': 'timeSeries',
'right-arm': 'timeSeries'
}, (persistenceType, name) => ({
name,
persistenceType,
entityType: 'deviceTemplate',
deviceTemplate: NAMES.JACKET
}))

const solarPanelDeviceChannels = _.map({
control: 'simple',
power: 'timeSeries',
Expand Down Expand Up @@ -217,16 +191,6 @@ const rawDevices = [{
filterType: 'carbonHEPA'
})
}
}, {
name: NAMES.JACKET,
count: DEVICES_PER_ORGANIZATION.JACKET,
organizations: homeOrganizations,
generate: (options) => {
const generic = generateGenericDevice(Object.assign({ templateName: 'JACKET' }, options || {}))
return _.merge(generic, {
includedSensors: 'Core, Left arm, Right arm'
})
}
}, {
name: NAMES.INDUSTRIAL_HVAC,
count: DEVICES_PER_ORGANIZATION.INDUSTRIAL_HVAC,
Expand Down Expand Up @@ -292,8 +256,6 @@ const config = {
name: NAMES.HOME_AIR_PUTIFIER
}, {
name: NAMES.INDUSTRIAL_HVAC
}, {
name: NAMES.JACKET
}, {
name: NAMES.SOLAR_PANEL
}],
Expand All @@ -305,8 +267,8 @@ const config = {
name: NAMES.COMMERCIAL_SERVICE_TECHNICIAN
}],
organizations: [].concat(homeOrganizations).concat(warehouseOrganizations).concat(factoryOrganizations),
deviceFields: [].concat(homeDeviceFields).concat(commercialDeviceFields).concat(jacketDeviceFields).concat(solarPanelDeviceFields),
channelTemplates: [].concat(homeDeviceChannels).concat(commercialDeviceChannels).concat(jacketDeviceChannels).concat(solarPanelDeviceChannels),
deviceFields: [].concat(homeDeviceFields).concat(commercialDeviceFields).concat(solarPanelDeviceFields),
channelTemplates: [].concat(homeDeviceChannels).concat(commercialDeviceChannels).concat(solarPanelDeviceChannels),
devices: _.flattenDeep(_.map(rawDevices, (rawDevice) => {
return _.map(rawDevice.organizations, (organization, orgIdx) => {
return _.times(rawDevice.count, (idx) => rawDevice.generate({ idx, organization, orgIdx }))
Expand Down
Loading