use global websocket

This commit is contained in:
2018-09-17 08:40:39 +02:00
parent feb4f088d3
commit 20e87b30f3
7 changed files with 28 additions and 42 deletions

View File

@@ -33,38 +33,33 @@
<li class="form-row ParamColor"
data-mode="2"
data-name="color"
data-label="Color"
data-endpoint="ws://192.168.1.246/pixel">
data-label="Color">
</li>
<li class="form-row ParamColor"
data-mode="2"
data-name="color2"
data-label="Color 2"
data-endpoint="/pixel">
data-label="Color 2">
</li>
<li class="form-row LedStripPatternSwitch"
data-group="stripPattern"
data-id="1"
data-mode="3"
data-name="Rainbow"
data-label="Rainbow"
data-endpoint="ws://192.168.1.246/pixel">
data-label="Rainbow">
</li>
<li class="form-row LedStripPatternSwitch"
data-group="stripPattern"
data-name="TheaterChase"
data-label="Theater Chase"
data-id="2"
data-mode="3"
data-endpoint="ws://192.168.1.246/pixel">
data-mode="3">
</li>
<li class="form-row LedStripPatternSwitch"
data-group="stripPattern"
data-name="Scanner"
data-label="Scanner"
data-id="4"
data-mode="3"
data-endpoint="ws://192.168.1.246/pixel">
data-mode="3">
</li>
</ul>
</div>

View File

@@ -10752,10 +10752,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(() => {
new __WEBPACK_IMPORTED_MODULE_1__core_App__["a" /* default */](__WEBPACK_IMPORTED_MODULE_0_jquery___default()('body'))
.components(__WEBPACK_IMPORTED_MODULE_2__components_exports__);
/* .websocket({
led: new WebSocket('ws://ledstrip/')
}); */
.components(__WEBPACK_IMPORTED_MODULE_2__components_exports__)
.websocket(new WebSocket('ws://192.168.1.246/pixel'));
});
@@ -11925,13 +11923,13 @@ class ParamColor extends __WEBPACK_IMPORTED_MODULE_1__base_ColorPicker_ColorPick
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 = 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) {
@@ -11940,7 +11938,7 @@ class ParamColor extends __WEBPACK_IMPORTED_MODULE_1__base_ColorPicker_ColorPick
});*/
//let cmd = this.config.id + parseInt(this.value.replace('#', '0x'));
console.log(parseInt(this.value.replace('#', '0x')));
this.ws.send(JSON.stringify({
this.ctx.ws.send(JSON.stringify({
mode: this.config.mode,
value: parseInt(this.value.replace('#', '0x'))
}));
@@ -11969,14 +11967,14 @@ class ParamWs extends __WEBPACK_IMPORTED_MODULE_1__base_TextInput_TextInput__["a
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 = 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);
this.node.find('input').val(event.data);
};
}; */
this.ctx.mediator.on(this.config.endpoint, this.onMessage.bind(this));
}
@@ -12016,9 +12014,9 @@ class LedStripPatternSwitch extends __WEBPACK_IMPORTED_MODULE_1__base_Switch_Swi
constructor(ctx, node) {
super(ctx, node);
this.store = new __WEBPACK_IMPORTED_MODULE_2__core_store_RestStore__["a" /* default */](this.config.endpoint);
//this.store = new RestStore(this.config.endpoint);
this.ws = new WebSocket(this.config.endpoint.indexOf('/') === 0 ? "ws://" + window.location.host + this.config.endpoint : this.config.endpoint );
this.ws = this.ctx.ws;
this.modes = ["init", "Color", "Pattern", "octoPrint"];
this.patterns = [ "none", "Rainbow", "Scanner", "ColorWipe", "TheaterChase"];