feature: device document template bulk generation

This commit is contained in:
Gary Sharp
2025-08-17 18:22:03 +10:00
parent 676ff82e4b
commit ca7193a8fc
39 changed files with 4437 additions and 2429 deletions
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Globalization;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
-1
View File
@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace Disco.Models.Repository namespace Disco.Models.Repository
{ {
@@ -1,5 +1,4 @@
using Disco.Models.Services.Authorization; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -1,5 +1,4 @@
using Disco.Models.Services.Authorization; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -7,13 +7,22 @@ namespace Disco.Models.UI.Config.DocumentTemplate
Repository.DocumentTemplate DocumentTemplate { get; set; } Repository.DocumentTemplate DocumentTemplate { get; set; }
int TemplatePageCount { get; set; } int TemplatePageCount { get; set; }
List<ItemWithCount<Repository.UserFlag>> UserFlags { get; set; }
List<ItemWithCount<Repository.DeviceProfile>> DeviceProfiles { get; set; } List<ItemWithCount<Repository.DeviceProfile>> DeviceProfiles { get; set; }
List<ItemWithCount<Repository.DeviceBatch>> DeviceBatches { get; set; } List<ItemWithCount<Repository.DeviceBatch>> DeviceBatches { get; set; }
List<ItemWithCount<Repository.DocumentTemplate>> DocumentTemplates { get; set; } List<ItemWithCount<Repository.DocumentTemplate>> DocumentTemplates { get; set; }
List<ItemWithCount<string>> UserDetails { get; set; } List<ItemWithCount<string>> UserDetails { get; set; }
} }
public interface ConfigDocumentTemplateBulkGenerateUser : ConfigDocumentTemplateBulkGenerate
{
List<ItemWithCount<Repository.UserFlag>> UserFlags { get; set; }
}
public interface ConfigDocumentTemplateBulkGenerateDevice : ConfigDocumentTemplateBulkGenerate
{
List<ItemWithCount<Repository.DeviceFlag>> DeviceFlags { get; set; }
}
public class ItemWithCount<T> public class ItemWithCount<T>
{ {
public T Item { get; set; } public T Item { get; set; }
@@ -1,6 +1,5 @@
using Disco.Data.Repository; using Disco.Data.Repository;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Devices.DeviceFlags; using Disco.Services.Devices.DeviceFlags;
using Disco.Services.Expressions; using Disco.Services.Expressions;
using Disco.Services.Logging; using Disco.Services.Logging;
@@ -1,7 +1,6 @@
using Disco.Data.Repository; using Disco.Data.Repository;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Models.Services.Documents; using Disco.Models.Services.Documents;
using Disco.Models.UI.Config.DocumentTemplate;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -1,5 +1,4 @@
using Disco.Data.Repository; using Disco.Data.Repository;
using Disco.Models.Services.Interop.DiscoServices;
using Disco.Services.Interop.DiscoServices; using Disco.Services.Interop.DiscoServices;
using Disco.Services.Tasks; using Disco.Services.Tasks;
using Quartz; using Quartz;
@@ -1,6 +1,5 @@
using Disco.Data.Repository; using Disco.Data.Repository;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Expressions; using Disco.Services.Expressions;
using Disco.Services.Logging; using Disco.Services.Logging;
using Disco.Services.Users; using Disco.Services.Users;
@@ -1,5 +1,4 @@
using Disco.Models.BI.Config; using Disco.Models.BI.Config;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
@@ -5,7 +5,6 @@ using Disco.Services.Devices.DeviceFlags;
using Disco.Services.Exporting; using Disco.Services.Exporting;
using Disco.Services.Interop.ActiveDirectory; using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Tasks; using Disco.Services.Tasks;
using Disco.Services.Users.UserFlags;
using Disco.Services.Web; using Disco.Services.Web;
using Disco.Web.Areas.API.Models.Shared; using Disco.Web.Areas.API.Models.Shared;
using Disco.Web.Areas.Config.Models.DeviceFlag; using Disco.Web.Areas.Config.Models.DeviceFlag;
@@ -31,13 +31,13 @@ namespace Disco.Web.Areas.API.Controllers
public partial class DocumentTemplateController : AuthorizedDatabaseController public partial class DocumentTemplateController : AuthorizedDatabaseController
{ {
const string pDescription = "description"; private const string pDescription = "description";
const string pScope = "scope"; private const string pScope = "scope";
const string pFilterExpression = "filterexpression"; private const string pFilterExpression = "filterexpression";
const string pOnGenerateExpression = "ongenerateexpression"; private const string pOnGenerateExpression = "ongenerateexpression";
const string pOnImportAttachmentExpression = "onimportattachmentexpression"; private const string pOnImportAttachmentExpression = "onimportattachmentexpression";
const string pFlattenForm = "flattenform"; private const string pFlattenForm = "flattenform";
const string pIsHidden = "ishidden"; private const string pIsHidden = "ishidden";
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)] [DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
[HttpPost, ValidateAntiForgeryToken] [HttpPost, ValidateAntiForgeryToken]
@@ -841,26 +841,49 @@ namespace Disco.Web.Areas.API.Controllers
return File(stream, "application/pdf", fileName); return File(stream, "application/pdf", fileName);
} }
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)] private List<BulkGenerateItemModel> BulkGenerateEvaluateScope<T>(string scope, T arg, Func<T, List<BulkGenerateItemModel>> userScope, Func<T, List<BulkGenerateItemModel>> deviceScope)
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddUsers(string userIds)
{ {
if (string.IsNullOrWhiteSpace(userIds)) if (string.IsNullOrWhiteSpace(scope))
throw new ArgumentNullException(nameof(scope), "Scope is required.");
if ("user".Equals(scope, StringComparison.OrdinalIgnoreCase))
return userScope(arg);
else if ("device".Equals(scope, StringComparison.OrdinalIgnoreCase))
return deviceScope(arg);
else
throw new ArgumentException("Invalid scope specified. Use 'user' or 'device'.", nameof(scope));
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddUsers(string scope, string userIds)
{
if (string.IsNullOrWhiteSpace(scope) || string.IsNullOrWhiteSpace(userIds))
return BadRequest(); return BadRequest();
var dataIds = userIds.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList(); var dataIds = userIds.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList();
var results = new List<BulkGenerateUserModel>(dataIds.Count);
if (dataIds.Count == 0)
return Json(new List<BulkGenerateItemModel>());
var results = BulkGenerateEvaluateScope(scope, dataIds, BulkGenerateUserAddUsers, BulkGenerateDeviceAddUsers);
return Json(results);
}
private List<BulkGenerateItemModel> BulkGenerateUserAddUsers(List<string> dataIds)
{
var results = new List<BulkGenerateItemModel>(dataIds.Count);
foreach (var dataId in dataIds) foreach (var dataId in dataIds)
{ {
var accountId = ActiveDirectory.ParseDomainAccountId(dataId); var accountId = ActiveDirectory.ParseDomainAccountId(dataId);
if (UserService.TryGetUser(accountId, Database, true, out var user)) if (UserService.TryGetUser(accountId, Database, true, out var user))
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = user.UserId, Id = user.UserId,
UserEmailAddress = user.EmailAddress, UserEmailAddress = user.EmailAddress,
DisplayName = user.DisplayName, UserDisplayName = user.DisplayName,
Scope = $"Matched '{dataId}'", Scope = $"Matched '{dataId}'",
IsError = false, IsError = false,
}); });
@@ -872,10 +895,10 @@ namespace Disco.Web.Areas.API.Controllers
if (adObject == null) if (adObject == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = dataId, Id = dataId,
DisplayName = dataId, UserDisplayName = dataId,
Scope = $"Unknown User or Security Group '{dataId}'", Scope = $"Unknown User or Security Group '{dataId}'",
IsError = true, IsError = true,
}); });
@@ -886,10 +909,10 @@ namespace Disco.Web.Areas.API.Controllers
{ {
foreach (var adUser in group.GetUserMembersRecursive()) foreach (var adUser in group.GetUserMembersRecursive())
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = adUser.Id, Id = adUser.Id,
DisplayName = adUser.DisplayName, UserDisplayName = adUser.DisplayName,
UserEmailAddress = adUser.Email, UserEmailAddress = adUser.Email,
Scope = $"Group Member '{group.Name}'", Scope = $"Group Member '{group.Name}'",
IsError = false, IsError = false,
@@ -899,10 +922,10 @@ namespace Disco.Web.Areas.API.Controllers
} }
else else
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = dataId, Id = dataId,
DisplayName = dataId, UserDisplayName = dataId,
Scope = $"Unexpected AD Object found at '{adObject.DistinguishedName}'", Scope = $"Unexpected AD Object found at '{adObject.DistinguishedName}'",
IsError = true, IsError = true,
}); });
@@ -910,6 +933,88 @@ namespace Disco.Web.Areas.API.Controllers
} }
} }
} }
return results;
}
private List<BulkGenerateItemModel> BulkGenerateDeviceAddUsers(List<string> dataIds)
{
var results = new List<BulkGenerateItemModel>(dataIds.Count);
foreach (var dataId in dataIds)
{
var accountId = ActiveDirectory.ParseDomainAccountId(dataId);
var dbUser = Database.Users
.Include(u => u.DeviceUserAssignments)
.Where(u => u.UserId == accountId)
.FirstOrDefault();
if (dbUser != null)
{
var assignments = dbUser.CurrentDeviceAssignments;
if (assignments.Any())
{
if (UserService.TryGetUser(accountId, Database, true, out var adUser))
dbUser = adUser; // use updated user from AD
foreach (var assignment in assignments)
{
results.Add(new BulkGenerateItemModel()
{
Id = assignment.DeviceSerialNumber,
UserEmailAddress = dbUser.EmailAddress,
UserDisplayName = dbUser.DisplayName,
Scope = $"Matched assigned user '{dataId}'",
IsError = false,
});
}
}
}
}
return results;
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.Device.Actions.GenerateDocuments)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDevices(string deviceSerialNumbers)
{
if (string.IsNullOrWhiteSpace(deviceSerialNumbers))
return BadRequest();
var dataIds = deviceSerialNumbers.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList();
if (dataIds.Count == 0)
return Json(new List<BulkGenerateItemModel>());
var results = new List<BulkGenerateItemModel>();
var devices = Database.Devices.Include(d => d.AssignedUser).Where(d => dataIds.Contains(d.SerialNumber)).ToDictionary(d => d.SerialNumber, StringComparer.OrdinalIgnoreCase);
foreach (var deviceSerialNumber in dataIds)
{
if (devices.TryGetValue(deviceSerialNumber, out var device))
{
var user = device.AssignedUser;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = device.SerialNumber,
UserEmailAddress = user?.EmailAddress,
UserDisplayName = user?.DisplayName,
Scope = $"Matched '{deviceSerialNumber}'",
IsError = false,
});
}
else
{
results.Add(new BulkGenerateItemModel()
{
Id = deviceSerialNumber,
UserDisplayName = deviceSerialNumber,
Scope = $"Unknown Device '{deviceSerialNumber}'",
IsError = true,
});
}
}
return Json(results); return Json(results);
} }
@@ -921,17 +1026,17 @@ namespace Disco.Web.Areas.API.Controllers
if (string.IsNullOrWhiteSpace(groupId)) if (string.IsNullOrWhiteSpace(groupId))
return BadRequest(); return BadRequest();
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateItemModel>();
var accountId = ActiveDirectory.ParseDomainAccountId(groupId); var accountId = ActiveDirectory.ParseDomainAccountId(groupId);
var adObject = ActiveDirectory.RetrieveADObject(accountId, true); var adObject = ActiveDirectory.RetrieveADObject(accountId, true);
if (adObject == null) if (adObject == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = groupId, Id = groupId,
DisplayName = groupId, UserDisplayName = groupId,
Scope = $"Unknown Security Group '{groupId}'", Scope = $"Unknown Security Group '{groupId}'",
IsError = true, IsError = true,
}); });
@@ -940,10 +1045,10 @@ namespace Disco.Web.Areas.API.Controllers
{ {
foreach (var adUser in group.GetUserMembersRecursive()) foreach (var adUser in group.GetUserMembersRecursive())
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = adUser.Id, Id = adUser.Id,
DisplayName = adUser.DisplayName, UserDisplayName = adUser.DisplayName,
UserEmailAddress = adUser.Email, UserEmailAddress = adUser.Email,
Scope = $"Group Member '{group.Name}'", Scope = $"Group Member '{group.Name}'",
IsError = false, IsError = false,
@@ -952,10 +1057,10 @@ namespace Disco.Web.Areas.API.Controllers
} }
else if (adObject is ADUserAccount user) else if (adObject is ADUserAccount user)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = user.Id, Id = user.Id,
DisplayName = user.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = user.Email, UserEmailAddress = user.Email,
Scope = $"Matched '{groupId}'", Scope = $"Matched '{groupId}'",
IsError = false, IsError = false,
@@ -963,10 +1068,10 @@ namespace Disco.Web.Areas.API.Controllers
} }
else else
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = groupId, Id = groupId,
DisplayName = groupId, UserDisplayName = groupId,
Scope = $"Unexpected AD Object found at '{adObject.DistinguishedName}'", Scope = $"Unexpected AD Object found at '{adObject.DistinguishedName}'",
IsError = true, IsError = true,
}); });
@@ -982,16 +1087,16 @@ namespace Disco.Web.Areas.API.Controllers
if (flagId <= 0) if (flagId <= 0)
return BadRequest(); return BadRequest();
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateItemModel>();
var flag = Database.UserFlags.Include(f => f.UserFlagAssignments.Select(a => a.User)).FirstOrDefault(f => f.Id == flagId); var flag = Database.UserFlags.Include(f => f.UserFlagAssignments.Select(a => a.User)).FirstOrDefault(f => f.Id == flagId);
if (flag == null) if (flag == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = flagId.ToString(), Id = flagId.ToString(),
DisplayName = flagId.ToString(), UserDisplayName = flagId.ToString(),
Scope = $"Unknown User Flag '{flagId}'", Scope = $"Unknown User Flag '{flagId}'",
IsError = true, IsError = true,
}); });
@@ -1002,10 +1107,10 @@ namespace Disco.Web.Areas.API.Controllers
if (assignments.Count == 0) if (assignments.Count == 0)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = flag.Name, Id = flag.Name,
DisplayName = flag.Name, UserDisplayName = flag.Name,
Scope = $"User Flag has no active assignments", Scope = $"User Flag has no active assignments",
IsError = true, IsError = true,
}); });
@@ -1014,11 +1119,15 @@ namespace Disco.Web.Areas.API.Controllers
{ {
foreach (var assignment in assignments) foreach (var assignment in assignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.User;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.UserId, Id = assignment.UserId,
UserEmailAddress = assignment.User.EmailAddress, UserEmailAddress = user?.EmailAddress,
DisplayName = assignment.User.DisplayName, UserDisplayName = user?.DisplayName,
Scope = $"Assigned User Flag '{flag.Name}'", Scope = $"Assigned User Flag '{flag.Name}'",
IsError = false, IsError = false,
}); });
@@ -1029,37 +1138,103 @@ namespace Disco.Web.Areas.API.Controllers
return Json(results); return Json(results);
} }
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)] [DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken] [HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDeviceProfile(int deviceProfileId) public virtual ActionResult BulkGenerateAddDeviceFlag(int flagId)
{ {
if (deviceProfileId <= 0) if (flagId <= 0)
return BadRequest(); return BadRequest();
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateItemModel>();
var profile = Database.DeviceProfiles.Include(p => p.Devices.Select(a => a.AssignedUser)).FirstOrDefault(f => f.Id == deviceProfileId); var flag = Database.DeviceFlags.Include(f => f.DeviceFlagAssignments.Select(a => a.Device.AssignedUser)).FirstOrDefault(f => f.Id == flagId);
if (profile == null) if (flag == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = deviceProfileId.ToString(), Id = flagId.ToString(),
DisplayName = deviceProfileId.ToString(), UserDisplayName = flagId.ToString(),
Scope = $"Unknown Device Profile '{deviceProfileId}'", Scope = $"Unknown User Flag '{flagId}'",
IsError = true, IsError = true,
}); });
} }
else else
{ {
var assignments = flag.DeviceFlagAssignments.Where(a => a.RemovedDate == null).ToList();
if (assignments.Count == 0)
{
results.Add(new BulkGenerateItemModel()
{
Id = flag.Name,
UserDisplayName = flag.Name,
Scope = $"Device Flag has no active assignments",
IsError = true,
});
}
else
{
foreach (var assignment in assignments)
{
var user = assignment.Device.AssignedUser;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = assignment.DeviceSerialNumber,
UserEmailAddress = user?.EmailAddress,
UserDisplayName = user?.DisplayName,
Scope = $"Assigned User Flag '{flag.Name}'",
IsError = false,
});
}
}
}
return Json(results);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDeviceProfile(string scope, int deviceProfileId)
{
if (string.IsNullOrWhiteSpace(scope) && deviceProfileId <= 0)
return BadRequest();
var profile = Database.DeviceProfiles.Include(p => p.Devices.Select(a => a.AssignedUser)).FirstOrDefault(f => f.Id == deviceProfileId);
if (profile == null)
{
var result = new List<BulkGenerateItemModel>() {
new BulkGenerateItemModel()
{
Id = deviceProfileId.ToString(),
UserDisplayName = deviceProfileId.ToString(),
Scope = $"Unknown Device Profile '{deviceProfileId}'",
IsError = true,
}
};
return Json(result);
}
var results = BulkGenerateEvaluateScope(scope, profile, BulkGenerateUserAddDeviceProfile, BulkGenerateDeviceAddDeviceProfile);
return Json(results);
}
private List<BulkGenerateItemModel> BulkGenerateUserAddDeviceProfile(DeviceProfile profile)
{
var results = new List<BulkGenerateItemModel>();
var assignments = profile.Devices.Where(d => d.AssignedUser != null).ToList(); var assignments = profile.Devices.Where(d => d.AssignedUser != null).ToList();
if (assignments.Count == 0) if (assignments.Count == 0)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = profile.Name, Id = profile.Name,
DisplayName = profile.Name, UserDisplayName = profile.Name,
Scope = $"Device Profile has no devices with active assignments", Scope = $"Device Profile has no devices with active assignments",
IsError = true, IsError = true,
}); });
@@ -1068,52 +1243,95 @@ namespace Disco.Web.Areas.API.Controllers
{ {
foreach (var assignment in assignments) foreach (var assignment in assignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.AssignedUser;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.AssignedUserId, Id = user.UserId,
DisplayName = assignment.AssignedUser.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = assignment.AssignedUser.EmailAddress, UserEmailAddress = user.EmailAddress,
Scope = $"Device Profile '{profile.Name}' Matches Assigned Device '{assignment.SerialNumber}'", Scope = $"Device Profile '{profile.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
IsError = false, IsError = false,
}); });
} }
} }
return results;
} }
private List<BulkGenerateItemModel> BulkGenerateDeviceAddDeviceProfile(DeviceProfile profile)
return Json(results);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDeviceBatch(int deviceBatchId)
{ {
if (deviceBatchId <= 0) var results = new List<BulkGenerateItemModel>();
return BadRequest();
var results = new List<BulkGenerateUserModel>(); if (profile.Devices.Count == 0)
var batch = Database.DeviceBatches.Include(p => p.Devices.Select(a => a.AssignedUser)).FirstOrDefault(f => f.Id == deviceBatchId);
if (batch == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = deviceBatchId.ToString(), Id = profile.Name,
DisplayName = deviceBatchId.ToString(), UserDisplayName = profile.Name,
Scope = $"Unknown Device Batch '{deviceBatchId}'", Scope = $"Device Profile has no devices",
IsError = true, IsError = true,
}); });
} }
else else
{ {
var assignments = batch.Devices.Where(d => d.AssignedUser != null).ToList(); foreach (var device in profile.Devices)
{
var user = device.AssignedUser;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = device.SerialNumber,
UserDisplayName = user?.DisplayName,
UserEmailAddress = user?.EmailAddress,
Scope = $"Device Profile '{profile.Name}'",
IsError = false,
});
}
}
return results;
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDeviceBatch(string scope, int deviceBatchId)
{
if (deviceBatchId <= 0)
return BadRequest();
var batch = Database.DeviceBatches.Include(p => p.Devices.Select(a => a.AssignedUser)).FirstOrDefault(f => f.Id == deviceBatchId);
if (batch == null)
{
var result = new List<BulkGenerateItemModel>()
{
new BulkGenerateItemModel()
{
Id = deviceBatchId.ToString(),
UserDisplayName = deviceBatchId.ToString(),
Scope = $"Unknown Device Batch '{deviceBatchId}'",
IsError = true,
}
};
return Json(result);
}
var results = BulkGenerateEvaluateScope(scope, batch, BulkGenerateUserAddDeviceBatch, BulkGenerateDeviceAddDeviceBatch);
return Json(results);
}
private List<BulkGenerateItemModel> BulkGenerateUserAddDeviceBatch(DeviceBatch batch)
{
var assignments = batch.Devices.Where(d => d.AssignedUser != null).ToList();
var results = new List<BulkGenerateItemModel>();
if (assignments.Count == 0) if (assignments.Count == 0)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = batch.Name, Id = batch.Name,
DisplayName = batch.Name, UserDisplayName = batch.Name,
Scope = $"Device Batch has no devices with active assignments", Scope = $"Device Batch has no devices with active assignments",
IsError = true, IsError = true,
}); });
@@ -1122,44 +1340,89 @@ namespace Disco.Web.Areas.API.Controllers
{ {
foreach (var assignment in assignments) foreach (var assignment in assignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.AssignedUser;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.AssignedUserId, Id = assignment.AssignedUserId,
DisplayName = assignment.AssignedUser.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = assignment.AssignedUser.EmailAddress, UserEmailAddress = user.EmailAddress,
Scope = $"Device Batch '{batch.Name}' Matches Assigned Device '{assignment.SerialNumber}'", Scope = $"Device Batch '{batch.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
IsError = false, IsError = false,
}); });
} }
} }
return results;
} }
private List<BulkGenerateItemModel> BulkGenerateDeviceAddDeviceBatch(DeviceBatch batch)
return Json(results);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDocumentAttachment(string documentTemplateId, DateTime? threshold)
{ {
if (string.IsNullOrWhiteSpace(documentTemplateId)) var results = new List<BulkGenerateItemModel>();
return BadRequest(); if (batch.Devices.Count == 0)
var results = new List<BulkGenerateUserModel>();
var template = Database.DocumentTemplates.FirstOrDefault(f => f.Id == documentTemplateId);
if (template == null)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = documentTemplateId, Id = batch.Name,
DisplayName = documentTemplateId, UserDisplayName = batch.Name,
Scope = $"Unknown Document Template '{documentTemplateId}'", Scope = $"Device Batch has no devices",
IsError = true, IsError = true,
}); });
} }
else else
{ {
foreach (var device in batch.Devices)
{
var user = device.AssignedUser;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = device.SerialNumber,
UserDisplayName = user?.DisplayName,
UserEmailAddress = user?.EmailAddress,
Scope = $"Device Batch '{batch.Name}'",
IsError = false,
});
}
}
return results;
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateAddDocumentAttachment(string scope, string documentTemplateId, DateTime? threshold)
{
if (string.IsNullOrWhiteSpace(documentTemplateId))
return BadRequest();
var template = Database.DocumentTemplates.FirstOrDefault(f => f.Id == documentTemplateId);
if (template == null)
{
var result = new List<BulkGenerateItemModel>()
{
new BulkGenerateItemModel()
{
Id = documentTemplateId,
UserDisplayName = documentTemplateId,
Scope = $"Unknown Document Template '{documentTemplateId}'",
IsError = true,
}
};
return Json(result);
}
var results = BulkGenerateEvaluateScope(scope, (template, threshold), BulkGenerateUserAddDocumentTemplateAttachment, BulkGenerateDeviceAddDocumentTemplateAttachment);
return Json(results);
}
private List<BulkGenerateItemModel> BulkGenerateUserAddDocumentTemplateAttachment((DocumentTemplate template, DateTime? threshold) arg)
{
var (template, threshold) = arg;
var results = new List<BulkGenerateItemModel>();
switch (template.AttachmentType) switch (template.AttachmentType)
{ {
case AttachmentTypes.Device: case AttachmentTypes.Device:
@@ -1169,11 +1432,15 @@ namespace Disco.Web.Areas.API.Controllers
.ToList(); .ToList();
foreach (var assignment in deviceAssignments) foreach (var assignment in deviceAssignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.Device.AssignedUser;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.Device.AssignedUserId, Id = assignment.Device.AssignedUserId,
DisplayName = assignment.Device.AssignedUser.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = assignment.Device.AssignedUser.EmailAddress, UserEmailAddress = user.EmailAddress,
Scope = $"Document Template '{template.Id}' Attachment Matches Assigned Device '{assignment.Device.SerialNumber}'", Scope = $"Document Template '{template.Id}' Attachment Matches Assigned Device '{assignment.Device.SerialNumber}'",
IsError = false, IsError = false,
}); });
@@ -1186,11 +1453,15 @@ namespace Disco.Web.Areas.API.Controllers
.ToList(); .ToList();
foreach (var assignment in jobAssignments) foreach (var assignment in jobAssignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.Job.User;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.Job.UserId, Id = assignment.Job.UserId,
DisplayName = assignment.Job.User.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = assignment.Job.User.EmailAddress, UserEmailAddress = user.EmailAddress,
Scope = $"Document Template '{template.Id}' Attachment Matches Job '{assignment.Job.Id}'", Scope = $"Document Template '{template.Id}' Attachment Matches Job '{assignment.Job.Id}'",
IsError = false, IsError = false,
}); });
@@ -1203,11 +1474,15 @@ namespace Disco.Web.Areas.API.Controllers
.ToList(); .ToList();
foreach (var assignment in userAssignments) foreach (var assignment in userAssignments)
{ {
results.Add(new BulkGenerateUserModel() var user = assignment.User;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = assignment.UserId, Id = assignment.UserId,
DisplayName = assignment.User.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = assignment.User.EmailAddress, UserEmailAddress = user.EmailAddress,
Scope = $"Document Template '{template.Id}' Attachment Matches User", Scope = $"Document Template '{template.Id}' Attachment Matches User",
IsError = false, IsError = false,
}); });
@@ -1216,25 +1491,24 @@ namespace Disco.Web.Areas.API.Controllers
default: default:
throw new NotSupportedException(); throw new NotSupportedException();
} }
if (results.Count == 0) if (results.Count == 0)
{ {
if (threshold.HasValue) if (threshold.HasValue)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = template.Id, Id = template.Id,
DisplayName = template.Id, UserDisplayName = template.Id,
Scope = $"Document Template has no attachments with associated users after {threshold:yyyy-MM-dd}", Scope = $"Document Template has no attachments with associated users after {threshold:yyyy-MM-dd}",
IsError = true, IsError = true,
}); });
} }
else else
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = template.Id, Id = template.Id,
DisplayName = template.Id, UserDisplayName = template.Id,
Scope = $"Document Template has no attachments with associated users", Scope = $"Document Template has no attachments with associated users",
IsError = true, IsError = true,
}); });
@@ -1245,12 +1519,120 @@ namespace Disco.Web.Areas.API.Controllers
var distinctSet = new HashSet<string>(StringComparer.Ordinal); var distinctSet = new HashSet<string>(StringComparer.Ordinal);
results = results.Where(r => distinctSet.Add(r.Id)).ToList(); results = results.Where(r => distinctSet.Add(r.Id)).ToList();
} }
return results;
}
private List<BulkGenerateItemModel> BulkGenerateDeviceAddDocumentTemplateAttachment((DocumentTemplate template, DateTime? threshold) arg)
{
var (template, threshold) = arg;
var results = new List<BulkGenerateItemModel>();
switch (template.AttachmentType)
{
case AttachmentTypes.Device:
var deviceAssignments = Database.DeviceAttachments
.Include(a => a.Device.AssignedUser)
.Where(a => a.DocumentTemplateId == template.Id && (threshold == null || a.Timestamp > threshold))
.ToList();
foreach (var assignment in deviceAssignments)
{
var user = assignment.Device.AssignedUser;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = assignment.DeviceSerialNumber,
UserDisplayName = user?.DisplayName,
UserEmailAddress = user?.EmailAddress,
Scope = $"Document Template '{template.Id}'",
IsError = false,
});
}
break;
case AttachmentTypes.Job:
var jobAssignments = Database.JobAttachments
.Include(a => a.Job.User)
.Where(a => a.DocumentTemplateId == template.Id && (threshold == null || a.Timestamp > threshold) && a.Job.DeviceSerialNumber != null)
.ToList();
foreach (var assignment in jobAssignments)
{
var user = assignment.Job.User;
if (user != null && UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{
Id = assignment.Job.DeviceSerialNumber,
UserDisplayName = user?.DisplayName,
UserEmailAddress = user?.EmailAddress,
Scope = $"Document Template '{template.Id}' Attachment Matches Job '{assignment.Job.Id}'",
IsError = false,
});
}
break;
case AttachmentTypes.User:
var userAssignments = Database.UserAttachments
.Include(a => a.User.DeviceUserAssignments)
.Where(a => a.DocumentTemplateId == template.Id && (threshold == null || a.Timestamp > threshold))
.ToList();
foreach (var assignment in userAssignments)
{
var userDeviceAssignments = assignment.User.CurrentDeviceAssignments;
if (userDeviceAssignments.Any())
{
var user = assignment.User;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
foreach (var userDeviceAssignment in userDeviceAssignments)
{
results.Add(new BulkGenerateItemModel()
{
Id = userDeviceAssignment.DeviceSerialNumber,
UserDisplayName = user.DisplayName,
UserEmailAddress = user.EmailAddress,
Scope = $"Document Template '{template.Id}' Attachment Matches User '{user.UserId}'",
IsError = false,
});
}
}
}
break;
default:
throw new NotSupportedException();
}
if (results.Count == 0)
{
if (threshold.HasValue)
{
results.Add(new BulkGenerateItemModel()
{
Id = template.Id,
UserDisplayName = template.Id,
Scope = $"Document Template has no attachments after {threshold:yyyy-MM-dd}",
IsError = true,
});
}
else
{
results.Add(new BulkGenerateItemModel()
{
Id = template.Id,
UserDisplayName = template.Id,
Scope = $"Document Template has no attachments",
IsError = true,
});
}
}
else
{
var distinctSet = new HashSet<string>(StringComparer.Ordinal);
results = results.Where(r => distinctSet.Add(r.Id)).ToList();
}
return results;
} }
return Json(results); [DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments, Claims.User.ShowDetails)]
[HttpPost, ValidateAntiForgeryToken] [HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult BulkGenerateGetUserDetailValues(string key) public virtual ActionResult BulkGenerateGetUserDetailValues(string key)
{ {
@@ -1262,14 +1644,21 @@ namespace Disco.Web.Areas.API.Controllers
return Json(results); return Json(results);
} }
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments, Claims.User.ShowDetails)] [DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
[HttpPost, ValidateAntiForgeryToken, ValidateInput(false)] [HttpPost, ValidateAntiForgeryToken, ValidateInput(false)]
public virtual ActionResult BulkGenerateAddUserDetail(string key, string value) public virtual ActionResult BulkGenerateAddUserDetail(string scope, string key, string value)
{ {
if (string.IsNullOrWhiteSpace(key)) if (string.IsNullOrWhiteSpace(key))
return BadRequest(); return BadRequest();
var results = new List<BulkGenerateUserModel>(); var results = BulkGenerateEvaluateScope(scope, (key, value), BulkGenerateUserAddUserDetail, BulkGenerateDeviceAddUserDetail);
return Json(results);
}
private List<BulkGenerateItemModel> BulkGenerateUserAddUserDetail((string key, string value) arg)
{
var (key, value) = arg;
var results = new List<BulkGenerateItemModel>();
var query = Database.UserDetails.Include(d => d.User).Where(d => d.Scope == "Details" && d.Key == key); var query = Database.UserDetails.Include(d => d.User).Where(d => d.Scope == "Details" && d.Key == key);
if (!string.IsNullOrWhiteSpace(value)) if (!string.IsNullOrWhiteSpace(value))
@@ -1280,29 +1669,89 @@ namespace Disco.Web.Areas.API.Controllers
if (details.Count == 0) if (details.Count == 0)
{ {
results.Add(new BulkGenerateUserModel() results.Add(new BulkGenerateItemModel()
{ {
Id = key, Id = key,
DisplayName = $"{key}{(string.IsNullOrWhiteSpace(value) ? null : $":{value}")}", UserDisplayName = $"{key}{(string.IsNullOrWhiteSpace(value) ? null : $":{value}")}",
Scope = $"User Detail '{key}' didn't match any users{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")}", Scope = $"User Detail '{key}' didn't match any users{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")}",
IsError = true, IsError = true,
}); });
} }
else else
{ {
foreach (var user in details.Select(d => d.User).Distinct()) foreach (var dbUser in details.Select(d => d.User).Distinct())
{ {
results.Add(new BulkGenerateUserModel() var user = dbUser;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
results.Add(new BulkGenerateItemModel()
{ {
Id = user.UserId, Id = user.UserId,
DisplayName = user.DisplayName, UserDisplayName = user.DisplayName,
UserEmailAddress = user.EmailAddress,
Scope = $"User Detail '{key}'{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")} Matches User", Scope = $"User Detail '{key}'{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")} Matches User",
IsError = false, IsError = false,
}); });
} }
} }
return Json(results); return results;
}
private List<BulkGenerateItemModel> BulkGenerateDeviceAddUserDetail((string key, string value) arg)
{
var (key, value) = arg;
var results = new List<BulkGenerateItemModel>();
var query = Database.UserDetails.Include(d => d.User.DeviceUserAssignments).Where(d => d.Scope == "Details" && d.Key == key);
if (!string.IsNullOrWhiteSpace(value))
{
query = query.Where(d => d.Value == value);
}
var details = query.ToList();
if (details.Count > 0)
{
foreach (var dbUser in details.Select(d => d.User).Distinct())
{
var assignments = dbUser.CurrentDeviceAssignments;
if (assignments.Count == 0)
continue;
var user = dbUser;
if (UserService.TryGetUser(user.UserId, Database, true, out var adUser))
user = adUser; // use updated user from AD
foreach (var assignment in assignments)
{
results.Add(new BulkGenerateItemModel()
{
Id = assignment.DeviceSerialNumber,
UserDisplayName = user.DisplayName,
UserEmailAddress = user.EmailAddress,
Scope = $"User Detail '{key}'{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")} Matches User '{user.UserId}'",
IsError = false,
});
}
}
}
if (results.Count == 0)
{
results.Add(new BulkGenerateItemModel()
{
Id = key,
UserDisplayName = $"{key}{(string.IsNullOrWhiteSpace(value) ? null : $":{value}")}",
Scope = $"User Detail '{key}' didn't match any devices{(string.IsNullOrWhiteSpace(value) ? null : $" with the value '{value}'")}",
IsError = true,
});
}
else
{
var distinctSet = new HashSet<string>(StringComparer.Ordinal);
results = results.Where(r => distinctSet.Add(r.Id)).ToList();
}
return results;
} }
[HttpPost, ValidateAntiForgeryToken] [HttpPost, ValidateAntiForgeryToken]
@@ -1,6 +1,5 @@
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Services; using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web; using Disco.Services.Web;
using System; using System;
using System.Data.Entity; using System.Data.Entity;
@@ -1,10 +1,10 @@
namespace Disco.Web.Areas.API.Models.DocumentTemplate namespace Disco.Web.Areas.API.Models.DocumentTemplate
{ {
public class BulkGenerateUserModel public class BulkGenerateItemModel
{ {
public string Id { get; set; } public string Id { get; set; }
public string UserEmailAddress { get; set; } public string UserEmailAddress { get; set; }
public string DisplayName { get; set; } public string UserDisplayName { get; set; }
public string Scope { get; set; } public string Scope { get; set; }
public bool IsError { get; set; } public bool IsError { get; set; }
} }
@@ -2,7 +2,6 @@
using Disco.Models.UI.Config.DeviceBatch; using Disco.Models.UI.Config.DeviceBatch;
using Disco.Services; using Disco.Services;
using Disco.Services.Authorization; using Disco.Services.Authorization;
using Disco.Services.Devices;
using Disco.Services.Devices.ManagedGroups; using Disco.Services.Devices.ManagedGroups;
using Disco.Services.Plugins.Features.UIExtension; using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web; using Disco.Services.Web;
@@ -1,5 +1,4 @@
using Disco.Models.Areas.Config.UI.DeviceFlag; using Disco.Models.Areas.Config.UI.DeviceFlag;
using Disco.Models.Repository;
using Disco.Models.Services.Devices.DeviceFlag; using Disco.Models.Services.Devices.DeviceFlag;
using Disco.Models.UI.Config.DeviceFlag; using Disco.Models.UI.Config.DeviceFlag;
using Disco.Services.Authorization; using Disco.Services.Authorization;
@@ -209,7 +209,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
else else
{ {
ModelState.AddModelError("Id", "A Document Template Package with this Id already exists."); ModelState.AddModelError(nameof(model.Id), "A Document Template Package with this Id already exists.");
} }
} }
@@ -219,19 +219,22 @@ namespace Disco.Web.Areas.Config.Controllers
return View(model); return View(model);
} }
public static ConfigDocumentTemplateBulkGenerate BuildBulkGenerateModel(DocumentTemplate documentTemplate, DiscoDataContext database, AuthorizationToken authorization) public static (string viewName, ConfigDocumentTemplateBulkGenerate model) BuildBulkGenerateModel(DocumentTemplate documentTemplate, DiscoDataContext database, AuthorizationToken authorization)
{ {
var model = new BulkGenerateModel() BulkGenerateModel model;
{ string viewName;
DocumentTemplate = documentTemplate,
};
model.TemplatePageCount = model.DocumentTemplate.PdfPageHasAttachmentId(database).Count; if (documentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.User)
model.UserFlags = database.UserFlags.Select(f => new ItemWithCount<UserFlag>() {
authorization.Require(Claims.User.Actions.GenerateDocuments);
model = new BulkGenerateUserModel()
{
UserFlags = database.UserFlags.Select(f => new ItemWithCount<UserFlag>()
{ {
Item = f, Item = f,
Count = f.UserFlagAssignments.Where(a => a.RemovedDate == null).Count(), Count = f.UserFlagAssignments.Where(a => a.RemovedDate == null).Count(),
}).ToList(); }).ToList(),
};
model.DeviceProfiles = database.DeviceProfiles.Select(p => new ItemWithCount<DeviceProfile>() model.DeviceProfiles = database.DeviceProfiles.Select(p => new ItemWithCount<DeviceProfile>()
{ {
Item = p, Item = p,
@@ -275,11 +278,75 @@ namespace Disco.Web.Areas.Config.Controllers
{ {
model.UserDetails = new List<ItemWithCount<string>>(); model.UserDetails = new List<ItemWithCount<string>>();
} }
viewName = MVC.Config.DocumentTemplate.Views.BulkGenerateUser;
}
else if (documentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.Device)
{
authorization.Require(Claims.Device.Actions.GenerateDocuments);
model = new BulkGenerateDeviceModel()
{
DeviceFlags = database.DeviceFlags.Select(f => new ItemWithCount<DeviceFlag>()
{
Item = f,
Count = f.DeviceFlagAssignments.Where(a => a.RemovedDate == null).Count(),
}).ToList(),
};
model.DeviceProfiles = database.DeviceProfiles.Select(p => new ItemWithCount<DeviceProfile>()
{
Item = p,
Count = p.Devices.Count(),
}).ToList();
model.DeviceBatches = database.DeviceBatches.Select(p => new ItemWithCount<DeviceBatch>()
{
Item = p,
Count = p.Devices.Count(),
}).ToList();
model.DocumentTemplates = database.DocumentTemplates.Select(dt => new ItemWithCount<DocumentTemplate>()
{
Item = dt,
}).ToList();
foreach (var record in model.DocumentTemplates)
{
switch (record.Item.AttachmentType)
{
case AttachmentTypes.Device:
record.Count = database.DeviceAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Device).Distinct().Count();
break;
case AttachmentTypes.Job:
record.Count = database.JobAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Job.Device).Distinct().Count();
break;
case AttachmentTypes.User:
record.Count = database.UserAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).SelectMany(a => a.User.DeviceUserAssignments).Where(a => a.UnassignedDate == null).Select(a => a.DeviceSerialNumber).Distinct().Count();
break;
default:
throw new NotSupportedException();
}
}
if (authorization.Has(Claims.User.ShowDetails))
{
model.UserDetails = database.UserDetails.Where(d => d.Scope == "Details").GroupBy(d => d.Key).Select(g => new ItemWithCount<string>()
{
Item = g.Key,
Count = g.Select(i => i.User).SelectMany(u => u.DeviceUserAssignments).Where(a => a.UnassignedDate == null).Count(),
}).ToList();
}
else
{
model.UserDetails = new List<ItemWithCount<string>>();
}
viewName = MVC.Config.DocumentTemplate.Views.BulkGenerateDevice;
}
else
throw new NotSupportedException("Only user and device scoped document templates can be bulk generated using this method");
return model; model.DocumentTemplate = documentTemplate;
model.TemplatePageCount = model.DocumentTemplate.PdfPageHasAttachmentId(database).Count;
return (viewName, model);
} }
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)] [DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate)]
public virtual ActionResult BulkGenerate(string id) public virtual ActionResult BulkGenerate(string id)
{ {
var documentTemplate = Database.DocumentTemplates.FirstOrDefault(at => at.Id == id); var documentTemplate = Database.DocumentTemplates.FirstOrDefault(at => at.Id == id);
@@ -287,16 +354,15 @@ namespace Disco.Web.Areas.Config.Controllers
if (documentTemplate == null) if (documentTemplate == null)
throw new ArgumentException("Invalid Document Template Id", nameof(id)); throw new ArgumentException("Invalid Document Template Id", nameof(id));
if (documentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.User) if (documentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.User && documentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.Device)
throw new NotSupportedException("Only user-scoped document templates can be bulk generated using this method"); throw new NotSupportedException("Only user-scoped document templates can be bulk generated using this method");
var (viewName, model) = BuildBulkGenerateModel(documentTemplate, Database, Authorization);
var model = BuildBulkGenerateModel(documentTemplate, Database, Authorization);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions(ControllerContext, model); UIExtensions.ExecuteExtensions(ControllerContext, model);
return View(MVC.Config.DocumentTemplate.Views.BulkGenerate, model); return View(viewName, model);
} }
[HttpGet] [HttpGet]
@@ -1,5 +1,4 @@
using Disco.Models.Repository; using Disco.Models.Services.Jobs.JobQueues;
using Disco.Models.Services.Jobs.JobQueues;
using Disco.Models.UI.Config.JobQueue; using Disco.Models.UI.Config.JobQueue;
using Disco.Services.Authorization; using Disco.Services.Authorization;
using Disco.Services.Extensions; using Disco.Services.Extensions;
@@ -7,10 +7,19 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
{ {
public Disco.Models.Repository.DocumentTemplate DocumentTemplate { get; set; } public Disco.Models.Repository.DocumentTemplate DocumentTemplate { get; set; }
public int TemplatePageCount { get; set; } public int TemplatePageCount { get; set; }
public List<ItemWithCount<Disco.Models.Repository.UserFlag>> UserFlags { get; set; }
public List<ItemWithCount<Disco.Models.Repository.DeviceProfile>> DeviceProfiles { get; set; } public List<ItemWithCount<Disco.Models.Repository.DeviceProfile>> DeviceProfiles { get; set; }
public List<ItemWithCount<Disco.Models.Repository.DeviceBatch>> DeviceBatches { get; set; } public List<ItemWithCount<Disco.Models.Repository.DeviceBatch>> DeviceBatches { get; set; }
public List<ItemWithCount<Disco.Models.Repository.DocumentTemplate>> DocumentTemplates { get; set; } public List<ItemWithCount<Disco.Models.Repository.DocumentTemplate>> DocumentTemplates { get; set; }
public List<ItemWithCount<string>> UserDetails { get; set; } public List<ItemWithCount<string>> UserDetails { get; set; }
} }
public class BulkGenerateUserModel : BulkGenerateModel, ConfigDocumentTemplateBulkGenerateUser
{
public List<ItemWithCount<Disco.Models.Repository.UserFlag>> UserFlags { get; set; }
}
public class BulkGenerateDeviceModel : BulkGenerateModel, ConfigDocumentTemplateBulkGenerateDevice
{
public List<ItemWithCount<Disco.Models.Repository.DeviceFlag>> DeviceFlags { get; set; }
}
} }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,61 @@
@model Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateDeviceModel
@{
Authorization.RequireAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description, MVC.Config.DocumentTemplate.Index(Model.DocumentTemplate.Id), "Bulk Generate");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentBulkGenerate");
}
<div id="DocumentTemplate_BulkGenerate">
<div class="actions">
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)))
{
if (Model.TemplatePageCount > 1 && Model.TemplatePageCount % 2 != 0)
{
<input id="DocumentTemplate_BulkGenerate_InsertBlankPage" type="checkbox" name="InsertBlankPage" value="True" checked /><label for="DocumentTemplate_BulkGenerate_InsertBlankPage">Insert Blank Pages for Double-Sided Printing</label>
}
<input id="DocumentTemplate_BulkGenerate_DataIds" name="DataIds" type="hidden" />
<button id="BulkGenerate" class="button" disabled>Bulk Generate</button>
@Html.AntiForgeryToken()
}
<br />
<button id="AddDevices" class="button small">Add Devices</button>
@if (Model.DeviceFlags.Any(f => f.Count > 0))
{
<button id="AddDeviceFlag" class="button small">Add With Device Flag</button>
}
@if (Model.DeviceProfiles.Any(b => b.Count > 0))
{
<button id="AddDeviceProfile" class="button small">Add With Device Profile</button>
}
@if (Model.DeviceBatches.Any(b => b.Count > 0))
{
<button id="AddDeviceBatch" class="button small">Add With Device Batch</button>
}
@if (Model.DocumentTemplates.Any(b => b.Count > 0))
{
<button id="AddDocumentAttachment" class="button small">Add With Document Attachment</button>
}
<button id="AddUsers" class="button small">Add With Assigned User</button>
@if (Model.UserDetails.Any(b => b.Count > 0))
{
<button id="AddUserDetail" class="button small">Add With Assigned User Detail</button>
}
</div>
<table id="DocumentTemplate_BulkGenerate_Records" class="genericData" data-scope="device">
<thead>
<tr>
<th>&nbsp;</th>
<th>Serial Number</th>
<th class="name">&nbsp;</th>
<th>Scope</th>
</tr>
</thead>
<tbody>
<tr class="when-none">
<td colspan="4">Add Devices</td>
</tr>
</tbody>
</table>
</div>
@Html.Partial(MVC.Config.DocumentTemplate.Views._BulkGenerateShared, Model)
@@ -0,0 +1,332 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DocumentTemplate
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DocumentTemplate/BulkGenerateDevice.cshtml")]
public partial class BulkGenerateDevice : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateDeviceModel>
{
public BulkGenerateDevice()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
Authorization.RequireAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description, MVC.Config.DocumentTemplate.Index(Model.DocumentTemplate.Id), "Bulk Generate");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentBulkGenerate");
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" class=\"actions\"");
WriteLiteral(">\r\n");
#line 10 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
#line default
#line hidden
#line 10 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)))
{
if (Model.TemplatePageCount > 1 && Model.TemplatePageCount % 2 != 0)
{
#line default
#line hidden
WriteLiteral(" <input");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_InsertBlankPage\"");
WriteLiteral(" type=\"checkbox\"");
WriteLiteral(" name=\"InsertBlankPage\"");
WriteLiteral(" value=\"True\"");
WriteLiteral(" checked />");
WriteLiteral("<label");
WriteLiteral(" for=\"DocumentTemplate_BulkGenerate_InsertBlankPage\"");
WriteLiteral(">Insert Blank Pages for Double-Sided Printing</label>\r\n");
#line 15 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" <input");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_DataIds\"");
WriteLiteral(" name=\"DataIds\"");
WriteLiteral(" type=\"hidden\"");
WriteLiteral(" />\r\n");
WriteLiteral(" <button");
WriteLiteral(" id=\"BulkGenerate\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(" disabled>Bulk Generate</button>\r\n");
#line 18 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
#line default
#line hidden
#line 18 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
Write(Html.AntiForgeryToken());
#line default
#line hidden
#line 18 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" <br />\r\n <button");
WriteLiteral(" id=\"AddDevices\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add Devices</button>\r\n");
#line 22 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
#line default
#line hidden
#line 22 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
if (Model.DeviceFlags.Any(f => f.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDeviceFlag\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Device Flag</button>\r\n");
#line 25 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 26 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
if (Model.DeviceProfiles.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDeviceProfile\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Device Profile</button>\r\n");
#line 29 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 30 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
if (Model.DeviceBatches.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDeviceBatch\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Device Batch</button>\r\n");
#line 33 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 34 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
if (Model.DocumentTemplates.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDocumentAttachment\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Document Attachment</button>\r\n");
#line 37 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddUsers\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Assigned User</button>\r\n");
#line 39 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
#line default
#line hidden
#line 39 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
if (Model.UserDetails.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddUserDetail\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Assigned User Detail</button>\r\n");
#line 42 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n <table");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_Records\"");
WriteLiteral(" class=\"genericData\"");
WriteLiteral(" data-scope=\"device\"");
WriteLiteral(">\r\n <thead>\r\n <tr>\r\n <th>&nbsp;</th>\r\n " +
" <th>Serial Number</th>\r\n <th");
WriteLiteral(" class=\"name\"");
WriteLiteral(">&nbsp;</th>\r\n <th>Scope</th>\r\n </tr>\r\n </thead>" +
"\r\n <tbody>\r\n <tr");
WriteLiteral(" class=\"when-none\"");
WriteLiteral(">\r\n <td");
WriteLiteral(" colspan=\"4\"");
WriteLiteral(">Add Devices</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n");
#line 61 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml"
Write(Html.Partial(MVC.Config.DocumentTemplate.Views._BulkGenerateShared, Model));
#line default
#line hidden
WriteLiteral("\r\n");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,62 @@
@model Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateUserModel
@using Disco.Services.Interop.ActiveDirectory;
@{
Authorization.RequireAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description, MVC.Config.DocumentTemplate.Index(Model.DocumentTemplate.Id), "Bulk Generate");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentBulkGenerate");
}
<div id="DocumentTemplate_BulkGenerate">
<div class="actions">
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)))
{
if (Model.TemplatePageCount > 1 && Model.TemplatePageCount % 2 != 0)
{
<input id="DocumentTemplate_BulkGenerate_InsertBlankPage" type="checkbox" name="InsertBlankPage" value="True" checked /><label for="DocumentTemplate_BulkGenerate_InsertBlankPage">Insert Blank Pages for Double-Sided Printing</label>
}
<input id="DocumentTemplate_BulkGenerate_DataIds" name="DataIds" type="hidden" />
<button id="BulkGenerate" class="button" disabled>Bulk Generate</button>
@Html.AntiForgeryToken()
}
<br />
<button id="AddUsers" class="button small">Add Users</button>
<button id="AddGroupMembers" class="button small">Add Group Members</button>
@if (Model.UserFlags.Any(f => f.Count > 0))
{
<button id="AddUserFlag" class="button small">Add With User Flag</button>
}
@if (Model.DeviceProfiles.Any(b => b.Count > 0))
{
<button id="AddDeviceProfile" class="button small">Add With Device Profile</button>
}
@if (Model.DeviceBatches.Any(b => b.Count > 0))
{
<button id="AddDeviceBatch" class="button small">Add With Device Batch</button>
}
@if (Model.DocumentTemplates.Any(b => b.Count > 0))
{
<button id="AddDocumentAttachment" class="button small">Add With Document Attachment</button>
}
@if (Model.UserDetails.Any(b => b.Count > 0))
{
<button id="AddUserDetail" class="button small">Add With User Detail</button>
}
</div>
<table id="DocumentTemplate_BulkGenerate_Records" class="genericData" data-scope="user">
<thead>
<tr>
<th>&nbsp;</th>
<th>Username</th>
<th class="name">Name</th>
<th>Scope</th>
</tr>
</thead>
<tbody>
<tr class="when-none">
<td colspan="4">Add Users</td>
</tr>
</tbody>
</table>
</div>
@Html.Partial(MVC.Config.DocumentTemplate.Views._BulkGenerateShared, Model)
@@ -0,0 +1,332 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DocumentTemplate
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
#line 2 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
using Disco.Services.Interop.ActiveDirectory;
#line default
#line hidden
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DocumentTemplate/BulkGenerateUser.cshtml")]
public partial class BulkGenerateUser : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateUserModel>
{
public BulkGenerateUser()
{
}
public override void Execute()
{
#line 3 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
Authorization.RequireAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description, MVC.Config.DocumentTemplate.Index(Model.DocumentTemplate.Id), "Bulk Generate");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentBulkGenerate");
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" class=\"actions\"");
WriteLiteral(">\r\n");
#line 11 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
#line default
#line hidden
#line 11 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)))
{
if (Model.TemplatePageCount > 1 && Model.TemplatePageCount % 2 != 0)
{
#line default
#line hidden
WriteLiteral(" <input");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_InsertBlankPage\"");
WriteLiteral(" type=\"checkbox\"");
WriteLiteral(" name=\"InsertBlankPage\"");
WriteLiteral(" value=\"True\"");
WriteLiteral(" checked />");
WriteLiteral("<label");
WriteLiteral(" for=\"DocumentTemplate_BulkGenerate_InsertBlankPage\"");
WriteLiteral(">Insert Blank Pages for Double-Sided Printing</label>\r\n");
#line 16 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" <input");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_DataIds\"");
WriteLiteral(" name=\"DataIds\"");
WriteLiteral(" type=\"hidden\"");
WriteLiteral(" />\r\n");
WriteLiteral(" <button");
WriteLiteral(" id=\"BulkGenerate\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(" disabled>Bulk Generate</button>\r\n");
#line 19 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
#line default
#line hidden
#line 19 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
Write(Html.AntiForgeryToken());
#line default
#line hidden
#line 19 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" <br />\r\n <button");
WriteLiteral(" id=\"AddUsers\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add Users</button>\r\n <button");
WriteLiteral(" id=\"AddGroupMembers\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add Group Members</button>\r\n");
#line 24 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
#line default
#line hidden
#line 24 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
if (Model.UserFlags.Any(f => f.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddUserFlag\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With User Flag</button>\r\n");
#line 27 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 28 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
if (Model.DeviceProfiles.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDeviceProfile\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Device Profile</button>\r\n");
#line 31 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 32 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
if (Model.DeviceBatches.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDeviceBatch\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Device Batch</button>\r\n");
#line 35 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 36 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
if (Model.DocumentTemplates.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddDocumentAttachment\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With Document Attachment</button>\r\n");
#line 39 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 40 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
if (Model.UserDetails.Any(b => b.Count > 0))
{
#line default
#line hidden
WriteLiteral(" <button");
WriteLiteral(" id=\"AddUserDetail\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add With User Detail</button>\r\n");
#line 43 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n <table");
WriteLiteral(" id=\"DocumentTemplate_BulkGenerate_Records\"");
WriteLiteral(" class=\"genericData\"");
WriteLiteral(" data-scope=\"user\"");
WriteLiteral(">\r\n <thead>\r\n <tr>\r\n <th>&nbsp;</th>\r\n " +
" <th>Username</th>\r\n <th");
WriteLiteral(" class=\"name\"");
WriteLiteral(">Name</th>\r\n <th>Scope</th>\r\n </tr>\r\n </thead>\r\n" +
" <tbody>\r\n <tr");
WriteLiteral(" class=\"when-none\"");
WriteLiteral(">\r\n <td");
WriteLiteral(" colspan=\"4\"");
WriteLiteral(">Add Users</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n");
#line 62 "..\..\Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml"
Write(Html.Partial(MVC.Config.DocumentTemplate.Views._BulkGenerateShared, Model));
#line default
#line hidden
WriteLiteral("\r\n");
}
}
}
#pragma warning restore 1591
@@ -1039,7 +1039,7 @@
} }
@if (canBulkGenerate) @if (canBulkGenerate)
{ {
if (Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.User) if (Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.User || Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.Device)
{ {
@Html.ActionLinkButton("Bulk Generate", MVC.Config.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)) @Html.ActionLinkButton("Bulk Generate", MVC.Config.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id))
} }
@@ -3289,7 +3289,7 @@ WriteLiteral(" ");
#line 1040 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml" #line 1040 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
if (canBulkGenerate) if (canBulkGenerate)
{ {
if (Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.User) if (Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.User || Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.Device)
{ {
@@ -3328,16 +3328,16 @@ WriteLiteral(" id=\"dialogBulkGenerate\"");
WriteLiteral(" class=\"dialog dialog-bulk-generate\""); WriteLiteral(" class=\"dialog dialog-bulk-generate\"");
WriteAttribute("title", Tuple.Create(" title=\"", 62559), Tuple.Create("\"", 62610) WriteAttribute("title", Tuple.Create(" title=\"", 62641), Tuple.Create("\"", 62692)
, Tuple.Create(Tuple.Create("", 62567), Tuple.Create("Bulk", 62567), true) , Tuple.Create(Tuple.Create("", 62649), Tuple.Create("Bulk", 62649), true)
, Tuple.Create(Tuple.Create(" ", 62571), Tuple.Create("Generate:", 62572), true) , Tuple.Create(Tuple.Create(" ", 62653), Tuple.Create("Generate:", 62654), true)
#line 1049 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml" #line 1049 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
, Tuple.Create(Tuple.Create(" ", 62581), Tuple.Create<System.Object, System.Int32>(Model.DocumentTemplate.Id , Tuple.Create(Tuple.Create(" ", 62663), Tuple.Create<System.Object, System.Int32>(Model.DocumentTemplate.Id
#line default #line default
#line hidden #line hidden
, 62582), false) , 62664), false)
); );
WriteLiteral(">\r\n <div"); WriteLiteral(">\r\n <div");
@@ -3631,14 +3631,14 @@ WriteLiteral(" title=\"Download Bulk Documents\"");
WriteLiteral(">\r\n <a"); WriteLiteral(">\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 67770), Tuple.Create("\"", 67907) WriteAttribute("href", Tuple.Create(" href=\"", 67852), Tuple.Create("\"", 67989)
#line 1138 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml" #line 1138 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
, Tuple.Create(Tuple.Create("", 67777), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DocumentTemplate.BulkGenerateDownload(Model.BulkGenerateDownloadId.Value, Model.BulkGenerateDownloadFilename)) , Tuple.Create(Tuple.Create("", 67859), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DocumentTemplate.BulkGenerateDownload(Model.BulkGenerateDownloadId.Value, Model.BulkGenerateDownloadFilename))
#line default #line default
#line hidden #line hidden
, 67777), false) , 67859), false)
); );
WriteLiteral(" class=\"button\""); WriteLiteral(" class=\"button\"");
@@ -1,93 +1,106 @@
@model Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateModel @model Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateModel
@using Disco.Services.Interop.ActiveDirectory; @using Disco.Services.Interop.ActiveDirectory;
@{ @{
Authorization.RequireAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments); if (Model == null)
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description, MVC.Config.DocumentTemplate.Index(Model.DocumentTemplate.Id), "Bulk Generate");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentBulkGenerate");
}
<div id="DocumentTemplate_BulkGenerate">
<div class="actions">
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id)))
{ {
if (Model.TemplatePageCount > 1 && Model.TemplatePageCount % 2 != 0) throw new ArgumentNullException("Model", "Model cannot be null.");
}
var userModel = Model as Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateUserModel;
var deviceModel = Model as Disco.Web.Areas.Config.Models.DocumentTemplate.BulkGenerateDeviceModel;
string scope;
if (userModel != null)
{ {
<input id="DocumentTemplate_BulkGenerate_InsertBlankPage" type="checkbox" name="InsertBlankPage" value="True" checked /><label for="DocumentTemplate_BulkGenerate_InsertBlankPage">Insert Blank Pages for Double-Sided Printing</label> scope = "user";
} }
<input id="DocumentTemplate_BulkGenerate_DataIds" name="DataIds" type="hidden" /> else if (deviceModel != null)
<button id="BulkGenerate" class="button" disabled>Bulk Generate</button>
@Html.AntiForgeryToken()
}
<br />
<button id="AddUsers" class="button small">Add Users</button>
<button id="AddGroupMembers" class="button small">Add Group Members</button>
@if (Model.UserFlags.Any(f => f.Count > 0))
{ {
<button id="AddUserFlag" class="button small">Add With User Flag</button> scope = "device";
} }
@if (Model.DeviceProfiles.Any(b => b.Count > 0)) else
{ {
<button id="AddDeviceProfile" class="button small">Add With Device Profile</button> throw new InvalidOperationException("Unexpected model: " + Model.GetType().FullName);
} }
@if (Model.DeviceBatches.Any(b => b.Count > 0))
{
<button id="AddDeviceBatch" class="button small">Add With Device Batch</button>
} }
@if (Model.DocumentTemplates.Any(b => b.Count > 0)) <div id="DocumentTemplate_BulkGenerate_Dialog_AddUsers" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Users">
{
<button id="AddDocumentAttachment" class="button small">Add With Document Attachment</button>
}
@if (Model.UserDetails.Any(b => b.Count > 0))
{
<button id="AddUserDetail" class="button small">Add With User Detail</button>
}
</div>
<table class="genericData">
<thead>
<tr>
<th>&nbsp;</th>
<th>Username</th>
<th>Name</th>
<th>Scope</th>
</tr>
</thead>
<tbody>
<tr class="when-none">
<td colspan="4">Add Users</td>
</tr>
</tbody>
</table>
</div>
<div id="DocumentTemplate_BulkGenerate_Dialog_AddUsers" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add Users">
<div class="brief"> <div class="brief">
<div> <div>
Enter multiple <span class="scopeDescBulkGenerate">User Ids</span> separated by <code>&lt;new line&gt;</code>, commas (<code>,</code>) or semicolons (<code>;</code>). Enter multiple <span class="scopeDescBulkGenerate">User Ids</span> separated by <code>&lt;new line&gt;</code>, commas (<code>,</code>) or semicolons (<code>;</code>).
</div> </div>
@if (userModel != null)
{
<div> <div>
Security Groups can also be included. Members will be resolved and added. Security Groups can also be included. Members will be resolved and added.
</div> </div>
}
@if (deviceModel != null)
{
<div>
Devices associated with the users will be added.
</div>
}
<div class="examples clearfix"> <div class="examples clearfix">
<h4>Examples:</h4> <h4>Examples:</h4>
<div class="example1 code"> <div class="example1 code">
user6<br /> user6<br />
smi0099<br /> smi0099<br />
@(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith<br /> @(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith<br />
Domain Admins @if (userModel != null)
{
<text>Domain Admins</text>
}
</div>
<div class="example2 code">
user6,smi0099,@(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith
</div>
<div class="example3 code">
user6;smi0099;@(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith
</div> </div>
<div class="example2 code">user6,smi0099,@(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith,Domain Admins</div>
<div class="example3 code">user6;smi0099;@(ActiveDirectory.Context.PrimaryDomain.NetBiosName)\rsmith;Domain Admins</div>
</div> </div>
</div> </div>
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddUsers())) @using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddUsers()))
{ {
<div class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="userIds"></div> <div class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="userIds"></div>
<textarea id="inputBulkGenerateDataIds" name="userIds" data-val="true" data-val-required="Identifiers are required" required></textarea> <textarea id="inputBulkGenerateDataIds" name="userIds" data-val="true" data-val-required="Identifiers are required" required></textarea>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
<div id="DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add Group Members"> @if (deviceModel != null)
{
<div id="DocumentTemplate_BulkGenerate_Dialog_AddDevices" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Devices">
<div class="brief">
<div>
Enter multiple <span class="scopeDescBulkGenerate">Device Serial Numbers</span> separated by <code>&lt;new line&gt;</code>, commas (<code>,</code>) or semicolons (<code>;</code>).
</div>
<div class="examples clearfix">
<h4>Examples:</h4>
<div class="example1 code">
LAPTOP-12345<br />
TAB-987654<br />
PHONE-ABC321
</div>
<div class="example2 code">
LAPTOP-12345,TAB-987654,PHONE-ABC321
</div>
<div class="example3 code">
LAPTOP-12345;TAB-987654;PHONE-ABC321
</div>
</div>
</div>
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddDevices()))
{
<div class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="userIds"></div>
<textarea name="deviceSerialNumbers" data-val="true" data-val-required="Identifiers are required" required></textarea>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken()
}
</div>
}
@if (userModel != null)
{
<div id="DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Group Members">
<div class="brief"> <div class="brief">
<div> <div>
Add all members of a group (including recursive members) to the bulk generation. Add all members of a group (including recursive members) to the bulk generation.
@@ -110,10 +123,11 @@
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
}
@if (Model.UserFlags.Any(f => f.Count > 0)) @if (userModel != null && userModel.UserFlags.Any(f => f.Count > 0))
{ {
<div id="DocumentTemplate_BulkGenerate_Dialog_AddUserFlag" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User Flag Assignments"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddUserFlag" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User Flag">
<div class="brief"> <div class="brief">
<div> <div>
Add all users associated with the flag to the bulk generation. Add all users associated with the flag to the bulk generation.
@@ -123,10 +137,35 @@
{ {
<input name="flagId" type="hidden" required /> <input name="flagId" type="hidden" required />
<div class="dialog-item-picker"> <div class="dialog-item-picker">
@foreach (var flag in Model.UserFlags) @foreach (var flag in userModel.UserFlags)
{ {
<div class="item @(flag.Count == 0 ? "disabled" : null)" data-userflagid="@flag.Item.Id"> <div class="item @(flag.Count == 0 ? "disabled" : null)" data-userflagid="@flag.Item.Id">
<i class="fa fa-@(flag.Item.Icon) fa-fw fa-lg d-@(flag.Item.IconColour)"></i>@flag.Item.Name <small>(@flag.Count.ToString("N0") user@(flag.Count == 1 ? null : "s"))</small> <i class="fa fa-@(flag.Item.Icon) fa-fw fa-lg d-@(flag.Item.IconColour)"></i>@flag.Item.Name <small>(@flag.Count.ToString("N0") @scope@(flag.Count == 1 ? null : "s"))</small>
</div>
}
</div>
@Html.AntiForgeryToken()
}
</div>
}
@if (deviceModel != null && deviceModel.DeviceFlags.Any(f => f.Count > 0))
{
<div id="DocumentTemplate_BulkGenerate_Dialog_AddDeviceFlag" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add Device Flag">
<div class="brief">
<div>
Add all devices associated with the flag to the bulk generation.
</div>
</div>
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddDeviceFlag()))
{
<input name="flagId" type="hidden" required />
<div class="dialog-item-picker">
@foreach (var flag in deviceModel.DeviceFlags)
{
<div class="item @(flag.Count == 0 ? "disabled" : null)" data-userflagid="@flag.Item.Id">
<i class="fa fa-@(flag.Item.Icon) fa-fw fa-lg d-@(flag.Item.IconColour)"></i>@flag.Item.Name <small>(@flag.Count.ToString("N0") @scope@(flag.Count == 1 ? null : "s"))</small>
</div> </div>
} }
@@ -138,12 +177,15 @@
@if (Model.DeviceProfiles.Any(b => b.Count > 0)) @if (Model.DeviceProfiles.Any(b => b.Count > 0))
{ {
<div id="DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User by Assigned Device Profile"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Device Profile">
@if (userModel != null)
{
<div class="brief"> <div class="brief">
<div> <div>
Add all users associated with a device in the selected profile to the bulk generation. Add all users associated with a device in the selected profile to the bulk generation.
</div> </div>
</div> </div>
}
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddDeviceProfile())) @using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddDeviceProfile()))
{ {
<input name="deviceProfileId" type="hidden" required /> <input name="deviceProfileId" type="hidden" required />
@@ -151,10 +193,11 @@
@foreach (var profile in Model.DeviceProfiles) @foreach (var profile in Model.DeviceProfiles)
{ {
<div class="item @(profile.Count == 0 ? "disabled" : null)" data-id="@profile.Item.Id"> <div class="item @(profile.Count == 0 ? "disabled" : null)" data-id="@profile.Item.Id">
<i class="fa fa-cog fa-fw fa-lg"></i>@profile.Item.Name <small>(@profile.Count.ToString("N0") user@(profile.Count == 1 ? null : "s"))</small> <i class="fa fa-cog fa-fw fa-lg"></i>@profile.Item.Name <small>(@profile.Count.ToString("N0") @scope@(profile.Count == 1 ? null : "s"))</small>
</div> </div>
} }
</div> </div>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
@@ -162,7 +205,7 @@
@if (Model.DeviceBatches.Any(b => b.Count > 0)) @if (Model.DeviceBatches.Any(b => b.Count > 0))
{ {
<div id="DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User by Assigned Device Batch"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Device Batch">
<div class="brief"> <div class="brief">
<div> <div>
Add all users associated with a device in the selected batch to the bulk generation. Add all users associated with a device in the selected batch to the bulk generation.
@@ -175,10 +218,11 @@
@foreach (var batch in Model.DeviceBatches) @foreach (var batch in Model.DeviceBatches)
{ {
<div class="item @(batch.Count == 0 ? "disabled" : null)" data-id="@batch.Item.Id"> <div class="item @(batch.Count == 0 ? "disabled" : null)" data-id="@batch.Item.Id">
<i class="fa fa-cog fa-fw fa-lg"></i>@batch.Item.Name <small>(@batch.Count.ToString("N0") user@(batch.Count == 1 ? null : "s"))</small> <i class="fa fa-cog fa-fw fa-lg"></i>@batch.Item.Name <small>(@batch.Count.ToString("N0") @scope@(batch.Count == 1 ? null : "s"))</small>
</div> </div>
} }
</div> </div>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
@@ -186,7 +230,7 @@
@if (Model.DocumentTemplates.Any(b => b.Count > 0)) @if (Model.DocumentTemplates.Any(b => b.Count > 0))
{ {
<div id="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User by Assigned Device Batch"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by Document Attachment">
<div class="brief"> <div class="brief">
<div> <div>
Add all users associated with an attachment of the selected document template to the bulk generation. Add all users associated with an attachment of the selected document template to the bulk generation.
@@ -199,7 +243,7 @@
@foreach (var template in Model.DocumentTemplates) @foreach (var template in Model.DocumentTemplates)
{ {
<div class="item @(template.Count == 0 ? "disabled" : null)" data-id="@template.Item.Id"> <div class="item @(template.Count == 0 ? "disabled" : null)" data-id="@template.Item.Id">
<i class="fa fa-file-text-o fa-fw fa-lg"></i>@template.Item.Id: @template.Item.Description <small>(@template.Count.ToString("N0") user@(template.Count == 1 ? null : "s"))</small> <i class="fa fa-file-text-o fa-fw fa-lg"></i>@template.Item.Id: @template.Item.Description <small>(@template.Count.ToString("N0") @scope@(template.Count == 1 ? null : "s"))</small>
</div> </div>
} }
</div> </div>
@@ -207,6 +251,7 @@
<label for="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment_Threshold">Attachment Added After <small>(optional)</small></label> <label for="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment_Threshold">Attachment Added After <small>(optional)</small></label>
<input id="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment_Threshold" name="threshold" type="date" /> <input id="DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment_Threshold" name="threshold" type="date" />
</div> </div>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
@@ -214,11 +259,20 @@
@if (Model.UserDetails.Any(b => b.Count > 0)) @if (Model.UserDetails.Any(b => b.Count > 0))
{ {
<div id="DocumentTemplate_BulkGenerate_Dialog_AddUserDetail" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add User by Detail"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddUserDetail" class="dialog dialog-bulk-generate" title="@(Model.DocumentTemplate.Description): Add by User Detail">
<div class="brief"> <div class="brief">
@if (userModel != null)
{
<div> <div>
Add all users with a matching user detail to the bulk generation. Add all users with a matching user detail to the bulk generation.
</div> </div>
}
@if (deviceModel != null)
{
<div>
Add all devices assigned to users with a matching user detail to the bulk generation.
</div>
}
</div> </div>
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddUserDetail())) @using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateAddUserDetail()))
{ {
@@ -229,11 +283,11 @@
@foreach (var key in Model.UserDetails) @foreach (var key in Model.UserDetails)
{ {
<div class="item @(key.Count == 0 ? "disabled" : null)" data-id="@key.Item"> <div class="item @(key.Count == 0 ? "disabled" : null)" data-id="@key.Item">
<i class="fa fa-info fa-fw fa-lg"></i>@key.Item.TrimEnd('*', '&') <small>(@key.Count.ToString("N0") user@(key.Count == 1 ? null : "s"))</small> <i class="fa fa-info fa-fw fa-lg"></i>@key.Item.TrimEnd('*', '&') <small>(@key.Count.ToString("N0") @scope@(key.Count == 1 ? null : "s"))</small>
</div> </div>
} }
</div> </div>
<input type="hidden" name="scope" value="@scope" />
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
@using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateGetUserDetailValues())) @using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerateGetUserDetailValues()))
@@ -242,7 +296,6 @@
<div id="DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value" class="dialog-item-picker" style="width: 49%; float: left; margin-left: 1%;"> <div id="DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value" class="dialog-item-picker" style="width: 49%; float: left; margin-left: 1%;">
</div> </div>
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
} }
</div> </div>
File diff suppressed because it is too large Load Diff
@@ -1,36 +1,36 @@
$(() => { $(() => {
const users = []; const records = [];
const $table = $('#DocumentTemplate_BulkGenerate table'); const $table = $('#DocumentTemplate_BulkGenerate_Records');
const scope = $table.attr('data-scope');
function redrawTable() { function redrawTable() {
if (users.length > 0) { if (records.length > 0) {
$table.find('tbody tr:first-child').hide(); $table.find('tbody tr:first-child').hide();
} }
const $tbody = $table.find('tbody'); const $tbody = $table.find('tbody');
let checkedCount = 0; let checkedCount = 0;
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
var user = users[i]; var record = records[i];
if (user.checkbox === undefined) { if (record.checkbox === undefined) {
const tr = $('<tr><td><input id="BulkGenerate_User_' + i.toString() + '" type="checkbox" /></td><td><label for="BulkGenerate_User_' + i.toString() + '"></label></td><td><span class="name"></span></td><td><span class="scope"></span></td></tr>'); const tr = $('<tr><td><input id="BulkGenerate_User_' + i.toString() + '" type="checkbox" /></td><td><label for="BulkGenerate_User_' + i.toString() + '"></label></td><td class="name"><span class="name"></span></td><td><span class="scope"></span></td></tr>');
const checkbox = tr.find('input')[0]; const checkbox = tr.find('input')[0];
const label = tr.find('label'); const label = tr.find('label');
const name = tr.find('span.name'); const name = tr.find('span.name');
const scope = tr.find('span.scope'); const scope = tr.find('span.scope');
label.text(user.Id); label.text(record.Id);
scope.text(user.Scope); scope.text(record.Scope);
if (!user.IsError) { if (!record.IsError) {
checkbox.checked = true; checkbox.checked = true;
name.text(user.DisplayName); name.text(record.UserDisplayName);
checkedCount++; checkedCount++;
} else { } else {
tr.addClass('error'); tr.addClass('error');
checkbox.checked = false; checkbox.checked = false;
checkbox.disabled = true; checkbox.disabled = true;
} }
user.checkbox = checkbox; record.checkbox = checkbox;
$tbody.append(tr); $tbody.append(tr);
} else { } else {
if (!user.IsError && user.checkbox.checked) { if (!record.IsError && record.checkbox.checked) {
checkedCount++; checkedCount++;
} }
} }
@@ -42,13 +42,13 @@ $(() => {
} }
} }
function addUsers(r) { function addRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < r.length; i++) { for (var i = 0; i < r.length; i++) {
const user = r[i]; const item = r[i];
const record = users.find(u => u.Id === user.Id); const record = records.find(u => u.Id === item.Id);
if (record === undefined || user.IsError) { if (record === undefined || item.IsError) {
users.push(user); records.push(item);
changeCount++; changeCount++;
} else if (record.checkbox !== undefined && !record.checkbox.checked && !record.IsError) { } else if (record.checkbox !== undefined && !record.checkbox.checked && !record.IsError) {
record.checkbox.checked = true; record.checkbox.checked = true;
@@ -60,11 +60,11 @@ $(() => {
} }
} }
function excludeUsers(r) { function excludeRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < r.length; i++) { for (var i = 0; i < r.length; i++) {
const user = r[i]; const user = r[i];
const record = users.find(u => u.Id === user.Id); const record = records.find(u => u.Id === user.Id);
if (record !== undefined && record.checkbox !== undefined) { if (record !== undefined && record.checkbox !== undefined) {
record.checkbox.checked = false; record.checkbox.checked = false;
changeCount++; changeCount++;
@@ -75,12 +75,12 @@ $(() => {
} }
} }
function excludeOtherUsers(r) { function excludeOtherRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
const user = users[i]; const record = records[i];
if (!r.find(u => u.Id === user.Id)) { if (!r.find(u => u.Id === record.Id)) {
user.checkbox.checked = false; record.checkbox.checked = false;
changeCount++; changeCount++;
} }
} }
@@ -94,15 +94,15 @@ $(() => {
}); });
$('#BulkGenerate').click(e => { $('#BulkGenerate').click(e => {
let userIds = []; let dataIds = [];
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
var user = users[i]; var record = records[i];
if (!user.IsError && user.checkbox !== undefined && user.checkbox.checked) { if (!record.IsError && record.checkbox !== undefined && record.checkbox.checked) {
userIds.push(user.Id); dataIds.push(record.Id);
} }
} }
if (userIds.length > 0) { if (dataIds.length > 0) {
$('#DocumentTemplate_BulkGenerate_DataIds').val(userIds.join('\r\n')); $('#DocumentTemplate_BulkGenerate_DataIds').val(dataIds.join('\r\n'));
$('#BulkGenerate').closest('form').submit(); $('#BulkGenerate').closest('form').submit();
} }
}); });
@@ -113,45 +113,91 @@ $(() => {
let dialog = dialogAddUsers; let dialog = dialogAddUsers;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const results = await response.json();
.then(r => { applier(results);
applier(r);
dialog.find('textarea').html('').val(''); dialog.find('textarea').html('').val('');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate users: ' + e);
.catch(reason => {
alert('Failed to validate users: ' + reason);
});
} }
dialog.dialog("disable");
} }
}
const target = scope === 'user' ? 'Users' : 'Assigned Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: buttons
});
dialogAddUsers = dialog;
}
dialog.dialog('open');
return false;
});
let dialogAddDevices = null;
$('#AddDevices').click(e => {
e.preventDefault();
let dialog = dialogAddDevices;
if (!dialog) {
const action = async function (applier) {
const form = dialog.find('form')[0];
if (form.reportValidity()) {
const body = new FormData(form);
try {
const response = await fetch(form.action, {
method: 'POST',
body: body
});
const results = await response.json();
applier(results);
dialog.find('textarea').html('').val('');
dialog.dialog("close");
} catch (e) {
alert('Failed to validate devices: ' + e);
}
}
}
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDevices').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 550,
buttons: { buttons: {
"Exclude Other Users": function () { "Exclude Unmatched Devices": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Users": function () { "Exclude Devices": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Users": function () { "Add Devices": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
dialogAddUsers = dialog; dialogAddDevices = dialog;
} }
dialog.dialog('open'); dialog.dialog('open');
return false; return false;
@@ -163,41 +209,38 @@ $(() => {
let dialog = dialogAddGroupMembers; let dialog = dialogAddGroupMembers;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
dialog.find('input[type="text"]').val(''); dialog.find('input[type="text"]').val('');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate group: ' + e);
.catch(reason => { }
alert('Failed to validate group: ' + reason);
});
} }
dialog.dialog("disable");
} }
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: {
"Exclude Non-Group Members": function () { "Exclude Non-Group Members": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Group Members": function () { "Exclude Group Members": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Group Members": function () { "Add Group Members": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
@@ -227,42 +270,39 @@ $(() => {
let dialog = dialogAddUserFlag; let dialog = dialogAddUserFlag;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
dialog.find('input[name="flagId"]').val(''); dialog.find('input[name="flagId"]').val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate user flag: ' + e);
.catch(reason => { }
alert('Failed to validate user flag: ' + reason);
});
} }
dialog.dialog("disable");
} }
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: {
"Exclude Unassigned Users": function () { "Exclude Unassigned Users": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Assigned Users": function () { "Exclude Assigned Users": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Assigned Users": function () { "Add Assigned Users": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
@@ -281,52 +321,107 @@ $(() => {
return false; return false;
}); });
let dialogAddDeviceFlag = null;
$('#AddDeviceFlag').click(e => {
e.preventDefault();
let dialog = dialogAddDeviceFlag;
if (!dialog) {
const action = async function (applier) {
const form = dialog.find('form')[0];
if (form.reportValidity()) {
const body = new FormData(form);
try {
const response = await fetch(form.action, {
method: 'POST',
body: body
});
const result = await response.json();
applier(result);
dialog.find('input[name="flagId"]').val('');
dialog.find('div.item').removeClass('selected');
dialog.dialog("close");
} catch (e) {
alert('Failed to validate device flag: ' + e);
}
}
}
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceFlag').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 550,
buttons: {
"Exclude Unassigned Devices": function () {
action(excludeOtherRecords);
},
"Exclude Assigned Devices": function () {
action(excludeRecords);
},
"Add Assigned Devices": function () {
action(addRecords);
}
}
});
const $input = dialog.find('input[name="flagId"]');
dialog.on('click', 'div.item:not(.disabled)', e => {
e.preventDefault();
const $target = $(e.currentTarget);
$input.val($target.attr('data-userflagid'));
dialog.find('div.item').removeClass('selected');
$target.addClass('selected');
return false;
});
dialogAddDeviceFlag = dialog;
}
dialog.dialog('open');
return false;
});
let dialogAddDeviceProfile = null; let dialogAddDeviceProfile = null;
$('#AddDeviceProfile').click(e => { $('#AddDeviceProfile').click(e => {
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDeviceProfile; let dialog = dialogAddDeviceProfile;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="deviceProfileId"]'); const input = dialog.find('input[name="deviceProfileId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device profile: ' + e);
.catch(reason => {
alert('Failed to validate device profile: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Assigned Users' : 'Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="deviceProfileId"]'); const $input = dialog.find('input[name="deviceProfileId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -348,47 +443,45 @@ $(() => {
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDeviceBatch; let dialog = dialogAddDeviceBatch;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="deviceBatchId"]'); const input = dialog.find('input[name="deviceBatchId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device batch: ' + e);
.catch(reason => {
alert('Failed to validate device batch: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Assigned Users' : 'Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="deviceBatchId"]'); const $input = dialog.find('input[name="deviceBatchId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -410,47 +503,45 @@ $(() => {
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDocumentAttachment; let dialog = dialogAddDocumentAttachment;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="documentTemplateId"]'); const input = dialog.find('input[name="documentTemplateId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device batch: ' + e);
.catch(reason => {
alert('Failed to validate device batch: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Users' : 'Devices';
const buttons = {};
buttons[`Exclude Unassigned ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude Assigned ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add Assigned ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="documentTemplateId"]'); const $input = dialog.find('input[name="documentTemplateId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -472,49 +563,47 @@ $(() => {
e.preventDefault(); e.preventDefault();
let dialog = dialogAddUserDetail; let dialog = dialogAddUserDetail;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const key = $(form).find('input[name="key"]'); const key = $(form).find('input[name="key"]');
if (key.val()) { if (key.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
key.val(''); key.val('');
$(form).find('input[name="value"]').val(''); $(form).find('input[name="value"]').val('');
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty(); $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate user detail: ' + e);
.catch(reason => {
alert('Failed to validate user detail: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Users' : 'Devices';
const buttons = {};
buttons[`Exclude Unmatched ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude Matched ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add Matched ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 690, width: 690,
buttons: { buttons: buttons
"Exclude Unmatched Users": function () {
action(excludeOtherUsers);
},
"Exclude Matched Users": function () {
action(excludeUsers);
},
"Add Matched Users": function () {
action(addUsers);
}
}
}); });
const $key = dialog.find('input[name="key"]'); const $key = dialog.find('input[name="key"]');
const $value = dialog.find('input[name="value"]'); const $value = dialog.find('input[name="value"]');
File diff suppressed because one or more lines are too long
@@ -1,36 +1,36 @@
$(() => { $(() => {
const users = []; const records = [];
const $table = $('#DocumentTemplate_BulkGenerate table'); const $table = $('#DocumentTemplate_BulkGenerate_Records');
const scope = $table.attr('data-scope');
function redrawTable() { function redrawTable() {
if (users.length > 0) { if (records.length > 0) {
$table.find('tbody tr:first-child').hide(); $table.find('tbody tr:first-child').hide();
} }
const $tbody = $table.find('tbody'); const $tbody = $table.find('tbody');
let checkedCount = 0; let checkedCount = 0;
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
var user = users[i]; var record = records[i];
if (user.checkbox === undefined) { if (record.checkbox === undefined) {
const tr = $('<tr><td><input id="BulkGenerate_User_' + i.toString() + '" type="checkbox" /></td><td><label for="BulkGenerate_User_' + i.toString() + '"></label></td><td><span class="name"></span></td><td><span class="scope"></span></td></tr>'); const tr = $('<tr><td><input id="BulkGenerate_User_' + i.toString() + '" type="checkbox" /></td><td><label for="BulkGenerate_User_' + i.toString() + '"></label></td><td class="name"><span class="name"></span></td><td><span class="scope"></span></td></tr>');
const checkbox = tr.find('input')[0]; const checkbox = tr.find('input')[0];
const label = tr.find('label'); const label = tr.find('label');
const name = tr.find('span.name'); const name = tr.find('span.name');
const scope = tr.find('span.scope'); const scope = tr.find('span.scope');
label.text(user.Id); label.text(record.Id);
scope.text(user.Scope); scope.text(record.Scope);
if (!user.IsError) { if (!record.IsError) {
checkbox.checked = true; checkbox.checked = true;
name.text(user.DisplayName); name.text(record.UserDisplayName);
checkedCount++; checkedCount++;
} else { } else {
tr.addClass('error'); tr.addClass('error');
checkbox.checked = false; checkbox.checked = false;
checkbox.disabled = true; checkbox.disabled = true;
} }
user.checkbox = checkbox; record.checkbox = checkbox;
$tbody.append(tr); $tbody.append(tr);
} else { } else {
if (!user.IsError && user.checkbox.checked) { if (!record.IsError && record.checkbox.checked) {
checkedCount++; checkedCount++;
} }
} }
@@ -42,13 +42,13 @@
} }
} }
function addUsers(r) { function addRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < r.length; i++) { for (var i = 0; i < r.length; i++) {
const user = r[i]; const item = r[i];
const record = users.find(u => u.Id === user.Id); const record = records.find(u => u.Id === item.Id);
if (record === undefined || user.IsError) { if (record === undefined || item.IsError) {
users.push(user); records.push(item);
changeCount++; changeCount++;
} else if (record.checkbox !== undefined && !record.checkbox.checked && !record.IsError) { } else if (record.checkbox !== undefined && !record.checkbox.checked && !record.IsError) {
record.checkbox.checked = true; record.checkbox.checked = true;
@@ -60,11 +60,11 @@
} }
} }
function excludeUsers(r) { function excludeRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < r.length; i++) { for (var i = 0; i < r.length; i++) {
const user = r[i]; const user = r[i];
const record = users.find(u => u.Id === user.Id); const record = records.find(u => u.Id === user.Id);
if (record !== undefined && record.checkbox !== undefined) { if (record !== undefined && record.checkbox !== undefined) {
record.checkbox.checked = false; record.checkbox.checked = false;
changeCount++; changeCount++;
@@ -75,12 +75,12 @@
} }
} }
function excludeOtherUsers(r) { function excludeOtherRecords(r) {
let changeCount = 0; let changeCount = 0;
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
const user = users[i]; const record = records[i];
if (!r.find(u => u.Id === user.Id)) { if (!r.find(u => u.Id === record.Id)) {
user.checkbox.checked = false; record.checkbox.checked = false;
changeCount++; changeCount++;
} }
} }
@@ -94,15 +94,15 @@
}); });
$('#BulkGenerate').click(e => { $('#BulkGenerate').click(e => {
let userIds = []; let dataIds = [];
for (var i = 0; i < users.length; i++) { for (var i = 0; i < records.length; i++) {
var user = users[i]; var record = records[i];
if (!user.IsError && user.checkbox !== undefined && user.checkbox.checked) { if (!record.IsError && record.checkbox !== undefined && record.checkbox.checked) {
userIds.push(user.Id); dataIds.push(record.Id);
} }
} }
if (userIds.length > 0) { if (dataIds.length > 0) {
$('#DocumentTemplate_BulkGenerate_DataIds').val(userIds.join('\r\n')); $('#DocumentTemplate_BulkGenerate_DataIds').val(dataIds.join('\r\n'));
$('#BulkGenerate').closest('form').submit(); $('#BulkGenerate').closest('form').submit();
} }
}); });
@@ -113,45 +113,91 @@
let dialog = dialogAddUsers; let dialog = dialogAddUsers;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const results = await response.json();
.then(r => { applier(results);
applier(r);
dialog.find('textarea').html('').val(''); dialog.find('textarea').html('').val('');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate users: ' + e);
.catch(reason => {
alert('Failed to validate users: ' + reason);
});
} }
dialog.dialog("disable");
} }
}
const target = scope === 'user' ? 'Users' : 'Assigned Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: buttons
});
dialogAddUsers = dialog;
}
dialog.dialog('open');
return false;
});
let dialogAddDevices = null;
$('#AddDevices').click(e => {
e.preventDefault();
let dialog = dialogAddDevices;
if (!dialog) {
const action = async function (applier) {
const form = dialog.find('form')[0];
if (form.reportValidity()) {
const body = new FormData(form);
try {
const response = await fetch(form.action, {
method: 'POST',
body: body
});
const results = await response.json();
applier(results);
dialog.find('textarea').html('').val('');
dialog.dialog("close");
} catch (e) {
alert('Failed to validate devices: ' + e);
}
}
}
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDevices').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 550,
buttons: { buttons: {
"Exclude Other Users": function () { "Exclude Unmatched Devices": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Users": function () { "Exclude Devices": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Users": function () { "Add Devices": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
dialogAddUsers = dialog; dialogAddDevices = dialog;
} }
dialog.dialog('open'); dialog.dialog('open');
return false; return false;
@@ -163,41 +209,38 @@
let dialog = dialogAddGroupMembers; let dialog = dialogAddGroupMembers;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
dialog.find('input[type="text"]').val(''); dialog.find('input[type="text"]').val('');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate group: ' + e);
.catch(reason => { }
alert('Failed to validate group: ' + reason);
});
} }
dialog.dialog("disable");
} }
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: {
"Exclude Non-Group Members": function () { "Exclude Non-Group Members": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Group Members": function () { "Exclude Group Members": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Group Members": function () { "Add Group Members": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
@@ -227,42 +270,39 @@
let dialog = dialogAddUserFlag; let dialog = dialogAddUserFlag;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
dialog.find('input[name="flagId"]').val(''); dialog.find('input[name="flagId"]').val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate user flag: ' + e);
.catch(reason => { }
alert('Failed to validate user flag: ' + reason);
});
} }
dialog.dialog("disable");
} }
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: {
"Exclude Unassigned Users": function () { "Exclude Unassigned Users": function () {
action(excludeOtherUsers); action(excludeOtherRecords);
}, },
"Exclude Assigned Users": function () { "Exclude Assigned Users": function () {
action(excludeUsers); action(excludeRecords);
}, },
"Add Assigned Users": function () { "Add Assigned Users": function () {
action(addUsers); action(addRecords);
} }
} }
}); });
@@ -281,52 +321,107 @@
return false; return false;
}); });
let dialogAddDeviceFlag = null;
$('#AddDeviceFlag').click(e => {
e.preventDefault();
let dialog = dialogAddDeviceFlag;
if (!dialog) {
const action = async function (applier) {
const form = dialog.find('form')[0];
if (form.reportValidity()) {
const body = new FormData(form);
try {
const response = await fetch(form.action, {
method: 'POST',
body: body
});
const result = await response.json();
applier(result);
dialog.find('input[name="flagId"]').val('');
dialog.find('div.item').removeClass('selected');
dialog.dialog("close");
} catch (e) {
alert('Failed to validate device flag: ' + e);
}
}
}
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceFlag').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 550,
buttons: {
"Exclude Unassigned Devices": function () {
action(excludeOtherRecords);
},
"Exclude Assigned Devices": function () {
action(excludeRecords);
},
"Add Assigned Devices": function () {
action(addRecords);
}
}
});
const $input = dialog.find('input[name="flagId"]');
dialog.on('click', 'div.item:not(.disabled)', e => {
e.preventDefault();
const $target = $(e.currentTarget);
$input.val($target.attr('data-userflagid'));
dialog.find('div.item').removeClass('selected');
$target.addClass('selected');
return false;
});
dialogAddDeviceFlag = dialog;
}
dialog.dialog('open');
return false;
});
let dialogAddDeviceProfile = null; let dialogAddDeviceProfile = null;
$('#AddDeviceProfile').click(e => { $('#AddDeviceProfile').click(e => {
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDeviceProfile; let dialog = dialogAddDeviceProfile;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="deviceProfileId"]'); const input = dialog.find('input[name="deviceProfileId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device profile: ' + e);
.catch(reason => {
alert('Failed to validate device profile: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Assigned Users' : 'Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceProfile').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="deviceProfileId"]'); const $input = dialog.find('input[name="deviceProfileId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -348,47 +443,45 @@
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDeviceBatch; let dialog = dialogAddDeviceBatch;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="deviceBatchId"]'); const input = dialog.find('input[name="deviceBatchId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device batch: ' + e);
.catch(reason => {
alert('Failed to validate device batch: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Assigned Users' : 'Devices';
const buttons = {};
buttons[`Exclude Other ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDeviceBatch').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="deviceBatchId"]'); const $input = dialog.find('input[name="deviceBatchId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -410,47 +503,45 @@
e.preventDefault(); e.preventDefault();
let dialog = dialogAddDocumentAttachment; let dialog = dialogAddDocumentAttachment;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const input = dialog.find('input[name="documentTemplateId"]'); const input = dialog.find('input[name="documentTemplateId"]');
if (input.val()) { if (input.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
input.val(''); input.val('');
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate device batch: ' + e);
.catch(reason => {
alert('Failed to validate device batch: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Users' : 'Devices';
const buttons = {};
buttons[`Exclude Unassigned ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude Assigned ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add Assigned ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddDocumentAttachment').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 460, width: 550,
buttons: { buttons: buttons
"Exclude Unassigned Users": function () {
action(excludeOtherUsers);
},
"Exclude Assigned Users": function () {
action(excludeUsers);
},
"Add Assigned Users": function () {
action(addUsers);
}
}
}); });
const $input = dialog.find('input[name="documentTemplateId"]'); const $input = dialog.find('input[name="documentTemplateId"]');
dialog.on('click', 'div.item:not(.disabled)', e => { dialog.on('click', 'div.item:not(.disabled)', e => {
@@ -472,49 +563,47 @@
e.preventDefault(); e.preventDefault();
let dialog = dialogAddUserDetail; let dialog = dialogAddUserDetail;
if (!dialog) { if (!dialog) {
const action = function (applier) { const action = async function (applier) {
const form = dialog.find('form')[0]; const form = dialog.find('form')[0];
const key = $(form).find('input[name="key"]'); const key = $(form).find('input[name="key"]');
if (key.val()) { if (key.val()) {
if (form.reportValidity()) { if (form.reportValidity()) {
const body = new FormData(form); const body = new FormData(form);
fetch(form.action, { try {
const response = await fetch(form.action, {
method: 'POST', method: 'POST',
body: body body: body
}) });
.then(r => r.json()) const result = await response.json();
.then(r => { applier(result);
applier(r);
key.val(''); key.val('');
$(form).find('input[name="value"]').val(''); $(form).find('input[name="value"]').val('');
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty(); $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
dialog.find('div.item').removeClass('selected'); dialog.find('div.item').removeClass('selected');
dialog.dialog("close"); dialog.dialog("close");
dialog.dialog("enable"); } catch (e) {
}) alert('Failed to validate user detail: ' + e);
.catch(reason => {
alert('Failed to validate user detail: ' + reason);
});
dialog.dialog("disable");
} }
} }
} }
}
const target = scope === 'user' ? 'Users' : 'Devices';
const buttons = {};
buttons[`Exclude Unmatched ${target}`] = function () {
action(excludeOtherRecords);
};
buttons[`Exclude Matched ${target}`] = function () {
action(excludeRecords);
};
buttons[`Add Matched ${target}`] = function () {
action(addRecords);
};
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail').dialog({ dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail').dialog({
resizable: false, resizable: false,
modal: true, modal: true,
autoOpen: false, autoOpen: false,
width: 690, width: 690,
buttons: { buttons: buttons
"Exclude Unmatched Users": function () {
action(excludeOtherUsers);
},
"Exclude Matched Users": function () {
action(excludeUsers);
},
"Add Matched Users": function () {
action(addUsers);
}
}
}); });
const $key = dialog.find('input[name="key"]'); const $key = dialog.find('input[name="key"]');
const $value = dialog.find('input[name="value"]'); const $value = dialog.find('input[name="value"]');
+5 -2
View File
@@ -1981,14 +1981,17 @@ h1.Config_DocumentTemplates {
padding-bottom: 0.5em; padding-bottom: 0.5em;
text-align: right; text-align: right;
} }
#DocumentTemplate_BulkGenerate table { #DocumentTemplate_BulkGenerate_Records {
max-width: 850px; max-width: 850px;
margin: auto; margin: auto;
} }
#DocumentTemplate_BulkGenerate table tr.when-none { #DocumentTemplate_BulkGenerate_Records tr.when-none {
text-align: center; text-align: center;
font-style: italic; font-style: italic;
} }
#DocumentTemplate_BulkGenerate_Records[data-scope="device"] .name {
display: none;
}
.dialog-item-picker { .dialog-item-picker {
height: 300px; height: 300px;
overflow-y: auto; overflow-y: auto;
+7 -1
View File
@@ -2386,8 +2386,9 @@ h1.Config_DocumentTemplates {
padding-bottom: .5em; padding-bottom: .5em;
text-align: right; text-align: right;
} }
}
table { #DocumentTemplate_BulkGenerate_Records {
max-width: 850px; max-width: 850px;
margin: auto; margin: auto;
@@ -2395,6 +2396,11 @@ h1.Config_DocumentTemplates {
text-align: center; text-align: center;
font-style: italic; font-style: italic;
} }
&[data-scope="device"] {
.name {
display: none;
}
} }
} }
File diff suppressed because one or more lines are too long
+23 -5
View File
@@ -222,7 +222,7 @@
<Compile Include="Areas\API\Models\Activation\CallbackModel.cs" /> <Compile Include="Areas\API\Models\Activation\CallbackModel.cs" />
<Compile Include="Areas\API\Models\DeviceModel\TestComputerNameTemplateModel.cs" /> <Compile Include="Areas\API\Models\DeviceModel\TestComputerNameTemplateModel.cs" />
<Compile Include="Areas\API\Models\DocumentTemplate\AddOnImportUserFlagRuleModel.cs" /> <Compile Include="Areas\API\Models\DocumentTemplate\AddOnImportUserFlagRuleModel.cs" />
<Compile Include="Areas\API\Models\DocumentTemplate\BulkGenerateUserModel.cs" /> <Compile Include="Areas\API\Models\DocumentTemplate\BulkGenerateItemModel.cs" />
<Compile Include="Areas\API\Models\DocumentTemplate\DocumentHandlersModel.cs" /> <Compile Include="Areas\API\Models\DocumentTemplate\DocumentHandlersModel.cs" />
<Compile Include="Areas\API\Models\Job\DeviceHeldLocationModel.cs" /> <Compile Include="Areas\API\Models\Job\DeviceHeldLocationModel.cs" />
<Compile Include="Areas\API\Models\Shared\SubjectDescriptorModel.cs" /> <Compile Include="Areas\API\Models\Shared\SubjectDescriptorModel.cs" />
@@ -293,10 +293,15 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\BulkGenerate.generated.cs"> <Compile Include="Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.generated.cs">
<DependentUpon>BulkGenerateDevice.cshtml</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>BulkGenerate.cshtml</DependentUpon> </Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\BulkGenerateUser.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>BulkGenerateUser.cshtml</DependentUpon>
</Compile> </Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\CreatePackage.generated.cs"> <Compile Include="Areas\Config\Views\DocumentTemplate\CreatePackage.generated.cs">
<DependentUpon>CreatePackage.cshtml</DependentUpon> <DependentUpon>CreatePackage.cshtml</DependentUpon>
@@ -313,6 +318,11 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>ShowPackage.cshtml</DependentUpon> <DependentUpon>ShowPackage.cshtml</DependentUpon>
</Compile> </Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\_BulkGenerateShared.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>_BulkGenerateShared.cshtml</DependentUpon>
</Compile>
<Compile Include="Areas\Config\Views\Export\_Edit.generated.cs"> <Compile Include="Areas\Config\Views\Export\_Edit.generated.cs">
<DependentUpon>_Edit.cshtml</DependentUpon> <DependentUpon>_Edit.cshtml</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@@ -1393,9 +1403,13 @@
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>Create.generated.cs</LastGenOutput> <LastGenOutput>Create.generated.cs</LastGenOutput>
</None> </None>
<None Include="Areas\Config\Views\DocumentTemplate\BulkGenerate.cshtml"> <Content Include="Areas\Config\Views\DocumentTemplate\BulkGenerateDevice.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>BulkGenerate.generated.cs</LastGenOutput> <LastGenOutput>BulkGenerateDevice.generated.cs</LastGenOutput>
</Content>
<None Include="Areas\Config\Views\DocumentTemplate\BulkGenerateUser.cshtml">
<Generator>RazorGenerator</Generator>
<LastGenOutput>BulkGenerateUser.generated.cs</LastGenOutput>
</None> </None>
<None Include="Areas\Config\Views\DocumentTemplate\Export.cshtml"> <None Include="Areas\Config\Views\DocumentTemplate\Export.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
@@ -1409,6 +1423,10 @@
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>CreatePackage.generated.cs</LastGenOutput> <LastGenOutput>CreatePackage.generated.cs</LastGenOutput>
</None> </None>
<None Include="Areas\Config\Views\DocumentTemplate\_BulkGenerateShared.cshtml">
<Generator>RazorGenerator</Generator>
<LastGenOutput>_BulkGenerateShared.generated.cs</LastGenOutput>
</None>
<None Include="Areas\Config\Views\Export\Create.cshtml"> <None Include="Areas\Config\Views\Export\Create.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>Create.generated.cs</LastGenOutput> <LastGenOutput>Create.generated.cs</LastGenOutput>
@@ -205,6 +205,12 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult BulkGenerateAddDevices()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDevices);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult BulkGenerateAddGroupMembers() public virtual System.Web.Mvc.ActionResult BulkGenerateAddGroupMembers()
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddGroupMembers); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddGroupMembers);
@@ -217,6 +223,12 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult BulkGenerateAddDeviceFlag()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceFlag);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult BulkGenerateAddDeviceProfile() public virtual System.Web.Mvc.ActionResult BulkGenerateAddDeviceProfile()
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceProfile); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceProfile);
@@ -340,8 +352,10 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string BulkGenerate = "BulkGenerate"; public readonly string BulkGenerate = "BulkGenerate";
public readonly string BulkGenerateDownload = "BulkGenerateDownload"; public readonly string BulkGenerateDownload = "BulkGenerateDownload";
public readonly string BulkGenerateAddUsers = "BulkGenerateAddUsers"; public readonly string BulkGenerateAddUsers = "BulkGenerateAddUsers";
public readonly string BulkGenerateAddDevices = "BulkGenerateAddDevices";
public readonly string BulkGenerateAddGroupMembers = "BulkGenerateAddGroupMembers"; public readonly string BulkGenerateAddGroupMembers = "BulkGenerateAddGroupMembers";
public readonly string BulkGenerateAddUserFlag = "BulkGenerateAddUserFlag"; public readonly string BulkGenerateAddUserFlag = "BulkGenerateAddUserFlag";
public readonly string BulkGenerateAddDeviceFlag = "BulkGenerateAddDeviceFlag";
public readonly string BulkGenerateAddDeviceProfile = "BulkGenerateAddDeviceProfile"; public readonly string BulkGenerateAddDeviceProfile = "BulkGenerateAddDeviceProfile";
public readonly string BulkGenerateAddDeviceBatch = "BulkGenerateAddDeviceBatch"; public readonly string BulkGenerateAddDeviceBatch = "BulkGenerateAddDeviceBatch";
public readonly string BulkGenerateAddDocumentAttachment = "BulkGenerateAddDocumentAttachment"; public readonly string BulkGenerateAddDocumentAttachment = "BulkGenerateAddDocumentAttachment";
@@ -386,8 +400,10 @@ namespace Disco.Web.Areas.API.Controllers
public const string BulkGenerate = "BulkGenerate"; public const string BulkGenerate = "BulkGenerate";
public const string BulkGenerateDownload = "BulkGenerateDownload"; public const string BulkGenerateDownload = "BulkGenerateDownload";
public const string BulkGenerateAddUsers = "BulkGenerateAddUsers"; public const string BulkGenerateAddUsers = "BulkGenerateAddUsers";
public const string BulkGenerateAddDevices = "BulkGenerateAddDevices";
public const string BulkGenerateAddGroupMembers = "BulkGenerateAddGroupMembers"; public const string BulkGenerateAddGroupMembers = "BulkGenerateAddGroupMembers";
public const string BulkGenerateAddUserFlag = "BulkGenerateAddUserFlag"; public const string BulkGenerateAddUserFlag = "BulkGenerateAddUserFlag";
public const string BulkGenerateAddDeviceFlag = "BulkGenerateAddDeviceFlag";
public const string BulkGenerateAddDeviceProfile = "BulkGenerateAddDeviceProfile"; public const string BulkGenerateAddDeviceProfile = "BulkGenerateAddDeviceProfile";
public const string BulkGenerateAddDeviceBatch = "BulkGenerateAddDeviceBatch"; public const string BulkGenerateAddDeviceBatch = "BulkGenerateAddDeviceBatch";
public const string BulkGenerateAddDocumentAttachment = "BulkGenerateAddDocumentAttachment"; public const string BulkGenerateAddDocumentAttachment = "BulkGenerateAddDocumentAttachment";
@@ -635,8 +651,17 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddUsers public class ActionParamsClass_BulkGenerateAddUsers
{ {
public readonly string scope = "scope";
public readonly string userIds = "userIds"; public readonly string userIds = "userIds";
} }
static readonly ActionParamsClass_BulkGenerateAddDevices s_params_BulkGenerateAddDevices = new ActionParamsClass_BulkGenerateAddDevices();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_BulkGenerateAddDevices BulkGenerateAddDevicesParams { get { return s_params_BulkGenerateAddDevices; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddDevices
{
public readonly string deviceSerialNumbers = "deviceSerialNumbers";
}
static readonly ActionParamsClass_BulkGenerateAddGroupMembers s_params_BulkGenerateAddGroupMembers = new ActionParamsClass_BulkGenerateAddGroupMembers(); static readonly ActionParamsClass_BulkGenerateAddGroupMembers s_params_BulkGenerateAddGroupMembers = new ActionParamsClass_BulkGenerateAddGroupMembers();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_BulkGenerateAddGroupMembers BulkGenerateAddGroupMembersParams { get { return s_params_BulkGenerateAddGroupMembers; } } public ActionParamsClass_BulkGenerateAddGroupMembers BulkGenerateAddGroupMembersParams { get { return s_params_BulkGenerateAddGroupMembers; } }
@@ -653,12 +678,21 @@ namespace Disco.Web.Areas.API.Controllers
{ {
public readonly string flagId = "flagId"; public readonly string flagId = "flagId";
} }
static readonly ActionParamsClass_BulkGenerateAddDeviceFlag s_params_BulkGenerateAddDeviceFlag = new ActionParamsClass_BulkGenerateAddDeviceFlag();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_BulkGenerateAddDeviceFlag BulkGenerateAddDeviceFlagParams { get { return s_params_BulkGenerateAddDeviceFlag; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddDeviceFlag
{
public readonly string flagId = "flagId";
}
static readonly ActionParamsClass_BulkGenerateAddDeviceProfile s_params_BulkGenerateAddDeviceProfile = new ActionParamsClass_BulkGenerateAddDeviceProfile(); static readonly ActionParamsClass_BulkGenerateAddDeviceProfile s_params_BulkGenerateAddDeviceProfile = new ActionParamsClass_BulkGenerateAddDeviceProfile();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_BulkGenerateAddDeviceProfile BulkGenerateAddDeviceProfileParams { get { return s_params_BulkGenerateAddDeviceProfile; } } public ActionParamsClass_BulkGenerateAddDeviceProfile BulkGenerateAddDeviceProfileParams { get { return s_params_BulkGenerateAddDeviceProfile; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddDeviceProfile public class ActionParamsClass_BulkGenerateAddDeviceProfile
{ {
public readonly string scope = "scope";
public readonly string deviceProfileId = "deviceProfileId"; public readonly string deviceProfileId = "deviceProfileId";
} }
static readonly ActionParamsClass_BulkGenerateAddDeviceBatch s_params_BulkGenerateAddDeviceBatch = new ActionParamsClass_BulkGenerateAddDeviceBatch(); static readonly ActionParamsClass_BulkGenerateAddDeviceBatch s_params_BulkGenerateAddDeviceBatch = new ActionParamsClass_BulkGenerateAddDeviceBatch();
@@ -667,6 +701,7 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddDeviceBatch public class ActionParamsClass_BulkGenerateAddDeviceBatch
{ {
public readonly string scope = "scope";
public readonly string deviceBatchId = "deviceBatchId"; public readonly string deviceBatchId = "deviceBatchId";
} }
static readonly ActionParamsClass_BulkGenerateAddDocumentAttachment s_params_BulkGenerateAddDocumentAttachment = new ActionParamsClass_BulkGenerateAddDocumentAttachment(); static readonly ActionParamsClass_BulkGenerateAddDocumentAttachment s_params_BulkGenerateAddDocumentAttachment = new ActionParamsClass_BulkGenerateAddDocumentAttachment();
@@ -675,6 +710,7 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddDocumentAttachment public class ActionParamsClass_BulkGenerateAddDocumentAttachment
{ {
public readonly string scope = "scope";
public readonly string documentTemplateId = "documentTemplateId"; public readonly string documentTemplateId = "documentTemplateId";
public readonly string threshold = "threshold"; public readonly string threshold = "threshold";
} }
@@ -692,6 +728,7 @@ namespace Disco.Web.Areas.API.Controllers
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_BulkGenerateAddUserDetail public class ActionParamsClass_BulkGenerateAddUserDetail
{ {
public readonly string scope = "scope";
public readonly string key = "key"; public readonly string key = "key";
public readonly string value = "value"; public readonly string value = "value";
} }
@@ -1135,14 +1172,27 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
partial void BulkGenerateAddUsersOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string userIds); partial void BulkGenerateAddUsersOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string scope, string userIds);
[NonAction] [NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddUsers(string userIds) public override System.Web.Mvc.ActionResult BulkGenerateAddUsers(string scope, string userIds)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddUsers); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddUsers);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "scope", scope);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userIds", userIds); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userIds", userIds);
BulkGenerateAddUsersOverride(callInfo, userIds); BulkGenerateAddUsersOverride(callInfo, scope, userIds);
return callInfo;
}
[NonAction]
partial void BulkGenerateAddDevicesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string deviceSerialNumbers);
[NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddDevices(string deviceSerialNumbers)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDevices);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceSerialNumbers", deviceSerialNumbers);
BulkGenerateAddDevicesOverride(callInfo, deviceSerialNumbers);
return callInfo; return callInfo;
} }
@@ -1171,39 +1221,54 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
partial void BulkGenerateAddDeviceProfileOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int deviceProfileId); partial void BulkGenerateAddDeviceFlagOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int flagId);
[NonAction] [NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddDeviceProfile(int deviceProfileId) public override System.Web.Mvc.ActionResult BulkGenerateAddDeviceFlag(int flagId)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceFlag);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "flagId", flagId);
BulkGenerateAddDeviceFlagOverride(callInfo, flagId);
return callInfo;
}
[NonAction]
partial void BulkGenerateAddDeviceProfileOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string scope, int deviceProfileId);
[NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddDeviceProfile(string scope, int deviceProfileId)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceProfile); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceProfile);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "scope", scope);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceProfileId", deviceProfileId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceProfileId", deviceProfileId);
BulkGenerateAddDeviceProfileOverride(callInfo, deviceProfileId); BulkGenerateAddDeviceProfileOverride(callInfo, scope, deviceProfileId);
return callInfo; return callInfo;
} }
[NonAction] [NonAction]
partial void BulkGenerateAddDeviceBatchOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int deviceBatchId); partial void BulkGenerateAddDeviceBatchOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string scope, int deviceBatchId);
[NonAction] [NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddDeviceBatch(int deviceBatchId) public override System.Web.Mvc.ActionResult BulkGenerateAddDeviceBatch(string scope, int deviceBatchId)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceBatch); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDeviceBatch);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "scope", scope);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceBatchId", deviceBatchId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceBatchId", deviceBatchId);
BulkGenerateAddDeviceBatchOverride(callInfo, deviceBatchId); BulkGenerateAddDeviceBatchOverride(callInfo, scope, deviceBatchId);
return callInfo; return callInfo;
} }
[NonAction] [NonAction]
partial void BulkGenerateAddDocumentAttachmentOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string documentTemplateId, System.DateTime? threshold); partial void BulkGenerateAddDocumentAttachmentOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string scope, string documentTemplateId, System.DateTime? threshold);
[NonAction] [NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddDocumentAttachment(string documentTemplateId, System.DateTime? threshold) public override System.Web.Mvc.ActionResult BulkGenerateAddDocumentAttachment(string scope, string documentTemplateId, System.DateTime? threshold)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDocumentAttachment); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddDocumentAttachment);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "scope", scope);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "documentTemplateId", documentTemplateId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "documentTemplateId", documentTemplateId);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "threshold", threshold); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "threshold", threshold);
BulkGenerateAddDocumentAttachmentOverride(callInfo, documentTemplateId, threshold); BulkGenerateAddDocumentAttachmentOverride(callInfo, scope, documentTemplateId, threshold);
return callInfo; return callInfo;
} }
@@ -1220,15 +1285,16 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
partial void BulkGenerateAddUserDetailOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string key, string value); partial void BulkGenerateAddUserDetailOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string scope, string key, string value);
[NonAction] [NonAction]
public override System.Web.Mvc.ActionResult BulkGenerateAddUserDetail(string key, string value) public override System.Web.Mvc.ActionResult BulkGenerateAddUserDetail(string scope, string key, string value)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddUserDetail); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerateAddUserDetail);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "scope", scope);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "key", key); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "key", key);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "value", value); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "value", value);
BulkGenerateAddUserDetailOverride(callInfo, key, value); BulkGenerateAddUserDetailOverride(callInfo, scope, key, value);
return callInfo; return callInfo;
} }
@@ -186,8 +186,10 @@ namespace Disco.Web.Areas.Config.Controllers
public _ViewNamesClass ViewNames { get { return s_ViewNames; } } public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
public class _ViewNamesClass public class _ViewNamesClass
{ {
public readonly string _BulkGenerateShared = "_BulkGenerateShared";
public readonly string _ExpressionsTable = "_ExpressionsTable"; public readonly string _ExpressionsTable = "_ExpressionsTable";
public readonly string BulkGenerate = "BulkGenerate"; public readonly string BulkGenerateDevice = "BulkGenerateDevice";
public readonly string BulkGenerateUser = "BulkGenerateUser";
public readonly string Create = "Create"; public readonly string Create = "Create";
public readonly string CreatePackage = "CreatePackage"; public readonly string CreatePackage = "CreatePackage";
public readonly string Export = "Export"; public readonly string Export = "Export";
@@ -197,8 +199,10 @@ namespace Disco.Web.Areas.Config.Controllers
public readonly string ShowPackage = "ShowPackage"; public readonly string ShowPackage = "ShowPackage";
public readonly string UndetectedPages = "UndetectedPages"; public readonly string UndetectedPages = "UndetectedPages";
} }
public readonly string _BulkGenerateShared = "~/Areas/Config/Views/DocumentTemplate/_BulkGenerateShared.cshtml";
public readonly string _ExpressionsTable = "~/Areas/Config/Views/DocumentTemplate/_ExpressionsTable.cshtml"; public readonly string _ExpressionsTable = "~/Areas/Config/Views/DocumentTemplate/_ExpressionsTable.cshtml";
public readonly string BulkGenerate = "~/Areas/Config/Views/DocumentTemplate/BulkGenerate.cshtml"; public readonly string BulkGenerateDevice = "~/Areas/Config/Views/DocumentTemplate/BulkGenerateDevice.cshtml";
public readonly string BulkGenerateUser = "~/Areas/Config/Views/DocumentTemplate/BulkGenerateUser.cshtml";
public readonly string Create = "~/Areas/Config/Views/DocumentTemplate/Create.cshtml"; public readonly string Create = "~/Areas/Config/Views/DocumentTemplate/Create.cshtml";
public readonly string CreatePackage = "~/Areas/Config/Views/DocumentTemplate/CreatePackage.cshtml"; public readonly string CreatePackage = "~/Areas/Config/Views/DocumentTemplate/CreatePackage.cshtml";
public readonly string Export = "~/Areas/Config/Views/DocumentTemplate/Export.cshtml"; public readonly string Export = "~/Areas/Config/Views/DocumentTemplate/Export.cshtml";
+12 -22
View File
@@ -171,8 +171,8 @@ namespace Links
public static readonly string disco_uicore_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.uicore.min.js") ? Url("disco.uicore.min.js") : Url("disco.uicore.js"); public static readonly string disco_uicore_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.uicore.min.js") ? Url("disco.uicore.min.js") : Url("disco.uicore.js");
public static readonly string disco_unobtrusiveValidation_extensions_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.unobtrusiveValidation.extensions.min.js") ? Url("disco.unobtrusiveValidation.extensions.min.js") : Url("disco.unobtrusiveValidation.extensions.js"); public static readonly string disco_unobtrusiveValidation_extensions_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.unobtrusiveValidation.extensions.min.js") ? Url("disco.unobtrusiveValidation.extensions.min.js") : Url("disco.unobtrusiveValidation.extensions.js");
public static readonly string disco_unobtrusiveValidation_extensions_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.unobtrusiveValidation.extensions.min.js") ? Url("disco.unobtrusiveValidation.extensions.min.js") : Url("disco.unobtrusiveValidation.extensions.js"); public static readonly string disco_unobtrusiveValidation_extensions_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco.unobtrusiveValidation.extensions.min.js") ? Url("disco.unobtrusiveValidation.extensions.min.js") : Url("disco.unobtrusiveValidation.extensions.js");
public static readonly string jquery_2_1_1_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery-2.1.1.min.js") ? Url("jquery-2.1.1.min.js") : Url("jquery-2.1.1.js"); public static readonly string jquery_3_7_1_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery-3.7.1.min.js") ? Url("jquery-3.7.1.min.js") : Url("jquery-3.7.1.js");
public static readonly string jquery_ui_1_10_4_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery-ui-1.10.4.min.js") ? Url("jquery-ui-1.10.4.min.js") : Url("jquery-ui-1.10.4.js"); public static readonly string jquery_ui_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery-ui.min.js") ? Url("jquery-ui.min.js") : Url("jquery-ui.js");
public static readonly string jquery_dataTables_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.dataTables.min.js") ? Url("jquery.dataTables.min.js") : Url("jquery.dataTables.js"); public static readonly string jquery_dataTables_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.dataTables.min.js") ? Url("jquery.dataTables.min.js") : Url("jquery.dataTables.js");
public static readonly string jquery_dataTables_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.dataTables.min.js") ? Url("jquery.dataTables.min.js") : Url("jquery.dataTables.js"); public static readonly string jquery_dataTables_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.dataTables.min.js") ? Url("jquery.dataTables.min.js") : Url("jquery.dataTables.js");
public static readonly string jquery_validate_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.validate.min.js") ? Url("jquery.validate.min.js") : Url("jquery.validate.js"); public static readonly string jquery_validate_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.validate.min.js") ? Url("jquery.validate.min.js") : Url("jquery.validate.js");
@@ -354,7 +354,7 @@ namespace Links
public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(UrlPath + "/" + fileName); } public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(UrlPath + "/" + fileName); }
public static readonly string disco_hubs_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco-hubs.min.js") ? Url("disco-hubs.min.js") : Url("disco-hubs.js"); public static readonly string disco_hubs_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco-hubs.min.js") ? Url("disco-hubs.min.js") : Url("disco-hubs.js");
public static readonly string disco_hubs_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco-hubs.min.js") ? Url("disco-hubs.min.js") : Url("disco-hubs.js"); public static readonly string disco_hubs_js_ = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/disco-hubs.min.js") ? Url("disco-hubs.min.js") : Url("disco-hubs.js");
public static readonly string jquery_signalR_2_1_2_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.signalR-2.1.2.min.js") ? Url("jquery.signalR-2.1.2.min.js") : Url("jquery.signalR-2.1.2.js"); public static readonly string jquery_signalR_2_4_3_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery.signalR-2.4.3.min.js") ? Url("jquery.signalR-2.4.3.min.js") : Url("jquery.signalR-2.4.3.js");
} }
public static readonly string jQuery_SignalR_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jQuery-SignalR.min.js") ? Url("jQuery-SignalR.min.js") : Url("jQuery-SignalR.js"); public static readonly string jQuery_SignalR_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jQuery-SignalR.min.js") ? Url("jQuery-SignalR.min.js") : Url("jQuery-SignalR.js");
@@ -725,25 +725,15 @@ namespace Links
public const string UrlPath = "~/ClientSource/Style/jQueryUI/images"; public const string UrlPath = "~/ClientSource/Style/jQueryUI/images";
public static string Url() { return T4MVCHelpers.ProcessVirtualPath(UrlPath); } public static string Url() { return T4MVCHelpers.ProcessVirtualPath(UrlPath); }
public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(UrlPath + "/" + fileName); } public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(UrlPath + "/" + fileName); }
public static readonly string animated_overlay_gif = Url("animated-overlay.gif"); public static readonly string ui_icons_444444_256x240_png = Url("ui-icons_444444_256x240.png");
public static readonly string ui_bg_flat_0_aaaaaa_40x100_png = Url("ui-bg_flat_0_aaaaaa_40x100.png"); public static readonly string ui_icons_555555_256x240_png = Url("ui-icons_555555_256x240.png");
public static readonly string ui_bg_flat_75_ffffff_40x100_png = Url("ui-bg_flat_75_ffffff_40x100.png"); public static readonly string ui_icons_777620_256x240_png = Url("ui-icons_777620_256x240.png");
public static readonly string ui_bg_glass_55_fbf9ee_1x400_png = Url("ui-bg_glass_55_fbf9ee_1x400.png"); public static readonly string ui_icons_777777_256x240_png = Url("ui-icons_777777_256x240.png");
public static readonly string ui_bg_glass_65_ffffff_1x400_png = Url("ui-bg_glass_65_ffffff_1x400.png"); public static readonly string ui_icons_cc0000_256x240_png = Url("ui-icons_cc0000_256x240.png");
public static readonly string ui_bg_glass_75_dadada_1x400_png = Url("ui-bg_glass_75_dadada_1x400.png"); public static readonly string ui_icons_ffffff_256x240_png = Url("ui-icons_ffffff_256x240.png");
public static readonly string ui_bg_glass_75_e6e6e6_1x400_png = Url("ui-bg_glass_75_e6e6e6_1x400.png");
public static readonly string ui_bg_glass_95_fef1ec_1x400_png = Url("ui-bg_glass_95_fef1ec_1x400.png");
public static readonly string ui_bg_highlight_soft_75_cccccc_1x100_png = Url("ui-bg_highlight-soft_75_cccccc_1x100.png");
public static readonly string ui_icons_222222_256x240_png = Url("ui-icons_222222_256x240.png");
public static readonly string ui_icons_2e83ff_256x240_png = Url("ui-icons_2e83ff_256x240.png");
public static readonly string ui_icons_454545_256x240_png = Url("ui-icons_454545_256x240.png");
public static readonly string ui_icons_888888_256x240_png = Url("ui-icons_888888_256x240.png");
public static readonly string ui_icons_cd0a0a_256x240_png = Url("ui-icons_cd0a0a_256x240.png");
} }
public static readonly string jquery_ui_less = Url("jquery-ui.less"); public static readonly string jquery_ui_less = Url("jquery-ui.less");
public static readonly string jquery_ui_css = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(UrlPath + "/jquery-ui.min.css") ? Url("jquery-ui.min.css") : Url("jquery-ui.css");
public static readonly string jquery_ui_min_css = Url("jquery-ui.min.css");
} }
public static readonly string jQueryUIExtensions_less = Url("jQueryUIExtensions.less"); public static readonly string jQueryUIExtensions_less = Url("jQueryUIExtensions.less");
@@ -913,8 +903,8 @@ namespace Links
public const string disco_uicore_js_ = "~/ClientSource/Scripts/Core/disco.uicore.js"; public const string disco_uicore_js_ = "~/ClientSource/Scripts/Core/disco.uicore.js";
public const string disco_unobtrusiveValidation_extensions_js = "~/ClientSource/Scripts/Core/disco.unobtrusiveValidation.extensions.js"; public const string disco_unobtrusiveValidation_extensions_js = "~/ClientSource/Scripts/Core/disco.unobtrusiveValidation.extensions.js";
public const string disco_unobtrusiveValidation_extensions_js_ = "~/ClientSource/Scripts/Core/disco.unobtrusiveValidation.extensions.js"; public const string disco_unobtrusiveValidation_extensions_js_ = "~/ClientSource/Scripts/Core/disco.unobtrusiveValidation.extensions.js";
public const string jquery_2_1_1_js = "~/ClientSource/Scripts/Core/jquery-2.1.1.js"; public const string jquery_3_7_1_js = "~/ClientSource/Scripts/Core/jquery-3.7.1.js";
public const string jquery_ui_1_10_4_js = "~/ClientSource/Scripts/Core/jquery-ui-1.10.4.js"; public const string jquery_ui_js = "~/ClientSource/Scripts/Core/jquery-ui.js";
public const string jquery_dataTables_js = "~/ClientSource/Scripts/Core/jquery.dataTables.js"; public const string jquery_dataTables_js = "~/ClientSource/Scripts/Core/jquery.dataTables.js";
public const string jquery_dataTables_js_ = "~/ClientSource/Scripts/Core/jquery.dataTables.js"; public const string jquery_dataTables_js_ = "~/ClientSource/Scripts/Core/jquery.dataTables.js";
public const string jquery_validate_js = "~/ClientSource/Scripts/Core/jquery.validate.js"; public const string jquery_validate_js = "~/ClientSource/Scripts/Core/jquery.validate.js";
@@ -1038,7 +1028,7 @@ namespace Links
{ {
public const string disco_hubs_js = "~/ClientSource/Scripts/Modules/jQuery-SignalR/disco-hubs.js"; public const string disco_hubs_js = "~/ClientSource/Scripts/Modules/jQuery-SignalR/disco-hubs.js";
public const string disco_hubs_js_ = "~/ClientSource/Scripts/Modules/jQuery-SignalR/disco-hubs.js"; public const string disco_hubs_js_ = "~/ClientSource/Scripts/Modules/jQuery-SignalR/disco-hubs.js";
public const string jquery_signalR_2_1_2_js = "~/ClientSource/Scripts/Modules/jQuery-SignalR/jquery.signalR-2.1.2.js"; public const string jquery_signalR_2_4_3_js = "~/ClientSource/Scripts/Modules/jQuery-SignalR/jquery.signalR-2.4.3.js";
} }
} }
public static partial class jQueryUI_DynaTree public static partial class jQueryUI_DynaTree
-1
View File
@@ -6,7 +6,6 @@
<package id="EntityFramework" version="5.0.0" targetFramework="net45" /> <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="EntityFramework.SqlServerCompact" version="4.3.6" targetFramework="net45" /> <package id="EntityFramework.SqlServerCompact" version="4.3.6" targetFramework="net45" />
<package id="FontAwesome" version="4.1.0" targetFramework="net45" /> <package id="FontAwesome" version="4.1.0" targetFramework="net45" />
<package id="jQuery" version="1.9.0" targetFramework="net462" />
<package id="knockoutjs" version="3.1.0" targetFramework="net45" /> <package id="knockoutjs" version="3.1.0" targetFramework="net45" />
<package id="MarkdownSharp" version="1.13.0.0" targetFramework="net45" /> <package id="MarkdownSharp" version="1.13.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net45" />