mirror of
https://gitlab.com/wirelos/sprocket-ui.git
synced 2025-12-15 22:28:23 +01:00
copy old frontend
This commit is contained in:
40
src/app/components/LedStripPatternSwitch.js
Normal file
40
src/app/components/LedStripPatternSwitch.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import $ from 'jquery';
|
||||
import Switch from './base/Switch/Switch';
|
||||
import Store from '../core/store/RestStore';
|
||||
|
||||
export default class LedStripPatternSwitch extends Switch {
|
||||
|
||||
constructor(ctx, node) {
|
||||
super(ctx, node);
|
||||
this.store = new Store(this.config.endpoint);
|
||||
this.modes = ["init", "Color", "Pattern", "octoPrint"];
|
||||
this.patterns = [ "none", "Rainbow", "Scanner", "ColorWipe", "TheaterChase"];
|
||||
}
|
||||
|
||||
onClick(evt) {
|
||||
// FIXME separate mode from pattern
|
||||
let payload = {
|
||||
id: this.patterns.indexOf(this.config.name),
|
||||
pattern: this.config.name.substring(0,1),
|
||||
group: this.config.group,
|
||||
mode: 'P',
|
||||
state: this.state
|
||||
};
|
||||
this.ctx.mediator.trigger('/ledStripPreset/switched', payload);
|
||||
}
|
||||
|
||||
subscribe() {
|
||||
this.ctx.mediator.on('/ledStripPreset/switched', (payload) => {
|
||||
this.store.save(payload);
|
||||
if (payload.state
|
||||
&& payload.id !== this.patterns.indexOf(this.config.name)
|
||||
&& payload.group === this.config.group) {
|
||||
if (this.state) {
|
||||
this.state = false;
|
||||
this.node.find('input').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user