diff --git a/Oqtane.Client/Modules/Admin/Files/Add.razor b/Oqtane.Client/Modules/Admin/Files/Add.razor
index a01b9b1c..9f19370d 100644
--- a/Oqtane.Client/Modules/Admin/Files/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Files/Add.razor
@@ -1,4 +1,5 @@
@namespace Oqtane.Modules.Admin.Files
+@using System.IO
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IFileService FileService
@@ -12,7 +13,7 @@
-
+
|
@@ -70,18 +71,32 @@
private async Task Download()
{
+ if (url == string.Empty || _folderId == -1)
+ {
+ AddModuleMessage("You Must Enter A Url And Select A Folder", MessageType.Warning);
+ return;
+ }
+
+ var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
+
+ if (!Constants.UploadableFiles.Split(',')
+ .Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
+ {
+ AddModuleMessage("File Could Not Be Downloaded From Url Due To Its File Extension", MessageType.Warning);
+ return ;
+ }
+
+ if (!filename.IsPathOrFileValid())
+ {
+ AddModuleMessage("You Must Enter A Url With A Valid File Name", MessageType.Warning);
+ return;
+ }
+
try
{
- if (url != string.Empty && _folderId != -1)
- {
- await FileService.UploadFileAsync(url, _folderId);
- await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
- AddModuleMessage("File Downloaded Successfully From Url", MessageType.Success);
- }
- else
- {
- AddModuleMessage("You Must Enter A Url And Select A Folder", MessageType.Warning);
- }
+ await FileService.UploadFileAsync(url, _folderId);
+ await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
+ AddModuleMessage("File Downloaded Successfully From Url", MessageType.Success);
}
catch (Exception ex)
{
diff --git a/Oqtane.Client/Modules/Admin/Files/Edit.razor b/Oqtane.Client/Modules/Admin/Files/Edit.razor
index 0083cce0..5d42485b 100644
--- a/Oqtane.Client/Modules/Admin/Files/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Files/Edit.razor
@@ -25,7 +25,7 @@
-
+
|
@@ -112,51 +112,63 @@
private async Task SaveFolder()
{
+ if (_name == string.Empty || _parentId == -1)
+ {
+ AddModuleMessage("Folders Must Have A Parent And A Name", MessageType.Warning);
+ return;
+ }
+
+ if (!_name.IsPathOrFileValid())
+ {
+ AddModuleMessage("Folder Name Not Valid.", MessageType.Warning);
+ return;
+ }
+
try
{
- if (_name != string.Empty && _parentId != -1)
+ Folder folder;
+ if (_folderId != -1)
{
- Folder folder;
- if (_folderId != -1)
- {
- folder = await FolderService.GetFolderAsync(_folderId);
- }
- else
- {
- folder = new Folder();
- }
+ folder = await FolderService.GetFolderAsync(_folderId);
+ }
+ else
+ {
+ folder = new Folder();
+ }
- folder.SiteId = PageState.Site.SiteId;
+ folder.SiteId = PageState.Site.SiteId;
- if (_parentId == -1)
- {
- folder.ParentId = null;
- }
- else
- {
- folder.ParentId = _parentId;
- }
+ if (_parentId == -1)
+ {
+ folder.ParentId = null;
+ }
+ else
+ {
+ folder.ParentId = _parentId;
+ }
- folder.Name = _name;
- folder.IsSystem = _isSystem;
- folder.Permissions = _permissionGrid.GetPermissions();
+ folder.Name = _name;
+ folder.IsSystem = _isSystem;
+ folder.Permissions = _permissionGrid.GetPermissions();
- if (_folderId != -1)
- {
- folder = await FolderService.UpdateFolderAsync(folder);
- }
- else
- {
- folder = await FolderService.AddFolderAsync(folder);
- }
+ if (_folderId != -1)
+ {
+ folder = await FolderService.UpdateFolderAsync(folder);
+ }
+ else
+ {
+ folder = await FolderService.AddFolderAsync(folder);
+ }
+ if (folder != null)
+ {
await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId);
await logger.LogInformation("Folder Saved {Folder}", folder);
NavigationManager.NavigateTo(NavigateUrl());
}
else
{
- AddModuleMessage("Folders Must Have A Parent And A Name", MessageType.Warning);
+ AddModuleMessage("An Error Was Encountered Saving The Folder", MessageType.Error);
}
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
index 8b4cb758..9d26615a 100644
--- a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
+++ b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
@@ -3,53 +3,66 @@
@inject NavigationManager NavigationManager
@inject IModuleDefinitionService ModuleDefinitionService
@inject IModuleService ModuleService
+@inject ISystemService SystemService
-
-@code {
+@code {
private string _owner = string.Empty;
private string _module = string.Empty;
private string _description = string.Empty;
- private string _template = string.Empty;
+ private string _template = "-";
+ private string _location = string.Empty;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
@@ -62,9 +75,9 @@
{
try
{
- if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && !string.IsNullOrEmpty(_template))
+ if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && _template != "-")
{
- var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ",""), Name = _module.Replace(" ", ""), Description = _description, Template = _template };
+ var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ", ""), Name = _module.Replace(" ", ""), Description = _description, Template = _template };
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
}
else
@@ -77,4 +90,35 @@
await logger.LogError(ex, "Error Creating Module");
}
}
+
+ private async void TemplateChanged(ChangeEventArgs e)
+ {
+ try
+ {
+ _location = string.Empty;
+ _template = (string)e.Value;
+ if (_template != "-")
+ {
+ Dictionary systeminfo = await SystemService.GetSystemInfoAsync();
+ if (systeminfo != null)
+ {
+ string[] path = systeminfo["serverpath"].Split('\\');
+ if (_template == "internal")
+ {
+ _location = string.Join("\\", path, 0, path.Length - 1) + "\\Oqtane.Client\\Modules\\" + _owner + "." + _module + "s";
+ }
+ else
+ {
+ _location = string.Join("\\", path, 0, path.Length - 2) + "\\" + _owner + "." + _module + "s";
+ }
+ }
+ }
+ StateHasChanged();
+ }
+ catch (Exception ex)
+ {
+ await logger.LogError(ex, "Error Getting System Info {Error}", ex.Message);
+ AddModuleMessage("Error Getting System Info", MessageType.Error);
+ }
+ }
}
diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/debug.cmd b/Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/debug.cmd
deleted file mode 100644
index 37f0dd87..00000000
--- a/Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/debug.cmd
+++ /dev/null
@@ -1,6 +0,0 @@
-XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Client.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Client.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Module.Server.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Module.Server.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Shared.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Shared.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
index a63784bc..db9186bd 100644
--- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
+++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
@@ -35,7 +35,7 @@
|
-
+
|
diff --git a/Oqtane.Client/Modules/Admin/Modules/Settings.razor b/Oqtane.Client/Modules/Admin/Modules/Settings.razor
index c8a90d23..98e78bdf 100644
--- a/Oqtane.Client/Modules/Admin/Modules/Settings.razor
+++ b/Oqtane.Client/Modules/Admin/Modules/Settings.razor
@@ -24,7 +24,7 @@
|
+
+
+
+ |
+
+
+ |
+
@@ -77,6 +88,7 @@
private Dictionary _containers;
private string _title;
private string _containerType;
+ private string _allPages = "false";
private string _permissionNames = "";
private string _permissions;
private string _pageId;
@@ -95,6 +107,15 @@
_title = ModuleState.Title;
_containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
_containerType = ModuleState.ContainerType;
+ if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType)
+ {
+ _containerType = "-";
+ }
+ if (_containerType == PageState.Site.DefaultContainerType)
+ {
+ _containerType = "-";
+ }
+ _allPages = ModuleState.AllPages.ToString();
_permissions = ModuleState.Permissions;
_permissionNames = ModuleState.ModuleDefinition.PermissionNames;
_pageId = ModuleState.PageId.ToString();
@@ -102,8 +123,8 @@
_settingsModuleType = Type.GetType(ModuleState.ModuleType);
if (_settingsModuleType != null)
{
- var moduleobject = Activator.CreateInstance(_settingsModuleType);
- _settingstitle = (string)_settingsModuleType.GetProperty("Title").GetValue(moduleobject, null);
+ var moduleobject = Activator.CreateInstance(_settingsModuleType) as IModuleControl;
+ _settingstitle = moduleobject.Title;
if (string.IsNullOrEmpty(_settingstitle))
{
_settingstitle = "Other Settings";
@@ -120,18 +141,26 @@
private async Task SaveModule()
{
- var module = ModuleState;
- module.Permissions = _permissionGrid.GetPermissions();
- await ModuleService.UpdateModuleAsync(module);
-
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
pagemodule.PageId = int.Parse(_pageId);
pagemodule.Title = _title;
- pagemodule.ContainerType = _containerType;
-
+ pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty;
+ if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType)
+ {
+ pagemodule.ContainerType = string.Empty;
+ }
+ if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType)
+ {
+ pagemodule.ContainerType = string.Empty;
+ }
await PageModuleService.UpdatePageModuleAsync(pagemodule);
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
+ var module = ModuleState;
+ module.AllPages = bool.Parse(_allPages);
+ module.Permissions = _permissionGrid.GetPermissions();
+ await ModuleService.UpdateModuleAsync(module);
+
if (_settingsModuleType != null)
{
var moduleType = Type.GetType(ModuleState.ModuleType);
diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor
index f7e3c20f..8761ff3a 100644
--- a/Oqtane.Client/Modules/Admin/Pages/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor
@@ -101,7 +101,7 @@
|
|
|
+
+
+
+ |
+
+
+ |
+
@@ -187,6 +201,7 @@
@code {
private Dictionary _themes;
private Dictionary _panelayouts;
+ private Dictionary _containers = new Dictionary();
private List _themeList;
private List _pageList;
private string _name;
@@ -202,6 +217,7 @@
private string _mode = "view";
private string _themetype = "-";
private string _layouttype = "-";
+ private string _containertype = "-";
private string _icon = string.Empty;
private string _permissions = string.Empty;
private PermissionGrid _permissionGrid;
@@ -216,11 +232,9 @@
_pageList = PageState.Pages;
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
- _themetype = PageState.Site.DefaultThemeType;
- _layouttype = PageState.Site.DefaultLayoutType;
-
_themes = ThemeService.GetThemeTypes(_themeList);
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
+ _containers = ThemeService.GetContainerTypes(_themeList);
_permissions = string.Empty;
}
@@ -351,16 +365,20 @@
page.Url = _url;
page.EditMode = (_mode == "edit" ? true : false);
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
- page.LayoutType = (_layouttype != "-") ? _layouttype : string.Empty;
- if (page.ThemeType == PageState.Site.DefaultThemeType)
+ if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
{
page.ThemeType = string.Empty;
}
-
- if (page.LayoutType == PageState.Site.DefaultLayoutType)
+ page.LayoutType = (_layouttype != "-") ? _layouttype : string.Empty;
+ if (!string.IsNullOrEmpty(page.LayoutType) && page.LayoutType == PageState.Site.DefaultLayoutType)
{
page.LayoutType = string.Empty;
}
+ page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
+ if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
+ {
+ page.DefaultContainerType = string.Empty;
+ }
page.Icon = (_icon == null ? string.Empty : _icon);
page.Permissions = _permissionGrid.GetPermissions();
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor
index 8132696d..b25f6b2e 100644
--- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor
@@ -112,7 +112,7 @@
|
|
|
+
+
+
+ |
+
+
+ |
+
@@ -200,6 +214,7 @@
@code {
private Dictionary _themes;
private Dictionary _panelayouts;
+ private Dictionary _containers = new Dictionary();
private List _themeList;
private List _pageList;
private int _pageId;
@@ -217,6 +232,7 @@
private string _mode;
private string _themetype = "-";
private string _layouttype = "-";
+ private string _containertype = "-";
private string _icon;
private string _permissions;
private string _createdby;
@@ -241,6 +257,7 @@
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
_themes = ThemeService.GetThemeTypes(_themeList);
+ _containers = ThemeService.GetContainerTypes(_themeList);
_pageId = Int32.Parse(PageState.QueryString["id"]);
var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
@@ -270,16 +287,21 @@
_ispersonalizable = page.IsPersonalizable.ToString();
_mode = (page.EditMode) ? "edit" : "view";
_themetype = page.ThemeType;
- _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
- _layouttype = page.LayoutType;
if (_themetype == PageState.Site.DefaultThemeType)
{
_themetype = "-";
}
+ _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
+ _layouttype = page.LayoutType;
if (_layouttype == PageState.Site.DefaultLayoutType)
{
_layouttype = "-";
}
+ _containertype = page.DefaultContainerType;
+ if (string.IsNullOrEmpty(_containertype))
+ {
+ _containertype = "-";
+ }
_icon = page.Icon;
_permissions = page.Permissions;
_createdby = page.CreatedBy;
@@ -426,15 +448,20 @@
page.Url = _url;
page.EditMode = (_mode == "edit");
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
- page.LayoutType = (_layouttype != "-") ? _layouttype : string.Empty;
- if (page.ThemeType == PageState.Site.DefaultThemeType)
+ if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
{
page.ThemeType = string.Empty;
}
- if (page.LayoutType == PageState.Site.DefaultLayoutType)
+ page.LayoutType = (_layouttype != "-") ? _layouttype : string.Empty;
+ if (!string.IsNullOrEmpty(page.LayoutType) && page.LayoutType == PageState.Site.DefaultLayoutType)
{
page.LayoutType = string.Empty;
}
+ page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
+ if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
+ {
+ page.DefaultContainerType = string.Empty;
+ }
page.Icon = _icon ?? string.Empty;
page.Permissions = _permissionGrid.GetPermissions();
page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor
index e4bae61e..3f3425f6 100644
--- a/Oqtane.Client/Modules/Admin/Site/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Site/Index.razor
@@ -39,7 +39,7 @@
|
-
+
|
@@ -47,7 +47,7 @@
-
+
|
@@ -185,7 +185,7 @@
-
+
|
@@ -193,7 +193,7 @@
-
+
|
diff --git a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
index 8e19125f..ca7c7f2c 100644
--- a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
+++ b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
@@ -8,7 +8,7 @@
-
+
|
@@ -16,7 +16,7 @@
-
+
|
@@ -24,7 +24,7 @@
-
+
|
@@ -32,7 +32,7 @@
-
+
|
@@ -40,7 +40,7 @@
-
+
|
@@ -48,7 +48,7 @@
-
+
|
diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor
index 5ad4f5c6..da47d8a9 100644
--- a/Oqtane.Client/Modules/Admin/Themes/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor
@@ -35,7 +35,7 @@
-
+
|
diff --git a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
index 2aa2ce86..7ee95e30 100644
--- a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
@@ -11,29 +11,27 @@
@if (_upgradeavailable)
{
-
- @("Framework") @_package.Version
+
+ @("Framework") @_package.Version
}
else
{
}
- @if (_upgradeavailable)
- {
-
+
|
-
+
|
+
- }
}
diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
index 6f3ab545..fec53f62 100644
--- a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
+++ b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
@@ -64,7 +64,7 @@ else
-
+
|
diff --git a/Oqtane.Client/Modules/Admin/Users/Edit.razor b/Oqtane.Client/Modules/Admin/Users/Edit.razor
index 3aa30e1b..95449f2d 100644
--- a/Oqtane.Client/Modules/Admin/Users/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Users/Edit.razor
@@ -63,7 +63,7 @@ else
-
+
|
diff --git a/Oqtane.Client/Modules/Controls/ActionDialog.razor b/Oqtane.Client/Modules/Controls/ActionDialog.razor
index 08b2d77d..076f1e9d 100644
--- a/Oqtane.Client/Modules/Controls/ActionDialog.razor
+++ b/Oqtane.Client/Modules/Controls/ActionDialog.razor
@@ -1,6 +1,6 @@
@namespace Oqtane.Modules.Controls
@inherits ModuleBase
-
+@attribute [OqtaneIgnore]
@if (_visible)
{
@@ -62,9 +62,9 @@
[Parameter]
public string Class { get; set; } // optional
- [Parameter]
- public bool Disabled { get; set; } // optional
-
+ [Parameter]
+ public bool Disabled { get; set; } // optional
+
[Parameter]
public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true
@@ -109,8 +109,8 @@
Type moduleType = Type.GetType(typename);
if (moduleType != null)
{
- var moduleobject = Activator.CreateInstance(moduleType);
- security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
+ var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
+ security = moduleobject.SecurityAccessLevel;
}
else
{
diff --git a/Oqtane.Client/Modules/Controls/ActionLink.razor b/Oqtane.Client/Modules/Controls/ActionLink.razor
index cf588579..d8ed32a6 100644
--- a/Oqtane.Client/Modules/Controls/ActionLink.razor
+++ b/Oqtane.Client/Modules/Controls/ActionLink.razor
@@ -1,5 +1,6 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
+@inherits ModuleBase
+@attribute [OqtaneIgnore]
@inject IUserService UserService
@if (_authorized)
@@ -100,8 +101,8 @@
var moduleType = Type.GetType(typename);
if (moduleType != null)
{
- var moduleobject = Activator.CreateInstance(moduleType);
- security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
+ var moduleobject = Activator.CreateInstance(moduleType) as IModuleControl;
+ security = moduleobject.SecurityAccessLevel;
}
else
{
diff --git a/Oqtane.Client/Modules/Controls/AuditInfo.razor b/Oqtane.Client/Modules/Controls/AuditInfo.razor
index 75079c6c..7c081d3f 100644
--- a/Oqtane.Client/Modules/Controls/AuditInfo.razor
+++ b/Oqtane.Client/Modules/Controls/AuditInfo.razor
@@ -1,5 +1,6 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
+@inherits ModuleBase
+@attribute [OqtaneIgnore]
@if (_text != string.Empty)
{
diff --git a/Oqtane.Client/Modules/Controls/FileManager.razor b/Oqtane.Client/Modules/Controls/FileManager.razor
index 0519e1b5..96196b06 100644
--- a/Oqtane.Client/Modules/Controls/FileManager.razor
+++ b/Oqtane.Client/Modules/Controls/FileManager.razor
@@ -1,5 +1,7 @@
@namespace Oqtane.Modules.Controls
@inherits ModuleBase
+
+@attribute [OqtaneIgnore]
@inject IFolderService FolderService
@inject IFileService FileService
@inject IJSRuntime JsRuntime
@@ -9,33 +11,36 @@
-
-
+
+ }
+ @if (ShowFiles)
{
FileChanged(e))">
@foreach (File file in _files)
{
- if (file.FileId == _fileid)
+ if (file.FileId == FileId)
{
}
@@ -47,33 +52,33 @@
}
- @if (_haseditpermission)
+ @if (ShowUpload && _haseditpermission)
{
- @((MarkupString)_message)
}
+ @((MarkupString) _message)
@if (_image != string.Empty)
{
- @((MarkupString)_image)
+ @((MarkupString) _image)
}
@@ -83,15 +88,12 @@
@code {
private string _id;
private List
_folders;
- private int _folderid = -1;
private List _files = new List();
- private int _fileid = -1;
private bool _showfiles = true;
private string _fileinputid = string.Empty;
private string _progressinfoid = string.Empty;
private string _progressbarid = string.Empty;
private string _filter = "*";
- private bool _uploadmultiple = false;
private bool _haseditpermission = false;
private string _message = string.Empty;
private string _image = string.Empty;
@@ -104,19 +106,25 @@
public string Folder { get; set; } // optional - for setting a specific folder by default
[Parameter]
- public string FolderId { get; set; } // optional - for setting a specific folderid by default
+ public int FolderId { get; set; } = -1; // optional - for setting a specific folderid by default
[Parameter]
- public string ShowFiles { get; set; } // optional - for indicating whether a list of files should be displayed - default is true
+ public bool ShowFiles { get; set; } = true; // optional - for indicating whether a list of files should be displayed - default is true
[Parameter]
- public string FileId { get; set; } // optional - for setting a specific file by default
+ public bool ShowUpload { get; set; } = true; // optional - for indicating whether a Upload controls should be displayed - default is true
+
+ [Parameter]
+ public bool ShowFolders { get; set; } = true; // optional - for indicating whether a list of folders should be displayed - default is true
+
+ [Parameter]
+ public int FileId { get; set; } = -1; // optional - for setting a specific file by default
[Parameter]
public string Filter { get; set; } // optional - comma delimited list of file types that can be selected or uploaded ie. "jpg,gif"
[Parameter]
- public string UploadMultiple { get; set; } // optional - enable multiple file uploads - default false
+ public bool UploadMultiple { get; set; } = false; // optional - enable multiple file uploads - default false
protected override async Task OnInitializedAsync()
{
@@ -128,56 +136,39 @@
if (!string.IsNullOrEmpty(Folder))
{
_folders = new List {new Folder {FolderId = -1, Name = Folder}};
- _folderid = -1;
+ FolderId = -1;
}
else
{
_folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
- if (!string.IsNullOrEmpty(FolderId))
- {
- _folderid = int.Parse(FolderId);
- }
}
- if (!string.IsNullOrEmpty(FileId))
+ if (FileId != -1)
{
- _fileid = int.Parse(FileId);
- if (_fileid != -1)
+ File file = await FileService.GetFileAsync(FileId);
+ if (file != null)
{
- File file = await FileService.GetFileAsync(int.Parse(FileId));
- if (file != null)
- {
- _folderid = file.FolderId;
- }
- else
- {
- _fileid = -1; // file does not exist
- }
+ FolderId = file.FolderId;
+ }
+ else
+ {
+ FileId = -1; // file does not exist
}
- await SetImage();
- }
- if (!string.IsNullOrEmpty(ShowFiles))
- {
- _showfiles = bool.Parse(ShowFiles);
}
+ await SetImage();
if (!string.IsNullOrEmpty(Filter))
{
- _filter = "." + Filter.Replace(",",",.");
+ _filter = "." + Filter.Replace(",", ",.");
}
await GetFiles();
- // create unique id for component
+ // create unique id for component
_guid = Guid.NewGuid().ToString("N");
_fileinputid = _guid + "FileInput";
_progressinfoid = _guid + "ProgressInfo";
_progressbarid = _guid + "ProgressBar";
-
- if (!string.IsNullOrEmpty(UploadMultiple))
- {
- _uploadmultiple = bool.Parse(UploadMultiple);
- }
}
private async Task GetFiles()
@@ -190,11 +181,11 @@
}
else
{
- Folder folder = _folders.FirstOrDefault(item => item.FolderId == _folderid);
+ Folder folder = _folders.FirstOrDefault(item => item.FolderId == FolderId);
if (folder != null)
{
- _haseditpermission = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, folder.Permissions);
- _files = await FileService.GetFilesAsync(_folderid);
+ _haseditpermission = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, folder.Permissions);
+ _files = await FileService.GetFilesAsync(FolderId);
}
else
{
@@ -221,9 +212,9 @@
_message = string.Empty;
try
{
- _folderid = int.Parse((string)e.Value);
+ FolderId = int.Parse((string) e.Value);
await GetFiles();
- _fileid = -1;
+ FileId = -1;
_image = string.Empty;
StateHasChanged();
}
@@ -237,7 +228,7 @@
private async Task FileChanged(ChangeEventArgs e)
{
_message = string.Empty;
- _fileid = int.Parse((string)e.Value);
+ FileId = int.Parse((string) e.Value);
await SetImage();
StateHasChanged();
@@ -246,21 +237,21 @@
private async Task SetImage()
{
_image = string.Empty;
- if (_fileid != -1)
+ if (FileId != -1)
{
- File file = await FileService.GetFileAsync(_fileid);
+ File file = await FileService.GetFileAsync(FileId);
if (file != null && file.ImageHeight != 0 && file.ImageWidth != 0)
{
var maxwidth = 200;
var maxheight = 200;
- var ratioX = (double)maxwidth / (double)file.ImageWidth;
- var ratioY = (double)maxheight / (double)file.ImageHeight;
+ var ratioX = (double) maxwidth / (double) file.ImageWidth;
+ var ratioY = (double) maxheight / (double) file.ImageHeight;
var ratio = ratioX < ratioY ? ratioX : ratioY;
- _image = "
";
+ _image = "
";
}
}
}
@@ -280,7 +271,7 @@
}
else
{
- result = await FileService.UploadFilesAsync(_folderid, upload, _guid);
+ result = await FileService.UploadFilesAsync(FolderId, upload, _guid);
}
if (result == string.Empty)
@@ -294,7 +285,7 @@
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
if (file != null)
{
- _fileid = file.FileId;
+ FileId = file.FileId;
await SetImage();
}
}
@@ -324,21 +315,21 @@
try
{
- await FileService.DeleteFileAsync(_fileid);
- await logger.LogInformation("File Deleted {File}", _fileid);
+ await FileService.DeleteFileAsync(FileId);
+ await logger.LogInformation("File Deleted {File}", FileId);
_message = "
File Deleted
";
await GetFiles();
- _fileid = -1;
+ FileId = -1;
await SetImage();
StateHasChanged();
}
catch (Exception ex)
{
- await logger.LogError(ex, "Error Deleting File {File} {Error}", _fileid, ex.Message);
+ await logger.LogError(ex, "Error Deleting File {File} {Error}", FileId, ex.Message);
_message = "
Error Deleting File
";
}
}
- public int GetFileId() => _fileid;
+ public int GetFileId() => FileId;
}
diff --git a/Oqtane.Client/Modules/Controls/Label.razor b/Oqtane.Client/Modules/Controls/Label.razor
index 0826e0cb..e57d01ec 100644
--- a/Oqtane.Client/Modules/Controls/Label.razor
+++ b/Oqtane.Client/Modules/Controls/Label.razor
@@ -1,5 +1,6 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
+@inherits ModuleBase
+@attribute [OqtaneIgnore]
@if (!string.IsNullOrEmpty(HelpText))
{
@@ -41,4 +42,4 @@ else
_openLabel += ">";
}
-}
\ No newline at end of file
+}
diff --git a/Oqtane.Client/Modules/Controls/ModuleMessage.razor b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
index 67f3f50d..5e00cb76 100644
--- a/Oqtane.Client/Modules/Controls/ModuleMessage.razor
+++ b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
@@ -1,5 +1,6 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
+@inherits ModuleBase
+@attribute [OqtaneIgnore]
@if (!string.IsNullOrEmpty(_message))
{
diff --git a/Oqtane.Client/Modules/Controls/Pager.razor b/Oqtane.Client/Modules/Controls/Pager.razor
index 184eaa8a..ff7e13ee 100644
--- a/Oqtane.Client/Modules/Controls/Pager.razor
+++ b/Oqtane.Client/Modules/Controls/Pager.razor
@@ -1,6 +1,8 @@
@namespace Oqtane.Modules.Controls
@inherits ModuleBase
-@typeparam TableItem
+@attribute [OqtaneIgnore]
+@typeparam TableItem
+
@if(Format == "Table")
@@ -209,4 +211,4 @@
UpdateList(_page);
}
-}
\ No newline at end of file
+}
diff --git a/Oqtane.Client/Modules/Controls/PermissionGrid.razor b/Oqtane.Client/Modules/Controls/PermissionGrid.razor
index 543403f2..90954bbe 100644
--- a/Oqtane.Client/Modules/Controls/PermissionGrid.razor
+++ b/Oqtane.Client/Modules/Controls/PermissionGrid.razor
@@ -1,5 +1,6 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
+@inherits ModuleBase
+@attribute [OqtaneIgnore]
@inject IRoleService RoleService
@inject IUserService UserService
diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
index 36368c5a..c588274f 100644
--- a/Oqtane.Client/Modules/Controls/RichTextEditor.razor
+++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
@@ -1,28 +1,82 @@
@namespace Oqtane.Modules.Controls
@inherits ModuleBase
+@attribute [OqtaneIgnore]
@inject IJSRuntime JsRuntime
-@if (_filemanagervisible)
-{
-
- @((MarkupString)_message)
-
-}
-
-
- @if (_filemanagervisible)
- {
- @((MarkupString)" ")
-
- }
-
-
-
-
- @ToolbarContent
-
-
-
+
+
+
+
+ @if (_filemanagervisible)
+ {
+
+ @((MarkupString)_message)
+
+ }
+
+
+
+ @if (_filemanagervisible)
+ {
+ @((MarkupString)" ")
+
+ }
+
+
+
+
+ @if (ToolbarContent != null)
+ {
+ @ToolbarContent
+ }
+ else
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ @if (ReadOnly)
+ {
+
+ }
+ else
+ {
+
+ }
+
+
@@ -31,10 +85,12 @@
private ElementReference _toolBar;
private bool _filemanagervisible = false;
private FileManager _fileManager;
+ private string _content = string.Empty;
+ private string _original = string.Empty;
private string _message = string.Empty;
[Parameter]
- public RenderFragment ToolbarContent { get; set; }
+ public string Content { get; set; }
[Parameter]
public bool ReadOnly { get; set; } = false;
@@ -42,60 +98,78 @@
[Parameter]
public string Placeholder { get; set; } = "Enter Your Content...";
+ // parameters only applicable to rich text editor
+ [Parameter]
+ public RenderFragment ToolbarContent { get; set; }
+
[Parameter]
public string Theme { get; set; } = "snow";
[Parameter]
public string DebugLevel { get; set; } = "info";
+ protected override void OnInitialized()
+ {
+ _content = Content; // raw HTML
+ }
+
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
- await RichTextEditorInterop.CreateEditor(
- JsRuntime,
+ var interop = new RichTextEditorInterop(JsRuntime);
+
+ await interop.CreateEditor(
_editorElement,
_toolBar,
ReadOnly,
Placeholder,
Theme,
DebugLevel);
+
+ await interop.LoadEditorContent(_editorElement, Content);
+
+ // preserve a copy of the rich text content ( Quill sanitizes content so we need to retrieve it from the editor )
+ _original = await interop.GetHtml(_editorElement);
}
}
- public async Task
GetText()
+ public void CloseFileManager()
{
- return await RichTextEditorInterop.GetText(
- JsRuntime,
- _editorElement);
+ _filemanagervisible = false;
+ _message = string.Empty;
+ StateHasChanged();
+ }
+
+ public async Task RefreshRichText()
+ {
+ var interop = new RichTextEditorInterop(JsRuntime);
+ await interop.LoadEditorContent(_editorElement, _content);
+ }
+
+ public async Task RefreshRawHtml()
+ {
+ var interop = new RichTextEditorInterop(JsRuntime);
+ _content = await interop.GetHtml(_editorElement);
+ StateHasChanged();
}
public async Task GetHtml()
{
- return await RichTextEditorInterop.GetHtml(
- JsRuntime,
- _editorElement);
- }
+ // get rich text content
+ var interop = new RichTextEditorInterop(JsRuntime);
+ string content = await interop.GetHtml(_editorElement);
- public async Task GetContent()
- {
- return await RichTextEditorInterop.GetContent(
- JsRuntime,
- _editorElement);
- }
-
- public async Task LoadContent(string content)
- {
- await RichTextEditorInterop.LoadEditorContent(
- JsRuntime,
- _editorElement, content);
- }
-
- public async Task EnableEditor(bool mode)
- {
- await RichTextEditorInterop.EnableEditor(
- JsRuntime,
- _editorElement, mode);
+ if (_original != content)
+ {
+ // rich text content has changed - return it
+ return content;
+ }
+ else
+ {
+ // return raw html content
+ return _content;
+ }
}
public async Task InsertImage()
@@ -105,9 +179,8 @@
var fileid = _fileManager.GetFileId();
if (fileid != -1)
{
- await RichTextEditorInterop.InsertImage(
- JsRuntime,
- _editorElement, ContentUrl(fileid));
+ var interop = new RichTextEditorInterop(JsRuntime);
+ await interop.InsertImage(_editorElement, ContentUrl(fileid));
_filemanagervisible = false;
_message = string.Empty;
}
@@ -121,16 +194,25 @@
_filemanagervisible = true;
_message = string.Empty;
}
-
StateHasChanged();
}
- public void CloseFileManager()
+ // other rich text editor methods which can be used by developers
+ public async Task GetText()
{
- _filemanagervisible = false;
- _message = string.Empty;
-
- StateHasChanged();
+ var interop = new RichTextEditorInterop(JsRuntime);
+ return await interop.GetText(_editorElement);
}
+ public async Task GetContent()
+ {
+ var interop = new RichTextEditorInterop(JsRuntime);
+ return await interop.GetContent(_editorElement);
+ }
+
+ public async Task EnableEditor(bool mode)
+ {
+ var interop = new RichTextEditorInterop(JsRuntime);
+ await interop.EnableEditor(_editorElement, mode);
+ }
}
diff --git a/Oqtane.Client/Modules/Controls/RichTextEditorInterop.cs b/Oqtane.Client/Modules/Controls/RichTextEditorInterop.cs
new file mode 100644
index 00000000..c9b442d4
--- /dev/null
+++ b/Oqtane.Client/Modules/Controls/RichTextEditorInterop.cs
@@ -0,0 +1,124 @@
+using Microsoft.AspNetCore.Components;
+using Microsoft.JSInterop;
+using System.Threading.Tasks;
+
+namespace Oqtane.Modules.Controls
+{
+ public class RichTextEditorInterop
+ {
+ private readonly IJSRuntime _jsRuntime;
+
+ public RichTextEditorInterop(IJSRuntime jsRuntime)
+ {
+ _jsRuntime = jsRuntime;
+ }
+
+ public Task CreateEditor(
+ ElementReference quillElement,
+ ElementReference toolbar,
+ bool readOnly,
+ string placeholder,
+ string theme,
+ string debugLevel)
+ {
+ try
+ {
+ _jsRuntime.InvokeAsync