Update #9: by default, hide decommissioned devices from search
This commit is contained in:
@@ -261,7 +261,7 @@ namespace Disco.Services.Searching
|
||||
#endregion
|
||||
|
||||
#region Devices
|
||||
public static List<DeviceSearchResultItem> SearchDevices(DiscoDataContext Database, string Term, int? LimitCount = ActiveDirectory.DefaultSearchResultLimit, bool SearchDetails = false)
|
||||
public static List<DeviceSearchResultItem> SearchDevices(DiscoDataContext Database, string Term, int? LimitCount = ActiveDirectory.DefaultSearchResultLimit, bool SearchDetails = false, bool includeDecommissioned = false)
|
||||
{
|
||||
IQueryable<Device> query;
|
||||
|
||||
@@ -269,7 +269,9 @@ namespace Disco.Services.Searching
|
||||
|
||||
if (SearchDetails)
|
||||
{
|
||||
query = Database.Devices.Where(d =>
|
||||
query = Database.Devices
|
||||
.Where(d => includeDecommissioned || d.DecommissionedDate == null)
|
||||
.Where(d =>
|
||||
d.AssetNumber.Contains(Term) ||
|
||||
d.DeviceDomainId.Contains(Term) ||
|
||||
d.SerialNumber.Contains(Term) ||
|
||||
@@ -280,12 +282,15 @@ namespace Disco.Services.Searching
|
||||
}
|
||||
else
|
||||
{
|
||||
query = Database.Devices.Where(d =>
|
||||
query = Database.Devices
|
||||
.Where(d => includeDecommissioned || d.DecommissionedDate == null)
|
||||
.Where(d =>
|
||||
d.AssetNumber.Contains(Term) ||
|
||||
d.DeviceDomainId.Contains(Term) ||
|
||||
d.SerialNumber.Contains(Term) ||
|
||||
d.Location.Contains(Term) ||
|
||||
Term.Contains(d.SerialNumber));
|
||||
Term.Contains(d.SerialNumber)
|
||||
);
|
||||
}
|
||||
|
||||
return query
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Disco.Web.Controllers
|
||||
{
|
||||
#region Query
|
||||
[DiscoAuthorizeAny(Claims.Job.Search, Claims.Device.Search, Claims.User.Search)]
|
||||
public virtual ActionResult Query(string term, string limit = null, bool searchDetails = false)
|
||||
public virtual ActionResult Query(string term, string limit = null, bool searchDetails = false, bool includeDecommissioned = false)
|
||||
{
|
||||
term = term.Trim();
|
||||
int termInt;
|
||||
@@ -66,7 +66,7 @@ namespace Disco.Web.Controllers
|
||||
m.Jobs = Services.Searching.Search.SearchJobsTable(Database, term, LimitCount: null, IncludeJobStatus: true, SearchDetails: searchDetails);
|
||||
|
||||
if (Authorization.Has(Claims.Device.Search))
|
||||
m.Devices = Services.Searching.Search.SearchDevices(Database, term, LimitCount: null, SearchDetails: searchDetails);
|
||||
m.Devices = Services.Searching.Search.SearchDevices(Database, term, LimitCount: null, SearchDetails: searchDetails, includeDecommissioned: includeDecommissioned);
|
||||
|
||||
if (Authorization.Has(Claims.User.Search))
|
||||
m.Users = Services.Searching.Search.SearchUsers(Database, term, true, LimitCount: null);
|
||||
@@ -134,7 +134,7 @@ namespace Disco.Web.Controllers
|
||||
m.ErrorMessage = "A search term of at least two characters is required";
|
||||
return View(m);
|
||||
}
|
||||
m.Devices = Services.Searching.Search.SearchDevices(Database, term, null, searchDetails);
|
||||
m.Devices = Services.Searching.Search.SearchDevices(Database, term, null, searchDetails, includeDecommissioned);
|
||||
if (m.Devices.Count == 1)
|
||||
{
|
||||
return RedirectToAction(MVC.Device.Show(m.Devices[0].Id));
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Disco.Web.Controllers
|
||||
public readonly string term = "term";
|
||||
public readonly string limit = "limit";
|
||||
public readonly string searchDetails = "searchDetails";
|
||||
public readonly string includeDecommissioned = "includeDecommissioned";
|
||||
}
|
||||
static readonly ViewsClass s_views = new ViewsClass();
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
@@ -123,16 +124,17 @@ namespace Disco.Web.Controllers
|
||||
public T4MVC_SearchController() : base(Dummy.Instance) { }
|
||||
|
||||
[NonAction]
|
||||
partial void QueryOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string term, string limit, bool searchDetails);
|
||||
partial void QueryOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string term, string limit, bool searchDetails, bool includeDecommissioned);
|
||||
|
||||
[NonAction]
|
||||
public override System.Web.Mvc.ActionResult Query(string term, string limit, bool searchDetails)
|
||||
public override System.Web.Mvc.ActionResult Query(string term, string limit, bool searchDetails, bool includeDecommissioned)
|
||||
{
|
||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Query);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "term", term);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "limit", limit);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "searchDetails", searchDetails);
|
||||
QueryOverride(callInfo, term, limit, searchDetails);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "includeDecommissioned", includeDecommissioned);
|
||||
QueryOverride(callInfo, term, limit, searchDetails, includeDecommissioned);
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
if (Model == "jobs" || Model == "devices")
|
||||
{
|
||||
<br />
|
||||
<input type="checkbox" name="searchDetails" id="searchDetails" value="true" /><label
|
||||
for="searchDetails">Search Details</label>
|
||||
<input type="checkbox" name="searchDetails" id="searchDetails" value="true" /><label for="searchDetails">Search Details</label>
|
||||
}
|
||||
if (Model == "devices")
|
||||
{
|
||||
<br />
|
||||
<input type="checkbox" name="includeDecommissioned" id="includeDecommissioned" value="true" /><label for="includeDecommissioned">Include Decommissioned</label>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
|
||||
@@ -131,10 +131,43 @@ WriteLiteral(" value=\"true\"");
|
||||
|
||||
WriteLiteral(" />");
|
||||
|
||||
WriteLiteral("<label\r\n for=\"searchDetails\">Search Details</label>\r\n");
|
||||
WriteLiteral("<label");
|
||||
|
||||
WriteLiteral(" for=\"searchDetails\"");
|
||||
|
||||
WriteLiteral(">Search Details</label>\r\n");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Shared\_SearchDialog.cshtml"
|
||||
#line 20 "..\..\Views\Shared\_SearchDialog.cshtml"
|
||||
}
|
||||
if (Model == "devices")
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <br />\r\n");
|
||||
|
||||
WriteLiteral(" <input");
|
||||
|
||||
WriteLiteral(" type=\"checkbox\"");
|
||||
|
||||
WriteLiteral(" name=\"includeDecommissioned\"");
|
||||
|
||||
WriteLiteral(" id=\"includeDecommissioned\"");
|
||||
|
||||
WriteLiteral(" value=\"true\"");
|
||||
|
||||
WriteLiteral(" />");
|
||||
|
||||
WriteLiteral("<label");
|
||||
|
||||
WriteLiteral(" for=\"includeDecommissioned\"");
|
||||
|
||||
WriteLiteral(">Include Decommissioned</label>\r\n");
|
||||
|
||||
|
||||
#line 25 "..\..\Views\Shared\_SearchDialog.cshtml"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +194,7 @@ WriteLiteral(">\r\n $(function () {\r\n $(\'#searchDia
|
||||
"watermark(\'Search\').focus();\r\n });\r\n </script>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 35 "..\..\Views\Shared\_SearchDialog.cshtml"
|
||||
#line 39 "..\..\Views\Shared\_SearchDialog.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
|
||||
Reference in New Issue
Block a user