Skip to content

Commit f378f8c

Browse files
[~] FileUpload/FileInput now respects the supported fileformat from parameter CactuseSecurity#3024
1 parent 7535451 commit f378f8c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

roles/ui/files/FWO.UI/Pages/Settings/SettingsModelling.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@using System.Text.Json
1+
@using System.Text.Json
22
@using FWO.Ui.Pages.NetworkModelling
33

44
@page "/settings/modelling"
@@ -15,7 +15,7 @@
1515
@(userConfig.GetText("U5322"))
1616
<hr />
1717

18-
@if (configData != null && initComplete)
18+
@if(configData != null && initComplete)
1919
{
2020
<form onsubmit="return false">
2121
<button type="button" class="btn btn-sm btn-dark ms-5" data-toggle="tooltip" title="@(userConfig.PureLine("H5602"))"
@@ -82,7 +82,7 @@
8282
<div class="form-group row mt-4" data-toggle="tooltip" title="@(userConfig.PureLine("H9055"))">
8383
<label class="col-form-label col-sm-4">@userConfig.GetText("import_app_server"):</label>
8484
<div class="row col-sm-6">
85-
<CSVFileUpload AuthorizedRoles="@Roles.Admin" OnAddAppServerError="OnAddAppServerError" OnAddAppServerWarning="OnAddAppServerWarning" OnImportSuccess="OnAppServerImportSuccess"></CSVFileUpload>
85+
<CSVFileUpload SupportedFileFormats=".csv" AuthorizedRoles="@Roles.Admin" OnAddAppServerError="OnAddAppServerError" OnAddAppServerWarning="OnAddAppServerWarning" OnImportSuccess="OnAppServerImportSuccess"></CSVFileUpload>
8686
</div>
8787
</div>
8888
<hr />

roles/ui/files/FWO.UI/Shared/CSVFileUpload.razor

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@using FWO.Ui.Data
1+
@using FWO.Ui.Data
22
@using FWO.Data.Modelling
33
@using NetTools
44
@using System.Net
@@ -15,7 +15,7 @@
1515
@(ModellingHandlerBase.DisplayButton(userConfig, "import", Icons.Add))
1616
<span class="ms-2">@(userConfig.GetText("add"))</span>
1717
</label>
18-
<InputFile id="fileUpload" hidden accept=".csv" OnChange="@SingleUpload" />
18+
<InputFile id="fileUpload" hidden accept="@SupportedFileFormats" OnChange="@SingleUpload" />
1919
@if (InputFileChangeEventArgs is not null && !string.IsNullOrEmpty(InputFileChangeEventArgs.File.Name))
2020
{
2121
<label class="d-inline">@InputFileChangeEventArgs.File.Name</label>
@@ -74,6 +74,12 @@
7474
[Parameter]
7575
public EventCallback OnImportSuccess { get; set; }
7676

77+
/// <summary>
78+
/// Defines a set of supported file formats.
79+
/// </summary>
80+
[Parameter, EditorRequired]
81+
public string SupportedFileFormats { get; set; } = "";
82+
7783
private List<AppServerType> AppServerTypes = new();
7884

7985
protected override void OnParametersSet()
@@ -83,6 +89,11 @@
8389
throw new UnauthorizedAccessException($"Parameter {nameof(AuthorizedRoles)} cannot be empty!");
8490
}
8591

92+
if (string.IsNullOrWhiteSpace(SupportedFileFormats))
93+
{
94+
throw new ArgumentNullException($"Parameter {nameof(SupportedFileFormats)} cannot be empty!");
95+
}
96+
8697
base.OnParametersSet();
8798
}
8899

0 commit comments

Comments
 (0)