diff --git a/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox.patch b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox.patch new file mode 100644 index 0000000000..b7e345fbcd --- /dev/null +++ b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox.patch @@ -0,0 +1,33 @@ +--- occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl.orig ++++ occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl +@@ -329,7 +329,8 @@ + { + ShowWaitAnim(); + +- DeviceListPage.showConfiguration(false, 'DEVICE', selfGroup.device.id); ++ var virtualDevice = new GroupDevice(self.virtualDeviceSerialNumber(),self.virtualDeviceSerialNumber(), "VirtualDevice"); ++ DeviceListPage.showConfiguration(false, 'DEVICE', virtualDevice.device.id); + HideWaitAnim(); + + /* +@@ -568,7 +569,9 @@ + }); + + ko.utils.arrayForEach(viewModel.assignableDevices(), function(item) { +- homematic("Interface.setMetadata", {"objectId":item.device.id, "dataId": "inHeatingGroup", "value" : "false"}); ++ if(item.device != undefined) { ++ homematic("Interface.setMetadata", {"objectId":item.device.id, "dataId": "inHeatingGroup", "value" : "false"}); ++ } + }); + + pb = JSON.stringify(data); +--- occu/WebUI/www/webui/js/common/viewmodels.js.orig ++++ occu/WebUI/www/webui/js/common/viewmodels.js +@@ -64,6 +64,7 @@ + if (typeof self.device != "undefined") { + return DEV_getImagePath(self.device.deviceType.id, 50); + } ++ else return DEV_getImagePath(this.type, 50); + } + + }, this); diff --git a/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl new file mode 100644 index 0000000000..01762dd9eb --- /dev/null +++ b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl @@ -0,0 +1,688 @@ + + + + + +
+ + + + \ No newline at end of file diff --git a/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl.orig b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl.orig new file mode 100644 index 0000000000..a5e7559532 --- /dev/null +++ b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/HMserver/opt/HMServer/pages/GroupEditPage.ftl.orig @@ -0,0 +1,685 @@ + + + + + + + + + + \ No newline at end of file diff --git a/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js new file mode 100755 index 0000000000..3bc4b96d3b --- /dev/null +++ b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js @@ -0,0 +1,192 @@ +virtualDevicePrefix = "INT"; + +//Class to represent a device +function GroupDevice(id, serialNumber, type) +{ + conInfo(id + " " + serialNumber + " " + type); + var self = this; + self.id = id; + self.arSerialNumber = serialNumber.split(":"); + self.realSerialNumber = self.arSerialNumber[0]; + self.Channel = self.arSerialNumber[1]; + conInfo(self.realSerialNumber); + self.serialNumber = serialNumber; + self.device = DeviceList.getDeviceByAddress(self.realSerialNumber); + conInfo(self.device); + self.type = type; + self.devType = translateKey(type); + self.name = ""; + self.extDescr = ""; + if(typeof self.device == "undefined") + { + self.name = type +" "+ self.serialNumber; + } + else + { + var chn = DeviceList.getChannelByAddress(serialNumber); + if (typeof chn != "undefined") { + self.name = chn.getName(); + self.extDescr = (typeof chn.nameExtention != "undefined") ? chn.nameExtention : ""; + } else { + self.name = self.device.getName(); + } + } + + self.getConfigPending = function() + { + var interfaceId = "BidCos-RF"; + if(!self.type.startsWith("HM-")) + { + interfaceId = "HmIP-RF"; + } + + var deviceParamSet = homematic('Interface.getParamset', {"interface": interfaceId, "address" : self.realSerialNumber+":0", "paramsetKey" : "VALUES"}); + // conInfo(deviceParamSet); + // handle null/undefined like no config pending + if(deviceParamSet != typeof 'undefined' && deviceParamSet != null && (deviceParamSet.CONFIG_PENDING === '1' || deviceParamSet.CONFIG_PENDING === true)) + { + return true; + } + else + { + return false; + } + }; + + self.imagePath = ko.computed(function() { + if(this.type == "unknown") + { + return "/config/img/devices/50/unknown_device_thumb.png"; + } + else + { + //return DEV_getImagePath(this.type, 50); + if (typeof self.device != "undefined") { + return DEV_getImagePath(self.device.deviceType.id, 50); + } + else return DEV_getImagePath(this.type, 50); + } + + }, this); + + self.showDevicePicture = function(groupdevice, mouseoverevent) + { + //picDivShow(jg_250, self.type, 250, -1, mouseoverevent.currentTarget); + if (typeof self.device != "undefined") { + picDivShow(jg_250, self.device.deviceType.id, 250, self.Channel, mouseoverevent.currentTarget); + } + }; + + self.hideDevicePicture = function() + { + picDivHide(jg_250); + }; +} + +function Header(title, propertyName) +{ + var self = this; + self.title = title; + self.sortPropertyName = propertyName; + self.colspan = 1; + self.asc = true; + self.isActive = ko.observable(false); + self.headerClass = ko.computed(function(){ + return self.isActive() ? "DeviceListHead_Active" : "DeviceListHead"; + }); +} + +function padLeft(nr, n, str){ + return Array(n-String(nr).length+1).join(str||'0')+nr; +} + +function createVirtualDeviceSerialNumber (id) { + return virtualDevicePrefix+padLeft(id,7); +} + +function retryGetDeviceAndDeviceName(group, tries) { + function getGroupDeviceFromRega () { + group.device = DeviceList.getDeviceByAddress(group.virtualDeviceSerialNumber); + if(typeof group.device === "undefined") + { + if(tries > 0) { + retryGetDeviceAndDeviceName(group, tries - 1); + } else { + group.virtualDeviceName(""); + group.groupDeviceName(""); + } + } + else + { + group.virtualDeviceName(group.device.getName()); + group.groupDeviceName(group.device.getName()); + } + } + + window.setTimeout(getGroupDeviceFromRega, 1000); +} + +function VirtualGroup(id, name, groupTypeLabel, virtualDeviceType) +{ + var selfGroup = this; + selfGroup.id = id; + selfGroup.name = name; + var temp = createVirtualDeviceSerialNumber(selfGroup.id); + selfGroup.virtualDeviceSerialNumber = temp; + selfGroup.device = DeviceList.getDeviceByAddress(temp); + selfGroup.groupTypeLabel = groupTypeLabel; + selfGroup.virtualDeviceName = ko.observable(""); // Todo check if this is still in use somewhere + selfGroup.groupDeviceName = ko.observable(""); + if(typeof selfGroup.device === "undefined") + { + retryGetDeviceAndDeviceName(selfGroup, 3); + } + else + { + selfGroup.virtualDeviceName(selfGroup.device.getName()); + selfGroup.groupDeviceName(selfGroup.device.getName()); + } + + selfGroup.configureVirtualDevice = function() + { + ShowWaitAnim(); + DeviceListPage.showConfiguration(false, 'DEVICE', selfGroup.device.id); + HideWaitAnim(); + /* + jQuery.get( "/config/ic_deviceparameters.cgi?sid="+SessionId+"&iface=VirtualDevices&address="+selfGroup.virtualDeviceSerialNumber+"&redirect_url=GO_BACK", + function( data ) { + WebUI.previousPage = WebUI.currentPage; + WebUI.previousPageOptions = WebUI.currentPageOptions; + WebUI.currentPage = DeviceListPage; + HideWaitAnim(); + jQuery("#content").html(data); + }); + */ + }; + + selfGroup.operateVirtualDevice = function() + { + var virtualDevice = new GroupDevice(selfGroup.virtualDeviceSerialNumber,selfGroup.virtualDeviceSerialNumber); + var url = '/pages/tabs/control/devices.htm?sid='+SessionId; + var pb = "{}"; + var opt = + { + postBody: pb, + onComplete: function(t) + { + WebUI.previousPage = WebUI.currentPage; + WebUI.previousPageOptions = WebUI.currentPageOptions; + WebUI.currentPage = ControlDevicesPage; + var regularExpression = new RegExp("loadChannels\\W\\s[0-9]+\\s\\W"); + var newContent = t.responseText.replace(regularExpression, "loadChannels("+virtualDevice.device.id+")"); + + /*regularExpression = new RegExp("WebUI.goBack\\(\\)"); + newContent = newContent.replace(regularExpression, "WebUI.enter"+"(CreateGroupPage)");*/ + + + jQuery("#content").html(newContent); + } + }; + new Ajax.Request(url,opt); + }; +} \ No newline at end of file diff --git a/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js.orig b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js.orig new file mode 100755 index 0000000000..67ea231023 --- /dev/null +++ b/buildroot-external/patches/occu/0187-WebUI-Fix-GroupEditingIfDevicesInInbox/occu/WebUI/www/webui/js/common/viewmodels.js.orig @@ -0,0 +1,191 @@ +virtualDevicePrefix = "INT"; + +//Class to represent a device +function GroupDevice(id, serialNumber, type) +{ + conInfo(id + " " + serialNumber + " " + type); + var self = this; + self.id = id; + self.arSerialNumber = serialNumber.split(":"); + self.realSerialNumber = self.arSerialNumber[0]; + self.Channel = self.arSerialNumber[1]; + conInfo(self.realSerialNumber); + self.serialNumber = serialNumber; + self.device = DeviceList.getDeviceByAddress(self.realSerialNumber); + conInfo(self.device); + self.type = type; + self.devType = translateKey(type); + self.name = ""; + self.extDescr = ""; + if(typeof self.device == "undefined") + { + self.name = type +" "+ self.serialNumber; + } + else + { + var chn = DeviceList.getChannelByAddress(serialNumber); + if (typeof chn != "undefined") { + self.name = chn.getName(); + self.extDescr = (typeof chn.nameExtention != "undefined") ? chn.nameExtention : ""; + } else { + self.name = self.device.getName(); + } + } + + self.getConfigPending = function() + { + var interfaceId = "BidCos-RF"; + if(!self.type.startsWith("HM-")) + { + interfaceId = "HmIP-RF"; + } + + var deviceParamSet = homematic('Interface.getParamset', {"interface": interfaceId, "address" : self.realSerialNumber+":0", "paramsetKey" : "VALUES"}); + // conInfo(deviceParamSet); + // handle null/undefined like no config pending + if(deviceParamSet != typeof 'undefined' && deviceParamSet != null && (deviceParamSet.CONFIG_PENDING === '1' || deviceParamSet.CONFIG_PENDING === true)) + { + return true; + } + else + { + return false; + } + }; + + self.imagePath = ko.computed(function() { + if(this.type == "unknown") + { + return "/config/img/devices/50/unknown_device_thumb.png"; + } + else + { + //return DEV_getImagePath(this.type, 50); + if (typeof self.device != "undefined") { + return DEV_getImagePath(self.device.deviceType.id, 50); + } + } + + }, this); + + self.showDevicePicture = function(groupdevice, mouseoverevent) + { + //picDivShow(jg_250, self.type, 250, -1, mouseoverevent.currentTarget); + if (typeof self.device != "undefined") { + picDivShow(jg_250, self.device.deviceType.id, 250, self.Channel, mouseoverevent.currentTarget); + } + }; + + self.hideDevicePicture = function() + { + picDivHide(jg_250); + }; +} + +function Header(title, propertyName) +{ + var self = this; + self.title = title; + self.sortPropertyName = propertyName; + self.colspan = 1; + self.asc = true; + self.isActive = ko.observable(false); + self.headerClass = ko.computed(function(){ + return self.isActive() ? "DeviceListHead_Active" : "DeviceListHead"; + }); +} + +function padLeft(nr, n, str){ + return Array(n-String(nr).length+1).join(str||'0')+nr; +} + +function createVirtualDeviceSerialNumber (id) { + return virtualDevicePrefix+padLeft(id,7); +} + +function retryGetDeviceAndDeviceName(group, tries) { + function getGroupDeviceFromRega () { + group.device = DeviceList.getDeviceByAddress(group.virtualDeviceSerialNumber); + if(typeof group.device === "undefined") + { + if(tries > 0) { + retryGetDeviceAndDeviceName(group, tries - 1); + } else { + group.virtualDeviceName(""); + group.groupDeviceName(""); + } + } + else + { + group.virtualDeviceName(group.device.getName()); + group.groupDeviceName(group.device.getName()); + } + } + + window.setTimeout(getGroupDeviceFromRega, 1000); +} + +function VirtualGroup(id, name, groupTypeLabel, virtualDeviceType) +{ + var selfGroup = this; + selfGroup.id = id; + selfGroup.name = name; + var temp = createVirtualDeviceSerialNumber(selfGroup.id); + selfGroup.virtualDeviceSerialNumber = temp; + selfGroup.device = DeviceList.getDeviceByAddress(temp); + selfGroup.groupTypeLabel = groupTypeLabel; + selfGroup.virtualDeviceName = ko.observable(""); // Todo check if this is still in use somewhere + selfGroup.groupDeviceName = ko.observable(""); + if(typeof selfGroup.device === "undefined") + { + retryGetDeviceAndDeviceName(selfGroup, 3); + } + else + { + selfGroup.virtualDeviceName(selfGroup.device.getName()); + selfGroup.groupDeviceName(selfGroup.device.getName()); + } + + selfGroup.configureVirtualDevice = function() + { + ShowWaitAnim(); + DeviceListPage.showConfiguration(false, 'DEVICE', selfGroup.device.id); + HideWaitAnim(); + /* + jQuery.get( "/config/ic_deviceparameters.cgi?sid="+SessionId+"&iface=VirtualDevices&address="+selfGroup.virtualDeviceSerialNumber+"&redirect_url=GO_BACK", + function( data ) { + WebUI.previousPage = WebUI.currentPage; + WebUI.previousPageOptions = WebUI.currentPageOptions; + WebUI.currentPage = DeviceListPage; + HideWaitAnim(); + jQuery("#content").html(data); + }); + */ + }; + + selfGroup.operateVirtualDevice = function() + { + var virtualDevice = new GroupDevice(selfGroup.virtualDeviceSerialNumber,selfGroup.virtualDeviceSerialNumber); + var url = '/pages/tabs/control/devices.htm?sid='+SessionId; + var pb = "{}"; + var opt = + { + postBody: pb, + onComplete: function(t) + { + WebUI.previousPage = WebUI.currentPage; + WebUI.previousPageOptions = WebUI.currentPageOptions; + WebUI.currentPage = ControlDevicesPage; + var regularExpression = new RegExp("loadChannels\\W\\s[0-9]+\\s\\W"); + var newContent = t.responseText.replace(regularExpression, "loadChannels("+virtualDevice.device.id+")"); + + /*regularExpression = new RegExp("WebUI.goBack\\(\\)"); + newContent = newContent.replace(regularExpression, "WebUI.enter"+"(CreateGroupPage)");*/ + + + jQuery("#content").html(newContent); + } + }; + new Ajax.Request(url,opt); + }; +} \ No newline at end of file