resolves #179: filter noticeboard by job queue
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Jobs.Noticeboards;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web.Areas.Public.Models.UserHeldDevices;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
@@ -10,30 +10,53 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
public partial class HeldDevicesController : DatabaseController
|
||||
{
|
||||
public virtual ActionResult Index(List<int?> DeviceProfileInclude, List<int?> DeviceProfileExclude, List<string> DeviceAddressInclude, List<string> DeviceAddressExclude)
|
||||
public virtual ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude)
|
||||
{
|
||||
IQueryable<Job> query = Database.Jobs;
|
||||
|
||||
if (DeviceProfileInclude != null)
|
||||
query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId));
|
||||
if (DeviceProfileExclude != null)
|
||||
query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId));
|
||||
if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0)
|
||||
{
|
||||
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList();
|
||||
query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0)
|
||||
{
|
||||
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList();
|
||||
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
var query = FilterJobs(Database.Jobs, Database, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude);
|
||||
|
||||
var m = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(query);
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
internal static IQueryable<Job> FilterJobs(IQueryable<Job> query, DiscoDataContext database, string deviceProfileInclude, string deviceProfileExclude, string deviceAddressInclude, string deviceAddressExclude, string jobQueueInclude, string jobQueueExclude)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(deviceProfileInclude))
|
||||
{
|
||||
var include = deviceProfileInclude.Split(',').Select(int.Parse).ToList();
|
||||
query = query.Where(j => include.Contains(j.Device.DeviceProfileId));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(deviceProfileExclude))
|
||||
{
|
||||
var exclude = deviceProfileExclude.Split(',').Select(int.Parse).ToList();
|
||||
query = query.Where(j => !exclude.Contains(j.Device.DeviceProfileId));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(deviceAddressInclude))
|
||||
{
|
||||
var include = deviceAddressInclude.Split(',');
|
||||
var addressIds = database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => include.Contains(a.ShortName)).Select(a => a.Id).ToList();
|
||||
query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(deviceAddressExclude))
|
||||
{
|
||||
var exclude = deviceAddressExclude.Split(',');
|
||||
var addressIds = database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => exclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList();
|
||||
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
if (jobQueueInclude != null)
|
||||
{
|
||||
var include = jobQueueInclude.Split(',').Select(int.Parse).ToList();
|
||||
query = query.Where(j => j.JobQueues.Any(q => q.RemovedDate == null && include.Contains(q.JobQueueId)));
|
||||
}
|
||||
if (jobQueueExclude != null)
|
||||
{
|
||||
var exclude = jobQueueExclude.Split(',').Select(int.Parse).ToList();
|
||||
query = query.Where(j => !j.JobQueues.Any(q => q.RemovedDate == null && exclude.Contains(q.JobQueueId)));
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public virtual ActionResult ReadyForReturnXml()
|
||||
{
|
||||
var readyForReturn = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(Database)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Jobs.Noticeboards;
|
||||
using Disco.Services.Jobs.Noticeboards;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web.Areas.Public.Models.UserHeldDevices;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
@@ -10,24 +8,9 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
public partial class UserHeldDevicesController : DatabaseController
|
||||
{
|
||||
public virtual ActionResult Index(List<int?> DeviceProfileInclude, List<int?> DeviceProfileExclude, List<string> DeviceAddressInclude, List<string> DeviceAddressExclude)
|
||||
public virtual ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude)
|
||||
{
|
||||
IQueryable<Job> query = Database.Jobs;
|
||||
|
||||
if (DeviceProfileInclude != null)
|
||||
query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId));
|
||||
if (DeviceProfileExclude != null)
|
||||
query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId));
|
||||
if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0)
|
||||
{
|
||||
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList();
|
||||
query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0)
|
||||
{
|
||||
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList();
|
||||
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
|
||||
}
|
||||
var query = HeldDevicesController.FilterJobs(Database.Jobs, Database, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude);
|
||||
|
||||
var m = HeldDevicesForUsers.GetHeldDevicesForUsers(query);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{
|
||||
<tr>
|
||||
<td class="id">
|
||||
@item.DeviceComputerNameFriendly
|
||||
@item.DeviceName
|
||||
</td>
|
||||
<td class="description">
|
||||
@if (item.UserId != null)
|
||||
|
||||
@@ -114,7 +114,7 @@ WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 17 "..\..\Areas\Public\Views\HeldDevices\Index.cshtml"
|
||||
Write(item.DeviceComputerNameFriendly);
|
||||
Write(item.DeviceName);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -448,15 +448,15 @@ WriteLiteral("\r\n");
|
||||
#line hidden
|
||||
WriteLiteral(" </td>\r\n <td");
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 3397), Tuple.Create("\"", 3455)
|
||||
, Tuple.Create(Tuple.Create("", 3405), Tuple.Create("timestamp", 3405), true)
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 3381), Tuple.Create("\"", 3439)
|
||||
, Tuple.Create(Tuple.Create("", 3389), Tuple.Create("timestamp", 3389), true)
|
||||
|
||||
#line 81 "..\..\Areas\Public\Views\HeldDevices\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 3414), Tuple.Create<System.Object, System.Int32>(item.IsAlert ? " Alert" : string.Empty
|
||||
, Tuple.Create(Tuple.Create("", 3398), Tuple.Create<System.Object, System.Int32>(item.IsAlert ? " Alert" : string.Empty
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 3414), false)
|
||||
, 3398), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">Since ");
|
||||
@@ -650,15 +650,15 @@ WriteLiteral("\r\n");
|
||||
#line hidden
|
||||
WriteLiteral(" </td>\r\n <td");
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 5022), Tuple.Create("\"", 5080)
|
||||
, Tuple.Create(Tuple.Create("", 5030), Tuple.Create("timestamp", 5030), true)
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 5006), Tuple.Create("\"", 5064)
|
||||
, Tuple.Create(Tuple.Create("", 5014), Tuple.Create("timestamp", 5014), true)
|
||||
|
||||
#line 119 "..\..\Areas\Public\Views\HeldDevices\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 5039), Tuple.Create<System.Object, System.Int32>(item.IsAlert ? " Alert" : string.Empty
|
||||
, Tuple.Create(Tuple.Create("", 5023), Tuple.Create<System.Object, System.Int32>(item.IsAlert ? " Alert" : string.Empty
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 5039), false)
|
||||
, 5023), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">Ready ");
|
||||
|
||||
@@ -353,6 +353,42 @@
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'jobqueueinclude': // FILTER: Job Queue Include
|
||||
var jobQueues = value.split(",").map(function (v) { return parseInt(v); });
|
||||
if (jobQueues.length > 0) {
|
||||
filters.push(function (heldDeviceItem) {
|
||||
// true if any JobQueueId is included
|
||||
if (!heldDeviceItem.JobQueueIds)
|
||||
return false; // not in any queues
|
||||
var include = false;
|
||||
$.each(jobQueues, function (i, v) {
|
||||
if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {
|
||||
include = true;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
return include;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'jobqueueexclude': // FILTER: Job Queue Exclude
|
||||
var jobQueues = value.split(",").map(function (v) { return parseInt(v); });
|
||||
if (jobQueues.length > 0) {
|
||||
filters.push(function (heldDeviceItem) {
|
||||
// true if any JobQueueId is excluded
|
||||
if (!heldDeviceItem.JobQueueIds)
|
||||
return true; // not in any queues
|
||||
var exclude = false;
|
||||
$.each(jobQueues, function (i, v) {
|
||||
if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {
|
||||
exclude = true;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
return !exclude;
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -409,58 +409,88 @@ WriteLiteral(">\r\n <li data-bind=\"css: { alert: IsAlert }\">\r\n
|
||||
"luded\r\n return $.inArray(heldDeviceItem.D" +
|
||||
"eviceProfileId, deviceProfiles) < 0;\r\n });\r\n " +
|
||||
" }\r\n break;\r\n " +
|
||||
" }\r\n });\r\n\r\n if (filters." +
|
||||
"length > 0)\r\n itemFilters = filters;\r\n " +
|
||||
" else\r\n itemFilters = null;\r\n }\r\n " +
|
||||
" }\r\n\r\n function connectionError() {\r\n try {\r\n " +
|
||||
" $(\'body\').addClass(\'status-error\');\r\n } catch (e) {\r" +
|
||||
"\n // Ignore\r\n }\r\n\r\n window.setT" +
|
||||
"imeout(function () {\r\n window.location.reload(true);\r\n " +
|
||||
" }, 10000);\r\n }\r\n\r\n // Helpers\r\n functi" +
|
||||
"on rotateArray(koArray, element) {\r\n var items = koArray();\r\n\r\n " +
|
||||
" if (items.length <= 1)\r\n return 0;\r\n\r\n " +
|
||||
" if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " +
|
||||
" if (findUnsortedArrayTopIndex(items) !== 0)\r\n ko" +
|
||||
"Array.sort(sortFunction);\r\n\r\n // Don\'t rotate if small & sort" +
|
||||
"ed correctly\r\n return;\r\n }\r\n\r\n " +
|
||||
"// Move Last Item to Top\r\n var item = koArray.pop();\r\n " +
|
||||
" koArray.unshift(item);\r\n }\r\n function removeItemFromA" +
|
||||
"rray(koArray, deviceSerialNumber) {\r\n var items = koArray();\r\n " +
|
||||
" for (var i = 0; i < items.length; i++) {\r\n if (i" +
|
||||
"tems[i].DeviceSerialNumber == deviceSerialNumber) {\r\n koA" +
|
||||
"rray.splice(i, 1);\r\n items = koArray();\r\n " +
|
||||
" i--;\r\n }\r\n }\r\n }\r\n " +
|
||||
" function findUnsortedArrayTopIndex(items) {\r\n // Only one Item" +
|
||||
" case \'jobqueueinclude\': // FILTER: Job Queue Include\r\n " +
|
||||
" var jobQueues = value.split(\",\").map(function (v) { " +
|
||||
"return parseInt(v); });\r\n if (jobQueues.length > " +
|
||||
"0) {\r\n filters.push(function (heldDeviceItem)" +
|
||||
" {\r\n // true if any JobQueueId is include" +
|
||||
"d\r\n if (!heldDeviceItem.JobQueueIds)\r\n " +
|
||||
" return false; // not in any queues\r\n " +
|
||||
" var include = false;\r\n " +
|
||||
" $.each(jobQueues, function (i, v) {\r\n " +
|
||||
" if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {\r\n " +
|
||||
" include = true;\r\n " +
|
||||
" return false; // break\r\n " +
|
||||
" }\r\n });\r\n " +
|
||||
" return include;\r\n });\r" +
|
||||
"\n }\r\n break;\r\n " +
|
||||
" case \'jobqueueexclude\': // FILTER: Job Queue Exclude\r\n " +
|
||||
" var jobQueues = value.split(\",\").map(function (v) " +
|
||||
"{ return parseInt(v); });\r\n if (jobQueues.length " +
|
||||
"> 0) {\r\n filters.push(function (heldDeviceIte" +
|
||||
"m) {\r\n // true if any JobQueueId is exclu" +
|
||||
"ded\r\n if (!heldDeviceItem.JobQueueIds)\r\n " +
|
||||
" return true; // not in any queues\r\n " +
|
||||
" var exclude = false;\r\n " +
|
||||
" $.each(jobQueues, function (i, v) {\r\n " +
|
||||
" if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {\r\n " +
|
||||
" exclude = true;\r\n " +
|
||||
" return false; // break\r\n " +
|
||||
" }\r\n });\r\n " +
|
||||
" return !exclude;\r\n })" +
|
||||
";\r\n }\r\n break;\r\n " +
|
||||
" }\r\n });\r\n\r\n if (filt" +
|
||||
"ers.length > 0)\r\n itemFilters = filters;\r\n " +
|
||||
" else\r\n itemFilters = null;\r\n }\r\n " +
|
||||
" }\r\n\r\n function connectionError() {\r\n try {\r\n " +
|
||||
" $(\'body\').addClass(\'status-error\');\r\n } catch (e" +
|
||||
") {\r\n // Ignore\r\n }\r\n\r\n window." +
|
||||
"setTimeout(function () {\r\n window.location.reload(true);\r\n " +
|
||||
" }, 10000);\r\n }\r\n\r\n // Helpers\r\n fu" +
|
||||
"nction rotateArray(koArray, element) {\r\n var items = koArray();\r\n" +
|
||||
"\r\n if (items.length <= 1)\r\n return 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 " +
|
||||
" return i;\r\n }\r\n\r\n return 0;\r\n " +
|
||||
" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem) {\r" +
|
||||
"\n var items = koArray();\r\n var startIndex = findUn" +
|
||||
"sortedArrayTopIndex(items);\r\n for (var i = startIndex; i < items." +
|
||||
"length; i++) {\r\n var s = sortFunction(heldDeviceItem, items[i" +
|
||||
"]);\r\n if (s <= 0)\r\n return i;\r\n " +
|
||||
" }\r\n if (startIndex !== 0) {\r\n for (va" +
|
||||
"r i = 0; i < startIndex; i++) {\r\n var s = sortFunction(he" +
|
||||
"ldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
|
||||
" return i;\r\n }\r\n return startInd" +
|
||||
"ex;\r\n } else {\r\n return -1;\r\n }" +
|
||||
"\r\n }\r\n function sortFunction(l, r) {\r\n retu" +
|
||||
"rn l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase() ? 0 : " +
|
||||
"(l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ? -1 : 1)" +
|
||||
"\r\n }\r\n function isInProcess(i) {\r\n return !" +
|
||||
"i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n functio" +
|
||||
"n isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingFo" +
|
||||
"rUserAction;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " +
|
||||
" return i.WaitingForUserAction;\r\n }\r\n functi" +
|
||||
"on getQueryStringParameters() {\r\n\r\n if (window.location.search.le" +
|
||||
"ngth === 0)\r\n return null;\r\n\r\n var params = {}" +
|
||||
";\r\n window.location.search.substr(1).split(\"&\").forEach(function " +
|
||||
"(pair) {\r\n if (pair === \"\") return;\r\n var " +
|
||||
"parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] && dec" +
|
||||
"odeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " +
|
||||
" return params;\r\n }\r\n\r\n init();\r\n });\r\n </sc" +
|
||||
"ript>\r\n</body>\r\n</html>\r\n");
|
||||
" if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " +
|
||||
" if (findUnsortedArrayTopIndex(items) !== 0)\r\n " +
|
||||
" koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate if 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 " +
|
||||
" koArray.unshift(item);\r\n }\r\n function removeItemF" +
|
||||
"romArray(koArray, deviceSerialNumber) {\r\n var items = koArray();\r" +
|
||||
"\n for (var i = 0; i < items.length; i++) {\r\n i" +
|
||||
"f (items[i].DeviceSerialNumber == deviceSerialNumber) {\r\n " +
|
||||
" koArray.splice(i, 1);\r\n items = koArray();\r\n " +
|
||||
" i--;\r\n }\r\n }\r\n }\r\n " +
|
||||
" function findUnsortedArrayTopIndex(items) {\r\n // Only one " +
|
||||
"Item\r\n if (items.length <= 1)\r\n return 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 " +
|
||||
" return i;\r\n }\r\n\r\n return 0;\r\n " +
|
||||
" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem" +
|
||||
") {\r\n var items = koArray();\r\n var startIndex = fi" +
|
||||
"ndUnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < it" +
|
||||
"ems.length; i++) {\r\n var s = sortFunction(heldDeviceItem, ite" +
|
||||
"ms[i]);\r\n if (s <= 0)\r\n return i;\r\n " +
|
||||
" }\r\n if (startIndex !== 0) {\r\n for" +
|
||||
" (var i = 0; i < startIndex; i++) {\r\n var s = sortFunctio" +
|
||||
"n(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
|
||||
" return i;\r\n }\r\n return star" +
|
||||
"tIndex;\r\n } else {\r\n return -1;\r\n " +
|
||||
" }\r\n }\r\n function sortFunction(l, r) {\r\n " +
|
||||
"return l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase() ? " +
|
||||
"0 : (l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ? -1 " +
|
||||
": 1)\r\n }\r\n function isInProcess(i) {\r\n retu" +
|
||||
"rn !i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n fun" +
|
||||
"ction isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.Waiti" +
|
||||
"ngForUserAction;\r\n }\r\n function isWaitingForUserAction(i) " +
|
||||
"{\r\n return i.WaitingForUserAction;\r\n }\r\n fu" +
|
||||
"nction getQueryStringParameters() {\r\n\r\n if (window.location.searc" +
|
||||
"h.length === 0)\r\n return null;\r\n\r\n var params " +
|
||||
"= {};\r\n window.location.search.substr(1).split(\"&\").forEach(funct" +
|
||||
"ion (pair) {\r\n if (pair === \"\") return;\r\n " +
|
||||
"var parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] &&" +
|
||||
" decodeURIComponent(parts[1].replace(/\\+/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");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,6 +353,42 @@
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'jobqueueinclude': // FILTER: Job Queue Include
|
||||
var jobQueues = value.split(",").map(function (v) { return parseInt(v); });
|
||||
if (jobQueues.length > 0) {
|
||||
filters.push(function (heldDeviceItem) {
|
||||
// true if any JobQueueId is included
|
||||
if (!heldDeviceItem.JobQueueIds)
|
||||
return false; // not in any queues
|
||||
var include = false;
|
||||
$.each(jobQueues, function (i, v) {
|
||||
if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {
|
||||
include = true;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
return include;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'jobqueueexclude': // FILTER: Job Queue Exclude
|
||||
var jobQueues = value.split(",").map(function (v) { return parseInt(v); });
|
||||
if (jobQueues.length > 0) {
|
||||
filters.push(function (heldDeviceItem) {
|
||||
// true if any JobQueueId is excluded
|
||||
if (!heldDeviceItem.JobQueueIds)
|
||||
return true; // not in any queues
|
||||
var exclude = false;
|
||||
$.each(jobQueues, function (i, v) {
|
||||
if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {
|
||||
exclude = true;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
return !exclude;
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -408,58 +408,88 @@ WriteLiteral(">\r\n <li data-bind=\"css: { alert: IsAlert }\">\r\n
|
||||
" // true if DeviceProfileId is excluded\r\n " +
|
||||
" return $.inArray(heldDeviceItem.DeviceProfileId, deviceProfiles) < 0;\r\n " +
|
||||
" });\r\n }\r\n " +
|
||||
" break;\r\n }\r\n }" +
|
||||
");\r\n\r\n if (filters.length > 0)\r\n itemF" +
|
||||
"ilters = filters;\r\n else\r\n itemFilters" +
|
||||
" = null;\r\n }\r\n }\r\n\r\n function connectionErr" +
|
||||
"or() {\r\n try {\r\n $(\'body\').addClass(\'status-er" +
|
||||
"ror\');\r\n } catch (e) {\r\n // Ignore\r\n " +
|
||||
" }\r\n\r\n window.setTimeout(function () {\r\n " +
|
||||
"window.location.reload(true);\r\n }, 10000);\r\n }\r\n\r\n " +
|
||||
" // Helpers\r\n function rotateArray(koArray, element) {\r\n " +
|
||||
" var items = koArray();\r\n\r\n if (items.length <= 1)\r\n " +
|
||||
" return 0;\r\n\r\n if (element.height() < (element.par" +
|
||||
"ent().height() - 30)) {\r\n\r\n if (findUnsortedArrayTopIndex(ite" +
|
||||
"ms) !== 0)\r\n koArray.sort(sortFunction);\r\n\r\n " +
|
||||
" // Don\'t rotate if 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 koArray.unshift(item);\r\n }" +
|
||||
"\r\n function removeItemFromArray(koArray, UserId) {\r\n v" +
|
||||
"ar items = koArray();\r\n for (var i = 0; i < items.length; i++) {\r" +
|
||||
"\n if (items[i].UserId == UserId) {\r\n k" +
|
||||
"oArray.splice(i, 1);\r\n items = koArray();\r\n " +
|
||||
" i--;\r\n }\r\n }\r\n }\r\n " +
|
||||
" function findUnsortedArrayTopIndex(items) {\r\n // Only one It" +
|
||||
"em\r\n if (items.length <= 1)\r\n return 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 " +
|
||||
" return i;\r\n }\r\n\r\n return 0;\r\n " +
|
||||
" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem) " +
|
||||
"{\r\n var items = koArray();\r\n var startIndex = find" +
|
||||
"UnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < item" +
|
||||
"s.length; i++) {\r\n var s = sortFunction(heldDeviceItem, items" +
|
||||
"[i]);\r\n if (s <= 0)\r\n return i;\r\n " +
|
||||
" }\r\n if (startIndex !== 0) {\r\n for (" +
|
||||
"var i = 0; i < startIndex; i++) {\r\n var s = sortFunction(" +
|
||||
"heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
|
||||
" return i;\r\n }\r\n return startI" +
|
||||
"ndex;\r\n } else {\r\n return -1;\r\n " +
|
||||
" }\r\n }\r\n function sortFunction(l, r) {\r\n re" +
|
||||
"turn l.UserIdFriendly.toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : (l.U" +
|
||||
"serIdFriendly.toLowerCase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n " +
|
||||
" }\r\n function isInProcess(i) {\r\n return !i.ReadyFor" +
|
||||
"Return && !i.WaitingForUserAction;\r\n }\r\n function isReadyF" +
|
||||
"orReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingForUserActio" +
|
||||
"n;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " +
|
||||
" return i.WaitingForUserAction;\r\n }\r\n function getQuer" +
|
||||
"yStringParameters() {\r\n\r\n if (window.location.search.length === 0" +
|
||||
")\r\n return null;\r\n\r\n var params = {};\r\n " +
|
||||
" window.location.search.substr(1).split(\"&\").forEach(function (pair) {\r\n" +
|
||||
" if (pair === \"\") return;\r\n var parts = pa" +
|
||||
"ir.split(\"=\");\r\n params[parts[0]] = parts[1] && decodeURIComp" +
|
||||
"onent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n retur" +
|
||||
"n params;\r\n }\r\n\r\n init();\r\n });\r\n </script>\r\n</b" +
|
||||
"ody>\r\n</html>\r\n");
|
||||
" break;\r\n case \'jobqueueinclud" +
|
||||
"e\': // FILTER: Job Queue Include\r\n var jobQueues " +
|
||||
"= value.split(\",\").map(function (v) { return parseInt(v); });\r\n " +
|
||||
" if (jobQueues.length > 0) {\r\n " +
|
||||
"filters.push(function (heldDeviceItem) {\r\n " +
|
||||
" // true if any JobQueueId is included\r\n " +
|
||||
" if (!heldDeviceItem.JobQueueIds)\r\n r" +
|
||||
"eturn false; // not in any queues\r\n var i" +
|
||||
"nclude = false;\r\n $.each(jobQueues, funct" +
|
||||
"ion (i, v) {\r\n if ($.inArray(v, heldD" +
|
||||
"eviceItem.JobQueueIds) >= 0) {\r\n " +
|
||||
"include = true;\r\n return false; /" +
|
||||
"/ break\r\n }\r\n " +
|
||||
" });\r\n return include;\r\n " +
|
||||
" });\r\n }\r\n " +
|
||||
" break;\r\n case \'jobqueueexcl" +
|
||||
"ude\': // FILTER: Job Queue Exclude\r\n var jobQueue" +
|
||||
"s = value.split(\",\").map(function (v) { return parseInt(v); });\r\n " +
|
||||
" if (jobQueues.length > 0) {\r\n " +
|
||||
" filters.push(function (heldDeviceItem) {\r\n " +
|
||||
" // true if any JobQueueId is excluded\r\n " +
|
||||
" if (!heldDeviceItem.JobQueueIds)\r\n " +
|
||||
" return true; // not in any queues\r\n var " +
|
||||
"exclude = false;\r\n $.each(jobQueues, func" +
|
||||
"tion (i, v) {\r\n if ($.inArray(v, held" +
|
||||
"DeviceItem.JobQueueIds) >= 0) {\r\n " +
|
||||
" exclude = true;\r\n return false; " +
|
||||
"// break\r\n }\r\n " +
|
||||
" });\r\n return !exclude;\r\n" +
|
||||
" });\r\n }\r\n " +
|
||||
" break;\r\n }\r\n " +
|
||||
" });\r\n\r\n if (filters.length > 0)\r\n i" +
|
||||
"temFilters = filters;\r\n else\r\n itemFil" +
|
||||
"ters = null;\r\n }\r\n }\r\n\r\n function connectio" +
|
||||
"nError() {\r\n try {\r\n $(\'body\').addClass(\'statu" +
|
||||
"s-error\');\r\n } catch (e) {\r\n // Ignore\r\n " +
|
||||
" }\r\n\r\n window.setTimeout(function () {\r\n " +
|
||||
" window.location.reload(true);\r\n }, 10000);\r\n }\r\n\r\n" +
|
||||
" // Helpers\r\n function rotateArray(koArray, element) {\r\n " +
|
||||
" var items = koArray();\r\n\r\n if (items.length <= 1)\r\n" +
|
||||
" return 0;\r\n\r\n if (element.height() < (element" +
|
||||
".parent().height() - 30)) {\r\n\r\n if (findUnsortedArrayTopIndex" +
|
||||
"(items) !== 0)\r\n koArray.sort(sortFunction);\r\n\r\n " +
|
||||
" // Don\'t rotate if small & sorted correctly\r\n retu" +
|
||||
"rn;\r\n }\r\n\r\n // Move Last Item to Top\r\n " +
|
||||
" var item = koArray.pop();\r\n koArray.unshift(item);\r\n " +
|
||||
" }\r\n function removeItemFromArray(koArray, UserId) {\r\n " +
|
||||
" var items = koArray();\r\n for (var i = 0; i < items.length; i++" +
|
||||
") {\r\n if (items[i].UserId == UserId) {\r\n " +
|
||||
" koArray.splice(i, 1);\r\n items = koArray();\r\n " +
|
||||
" i--;\r\n }\r\n }\r\n }\r\n " +
|
||||
" function findUnsortedArrayTopIndex(items) {\r\n // Only on" +
|
||||
"e Item\r\n if (items.length <= 1)\r\n return 0;\r\n\r" +
|
||||
"\n for (var i = 1; i < items.length; i++) {\r\n v" +
|
||||
"ar s = sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " +
|
||||
" return i;\r\n }\r\n\r\n return 0;\r" +
|
||||
"\n }\r\n function findSortedInsertIndex(koArray, heldDeviceIt" +
|
||||
"em) {\r\n var items = koArray();\r\n var startIndex = " +
|
||||
"findUnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < " +
|
||||
"items.length; i++) {\r\n var s = sortFunction(heldDeviceItem, i" +
|
||||
"tems[i]);\r\n if (s <= 0)\r\n return i;\r\n " +
|
||||
" }\r\n if (startIndex !== 0) {\r\n f" +
|
||||
"or (var i = 0; i < startIndex; i++) {\r\n var s = sortFunct" +
|
||||
"ion(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
|
||||
" return i;\r\n }\r\n return st" +
|
||||
"artIndex;\r\n } else {\r\n return -1;\r\n " +
|
||||
" }\r\n }\r\n function sortFunction(l, r) {\r\n " +
|
||||
" return l.UserIdFriendly.toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : " +
|
||||
"(l.UserIdFriendly.toLowerCase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n " +
|
||||
" }\r\n function isInProcess(i) {\r\n return !i.Read" +
|
||||
"yForReturn && !i.WaitingForUserAction;\r\n }\r\n function isRe" +
|
||||
"adyForReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingForUserA" +
|
||||
"ction;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " +
|
||||
" return i.WaitingForUserAction;\r\n }\r\n function get" +
|
||||
"QueryStringParameters() {\r\n\r\n if (window.location.search.length =" +
|
||||
"== 0)\r\n return null;\r\n\r\n var params = {};\r\n " +
|
||||
" window.location.search.substr(1).split(\"&\").forEach(function (pair)" +
|
||||
" {\r\n if (pair === \"\") return;\r\n var parts " +
|
||||
"= pair.split(\"=\");\r\n params[parts[0]] = parts[1] && decodeURI" +
|
||||
"Component(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n r" +
|
||||
"eturn params;\r\n }\r\n\r\n init();\r\n });\r\n </script>\r" +
|
||||
"\n</body>\r\n</html>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user