Feature: User Create Job where Multiple Devices

This commit is contained in:
Gary Sharp
2013-06-24 19:03:35 +10:00
parent deb1f1c925
commit d52d4b6164
6 changed files with 780 additions and 376 deletions
@@ -15,11 +15,10 @@
}
}
// Create Job Button
$('#buttonCreateJob').click(function () {
var $this = $(this);
var href = $this.attr('href');
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
}
document.DiscoFunctions.CreateOpenJobDialog = function (url) {
createJobDialog = $('<div>').attr('id', 'createJobDialog').width('100%').height('100%').appendTo(document.body);
createJobDialog.dialog({
@@ -38,9 +37,17 @@
buttons: {}
});
var iframe = $('<iframe>').attr({ 'src': href }).width('100%').height('100%').css('border', 'none').appendTo(createJobDialog);
var iframe = $('<iframe>').attr({ 'src': url }).width('100%').height('100%').css('border', 'none').appendTo(createJobDialog);
createJobDialog[0].discoDialogMethods = dialogMethods;
}
// Create Job Button
$('#buttonCreateJob').click(function () {
var $this = $(this);
var href = $this.attr('href');
document.DiscoFunctions.CreateOpenJobDialog(href);
return false;
});
@@ -1,2 +1,2 @@
(function(n,t,i){n(function(){var r=null,u={close:function(){r.dialog("close")},setButtons:function(n){r&&r.dialog("option","buttons",n)}};n("#buttonCreateJob").click(function(){var f=n(this),e=f.attr("href"),o;return r=n("<div>").attr("id","createJobDialog").width("100%").height("100%").appendTo(i.body),r.dialog({resizable:!1,draggable:!1,modal:!0,autoOpen:!0,title:"Create Job",width:850,height:n(t).height()-50,close:function(){r.find("iframe").attr("src","about:blank"),r.dialog("destroy").remove(),r=null},buttons:{}}),o=n("<iframe>").attr({src:e}).width("100%").height("100%").css("border","none").appendTo(r),r[0].discoDialogMethods=u,!1})})})($,window,document);
(function(n,t,i){n(function(){var r=null,u={close:function(){r.dialog("close")},setButtons:function(n){r&&r.dialog("option","buttons",n)}};i.DiscoFunctions||(i.DiscoFunctions={}),i.DiscoFunctions.CreateOpenJobDialog=function(f){r=n("<div>").attr("id","createJobDialog").width("100%").height("100%").appendTo(i.body),r.dialog({resizable:!1,draggable:!1,modal:!0,autoOpen:!0,title:"Create Job",width:850,height:n(t).height()-50,close:function(){r.find("iframe").attr("src","about:blank"),r.dialog("destroy").remove(),r=null},buttons:{}});var e=n("<iframe>").attr({src:f}).width("100%").height("100%").css("border","none").appendTo(r);r[0].discoDialogMethods=u},n("#buttonCreateJob").click(function(){var t=n(this),r=t.attr("href");return i.DiscoFunctions.CreateOpenJobDialog(r),!1})})})($,window,document);
//@ sourceMappingURL=Disco-CreateJob.min.js.map
@@ -2,7 +2,7 @@
"version":3,
"file":"Disco-CreateJob.min.js",
"lineCount":1,
"mappings":"CAGC,QAAS,CAACA,CAAC,CAAEC,CAAM,CAAEC,CAAZ,CAAsB,CAC5BF,CAAC,CAAC,QAAS,CAAA,CAAG,CACV,IAAIG,EAAkB,KAClBC,EAAgB,CAChB,KAAK,CAAEC,QAAS,CAAA,CAAG,CACfF,CAAeG,OAAO,CAAC,OAAD,CADP,CAElB,CACD,UAAU,CAAEC,QAAS,CAACC,CAAD,CAAU,CACvBL,C,EACAA,CAAeG,OAAO,CAAC,QAAQ,CAAE,SAAS,CAAEE,CAAtB,CAFC,CAJf,CADM,CAY1BR,CAAC,CAAC,kBAAD,CAAoBS,MAAM,CAAC,QAAS,CAAA,CAAG,CACpC,IAAIC,EAAQV,CAAC,CAAC,IAAD,EACTW,EAAOD,CAAKE,KAAK,CAAC,MAAD,EAoBjBC,CArBe,CAyBnB,OAtBAV,CAAgB,CAAEH,CAAC,CAAC,OAAD,CAASY,KAAK,CAAC,IAAI,CAAE,iBAAP,CAAyBE,MAAM,CAAC,MAAD,CAAQC,OAAO,CAAC,MAAD,CAAQC,SAAS,CAACd,CAAQe,KAAT,CAAe,CAE/Gd,CAAeG,OAAO,CAAC,CACnB,SAAS,CAAE,CAAA,CAAK,CAChB,SAAS,CAAE,CAAA,CAAK,CAChB,KAAK,CAAE,CAAA,CAAI,CACX,QAAQ,CAAE,CAAA,CAAI,CACd,KAAK,CAAE,YAAY,CACnB,KAAK,CAAE,GAAG,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-CreateJob/disco.createjob.js"],
"names":["$","window","document","createJobDialog","dialogMethods","close","dialog","setButtons","buttons","click","$this","href","attr","iframe","width","height","appendTo","body","find","remove","css","discoDialogMethods"]
"names":["$","window","document","createJobDialog","dialogMethods","close","dialog","setButtons","buttons","DiscoFunctions","CreateOpenJobDialog","document.DiscoFunctions.CreateOpenJobDialog","url","attr","width","height","appendTo","body","find","remove","iframe","css","discoDialogMethods","click","$this","href"]
}
@@ -14,11 +14,10 @@
}
}
// Create Job Button
$('#buttonCreateJob').click(function () {
var $this = $(this);
var href = $this.attr('href');
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
}
document.DiscoFunctions.CreateOpenJobDialog = function (url) {
createJobDialog = $('<div>').attr('id', 'createJobDialog').width('100%').height('100%').appendTo(document.body);
createJobDialog.dialog({
@@ -37,9 +36,17 @@
buttons: {}
});
var iframe = $('<iframe>').attr({ 'src': href }).width('100%').height('100%').css('border', 'none').appendTo(createJobDialog);
var iframe = $('<iframe>').attr({ 'src': url }).width('100%').height('100%').css('border', 'none').appendTo(createJobDialog);
createJobDialog[0].discoDialogMethods = dialogMethods;
}
// Create Job Button
$('#buttonCreateJob').click(function () {
var $this = $(this);
var href = $this.attr('href');
document.DiscoFunctions.CreateOpenJobDialog(href);
return false;
});
+254 -143
View File
@@ -1,75 +1,79 @@
@model Disco.Web.Models.User.ShowModel
@{
var currentDeviceAssignments = Model.User.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue).OrderByDescending(dua => dua.AssignedDate).ToList();
}
<table id="User_Show_Subjects">
<tr>
<td id="User_Show_Details">
<div>
<div id="User_Show_Details_Identity">
<table class="none verticalHeadings">
<tr>
<td><span>Username (Id):</span>
</td>
<td>
<h4 id="User_Show_Details_Identity_Id" title="Username">@Model.User.Id</h4>
</td>
</tr>
<tr>
<td>Display Name:</td>
<td><span id="User_Show_Details_Identity_DisplayName" title="Display Name">@Model.User.DisplayName</span></td>
</tr>
<tr>
<td>Given Name:</td>
<td><span id="User_Show_Details_Identity_GivenName" title="Given Name">@Model.User.GivenName</span></td>
</tr>
<tr>
<td>Surname:</td>
<td><span id="User_Show_Details_Identity_Surname" title="Surname">@Model.User.Surname</span></td>
</tr>
</table>
</div>
<div id="User_Show_Details_Category" class="status">
<table class="none verticalHeadings">
<tr>
<td>Type:
</td>
<td><span id="User_Show_Details_Category_Type" title="Type">@Model.User.Type</span></td>
</tr>
</table>
</div>
<div id="User_Show_Details_Attributes" class="status">
<table class="none verticalHeadings">
<tr>
<td>Email:</td>
<td>
@if (!string.IsNullOrEmpty(Model.User.EmailAddress))
{
<span id="User_Show_Details_Attributes_Email" title="Email Address [Update in Active Directory]">@Model.User.EmailAddress</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
@if (!string.IsNullOrEmpty(Model.User.PhoneNumber))
{
<span id="User_Show_Details_Attributes_Phone" title="Phone Number [Update in Active Directory]">@Model.User.PhoneNumber</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
</table>
</div>
<div id="User_Show_GenerateDocument_Container" class="status">
@Html.DropDownList("User_Show_GenerateDocument", Model.DocumentTemplatesSelectListItems)
<script type="text/javascript">
$(function () {
var generatePdfUrl = '@Url.Action(MVC.API.User.GeneratePdf(Model.User.Id, null))?DocumentTemplateId=';
<tbody>
<tr>
<td id="User_Show_Details">
<div>
<div id="User_Show_Details_Identity">
<table class="none verticalHeadings">
<tr>
<td><span>Username (Id):</span>
</td>
<td>
<h4 id="User_Show_Details_Identity_Id" title="Username">@Model.User.Id</h4>
</td>
</tr>
<tr>
<td>Display Name:</td>
<td><span id="User_Show_Details_Identity_DisplayName" title="Display Name">@Model.User.DisplayName</span></td>
</tr>
<tr>
<td>Given Name:</td>
<td><span id="User_Show_Details_Identity_GivenName" title="Given Name">@Model.User.GivenName</span></td>
</tr>
<tr>
<td>Surname:</td>
<td><span id="User_Show_Details_Identity_Surname" title="Surname">@Model.User.Surname</span></td>
</tr>
</table>
</div>
<div id="User_Show_Details_Category" class="status">
<table class="none verticalHeadings">
<tr>
<td>Type:
</td>
<td><span id="User_Show_Details_Category_Type" title="Type">@Model.User.Type</span></td>
</tr>
</table>
</div>
<div id="User_Show_Details_Attributes" class="status">
<table class="none verticalHeadings">
<tr>
<td>Email:</td>
<td>
@if (!string.IsNullOrEmpty(Model.User.EmailAddress))
{
<span id="User_Show_Details_Attributes_Email" title="Email Address [Update in Active Directory]">@Model.User.EmailAddress</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
@if (!string.IsNullOrEmpty(Model.User.PhoneNumber))
{
<span id="User_Show_Details_Attributes_Phone" title="Phone Number [Update in Active Directory]">@Model.User.PhoneNumber</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
</table>
</div>
<div id="User_Show_GenerateDocument_Container" class="status">
@Html.DropDownList("User_Show_GenerateDocument", Model.DocumentTemplatesSelectListItems)
<script type="text/javascript">
$(function () {
var generatePdfUrl = '@Url.Action(MVC.API.User.GeneratePdf(Model.User.Id, null))?DocumentTemplateId=';
var $documentTemplates = $('#User_Show_GenerateDocument');
$documentTemplates.change(function () {
var v = $documentTemplates.val();
@@ -79,79 +83,186 @@
}
});
});
</script>
</div>
<div id="User_Show_Details_Actions">
@{
Html.BundleDeferred("~/ClientScripts/Modules/Disco-CreateJob");
}
@Html.ActionLinkSmallButton("Create Job", MVC.Job.Create(Model.PrimaryDeviceSerialNumber, Model.User.Id), "buttonCreateJob")
</div>
</div>
</td>
<td id="User_Show_AssignedDevices">
<div>
<div id="User_Show_AssignedDevices_Active">
<h3>Current Device Assignments</h3>
@{
var currentAssignments = Model.User.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue).ToList();
}
@if (currentAssignments.Count > 0)
{
foreach (var assignment in currentAssignments)
{
<div class="User_Show_AssignedDevices_CurrentAssignment clearfix" data-deviceserialnumber="@assignment.DeviceSerialNumber">
<a href="@Url.Action(MVC.Device.Show(assignment.Device.SerialNumber))">
<img class="User_Show_AssignedDevices_CurrentAssignment_Image" alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(assignment.Device.DeviceModel.Id, assignment.Device.DeviceModel.ImageHash()))" />
</a>
<div class="User_Show_AssignedDevices_CurrentAssignment_Details">
<table class="none">
<tbody>
<tr>
<td>Serial Number:
</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_SerialNumber">@Html.ActionLink(assignment.Device.SerialNumber, MVC.Device.Show(assignment.Device.SerialNumber))</span> (<span>@assignment.Device.ComputerName</span>)
</td>
</tr>
<tr>
<td>Model:
</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_Model">@assignment.Device.DeviceModel.ToString()</span>
</td>
</tr>
<tr>
<td>Asset:</td>
<td>
@if (!string.IsNullOrEmpty(assignment.Device.AssetNumber))
{
<span class="User_Show_AssignedDevices_CurrentAssignment_Asset">@assignment.Device.AssetNumber</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
<tr>
<td>Assigned:</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_Assigned">@CommonHelpers.FriendlyDate(assignment.AssignedDate)</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</script>
</div>
<div id="User_Show_Details_Actions">
@{
Html.BundleDeferred("~/ClientScripts/Modules/Disco-CreateJob");
}
}
else
{
<span class="smallMessage">No Current Device Assignments</span>
}
@Html.ActionLinkSmallButton("Create Job", MVC.Job.Create(Model.PrimaryDeviceSerialNumber, Model.User.Id), "User_Show_Details_Actions_CreateJob_Button")
@if (currentDeviceAssignments.Count > 1)
{
<div id="User_Show_Details_Actions_CreateJob_Dialog" class="dialog" title="Create Job for Which Device?">
<div class="clearfix">
<span class="ui-icon ui-icon-info" style="float: left; margin: 0 7px 20px 0;"></span>
Multiple devices are assigned to this user. Which device should be associated with this job?
</div>
<div>
<ul id="CreateJob_Assignments" class="none">
@foreach (var assignment in currentDeviceAssignments)
{
<li class="CreateJob_Assignment clearfix" data-createjoburl="@Url.Action(MVC.Job.Create(assignment.DeviceSerialNumber, Model.User.Id))">
<img class="CreateJob_Assignment_Image" alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(assignment.Device.DeviceModel.Id, assignment.Device.DeviceModel.ImageHash()))" />
<div class="CreateJob_Assignment_Details">
<table class="none">
<tbody>
<tr>
<td>Serial Number:
</td>
<td>
<span>@assignment.Device.SerialNumber</span> (<span>@assignment.Device.ComputerName</span>)
</td>
</tr>
<tr>
<td>Model:
</td>
<td>
<span>@assignment.Device.DeviceModel.ToString()</span>
</td>
</tr>
<tr>
<td>Asset:</td>
<td>
@if (!string.IsNullOrEmpty(assignment.Device.AssetNumber))
{
<span>@assignment.Device.AssetNumber</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
<tr>
<td>Assigned:</td>
<td>
<span>@CommonHelpers.FriendlyDate(assignment.AssignedDate)</span>
</td>
</tr>
</tbody>
</table>
</div>
</li>
}
</ul>
</div>
</div>
<script>
$(function () {
var button = $('#User_Show_Details_Actions_CreateJob_Button');
var buttonDialog = null;
button.click(function () {
if (!buttonDialog) {
buttonDialog = $('#User_Show_Details_Actions_CreateJob_Dialog').dialog({
resizable: false,
width: 400,
modal: true,
autoOpen: false,
buttons: {
Cancel: function () {
$(this).dialog("close");
}
}
});
dialogItems = buttonDialog.find('li.CreateJob_Assignment');
dialogItems.click(function () {
var $this = $(this);
buttonDialog.dialog("close");
var createJobUrl = $this.attr('data-createjoburl');
document.DiscoFunctions.CreateOpenJobDialog(createJobUrl);
});
}
buttonDialog.dialog('open');
return false;
});
});
</script>
}
else
{
<script>
$(function () {
$('#User_Show_Details_Actions_CreateJob_Button').click(function () {
var $this = $(this);
var href = $this.attr('href');
document.DiscoFunctions.CreateOpenJobDialog(href);
return false;
});
});
</script>
}
</div>
</div>
</div>
</td>
</tr>
</td>
<td id="User_Show_AssignedDevices">
<div>
<div id="User_Show_AssignedDevices_Active">
<h3>Current Device Assignments</h3>
@if (currentDeviceAssignments.Count > 0)
{
foreach (var assignment in currentDeviceAssignments)
{
<div class="User_Show_AssignedDevices_CurrentAssignment clearfix" data-deviceserialnumber="@assignment.DeviceSerialNumber">
<a href="@Url.Action(MVC.Device.Show(assignment.Device.SerialNumber))">
<img class="User_Show_AssignedDevices_CurrentAssignment_Image" alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(assignment.Device.DeviceModel.Id, assignment.Device.DeviceModel.ImageHash()))" />
</a>
<div class="User_Show_AssignedDevices_CurrentAssignment_Details">
<table class="none">
<tbody>
<tr>
<td>Serial Number:
</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_SerialNumber">@Html.ActionLink(assignment.Device.SerialNumber, MVC.Device.Show(assignment.Device.SerialNumber))</span> (<span>@assignment.Device.ComputerName</span>)
</td>
</tr>
<tr>
<td>Model:
</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_Model">@assignment.Device.DeviceModel.ToString()</span>
</td>
</tr>
<tr>
<td>Asset:</td>
<td>
@if (!string.IsNullOrEmpty(assignment.Device.AssetNumber))
{
<span class="User_Show_AssignedDevices_CurrentAssignment_Asset">@assignment.Device.AssetNumber</span>
}
else
{
<span class="smallMessage">Unknown</span>
}
</td>
</tr>
<tr>
<td>Assigned:</td>
<td>
<span class="User_Show_AssignedDevices_CurrentAssignment_Assigned">@CommonHelpers.FriendlyDate(assignment.AssignedDate)</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
}
}
else
{
<span class="smallMessage">No Current Device Assignments</span>
}
</div>
</div>
</td>
</tr>
</tbody>
</table>
File diff suppressed because it is too large Load Diff