From ed18b11c6a5e09727c3e13eb0e5000b394aded29 Mon Sep 17 00:00:00 2001 From: NADAL Jean-Baptiste Date: Mon, 9 May 2016 23:08:17 +0200 Subject: [PATCH] Set Light is now functional when clic on a switch button. --- src/ui/Domo/src/components/Light.vue | 14 +---- src/ui/Domo/src/components/Lights.vue | 79 +++++---------------------- 2 files changed, 18 insertions(+), 75 deletions(-) diff --git a/src/ui/Domo/src/components/Light.vue b/src/ui/Domo/src/components/Light.vue index 4ceed585..a4d9e0bc 100644 --- a/src/ui/Domo/src/components/Light.vue +++ b/src/ui/Domo/src/components/Light.vue @@ -5,7 +5,7 @@ {{inlineDesc}}
- +
@@ -27,27 +27,19 @@ export default { } }, props: { - title: { - type: String, - required: true - }, data: {}, disabled: { type: Boolean, default: false }, - value: { - type: Boolean, - twoWay: true - }, inlineDesc: { type: String } }, ready: function () {}, watch: { - value: function (newVal) { - this.$dispatch('on-change', newVal) + 'data.state': function (newState) { + this.$dispatch('on-change', this.data) } } } diff --git a/src/ui/Domo/src/components/Lights.vue b/src/ui/Domo/src/components/Lights.vue index d5e43f00..aa0dc077 100644 --- a/src/ui/Domo/src/components/Lights.vue +++ b/src/ui/Domo/src/components/Lights.vue @@ -1,11 +1,7 @@ @@ -33,9 +29,7 @@ export default { Light }, methods: { - change (e) { - console.log(e) - }, + /* Get Lights */ getLights () { this.$http.get('http://192.168.1.6:8081/v1/capabilities/lights') .then(function (response) { @@ -44,64 +38,21 @@ export default { }, function (err) { console.log(err) }) + }, + /* Set Light */ + setLight (data) { + var msg = '' + console.log(data) + msg = '{"id": ' + data.id + ', "state": ' + data.state + '}' + console.log(msg) + this.$http.post('http://192.168.1.6:8081/v1/capabilities/lights', msg) + .then(function (response) { + console.log('Success!:', response.data) + }, function (err) { + console.log(err) + }) } } } -