diff --git a/Oqtane.Client/Modules/Admin/Files/Index.razor b/Oqtane.Client/Modules/Admin/Files/Index.razor index 504a888f..06f7e61c 100644 --- a/Oqtane.Client/Modules/Admin/Files/Index.razor +++ b/Oqtane.Client/Modules/Admin/Files/Index.razor @@ -3,54 +3,92 @@ @inject NavigationManager NavigationManager @inject IFolderService FolderService @inject IFileService FileService +@inject ISettingService SettingService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -@if (_files != null) +@if (_files == null) { -
-
- -
-
-
- @Localizer["Folder"]: - -   +

+ @SharedLocalizer["Loading"] +

+} +else +{ + + +
+
+ +
+
+
+ @Localizer["Folder"]: + +   +
+
+
+ +
-
-
- -
-
- -
-   -   - @SharedLocalizer["Name"] - @Localizer["Modified"] - @Localizer["Type"] - @Localizer["Size"] -
- - - - @context.Name - @context.ModifiedOn - @context.Extension.ToUpper() @SharedLocalizer["File"] - @string.Format("{0:0.00}", ((decimal)context.Size / 1000)) KB - -
- @if (_files.Count == 0) - { -
@Localizer["NoFiles"]
- } + @if (_files.Count != 0) + { + +
+   +   + @SharedLocalizer["Name"] + @Localizer["Modified"] + @Localizer["Type"] + @Localizer["Size"] +
+ + + + @context.Name + @context.ModifiedOn + @context.Extension.ToUpper() @SharedLocalizer["File"] + @string.Format("{0:0.00}", ((decimal)context.Size / 1000)) KB + +
+ } + else + { +
@Localizer["NoFiles"]
+ } + + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ } @code { @@ -58,6 +96,10 @@ private int _folderId = -1; private List _files; + private string _imageFiles = string.Empty; + private string _uploadableFiles = string.Empty; + private int _maxChunkSize = 1; + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; protected override async Task OnParametersSetAsync() @@ -71,6 +113,13 @@ _folderId = _folders[0].FolderId; await GetFiles(); } + + var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId); + _imageFiles = SettingService.GetSetting(settings, "ImageFiles", Constants.ImageFiles); + _imageFiles = (string.IsNullOrEmpty(_imageFiles)) ? Constants.ImageFiles : _imageFiles; + _uploadableFiles = SettingService.GetSetting(settings, "UploadableFiles", Constants.UploadableFiles); + _uploadableFiles = (string.IsNullOrEmpty(_uploadableFiles)) ? Constants.UploadableFiles : _uploadableFiles; + _maxChunkSize = int.Parse(SettingService.GetSetting(settings, "MaxChunkSize", "1")); } catch (Exception ex) { @@ -115,4 +164,23 @@ AddModuleMessage(string.Format(Localizer["Error.File.Delete"], file.Name), MessageType.Error); } } + + private async Task SaveSiteSettings() + { + try + { + var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId); + settings = SettingService.SetSetting(settings, "ImageFiles", (_imageFiles != Constants.ImageFiles) ? _imageFiles.Replace(" ", "") : "", false); + settings = SettingService.SetSetting(settings, "UploadableFiles", (_uploadableFiles != Constants.UploadableFiles) ? _uploadableFiles.Replace(" ", "") : "", false); + settings = SettingService.SetSetting(settings, "MaxChunkSize", _maxChunkSize.ToString(), false); + await SettingService.UpdateSiteSettingsAsync(settings, PageState.Site.SiteId); + AddModuleMessage(Localizer["Success.SaveSiteSettings"], MessageType.Success); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Saving Site Settings {Error}", ex.Message); + AddModuleMessage(Localizer["Error.SaveSiteSettings"], MessageType.Error); + } + } + } diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 1db3bc96..c23f9732 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -144,18 +144,6 @@
-
- -
- -
-
-
- -
- -
-
@@ -431,7 +419,6 @@ private Dictionary _textEditors = new Dictionary(); private string _textEditor = ""; private string _imageFiles = string.Empty; - private string _uploadableFiles = string.Empty; private string _headcontent = string.Empty; private string _bodycontent = string.Empty; @@ -528,8 +515,6 @@ _textEditor = SettingService.GetSetting(settings, "TextEditor", Constants.DefaultTextEditor); _imageFiles = SettingService.GetSetting(settings, "ImageFiles", Constants.ImageFiles); _imageFiles = (string.IsNullOrEmpty(_imageFiles)) ? Constants.ImageFiles : _imageFiles; - _uploadableFiles = SettingService.GetSetting(settings, "UploadableFiles", Constants.UploadableFiles); - _uploadableFiles = (string.IsNullOrEmpty(_uploadableFiles)) ? Constants.UploadableFiles : _uploadableFiles; // page content _headcontent = site.HeadContent; @@ -734,8 +719,6 @@ // functionality settings = SettingService.SetSetting(settings, "TextEditor", _textEditor); - settings = SettingService.SetSetting(settings, "ImageFiles", (_imageFiles != Constants.ImageFiles) ? _imageFiles.Replace(" ", "") : "", false); - settings = SettingService.SetSetting(settings, "UploadableFiles", (_uploadableFiles != Constants.UploadableFiles) ? _uploadableFiles.Replace(" ", "") : "", false); await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId); diff --git a/Oqtane.Client/Modules/Controls/FileManager.razor b/Oqtane.Client/Modules/Controls/FileManager.razor index 9a1f6d85..009eca34 100644 --- a/Oqtane.Client/Modules/Controls/FileManager.razor +++ b/Oqtane.Client/Modules/Controls/FileManager.razor @@ -3,8 +3,8 @@ @inherits ModuleControlBase @inject IFolderService FolderService @inject IFileService FileService -@inject ISettingService SettingService @inject IUserService UserService +@inject ISettingService SettingService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer @@ -380,6 +380,13 @@ } } + var chunksize = ChunkSize; + if (chunksize == 1) + { + // if ChunkSize parameter is not overridden use the site setting + chunksize = int.Parse(SettingService.GetSetting(PageState.Site.Settings, "MaxChunkSize", "1")); + } + if (!ShowProgress) { _uploading = true; @@ -387,7 +394,7 @@ } // upload files - var success = await interop.UploadFiles(posturl, folder, _guid, SiteState.AntiForgeryToken, jwt, ChunkSize); + var success = await interop.UploadFiles(posturl, folder, _guid, SiteState.AntiForgeryToken, jwt, chunksize); // reset progress indicators if (ShowProgress) diff --git a/Oqtane.Client/Resources/Modules/Admin/Files/Index.resx b/Oqtane.Client/Resources/Modules/Admin/Files/Index.resx index 949ce2a3..a4d7177e 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Files/Index.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Files/Index.resx @@ -165,4 +165,31 @@ Upload Files + + Files + + + Image Extensions: + + + Enter a comma separated list of image file extensions + + + Uploadable File Extensions: + + + Enter a comma separated list of uploadable file extensions + + + Max Upload Chunk Size (MB): + + + Files are split into chunks to streamline the upload process. Specify the maximum chunk size in MB (note that higher chunk sizes should only be used on faster networks). + + + Settings Saved Successfully + + + Error Saving Settings + \ No newline at end of file diff --git a/Oqtane.Client/Resources/Modules/Admin/Site/Index.resx b/Oqtane.Client/Resources/Modules/Admin/Site/Index.resx index 670a4cba..0551fb8f 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Site/Index.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Site/Index.resx @@ -402,18 +402,6 @@ Retention (Days): - - Enter a comma separated list of image file extensions - - - Image Extensions: - - - Enter a comma separated list of uploadable file extensions - - - Uploadable File Extensions: - Specifies if the site can be integrated with an external .NET MAUI hybrid application