diff --git a/web/app/pods/components/bridge-finder/component.js b/web/app/pods/components/bridge-finder/component.js index 588796e..2a8fa03 100644 --- a/web/app/pods/components/bridge-finder/component.js +++ b/web/app/pods/components/bridge-finder/component.js @@ -116,7 +116,6 @@ export default Component.extend({ clearBridgePingIntervalHandle(){ clearInterval(this.get('bridgePingIntervalHandle')); - this.set('bridgePingIntervalHandle', null); }, actions: { diff --git a/web/app/pods/components/groups-list/add-group-modal/component.js b/web/app/pods/components/groups-list/add-group-modal/component.js deleted file mode 100644 index 653fd7b..0000000 --- a/web/app/pods/components/groups-list/add-group-modal/component.js +++ /dev/null @@ -1,70 +0,0 @@ -import Ember from 'ember'; - -const { - Component, - observer, - computed, - isEmpty, - isNone, - $ -} = Ember; - -export default Component.extend({ - groupName: null, - selectedLights: [], - - onIsShowingModalChange: observer('isShowingModal', function(){ - if(this.get('isShowingModal')){ - this.setProperties({ - selectedLights: [], - groupName: null - }); - } - }), - - saveDisabled: computed('groupName', 'selectedLights.[]', function(){ - return isNone(this.get('groupName')) || isEmpty(this.get('selectedLights')) || isEmpty(this.get('groupName').trim()); - }), - - didInsertElement: function() { - $(document).keypress((event) => { - if(!this.get('saveDisabled') && event.which === 13) { - this.send('save'); - } - }); - }, - - actions: { - close: function(){ - this.sendAction(); - }, - save: function(){ - let newGroupData = {"name": this.get('groupName'), "lights": this.get('selectedLights')}, - newGroupsData = this.get('groupsData'); - - $.ajax(this.get('apiURL') + '/groups', { - data: JSON.stringify(newGroupData), - contentType: 'application/json', - type: 'POST' - }); - - // crappy code to redraw the lights - newGroupsData['9999'] = newGroupData; - - this.setProperties({ - updateGroupsData: true, - groupsData: newGroupsData - }); - this.sendAction(); - }, - clickLight: function(id) { - let selectedLights = this.get('selectedLights'); - - if(selectedLights.contains(id)){ - selectedLights.removeObject(id); - } else { - selectedLights.pushObject(id); - } - } - } -}); diff --git a/web/app/pods/components/groups-list/add-group-modal/template.hbs b/web/app/pods/components/groups-list/add-group-modal/template.hbs deleted file mode 100644 index 4cc896c..0000000 --- a/web/app/pods/components/groups-list/add-group-modal/template.hbs +++ /dev/null @@ -1,12 +0,0 @@ -{{#if isShowingModal}} - {{#modal-dialog close="close" alignment="center" translucentOverlay=true}} - - {{light-group lightsData=lightsData activeLights=selectedLights action="clickLight" apiURL=apiURL noHover=true}} - - {{paper-input label="Group name" value=groupName max="32" max-errortext="The group name cannot exceed 32 characters"}} - - {{#paper-button action="close"}}Close{{/paper-button}} - {{#paper-button class="pull-right" action="save" disabled=saveDisabled primary=true}}Save{{/paper-button}} - - {{/modal-dialog}} -{{/if}} \ No newline at end of file diff --git a/web/app/pods/components/groups-list/component.js b/web/app/pods/components/groups-list/component.js deleted file mode 100644 index 5a65303..0000000 --- a/web/app/pods/components/groups-list/component.js +++ /dev/null @@ -1,86 +0,0 @@ -import Ember from 'ember'; - -const { - Component, - observer, - computed, - isEmpty, - isNone, -} = Ember; - -export default Component.extend({ - classNames: ['dropdown-menu'], - elementId: 'group-list', - tagName: null, - groupIdSelection: null, - - groupsArrData: computed('groupsData', 'groupIdSelection', function(){ - let groupsData = this.get('groupsData'), lightsData = this.get('lightsData'), groupsArrData = [], ids = [], groupIdSelection = this.get('groupIdSelection'); - - for (let key in lightsData) { - if(lightsData.hasOwnProperty(key) && lightsData[key].state.reachable){ - ids.push(key); - } - } - groupsArrData.push({name: 'All', data: {lights: ids, key: '0' }, rowClass: groupIdSelection === '0' ? 'group-row selected-row' : 'group-row', deletable: false}); - - for (let key in groupsData) { - if (groupsData.hasOwnProperty(key)) { - let rowClass = 'group-row'; - - if(key === groupIdSelection){ - rowClass += ' selected-row'; - } - - groupsArrData.push({name: groupsData[key].name, data: {lights: groupsData[key].lights, key: key}, rowClass: rowClass, deletable: true}); - } - } - - return groupsArrData; - }), - - onGroupIdSelectionChanged: observer('groupIdSelection', 'groupsArrData', function(){ - let groupIdSelection = this.get('groupIdSelection'), - lights = []; - - this.get('groupsArrData').some(function(group){ - if(group.data.key === groupIdSelection){ - lights = group.data.lights; - return true; - } - }); - - this.get('storage').set('huegasm.selectedGroup', groupIdSelection); - - if(!isNone(groupIdSelection) && !isEmpty(lights)){ - this.set('activeLights', lights); - } - }), - - didInsertElement(){ - let selectGroup = '0', - storageItem = this.get('storage').get('huegasm.selectedGroup'); - - if(storageItem){ - selectGroup = storageItem; - } - - this.set('groupIdSelection', selectGroup); - }, - - actions: { - selectGroup(selection){ - this.set('groupIdSelection', selection); - }, - toggleConfirmDeleteGroupsModal(groupName, groupId){ - this.setProperties({ - deleteGroupName: groupName, - deleteGroupId: groupId - }); - this.toggleProperty('isShowingConfirmDeleteModal'); - }, - toggleAddGroupsModal(){ - this.toggleProperty('isShowingAddGroupsModal'); - } - } -}); diff --git a/web/app/pods/components/groups-list/delete-group-modal/component.js b/web/app/pods/components/groups-list/delete-group-modal/component.js deleted file mode 100644 index c9ac9be..0000000 --- a/web/app/pods/components/groups-list/delete-group-modal/component.js +++ /dev/null @@ -1,40 +0,0 @@ -import Ember from 'ember'; - -const { - Component, - $ -} = Ember; - -export default Component.extend({ - actions: { - close: function(){ - this.sendAction(); - }, - delete: function(){ - let groupId = this.get('groupId'); - - $.ajax(this.get('apiURL') + '/groups/' + groupId, { - contentType: 'application/json', - type: 'DELETE' - }); - - let groupsData = this.get('groupsData'), newGroupsData = []; - for (let key in groupsData) { - if(groupsData.hasOwnProperty(key) && groupsData[key].name !== this.get('groupName') ){ - newGroupsData[key] = groupsData[key]; - } - } - - if(groupId === this.get('groupIdSelection')){ - this.set('groupIdSelection', '0'); - } - - this.setProperties({ - updateGroupsData: true, - groupsData: newGroupsData - }); - - this.sendAction(); - } - } -}); diff --git a/web/app/pods/components/groups-list/delete-group-modal/template.hbs b/web/app/pods/components/groups-list/delete-group-modal/template.hbs deleted file mode 100644 index 2ea092e..0000000 --- a/web/app/pods/components/groups-list/delete-group-modal/template.hbs +++ /dev/null @@ -1,10 +0,0 @@ -{{#if isShowingModal}} - {{#modal-dialog close="close" alignment="center" translucentOverlay=true}} - -
Are you sure you want to delete group "{{groupName}}"?
- - {{#paper-button action="close"}}Close{{/paper-button}} - {{#paper-button class="pull-right" action="delete" primary=true}}Delete{{/paper-button}} - - {{/modal-dialog}} -{{/if}} \ No newline at end of file diff --git a/web/app/pods/components/groups-list/template.hbs b/web/app/pods/components/groups-list/template.hbs deleted file mode 100644 index 1bf0f09..0000000 --- a/web/app/pods/components/groups-list/template.hbs +++ /dev/null @@ -1,15 +0,0 @@ -{{#paper-list}} - {{#paper-item class="new-group-row"}} -