Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Nest #82

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Nest #82

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
70d0ed0
feat(demo): add height support
May 25, 2016
46cd53b
feat(settings): image upload preview
May 25, 2016
e9ac662
feat(image): store images in database
May 25, 2016
df907a1
fix(fields): fix excluded device info fields
May 25, 2016
439807e
fix(settings): persist changes
May 26, 2016
904f701
fix(tooltip): default direction and distance
May 26, 2016
3b52946
fix(salesforce): update assets and contacts on startup
May 26, 2016
17ce4cf
fix(mobile): cancelling edit on info fields no longer breaks app
May 27, 2016
ee7643f
fix(share): increase modal height
May 27, 2016
0a686d0
fix(device): fix device image height
May 27, 2016
387b51c
feat(app): remove jacket
May 27, 2016
1d746bc
docs for updating habanero dependency
mattotodd May 31, 2016
1a91fec
Build
May 31, 2016
4b36e25
feat(app.json): add heroku connect plugin
Jun 10, 2016
f8c7a5f
Nest initial commit (provision, login)
nborics Jun 22, 2016
1ad79c1
Modified nest widget
nborics Jun 22, 2016
3a12a42
Added missing firebas cdn
nborics Jun 23, 2016
c4f1592
Added lock and refactored nest code.
nborics Jun 23, 2016
3ed2aab
nest PIN auth sequence added
milgra Jun 24, 2016
898fbee
Added away channel
t44k Jun 24, 2016
22a576c
Merge branch 'nest' of github.com:Golyo88/simulator into nest
t44k Jun 24, 2016
fbd39d6
Subscribe and UI changes.
nborics Jun 27, 2016
1f214d3
Added new nest-display widget
t44k Jun 27, 2016
e5eaf82
Added event emitter part
nborics Jun 27, 2016
2dc5c0c
Added image swapping functionality
nborics Jun 27, 2016
1910b6c
UI changes added todo inline
nborics Jun 28, 2016
f73fdf0
Fixed eslint
nborics Jun 28, 2016
cd46097
Removed lock channel
nborics Jun 28, 2016
b08f1d3
Sending away status to NEST
t44k Jun 29, 2016
734b6f0
Rename nest simulator to Door Lock
t44k Jun 30, 2016
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
14 changes: 11 additions & 3 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 All @@ -122,7 +122,7 @@ function deviceDemoRoute ($stateProvider) {
</tooltip>
<div ng-if="sensor.widget" bind-html-compile="demo.getHtml(sensor.widget)"></div>
</div>
<img class="device-image" src="{{ demo.config.image }}" />
<img class="device-image" ng-src="{{ demo.config.image }}" />
</div>
<div class="no-image" ng-if="!demo.config.image">
<h2>No image available</h2>
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
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>simulator</title>
<script src="/script/config.js" charset="utf-8"></script>
<script src="//vmss.boldchat.com/aid/461159850398350203/bc.vms4/vms.js" charset="utf-8" async="true"></script>
<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
</head>
<body>
<navigation-bar></navigation-bar>
Expand Down
82 changes: 21 additions & 61 deletions config/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const filterRule = (latestValue, sensors) => {

const config = {
general: {
hiddenChannels: ['sensor', 'control'],
hiddenChannels: ['sensor', 'control', 'lock', 'token'],
excludedDeviceInfoFields: [
'Created',
'CreatedById',
Expand Down 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 Expand Up @@ -516,6 +456,26 @@ const config = {
}
}
}
},
'Door Lock': {
image: '/devices/images/smartlock-design_locked.png',
width: 800,
defaultSensor: 'state',
widgets: ['nest'],
sensors: {
state: {
widget: {
name: 'nest-display',
position: {
top: 450,
left: 400
}
},
min: 0,
max: 1,
wiggle: true
}
}
}
}

Expand Down
Binary file added config/devices/images/smartlock-design_locked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added config/devices/images/smartlock-design_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions config/devices/widgets/nest-display/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nestDisplayComponent = require('./nest-display.component.js')

module.exports = nestDisplayComponent
Loading