feature: bulk generate documents for device batches, models and profiles
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
@model Disco.Web.Areas.Config.Models.Shared.DeviceGroupDocumentTemplateBulkGenerateModel
|
||||
@if (Model.BulkGenerateDocumentTemplates != null && Model.BulkGenerateDocumentTemplates.Any())
|
||||
{
|
||||
List<AttachmentTypes> allowedTargets = new List<AttachmentTypes>();
|
||||
if (Authorization.HasAll(Claims.Device.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.Device);
|
||||
}
|
||||
if (Authorization.HasAll(Claims.Job.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.Job);
|
||||
}
|
||||
if (Authorization.HasAll(Claims.User.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.User);
|
||||
}
|
||||
var allowedTemplates = Model.BulkGenerateDocumentTemplates.Where(m => allowedTargets.Contains(m.AttachmentType)).ToList();
|
||||
if (allowedTemplates.Any())
|
||||
{
|
||||
string targetDescription;
|
||||
int targetId = Model.DeviceGroupId;
|
||||
Func<ActionResult> urlDelegate;
|
||||
if (Model is Disco.Web.Areas.Config.Models.DeviceBatch.ShowModel)
|
||||
{
|
||||
targetDescription = "Batch";
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceBatch;
|
||||
}
|
||||
else if (Model is Disco.Web.Areas.Config.Models.DeviceModel.ShowModel)
|
||||
{
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceModel;
|
||||
targetDescription = "Model";
|
||||
}
|
||||
else if (Model is Disco.Web.Areas.Config.Models.DeviceProfile.ShowModel)
|
||||
{
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceProfile;
|
||||
targetDescription = "Profile";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Unsupported Device Group Model");
|
||||
}
|
||||
<div class="dialog" id="Config_Shared_DeviceGroupDocumentTemplateBulkGenerate_Dialog" title="Document Template Bulk Generate for Device @targetDescription">
|
||||
<p>
|
||||
Bulk generate documents for devices, users or jobs (based on document template scope) associated with this Device @(targetDescription).
|
||||
</p>
|
||||
@using (Html.BeginForm(urlDelegate(), FormMethod.Post))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
@Html.Hidden("deviceGroupId", targetId)
|
||||
<select name="id" required>
|
||||
<option value="">-- Choose Document Template --</option>
|
||||
@foreach (var template in allowedTemplates)
|
||||
{
|
||||
<option value="@template.Id">@template.Description (@(template.AttachmentType)s)</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
const button = $('<button class="button">Document Bulk Generate</button>').prependTo('.actionBar');
|
||||
let dialog = null;
|
||||
button.click(e => {
|
||||
if (!dialog) {
|
||||
dialog = $('#Config_Shared_DeviceGroupDocumentTemplateBulkGenerate_Dialog')
|
||||
.dialog({
|
||||
resizable: false,
|
||||
width: 450,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
Close: function () {
|
||||
$(this).dialog("close");
|
||||
},
|
||||
'Bulk Generate': function () {
|
||||
const form = dialog.find('form')[0];
|
||||
if (form.reportValidity()) {
|
||||
form.submit();
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
#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.Shared
|
||||
{
|
||||
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/Shared/_DeviceGroupDocumentBulkGenerate.cshtml")]
|
||||
public partial class _DeviceGroupDocumentBulkGenerate : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Shared.DeviceGroupDocumentTemplateBulkGenerateModel>
|
||||
{
|
||||
public _DeviceGroupDocumentBulkGenerate()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
if (Model.BulkGenerateDocumentTemplates != null && Model.BulkGenerateDocumentTemplates.Any())
|
||||
{
|
||||
List<AttachmentTypes> allowedTargets = new List<AttachmentTypes>();
|
||||
if (Authorization.HasAll(Claims.Device.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.Device);
|
||||
}
|
||||
if (Authorization.HasAll(Claims.Job.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.Job);
|
||||
}
|
||||
if (Authorization.HasAll(Claims.User.Actions.GenerateDocuments, Claims.Config.DocumentTemplate.BulkGenerate))
|
||||
{
|
||||
allowedTargets.Add(AttachmentTypes.User);
|
||||
}
|
||||
var allowedTemplates = Model.BulkGenerateDocumentTemplates.Where(m => allowedTargets.Contains(m.AttachmentType)).ToList();
|
||||
if (allowedTemplates.Any())
|
||||
{
|
||||
string targetDescription;
|
||||
int targetId = Model.DeviceGroupId;
|
||||
Func<ActionResult> urlDelegate;
|
||||
if (Model is Disco.Web.Areas.Config.Models.DeviceBatch.ShowModel)
|
||||
{
|
||||
targetDescription = "Batch";
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceBatch;
|
||||
}
|
||||
else if (Model is Disco.Web.Areas.Config.Models.DeviceModel.ShowModel)
|
||||
{
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceModel;
|
||||
targetDescription = "Model";
|
||||
}
|
||||
else if (Model is Disco.Web.Areas.Config.Models.DeviceProfile.ShowModel)
|
||||
{
|
||||
urlDelegate = MVC.API.DocumentTemplate.BulkGenerateDeviceProfile;
|
||||
targetDescription = "Profile";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Unsupported Device Group Model");
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" id=\"Config_Shared_DeviceGroupDocumentTemplateBulkGenerate_Dialog\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 1966), Tuple.Create("\"", 2035)
|
||||
, Tuple.Create(Tuple.Create("", 1974), Tuple.Create("Document", 1974), true)
|
||||
, Tuple.Create(Tuple.Create(" ", 1982), Tuple.Create("Template", 1983), true)
|
||||
, Tuple.Create(Tuple.Create(" ", 1991), Tuple.Create("Bulk", 1992), true)
|
||||
, Tuple.Create(Tuple.Create(" ", 1996), Tuple.Create("Generate", 1997), true)
|
||||
, Tuple.Create(Tuple.Create(" ", 2005), Tuple.Create("for", 2006), true)
|
||||
, Tuple.Create(Tuple.Create(" ", 2009), Tuple.Create("Device", 2010), true)
|
||||
|
||||
#line 42 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
, Tuple.Create(Tuple.Create(" ", 2016), Tuple.Create<System.Object, System.Int32>(targetDescription
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2017), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <p>\r\n Bulk generate documents for devices, users or" +
|
||||
" jobs (based on document template scope) associated with this Device ");
|
||||
|
||||
|
||||
#line 44 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
Write(targetDescription);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(".\r\n </p>\r\n");
|
||||
|
||||
|
||||
#line 46 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 46 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
using (Html.BeginForm(urlDelegate(), FormMethod.Post))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 48 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
Write(Html.AntiForgeryToken());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 48 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 49 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
Write(Html.Hidden("deviceGroupId", targetId));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 49 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <select");
|
||||
|
||||
WriteLiteral(" name=\"id\"");
|
||||
|
||||
WriteLiteral(" required>\r\n <option");
|
||||
|
||||
WriteLiteral(" value=\"\"");
|
||||
|
||||
WriteLiteral(">-- Choose Document Template --</option>\r\n");
|
||||
|
||||
|
||||
#line 52 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 52 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
foreach (var template in allowedTemplates)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <option");
|
||||
|
||||
WriteAttribute("value", Tuple.Create(" value=\"", 2652), Tuple.Create("\"", 2672)
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2660), Tuple.Create<System.Object, System.Int32>(template.Id
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2660), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
Write(template.Description);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" (");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
Write(template.AttachmentType);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("s)</option>\r\n");
|
||||
|
||||
|
||||
#line 55 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </select>\r\n");
|
||||
|
||||
|
||||
#line 57 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </div>\r\n");
|
||||
|
||||
WriteLiteral(" <script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
const button = $('<button class=""button"">Document Bulk Generate</button>').prependTo('.actionBar');
|
||||
let dialog = null;
|
||||
button.click(e => {
|
||||
if (!dialog) {
|
||||
dialog = $('#Config_Shared_DeviceGroupDocumentTemplateBulkGenerate_Dialog')
|
||||
.dialog({
|
||||
resizable: false,
|
||||
width: 450,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
Close: function () {
|
||||
$(this).dialog(""close"");
|
||||
},
|
||||
'Bulk Generate': function () {
|
||||
const form = dialog.find('form')[0];
|
||||
if (form.reportValidity()) {
|
||||
form.submit();
|
||||
$(this).dialog(""close"");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
");
|
||||
|
||||
|
||||
#line 89 "..\..\Areas\Config\Views\Shared\_DeviceGroupDocumentBulkGenerate.cshtml"
|
||||
}
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
Reference in New Issue
Block a user