Merge remote-tracking branch 'oqtane/dev' into dev
This commit is contained in:
@ -61,10 +61,20 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mt-1"><span id="@_progressinfoid" style="display: none;"></span></div>
|
||||
<div class="col mt-1"><progress id="@_progressbarid" class="mt-1" style="display: none;"></progress></div>
|
||||
</div>
|
||||
@if (ShowProgress)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col mt-1"><span id="@_progressinfoid" style="display: none;"></span></div>
|
||||
<div class="col mt-1"><progress id="@_progressbarid" class="mt-1" style="display: none;"></progress></div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_uploading)
|
||||
{
|
||||
<div class="app-progress-indicator"></div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@ -100,6 +110,7 @@
|
||||
private string _guid;
|
||||
private string _message = string.Empty;
|
||||
private MessageType _messagetype;
|
||||
private bool _uploading = false;
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; } // optional - for setting the id of the FileManager component for accessibility
|
||||
@ -128,6 +139,9 @@
|
||||
[Parameter]
|
||||
public bool ShowImage { get; set; } = true; // optional - for indicating whether an image thumbnail should be displayed - default is true
|
||||
|
||||
[Parameter]
|
||||
public bool ShowProgress { get; set; } = true; // optional - for indicating whether progress info should be displayed during upload - default is true
|
||||
|
||||
[Parameter]
|
||||
public bool ShowSuccess { get; set; } = false; // optional - for indicating whether a success message should be displayed upon successful upload - default is false
|
||||
|
||||
@ -271,13 +285,10 @@
|
||||
{
|
||||
_message = string.Empty;
|
||||
FileId = int.Parse((string)e.Value);
|
||||
if (FileId != -1)
|
||||
{
|
||||
await OnSelect.InvokeAsync(FileId);
|
||||
}
|
||||
|
||||
await SetImage();
|
||||
await OnSelect.InvokeAsync(FileId);
|
||||
StateHasChanged();
|
||||
|
||||
}
|
||||
|
||||
private async Task SetImage()
|
||||
@ -321,6 +332,12 @@
|
||||
}
|
||||
if (restricted == "")
|
||||
{
|
||||
if (!ShowProgress)
|
||||
{
|
||||
_uploading = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// upload the files
|
||||
@ -354,8 +371,16 @@
|
||||
}
|
||||
|
||||
// reset progress indicators
|
||||
await interop.SetElementAttribute(_guid + "ProgressInfo", "style", "display: none;");
|
||||
await interop.SetElementAttribute(_guid + "ProgressBar", "style", "display: none;");
|
||||
if (ShowProgress)
|
||||
{
|
||||
await interop.SetElementAttribute(_guid + "ProgressInfo", "style", "display: none;");
|
||||
await interop.SetElementAttribute(_guid + "ProgressBar", "style", "display: none;");
|
||||
}
|
||||
else
|
||||
{
|
||||
_uploading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
@ -396,7 +421,9 @@
|
||||
await logger.LogError(ex, "File Upload Failed {Error}", ex.Message);
|
||||
_message = Localizer["Error.File.Upload"];
|
||||
_messagetype = MessageType.Error;
|
||||
_uploading = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -202,15 +202,15 @@ namespace Oqtane.Services
|
||||
|
||||
private async Task<bool> CheckResponse(HttpResponseMessage response, string uri)
|
||||
{
|
||||
if (uri.Contains("/api/") && !response.RequestMessage.RequestUri.AbsolutePath.Contains("/api/"))
|
||||
if (response.IsSuccessStatusCode && uri.Contains("/api/") && !response.RequestMessage.RequestUri.AbsolutePath.Contains("/api/"))
|
||||
{
|
||||
await Log(uri, response.RequestMessage.Method.ToString(), "Request {Uri} Not Mapped To A Controller Method", uri);
|
||||
await Log(uri, response.RequestMessage.Method.ToString(), response.StatusCode.ToString(), "Request {Uri} Not Mapped To An API Controller Method", uri);
|
||||
return false;
|
||||
}
|
||||
if (response.IsSuccessStatusCode) return true;
|
||||
if (response.StatusCode != HttpStatusCode.NoContent && response.StatusCode != HttpStatusCode.NotFound)
|
||||
{
|
||||
await Log(uri, response.RequestMessage.Method.ToString(), "Request {Uri} Failed With Status {StatusCode} - {ReasonPhrase}", uri, response.StatusCode, response.ReasonPhrase);
|
||||
await Log(uri, response.RequestMessage.Method.ToString(), response.StatusCode.ToString(), "Request {Uri} Failed With Status {StatusCode} - {ReasonPhrase}", uri, response.StatusCode, response.ReasonPhrase);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -221,7 +221,7 @@ namespace Oqtane.Services
|
||||
return mediaType != null && mediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private async Task Log(string uri, string method, string message, params object[] args)
|
||||
private async Task Log(string uri, string method, string status, string message, params object[] args)
|
||||
{
|
||||
if (_siteState.Alias != null)
|
||||
{
|
||||
@ -251,7 +251,14 @@ namespace Oqtane.Services
|
||||
log.Function = LogFunction.Other.ToString();
|
||||
break;
|
||||
}
|
||||
log.Level = LogLevel.Error.ToString();
|
||||
if (status == "500")
|
||||
{
|
||||
log.Level = LogLevel.Error.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Level = LogLevel.Warning.ToString();
|
||||
}
|
||||
log.Message = message;
|
||||
log.MessageTemplate = "";
|
||||
log.Properties = JsonSerializer.Serialize(args);
|
||||
|
@ -139,11 +139,11 @@ namespace Oqtane.Themes.Controls
|
||||
var permissions = pagemodule.Module.PermissionList;
|
||||
if (!permissions.Any(item => item.PermissionName == PermissionNames.View && item.RoleName == RoleNames.Everyone))
|
||||
{
|
||||
permissions.Add(new Permission(ModuleState.SiteId, EntityNames.Page, pagemodule.PageId, PermissionNames.View, RoleNames.Everyone, null, true));
|
||||
permissions.Add(new Permission(ModuleState.SiteId, EntityNames.Module, pagemodule.ModuleId, PermissionNames.View, RoleNames.Everyone, null, true));
|
||||
}
|
||||
if (!permissions.Any(item => item.PermissionName == PermissionNames.View && item.RoleName == RoleNames.Registered))
|
||||
{
|
||||
permissions.Add(new Permission(ModuleState.SiteId, EntityNames.Page, pagemodule.PageId, PermissionNames.View, RoleNames.Registered, null, true));
|
||||
permissions.Add(new Permission(ModuleState.SiteId, EntityNames.Module, pagemodule.ModuleId, PermissionNames.View, RoleNames.Registered, null, true));
|
||||
}
|
||||
pagemodule.Module.PermissionList = permissions;
|
||||
await ModuleService.UpdateModuleAsync(pagemodule.Module);
|
||||
|
@ -89,7 +89,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
if (page != null)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Get Attempt {PageId}", id);
|
||||
_logger.Log(LogLevel.Warning, this, LogFunction.Security, "Unauthorized Page Get Attempt {PageId}", id);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
else
|
||||
@ -116,7 +116,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
if (page != null)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Get Attempt {SiteId} {Path}", siteid, path);
|
||||
_logger.Log(LogLevel.Warning, this, LogFunction.Security, "Unauthorized Page Get Attempt {SiteId} {Path}", siteid, path);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
}
|
||||
else
|
||||
|
@ -201,7 +201,24 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
||||
}
|
||||
entry.ExtractToFile(filename, true);
|
||||
if (Path.Exists(filename) && Path.GetExtension(filename).ToLower() == ".dll")
|
||||
{
|
||||
// ensure assembly version is equal to or greater than existing assembly
|
||||
var assembly = filename.Replace(Path.GetFileName(filename), "temp.dll");
|
||||
entry.ExtractToFile(assembly, true);
|
||||
if (Version.Parse(FileVersionInfo.GetVersionInfo(assembly).FileVersion).CompareTo(Version.Parse(FileVersionInfo.GetVersionInfo(filename).FileVersion)) >= 0)
|
||||
{
|
||||
File.Move(assembly, filename, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(assembly);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.ExtractToFile(filename, true);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -290,8 +290,10 @@ Oqtane.Interop = {
|
||||
var progressinfo = document.getElementById('ProgressInfo_' + id);
|
||||
var progressbar = document.getElementById('ProgressBar_' + id);
|
||||
|
||||
progressinfo.setAttribute("style", "display: inline;");
|
||||
progressbar.setAttribute("style", "width: 100%; display: inline;");
|
||||
if (progressinfo !== null && progressbar !== null) {
|
||||
progressinfo.setAttribute("style", "display: inline;");
|
||||
progressbar.setAttribute("style", "width: 100%; display: inline;");
|
||||
}
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var FileChunk = [];
|
||||
@ -322,21 +324,29 @@ Oqtane.Interop = {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('POST', posturl, true);
|
||||
request.upload.onloadstart = function (e) {
|
||||
progressinfo.innerHTML = file.name + ' 0%';
|
||||
progressbar.value = 0;
|
||||
if (progressinfo !== null && progressbar !== null) {
|
||||
progressinfo.innerHTML = file.name + ' 0%';
|
||||
progressbar.value = 0;
|
||||
}
|
||||
};
|
||||
request.upload.onprogress = function (e) {
|
||||
var percent = Math.ceil((e.loaded / e.total) * 100);
|
||||
progressinfo.innerHTML = file.name + '[' + PartCount + '] ' + percent + '%';
|
||||
progressbar.value = (percent / 100);
|
||||
if (progressinfo !== null && progressbar !== null) {
|
||||
var percent = Math.ceil((e.loaded / e.total) * 100);
|
||||
progressinfo.innerHTML = file.name + '[' + PartCount + '] ' + percent + '%';
|
||||
progressbar.value = (percent / 100);
|
||||
}
|
||||
};
|
||||
request.upload.onloadend = function (e) {
|
||||
progressinfo.innerHTML = file.name + ' 100%';
|
||||
progressbar.value = 1;
|
||||
if (progressinfo !== null && progressbar !== null) {
|
||||
progressinfo.innerHTML = file.name + ' 100%';
|
||||
progressbar.value = 1;
|
||||
}
|
||||
};
|
||||
request.upload.onerror = function () {
|
||||
progressinfo.innerHTML = file.name + ' Error: ' + xhr.status;
|
||||
progressbar.value = 0;
|
||||
request.upload.onerror = function() {
|
||||
if (progressinfo !== null && progressbar !== null) {
|
||||
progressinfo.innerHTML = file.name + ' Error: ' + xhr.status;
|
||||
progressbar.value = 0;
|
||||
}
|
||||
};
|
||||
request.send(data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user