From 5c3b70bc96aada0bccc10c2b9c45a6ae3bc565be Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Mon, 17 Sep 2018 11:26:16 +0200 Subject: [PATCH] adapt message --- data/index.html | 5 +- data/script.js | 158 ++++++++++++++---------------- src/app/components/ParamColor.js | 24 ++--- src/app/components/ParamSelect.js | 7 +- src/pages/index.html | 5 +- 5 files changed, 91 insertions(+), 108 deletions(-) diff --git a/data/index.html b/data/index.html index ccd046c..fc0b4b6 100644 --- a/data/index.html +++ b/data/index.html @@ -33,16 +33,19 @@
  • diff --git a/data/script.js b/data/script.js index 754e569..1d5e6cf 100644 --- a/data/script.js +++ b/data/script.js @@ -10438,57 +10438,6 @@ return jQuery; /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Mediator__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__DataStore__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__StoreAction__ = __webpack_require__(18); - - - - - -class RestStore extends __WEBPACK_IMPORTED_MODULE_2__DataStore__["a" /* default */] { - constructor(endpoint, mediator = new __WEBPACK_IMPORTED_MODULE_1__Mediator__["a" /* default */]()){ - super(mediator); - this.endpoint = endpoint; - } - load(entry){ - return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].LOAD, 'GET', entry); - } - save(entry){ - return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].SAVE, 'POST', entry); - } - add(entry){ - return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].ADD, 'PUT', entry); - } - delete(entry){ - return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].DELETE, 'POST', entry); - } - request(event, type, payload){ - return __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.ajax({ - url: this.endpoint, - type: type, - data: payload - }) - .then(JSON.parse) - .then((response) => { - this.mediator.trigger(event, response); - }); - } - on(event, subscriber, context){ - this.mediator.on(event, subscriber, context); - } -} -/* harmony export (immutable) */ __webpack_exports__["a"] = RestStore; - - - -/***/ }), -/* 2 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mustache__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mustache___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_mustache__); @@ -10539,6 +10488,57 @@ class Component { /* harmony export (immutable) */ __webpack_exports__["a"] = Component; +/***/ }), +/* 2 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Mediator__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__DataStore__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__StoreAction__ = __webpack_require__(18); + + + + + +class RestStore extends __WEBPACK_IMPORTED_MODULE_2__DataStore__["a" /* default */] { + constructor(endpoint, mediator = new __WEBPACK_IMPORTED_MODULE_1__Mediator__["a" /* default */]()){ + super(mediator); + this.endpoint = endpoint; + } + load(entry){ + return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].LOAD, 'GET', entry); + } + save(entry){ + return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].SAVE, 'POST', entry); + } + add(entry){ + return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].ADD, 'PUT', entry); + } + delete(entry){ + return this.request(__WEBPACK_IMPORTED_MODULE_3__StoreAction__["a" /* default */].DELETE, 'POST', entry); + } + request(event, type, payload){ + return __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.ajax({ + url: this.endpoint, + type: type, + data: payload + }) + .then(JSON.parse) + .then((response) => { + this.mediator.trigger(event, response); + }); + } + on(event, subscriber, context){ + this.mediator.on(event, subscriber, context); + } +} +/* harmony export (immutable) */ __webpack_exports__["a"] = RestStore; + + + /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { @@ -10546,7 +10546,7 @@ class Component { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextInput_html__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextInput_html___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__TextInput_html__); @@ -10584,7 +10584,7 @@ class TextInput extends __WEBPACK_IMPORTED_MODULE_1__core_Component__["a" /* def "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Switch_html__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Switch_html___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__Switch_html__); @@ -10656,7 +10656,7 @@ class Mediator { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Slider_html__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Slider_html___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__Slider_html__); @@ -10694,7 +10694,7 @@ class Slider extends __WEBPACK_IMPORTED_MODULE_1__core_Component__["a" /* defaul "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Select_html__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Select_html___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__Select_html__); @@ -10728,7 +10728,7 @@ class Select extends __WEBPACK_IMPORTED_MODULE_1__core_Component__["a" /* defaul "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ColorPicker_html__ = __webpack_require__(22); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ColorPicker_html___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__ColorPicker_html__); @@ -11023,9 +11023,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Component__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextInput_TextInput__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_store_RestStore__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_store_RestStore__ = __webpack_require__(2); @@ -11850,7 +11850,7 @@ module.exports = "\n { - console.log('open ' + this.config.endpoint); - }; - this.ws.onmessage = (event) => { - console.log(event.data); - }; */ } onChange(evt) { - /*this.store.save({ - rgb: parseInt(this.value.replace('#', '0x')) - });*/ - //let cmd = this.config.id + parseInt(this.value.replace('#', '0x')); - console.log(parseInt(this.value.replace('#', '0x'))); - this.ctx.ws.send(JSON.stringify({ - mode: this.config.mode, - value: parseInt(this.value.replace('#', '0x')) - })); + let obj = { + topic: this.config.topic, + payload: parseInt(this.value.replace('#', '0x')) + }; + this.ctx.ws.send(JSON.stringify(obj)); + console.log(obj); } } @@ -12002,7 +11989,7 @@ class ParamColor extends __WEBPACK_IMPORTED_MODULE_1__base_ColorPicker_ColorPick /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__base_TextInput_TextInput__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_store_RestStore__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_store_RestStore__ = __webpack_require__(2); @@ -12067,10 +12054,11 @@ class ParamSelect extends __WEBPACK_IMPORTED_MODULE_1__base_Select_Select__["a" } onChange(evt) { - let obj = {}; - obj[this.config.name] = evt.target.value; + let obj = { + topic: this.config.topic, + payload: evt.target.value + }; this.ctx.ws.send(JSON.stringify(obj)); - } } @@ -12085,7 +12073,7 @@ class ParamSelect extends __WEBPACK_IMPORTED_MODULE_1__base_Select_Select__["a" /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__base_Switch_Switch__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_store_RestStore__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_store_RestStore__ = __webpack_require__(2); diff --git a/src/app/components/ParamColor.js b/src/app/components/ParamColor.js index 7dc4d57..ceaf1a8 100644 --- a/src/app/components/ParamColor.js +++ b/src/app/components/ParamColor.js @@ -1,31 +1,19 @@ import $ from 'jquery'; import ColorPicker from './base/ColorPicker/ColorPicker'; -import Store from '../core/store/RestStore'; export default class ParamColor extends ColorPicker { constructor(ctx, node) { super(ctx, node); - //this.store = new Store(this.config.endpoint); - /* this.ws = new WebSocket(this.config.endpoint.indexOf('/') === 0 ? "ws://" + window.location.host + this.config.endpoint : this.config.endpoint ); - this.ws.onopen = (event) => { - console.log('open ' + this.config.endpoint); - }; - this.ws.onmessage = (event) => { - console.log(event.data); - }; */ } onChange(evt) { - /*this.store.save({ - rgb: parseInt(this.value.replace('#', '0x')) - });*/ - //let cmd = this.config.id + parseInt(this.value.replace('#', '0x')); - console.log(parseInt(this.value.replace('#', '0x'))); - this.ctx.ws.send(JSON.stringify({ - mode: this.config.mode, - value: parseInt(this.value.replace('#', '0x')) - })); + let obj = { + topic: this.config.topic, + payload: parseInt(this.value.replace('#', '0x')) + }; + this.ctx.ws.send(JSON.stringify(obj)); + console.log(obj); } } \ No newline at end of file diff --git a/src/app/components/ParamSelect.js b/src/app/components/ParamSelect.js index 54674b7..d638760 100644 --- a/src/app/components/ParamSelect.js +++ b/src/app/components/ParamSelect.js @@ -14,10 +14,11 @@ export default class ParamSelect extends Select { } onChange(evt) { - let obj = {}; - obj[this.config.name] = evt.target.value; + let obj = { + topic: this.config.topic, + payload: evt.target.value + }; this.ctx.ws.send(JSON.stringify(obj)); - } } \ No newline at end of file diff --git a/src/pages/index.html b/src/pages/index.html index ccd046c..fc0b4b6 100644 --- a/src/pages/index.html +++ b/src/pages/index.html @@ -33,16 +33,19 @@