feature: saved exports view/edit/trigger

This commit is contained in:
Gary Sharp
2025-02-12 18:36:30 +11:00
parent 59dc0b9d5a
commit eec8ba438c
40 changed files with 3042 additions and 1187 deletions
@@ -0,0 +1,53 @@
using Disco.Services.Authorization;
using Disco.Services.Exporting;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Web;
using Disco.Web.Areas.API.Models.Shared;
using Disco.Web.Areas.Config.Models.Export;
using System;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
[ValidateAntiForgeryToken]
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
public partial class ExportController : AuthorizedDatabaseController
{
[HttpPost]
public virtual ActionResult Update(EditModel model)
{
if (model.OnDemandPrincipals != null)
{
model.OnDemandSubjects = model.OnDemandPrincipals
.Where(p => !string.IsNullOrWhiteSpace(p))
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(p => ActiveDirectory.RetrieveADObject(p, true))
.Where(ad => ad is ADUserAccount || ad is ADGroup)
.Select(ad => SubjectDescriptorModel.FromActiveDirectoryObject(ad))
.ToList();
}
if (!ModelState.IsValid)
{
var errorState = ModelState.First(m => m.Value.Errors.Any());
var error = errorState.Value.Errors.First();
return new HttpStatusCodeResult(400, $"{errorState.Key}: {error.Exception?.Message ?? error.ErrorMessage}");
}
SavedExports.UpdateSavedExport(Database, model.ToSavedExport());
return RedirectToAction(MVC.Config.Export.Show(model.Id, saved: true));
}
[HttpPost]
public virtual ActionResult Delete(Guid id)
{
SavedExports.DeleteSavedExport(Database, id);
return RedirectToAction(MVC.Config.Export.Index());
}
}
}
@@ -1,10 +1,9 @@
using Disco.Models.UI.Config.Export;
using Disco.Services.Authorization;
using Disco.Services.Exporting;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Logging;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using Disco.Web.Areas.API.Models.Shared;
using Disco.Web.Areas.Config.Models.Export;
using Disco.Web.Extensions;
using System;
@@ -13,10 +12,49 @@ using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
[DiscoAuthorize]
public partial class ExportController : AuthorizedDatabaseController
{
[HttpGet]
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
public virtual ActionResult Index()
{
var exports = SavedExports.GetSavedExports(Database);
var exportUserIds = exports.Select(e => e.CreatedBy).Distinct().ToList();
var users = Database.Users.Where(u => exportUserIds.Contains(u.UserId)).ToDictionary(u => u.UserId, StringComparer.OrdinalIgnoreCase);
var m = new IndexModel
{
SavedExports = exports,
ExportTypeNames = SavedExports.GetSavedExportTypeNames(),
CreatedUsers = users
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigExportIndexModel>(ControllerContext, m);
return View(m);
}
[HttpGet]
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
public virtual ActionResult Show(Guid id, bool? saved = null, bool? exported = null)
{
var export = SavedExports.GetSavedExport(Database, id, out var exportTypeName);
if (export == null)
return HttpNotFound();
var m = ShowModel.FromSavedExport(export, exportTypeName, saved ?? false, exported ?? false);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigExportShowModel>(ControllerContext, m);
return View(m);
}
[HttpGet]
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
public virtual ActionResult Create(Guid id)
{
var export = SavedExports.GetSavedExport(Database, id, out var exportTypeName);
@@ -24,7 +62,7 @@ namespace Disco.Web.Areas.Config.Controllers
if (export == null)
return HttpNotFound();
var m = CreateModel.FromSavedExport(export, exportTypeName);
var m = EditModel.FromNewSavedExport(export, exportTypeName);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigExportCreateModel>(ControllerContext, m);
@@ -32,32 +70,7 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[HttpPost]
public virtual ActionResult Create(CreateModel model)
{
if (model.OnDemandPrincipals != null)
{
model.OnDemandSubjects = model.OnDemandPrincipals
.Where(p => !string.IsNullOrWhiteSpace(p))
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(p => ActiveDirectory.RetrieveADObject(p, true))
.Where(ad => ad is ADUserAccount || ad is ADGroup)
.Select(ad => SubjectDescriptorModel.FromActiveDirectoryObject(ad))
.ToList();
}
if (ModelState.IsValid)
{
SavedExports.UpdateSavedExport(Database, model.ToSavedExport());
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigExportCreateModel>(ControllerContext, model);
return View(model);
}
[DiscoAuthorize]
[HttpGet]
public virtual ActionResult Run(Guid id)
{
var export = SavedExports.GetSavedExport(Database, id, out _);
@@ -72,7 +85,23 @@ namespace Disco.Web.Areas.Config.Controllers
var fileStream = exportResult.Result;
SystemLog.LogInformation($"Ran '{export.Name}' [{export.Name}] for {Authorization.User.UserId}");
return this.File(fileStream.GetBuffer(), 0, (int)fileStream.Length, exportResult.MimeType, exportResult.Filename);
}
[HttpGet]
[DiscoAuthorize(Claims.Config.ManageSavedExports)]
public virtual ActionResult RunScheduled(Guid id)
{
var export = SavedExports.GetSavedExport(Database, id, out _);
if (export == null)
return HttpNotFound();
SavedExports.EvaluateSavedExportSchedule(Database, export);
return RedirectToAction(MVC.Config.Export.Show(export.Id, exported: true));
}
}
}
@@ -8,16 +8,16 @@ using System.Linq;
namespace Disco.Web.Areas.Config.Models.Export
{
public class CreateModel : ConfigExportCreateModel
public class EditModel : ConfigExportCreateModel, ConfigExportShowModel
{
public string ExportTypeName { get; set; }
[Required]
public Guid Id { get; set; }
public string ExportTypeName { get; set; }
[Required]
public string Name { get; set; }
[DataType(DataType.MultilineText)]
public string Description { get; set; }
public bool IsEnabled { get; set; }
public string FilePath { get; set; }
public bool TimestampSuffix { get; set; }
@@ -38,11 +38,12 @@ namespace Disco.Web.Areas.Config.Models.Export
public List<SubjectDescriptorModel> OnDemandSubjects { get; set; }
public List<string> OnDemandPrincipals { get; set; }
public static CreateModel FromSavedExport(SavedExport savedExport, string exportTypeName)
public static EditModel FromNewSavedExport(SavedExport savedExport, string exportTypeName)
{
return new CreateModel
return new EditModel
{
Id = savedExport.Id,
IsEnabled = false,
ExportTypeName = exportTypeName,
ScheduleMonday = true,
ScheduleTuesday = true,
@@ -0,0 +1,14 @@
using Disco.Models.Repository;
using Disco.Models.Services.Exporting;
using Disco.Models.UI.Config.Export;
using System.Collections.Generic;
namespace Disco.Web.Areas.Config.Models.Export
{
public class IndexModel : ConfigExportIndexModel
{
public List<SavedExport> SavedExports { get; set; }
public Dictionary<string, string> ExportTypeNames { get; set; }
public Dictionary<string, User> CreatedUsers { get; set; }
}
}
@@ -0,0 +1,52 @@
using Disco.Models.Services.Exporting;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Web.Areas.API.Models.Shared;
using System;
using System.Linq;
namespace Disco.Web.Areas.Config.Models.Export
{
public class ShowModel : EditModel
{
public bool WasSaved { get; set; }
public bool WasExported { get; set; }
public static EditModel FromSavedExport(SavedExport savedExport, string exportTypeName, bool wasSaved, bool wasExported)
{
var model = new ShowModel
{
Id = savedExport.Id,
ExportTypeName = exportTypeName,
Name = savedExport.Name,
Description = savedExport.Description,
IsEnabled = savedExport.Enabled,
FilePath = savedExport.FilePath,
TimestampSuffix = savedExport.TimestampSuffix,
ScheduleEnabled = savedExport.Schedule != null,
ScheduleSunday = savedExport.Schedule?.IncludesDay(DayOfWeek.Sunday) ?? false,
ScheduleMonday = savedExport.Schedule?.IncludesDay(DayOfWeek.Monday) ?? true,
ScheduleTuesday = savedExport.Schedule?.IncludesDay(DayOfWeek.Tuesday) ?? true,
ScheduleWednesday = savedExport.Schedule?.IncludesDay(DayOfWeek.Wednesday) ?? true,
ScheduleThursday = savedExport.Schedule?.IncludesDay(DayOfWeek.Thursday) ?? true,
ScheduleFriday = savedExport.Schedule?.IncludesDay(DayOfWeek.Friday) ?? true,
ScheduleSaturday = savedExport.Schedule?.IncludesDay(DayOfWeek.Saturday) ?? false,
ScheduleStartHour = savedExport.Schedule?.StartHour ?? 0,
ScheduleEndHour = savedExport.Schedule?.EndHour,
WasSaved = wasSaved,
WasExported = wasExported,
};
if (savedExport.OnDemandPrincipals != null)
{
model.OnDemandPrincipals = savedExport.OnDemandPrincipals;
model.OnDemandSubjects = savedExport.OnDemandPrincipals
.Where(p => !string.IsNullOrWhiteSpace(p))
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(p => ActiveDirectory.RetrieveADObject(p, true))
.Where(ad => ad is ADUserAccount || ad is ADGroup)
.Select(ad => SubjectDescriptorModel.FromActiveDirectoryObject(ad))
.ToList();
}
return model;
}
}
}
@@ -128,7 +128,7 @@
}
</div>
}
@if (Authorization.HasAny(Claims.Config.DocumentTemplate.Show))
@if (Authorization.HasAny(Claims.Config.DocumentTemplate.Show, Claims.Config.ManageSavedExports))
{
<div class="pageMenuArea noSeperator">
<h2>Features</h2>
@@ -137,7 +137,14 @@
<i class="fa fa-cog"></i>@Html.ActionLinkClass("Document Templates", MVC.Config.DocumentTemplate.Index(), "config")
<div class="pageMenuBlurb">
Create, Update and Bulk Generate documents based on PDF Templates for Jobs, Devices
and Users.
and Users.
</div>
}
@if (Authorization.Has(Claims.Config.ManageSavedExports))
{
<i class="fa fa-cog"></i>@Html.ActionLinkClass("Saved Exports", MVC.Config.Export.Index(), "config")
<div class="pageMenuBlurb">
Update and run saved exports.
</div>
}
</div>
@@ -855,7 +855,7 @@ WriteLiteral(" ");
#line 131 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.HasAny(Claims.Config.DocumentTemplate.Show))
if (Authorization.HasAny(Claims.Config.DocumentTemplate.Show, Claims.Config.ManageSavedExports))
{
@@ -912,20 +912,70 @@ WriteLiteral(" <div");
WriteLiteral(" class=\"pageMenuBlurb\"");
WriteLiteral(">\r\n Create, Update and Bulk Generate documents bas" +
"ed on PDF Templates for Jobs, Devices\r\n and Users.\r\n " +
" </div>\r\n");
"ed on PDF Templates for Jobs, Devices\r\n and Users" +
".\r\n </div>\r\n");
#line 142 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 143 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.ManageSavedExports))
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 145 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 145 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Saved Exports", MVC.Config.Export.Index(), "config"));
#line default
#line hidden
#line 145 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"pageMenuBlurb\"");
WriteLiteral(">\r\n Update and run saved exports.\r\n " +
" </div>\r\n");
#line 149 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n");
#line 144 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 151 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -934,7 +984,7 @@ WriteLiteral(" </div>\r\n");
WriteLiteral(" </td>\r\n");
#line 146 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 153 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -943,7 +993,7 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" </tr>\r\n</table>\r\n");
#line 149 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 156 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Model.UpdateAvailable)
{
@@ -961,14 +1011,14 @@ WriteLiteral(" class=\"fa fa-cloud-download info\"");
WriteLiteral("></i>\r\n <div>An updated version of Disco is available</div>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 8213), Tuple.Create("\"", 8249)
WriteAttribute("href", Tuple.Create(" href=\"", 8682), Tuple.Create("\"", 8718)
#line 155 "..\..\Areas\Config\Views\Config\Index.cshtml"
, Tuple.Create(Tuple.Create("", 8220), Tuple.Create<System.Object, System.Int32>(Model.UpdateResponse.UrlLink
#line 162 "..\..\Areas\Config\Views\Config\Index.cshtml"
, Tuple.Create(Tuple.Create("", 8689), Tuple.Create<System.Object, System.Int32>(Model.UpdateResponse.UrlLink
#line default
#line hidden
, 8220), false)
, 8689), false)
);
WriteLiteral(" class=\"button small alert\"");
@@ -978,7 +1028,7 @@ WriteLiteral(" target=\"_blank\"");
WriteLiteral(">Download v");
#line 155 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 162 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Model.UpdateResponse.LatestVersion);
@@ -995,13 +1045,13 @@ WriteLiteral(@" <script>
");
#line 163 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 170 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 163 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 170 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Model.UpdateResponse.ReleasedDate < DateTime.Now.AddDays(-14))
{
@@ -1017,7 +1067,7 @@ WriteLiteral("\r\n updateAvailableContainer.effect(\"shake\", { t
WriteLiteral("\r\n");
#line 169 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 176 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -1026,7 +1076,7 @@ WriteLiteral("\r\n");
WriteLiteral("\r\n });\r\n })();\r\n </script>\r\n");
#line 174 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 181 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -1,230 +1,7 @@
@model Disco.Web.Areas.Config.Models.Export.CreateModel
@model Disco.Web.Areas.Config.Models.Export.EditModel
@{
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", null, "Create Saved " + Model.ExportTypeName);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", MVC.Config.Export.Index(), "Create Saved " + Model.ExportTypeName);
}
@using (Html.BeginForm(MVC.Config.Export.Create(), FormMethod.Post))
{
@Html.AntiForgeryToken();
@Html.HiddenFor(m => m.Id)
<div id="Config_Export_Create_Details" class="form" style="width: 530px;">
<h2>Save @Model.ExportTypeName</h2>
<table>
<tr>
<th style="width: 140px">Name:</th>
<td>
@Html.EditorFor(model => model.Name)
</td>
</tr>
<tr>
<th>
Description:<br />
<em class="small">Optional</em>
</th>
<td>
@Html.EditorFor(model => model.Description)
</td>
</tr>
</table>
</div>
<div id="Config_Export_Create_Schedule" class="form" style="width: 530px; margin-top: 10px;">
<h2>Schedule</h2>
<table>
<tr>
<th style="width: 140px">&nbsp;</th>
<td>
<label>
@Html.EditorFor(m => m.ScheduleEnabled)
Enable Scheduled Export
</label>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Days:
</th>
<td>
<ul class="none">
<li><label>@Html.EditorFor(m => m.ScheduleMonday) Monday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleTuesday) Tuesday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleWednesday) Wednesday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleThursday) Thursday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleFriday) Friday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleSaturday) Saturday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleSunday) Sunday</label></li>
</ul>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Start Time:
</th>
<td>
<select name="ScheduleStartHour">
@{
<option value="0" @(Model.ScheduleStartHour == 0 ? "selected" : null)>12:00 AM</option>
for (int i = 1; i < 12; i++)
{
<option value="@i" @(Model.ScheduleStartHour == i ? "selected" : null)>@i:00 AM</option>
}
<option value="12" @(Model.ScheduleStartHour == 12 ? "selected" : null)>12:00 PM</option>
for (int i = 13; i < 24; i++)
{
<option value="@i" @(Model.ScheduleStartHour == i ? "selected" : null)>@(i % 12):00 PM</option>
}
}
</select>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> By default, Disco ICT shuts down at 1:30am and does not resume again until its needed. If a scheduled export was missed during this time, it will be run as soon as Disco ICT is resumed.
</p>
</div>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Repeat Hourly Until:
</th>
<td>
<select name="ScheduleEndHour">
<option value="" @(Model.ScheduleEndHour.HasValue ? null : "selected")>Run once</option>
@{
for (int i = 1; i < 12; i++)
{
<option value="@i" @(Model.ScheduleEndHour == i ? "selected" : null)>@i:00 AM</option>
}
<option value="12" @(Model.ScheduleEndHour == 12 ? "selected" : null)>12:00 PM</option>
for (int i = 12; i < 24; i++)
{
<option value="@i" @(Model.ScheduleEndHour == i ? "selected" : null)>@(i % 12):00 PM</option>
}
}
</select>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
File System Location:
</th>
<td>
@Html.EditorFor(m => m.FilePath)
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> This is the full file path on the Disco ICT server (<code>@Environment.MachineName</code>). The location may be a network path. The Disco ICT Service Account (<code>@Environment.UserDomainName\@Environment.UserName</code>) must have write access to the location.
</p>
</div>
<label>
@Html.EditorFor(m => m.TimestampSuffix) Add time stamp suffix to file name
</label>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> This will create a new file each time the export runs.
</p>
</div>
</td>
</tr>
</table>
</div>
<div id="Config_Export_Create_OnDemand" class="form" style="width: 530px; margin-top: 10px;">
<h2>On Demand Export</h2>
<table>
<tr>
<th style="width: 140px">
Additional Users/Groups:
</th>
<td>
<ul id="Config_Export_Create_OnDemand_List" class="none">
@if (Model.OnDemandSubjects != null)
{
foreach (var sg in Model.OnDemandSubjects)
{
<li>
<input type="hidden" name="OnDemandPrincipals" value="@sg.Id" />
<i class="fa fa-user@(sg.IsGroup ? "s" : null) fa-lg"></i>
@sg.Name [@sg.Id]
<i class="fa fa-times-circle remove"></i>
</li>
}
}
</ul>
<div>
<input type="text" id="Config_Export_Create_OnDemand_Input" placeholder="Search users and groups" data-url="@(Url.Action(MVC.API.System.SearchSubjects()))" data-subjecturl="@Url.Action(MVC.API.System.Subject())" />
<button type="button" id="Config_Export_Create_OnDemand_Add" class="button small">Add</button>
</div>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> Users with the Manage Saved Exports permission (including Disco ICT Administrators) can perform an on-demand export at any time.
Users or Group Members can be added to this list. These will also be able to perform an on-demand export using the link available after saving.
</p>
</div>
</td>
</tr>
</table>
</div>
<div class="actionBar">
<button type="submit" class="button">Save</button>
</div>
}
<script>
$(function () {
$('#ScheduleEnabled').on('change', function () {
const enabled = $(this).is(':checked');
$('#Config_Export_Create_Schedule tr:not(:first)').toggleClass('hidden', !enabled);
});
const onDemandInput = $('#Config_Export_Create_OnDemand_Input');
onDemandInput
.autocomplete({
source: onDemandInput.attr('data-url'),
minLength: 2,
focus: function (e, ui) {
onDemandInput.val(ui.item.Id);
return false;
},
select: function (e, ui) {
onDemandInput.val(ui.item.Id).blur();
return false;
}
}).data('ui-autocomplete')._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
.appendTo(ul);
};
$('#Config_Export_Create_OnDemand_Add').on('click', async function () {
const id = onDemandInput.val();
const body = new FormData();
body.append('Id', id);
const response = await fetch(onDemandInput.attr('data-subjecturl'), {
method: 'POST',
body: body
});
if (!response.ok) {
alert('Error: ' + response.statusText);
return;
}
const data = await response.json();
if (!data.IsGroup && !data.IsUserAccount) {
alert('Error: Only users and groups can be added.');
return;
}
const $li = $('<li><input type="hidden" name="OnDemandPrincipals" /><i class="fa fa-lg"></i> <span></span><i class="fa fa-times-circle remove"></i></li>');
$li.find('input').val(data.Id);
$li.find('i.fa-lg').addClass(data.Type === 'user' ? 'fa-user' : 'fa-users');
$li.find('span').text(data.Name + ' [' + data.Id + ']');
$li.appendTo('#Config_Export_Create_OnDemand_List');
});
$('#Config_Export_Create_OnDemand_List').on('click', '.remove', function () {
$(this).closest('li').remove();
})
})
</script>
@Html.Partial(MVC.Config.Export.Views._Edit, Model)
@@ -36,7 +36,7 @@ namespace Disco.Web.Areas.Config.Views.Export
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Export/Create.cshtml")]
public partial class Create : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Export.CreateModel>
public partial class Create : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Export.EditModel>
{
public Create()
{
@@ -48,856 +48,21 @@ namespace Disco.Web.Areas.Config.Views.Export
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", null, "Create Saved " + Model.ExportTypeName);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", MVC.Config.Export.Index(), "Create Saved " + Model.ExportTypeName);
#line default
#line hidden
WriteLiteral("\r\n\r\n");
WriteLiteral("\r\n");
#line 8 "..\..\Areas\Config\Views\Export\Create.cshtml"
using (Html.BeginForm(MVC.Config.Export.Create(), FormMethod.Post))
{
#line default
#line hidden
#line 10 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.AntiForgeryToken());
#line default
#line hidden
#line 10 "..\..\Areas\Config\Views\Export\Create.cshtml"
;
#line default
#line hidden
#line 11 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.HiddenFor(m => m.Id));
#line default
#line hidden
#line 11 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Export_Create_Details\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px;\"");
WriteLiteral(">\r\n <h2>Save ");
#line 14 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ExportTypeName);
#line default
#line hidden
WriteLiteral("</h2>\r\n <table>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 140px\"");
WriteLiteral(">Name:</th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 19 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(model => model.Name));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th" +
">\r\n Description:<br />\r\n <em");
WriteLiteral(" class=\"small\"");
WriteLiteral(">Optional</em>\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 28 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(model => model.Description));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n");
#line 33 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Export_Create_Schedule\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px; margin-top: 10px;\"");
WriteLiteral(">\r\n <h2>Schedule</h2>\r\n <table>\r\n <tr>\r\n " +
"<th");
WriteLiteral(" style=\"width: 140px\"");
WriteLiteral(">&nbsp;</th>\r\n <td>\r\n <label>\r\n");
WriteLiteral(" ");
#line 41 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleEnabled));
#line default
#line hidden
WriteLiteral("\r\n Enable Scheduled Export\r\n </label>\r\n" +
" </td>\r\n </tr>\r\n <tr");
WriteAttribute("class", Tuple.Create(" class=\"", 1528), Tuple.Create("\"", 1578)
#line 46 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 1536), Tuple.Create<System.Object, System.Int32>(Model.ScheduleEnabled ? null : "hidden"
#line default
#line hidden
, 1536), false)
);
WriteLiteral(">\r\n <th>\r\n Days:\r\n </th>\r\n " +
" <td>\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n <li><label>");
#line 52 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleMonday));
#line default
#line hidden
WriteLiteral(" Monday</label></li>\r\n <li><label>");
#line 53 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleTuesday));
#line default
#line hidden
WriteLiteral(" Tuesday</label></li>\r\n <li><label>");
#line 54 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleWednesday));
#line default
#line hidden
WriteLiteral(" Wednesday</label></li>\r\n <li><label>");
#line 55 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleThursday));
#line default
#line hidden
WriteLiteral(" Thursday</label></li>\r\n <li><label>");
#line 56 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleFriday));
#line default
#line hidden
WriteLiteral(" Friday</label></li>\r\n <li><label>");
#line 57 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleSaturday));
#line default
#line hidden
WriteLiteral(" Saturday</label></li>\r\n <li><label>");
#line 58 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.ScheduleSunday));
#line default
#line hidden
WriteLiteral(" Sunday</label></li>\r\n </ul>\r\n </td>\r\n " +
" </tr>\r\n <tr");
WriteAttribute("class", Tuple.Create(" class=\"", 2480), Tuple.Create("\"", 2530)
#line 62 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 2488), Tuple.Create<System.Object, System.Int32>(Model.ScheduleEnabled ? null : "hidden"
#line default
#line hidden
, 2488), false)
);
WriteLiteral(">\r\n <th>\r\n Start Time:\r\n </th>\r\n" +
" <td>\r\n <select");
WriteLiteral(" name=\"ScheduleStartHour\"");
WriteLiteral(">\r\n");
#line 68 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
#line 68 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <option");
WriteLiteral(" value=\"0\"");
WriteLiteral(" ");
#line 69 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleStartHour == 0 ? "selected" : null);
#line default
#line hidden
WriteLiteral(">12:00 AM</option>\r\n");
#line 70 "..\..\Areas\Config\Views\Export\Create.cshtml"
for (int i = 1; i < 12; i++)
{
#line default
#line hidden
WriteLiteral(" <option");
WriteAttribute("value", Tuple.Create(" value=\"", 2962), Tuple.Create("\"", 2972)
#line 72 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 2970), Tuple.Create<System.Object, System.Int32>(i
#line default
#line hidden
, 2970), false)
);
WriteLiteral(" ");
#line 72 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleStartHour == i ? "selected" : null);
#line default
#line hidden
WriteLiteral(">");
#line 72 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(i);
#line default
#line hidden
WriteLiteral(":00 AM</option>\r\n");
#line 73 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
#line default
#line hidden
WriteLiteral(" <option");
WriteLiteral(" value=\"12\"");
WriteLiteral(" ");
#line 74 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleStartHour == 12 ? "selected" : null);
#line default
#line hidden
WriteLiteral(">12:00 PM</option>\r\n");
#line 75 "..\..\Areas\Config\Views\Export\Create.cshtml"
for (int i = 13; i < 24; i++)
{
#line default
#line hidden
WriteLiteral(" <option");
WriteAttribute("value", Tuple.Create(" value=\"", 3324), Tuple.Create("\"", 3334)
#line 77 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 3332), Tuple.Create<System.Object, System.Int32>(i
#line default
#line hidden
, 3332), false)
);
WriteLiteral(" ");
#line 77 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleStartHour == i ? "selected" : null);
#line default
#line hidden
WriteLiteral(">");
#line 77 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(i % 12);
#line default
#line hidden
WriteLiteral(":00 PM</option>\r\n");
#line 78 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
#line default
#line hidden
WriteLiteral("\r\n </select>\r\n <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral(@"></i> By default, Disco ICT shuts down at 1:30am and does not resume again until its needed. If a scheduled export was missed during this time, it will be run as soon as Disco ICT is resumed.
</p>
</div>
</td>
</tr>
<tr");
WriteAttribute("class", Tuple.Create(" class=\"", 3959), Tuple.Create("\"", 4009)
#line 88 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 3967), Tuple.Create<System.Object, System.Int32>(Model.ScheduleEnabled ? null : "hidden"
#line default
#line hidden
, 3967), false)
);
WriteLiteral(">\r\n <th>\r\n Repeat Hourly Until:\r\n " +
" </th>\r\n <td>\r\n <select");
WriteLiteral(" name=\"ScheduleEndHour\"");
WriteLiteral(">\r\n <option");
WriteLiteral(" value=\"\"");
WriteLiteral(" ");
#line 94 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleEndHour.HasValue ? null : "selected");
#line default
#line hidden
WriteLiteral(">Run once</option>\r\n");
#line 95 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
#line 95 "..\..\Areas\Config\Views\Export\Create.cshtml"
for (int i = 1; i < 12; i++)
{
#line default
#line hidden
WriteLiteral(" <option");
WriteAttribute("value", Tuple.Create(" value=\"", 4445), Tuple.Create("\"", 4455)
#line 98 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 4453), Tuple.Create<System.Object, System.Int32>(i
#line default
#line hidden
, 4453), false)
);
WriteLiteral(" ");
#line 98 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleEndHour == i ? "selected" : null);
#line default
#line hidden
WriteLiteral(">");
#line 98 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(i);
#line default
#line hidden
WriteLiteral(":00 AM</option>\r\n");
#line 99 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
#line default
#line hidden
WriteLiteral(" <option");
WriteLiteral(" value=\"12\"");
WriteLiteral(" ");
#line 100 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleEndHour == 12 ? "selected" : null);
#line default
#line hidden
WriteLiteral(">12:00 PM</option>\r\n");
#line 101 "..\..\Areas\Config\Views\Export\Create.cshtml"
for (int i = 12; i < 24; i++)
{
#line default
#line hidden
WriteLiteral(" <option");
WriteAttribute("value", Tuple.Create(" value=\"", 4803), Tuple.Create("\"", 4813)
#line 103 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 4811), Tuple.Create<System.Object, System.Int32>(i
#line default
#line hidden
, 4811), false)
);
WriteLiteral(" ");
#line 103 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Model.ScheduleEndHour == i ? "selected" : null);
#line default
#line hidden
WriteLiteral(">");
#line 103 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(i % 12);
#line default
#line hidden
WriteLiteral(":00 PM</option>\r\n");
#line 104 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
#line default
#line hidden
WriteLiteral("\r\n </select>\r\n </td>\r\n </tr>\r\n " +
" <tr");
WriteAttribute("class", Tuple.Create(" class=\"", 5037), Tuple.Create("\"", 5087)
#line 109 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 5045), Tuple.Create<System.Object, System.Int32>(Model.ScheduleEnabled ? null : "hidden"
#line default
#line hidden
, 5045), false)
);
WriteLiteral(">\r\n <th>\r\n File System Location:\r\n " +
" </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 114 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.FilePath));
#line default
#line hidden
WriteLiteral("\r\n <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral("></i> This is the full file path on the Disco ICT server (<code>");
#line 117 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Environment.MachineName);
#line default
#line hidden
WriteLiteral("</code>). The location may be a network path. The Disco ICT Service Account (<cod" +
"e>");
#line 117 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Environment.UserDomainName);
#line default
#line hidden
WriteLiteral("\\");
#line 117 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Environment.UserName);
#line default
#line hidden
WriteLiteral("</code>) must have write access to the location.\r\n </p>\r\n " +
" </div>\r\n <label>\r\n");
WriteLiteral(" ");
#line 121 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.EditorFor(m => m.TimestampSuffix));
#line default
#line hidden
WriteLiteral(" Add time stamp suffix to file name\r\n </label>\r\n " +
" <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral("></i> This will create a new file each time the export runs.\r\n " +
" </p>\r\n </div>\r\n </td>\r\n </tr>\r" +
"\n </table>\r\n </div>\r\n");
#line 132 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Export_Create_OnDemand\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px; margin-top: 10px;\"");
WriteLiteral(">\r\n <h2>On Demand Export</h2>\r\n <table>\r\n <tr>\r\n " +
" <th");
WriteLiteral(" style=\"width: 140px\"");
WriteLiteral(">\r\n Additional Users/Groups:\r\n </th>\r\n " +
" <td>\r\n <ul");
WriteLiteral(" id=\"Config_Export_Create_OnDemand_List\"");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 142 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
#line 142 "..\..\Areas\Config\Views\Export\Create.cshtml"
if (Model.OnDemandSubjects != null)
{
foreach (var sg in Model.OnDemandSubjects)
{
#line default
#line hidden
WriteLiteral(" <li>\r\n <input");
WriteLiteral(" type=\"hidden\"");
WriteLiteral(" name=\"OnDemandPrincipals\"");
WriteAttribute("value", Tuple.Create(" value=\"", 6926), Tuple.Create("\"", 6940)
#line 147 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 6934), Tuple.Create<System.Object, System.Int32>(sg.Id
#line default
#line hidden
, 6934), false)
);
WriteLiteral(" />\r\n <i");
WriteAttribute("class", Tuple.Create(" class=\"", 6984), Tuple.Create("\"", 7034)
, Tuple.Create(Tuple.Create("", 6992), Tuple.Create("fa", 6992), true)
, Tuple.Create(Tuple.Create(" ", 6994), Tuple.Create("fa-user", 6995), true)
#line 148 "..\..\Areas\Config\Views\Export\Create.cshtml"
, Tuple.Create(Tuple.Create("", 7002), Tuple.Create<System.Object, System.Int32>(sg.IsGroup ? "s" : null
#line default
#line hidden
, 7002), false)
, Tuple.Create(Tuple.Create(" ", 7028), Tuple.Create("fa-lg", 7029), true)
);
WriteLiteral("></i>\r\n");
WriteLiteral(" ");
#line 149 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(sg.Name);
#line default
#line hidden
WriteLiteral(" [");
#line 149 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(sg.Id);
#line default
#line hidden
WriteLiteral("]\r\n <i");
WriteLiteral(" class=\"fa fa-times-circle remove\"");
WriteLiteral("></i>\r\n </li>\r\n");
#line 152 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n <div>\r\n <in" +
"put");
WriteLiteral(" type=\"text\"");
WriteLiteral(" id=\"Config_Export_Create_OnDemand_Input\"");
WriteLiteral(" placeholder=\"Search users and groups\"");
WriteLiteral(" data-url=\"");
#line 156 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Url.Action(MVC.API.System.SearchSubjects()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-subjecturl=\"");
#line 156 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Url.Action(MVC.API.System.Subject()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" />\r\n <button");
WriteLiteral(" type=\"button\"");
WriteLiteral(" id=\"Config_Export_Create_OnDemand_Add\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add</button>\r\n </div>\r\n <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral(@"></i> Users with the Manage Saved Exports permission (including Disco ICT Administrators) can perform an on-demand export at any time.
Users or Group Members can be added to this list. These will also be able to perform an on-demand export using the link available after saving.
</p>
</div>
</td>
</tr>
</table>
</div>
");
#line 169 "..\..\Areas\Config\Views\Export\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n <button");
WriteLiteral(" type=\"submit\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(">Save</button>\r\n </div>\r\n");
#line 173 "..\..\Areas\Config\Views\Export\Create.cshtml"
}
#line 7 "..\..\Areas\Config\Views\Export\Create.cshtml"
Write(Html.Partial(MVC.Config.Export.Views._Edit, Model));
#line default
#line hidden
WriteLiteral("<script>\r\n $(function () {\r\n $(\'#ScheduleEnabled\').on(\'change\', functio" +
"n () {\r\n const enabled = $(this).is(\':checked\');\r\n $(\'#Con" +
"fig_Export_Create_Schedule tr:not(:first)\').toggleClass(\'hidden\', !enabled);\r\n " +
" });\r\n\r\n const onDemandInput = $(\'#Config_Export_Create_OnDemand_Inp" +
"ut\');\r\n\r\n onDemandInput\r\n .autocomplete({\r\n sou" +
"rce: onDemandInput.attr(\'data-url\'),\r\n minLength: 2,\r\n " +
" focus: function (e, ui) {\r\n onDemandInput.val(ui.item.Id" +
");\r\n return false;\r\n },\r\n selec" +
"t: function (e, ui) {\r\n onDemandInput.val(ui.item.Id).blur();" +
"\r\n return false;\r\n }\r\n }).data(\'ui-" +
"autocomplete\')._renderItem = function (ul, item) {\r\n return $(\"<l" +
"i></li>\")\r\n .data(\"item.autocomplete\", item)\r\n " +
" .append(\"<a><strong>\" + item.Name + \"</strong><br>\" + item.Id + \" (\" + item" +
".Type + \")</a>\")\r\n .appendTo(ul);\r\n };\r\n $(" +
"\'#Config_Export_Create_OnDemand_Add\').on(\'click\', async function () {\r\n " +
" const id = onDemandInput.val();\r\n const body = new FormData();\r\n " +
" body.append(\'Id\', id);\r\n const response = await fetch(onDem" +
"andInput.attr(\'data-subjecturl\'), {\r\n method: \'POST\',\r\n " +
" body: body\r\n });\r\n if (!response.ok) {\r\n " +
" alert(\'Error: \' + response.statusText);\r\n return;\r\n " +
" }\r\n const data = await response.json();\r\n\r\n if (!data.Is" +
"Group && !data.IsUserAccount) {\r\n alert(\'Error: Only users and gr" +
"oups can be added.\');\r\n return;\r\n }\r\n\r\n con" +
"st $li = $(\'<li><input type=\"hidden\" name=\"OnDemandPrincipals\" /><i class=\"fa fa" +
"-lg\"></i> <span></span><i class=\"fa fa-times-circle remove\"></i></li>\');\r\n " +
" $li.find(\'input\').val(data.Id);\r\n $li.find(\'i.fa-lg\').addClass(" +
"data.Type === \'user\' ? \'fa-user\' : \'fa-users\');\r\n $li.find(\'span\').te" +
"xt(data.Name + \' [\' + data.Id + \']\');\r\n $li.appendTo(\'#Config_Export_" +
"Create_OnDemand_List\');\r\n });\r\n $(\'#Config_Export_Create_OnDemand_" +
"List\').on(\'click\', \'.remove\', function () {\r\n $(this).closest(\'li\').r" +
"emove();\r\n })\r\n })\r\n</script>\r\n");
WriteLiteral("\r\n");
}
}
@@ -0,0 +1,99 @@
@model Disco.Web.Areas.Config.Models.Export.IndexModel
@{
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Saved Exports");
}
@if (Model.SavedExports.Any())
{
<table class="tableData">
<tr>
<th>Name</th>
<th>Type</th>
<th>Created</th>
<th>Schedule</th>
<th>&nbsp;</th>
</tr>
@foreach (var export in Model.SavedExports.OrderBy(e => e.Name))
{
string exportTypeName;
Disco.Models.Repository.User createdUser;
Model.ExportTypeNames.TryGetValue(export.Type, out exportTypeName);
Model.CreatedUsers.TryGetValue(export.CreatedBy, out createdUser);
<tr>
<td>
<a href="@Url.Action(MVC.Config.Export.Show(export.Id))">@export.Name</a>
</td>
<td>@exportTypeName</td>
<td>
@if (createdUser != null)
{
@CommonHelpers.FriendlyDateAndUser(export.CreatedOn, createdUser)
}
else
{
@CommonHelpers.FriendlyDateAndUser(export.CreatedOn, export.CreatedBy)
}
</td>
<td>
@if (export.Schedule == null)
{
<text>&nbsp;</text>
}
else
{
var schedule = export.Schedule;
<div>
<span class="@(schedule.IncludesDay(DayOfWeek.Sunday) ? null : "subtleText")">S</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Monday) ? null : "subtleText")">M</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Tuesday) ? null : "subtleText")">T</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Wednesday) ? null : "subtleText")">W</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Thursday) ? null : "subtleText")">T</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Friday) ? null : "subtleText")">F</span>
<span class="@(schedule.IncludesDay(DayOfWeek.Saturday) ? null : "subtleText")">S</span>
<span class="smallText">at</span>
<span>@schedule.StartHourFriendly()</span>
@if (schedule.EndHour.HasValue)
{
<span class="smallText">-</span>
<span>@schedule.EndHourFriendly()</span>
}
</div>
}
</td>
<td>
@if (export.Schedule != null)
{
<a href="@Url.Action(MVC.Config.Export.RunScheduled(export.Id))">Schedule Now</a>
}
<a href="@Url.Action(MVC.Config.Export.Run(export.Id))">Export Now</a>
</td>
</tr>
}
</table>
}
else
{
<div class="form" style="width: 450px; padding: 100px 0;">
<h2>No saved exports are configured</h2>
<div>
@if (Authorization.Has(Claims.Device.Actions.Export))
{
<a href="@Url.Action(MVC.Device.Export())" class="button small">Device Export</a>
}
@if (Authorization.Has(Claims.Job.Actions.Export))
{
<a href="@Url.Action(MVC.Job.Export())" class="button small">Job Export</a>
}
@if (Authorization.Has(Claims.Config.UserFlag.Export))
{
<a href="@Url.Action(MVC.Config.UserFlag.Export())" class="button small">User Flag Export</a>
}
@if (Authorization.Has(Claims.Config.DeviceFlag.Export))
{
<a href="@Url.Action(MVC.Config.DeviceFlag.Export())" class="button small">Device Flag Export</a>
}
</div>
</div>
}
@@ -0,0 +1,573 @@
#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.Export
{
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/Export/Index.cshtml")]
public partial class Index : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Export.IndexModel>
{
public Index()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\Export\Index.cshtml"
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Saved Exports");
#line default
#line hidden
WriteLiteral("\r\n\r\n");
#line 8 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (Model.SavedExports.Any())
{
#line default
#line hidden
WriteLiteral(" <table");
WriteLiteral(" class=\"tableData\"");
WriteLiteral(">\r\n <tr>\r\n <th>Name</th>\r\n <th>Type</th>\r\n " +
" <th>Created</th>\r\n <th>Schedule</th>\r\n <th>&nbsp;</th>\r\n" +
" </tr>\r\n");
#line 18 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 18 "..\..\Areas\Config\Views\Export\Index.cshtml"
foreach (var export in Model.SavedExports.OrderBy(e => e.Name))
{
string exportTypeName;
Disco.Models.Repository.User createdUser;
Model.ExportTypeNames.TryGetValue(export.Type, out exportTypeName);
Model.CreatedUsers.TryGetValue(export.CreatedBy, out createdUser);
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 868), Tuple.Create("\"", 921)
#line 26 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 875), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.Export.Show(export.Id))
#line default
#line hidden
, 875), false)
);
WriteLiteral(">");
#line 26 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(export.Name);
#line default
#line hidden
WriteLiteral("</a>\r\n </td>\r\n <td>");
#line 28 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(exportTypeName);
#line default
#line hidden
WriteLiteral("</td>\r\n <td>\r\n");
#line 30 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 30 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (createdUser != null)
{
#line default
#line hidden
#line 32 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(CommonHelpers.FriendlyDateAndUser(export.CreatedOn, createdUser));
#line default
#line hidden
#line 32 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
else
{
#line default
#line hidden
#line 36 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(CommonHelpers.FriendlyDateAndUser(export.CreatedOn, export.CreatedBy));
#line default
#line hidden
#line 36 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n <td>\r\n");
#line 40 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 40 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (export.Schedule == null)
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("&nbsp;");
WriteLiteral("\r\n");
#line 43 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
else
{
var schedule = export.Schedule;
#line default
#line hidden
WriteLiteral(" <div>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 1737), Tuple.Create("\"", 1808)
#line 48 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1745), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Sunday) ? null : "subtleText"
#line default
#line hidden
, 1745), false)
);
WriteLiteral(">S</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 1853), Tuple.Create("\"", 1924)
#line 49 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1861), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Monday) ? null : "subtleText"
#line default
#line hidden
, 1861), false)
);
WriteLiteral(">M</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 1969), Tuple.Create("\"", 2041)
#line 50 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1977), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Tuesday) ? null : "subtleText"
#line default
#line hidden
, 1977), false)
);
WriteLiteral(">T</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 2086), Tuple.Create("\"", 2160)
#line 51 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 2094), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Wednesday) ? null : "subtleText"
#line default
#line hidden
, 2094), false)
);
WriteLiteral(">W</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 2205), Tuple.Create("\"", 2278)
#line 52 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 2213), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Thursday) ? null : "subtleText"
#line default
#line hidden
, 2213), false)
);
WriteLiteral(">T</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 2323), Tuple.Create("\"", 2394)
#line 53 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 2331), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Friday) ? null : "subtleText"
#line default
#line hidden
, 2331), false)
);
WriteLiteral(">F</span>\r\n <span");
WriteAttribute("class", Tuple.Create(" class=\"", 2439), Tuple.Create("\"", 2512)
#line 54 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 2447), Tuple.Create<System.Object, System.Int32>(schedule.IncludesDay(DayOfWeek.Saturday) ? null : "subtleText"
#line default
#line hidden
, 2447), false)
);
WriteLiteral(">S</span>\r\n <span");
WriteLiteral(" class=\"smallText\"");
WriteLiteral(">at</span>\r\n <span>");
#line 56 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(schedule.StartHourFriendly());
#line default
#line hidden
WriteLiteral("</span>\r\n");
#line 57 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 57 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (schedule.EndHour.HasValue)
{
#line default
#line hidden
WriteLiteral(" <span");
WriteLiteral(" class=\"smallText\"");
WriteLiteral(">-</span>\r\n");
WriteLiteral(" <span>");
#line 60 "..\..\Areas\Config\Views\Export\Index.cshtml"
Write(schedule.EndHourFriendly());
#line default
#line hidden
WriteLiteral("</span>\r\n");
#line 61 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n");
#line 63 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n <td>\r\n");
#line 66 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 66 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (export.Schedule != null)
{
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 3122), Tuple.Create("\"", 3183)
#line 68 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 3129), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.Export.RunScheduled(export.Id))
#line default
#line hidden
, 3129), false)
);
WriteLiteral(">Schedule Now</a>\r\n");
#line 69 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 3248), Tuple.Create("\"", 3300)
#line 70 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 3255), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.Export.Run(export.Id))
#line default
#line hidden
, 3255), false)
);
WriteLiteral(">Export Now</a>\r\n </td>\r\n </tr>\r\n");
#line 73 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </table>\r\n");
#line 75 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
else
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 450px; padding: 100px 0;\"");
WriteLiteral(">\r\n <h2>No saved exports are configured</h2>\r\n <div>\r\n");
#line 81 "..\..\Areas\Config\Views\Export\Index.cshtml"
#line default
#line hidden
#line 81 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (Authorization.Has(Claims.Device.Actions.Export))
{
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 3626), Tuple.Create("\"", 3665)
#line 83 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 3633), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Device.Export())
#line default
#line hidden
, 3633), false)
);
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Device Export</a>\r\n");
#line 84 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 85 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (Authorization.Has(Claims.Job.Actions.Export))
{
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 3819), Tuple.Create("\"", 3855)
#line 87 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 3826), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Job.Export())
#line default
#line hidden
, 3826), false)
);
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Job Export</a>\r\n");
#line 88 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 89 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (Authorization.Has(Claims.Config.UserFlag.Export))
{
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 4010), Tuple.Create("\"", 4058)
#line 91 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 4017), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.UserFlag.Export())
#line default
#line hidden
, 4017), false)
);
WriteLiteral(" class=\"button small\"");
WriteLiteral(">User Flag Export</a>\r\n");
#line 92 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 93 "..\..\Areas\Config\Views\Export\Index.cshtml"
if (Authorization.Has(Claims.Config.DeviceFlag.Export))
{
#line default
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 4221), Tuple.Create("\"", 4271)
#line 95 "..\..\Areas\Config\Views\Export\Index.cshtml"
, Tuple.Create(Tuple.Create("", 4228), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.DeviceFlag.Export())
#line default
#line hidden
, 4228), false)
);
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Device Flag Export</a>\r\n");
#line 96 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n </div>\r\n");
#line 99 "..\..\Areas\Config\Views\Export\Index.cshtml"
}
#line default
#line hidden
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,26 @@
@model Disco.Web.Areas.Config.Models.Export.ShowModel
@{
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", MVC.Config.Export.Index(), "Saved " + Model.ExportTypeName + ": " + Model.Name);
}
@if (Model.WasSaved)
{
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> The saved export was updated.
</p>
</div>
}
@if (Model.WasExported)
{
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> The scheduled export was run.
</p>
</div>
}
@Html.Partial(MVC.Config.Export.Views._Edit, (Disco.Web.Areas.Config.Models.Export.EditModel)Model)
@@ -0,0 +1,132 @@
#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.Export
{
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/Export/Show.cshtml")]
public partial class Show : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Export.ShowModel>
{
public Show()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\Export\Show.cshtml"
Authorization.Require(Claims.Config.ManageSavedExports);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Exports", MVC.Config.Export.Index(), "Saved " + Model.ExportTypeName + ": " + Model.Name);
#line default
#line hidden
WriteLiteral("\r\n\r\n");
#line 8 "..\..\Areas\Config\Views\Export\Show.cshtml"
if (Model.WasSaved)
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral("></i> The saved export was updated.\r\n </p>\r\n </div>\r\n");
#line 15 "..\..\Areas\Config\Views\Export\Show.cshtml"
}
#line default
#line hidden
WriteLiteral("\r\n");
#line 17 "..\..\Areas\Config\Views\Export\Show.cshtml"
if (Model.WasExported)
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"info-box\"");
WriteLiteral(">\r\n <p");
WriteLiteral(" class=\"fa-p\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
WriteLiteral("></i> The scheduled export was run.\r\n </p>\r\n </div>\r\n");
#line 24 "..\..\Areas\Config\Views\Export\Show.cshtml"
}
#line default
#line hidden
WriteLiteral("\r\n");
#line 26 "..\..\Areas\Config\Views\Export\Show.cshtml"
Write(Html.Partial(MVC.Config.Export.Views._Edit, (Disco.Web.Areas.Config.Models.Export.EditModel)Model));
#line default
#line hidden
WriteLiteral("\r\n");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,287 @@
@model Disco.Web.Areas.Config.Models.Export.EditModel
@using (Html.BeginForm(MVC.API.Export.Update(), FormMethod.Post))
{
@Html.AntiForgeryToken();
@Html.HiddenFor(m => m.Id)
<div id="Config_Export_Edit_Details" class="form" style="width: 530px;">
<h2>Saved @Model.ExportTypeName</h2>
<table>
<tr>
<th style="width: 140px">Name:</th>
<td>
@Html.EditorFor(model => model.Name)
</td>
</tr>
<tr>
<th>
Description:<br />
<em class="small">Optional</em>
</th>
<td>
@Html.EditorFor(model => model.Description)
</td>
</tr>
</table>
</div>
<div id="Config_Export_Edit_Schedule" class="form" style="width: 530px; margin-top: 10px;">
<h2>Schedule</h2>
<table>
<tr>
<th style="width: 140px">&nbsp;</th>
<td>
<label>
@Html.EditorFor(m => m.ScheduleEnabled)
Enable Scheduled Export
</label>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Days:
</th>
<td>
<ul class="none">
<li><label>@Html.EditorFor(m => m.ScheduleMonday) Monday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleTuesday) Tuesday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleWednesday) Wednesday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleThursday) Thursday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleFriday) Friday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleSaturday) Saturday</label></li>
<li><label>@Html.EditorFor(m => m.ScheduleSunday) Sunday</label></li>
</ul>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Start Time:
</th>
<td>
<select name="ScheduleStartHour">
@{
<option value="0" @(Model.ScheduleStartHour == 0 ? "selected" : null)>12:00 AM</option>
for (int i = 1; i < 12; i++)
{
<option value="@i" @(Model.ScheduleStartHour == i ? "selected" : null)>@i:00 AM</option>
}
<option value="12" @(Model.ScheduleStartHour == 12 ? "selected" : null)>12:00 PM</option>
for (int i = 13; i < 24; i++)
{
<option value="@i" @(Model.ScheduleStartHour == i ? "selected" : null)>@(i % 12):00 PM</option>
}
}
</select>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> By default, Disco ICT shuts down at 1:30am and does not resume again until its needed. If a scheduled export was missed during this time, it will be run as soon as Disco ICT is resumed.
</p>
</div>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
Repeat Hourly Until:
</th>
<td>
<select name="ScheduleEndHour">
<option value="" @(Model.ScheduleEndHour.HasValue ? null : "selected")>Run once</option>
@{
for (int i = 1; i < 12; i++)
{
<option value="@i" @(Model.ScheduleEndHour == i ? "selected" : null)>@i:00 AM</option>
}
<option value="12" @(Model.ScheduleEndHour == 12 ? "selected" : null)>12:00 PM</option>
for (int i = 12; i < 24; i++)
{
<option value="@i" @(Model.ScheduleEndHour == i ? "selected" : null)>@(i % 12):00 PM</option>
}
}
</select>
</td>
</tr>
<tr class="@(Model.ScheduleEnabled ? null : "hidden")">
<th>
File System Location:
</th>
<td>
@Html.EditorFor(m => m.FilePath)
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> This is the full file path on the Disco ICT server (<code>@Environment.MachineName</code>). The location may be a network path. The Disco ICT Service Account (<code>@Environment.UserDomainName\@Environment.UserName</code>) must have write access to the location.
</p>
</div>
<label>
@Html.EditorFor(m => m.TimestampSuffix) Add time stamp suffix to file name
</label>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> This will create a new file each time the export runs.
</p>
</div>
</td>
</tr>
</table>
</div>
<div id="Config_Export_Edit_OnDemand" class="form" style="width: 530px; margin-top: 10px;">
<h2>On Demand Export</h2>
<table>
<tr>
<th style="width: 140px">
Additional Users/Groups:
</th>
<td>
<ul id="Config_Export_Edit_OnDemand_List" class="none">
@if (Model.OnDemandSubjects != null)
{
foreach (var sg in Model.OnDemandSubjects)
{
<li>
<input type="hidden" name="OnDemandPrincipals" value="@sg.Id" />
<i class="fa fa-user@(sg.IsGroup ? "s" : null) fa-lg"></i>
@sg.Name [@sg.Id]
<i class="fa fa-times-circle remove"></i>
</li>
}
}
</ul>
<div>
<input type="text" id="Config_Export_Edit_OnDemand_Input" placeholder="Search users and groups" data-url="@(Url.Action(MVC.API.System.SearchSubjects()))" data-subjecturl="@Url.Action(MVC.API.System.Subject())" />
<button type="button" id="Config_Export_Edit_OnDemand_Add" class="button small">Add</button>
</div>
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i> Users with the Manage Saved Exports permission (including Disco ICT Administrators) can perform an on-demand export at any time.
Users or Group Members can be added to this list.
@if (!Model.IsEnabled)
{
<text>These will also be able to perform an on-demand export using the link available after saving.</text>
}
</p>
</div>
</td>
</tr>
@if (Model.IsEnabled)
{
var link = new Uri(Request.Url, Url.Action(MVC.Config.Export.Run(Model.Id)));
<tr>
<th>Link</th>
<td>
<input type="text" value="@link" style="width: 90%;" readonly data-clipboard />
</td>
</tr>
}
</table>
</div>
<div class="actionBar">
@if (Model.IsEnabled)
{
if (Model.ScheduleEnabled)
{
<a href="@Url.Action(MVC.Config.Export.RunScheduled(Model.Id))" class="button">Schedule Now</a>
}
<a href="@Url.Action(MVC.Config.Export.Run(Model.Id))" class="button">Export Now</a>
<button id="Config_Export_Edit_DeleteButton" type="button" class="button alert">Delete</button>
}
<button type="submit" class="button">Save</button>
</div>
}
@if (Model.IsEnabled)
{
<div id="Config_Export_Edit_DeleteDialog" title="Delete Saved @Model.ExportTypeName: @Model.Name" class="dialog">
<div class="info-box">
<p class="fa-p">
<i class="fa fa-exclamation-triangle"></i>Are you sure you want to delete the Saved @Model.ExportTypeName: @Model.Name?
</p>
</div>
@using (Html.BeginForm(MVC.API.Export.Delete(), FormMethod.Post))
{
@Html.AntiForgeryToken()
<input type="hidden" name="id" value="@Model.Id" />
}
</div>
}
<script>
$(function () {
$('#ScheduleEnabled').on('change', function () {
const enabled = $(this).is(':checked');
$('#Config_Export_Edit_Schedule tr:not(:first)').toggleClass('hidden', !enabled);
});
const onDemandInput = $('#Config_Export_Edit_OnDemand_Input');
onDemandInput
.autocomplete({
source: onDemandInput.attr('data-url'),
minLength: 2,
focus: function (e, ui) {
onDemandInput.val(ui.item.Id);
return false;
},
select: function (e, ui) {
onDemandInput.val(ui.item.Id).blur();
return false;
}
}).data('ui-autocomplete')._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
.appendTo(ul);
};
$('#Config_Export_Edit_OnDemand_Add').on('click', async function () {
const id = onDemandInput.val();
const body = new FormData();
body.append('Id', id);
const response = await fetch(onDemandInput.attr('data-subjecturl'), {
method: 'POST',
body: body
});
if (!response.ok) {
alert('Error: ' + response.statusText);
return;
}
const data = await response.json();
if (!data.IsGroup && !data.IsUserAccount) {
alert('Error: Only users and groups can be added.');
return;
}
const $li = $('<li><input type="hidden" name="OnDemandPrincipals" /><i class="fa fa-lg"></i> <span></span><i class="fa fa-times-circle remove"></i></li>');
$li.find('input').val(data.Id);
$li.find('i.fa-lg').addClass(data.Type === 'user' ? 'fa-user' : 'fa-users');
$li.find('span').text(data.Name + ' [' + data.Id + ']');
$li.appendTo('#Config_Export_Edit_OnDemand_List');
});
$('#Config_Export_Edit_OnDemand_List').on('click', '.remove', function () {
$(this).closest('li').remove();
})
let $deleteDialog = null;
$('#Config_Export_Edit_DeleteButton').on('click', function () {
if (!$deleteDialog) {
$deleteDialog = $('#Config_Export_Edit_DeleteDialog').dialog({
resizable: false,
modal: true,
width: 350,
autoOpen: false,
buttons: {
'Cancel': function () {
$(this).dialog("close");
},
'Delete': function () {
$deleteDialog.find('form').submit();
$(this).dialog("disable");
}
}
});
}
$deleteDialog.dialog('open');
})
})
</script>
File diff suppressed because it is too large Load Diff