Enhance Settings API for public Site Settings. Added Settings to Site model by default. Added new parameters to Login and UserProfile components. Enhanced Oqtane Theme settings to use new component parameters. Enhanced image download and resizing logic.
This commit is contained in:
@ -27,7 +27,7 @@
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="url" HelpText="Enter the url of the file you wish to download" ResourceKey="Url">Url: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="url" class="form-control" @bind="@url" required />
|
||||
<input id="url" class="form-control" @bind="@_url" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
@ -42,6 +42,12 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="name" HelpText="Enter the name of the file being downloaded" ResourceKey="Name">Name: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="name" class="form-control" @bind="@_name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-success" @onclick="Download">@SharedLocalizer["Download"]</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||
@ -53,9 +59,10 @@
|
||||
@code {
|
||||
private ElementReference form;
|
||||
private bool validated = false;
|
||||
private string url = string.Empty;
|
||||
private string _url = string.Empty;
|
||||
private List<Folder> _folders;
|
||||
private int _folderId = -1;
|
||||
private string _name = "";
|
||||
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||
|
||||
@ -75,22 +82,24 @@
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
{
|
||||
if (url == string.Empty || _folderId == -1)
|
||||
if (_url == string.Empty || _folderId == -1)
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||
if (string.IsNullOrEmpty(_name))
|
||||
{
|
||||
_name = _url.Substring(_url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||
}
|
||||
|
||||
if (!Constants.UploadableFiles.Split(',')
|
||||
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
|
||||
if (!Constants.UploadableFiles.Split(',').Contains(Path.GetExtension(_name).ToLower().Replace(".", "")))
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filename.IsPathOrFileValid())
|
||||
if (!_name.IsPathOrFileValid())
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning);
|
||||
return;
|
||||
@ -98,13 +107,13 @@
|
||||
|
||||
try
|
||||
{
|
||||
await FileService.UploadFileAsync(url, _folderId);
|
||||
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
|
||||
await FileService.UploadFileAsync(_url, _folderId, _name);
|
||||
await logger.LogInformation("File Downloaded Successfully From Url {Url}", _url);
|
||||
AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message);
|
||||
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", _url, ex.Message);
|
||||
AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user