Bug Fix #56: Noticeboard device profile filtering

This commit is contained in:
Gary Sharp
2014-07-10 17:49:36 +10:00
parent f4394fe2a0
commit 2274e2201d
4 changed files with 137 additions and 135 deletions
@@ -271,7 +271,7 @@
} }
break; break;
case 'deviceprofileinclude': case 'deviceprofileinclude':
var deviceProfiles = value.split(","); var deviceProfiles = value.split(",").map(function (v) { return parseInt(v); });
if (deviceProfiles.length > 0) { if (deviceProfiles.length > 0) {
filters.push(function (heldDeviceItem) { filters.push(function (heldDeviceItem) {
// true if DeviceProfileId is included // true if DeviceProfileId is included
@@ -280,7 +280,7 @@
} }
break; break;
case 'deviceprofileexclude': case 'deviceprofileexclude':
var deviceProfiles = value.split(","); var deviceProfiles = value.split(",").map(function (v) { return parseInt(v); });
if (deviceProfiles.length > 0) { if (deviceProfiles.length > 0) {
filters.push(function (heldDeviceItem) { filters.push(function (heldDeviceItem) {
// true if DeviceProfileId is excluded // true if DeviceProfileId is excluded
@@ -343,72 +343,73 @@ WriteLiteral("\', null, function (data) {\r\n\r\n var inProce
"toLowerCase(), deviceAddresses) < 0;\r\n });\r\n " + "toLowerCase(), deviceAddresses) < 0;\r\n });\r\n " +
" }\r\n break;\r\n " + " }\r\n break;\r\n " +
" case \'deviceprofileinclude\':\r\n " + " case \'deviceprofileinclude\':\r\n " +
" var deviceProfiles = value.split(\",\");\r\n if (" + " var deviceProfiles = value.split(\",\").map(function (v) { return parseInt(v);" +
"deviceProfiles.length > 0) {\r\n filters.push(f" + " });\r\n if (deviceProfiles.length > 0) {\r\n " +
"unction (heldDeviceItem) {\r\n // true if D" + " filters.push(function (heldDeviceItem) {\r\n " +
"eviceProfileId is included\r\n return $.inA" + " // true if DeviceProfileId is included\r\n " +
"rray(heldDeviceItem.DeviceProfileId, deviceProfiles) >= 0;\r\n " + " return $.inArray(heldDeviceItem.DeviceProfileId, d" +
" });\r\n }\r\n " + "eviceProfiles) >= 0;\r\n });\r\n " +
" break;\r\n case \'deviceprofileexclude\':\r\n " + " }\r\n break;\r\n " +
" var deviceProfiles = value.split(\",\");\r\n " + " case \'deviceprofileexclude\':\r\n var devicePr" +
"ofiles = value.split(\",\").map(function (v) { return parseInt(v); });\r\n " +
" if (deviceProfiles.length > 0) {\r\n " + " if (deviceProfiles.length > 0) {\r\n " +
" filters.push(function (heldDeviceItem) {\r\n " + " filters.push(function (heldDeviceItem) {\r\n " +
" // true if DeviceProfileId is excluded\r\n " + " // true if DeviceProfileId is excluded\r\n " +
" return $.inArray(heldDeviceItem.DeviceProfileId, deviceProfiles) < 0;\r" + " return $.inArray(heldDeviceItem.DeviceProfileId, deviceProfiles) <" +
"\n });\r\n }\r\n " + " 0;\r\n });\r\n }\r" +
" break;\r\n }\r\n " + "\n break;\r\n }\r\n " +
" });\r\n }\r\n\r\n if (filters.length > 0)\r\n " + " });\r\n }\r\n\r\n if (filters.length > 0)\r\n " +
" itemFilters = filters;\r\n else\r\n ite" + " itemFilters = filters;\r\n else\r\n " +
"mFilters = null;\r\n }\r\n\r\n function connectionError() {\r\n " + " itemFilters = null;\r\n }\r\n\r\n function connectionError() {\r" +
" try {\r\n $(\'body\').addClass(\'status-error\');\r\n " + "\n try {\r\n $(\'body\').addClass(\'status-error\');\r" +
" $.connection.hub.stop();\r\n } catch (e) {\r\n " + "\n $.connection.hub.stop();\r\n } catch (e) {\r\n " +
" // Ignore\r\n }\r\n\r\n window.setTimeout(" + " // Ignore\r\n }\r\n\r\n window.setTime" +
"function () {\r\n window.location.href = window.location.href;\r" + "out(function () {\r\n window.location.href = window.location.hr" +
"\n }, 10000);\r\n }\r\n\r\n // Helpers\r\n " + "ef;\r\n }, 10000);\r\n }\r\n\r\n // Helpers\r\n " +
" function rotateArray(koArray, element) {\r\n var items = koArray(" + " function rotateArray(koArray, element) {\r\n var items = koAr" +
");\r\n\r\n if (items.length <= 1)\r\n return 0;\r\n\r\n " + "ray();\r\n\r\n if (items.length <= 1)\r\n return 0;\r" +
" if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " + "\n\r\n if (element.height() < (element.parent().height() - 30)) {\r\n\r" +
" if (findUnsortedArrayTopIndex(items) !== 0)\r\n " + "\n if (findUnsortedArrayTopIndex(items) !== 0)\r\n " +
" koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate if smal" + " koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate if " +
"l & sorted correctly\r\n return;\r\n }\r\n\r\n " + "small & sorted correctly\r\n return;\r\n }\r\n\r\n " +
" // Move Last Item to Top\r\n var item = koArray.pop();\r\n " + " // Move Last Item to Top\r\n var item = koArray.pop();\r" +
" koArray.unshift(item);\r\n }\r\n function removeI" + "\n koArray.unshift(item);\r\n }\r\n function rem" +
"temFromArray(koArray, deviceSerialNumber) {\r\n var items = koArray" + "oveItemFromArray(koArray, deviceSerialNumber) {\r\n var items = koA" +
"();\r\n for (var i = 0; i < items.length; i++) {\r\n " + "rray();\r\n for (var i = 0; i < items.length; i++) {\r\n " +
" if (items[i].DeviceSerialNumber == deviceSerialNumber) {\r\n " + " if (items[i].DeviceSerialNumber == deviceSerialNumber) {\r\n " +
" koArray.splice(i, 1);\r\n items = koArray();\r\n " + " koArray.splice(i, 1);\r\n items = koArray();\r\n " +
" i--;\r\n }\r\n }\r\n }\r\n " + " i--;\r\n }\r\n }\r\n " +
" function findUnsortedArrayTopIndex(items) {\r\n // Only " + "}\r\n function findUnsortedArrayTopIndex(items) {\r\n // O" +
"one Item\r\n if (items.length <= 1)\r\n return 0;\r" + "nly one Item\r\n if (items.length <= 1)\r\n return" +
"\n\r\n for (var i = 1; i < items.length; i++) {\r\n " + " 0;\r\n\r\n for (var i = 1; i < items.length; i++) {\r\n " +
" var s = sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n" + " var s = sortFunction(items[i - 1], items[i]);\r\n if (s > " +
" return i;\r\n }\r\n\r\n return 0" + "0)\r\n return i;\r\n }\r\n\r\n retu" +
";\r\n }\r\n function findSortedInsertIndex(koArray, heldDevice" + "rn 0;\r\n }\r\n function findSortedInsertIndex(koArray, heldDe" +
"Item) {\r\n var items = koArray();\r\n var startIndex " + "viceItem) {\r\n var items = koArray();\r\n var startIn" +
"= findUnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i " + "dex = findUnsortedArrayTopIndex(items);\r\n for (var i = startIndex" +
"< items.length; i++) {\r\n var s = sortFunction(heldDeviceItem," + "; i < items.length; i++) {\r\n var s = sortFunction(heldDeviceI" +
" items[i]);\r\n if (s <= 0)\r\n return i;\r" + "tem, items[i]);\r\n if (s <= 0)\r\n return" +
"\n }\r\n if (startIndex !== 0) {\r\n " + " i;\r\n }\r\n if (startIndex !== 0) {\r\n " +
" for (var i = 0; i < startIndex; i++) {\r\n var s = sortFun" + " for (var i = 0; i < startIndex; i++) {\r\n var s = sor" +
"ction(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + "tFunction(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
" return i;\r\n }\r\n return " + " return i;\r\n }\r\n ret" +
"startIndex;\r\n } else {\r\n return -1;\r\n " + "urn startIndex;\r\n } else {\r\n return -1;\r\n " +
" }\r\n }\r\n function sortFunction(l, r) {\r\n " + " }\r\n }\r\n function sortFunction(l, r) {\r\n " +
" return l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase(" + " return l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerC" +
") ? 0 : (l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ?" + "ase() ? 0 : (l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase" +
" -1 : 1)\r\n }\r\n function isInProcess(i) {\r\n " + "() ? -1 : 1)\r\n }\r\n function isInProcess(i) {\r\n " +
"return !i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n " + " return !i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n " +
" function isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.W" + " function isReadyForReturn(i) {\r\n return i.ReadyForReturn && " +
"aitingForUserAction;\r\n }\r\n function isWaitingForUserAction" + "!i.WaitingForUserAction;\r\n }\r\n function isWaitingForUserAc" +
"(i) {\r\n return i.WaitingForUserAction;\r\n }\r\n " + "tion(i) {\r\n return i.WaitingForUserAction;\r\n }\r\n " +
" function getQueryStringParameters() {\r\n\r\n if (window.location.s" + " function getQueryStringParameters() {\r\n\r\n if (window.locati" +
"earch.length === 0)\r\n return null;\r\n\r\n var par" + "on.search.length === 0)\r\n return null;\r\n\r\n var" +
"ams = {};\r\n window.location.search.substr(1).split(\"&\").forEach(f" + " params = {};\r\n window.location.search.substr(1).split(\"&\").forEa" +
"unction (pair) {\r\n if (pair === \"\") return;\r\n " + "ch(function (pair) {\r\n if (pair === \"\") return;\r\n " +
" var parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1" + " var parts = pair.split(\"=\");\r\n params[parts[0]] = par" +
"] && decodeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " + "ts[1] && decodeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r" +
" return params;\r\n }\r\n\r\n init();\r\n });\r\n" + "\n return params;\r\n }\r\n\r\n init();\r\n }" +
" </script>\r\n</body>\r\n</html>"); ");\r\n </script>\r\n</body>\r\n</html>");
} }
} }
@@ -271,7 +271,7 @@
} }
break; break;
case 'deviceprofileinclude': case 'deviceprofileinclude':
var deviceProfiles = value.split(","); var deviceProfiles = value.split(",").map(function (v) { return parseInt(v); });
if (deviceProfiles.length > 0) { if (deviceProfiles.length > 0) {
filters.push(function (heldDeviceItem) { filters.push(function (heldDeviceItem) {
// true if DeviceProfileId is included // true if DeviceProfileId is included
@@ -280,7 +280,7 @@
} }
break; break;
case 'deviceprofileexclude': case 'deviceprofileexclude':
var deviceProfiles = value.split(","); var deviceProfiles = value.split(",").map(function (v) { return parseInt(v); });
if (deviceProfiles.length > 0) { if (deviceProfiles.length > 0) {
filters.push(function (heldDeviceItem) { filters.push(function (heldDeviceItem) {
// true if DeviceProfileId is excluded // true if DeviceProfileId is excluded
@@ -343,70 +343,71 @@ WriteLiteral("\', null, function (data) {\r\n\r\n var inProce
"ortName.toLowerCase(), deviceAddresses) < 0;\r\n " + "ortName.toLowerCase(), deviceAddresses) < 0;\r\n " +
" });\r\n }\r\n break;" + " });\r\n }\r\n break;" +
"\r\n case \'deviceprofileinclude\':\r\n " + "\r\n case \'deviceprofileinclude\':\r\n " +
" var deviceProfiles = value.split(\",\");\r\n " + " var deviceProfiles = value.split(\",\").map(function (v) { return pars" +
" if (deviceProfiles.length > 0) {\r\n filter" + "eInt(v); });\r\n if (deviceProfiles.length > 0) {\r\n" +
"s.push(function (heldDeviceItem) {\r\n // t" + " filters.push(function (heldDeviceItem) {\r\n " +
"rue if DeviceProfileId is included\r\n retu" + " // true if DeviceProfileId is included\r\n " +
"rn $.inArray(heldDeviceItem.DeviceProfileId, deviceProfiles) >= 0;\r\n " + " return $.inArray(heldDeviceItem.DeviceProf" +
" });\r\n }\r\n " + "ileId, deviceProfiles) >= 0;\r\n });\r\n " +
" break;\r\n case \'deviceprofileexclude\':" + " }\r\n break;\r\n " +
"\r\n var deviceProfiles = value.split(\",\");\r\n " + " case \'deviceprofileexclude\':\r\n var " +
"deviceProfiles = value.split(\",\").map(function (v) { return parseInt(v); });\r\n " +
" if (deviceProfiles.length > 0) {\r\n " + " if (deviceProfiles.length > 0) {\r\n " +
" filters.push(function (heldDeviceItem) {\r\n " + " filters.push(function (heldDeviceItem) {\r\n " +
" // true if DeviceProfileId is excluded\r\n " + " // true if DeviceProfileId is excluded\r\n " +
" return $.inArray(heldDeviceItem.DeviceProfileId, deviceProfile" + " return $.inArray(heldDeviceItem.DeviceProfileId, devicePro" +
"s) < 0;\r\n });\r\n " + "files) < 0;\r\n });\r\n " +
" }\r\n break;\r\n }\r\n " + " }\r\n break;\r\n }\r\n " +
" });\r\n }\r\n\r\n if (filters.length > 0)\r\n " + " });\r\n }\r\n\r\n if (filters.length > 0" +
" itemFilters = filters;\r\n else\r\n " + ")\r\n itemFilters = filters;\r\n else\r\n " +
" itemFilters = null;\r\n }\r\n\r\n function connectionError(" + " itemFilters = null;\r\n }\r\n\r\n function connectionEr" +
") {\r\n try {\r\n $(\'body\').addClass(\'status-error" + "ror() {\r\n try {\r\n $(\'body\').addClass(\'status-e" +
"\');\r\n $.connection.hub.stop();\r\n } catch (e) {" + "rror\');\r\n $.connection.hub.stop();\r\n } catch (" +
"\r\n // Ignore\r\n }\r\n\r\n window.set" + "e) {\r\n // Ignore\r\n }\r\n\r\n window" +
"Timeout(function () {\r\n window.location.href = window.locatio" + ".setTimeout(function () {\r\n window.location.href = window.loc" +
"n.href;\r\n }, 10000);\r\n }\r\n\r\n // Helpers\r\n " + "ation.href;\r\n }, 10000);\r\n }\r\n\r\n // Helpers" +
" function rotateArray(koArray, element) {\r\n var items = " + "\r\n function rotateArray(koArray, element) {\r\n var item" +
"koArray();\r\n\r\n if (items.length <= 1)\r\n return" + "s = koArray();\r\n\r\n if (items.length <= 1)\r\n re" +
" 0;\r\n\r\n if (element.height() < (element.parent().height() - 30)) " + "turn 0;\r\n\r\n if (element.height() < (element.parent().height() - 3" +
"{\r\n\r\n if (findUnsortedArrayTopIndex(items) !== 0)\r\n " + "0)) {\r\n\r\n if (findUnsortedArrayTopIndex(items) !== 0)\r\n " +
" koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate" + " koArray.sort(sortFunction);\r\n\r\n // Don\'t ro" +
" if small & sorted correctly\r\n return;\r\n }\r\n\r\n" + "tate if small & sorted correctly\r\n return;\r\n }" +
" // Move Last Item to Top\r\n var item = koArray.pop" + "\r\n\r\n // Move Last Item to Top\r\n var item = koArray" +
"();\r\n koArray.unshift(item);\r\n }\r\n function" + ".pop();\r\n koArray.unshift(item);\r\n }\r\n func" +
" removeItemFromArray(koArray, UserId) {\r\n var items = koArray();\r" + "tion removeItemFromArray(koArray, UserId) {\r\n var items = koArray" +
"\n for (var i = 0; i < items.length; i++) {\r\n i" + "();\r\n for (var i = 0; i < items.length; i++) {\r\n " +
"f (items[i].UserId == UserId) {\r\n koArray.splice(i, 1);\r\n" + " if (items[i].UserId == UserId) {\r\n koArray.splice(i, 1" +
" items = koArray();\r\n i--;\r\n " + ");\r\n items = koArray();\r\n i--;\r\n " +
" }\r\n }\r\n }\r\n function findUnso" + " }\r\n }\r\n }\r\n function find" +
"rtedArrayTopIndex(items) {\r\n // Only one Item\r\n if" + "UnsortedArrayTopIndex(items) {\r\n // Only one Item\r\n " +
" (items.length <= 1)\r\n return 0;\r\n\r\n for (var " + " if (items.length <= 1)\r\n return 0;\r\n\r\n for (" +
"i = 1; i < items.length; i++) {\r\n var s = sortFunction(items[" + "var i = 1; i < items.length; i++) {\r\n var s = sortFunction(it" +
"i - 1], items[i]);\r\n if (s > 0)\r\n retu" + "ems[i - 1], items[i]);\r\n if (s > 0)\r\n " +
"rn i;\r\n }\r\n\r\n return 0;\r\n }\r\n " + "return i;\r\n }\r\n\r\n return 0;\r\n }\r\n " +
" function findSortedInsertIndex(koArray, heldDeviceItem) {\r\n var" + " function findSortedInsertIndex(koArray, heldDeviceItem) {\r\n " +
" items = koArray();\r\n var startIndex = findUnsortedArrayTopIndex(" + " var items = koArray();\r\n var startIndex = findUnsortedArrayTopIn" +
"items);\r\n for (var i = startIndex; i < items.length; i++) {\r\n " + "dex(items);\r\n for (var i = startIndex; i < items.length; i++) {\r\n" +
" var s = sortFunction(heldDeviceItem, items[i]);\r\n " + " var s = sortFunction(heldDeviceItem, items[i]);\r\n " +
" if (s <= 0)\r\n return i;\r\n }\r\n " + " if (s <= 0)\r\n return i;\r\n }\r\n " +
" if (startIndex !== 0) {\r\n for (var i = 0; i < startIn" + " if (startIndex !== 0) {\r\n for (var i = 0; i < sta" +
"dex; i++) {\r\n var s = sortFunction(heldDeviceItem, items[" + "rtIndex; i++) {\r\n var s = sortFunction(heldDeviceItem, it" +
"i]);\r\n if (s <= 0)\r\n return i;" + "ems[i]);\r\n if (s <= 0)\r\n retur" +
"\r\n }\r\n return startIndex;\r\n " + "n i;\r\n }\r\n return startIndex;\r\n " +
" } else {\r\n return -1;\r\n }\r\n }\r\n " + " } else {\r\n return -1;\r\n }\r\n }\r" +
" function sortFunction(l, r) {\r\n return l.UserIdFriendly." + "\n function sortFunction(l, r) {\r\n return l.UserIdFrien" +
"toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : (l.UserIdFriendly.toLowerC" + "dly.toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : (l.UserIdFriendly.toLo" +
"ase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n }\r\n fun" + "werCase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n }\r\n " +
"ction isInProcess(i) {\r\n return !i.ReadyForReturn && !i.WaitingFo" + " function isInProcess(i) {\r\n return !i.ReadyForReturn && !i.Waiti" +
"rUserAction;\r\n }\r\n function isReadyForReturn(i) {\r\n " + "ngForUserAction;\r\n }\r\n function isReadyForReturn(i) {\r\n " +
" return i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n " + " return i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r" +
" function isWaitingForUserAction(i) {\r\n return i.WaitingF" + "\n function isWaitingForUserAction(i) {\r\n return i.Wait" +
"orUserAction;\r\n }\r\n function getQueryStringParameters() {\r" + "ingForUserAction;\r\n }\r\n function getQueryStringParameters(" +
"\n\r\n if (window.location.search.length === 0)\r\n " + ") {\r\n\r\n if (window.location.search.length === 0)\r\n " +
" return null;\r\n\r\n var params = {};\r\n window.locati" + " return null;\r\n\r\n var params = {};\r\n window.lo" +
"on.search.substr(1).split(\"&\").forEach(function (pair) {\r\n if" + "cation.search.substr(1).split(\"&\").forEach(function (pair) {\r\n " +
" (pair === \"\") return;\r\n var parts = pair.split(\"=\");\r\n " + " if (pair === \"\") return;\r\n var parts = pair.split(\"=\");\r\n " +
" params[parts[0]] = parts[1] && decodeURIComponent(parts[1].replace" + " params[parts[0]] = parts[1] && decodeURIComponent(parts[1].rep" +
"(/\\+/g, \" \"));\r\n });\r\n return params;\r\n " + "lace(/\\+/g, \" \"));\r\n });\r\n return params;\r\n " +
" }\r\n\r\n init();\r\n });\r\n </script>\r\n</body>\r\n</html>"); " }\r\n\r\n init();\r\n });\r\n </script>\r\n</body>\r\n</html>");
} }