From df721d7d6ebd9ea6e5c0551b3ad37a43d128ad15 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Thu, 19 Apr 2018 17:06:58 +1000 Subject: [PATCH] Searching: Add detail to device search results --- .../Searching/DeviceSearchResultItem.cs | 2 +- Disco.Services/Searching/Search.cs | 2 +- .../Scripts/Modules/Disco-DataTableHelpers.js | 9 +- .../Modules/Disco-DataTableHelpers.min.js | 2 +- .../disco.datatablehelpers.js | 30 +++- .../Scripts/Modules/Knockout.min.js | 2 +- Disco.Web/Views/Device/_DeviceTable.cshtml | 32 ++-- .../Views/Device/_DeviceTable.generated.cs | 150 ++++++++---------- 8 files changed, 118 insertions(+), 111 deletions(-) diff --git a/Disco.Models/Services/Searching/DeviceSearchResultItem.cs b/Disco.Models/Services/Searching/DeviceSearchResultItem.cs index c0cd6783..23fd0db4 100644 --- a/Disco.Models/Services/Searching/DeviceSearchResultItem.cs +++ b/Disco.Models/Services/Searching/DeviceSearchResultItem.cs @@ -40,7 +40,7 @@ namespace Disco.Models.Services.Searching public string AssignedUserId { get; set; } public string ComputerName { get; set; } public string DeviceModelDescription { get; set; } - public string DeviceProfileDescription { get; set; } + public string DeviceProfileName { get; set; } public string DeviceBatchName { get; set; } public int JobCount { get; set; } public DateTime? DecommissionedDate { get; set; } diff --git a/Disco.Services/Searching/Search.cs b/Disco.Services/Searching/Search.cs index 8e10e4f5..269d8fa5 100644 --- a/Disco.Services/Searching/Search.cs +++ b/Disco.Services/Searching/Search.cs @@ -301,7 +301,7 @@ namespace Disco.Services.Searching AssetNumber = d.AssetNumber, ComputerName = d.DeviceDomainId, DeviceModelDescription = d.DeviceModel.Description, - DeviceProfileDescription = d.DeviceProfile.Description, + DeviceProfileName = d.DeviceProfile.Name, DeviceBatchName = d.DeviceBatch.Name, DecommissionedDate = d.DecommissionedDate, AssignedUserId = d.AssignedUserId, diff --git a/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.js b/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.js index 2ce7aa71..8f9f7067 100644 --- a/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.js +++ b/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.js @@ -95,18 +95,21 @@ "bSort": true, "bInfo": false, "bAutoWidth": false, + "aoColumnDefs": [ + { 'aTargets': ['date'], 'sSortDataType': 'disco_datetime', 'sType': 'disco_datetime' } + ], "aaSorting": [], "oLanguage": { "sSearch": "Filter:" } }; - var $dataTable = $table.dataTable(dataTableOptions); - - // Contains Decommissioned Devces? + // Contains Decommissioned Devices? var $tbody = $table.children('tbody'); var $decommissionedDevices = $tbody.children('tr.decommissioned'); + var $dataTable = $table.dataTable(dataTableOptions); + if ($decommissionedDevices.length > 0) { var wrapper = $(this).closest('.dataTables_wrapper'); diff --git a/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.min.js b/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.min.js index be1b1b13..de4a591b 100644 --- a/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.min.js +++ b/Disco.Web/ClientSource/Scripts/Modules/Disco-DataTableHelpers.min.js @@ -1 +1 @@ -(function(n,t,i){var r=[];i(function(){function t(){var t=i(this).closest(".dataTables_wrapper");t.length>0&&n.setTimeout(function(){var e=i(n),o=t.height(),r=t.offset(),u=e.scrollTop(),s=e.height(),h=u-r.top,f;h>0?i("html").animate({scrollTop:r.top},125):(f=(u+s-(o+r.top))*-1,f>0&&(o>s?i("html").animate({scrollTop:r.top},125):i("html").animate({scrollTop:u+f},125)))},1)}i("table.jobTable").each(function(){var u=i(this),h=!1,l=u.hasClass("enablePaging"),a=u.hasClass("enableFilter"),v=u.find("tr").length>20,y={bPaginate:l,sPaginationType:"full_numbers",bLengthChange:v,iDisplayLength:20,bFilter:a,bSort:!0,bInfo:!1,bAutoWidth:!1,aoColumnDefs:[{aTargets:["dates"],sSortDataType:"disco_datetime",sType:"disco_datetime"}],aaSorting:[],oLanguage:{sSearch:"Filter:"},fnDrawCallback:function(){h?t.apply(u):h=!0}},p=u.dataTable(y),c,o,f,e,n,s;if(u.hasClass("hideStatusClosed")&&(c=u.children("tbody"),o=c.children('tr[data-status="Closed"]'),o.length>0)){f=i(this).closest(".dataTables_wrapper");e=f;f.parent(".jobTable").length>0&&(e=f.parent());n=e.prev();n.length>0&&(n.is("h1")||n.is("h2")||n.is("h3"))?n.data("dataTable_originalContent",n.html()).text("Active "+n.text()):n=null;s=e.find("div.allClosed_container");s.length>0?(u.hide(),f.find(".dataTables_filter").hide()):i('').text("Show Closed Jobs ("+o.length+")").appendTo(e);e.on("click","a.dataTables_showStatusClosed",function(){return u.show(),f.find(".dataTables_filter").show(),u.removeClass("hideStatusClosed"),s.remove(),i(this).remove(),n&&n.html(n.data("dataTable_originalContent")),t.apply(u[0]),!1})}r.push(this)});i("table.deviceTable").each(function(){var n=i(this),t=n.find("tr").length>20,u={bPaginate:t,sPaginationType:"full_numbers",bLengthChange:t,iDisplayLength:20,bFilter:!0,bSort:!0,bInfo:!1,bAutoWidth:!1,aaSorting:[],oLanguage:{sSearch:"Filter:"}};n.dataTable(u);r.push(this)});i("table.userTable").each(function(){var n=i(this),t=n.find("tr").length>20,u={bPaginate:t,sPaginationType:"full_numbers",bLengthChange:t,iDisplayLength:20,bFilter:!0,bSort:!0,bInfo:!1,bAutoWidth:!1,aaSorting:[],oLanguage:{sSearch:"Filter:"}};n.dataTable(u);r.push(this)})})})(window,document,$); \ No newline at end of file +(function(n,t,i){var r=[];i(function(){function t(){var t=i(this).closest(".dataTables_wrapper");t.length>0&&n.setTimeout(function(){var e=i(n),o=t.height(),r=t.offset(),u=e.scrollTop(),s=e.height(),h=u-r.top,f;h>0?i("html").animate({scrollTop:r.top},125):(f=(u+s-(o+r.top))*-1,f>0&&(o>s?i("html").animate({scrollTop:r.top},125):i("html").animate({scrollTop:u+f},125)))},1)}i("table.jobTable").each(function(){var u=i(this),h=!1,l=u.hasClass("enablePaging"),a=u.hasClass("enableFilter"),v=u.find("tr").length>20,y={bPaginate:l,sPaginationType:"full_numbers",bLengthChange:v,iDisplayLength:20,bFilter:a,bSort:!0,bInfo:!1,bAutoWidth:!1,aoColumnDefs:[{aTargets:["dates"],sSortDataType:"disco_datetime",sType:"disco_datetime"}],aaSorting:[],oLanguage:{sSearch:"Filter:"},fnDrawCallback:function(){h?t.apply(u):h=!0}},p=u.dataTable(y),c,o,f,e,n,s;if(u.hasClass("hideStatusClosed")&&(c=u.children("tbody"),o=c.children('tr[data-status="Closed"]'),o.length>0)){f=i(this).closest(".dataTables_wrapper");e=f;f.parent(".jobTable").length>0&&(e=f.parent());n=e.prev();n.length>0&&(n.is("h1")||n.is("h2")||n.is("h3"))?n.data("dataTable_originalContent",n.html()).text("Active "+n.text()):n=null;s=e.find("div.allClosed_container");s.length>0?(u.hide(),f.find(".dataTables_filter").hide()):i('').text("Show Closed Jobs ("+o.length+")").appendTo(e);e.on("click","a.dataTables_showStatusClosed",function(){return u.show(),f.find(".dataTables_filter").show(),u.removeClass("hideStatusClosed"),s.remove(),i(this).remove(),n&&n.html(n.data("dataTable_originalContent")),t.apply(u[0]),!1})}r.push(this)});i("table.deviceTable").each(function(){var n=i(this),u=n.find("tr").length>20,o={bPaginate:u,sPaginationType:"full_numbers",bLengthChange:u,iDisplayLength:20,bFilter:!0,bSort:!0,bInfo:!1,bAutoWidth:!1,aoColumnDefs:[{aTargets:["date"],sSortDataType:"disco_datetime",sType:"disco_datetime"}],aaSorting:[],oLanguage:{sSearch:"Filter:"}},s=n.children("tbody"),f=s.children("tr.decommissioned"),c=n.dataTable(o);if(f.length>0){var e=i(this).closest(".dataTables_wrapper"),h=i('