feature: saved exports view/edit/trigger
This commit is contained in:
+6
-5
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user