updated modules for input requirements
This commit is contained in:
		| @ -5,176 +5,183 @@ | ||||
| @inject IStringLocalizer<Edit> Localizer | ||||
| @inject IStringLocalizer<SharedResources> SharedLocalizer | ||||
|  | ||||
| <div class="container"> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="name" HelpText="Enter the job name" ResourceKey="Name">Name: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="name" class="form-control" @bind="@_name" /> | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <div class="container"> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="name" HelpText="Enter the job name" ResourceKey="Name">Name: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="name" class="form-control" @bind="@_name" maxlength="256" required /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="type" HelpText="The fully qualified job type name" ResourceKey="Type">Type: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="type" class="form-control" @bind="@_jobType" readonly/> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="enabled" HelpText="Select whether you want the job enabled or not" ResourceKey="Enabled">Enabled? </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <select id="enabled" class="form-select" @bind="@_isEnabled" required> | ||||
|                     <option value="True">@SharedLocalizer["Yes"]</option> | ||||
|                     <option value="False">@SharedLocalizer["No"]</option> | ||||
|                 </select> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="runs-every" HelpText="Select how often you want the job to run" ResourceKey="RunsEvery">Runs Every: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="runs-every" class="form-control" @bind="@_interval" required /> | ||||
|                 <select id="runs-every" class="form-select" @bind="@_frequency" required> | ||||
|                     <option value="m">@Localizer["Minute(s)"]</option> | ||||
|                     <option value="H">@Localizer["Hour(s)"]</option> | ||||
|                     <option value="d">@Localizer["Day(s)"]</option> | ||||
|                     <option value="M">@Localizer["Month(s)"]</option> | ||||
|                 </select> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="starting" HelpText="What time do you want the job to start" ResourceKey="Starting">Starting: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="starting" class="form-control" @bind="@_startDate" /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="ending" HelpText="When do you want the job to end" ResourceKey="Ending">Ending: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="ending" class="form-control" @bind="@_endDate" /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="retention" HelpText="Number of log entries to retain for this job" ResourceKey="RetentionLog">Retention Log (Items): </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="retention" class="form-control" @bind="@_retentionHistory" required /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="next" HelpText="Next execution for this job." ResourceKey="NextExecution">Next Execution: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="next" class="form-control" @bind="@_nextExecution" /> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="type" HelpText="The fully qualified job type name" ResourceKey="Type">Type: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="type" class="form-control" @bind="@_jobType" readonly /> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="enabled" HelpText="Select whether you want the job enabled or not" ResourceKey="Enabled">Enabled? </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <select id="enabled" class="form-select" @bind="@_isEnabled"> | ||||
|                 <option value="True">@SharedLocalizer["Yes"]</option> | ||||
|                 <option value="False">@SharedLocalizer["No"]</option> | ||||
|             </select> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="runs-every" HelpText="Select how often you want the job to run" ResourceKey="RunsEvery">Runs Every: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="runs-every" class="form-control" @bind="@_interval" /> | ||||
|             <select id="runs-every" class="form-select" @bind="@_frequency"> | ||||
|                 <option value="m">@Localizer["Minute(s)"]</option> | ||||
|                 <option value="H">@Localizer["Hour(s)"]</option> | ||||
|                 <option value="d">@Localizer["Day(s)"]</option> | ||||
|                 <option value="M">@Localizer["Month(s)"]</option> | ||||
|             </select> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="starting" HelpText="What time do you want the job to start" ResourceKey="Starting">Starting: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="starting" class="form-control" @bind="@_startDate" /> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="ending" HelpText="When do you want the job to end" ResourceKey="Ending">Ending: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="ending" class="form-control" @bind="@_endDate" /> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="retention" HelpText="Number of log entries to retain for this job" ResourceKey="RetentionLog">Retention Log (Items): </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="retention" class="form-control" @bind="@_retentionHistory" /> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="next" HelpText="Next execution for this job." ResourceKey="NextExecution">Next Execution: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="next" class="form-control" @bind="@_nextExecution" /> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| <br /> | ||||
| <button type="button" class="btn btn-success" @onclick="SaveJob">@SharedLocalizer["Save"]</button> | ||||
| <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
| <br /> | ||||
| <br /> | ||||
| <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo> | ||||
|     <br /> | ||||
|     <button type="button" class="btn btn-success" @onclick="SaveJob">@SharedLocalizer["Save"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|     <br /> | ||||
|     <br /> | ||||
|     <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo> | ||||
| </form> | ||||
|  | ||||
| @code { | ||||
|     private int _jobId; | ||||
|     private string _name = string.Empty; | ||||
|     private string _jobType = string.Empty; | ||||
|     private string _isEnabled = "True"; | ||||
|     private string _interval = string.Empty; | ||||
|     private string _frequency = string.Empty; | ||||
|     private string _startDate = string.Empty; | ||||
|     private string _endDate = string.Empty; | ||||
|     private string _retentionHistory = string.Empty; | ||||
|     private string _nextExecution = string.Empty; | ||||
|     private string createdby; | ||||
|     private DateTime createdon; | ||||
|     private string modifiedby; | ||||
|     private DateTime modifiedon; | ||||
|     @code { | ||||
|         private ElementReference form; | ||||
|         private bool validated = false; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; | ||||
|         private int _jobId; | ||||
|         private string _name = string.Empty; | ||||
|         private string _jobType = string.Empty; | ||||
|         private string _isEnabled = "True"; | ||||
|         private string _interval = string.Empty; | ||||
|         private string _frequency = string.Empty; | ||||
|         private string _startDate = string.Empty; | ||||
|         private string _endDate = string.Empty; | ||||
|         private string _retentionHistory = string.Empty; | ||||
|         private string _nextExecution = string.Empty; | ||||
|         private string createdby; | ||||
|         private DateTime createdon; | ||||
|         private string modifiedby; | ||||
|         private DateTime modifiedon; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         try | ||||
|         public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; | ||||
|  | ||||
|         protected override async Task OnInitializedAsync() | ||||
|         { | ||||
|             _jobId = Int32.Parse(PageState.QueryString["id"]); | ||||
|             Job job = await JobService.GetJobAsync(_jobId); | ||||
|             if (job != null) | ||||
|             { | ||||
|                 _name = job.Name; | ||||
|                 _jobType = job.JobType; | ||||
|                 _isEnabled = job.IsEnabled.ToString(); | ||||
|                 _interval = job.Interval.ToString(); | ||||
|                 _frequency = job.Frequency; | ||||
|                 _startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty; | ||||
|                 _endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty; | ||||
|                 _retentionHistory = job.RetentionHistory.ToString(); | ||||
|                 _nextExecution = job.NextExecution.ToString(); | ||||
|                 createdby = job.CreatedBy; | ||||
|                 createdon = job.CreatedOn; | ||||
|                 modifiedby = job.ModifiedBy; | ||||
|                 modifiedon = job.ModifiedOn; | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Job {JobId} {Error}", _jobId, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Job.Load"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task SaveJob() | ||||
|     { | ||||
|         if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty) | ||||
|         { | ||||
|             var job = await JobService.GetJobAsync(_jobId); | ||||
|             job.Name = _name; | ||||
|             job.JobType = _jobType; | ||||
|             job.IsEnabled = Boolean.Parse(_isEnabled); | ||||
|             job.Frequency = _frequency; | ||||
|             job.Interval = int.Parse(_interval); | ||||
|  | ||||
|             if (_startDate == string.Empty) | ||||
|             { | ||||
|                 job.StartDate = null; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 job.StartDate = DateTime.Parse(_startDate); | ||||
|             } | ||||
|  | ||||
|             if (_endDate == string.Empty) | ||||
|             { | ||||
|                 job.EndDate = null; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 job.EndDate = DateTime.Parse(_endDate); | ||||
|             } | ||||
|  | ||||
|             if (_nextExecution == string.Empty) | ||||
|             { | ||||
|                 job.NextExecution = null; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 job.NextExecution = DateTime.Parse(_nextExecution); | ||||
|             } | ||||
|  | ||||
|             job.RetentionHistory = int.Parse(_retentionHistory); | ||||
|  | ||||
|             try | ||||
|             { | ||||
|                 job = await JobService.UpdateJobAsync(job); | ||||
|                 await logger.LogInformation("Job Updated {Job}", job); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|                 _jobId = Int32.Parse(PageState.QueryString["id"]); | ||||
|                 Job job = await JobService.GetJobAsync(_jobId); | ||||
|                 if (job != null) | ||||
|                 { | ||||
|                     _name = job.Name; | ||||
|                     _jobType = job.JobType; | ||||
|                     _isEnabled = job.IsEnabled.ToString(); | ||||
|                     _interval = job.Interval.ToString(); | ||||
|                     _frequency = job.Frequency; | ||||
|                     _startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty; | ||||
|                     _endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty; | ||||
|                     _retentionHistory = job.RetentionHistory.ToString(); | ||||
|                     _nextExecution = job.NextExecution.ToString(); | ||||
|                     createdby = job.CreatedBy; | ||||
|                     createdon = job.CreatedOn; | ||||
|                     modifiedby = job.ModifiedBy; | ||||
|                     modifiedon = job.ModifiedOn; | ||||
|                 } | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error.Job.Update"], MessageType.Error); | ||||
|                 await logger.LogError(ex, "Error Loading Job {JobId} {Error}", _jobId, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error.Job.Load"], MessageType.Error); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|         private async Task SaveJob() | ||||
|         { | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             { | ||||
|                 var job = await JobService.GetJobAsync(_jobId); | ||||
|                 job.Name = _name; | ||||
|                 job.JobType = _jobType; | ||||
|                 job.IsEnabled = Boolean.Parse(_isEnabled); | ||||
|                 job.Frequency = _frequency; | ||||
|                 job.Interval = int.Parse(_interval); | ||||
|  | ||||
|                 if (_startDate == string.Empty) | ||||
|                 { | ||||
|                     job.StartDate = null; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     job.StartDate = DateTime.Parse(_startDate); | ||||
|                 } | ||||
|  | ||||
|                 if (_endDate == string.Empty) | ||||
|                 { | ||||
|                     job.EndDate = null; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     job.EndDate = DateTime.Parse(_endDate); | ||||
|                 } | ||||
|  | ||||
|                 if (_nextExecution == string.Empty) | ||||
|                 { | ||||
|                     job.NextExecution = null; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     job.NextExecution = DateTime.Parse(_nextExecution); | ||||
|                 } | ||||
|  | ||||
|                 job.RetentionHistory = int.Parse(_retentionHistory); | ||||
|  | ||||
|                 try | ||||
|                 { | ||||
|                     job = await JobService.UpdateJobAsync(job); | ||||
|                     await logger.LogInformation("Job Updated {Job}", job); | ||||
|                     NavigationManager.NavigateTo(NavigateUrl()); | ||||
|                 } | ||||
|                 catch (Exception ex) | ||||
|                 { | ||||
|                     await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message); | ||||
|                     AddModuleMessage(Localizer["Error.Job.Update"], MessageType.Error); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Grayson Walker
					Grayson Walker