diff --git a/web/app/pods/application/controller.js b/web/app/pods/application/controller.js new file mode 100644 index 0000000..b6ea587 --- /dev/null +++ b/web/app/pods/application/controller.js @@ -0,0 +1,40 @@ +import Ember from 'ember'; + +const { + Controller, + isEmpty +} = Ember; + +export default Controller.extend({ + dimmerOn: false, + + init(){ + this._super(...arguments); + + let storage = new window.Locally.Store({compress: true}), + dimmerOn = storage.get('huegasm.dimmerOn'); + this.set('storage', storage); + + if (!isEmpty(dimmerOn) && dimmerOn) { + this.send('toggleDimmer'); + } + }, + + actions: { + toggleDimmer(){ + this.toggleProperty('dimmerOn'); + + let dimmerOn = this.get('dimmerOn'); + + if (dimmerOn) { + $('body').addClass('dimmerOn'); + $('html').addClass('dimmerOn'); + } else { + $('body').removeClass('dimmerOn'); + $('html').removeClass('dimmerOn'); + } + + this.get('storage').set('huegasm.dimmerOn', dimmerOn); + } + } +}); diff --git a/web/app/pods/application/template.hbs b/web/app/pods/application/template.hbs index d53e9c5..a426219 100644 --- a/web/app/pods/application/template.hbs +++ b/web/app/pods/application/template.hbs @@ -1 +1,3 @@ -{{huegasm-app}} \ No newline at end of file +{{huegasm-app action="toggleDimmer" dimmerOn=dimmerOn storage=storage}} + +{{huegasm-footer action="toggleDimmer" dimmerOn=dimmerOn storage=storage}} \ No newline at end of file diff --git a/web/app/pods/components/hue-controls/component.js b/web/app/pods/components/hue-controls/component.js index d0106ef..d75d378 100644 --- a/web/app/pods/components/hue-controls/component.js +++ b/web/app/pods/components/hue-controls/component.js @@ -115,7 +115,7 @@ export default Component.extend({ location.reload(); }, toggleDimmer() { - this.sendAction("toggleDimmer"); + this.sendAction(); }, clearAllSettings() { this.get('storage').clear(); diff --git a/web/app/pods/components/hue-controls/template.hbs b/web/app/pods/components/hue-controls/template.hbs index fa2f318..b468924 100644 --- a/web/app/pods/components/hue-controls/template.hbs +++ b/web/app/pods/components/hue-controls/template.hbs @@ -1,7 +1,7 @@ {{#if ready}}