Bug Fixes: enrolment, assignment and search order

This commit is contained in:
Gary Sharp
2014-04-22 13:55:46 +10:00
parent 74df073b29
commit 3cf6d5475d
22 changed files with 310 additions and 127 deletions
@@ -114,8 +114,16 @@ namespace Disco.Web.Areas.API.Controllers
}
[DiscoAuthorize(Claims.Device.Actions.AssignUser)]
public virtual ActionResult UpdateAssignedUserId(string id, string AssignedUserId = null, bool redirect = false)
public virtual ActionResult UpdateAssignedUserId(string id, string AssignedUserId = null, string AssignedUserDomain = null, bool redirect = false)
{
if (AssignedUserId != null && !AssignedUserId.Contains('\\'))
{
if (string.IsNullOrWhiteSpace(AssignedUserDomain))
AssignedUserId = string.Format(@"{0}\{1}", ActiveDirectory.Context.PrimaryDomain.NetBiosName, AssignedUserId);
else
AssignedUserId = string.Format(@"{0}\{1}", AssignedUserDomain, AssignedUserId);
}
return Update(id, pAssignedUserId, AssignedUserId, redirect);
}
@@ -361,6 +369,9 @@ namespace Disco.Web.Areas.API.Controllers
[DiscoAuthorize(Claims.Device.Show)]
public virtual ActionResult LastNetworkLogonDate(string id)
{
if (string.IsNullOrWhiteSpace(id))
throw new ArgumentNullException("id", "The Device Serial Number is required");
var device = Database.Devices.Find(id);
if (device == null)
{
@@ -2,6 +2,7 @@
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
@@ -287,7 +288,7 @@ namespace Disco.Web.Areas.API.Controllers
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.UndetectedPages)]
public virtual ActionResult ImporterUndetectedDataIdLookup(string id, string term, int limitCount = 20)
public virtual ActionResult ImporterUndetectedDataIdLookup(string id, string term, int limitCount = ActiveDirectory.DefaultSearchResultLimit)
{
if (!string.IsNullOrEmpty(id) && !string.IsNullOrWhiteSpace(term))
{
@@ -330,7 +331,7 @@ namespace Disco.Web.Areas.API.Controllers
results = Disco.Services.Searching.Search.SearchJobsTable(Database, term, limitCount, false).Items.Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
break;
case DocumentTemplate.DocumentTemplateScopes.User:
results = Disco.Services.Searching.Search.SearchUsers(Database, term, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
results = Disco.Services.Searching.Search.SearchUsers(Database, term, false, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
break;
default:
results = null;
@@ -1,5 +1,6 @@
using Disco.Models.Services.Searching;
using Disco.Services.Authorization;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Searching;
using Disco.Services.Web;
using System;
@@ -13,7 +14,7 @@ namespace Disco.Web.Areas.API.Controllers
public partial class SearchController : AuthorizedDatabaseController
{
[DiscoAuthorizeAny(Claims.Job.Search, Claims.Device.Search, Claims.User.Search)]
public virtual ActionResult QuickQuery(string Term, int Limit = 15)
public virtual ActionResult QuickQuery(string Term, int Limit = ActiveDirectory.DefaultSearchResultLimit)
{
if (string.IsNullOrWhiteSpace(Term))
throw new ArgumentNullException("Term", "The search query term is required");
@@ -36,20 +37,35 @@ namespace Disco.Web.Areas.API.Controllers
break;
case '@': // User Only
if (Authorization.Has(Claims.User.Search))
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), Limit));
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), false, Limit));
break;
default: // Search All
if (Authorization.Has(Claims.Job.Search))
results = results.Concat(Search.SearchJobs(Database, Term, Limit));
if (Authorization.Has(Claims.User.Search))
results = results.Concat(Search.SearchUsers(Database, Term, Limit));
results = results.Concat(Search.SearchUsers(Database, Term, false, Limit));
if (Authorization.Has(Claims.Device.Search))
results = results.Concat(Search.SearchDevices(Database, Term, Limit));
break;
}
results = results.OrderByDescending(i => i.ScoreValue.Score(Term)).Take(Limit);
results = results.OrderByDescending(i => i.ScoreValues.Score(Term)).Take(Limit);
return Json(results, JsonRequestBehavior.AllowGet);
}
[DiscoAuthorize(Claims.User.Search)]
public virtual ActionResult UsersUpstream(string Term, int Limit = 15)
{
if (string.IsNullOrWhiteSpace(Term))
throw new ArgumentNullException("Term", "The search query term is required");
if (Term.Length < 2)
throw new ArgumentException("The search query term must be at least two characters", "Term");
if (Limit < 1)
throw new ArgumentException("The search query limit cannot be less than 1", "Limit");
var results = Search.SearchUsersUpstream(Database, Term, false, Limit);
return Json(results, JsonRequestBehavior.AllowGet);
}
@@ -12,12 +12,6 @@ namespace Disco.Web.Areas.API.Controllers
{
public partial class UserController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.User.Search)]
public virtual ActionResult UpstreamUsers(string term)
{
return Json(Disco.Services.Searching.Search.SearchUsersUpstream(term), JsonRequestBehavior.AllowGet);
}
#region User Attachements
[DiscoAuthorize(Claims.User.ShowAttachments)]
+8 -8
View File
@@ -62,13 +62,13 @@ namespace Disco.Web.Controllers
return View(m);
}
if (Authorization.Has(Claims.Job.Search))
m.Jobs = Services.Searching.Search.SearchJobsTable(Database, term, null, true, searchDetails);
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, null, searchDetails);
m.Devices = Services.Searching.Search.SearchDevices(Database, term, LimitCount: null, SearchDetails: searchDetails);
if (Authorization.Has(Claims.User.Search))
m.Users = Services.Searching.Search.SearchUsers(Database, term);
m.Users = Services.Searching.Search.SearchUsers(Database, term, true, LimitCount: null);
}
else
{
@@ -83,7 +83,7 @@ namespace Disco.Web.Controllers
if (vm != null)
{
m.FriendlyTerm = string.Format("Device Model: {0}", vm.ToString());
m.Devices = Services.Searching.Search.SearchDeviceModel(Database, vm.Id);
m.Devices = Services.Searching.Search.SearchDeviceModel(Database, vm.Id, LimitCount: null);
break;
}
}
@@ -100,7 +100,7 @@ namespace Disco.Web.Controllers
if (dp != null)
{
m.FriendlyTerm = string.Format("Device Profile: {0}", dp.ToString());
m.Devices = Services.Searching.Search.SearchDeviceProfile(Database, dp.Id);
m.Devices = Services.Searching.Search.SearchDeviceProfile(Database, dp.Id, LimitCount: null);
break;
}
}
@@ -117,7 +117,7 @@ namespace Disco.Web.Controllers
if (db != null)
{
m.FriendlyTerm = string.Format("Device Batch: {0}", db.ToString());
m.Devices = Services.Searching.Search.SearchDeviceBatch(Database, db.Id);
m.Devices = Services.Searching.Search.SearchDeviceBatch(Database, db.Id, LimitCount: null);
break;
}
}
@@ -154,7 +154,7 @@ namespace Disco.Web.Controllers
return RedirectToAction(MVC.Job.Show(termInt));
}
}
m.Jobs = Services.Searching.Search.SearchJobsTable(Database, term, null, true, searchDetails);
m.Jobs = Services.Searching.Search.SearchJobsTable(Database, term, LimitCount: null, IncludeJobStatus: true, SearchDetails: searchDetails);
break;
case "users":
Authorization.Require(Claims.User.Search);
@@ -164,7 +164,7 @@ namespace Disco.Web.Controllers
m.ErrorMessage = "A search term of at least two characters is required";
return View(m);
}
m.Users = Services.Searching.Search.SearchUsers(Database, term);
m.Users = Services.Searching.Search.SearchUsers(Database, term, true, LimitCount: null);
if (m.Users.Count == 1)
{
return RedirectToAction(MVC.User.Show(m.Users[0].Id));
+33 -29
View File
@@ -3684,6 +3684,7 @@ namespace Disco.Web.Areas.API.Controllers
{
public readonly string id = "id";
public readonly string AssignedUserId = "AssignedUserId";
public readonly string AssignedUserDomain = "AssignedUserDomain";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateAllowUnauthenticatedEnrol s_params_UpdateAllowUnauthenticatedEnrol = new ActionParamsClass_UpdateAllowUnauthenticatedEnrol();
@@ -3896,15 +3897,16 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
partial void UpdateAssignedUserIdOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string AssignedUserId, bool redirect);
partial void UpdateAssignedUserIdOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string AssignedUserId, string AssignedUserDomain, bool redirect);
public override System.Web.Mvc.ActionResult UpdateAssignedUserId(string id, string AssignedUserId, bool redirect)
public override System.Web.Mvc.ActionResult UpdateAssignedUserId(string id, string AssignedUserId, string AssignedUserDomain, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateAssignedUserId);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "AssignedUserId", AssignedUserId);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "AssignedUserDomain", AssignedUserDomain);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateAssignedUserIdOverride(callInfo, id, AssignedUserId, redirect);
UpdateAssignedUserIdOverride(callInfo, id, AssignedUserId, AssignedUserDomain, redirect);
return callInfo;
}
@@ -9065,6 +9067,12 @@ namespace Disco.Web.Areas.API.Controllers
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.QuickQuery);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UsersUpstream()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UsersUpstream);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public SearchController Actions { get { return MVC.API.Search; } }
@@ -9082,12 +9090,14 @@ namespace Disco.Web.Areas.API.Controllers
public class ActionNamesClass
{
public readonly string QuickQuery = "QuickQuery";
public readonly string UsersUpstream = "UsersUpstream";
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants
{
public const string QuickQuery = "QuickQuery";
public const string UsersUpstream = "UsersUpstream";
}
@@ -9100,6 +9110,15 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Term = "Term";
public readonly string Limit = "Limit";
}
static readonly ActionParamsClass_UsersUpstream s_params_UsersUpstream = new ActionParamsClass_UsersUpstream();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UsersUpstream UsersUpstreamParams { get { return s_params_UsersUpstream; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UsersUpstream
{
public readonly string Term = "Term";
public readonly string Limit = "Limit";
}
static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } }
@@ -9130,6 +9149,17 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
partial void UsersUpstreamOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Term, int Limit);
public override System.Web.Mvc.ActionResult UsersUpstream(string Term, int Limit)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UsersUpstream);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Term", Term);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Limit", Limit);
UsersUpstreamOverride(callInfo, Term, Limit);
return callInfo;
}
}
}
@@ -9564,12 +9594,6 @@ namespace Disco.Web.Areas.API.Controllers
return RedirectToRoutePermanent(callInfo.RouteValueDictionary);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpstreamUsers()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpstreamUsers);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult AttachmentDownload()
@@ -9628,7 +9652,6 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNamesClass
{
public readonly string UpstreamUsers = "UpstreamUsers";
public readonly string AttachmentDownload = "AttachmentDownload";
public readonly string AttachmentThumbnail = "AttachmentThumbnail";
public readonly string AttachmentUpload = "AttachmentUpload";
@@ -9641,7 +9664,6 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants
{
public const string UpstreamUsers = "UpstreamUsers";
public const string AttachmentDownload = "AttachmentDownload";
public const string AttachmentThumbnail = "AttachmentThumbnail";
public const string AttachmentUpload = "AttachmentUpload";
@@ -9652,14 +9674,6 @@ namespace Disco.Web.Areas.API.Controllers
}
static readonly ActionParamsClass_UpstreamUsers s_params_UpstreamUsers = new ActionParamsClass_UpstreamUsers();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpstreamUsers UpstreamUsersParams { get { return s_params_UpstreamUsers; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpstreamUsers
{
public readonly string term = "term";
}
static readonly ActionParamsClass_AttachmentDownload s_params_AttachmentDownload = new ActionParamsClass_AttachmentDownload();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_AttachmentDownload AttachmentDownloadParams { get { return s_params_AttachmentDownload; } }
@@ -9740,16 +9754,6 @@ namespace Disco.Web.Areas.API.Controllers
{
public T4MVC_UserController() : base(Dummy.Instance) { }
partial void UpstreamUsersOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string term);
public override System.Web.Mvc.ActionResult UpstreamUsers(string term)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpstreamUsers);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "term", term);
UpstreamUsersOverride(callInfo, term);
return callInfo;
}
partial void AttachmentDownloadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id);
public override System.Web.Mvc.ActionResult AttachmentDownload(int id)
+1 -1
View File
@@ -126,7 +126,7 @@
.watermark('Search Users')
.focus(function () { $AssignedUserId.select() })
.autocomplete({
source: '@(Url.Action(MVC.API.User.UpstreamUsers()))',
source: '@(Url.Action(MVC.API.Search.UsersUpstream()))',
minLength: 2,
focus: function (e, ui) {
$AssignedUserId.val(ui.item.DisplayName + ' (' + ui.item.Id + ')');
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -494,7 +494,7 @@ WriteLiteral(@"
#line 129 "..\..\Views\Device\AddOffline.cshtml"
Write(Url.Action(MVC.API.User.UpstreamUsers()));
Write(Url.Action(MVC.API.Search.UsersUpstream()));
#line default
@@ -500,7 +500,7 @@
}
@if (Model.Device.CanUpdateAssignment())
{
@Html.ActionLinkSmallButton("Update Assignment", MVC.API.Device.UpdateAssignedUserId(Model.Device.SerialNumber, null, true), "Device_Show_User_Actions_Assign_Button")
@Html.ActionLinkSmallButton("Update Assignment", MVC.API.Device.UpdateAssignedUserId(Model.Device.SerialNumber, null, null, true), "Device_Show_User_Actions_Assign_Button")
<div id="Device_Show_User_Actions_Assign_Dialog" class="dialog" title="Assign this Device?">
<h4><i class="fa fa-info-circle information"></i>&nbsp;Assign to User:</h4>
<br />
@@ -555,7 +555,7 @@
inputUserId = $('#Device_Show_User_Actions_Assign_UserId');
inputUserId.focus(function () { inputUserId.select() })
.autocomplete({
source: '@(Url.Action(MVC.API.User.UpstreamUsers()))',
source: '@(Url.Action(MVC.API.Search.UsersUpstream()))',
minLength: 2,
select: function (e, ui) {
inputUserId.val(ui.item.Id);
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -1901,14 +1901,14 @@ WriteLiteral(" ");
#line hidden
#line 503 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Html.ActionLinkSmallButton("Update Assignment", MVC.API.Device.UpdateAssignedUserId(Model.Device.SerialNumber, null, true), "Device_Show_User_Actions_Assign_Button"));
Write(Html.ActionLinkSmallButton("Update Assignment", MVC.API.Device.UpdateAssignedUserId(Model.Device.SerialNumber, null, null, true), "Device_Show_User_Actions_Assign_Button"));
#line default
#line hidden
#line 503 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line default
@@ -2008,7 +2008,7 @@ WriteLiteral("\r\n \"Assign\": function () {\r\n
#line 558 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Url.Action(MVC.API.User.UpstreamUsers()));
Write(Url.Action(MVC.API.Search.UsersUpstream()));
#line default
@@ -2314,28 +2314,28 @@ WriteLiteral(" <li>\r\n
WriteLiteral(" type=\"radio\"");
WriteAttribute("id", Tuple.Create(" id=\"", 41935), Tuple.Create("\"", 42013)
, Tuple.Create(Tuple.Create("", 41940), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 41940), true)
WriteAttribute("id", Tuple.Create(" id=\"", 41943), Tuple.Create("\"", 42021)
, Tuple.Create(Tuple.Create("", 41948), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 41948), true)
#line 679 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 41987), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
, Tuple.Create(Tuple.Create("", 41995), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 41987), false)
, 41995), false)
);
WriteLiteral("\r\n name=\"Device_Show_Device_Actions_Decomm" +
"ission_Reason\"");
WriteAttribute("value", Tuple.Create(" value=\"", 42109), Tuple.Create("\"", 42143)
WriteAttribute("value", Tuple.Create(" value=\"", 42117), Tuple.Create("\"", 42151)
#line 680 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 42117), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
, Tuple.Create(Tuple.Create("", 42125), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 42117), false)
, 42125), false)
);
WriteLiteral(" ");
@@ -2349,15 +2349,15 @@ WriteLiteral(" ");
#line hidden
WriteLiteral("/>\r\n <label");
WriteAttribute("for", Tuple.Create(" for=\"", 42293), Tuple.Create("\"", 42372)
, Tuple.Create(Tuple.Create("", 42299), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 42299), true)
WriteAttribute("for", Tuple.Create(" for=\"", 42301), Tuple.Create("\"", 42380)
, Tuple.Create(Tuple.Create("", 42307), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 42307), true)
#line 681 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 42346), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
, Tuple.Create(Tuple.Create("", 42354), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 42346), false)
, 42354), false)
);
WriteLiteral(">");