Personalizable?
@@ -235,7 +224,6 @@
private string _isnavigation;
private string _url;
private string _ispersonalizable;
- private string _mode;
private string _themetype = "-";
private string _layouttype = "-";
private string _containertype = "-";
@@ -290,7 +278,6 @@
_isnavigation = page.IsNavigation.ToString();
_url = page.Url;
_ispersonalizable = page.IsPersonalizable.ToString();
- _mode = (page.EditMode) ? "edit" : "view";
_themetype = page.ThemeType;
if (_themetype == PageState.Site.DefaultThemeType)
{
@@ -333,7 +320,7 @@
_children = new List();
if (_parentid == "-1")
{
- foreach(Page p in PageState.Pages.Where(item => item.ParentId == null))
+ foreach (Page p in PageState.Pages.Where(item => item.ParentId == null))
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
{
@@ -433,6 +420,13 @@
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
+
+ if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList))
+ {
+ AddModuleMessage($"A page with path {_path} already exists for the selected parent page. The page path needs to be unique for the selected parent.", MessageType.Warning);
+ return;
+ }
+
if (_insert != "=")
{
Page child;
@@ -456,7 +450,6 @@
}
page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
page.Url = _url;
- page.EditMode = (_mode == "edit");
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
{
@@ -512,4 +505,9 @@
AddModuleMessage("Error Saving Page", MessageType.Error);
}
}
+
+ private static bool PagePathIsUnique(string pagePath, int siteId, int pageId, List existingPages)
+ {
+ return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.PageId != pageId);
+ }
}
diff --git a/Oqtane.Client/Modules/Admin/Pages/Index.razor b/Oqtane.Client/Modules/Admin/Pages/Index.razor
index b53f3811..02d1d14c 100644
--- a/Oqtane.Client/Modules/Admin/Pages/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Pages/Index.razor
@@ -9,8 +9,8 @@
diff --git a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor
index 96a65b18..73847560 100644
--- a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor
@@ -145,6 +145,7 @@
profile = new Profile();
}
+ profile.SiteId = PageState.Site.SiteId;
profile.Name = _name;
profile.Title = _title;
profile.Description = _description;
diff --git a/Oqtane.Client/Modules/Admin/Profiles/Index.razor b/Oqtane.Client/Modules/Admin/Profiles/Index.razor
index e3cefdaa..36df1731 100644
--- a/Oqtane.Client/Modules/Admin/Profiles/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Profiles/Index.razor
@@ -12,8 +12,8 @@ else
diff --git a/Oqtane.Client/Modules/Admin/RecycleBin/Index.razor b/Oqtane.Client/Modules/Admin/RecycleBin/Index.razor
index d3955307..220f5ffe 100644
--- a/Oqtane.Client/Modules/Admin/RecycleBin/Index.razor
+++ b/Oqtane.Client/Modules/Admin/RecycleBin/Index.razor
@@ -16,8 +16,8 @@
{
-
-
+
+
Name
Deleted By
Deleted On
@@ -42,8 +42,8 @@
{
-
-
+
+
Page
Module
Deleted By
diff --git a/Oqtane.Client/Modules/Admin/Roles/Index.razor b/Oqtane.Client/Modules/Admin/Roles/Index.razor
index 881a9348..a41998d4 100644
--- a/Oqtane.Client/Modules/Admin/Roles/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Roles/Index.razor
@@ -12,9 +12,9 @@ else
diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor
index 9d4e4611..e483465e 100644
--- a/Oqtane.Client/Modules/Admin/Site/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Site/Index.razor
@@ -7,7 +7,7 @@
@inject IThemeService ThemeService
@inject ISettingService SettingService
-@if (_themes != null)
+@if (_initialized)
{
@@ -211,6 +211,7 @@
}
@code {
+ private bool _initialized = false;
private List _themeList;
private List _themes = new List();
private List _layouts = new List();
@@ -318,6 +319,8 @@
_deletedby = site.DeletedBy;
_deletedon = site.DeletedOn;
_isdeleted = site.IsDeleted.ToString();
+
+ _initialized = true;
}
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/Sites/Edit.razor b/Oqtane.Client/Modules/Admin/Sites/Edit.razor
index 00e3d9f9..43599e98 100644
--- a/Oqtane.Client/Modules/Admin/Sites/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Sites/Edit.razor
@@ -6,7 +6,7 @@
@inject IAliasService AliasService
@inject IThemeService ThemeService
-@if (_themes != null)
+@if (_initialized)
{
@@ -106,6 +106,7 @@
}
@code {
+ private bool _initialized = false;
private List _themeList;
private List _themes = new List();
private List _layouts = new List();
@@ -163,6 +164,8 @@
_deletedby = site.DeletedBy;
_deletedon = site.DeletedOn;
_isdeleted = site.IsDeleted.ToString();
+
+ _initialized = true;
}
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/Sites/Index.razor b/Oqtane.Client/Modules/Admin/Sites/Index.razor
index d8b79632..8d82492d 100644
--- a/Oqtane.Client/Modules/Admin/Sites/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Sites/Index.razor
@@ -14,8 +14,8 @@ else
diff --git a/Oqtane.Client/Modules/Admin/Tenants/Index.razor b/Oqtane.Client/Modules/Admin/Tenants/Index.razor
index ead272dc..1ce7c686 100644
--- a/Oqtane.Client/Modules/Admin/Tenants/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Tenants/Index.razor
@@ -11,8 +11,8 @@ else
{
diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor
index 327a7d3a..eda40597 100644
--- a/Oqtane.Client/Modules/Admin/Themes/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor
@@ -16,7 +16,7 @@
@context.Name
@@ -79,7 +79,7 @@
{
ShowProgressIndicator();
var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 3);
+ await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.InstallThemesAsync();
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/Themes/Index.razor b/Oqtane.Client/Modules/Admin/Themes/Index.razor
index d2e6b2e9..29ed1b00 100644
--- a/Oqtane.Client/Modules/Admin/Themes/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor
@@ -15,10 +15,10 @@ else
-
-
- Name
- Version
+
+
+ Name
+ Version
@@ -37,6 +37,7 @@ else
await DownloadTheme(context.ThemeName, context.Version))>Upgrade
}
+
}
@@ -86,7 +87,7 @@ else
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", themename, version);
ShowProgressIndicator();
var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 3);
+ await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.InstallThemesAsync();
}
catch (Exception ex)
@@ -102,7 +103,7 @@ else
{
ShowProgressIndicator();
var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 3);
+ await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.DeleteThemeAsync(Theme.ThemeName);
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
index 5eba7cbd..06611217 100644
--- a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor
@@ -12,7 +12,7 @@
@if (_upgradeavailable)
{
- @("Framework") @_package.Version await Download(Constants.PackageId, Constants.Version))>Upgrade
+ await Download(Constants.PackageId, @_package.Version))>Upgrade To @_package.Version
}
else
{
@@ -26,7 +26,7 @@
Framework:
-
+
@@ -71,7 +71,7 @@
{
ShowProgressIndicator();
var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 3);
+ await interop.RedirectBrowser(NavigateUrl(), 10);
await InstallationService.Upgrade();
}
catch (Exception ex)
@@ -88,7 +88,7 @@
await PackageService.DownloadPackageAsync(packageid, version, "Framework");
ShowProgressIndicator();
var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 3);
+ await interop.RedirectBrowser(NavigateUrl(), 10);
await InstallationService.Upgrade();
}
catch (Exception ex)
diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor
index c413ec91..b19bae1d 100644
--- a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor
+++ b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor
@@ -65,7 +65,8 @@
notification.ParentId = null;
notification.CreatedOn = DateTime.UtcNow;
notification.IsDelivered = false;
- notification.DeliveredOn = null;
+ notification.DeliveredOn = null;
+ notification.SendOn = DateTime.UtcNow;
notification = await NotificationService.AddNotificationAsync(notification);
await logger.LogInformation("Notification Created {Notification}", notification);
NavigationManager.NavigateTo(NavigateUrl());
diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
index 82ff8309..9c718ef1 100644
--- a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
+++ b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor
@@ -32,7 +32,7 @@ else
Password:
-
+
@@ -40,7 +40,7 @@ else
Confirm Password:
-
+
@@ -75,10 +75,12 @@ else
@if (profiles != null && settings != null)
{
-
- @foreach (Profile profile in profiles)
+
+ }
+
Save
Cancel
}
@@ -111,8 +121,8 @@ else
{
-
-
+
+
From
Subject
Received
@@ -241,7 +251,7 @@ else
{
try
{
- if (username != string.Empty && email != string.Empty)
+ if (username != string.Empty && email != string.Empty && ValidateProfiles())
{
if (password == confirm)
{
@@ -261,6 +271,7 @@ else
await UserService.UpdateUserAsync(user);
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
await logger.LogInformation("User Profile Saved");
+ AddModuleMessage("User Profile Updated Successfully", MessageType.Success);
}
else
{
@@ -269,7 +280,7 @@ else
}
else
{
- AddModuleMessage("You Must Provide A Username and Email Address", MessageType.Warning);
+ AddModuleMessage("You Must Provide A Username and Email Address As Well As All Required Profile Information", MessageType.Warning);
}
}
catch (Exception ex)
@@ -279,6 +290,26 @@ else
}
}
+ private bool ValidateProfiles()
+ {
+ bool valid = true;
+ foreach (Profile profile in profiles)
+ {
+ if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
+ {
+ settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
+ }
+ if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole))
+ {
+ if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
+ {
+ valid = false;
+ }
+ }
+ }
+ return valid;
+ }
+
private void Cancel()
{
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
diff --git a/Oqtane.Client/Modules/Admin/UserProfile/View.razor b/Oqtane.Client/Modules/Admin/UserProfile/View.razor
index 2e48fcb1..5621001f 100644
--- a/Oqtane.Client/Modules/Admin/UserProfile/View.razor
+++ b/Oqtane.Client/Modules/Admin/UserProfile/View.razor
@@ -33,7 +33,7 @@
-}
+ }
@if (title == "To")
{
@@ -51,7 +51,7 @@
-}
+ }
@if (title == "From")
{
@@ -62,7 +62,7 @@
-}
+ }
@if (title == "To")
{
@@ -73,7 +73,7 @@
-}
+ }
@@ -191,7 +191,8 @@
notification.ParentId = notificationid;
notification.CreatedOn = DateTime.UtcNow;
notification.IsDelivered = false;
- notification.DeliveredOn = null;
+ notification.DeliveredOn = null;
+ notification.SendOn = DateTime.UtcNow;
notification = await NotificationService.AddNotificationAsync(notification);
await logger.LogInformation("Notification Created {Notification}", notification);
NavigationManager.NavigateTo(NavigateUrl());
diff --git a/Oqtane.Client/Modules/Admin/Users/Add.razor b/Oqtane.Client/Modules/Admin/Users/Add.razor
index b6aa116a..4b15ce82 100644
--- a/Oqtane.Client/Modules/Admin/Users/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Users/Add.razor
@@ -71,10 +71,17 @@
}
- @p.Title:
+ @p.Title
- ProfileChanged(e, p.Name))" />
+ @if (p.IsRequired)
+ {
+ ProfileChanged(e, p.Name))" />
+ }
+ else
+ {
+ ProfileChanged(e, p.Name))" />
+ }
}
@@ -112,11 +119,14 @@
}
}
+ private string GetProfileValue(string SettingName, string DefaultValue)
+ => SettingService.GetSetting(settings, SettingName, DefaultValue);
+
private async Task SaveUser()
{
try
{
- if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty)
+ if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty && ValidateProfiles())
{
if (password == confirm)
{
@@ -149,7 +159,7 @@
}
else
{
- AddModuleMessage("You Must Provide A Username, Password, and Email Address", MessageType.Warning);
+ AddModuleMessage("You Must Provide A Username, Password, Email Address And All Required Profile Information", MessageType.Warning);
}
}
catch (Exception ex)
@@ -159,6 +169,23 @@
}
}
+ private bool ValidateProfiles()
+ {
+ bool valid = true;
+ foreach (Profile profile in profiles)
+ {
+ if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
+ {
+ settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
+ }
+ if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
+ {
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
private void ProfileChanged(ChangeEventArgs e, string SettingName)
{
var value = (string)e.Value;
diff --git a/Oqtane.Client/Modules/Admin/Users/Edit.razor b/Oqtane.Client/Modules/Admin/Users/Edit.razor
index 95449f2d..87a6a387 100644
--- a/Oqtane.Client/Modules/Admin/Users/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Users/Edit.razor
@@ -98,10 +98,17 @@ else
}
- @p.Title:
+ @p.Title
- ProfileChanged(e, p.Name))" />
+ @if (p.IsRequired)
+ {
+ ProfileChanged(e, p.Name))" />
+ }
+ else
+ {
+ ProfileChanged(e, p.Name))" />
+ }
}
@@ -180,7 +187,7 @@ else
{
try
{
- if (username != string.Empty && email != string.Empty)
+ if (username != string.Empty && email != string.Empty && ValidateProfiles())
{
if (password == confirm)
{
@@ -213,7 +220,7 @@ else
}
else
{
- AddModuleMessage("You Must Provide A Username, Password, and Email Address", MessageType.Warning);
+ AddModuleMessage("You Must Provide A Username, Password, Email Address, And All Required Profile Information", MessageType.Warning);
}
}
catch (Exception ex)
@@ -223,6 +230,23 @@ else
}
}
+ private bool ValidateProfiles()
+ {
+ bool valid = true;
+ foreach (Profile profile in profiles)
+ {
+ if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
+ {
+ settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
+ }
+ if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
+ {
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
private void ProfileChanged(ChangeEventArgs e, string SettingName)
{
var value = (string)e.Value;
diff --git a/Oqtane.Client/Modules/Admin/Users/Index.razor b/Oqtane.Client/Modules/Admin/Users/Index.razor
index 4abc278a..682e2d3b 100644
--- a/Oqtane.Client/Modules/Admin/Users/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Users/Index.razor
@@ -20,9 +20,9 @@ else
diff --git a/Oqtane.Client/Modules/Controls/ActionDialog.razor b/Oqtane.Client/Modules/Controls/ActionDialog.razor
index 076f1e9d..0182fe03 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]
+@inherits ModuleControlBase
+
@if (_visible)
{
@@ -40,7 +40,7 @@
@code {
private bool _visible = false;
- private bool _editmode = true;
+ private bool _editmode = false;
private bool _authorized = false;
private string _iconSpan = string.Empty;
@@ -66,7 +66,7 @@
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
+ public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false
[Parameter]
public Action OnClick { get; set; } // required if an Action is specified - executes a method in the calling component
@@ -84,6 +84,7 @@
{
Class = "btn btn-success";
}
+
if (!string.IsNullOrEmpty(EditMode))
{
_editmode = bool.Parse(EditMode);
diff --git a/Oqtane.Client/Modules/Controls/ActionLink.razor b/Oqtane.Client/Modules/Controls/ActionLink.razor
index 39782c08..7de2331a 100644
--- a/Oqtane.Client/Modules/Controls/ActionLink.razor
+++ b/Oqtane.Client/Modules/Controls/ActionLink.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@inject IUserService UserService
@if (_authorized)
@@ -21,7 +20,7 @@
private string _parameters = string.Empty;
private string _classname = "btn btn-primary";
private string _style = string.Empty;
- private bool _editmode = true;
+ private bool _editmode = false;
private bool _authorized = false;
private string _iconSpan = string.Empty;
@@ -47,11 +46,11 @@
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
+ public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false.
[Parameter]
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
-
+
[Parameter]
public bool IconOnly { get; set; } // optional - specifies only icon in link
@@ -90,8 +89,8 @@
if (!string.IsNullOrEmpty(IconName))
{
- _iconSpan = $"
{(IconOnly?"":" ")}";
-
+ _iconSpan = $"
{(IconOnly ? "" : " ")}";
+
}
_url = EditUrl(Action, _parameters);
@@ -123,7 +122,7 @@
{
security = Security.Value;
}
-
+
switch (security)
{
case SecurityAccessLevel.Anonymous:
@@ -143,7 +142,7 @@
break;
}
}
-
+
return authorized;
}
}
diff --git a/Oqtane.Client/Modules/Controls/AuditInfo.razor b/Oqtane.Client/Modules/Controls/AuditInfo.razor
index 7c081d3f..3022c49f 100644
--- a/Oqtane.Client/Modules/Controls/AuditInfo.razor
+++ b/Oqtane.Client/Modules/Controls/AuditInfo.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@if (_text != string.Empty)
{
@@ -8,7 +7,7 @@
}
@code {
-
+
private string _text = string.Empty;
[Parameter]
@@ -22,7 +21,7 @@
[Parameter]
public DateTime ModifiedOn { get; set; }
-
+
[Parameter]
public string DeletedBy { get; set; }
@@ -41,51 +40,51 @@
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
{
_text += "
Created ";
-
+
if (!String.IsNullOrEmpty(CreatedBy))
{
_text += " by " + CreatedBy + " ";
}
-
+
if (CreatedOn != null)
{
_text += " on " + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + " ";
}
-
+
_text += "
";
}
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
{
_text += "
Last modified ";
-
+
if (!String.IsNullOrEmpty(ModifiedBy))
{
_text += " by " + ModifiedBy + " ";
}
-
+
if (ModifiedOn != null)
{
_text += " on " + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + " ";
}
-
+
_text += "
";
}
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
{
_text += "
Deleted ";
-
+
if (!String.IsNullOrEmpty(DeletedBy))
{
_text += " by " + DeletedBy + " ";
}
-
+
if (DeletedOn != null)
{
_text += " on " + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + " ";
}
-
+
_text += "
";
}
}
diff --git a/Oqtane.Client/Modules/Controls/FileManager.razor b/Oqtane.Client/Modules/Controls/FileManager.razor
index bfeb0d57..2dff5419 100644
--- a/Oqtane.Client/Modules/Controls/FileManager.razor
+++ b/Oqtane.Client/Modules/Controls/FileManager.razor
@@ -1,7 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@inject IFolderService FolderService
@inject IFileService FileService
@@ -56,16 +54,16 @@
@if (UploadMultiple)
{
-
+
}
else
{
-
+
}
Upload
- @if (_showfiles && GetFileId() != -1)
+ @if (ShowFiles && GetFileId() != -1)
{
Delete
}
@@ -88,7 +86,6 @@
private string _id;
private List _folders;
private List _files = new List();
- private bool _showfiles = true;
private string _fileinputid = string.Empty;
private string _progressinfoid = string.Empty;
private string _progressbarid = string.Empty;
@@ -134,7 +131,7 @@
if (!string.IsNullOrEmpty(Folder))
{
- _folders = new List {new Folder {FolderId = -1, Name = Folder}};
+ _folders = new List { new Folder { FolderId = -1, Name = Folder } };
FolderId = -1;
}
else
@@ -163,7 +160,7 @@
await GetFiles();
- // create unique id for component
+ // create unique id for component
_guid = Guid.NewGuid().ToString("N");
_fileinputid = _guid + "FileInput";
_progressinfoid = _guid + "ProgressInfo";
@@ -211,7 +208,7 @@
_message = string.Empty;
try
{
- FolderId = int.Parse((string) e.Value);
+ FolderId = int.Parse((string)e.Value);
await GetFiles();
FileId = -1;
_image = string.Empty;
@@ -227,7 +224,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();
@@ -244,8 +241,8 @@
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 = " ";
}
}
diff --git a/Oqtane.Client/Modules/Controls/ModuleMessage.razor b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
index 5e00cb76..ad5957fa 100644
--- a/Oqtane.Client/Modules/Controls/ModuleMessage.razor
+++ b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
@@ -1,10 +1,16 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
+@inject NavigationManager NavigationManager
@if (!string.IsNullOrEmpty(_message))
{
- @_message
+
+ @_message
+ @if (Type == MessageType.Error && UserSecurity.IsAuthorized(PageState.User, Constants.HostRole))
+ {
+ @((MarkupString)" ")View Details
+ }
+
}
@@ -52,7 +58,7 @@
classname = "alert alert-danger";
break;
}
-
+
return classname;
}
}
diff --git a/Oqtane.Client/Modules/Controls/Pager.razor b/Oqtane.Client/Modules/Controls/Pager.razor
index ff7e13ee..5f3ae713 100644
--- a/Oqtane.Client/Modules/Controls/Pager.razor
+++ b/Oqtane.Client/Modules/Controls/Pager.razor
@@ -1,41 +1,39 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
-@typeparam TableItem
-
+@inherits ModuleControlBase
+@typeparam TableItem
- @if(Format == "Table")
+ @if (Format == "Table")
{
-
-
- @Header
-
-
+
+
+ @Header
+
+
+ @foreach (var item in ItemList)
+ {
+ @Row(item)
+ @if (Detail != null)
+ {
+ @Detail(item)
+ }
+ }
+
+
+ }
+ @if (Format == "Grid")
+ {
+
+
@Header
@foreach (var item in ItemList)
{
-
@Row(item)
+
@Row(item)
@if (Detail != null)
{
-
@Detail(item)
+
@Detail(item)
}
}
-
-
- }
- @if(Format == "Grid")
- {
-
-
@Header
- @foreach (var item in ItemList)
- {
-
@Row(item)
- @if (Detail != null)
- {
-
@Detail(item)
- }
- }
-
+
}
@if (_page > _maxPages)
@@ -44,7 +42,7 @@
}
@if (_endPage > 1)
{
-
NavigateToPage("previous"))>
+
NavigateToPage("previous"))>
@for (int i = _startPage; i <= _endPage; i++)
{
var pager = i;
@@ -105,7 +103,7 @@
{
Format = "Table";
}
-
+
if (string.IsNullOrEmpty(Class))
{
if (Format == "Table")
@@ -117,7 +115,7 @@
Class = "container";
}
}
-
+
if (string.IsNullOrEmpty(PageSize))
{
_maxItems = 10;
@@ -126,7 +124,7 @@
{
_maxItems = int.Parse(PageSize);
}
-
+
if (string.IsNullOrEmpty(DisplayPages))
{
_maxPages = 5;
@@ -149,7 +147,7 @@
{
ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems);
_page = currentPage;
-
+
StateHasChanged();
}
@@ -174,7 +172,7 @@
{
_endPage = _pages;
}
-
+
StateHasChanged();
}
else if (direction == "back")
@@ -208,7 +206,7 @@
_page -= 1;
}
}
-
+
UpdateList(_page);
}
}
diff --git a/Oqtane.Client/Modules/Controls/PermissionGrid.razor b/Oqtane.Client/Modules/Controls/PermissionGrid.razor
index 90954bbe..630a652b 100644
--- a/Oqtane.Client/Modules/Controls/PermissionGrid.razor
+++ b/Oqtane.Client/Modules/Controls/PermissionGrid.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@inject IRoleService RoleService
@inject IUserService UserService
@@ -10,10 +9,10 @@
- Role
+ Role
@foreach (PermissionString permission in _permissions)
{
- @permission.PermissionName
+ @permission.PermissionName
}
@foreach (Role role in _roles)
@@ -36,10 +35,10 @@
- User
+ User
@foreach (PermissionString permission in _permissions)
{
- @permission.PermissionName
+ @permission.PermissionName
}
@@ -52,7 +51,7 @@
@foreach (PermissionString permission in _permissions)
{
var p = permission;
-
+
}
@@ -64,9 +63,10 @@
@@ -106,13 +106,13 @@
_roles.Insert(0, new Role { Name = Constants.AllUsersRole });
_permissions = new List();
-
+
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
// initialize with admin role
_permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = Constants.AdminRole });
}
-
+
if (!string.IsNullOrEmpty(Permissions))
{
// populate permissions
@@ -122,7 +122,7 @@
{
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
}
-
+
if (permissionstring.Permissions.Contains("["))
{
foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries))
@@ -182,7 +182,7 @@
_message = "Username Does Not Exist";
}
}
-
+
_username = string.Empty;
}
@@ -208,7 +208,7 @@
case null:
break; // permission not specified
}
-
+
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray());
}
}
diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
index 28888050..5eeb17a2 100644
--- a/Oqtane.Client/Modules/Controls/RichTextEditor.razor
+++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@@ -108,12 +107,12 @@
public string DebugLevel { get; set; } = "info";
public override List
Resources => new List()
- {
+{
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill1.3.6.min.js" },
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-blot-formatter.min.js" },
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" }
};
-
+
protected override void OnInitialized()
{
_content = Content; // raw HTML
diff --git a/Oqtane.Client/Modules/Controls/Section.razor b/Oqtane.Client/Modules/Controls/Section.razor
index f21a7e17..02fab969 100644
--- a/Oqtane.Client/Modules/Controls/Section.razor
+++ b/Oqtane.Client/Modules/Controls/Section.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
diff --git a/Oqtane.Client/Modules/Controls/TabPanel.razor b/Oqtane.Client/Modules/Controls/TabPanel.razor
index bd89ab59..9f04dc5f 100644
--- a/Oqtane.Client/Modules/Controls/TabPanel.razor
+++ b/Oqtane.Client/Modules/Controls/TabPanel.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
@if (Name == Parent.ActiveTab)
{
diff --git a/Oqtane.Client/Modules/Controls/TabStrip.razor b/Oqtane.Client/Modules/Controls/TabStrip.razor
index ee6a6c82..cc58376f 100644
--- a/Oqtane.Client/Modules/Controls/TabStrip.razor
+++ b/Oqtane.Client/Modules/Controls/TabStrip.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls
-@inherits ModuleBase
-@attribute [OqtaneIgnore]
+@inherits ModuleControlBase
diff --git a/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor b/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor
index 3c056d87..845db70b 100644
--- a/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor
+++ b/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor
@@ -1,4 +1,5 @@
@namespace Oqtane.Modules.Controls
+@inherits ModuleControlBase
@@ -38,7 +39,7 @@
_value = true;
break;
}
-
+
SetImage();
OnChange(_value);
}
diff --git a/Oqtane.Client/Modules/HtmlText/Index.razor b/Oqtane.Client/Modules/HtmlText/Index.razor
index 8160c19a..36e7c35c 100644
--- a/Oqtane.Client/Modules/HtmlText/Index.razor
+++ b/Oqtane.Client/Modules/HtmlText/Index.razor
@@ -7,7 +7,7 @@
@if (PageState.EditMode)
{
-
+
}
@code {
diff --git a/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs b/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
index 51ab7887..1e9d42ab 100644
--- a/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
+++ b/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
@@ -21,23 +21,23 @@ namespace Oqtane.Modules.HtmlText.Services
public async Task
GetHtmlTextAsync(int moduleId)
{
- var htmltext = await GetJsonAsync>($"{ApiUrl}/{moduleId}?entityid={moduleId}");
+ var htmltext = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{ApiUrl}/{moduleId}", moduleId));
return htmltext.FirstOrDefault();
}
public async Task AddHtmlTextAsync(HtmlTextInfo htmlText)
{
- await PostJsonAsync($"{ApiUrl}?entityid={htmlText.ModuleId}", htmlText);
+ await PostJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}", htmlText.ModuleId), htmlText);
}
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmlText)
{
- await PutJsonAsync($"{ApiUrl}/{htmlText.HtmlTextId}?entityid={htmlText.ModuleId}", htmlText);
+ await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", htmlText.ModuleId), htmlText);
}
public async Task DeleteHtmlTextAsync(int moduleId)
{
- await DeleteAsync($"{ApiUrl}/{moduleId}?entityid={moduleId}");
+ await DeleteAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{moduleId}", moduleId));
}
}
}
diff --git a/Oqtane.Client/Modules/ModuleBase.cs b/Oqtane.Client/Modules/ModuleBase.cs
index f36a04ae..633caed5 100644
--- a/Oqtane.Client/Modules/ModuleBase.cs
+++ b/Oqtane.Client/Modules/ModuleBase.cs
@@ -17,7 +17,7 @@ namespace Oqtane.Modules
private Logger _logger;
protected Logger logger => _logger ?? (_logger = new Logger(this));
-
+
[Inject]
protected ILogService LoggingService { get; set; }
@@ -30,7 +30,7 @@ namespace Oqtane.Modules
[CascadingParameter]
protected Module ModuleState { get; set; }
- [CascadingParameter]
+ [CascadingParameter]
protected ModuleInstance ModuleInstance { get; set; }
// optional interface properties
@@ -62,7 +62,7 @@ namespace Oqtane.Modules
}
}
}
-
+
// path method
public string ModulePath()
@@ -116,6 +116,54 @@ namespace Oqtane.Modules
return Utilities.ContentUrl(PageState.Alias, fileid);
}
+ public virtual Dictionary GetUrlParameters(string parametersTemplate = "")
+ {
+ var urlParameters = new Dictionary();
+ string[] templateSegments;
+ var parameters = PageState.UrlParameters.Split('/', StringSplitOptions.RemoveEmptyEntries);
+ var parameterId = 0;
+
+ if (string.IsNullOrEmpty(parametersTemplate))
+ {
+ for (int i = 0; i < parameters.Length; i++)
+ {
+ urlParameters.TryAdd("parameter" + i, parameters[i]);
+ }
+ }
+ else
+ {
+ templateSegments = parametersTemplate.Split('/', StringSplitOptions.RemoveEmptyEntries);
+
+ if (parameters.Length == templateSegments.Length)
+ {
+ for (int i = 0; i < parameters.Length; i++)
+ {
+ if (parameters.Length > i)
+ {
+ if (templateSegments[i] == parameters[i])
+ {
+ urlParameters.TryAdd("parameter" + parameterId, parameters[i]);
+ parameterId++;
+ }
+ else if (templateSegments[i].StartsWith("{") && templateSegments[i].EndsWith("}"))
+ {
+ var key = templateSegments[i].Replace("{", "");
+ key = key.Replace("}", "");
+ urlParameters.TryAdd(key, parameters[i]);
+ }
+ else
+ {
+ i = parameters.Length;
+ urlParameters.Clear();
+ }
+ }
+ }
+ }
+ }
+
+ return urlParameters;
+ }
+
// user feedback methods
public void AddModuleMessage(string message, MessageType type)
{
@@ -154,12 +202,15 @@ namespace Oqtane.Modules
case "add":
logFunction = LogFunction.Create;
break;
+
case "edit":
logFunction = LogFunction.Update;
break;
+
case "delete":
logFunction = LogFunction.Delete;
break;
+
default:
logFunction = LogFunction.Read;
break;
@@ -241,4 +292,4 @@ namespace Oqtane.Modules
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Oqtane.Client/Modules/ModuleControlBase.cs b/Oqtane.Client/Modules/ModuleControlBase.cs
new file mode 100644
index 00000000..d245d97c
--- /dev/null
+++ b/Oqtane.Client/Modules/ModuleControlBase.cs
@@ -0,0 +1,10 @@
+using Oqtane.Shared;
+
+namespace Oqtane.Modules
+{
+ [OqtaneIgnore]
+ public abstract class ModuleControlBase : ModuleBase
+ {
+
+ }
+}
diff --git a/Oqtane.Client/Oqtane.Client.csproj b/Oqtane.Client/Oqtane.Client.csproj
index a712520f..f0c021ff 100644
--- a/Oqtane.Client/Oqtane.Client.csproj
+++ b/Oqtane.Client/Oqtane.Client.csproj
@@ -6,7 +6,7 @@
7.3
3.0
Debug;Release
- 1.0.0
+ 1.0.3
Oqtane
Shaun Walker
.NET Foundation
@@ -15,7 +15,7 @@
https://www.oqtane.org
https://github.com/oqtane
Git
- Not for production use.
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
Oqtane
true
diff --git a/Oqtane.Client/Services/ServiceBase.cs b/Oqtane.Client/Services/ServiceBase.cs
index 091709f2..2e891ca3 100644
--- a/Oqtane.Client/Services/ServiceBase.cs
+++ b/Oqtane.Client/Services/ServiceBase.cs
@@ -170,6 +170,19 @@ namespace Oqtane.Services
// can be used to override the default alias
public Alias Alias { get; set; }
+ // add entityid parameter to url for custom authorization policy
+ public string CreateAuthorizationPolicyUrl(string url, int entityId)
+ {
+ if (url.Contains("?"))
+ {
+ return url + "&entityid=" + entityId.ToString();
+ }
+ else
+ {
+ return url + "?entityid=" + entityId.ToString();
+ }
+ }
+
[Obsolete("This method is obsolete. Use CreateApiUrl(Alias alias, string serviceName) instead.", false)]
public string CreateApiUrl(Alias alias, string absoluteUri, string serviceName)
{
diff --git a/Oqtane.Client/Services/ThemeService.cs b/Oqtane.Client/Services/ThemeService.cs
index 3e6a3690..bd349b93 100644
--- a/Oqtane.Client/Services/ThemeService.cs
+++ b/Oqtane.Client/Services/ThemeService.cs
@@ -1,28 +1,26 @@
-using Oqtane.Models;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
-using System.Reflection;
-using System;
+using Oqtane.Models;
using Oqtane.Shared;
namespace Oqtane.Services
{
public class ThemeService : ServiceBase, IThemeService
{
- private readonly HttpClient _http;
+ private readonly SiteState _siteState;
- public ThemeService(HttpClient http) : base(http)
+ public ThemeService(HttpClient http, SiteState siteState) : base(http)
{
- _http = http;
+ _siteState = siteState;
}
- private string Apiurl => CreateApiUrl("Theme");
+ private string ApiUrl => CreateApiUrl(_siteState.Alias, "Theme");
public async Task> GetThemesAsync()
{
- List themes = await GetJsonAsync>(Apiurl);
+ List themes = await GetJsonAsync>(ApiUrl);
return themes.OrderBy(item => item.Name).ToList();
}
@@ -45,12 +43,12 @@ namespace Oqtane.Services
public async Task InstallThemesAsync()
{
- await GetJsonAsync>($"{Apiurl}/install");
+ await GetJsonAsync>($"{ApiUrl}/install");
}
public async Task DeleteThemeAsync(string themeName)
{
- await DeleteAsync($"{Apiurl}/{themeName}");
+ await DeleteAsync($"{ApiUrl}/{themeName}");
}
}
}
diff --git a/Oqtane.Client/Themes/BlazorTheme/Default.razor b/Oqtane.Client/Themes/BlazorTheme/Default.razor
index 81c7122a..bf62b5c5 100644
--- a/Oqtane.Client/Themes/BlazorTheme/Default.razor
+++ b/Oqtane.Client/Themes/BlazorTheme/Default.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.BlazorTheme
@inherits ThemeBase
-@implements IThemeControl
@@ -31,11 +30,11 @@
public override List
Resources => new List()
{
- new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css", Integrity = "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css", Integrity = "sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk", CrossOrigin = "anonymous" },
new Resource { ResourceType = ResourceType.Stylesheet, Url = ThemePath() + "Theme.css" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://code.jquery.com/jquery-3.3.1.slim.min.js", Integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo", CrossOrigin = "anonymous" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js", Integrity = "sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1", CrossOrigin = "anonymous" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js", Integrity = "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM", CrossOrigin = "anonymous" }
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://code.jquery.com/jquery-3.5.1.slim.min.js", Integrity = "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js", Integrity = "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js", Integrity = "sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI", CrossOrigin = "anonymous" }
};
}
\ No newline at end of file
diff --git a/Oqtane.Client/Themes/ContainerBase.cs b/Oqtane.Client/Themes/ContainerBase.cs
index 86cf85bd..a35c1478 100644
--- a/Oqtane.Client/Themes/ContainerBase.cs
+++ b/Oqtane.Client/Themes/ContainerBase.cs
@@ -7,5 +7,6 @@ namespace Oqtane.Themes
{
[CascadingParameter]
protected Module ModuleState { get; set; }
+
}
}
diff --git a/Oqtane.Client/Themes/Controls/Breadcrumbs.razor b/Oqtane.Client/Themes/Controls/Breadcrumbs.razor
index 310132f5..ef902a1c 100644
--- a/Oqtane.Client/Themes/Controls/Breadcrumbs.razor
+++ b/Oqtane.Client/Themes/Controls/Breadcrumbs.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
-@attribute [OqtaneIgnore]
@if (BreadCrumbPages.Any())
{
diff --git a/Oqtane.Client/Themes/Controls/ControlPanel.razor b/Oqtane.Client/Themes/Controls/ControlPanel.razor
index 5c24be76..24e90513 100644
--- a/Oqtane.Client/Themes/Controls/ControlPanel.razor
+++ b/Oqtane.Client/Themes/Controls/ControlPanel.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
-@attribute [OqtaneIgnore]
@inject NavigationManager NavigationManager
@inject IUserService UserService
@inject IModuleDefinitionService ModuleDefinitionService
@@ -128,7 +127,10 @@
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
{
- @moduledefinition.Name
+ if (moduledefinition.Runtimes == "" || moduledefinition.Runtimes.Contains(PageState.Runtime.ToString()))
+ {
+ @moduledefinition.Name
+ }
}
}
@@ -197,26 +199,17 @@
@if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions) || (PageState.Page.IsPersonalizable && PageState.User != null))
{
- @if (PageState.Page.EditMode)
+ if (PageState.EditMode)
{
-
+ await ToggleEditMode(PageState.EditMode))">
}
else
{
- if (PageState.EditMode)
- {
- await ToggleEditMode(PageState.EditMode))">
-
-
- }
- else
- {
- await ToggleEditMode(PageState.EditMode))">
-
-
- }
+ await ToggleEditMode(PageState.EditMode))">
+
+
}
}
diff --git a/Oqtane.Client/Themes/Controls/Login.razor b/Oqtane.Client/Themes/Controls/Login.razor
index ffa46d15..84ef808e 100644
--- a/Oqtane.Client/Themes/Controls/Login.razor
+++ b/Oqtane.Client/Themes/Controls/Login.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.Controls
@inherits LoginBase
-@attribute [OqtaneIgnore]
diff --git a/Oqtane.Client/Themes/Controls/Logo.razor b/Oqtane.Client/Themes/Controls/Logo.razor
index e189b753..1fa496fb 100644
--- a/Oqtane.Client/Themes/Controls/Logo.razor
+++ b/Oqtane.Client/Themes/Controls/Logo.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
-@attribute [OqtaneIgnore]
@if (PageState.Site.LogoFileId != null)
{
diff --git a/Oqtane.Client/Themes/Controls/MenuHorizontal.Razor b/Oqtane.Client/Themes/Controls/MenuHorizontal.Razor
index 58159b13..4400ad71 100644
--- a/Oqtane.Client/Themes/Controls/MenuHorizontal.Razor
+++ b/Oqtane.Client/Themes/Controls/MenuHorizontal.Razor
@@ -1,6 +1,6 @@
@namespace Oqtane.Themes.Controls
@inherits MenuBase
-@attribute [OqtaneIgnore]
+
@if (MenuPages.Any())
{
-}
\ No newline at end of file
+}
diff --git a/Oqtane.Client/Themes/Controls/ModuleActionsBase.cs b/Oqtane.Client/Themes/Controls/ModuleActionsBase.cs
index 58a7e3c4..a6a3f2ba 100644
--- a/Oqtane.Client/Themes/Controls/ModuleActionsBase.cs
+++ b/Oqtane.Client/Themes/Controls/ModuleActionsBase.cs
@@ -19,7 +19,7 @@ namespace Oqtane.Themes.Controls
[Inject] public IPageModuleService PageModuleService { get; set; }
[Inject] public IModuleService ModuleService { get; set; }
- protected List Actions;
+ public List Actions;
protected override void OnParametersSet()
{
@@ -31,51 +31,52 @@ namespace Oqtane.Themes.Controls
var actionList = new List();
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions))
{
- actionList.Add(new ActionViewModel {Name = "Manage Settings", Action = async (u, m) => await Settings(u, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.Cog, Name = "Manage Settings", Action = async (u, m) => await Settings(u, m)});
+
if (UserSecurity.GetPermissionStrings(ModuleState.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(Constants.AllUsersRole))
{
- actionList.Add(new ActionViewModel { Name = "Unpublish Module", Action = async (s, m) => await Unpublish(s, m) });
+ actionList.Add(new ActionViewModel {Icon=Icons.CircleX, Name = "Unpublish Module", Action = async (s, m) => await Unpublish(s, m) });
}
else
{
- actionList.Add(new ActionViewModel { Name = "Publish Module", Action = async (s, m) => await Publish(s, m) });
+ actionList.Add(new ActionViewModel {Icon=Icons.CircleCheck, Name = "Publish Module", Action = async (s, m) => await Publish(s, m) });
}
- actionList.Add(new ActionViewModel { Name = "Delete Module", Action = async (u, m) => await DeleteModule(u, m) });
+ actionList.Add(new ActionViewModel {Icon=Icons.Trash, Name = "Delete Module", Action = async (u, m) => await DeleteModule(u, m) });
if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerManagerType != "")
{
actionList.Add(new ActionViewModel { Name = "" });
- actionList.Add(new ActionViewModel {Name = "Import Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Import")});
- actionList.Add(new ActionViewModel {Name = "Export Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Export")});
+ actionList.Add(new ActionViewModel {Icon=Icons.CloudUpload, Name = "Import Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Import")});
+ actionList.Add(new ActionViewModel {Icon = Icons.CloudDownload, Name = "Export Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Export")});
}
actionList.Add(new ActionViewModel {Name = ""});
if (ModuleState.PaneModuleIndex > 0)
{
- actionList.Add(new ActionViewModel {Name = "Move To Top", Action = async (s, m) => await MoveTop(s, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.DataTransferUpload ,Name = "Move To Top", Action = async (s, m) => await MoveTop(s, m)});
}
if (ModuleState.PaneModuleIndex > 0)
{
- actionList.Add(new ActionViewModel {Name = "Move Up", Action = async (s, m) => await MoveUp(s, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.ArrowThickTop, Name = "Move Up", Action = async (s, m) => await MoveUp(s, m)});
}
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
{
- actionList.Add(new ActionViewModel {Name = "Move Down", Action = async (s, m) => await MoveDown(s, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.ArrowThickBottom, Name = "Move Down", Action = async (s, m) => await MoveDown(s, m)});
}
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
{
- actionList.Add(new ActionViewModel {Name = "Move To Bottom", Action = async (s, m) => await MoveBottom(s, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.DataTransferDownload, Name = "Move To Bottom", Action = async (s, m) => await MoveBottom(s, m)});
}
foreach (string pane in PageState.Page.Panes)
{
if (pane != ModuleState.Pane)
{
- actionList.Add(new ActionViewModel {Name = "Move To " + pane + " Pane", Action = async (s, m) => await MoveToPane(s, pane, m)});
+ actionList.Add(new ActionViewModel {Icon = Icons.AccountLogin, Name = "Move To " + pane + " Pane", Action = async (s, m) => await MoveToPane(s, pane, m)});
}
}
}
@@ -202,8 +203,8 @@ namespace Oqtane.Themes.Controls
public class ActionViewModel
{
+ public string Icon { get; set; }
public string Name { set; get; }
-
public Func> Action { set; get; }
}
}
diff --git a/Oqtane.Client/Themes/Controls/UserProfile.razor b/Oqtane.Client/Themes/Controls/UserProfile.razor
index 2f6f0975..a5d95aeb 100644
--- a/Oqtane.Client/Themes/Controls/UserProfile.razor
+++ b/Oqtane.Client/Themes/Controls/UserProfile.razor
@@ -1,6 +1,6 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
-@attribute [OqtaneIgnore]
+
@inject NavigationManager NavigationManager
diff --git a/Oqtane.Client/Themes/IContainerControl.cs b/Oqtane.Client/Themes/IContainerControl.cs
index bfd77a9c..072dd70e 100644
--- a/Oqtane.Client/Themes/IContainerControl.cs
+++ b/Oqtane.Client/Themes/IContainerControl.cs
@@ -2,7 +2,6 @@
{
public interface IContainerControl
{
- string Name { get; } // friendly name for a container
- string Thumbnail { get; } // screen shot of a container - assumed to be in the ThemePath() folder
+
}
}
diff --git a/Oqtane.Client/Themes/ILayoutControl.cs b/Oqtane.Client/Themes/ILayoutControl.cs
index 69f9cfd1..4aaa961a 100644
--- a/Oqtane.Client/Themes/ILayoutControl.cs
+++ b/Oqtane.Client/Themes/ILayoutControl.cs
@@ -2,9 +2,6 @@
{
public interface ILayoutControl
{
- string Name { get; } // friendly name for a layout
- string Thumbnail { get; } // screen shot of a layout - assumed to be in the ThemePath() folder
- string Panes { get; } // identifies all panes in a theme ( delimited by "," or ";" )
}
}
diff --git a/Oqtane.Client/Themes/OqtaneTheme/Default.razor b/Oqtane.Client/Themes/OqtaneTheme/Default.razor
index 5d4e4df9..1878ed09 100644
--- a/Oqtane.Client/Themes/OqtaneTheme/Default.razor
+++ b/Oqtane.Client/Themes/OqtaneTheme/Default.razor
@@ -1,6 +1,5 @@
@namespace Oqtane.Themes.OqtaneTheme
@inherits ThemeBase
-@implements IThemeControl
@@ -24,10 +23,10 @@
public override List Resources => new List()
{
- new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/cyborg/bootstrap.min.css", Integrity = "sha384-l7xaoY0cJM4h9xh1RfazbgJVUZvdtyLWPueWNtLAphf/UbBgOVzqbOTogxPwYLHM", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://stackpath.bootstrapcdn.com/bootswatch/4.5.0/cyborg/bootstrap.min.css", Integrity = "sha384-GKugkVcT8wqoh3M8z1lqHbU+g6j498/ZT/zuXbepz7Dc09/otQZxTimkEMTkRWHP", CrossOrigin = "anonymous" },
new Resource { ResourceType = ResourceType.Stylesheet, Url = ThemePath() + "Theme.css" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://code.jquery.com/jquery-3.3.1.slim.min.js", Integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo", CrossOrigin = "anonymous" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js", Integrity = "sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1", CrossOrigin = "anonymous" },
- new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js", Integrity = "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM", CrossOrigin = "anonymous" }
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://code.jquery.com/jquery-3.5.1.slim.min.js", Integrity = "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js", Integrity = "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo", CrossOrigin = "anonymous" },
+ new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js", Integrity = "sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI", CrossOrigin = "anonymous" }
};
}
diff --git a/Oqtane.Client/Themes/ThemeBase.cs b/Oqtane.Client/Themes/ThemeBase.cs
index d4400ec1..32b9c564 100644
--- a/Oqtane.Client/Themes/ThemeBase.cs
+++ b/Oqtane.Client/Themes/ThemeBase.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace Oqtane.Themes
{
- public abstract class ThemeBase : ComponentBase
+ public abstract class ThemeBase : ComponentBase, IThemeControl
{
[Inject]
protected IJSRuntime JSRuntime { get; set; }
diff --git a/Oqtane.Client/Themes/ThemeControlBase.cs b/Oqtane.Client/Themes/ThemeControlBase.cs
index 8cb6e763..ca60120b 100644
--- a/Oqtane.Client/Themes/ThemeControlBase.cs
+++ b/Oqtane.Client/Themes/ThemeControlBase.cs
@@ -1,5 +1,8 @@
-namespace Oqtane.Themes
+using Oqtane.Shared;
+
+namespace Oqtane.Themes
{
+ [OqtaneIgnore]
public abstract class ThemeControlBase : ThemeBase
{
diff --git a/Oqtane.Client/UI/ContainerBuilder.razor b/Oqtane.Client/UI/ContainerBuilder.razor
index 1273f784..5a164309 100644
--- a/Oqtane.Client/UI/ContainerBuilder.razor
+++ b/Oqtane.Client/UI/ContainerBuilder.razor
@@ -19,7 +19,7 @@
{
_moduleState = Module; // passed in from Pane component
string container = _moduleState.ContainerType;
- if (PageState.ModuleId != -1 && PageState.Action != "" && _moduleState.UseAdminContainer)
+ if (PageState.ModuleId != -1 && _moduleState.UseAdminContainer)
{
container = Constants.DefaultAdminContainer;
}
diff --git a/Oqtane.Client/UI/PageState.cs b/Oqtane.Client/UI/PageState.cs
index a2678802..cde1779b 100644
--- a/Oqtane.Client/UI/PageState.cs
+++ b/Oqtane.Client/UI/PageState.cs
@@ -14,10 +14,11 @@ namespace Oqtane.UI
public List Modules { get; set; }
public Uri Uri { get; set; }
public Dictionary QueryString { get; set; }
+ public string UrlParameters { get; set; }
public int ModuleId { get; set; }
public string Action { get; set; }
public bool EditMode { get; set; }
public DateTime LastSyncDate { get; set; }
public Runtime Runtime { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/Oqtane.Client/UI/Pane.razor b/Oqtane.Client/UI/Pane.razor
index 48f4d0ce..669e0ce4 100644
--- a/Oqtane.Client/UI/Pane.razor
+++ b/Oqtane.Client/UI/Pane.razor
@@ -1,4 +1,5 @@
-@namespace Oqtane.UI
+@using Microsoft.AspNetCore.Components.Rendering
+@namespace Oqtane.UI
@inject IUserService UserService
@inject IModuleService ModuleService
@inject IModuleDefinitionService ModuleDefinitionService
@@ -25,7 +26,7 @@
protected override void OnParametersSet()
{
- if (PageState.EditMode && !PageState.Page.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
+ if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
{
_paneadminborder = "app-pane-admin-border";
_panetitle = "" + Name + " Pane
";
@@ -38,12 +39,12 @@
DynamicComponent = builder =>
{
- if (PageState.ModuleId != -1 && PageState.Action != "")
+ if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
{
if (Name.ToLower() == Constants.AdminPane.ToLower())
{
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
- if (module != null)
+ if (module != null && !module.IsDeleted)
{
var typename = module.ModuleType;
// check for core module actions component
@@ -51,7 +52,7 @@
{
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
}
-
+
var moduleType = Type.GetType(typename);
if (moduleType != null)
{
@@ -88,10 +89,7 @@
{
module.Title = module.ControlTitle;
}
-
- builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
- builder.AddAttribute(1, "Module", module);
- builder.CloseComponent();
+ CreateComponent(builder, module);
}
}
else
@@ -106,14 +104,12 @@
if (PageState.ModuleId != -1)
{
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
- if (module != null && module.Pane.ToLower() == Name.ToLower())
+ if (module != null && module.Pane.ToLower() == Name.ToLower() && !module.IsDeleted)
{
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
- builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
- builder.AddAttribute(1, "Module", module);
- builder.CloseComponent();
+ CreateComponent(builder, module);
}
}
}
@@ -124,14 +120,19 @@
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
- builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
- builder.AddAttribute(1, "Module", module);
- builder.SetKey(module.PageModuleId);
- builder.CloseComponent();
+ CreateComponent(builder, module);
}
}
}
}
};
}
+
+ private void CreateComponent(RenderTreeBuilder builder, Module module)
+ {
+ builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
+ builder.AddAttribute(1, "Module", module);
+ builder.SetKey(module.PageModuleId);
+ builder.CloseComponent();
+ }
}
diff --git a/Oqtane.Client/UI/SiteRouter.razor b/Oqtane.Client/UI/SiteRouter.razor
index 662202a7..5c7f6cd5 100644
--- a/Oqtane.Client/UI/SiteRouter.razor
+++ b/Oqtane.Client/UI/SiteRouter.razor
@@ -76,7 +76,8 @@
User user = null;
List modules;
var moduleid = -1;
- var action = "";
+ var action = string.Empty;
+ var urlparameters = string.Empty;
var editmode = false;
var reload = Reload.None;
var lastsyncdate = DateTime.UtcNow;
@@ -179,21 +180,60 @@
// extract admin route elements from path
var segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
int result;
- // check if path has moduleid and action specification ie. pagename/moduleid/action/
- if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
+
+ int modIdPos = 0;
+ int actionPos = 0;
+ int urlParametersPos = 0;
+
+ for (int i = 0; i < segments.Length; i++)
{
- action = segments[segments.Length - 1];
- moduleid = result;
- path = path.Replace(moduleid.ToString() + "/" + action + "/", "");
- }
- else
- {
- // check if path has moduleid specification ie. pagename/moduleid/
- if (segments.Length >= 1 && int.TryParse(segments[segments.Length - 1], out result))
+
+ if (segments[i] == Constants.UrlParametersDelimiter)
{
- moduleid = result;
- path = path.Replace(moduleid.ToString() + "/", "");
+ urlParametersPos = i + 1;
}
+
+ if (i >= urlParametersPos && urlParametersPos != 0)
+ {
+ urlparameters += "/" + segments[i];
+ }
+
+ if (segments[i] == Constants.ModuleDelimiter)
+ {
+ modIdPos = i + 1;
+ actionPos = modIdPos + 1;
+ if (actionPos > segments.Length - 1)
+ {
+ action = Constants.DefaultAction;
+ }
+ else
+ {
+ action = segments[actionPos];
+
+ }
+ }
+
+ }
+
+ // check if path has moduleid and action specification ie. pagename/moduleid/action/
+ if (modIdPos > 0)
+ {
+ int.TryParse(segments[modIdPos], out result);
+ moduleid = result;
+ if (actionPos > segments.Length - 1)
+ {
+ path = path.Replace(segments[modIdPos - 1] + "/" + segments[modIdPos] + "/", "");
+ }
+ else
+ {
+ path = path.Replace(segments[modIdPos - 1] + "/" + segments[modIdPos] + "/" + segments[actionPos] + "/", "");
+ }
+
+ }
+
+ if (urlParametersPos > 0)
+ {
+ path = path.Replace(segments[urlParametersPos - 1] + urlparameters + "/", "");
}
// remove trailing slash so it can be used as a key for Pages
@@ -220,17 +260,14 @@
{
page = pages.Where(item => item.Path == path).FirstOrDefault();
reload = Reload.Page;
- if (page != null)
- {
- editmode = page.EditMode;
- }
+ editmode = false;
}
if (page != null)
{
if (PageState == null)
{
- editmode = page.EditMode;
+ editmode = false;
}
// check if user is authorized to view page
@@ -263,6 +300,7 @@
Modules = modules,
Uri = new Uri(_absoluteUri, UriKind.Absolute),
QueryString = querystring,
+ UrlParameters = urlparameters,
ModuleId = moduleid,
Action = action,
EditMode = editmode,
@@ -360,6 +398,13 @@
string panes = "";
Type themetype = Type.GetType(page.ThemeType);
+ if (themetype == null)
+ {
+ // fallback
+ page.ThemeType = Constants.DefaultTheme;
+ page.LayoutType = Constants.DefaultLayout;
+ themetype = Type.GetType(Constants.DefaultTheme);
+ }
if (themetype != null)
{
var themeobject = Activator.CreateInstance(themetype) as IThemeControl;
@@ -375,7 +420,7 @@
Type layouttype = Type.GetType(page.LayoutType);
if (layouttype != null)
{
- var layoutobject = Activator.CreateInstance(layouttype) as ILayoutControl;
+ var layoutobject = Activator.CreateInstance(layouttype) as IThemeControl;
if (layoutobject != null)
{
panes = layoutobject.Panes;
@@ -401,7 +446,7 @@
if (module.PageId == page.PageId || module.ModuleId == moduleid)
{
var typename = string.Empty;
- if (module.ModuleDefinition != null)
+ if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(GetRuntime().ToString())))
{
typename = module.ModuleDefinition.ControlTypeTemplate;
}
@@ -512,4 +557,4 @@
=> RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))
? Runtime.WebAssembly
: Runtime.Server;
-}
+}
\ No newline at end of file
diff --git a/Oqtane.Client/UI/ThemeBuilder.razor b/Oqtane.Client/UI/ThemeBuilder.razor
index 60c40e59..12513215 100644
--- a/Oqtane.Client/UI/ThemeBuilder.razor
+++ b/Oqtane.Client/UI/ThemeBuilder.razor
@@ -54,11 +54,6 @@
DynamicComponent = builder =>
{
var themeType = Type.GetType(PageState.Page.ThemeType);
- if (themeType == null)
- {
- // fallback
- themeType = Type.GetType(Constants.DefaultTheme);
- }
builder.OpenComponent(0, themeType);
builder.CloseComponent();
};
diff --git a/Oqtane.Package/Oqtane.Client.nuspec b/Oqtane.Package/Oqtane.Client.nuspec
index b826a37d..46e286ae 100644
--- a/Oqtane.Package/Oqtane.Client.nuspec
+++ b/Oqtane.Package/Oqtane.Client.nuspec
@@ -2,7 +2,7 @@
Oqtane.Client
- 1.0.0
+ 1.0.3
Shaun Walker
.NET Foundation
Oqtane Framework
@@ -13,7 +13,7 @@
https://github.com/oqtane/oqtane.framework
https://www.oqtane.org/Portals/0/icon.jpg
oqtane
- Initial Release
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
A modular application framework for Blazor
diff --git a/Oqtane.Package/Oqtane.Framework.nuspec b/Oqtane.Package/Oqtane.Framework.nuspec
index b5e83d5a..33ed5295 100644
--- a/Oqtane.Package/Oqtane.Framework.nuspec
+++ b/Oqtane.Package/Oqtane.Framework.nuspec
@@ -2,7 +2,7 @@
Oqtane.Framework
- 1.0.0
+ 1.0.3
Shaun Walker
.NET Foundation
Oqtane Framework
@@ -13,16 +13,11 @@
https://github.com/oqtane/oqtane.framework
https://www.oqtane.org/Portals/0/icon.jpg
oqtane framework
- Initial Release
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
A modular application framework for Blazor
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/Oqtane.Package/Oqtane.Server.nuspec b/Oqtane.Package/Oqtane.Server.nuspec
index 2645e9c2..854876a9 100644
--- a/Oqtane.Package/Oqtane.Server.nuspec
+++ b/Oqtane.Package/Oqtane.Server.nuspec
@@ -2,7 +2,7 @@
Oqtane.Server
- 1.0.0
+ 1.0.3
Shaun Walker
.NET Foundation
Oqtane Framework
@@ -13,7 +13,7 @@
https://github.com/oqtane/oqtane.framework
https://www.oqtane.org/Portals/0/icon.jpg
oqtane
- Initial Release
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
A modular application framework for Blazor
diff --git a/Oqtane.Package/Oqtane.Shared.nuspec b/Oqtane.Package/Oqtane.Shared.nuspec
index 8419aef2..e2bfeaf0 100644
--- a/Oqtane.Package/Oqtane.Shared.nuspec
+++ b/Oqtane.Package/Oqtane.Shared.nuspec
@@ -2,7 +2,7 @@
Oqtane.Shared
- 1.0.0
+ 1.0.3
Shaun Walker
.NET Foundation
Oqtane Framework
@@ -13,7 +13,7 @@
https://github.com/oqtane/oqtane.framework
https://www.oqtane.org/Portals/0/icon.jpg
oqtane
- Initial Release
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
A modular application framework for Blazor
diff --git a/Oqtane.Package/install.ps1 b/Oqtane.Package/install.ps1
new file mode 100644
index 00000000..78559c96
--- /dev/null
+++ b/Oqtane.Package/install.ps1
@@ -0,0 +1 @@
+Compress-Archive -Path "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.1.0.3.Install.zip" -Force
\ No newline at end of file
diff --git a/Oqtane.Package/nuget.exe b/Oqtane.Package/nuget.exe
index 3ae0060a..7d4cdaef 100644
Binary files a/Oqtane.Package/nuget.exe and b/Oqtane.Package/nuget.exe differ
diff --git a/Oqtane.Package/release.cmd b/Oqtane.Package/release.cmd
index 34df2891..014083b1 100644
--- a/Oqtane.Package/release.cmd
+++ b/Oqtane.Package/release.cmd
@@ -1,5 +1,18 @@
-DEL "*.nupkg"
+del "*.nupkg"
dotnet clean -c Release ..\Oqtane.sln
dotnet build -c Release ..\Oqtane.sln
-dotnet pack -o .\ -c Release ..\Oqtane.sln
-nuget.exe pack Oqtane.Framework.nuspec
+nuget.exe pack Oqtane.Client.nuspec
+nuget.exe pack Oqtane.Server.nuspec
+nuget.exe pack Oqtane.Shared.nuspec
+del /F/Q/S "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish" > NUL
+rmdir /Q/S "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish"
+dotnet publish ..\Oqtane.Server\Oqtane.Server.csproj /p:Configuration=Release
+del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.json"
+ren "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.release.json" "appsettings.json"
+C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\install.ps1"
+del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.json"
+C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\upgrade.ps1"
+del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\Oqtane.Upgrade.*"
+nuget.exe pack Oqtane.Framework.nuspec
+
+
diff --git a/Oqtane.Package/upgrade.ps1 b/Oqtane.Package/upgrade.ps1
new file mode 100644
index 00000000..80445608
--- /dev/null
+++ b/Oqtane.Package/upgrade.ps1
@@ -0,0 +1 @@
+Compress-Archive -Path "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.1.0.3.Upgrade.zip" -Force
\ No newline at end of file
diff --git a/Oqtane.Server/Controllers/FileController.cs b/Oqtane.Server/Controllers/FileController.cs
index 5d77254b..c96f6891 100644
--- a/Oqtane.Server/Controllers/FileController.cs
+++ b/Oqtane.Server/Controllers/FileController.cs
@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -135,8 +135,20 @@ namespace Oqtane.Controllers
[Authorize(Roles = Constants.RegisteredRole)]
public Models.File Put(int id, [FromBody] Models.File file)
{
- if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.Folder.FolderId, PermissionNames.Edit))
+ if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.FolderId, PermissionNames.Edit))
{
+ file.Folder = _folders.GetFolder(file.FolderId);
+ Models.File _file = _files.GetFile(id, false);
+ if (_file.Name != file.Name || _file.FolderId != file.FolderId)
+ {
+ string folderpath = GetFolderPath(file.Folder);
+ if (!Directory.Exists(folderpath))
+ {
+ Directory.CreateDirectory(folderpath);
+ }
+ System.IO.File.Move(Path.Combine(GetFolderPath(_file.Folder), _file.Name), Path.Combine(folderpath, file.Name));
+ }
+ file.Extension = Path.GetExtension(file.Name).ToLower().Replace(".", "");
file = _files.UpdateFile(file);
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", file);
}
@@ -483,7 +495,7 @@ namespace Oqtane.Controllers
string[] folders = folderpath.Split(separators, StringSplitOptions.RemoveEmptyEntries);
foreach (string folder in folders)
{
- path = Utilities.PathCombine(path, folder, "\\");
+ path = Utilities.PathCombine(path, folder, Path.DirectorySeparatorChar.ToString());
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
diff --git a/Oqtane.Server/Controllers/FolderController.cs b/Oqtane.Server/Controllers/FolderController.cs
index ebaaa590..b1bebcfd 100644
--- a/Oqtane.Server/Controllers/FolderController.cs
+++ b/Oqtane.Server/Controllers/FolderController.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Oqtane.Models;
@@ -10,20 +11,25 @@ using Oqtane.Extensions;
using Oqtane.Infrastructure;
using Oqtane.Repository;
using Oqtane.Security;
+using Microsoft.AspNetCore.Hosting;
namespace Oqtane.Controllers
{
[Route("{alias}/api/[controller]")]
public class FolderController : Controller
{
+ private readonly IWebHostEnvironment _environment;
private readonly IFolderRepository _folders;
private readonly IUserPermissions _userPermissions;
+ private readonly ITenantResolver _tenants;
private readonly ILogManager _logger;
- public FolderController(IFolderRepository folders, IUserPermissions userPermissions, ILogManager logger)
+ public FolderController(IWebHostEnvironment environment, IFolderRepository folders, IUserPermissions userPermissions, ITenantResolver tenants, ILogManager logger)
{
+ _environment = environment;
_folders = folders;
_userPermissions = userPermissions;
+ _tenants = tenants;
_logger = logger;
}
@@ -112,7 +118,7 @@ namespace Oqtane.Controllers
Folder parent = _folders.GetFolder(folder.ParentId.Value);
folder.Path = Utilities.PathCombine(parent.Path, folder.Name);
}
- folder.Path = Utilities.PathCombine(folder.Path, "\\");
+ folder.Path = Utilities.PathCombine(folder.Path, Path.DirectorySeparatorChar.ToString());
folder = _folders.AddFolder(folder);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", folder);
}
@@ -142,12 +148,19 @@ namespace Oqtane.Controllers
{
if (folder.IsPathValid())
{
- if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
+ if (folder.ParentId != null)
{
Folder parent = _folders.GetFolder(folder.ParentId.Value);
folder.Path = Utilities.PathCombine(parent.Path, folder.Name);
}
- folder.Path = Utilities.PathCombine(folder.Path, "\\");
+ folder.Path = Utilities.PathCombine(folder.Path, Path.DirectorySeparatorChar.ToString());
+
+ Models.Folder _folder = _folders.GetFolder(id, false);
+ if (_folder.Path != folder.Path && Directory.Exists(GetFolderPath(_folder)))
+ {
+ Directory.Move(GetFolderPath(_folder), GetFolderPath(folder));
+ }
+
folder = _folders.UpdateFolder(folder);
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", folder);
}
@@ -210,5 +223,10 @@ namespace Oqtane.Controllers
HttpContext.Response.StatusCode = 401;
}
}
+
+ private string GetFolderPath(Folder folder)
+ {
+ return Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", _tenants.GetTenant().TenantId.ToString(), "Sites", folder.SiteId.ToString(), folder.Path);
+ }
}
}
diff --git a/Oqtane.Server/Controllers/ModuleController.cs b/Oqtane.Server/Controllers/ModuleController.cs
index 55ea9e1e..b90db0b8 100644
--- a/Oqtane.Server/Controllers/ModuleController.cs
+++ b/Oqtane.Server/Controllers/ModuleController.cs
@@ -122,7 +122,7 @@ namespace Oqtane.Controllers
var pages = _pages.GetPages(module.SiteId).ToList();
foreach (Page page in pages)
{
- if (page.PageId != pageModule.PageId && !page.EditMode)
+ if (page.PageId != pageModule.PageId && !page.Path.StartsWith("admin/"))
{
_pageModules.AddPageModule(new PageModule { PageId = page.PageId, ModuleId = pageModule.ModuleId, Title = pageModule.Title, Pane = pageModule.Pane, Order = pageModule.Order, ContainerType = pageModule.ContainerType });
}
diff --git a/Oqtane.Server/Controllers/ModuleControllerBase.cs b/Oqtane.Server/Controllers/ModuleControllerBase.cs
new file mode 100644
index 00000000..b934e684
--- /dev/null
+++ b/Oqtane.Server/Controllers/ModuleControllerBase.cs
@@ -0,0 +1,21 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Oqtane.Infrastructure;
+
+namespace Oqtane.Controllers
+{
+ public class ModuleControllerBase : Controller
+ {
+ protected readonly ILogManager _logger;
+ protected int _entityId = -1; // passed as a querystring parameter for policy authorization and used for validation
+
+ public ModuleControllerBase(ILogManager logger, IHttpContextAccessor accessor)
+ {
+ _logger = logger;
+ if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
+ {
+ _entityId = int.Parse(accessor.HttpContext.Request.Query["entityid"]);
+ }
+ }
+ }
+}
diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
index 1cc77990..f1b9379f 100644
--- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs
+++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
@@ -94,8 +94,8 @@ namespace Oqtane.Controllers
[Authorize(Roles = Constants.HostRole)]
public void InstallModules()
{
- _installationManager.InstallPackages("Modules", true);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
+ _installationManager.InstallPackages("Modules", true);
}
// DELETE api//5?siteid=x
@@ -170,19 +170,19 @@ namespace Oqtane.Controllers
{
string rootPath;
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
- string templatePath = Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", moduleDefinition.Template,"\\");
+ string templatePath = Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", moduleDefinition.Template,Path.DirectorySeparatorChar.ToString());
if (moduleDefinition.Template == "internal")
{
- rootPath = Utilities.PathCombine(rootFolder.FullName,"\\");
- moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s, Oqtane.Client";
- moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, Oqtane.Server";
+ rootPath = Utilities.PathCombine(rootFolder.FullName,Path.DirectorySeparatorChar.ToString());
+ moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", Oqtane.Client";
+ moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, Oqtane.Server";
}
else
{
- rootPath = Utilities.PathCombine(rootFolder.Parent.FullName , moduleDefinition.Owner + "." + moduleDefinition.Name + "s","\\");
- moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Client.Oqtane";
- moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Server.Oqtane";
+ rootPath = Utilities.PathCombine(rootFolder.Parent.FullName , moduleDefinition.Owner + "." + moduleDefinition.Name,Path.DirectorySeparatorChar.ToString());
+ moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Client.Oqtane";
+ moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Server.Oqtane";
}
ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, rootFolder.Name, templatePath, moduleDefinition);
@@ -196,8 +196,8 @@ namespace Oqtane.Controllers
{
// add embedded resources to project
List resources = new List();
- resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name + "s", "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + "s.1.0.0.sql"));
- resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name + "s", "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Uninstall.sql"));
+ resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".1.0.0.sql"));
+ resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".Uninstall.sql"));
EmbedResourceFiles(Utilities.PathCombine(rootPath, "Oqtane.Server", "Oqtane.Server.csproj"), resources);
}
diff --git a/Oqtane.Server/Controllers/PageController.cs b/Oqtane.Server/Controllers/PageController.cs
index 72e4f352..01645921 100644
--- a/Oqtane.Server/Controllers/PageController.cs
+++ b/Oqtane.Server/Controllers/PageController.cs
@@ -125,7 +125,7 @@ namespace Oqtane.Controllers
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, page.SiteId);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", page);
- if (!page.EditMode)
+ if (!page.Path.StartsWith("admin/"))
{
var modules = _modules.GetModules(page.SiteId).Where(item => item.AllPages).ToList();
foreach (Module module in modules)
@@ -163,7 +163,6 @@ namespace Oqtane.Controllers
page.Order = 0;
page.IsNavigation = false;
page.Url = "";
- page.EditMode = false;
page.ThemeType = parent.ThemeType;
page.LayoutType = parent.LayoutType;
page.DefaultContainerType = parent.DefaultContainerType;
diff --git a/Oqtane.Server/Controllers/ThemeController.cs b/Oqtane.Server/Controllers/ThemeController.cs
index d2b5d542..03836680 100644
--- a/Oqtane.Server/Controllers/ThemeController.cs
+++ b/Oqtane.Server/Controllers/ThemeController.cs
@@ -43,8 +43,8 @@ namespace Oqtane.Controllers
[Authorize(Roles = Constants.HostRole)]
public void InstallThemes()
{
- _installationManager.InstallPackages("Themes", true);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
+ _installationManager.InstallPackages("Themes", true);
}
// DELETE api//xxx
diff --git a/Oqtane.Server/Controllers/UserController.cs b/Oqtane.Server/Controllers/UserController.cs
index 6fb3c93b..7ce9d1e5 100644
--- a/Oqtane.Server/Controllers/UserController.cs
+++ b/Oqtane.Server/Controllers/UserController.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Security.Claims;
using Oqtane.Shared;
using System;
+using System.IO;
using System.Net;
using Oqtane.Enums;
using Oqtane.Infrastructure;
@@ -148,7 +149,7 @@ namespace Oqtane.Controllers
notification.SiteId = user.SiteId;
notification.FromUserId = null;
notification.ToUserId = newUser.UserId;
- notification.ToEmail = "";
+ notification.ToEmail = newUser.Email;
notification.Subject = "User Account Verification";
string token = await _identityUserManager.GenerateEmailConfirmationTokenAsync(identityuser);
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token);
@@ -157,6 +158,7 @@ namespace Oqtane.Controllers
notification.CreatedOn = DateTime.UtcNow;
notification.IsDelivered = false;
notification.DeliveredOn = null;
+ notification.SendOn = DateTime.UtcNow;
_notifications.AddNotification(notification);
}
@@ -173,7 +175,7 @@ namespace Oqtane.Controllers
}
// add folder for user
- Folder folder = _folders.GetFolder(user.SiteId, Utilities.PathCombine("Users","\\"));
+ Folder folder = _folders.GetFolder(user.SiteId, Utilities.PathCombine("Users",Path.DirectorySeparatorChar.ToString()));
if (folder != null)
{
_folders.AddFolder(new Folder
@@ -181,7 +183,7 @@ namespace Oqtane.Controllers
SiteId = folder.SiteId,
ParentId = folder.FolderId,
Name = "My Folder",
- Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),"\\"),
+ Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),Path.DirectorySeparatorChar.ToString()),
Order = 1,
IsSystem = true,
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" +
@@ -385,6 +387,7 @@ namespace Oqtane.Controllers
notification.CreatedOn = DateTime.UtcNow;
notification.IsDelivered = false;
notification.DeliveredOn = null;
+ notification.SendOn = DateTime.UtcNow;
_notifications.AddNotification(notification);
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", user.Username);
}
diff --git a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs
index 3e778869..f49d189a 100644
--- a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs
+++ b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs
@@ -1,15 +1,12 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using Microsoft.Extensions.Hosting;
-using Oqtane.Extensions;
using Oqtane.Infrastructure;
using Oqtane.Modules;
using Oqtane.Services;
-using Oqtane.Shared;
using Oqtane.UI;
// ReSharper disable once CheckNamespace
@@ -55,31 +52,32 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddSingleton(hostedServiceType, serviceType);
}
}
-
+
var startUps = assembly.GetInstances();
foreach (var startup in startUps)
{
startup.ConfigureServices(services);
}
-
+
if (runtime == Runtime.Server)
{
- assembly.GetInstances()
- .ToList()
- .ForEach(x => x.ConfigureServices(services));
+ assembly.GetInstances()
+ .ToList()
+ .ForEach(x => x.ConfigureServices(services));
}
}
return services;
}
-
private static void LoadAssemblies()
{
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
if (assemblyPath == null) return;
- var assembliesFolder = new DirectoryInfo(assemblyPath);
+ AssemblyLoadContext.Default.Resolving += ResolveDependencies;
+ var assembliesFolder = new DirectoryInfo(assemblyPath);
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
// iterate through Oqtane assemblies in /bin ( filter is narrow to optimize loading process )
foreach (var dll in assembliesFolder.EnumerateFiles($"*.dll", SearchOption.TopDirectoryOnly).Where(f => f.IsOqtaneAssembly()))
@@ -95,7 +93,6 @@ namespace Microsoft.Extensions.DependencyInjection
continue;
}
- var assemblies = AppDomain.CurrentDomain.GetAssemblies();
if (!assemblies.Any(a => AssemblyName.ReferenceMatchesDefinition(assemblyName, a.GetName())))
{
try
@@ -121,5 +118,19 @@ namespace Microsoft.Extensions.DependencyInjection
}
}
}
+
+ private static Assembly ResolveDependencies(AssemblyLoadContext context, AssemblyName name)
+ {
+ var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "\\" + name.Name + ".dll";
+ if (File.Exists(assemblyPath))
+ {
+ return context.LoadFromStream(new MemoryStream(File.ReadAllBytes(assemblyPath)));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
}
}
diff --git a/Oqtane.Server/Infrastructure/DatabaseManager.cs b/Oqtane.Server/Infrastructure/DatabaseManager.cs
index 7a7cff0d..6aa2369a 100644
--- a/Oqtane.Server/Infrastructure/DatabaseManager.cs
+++ b/Oqtane.Server/Infrastructure/DatabaseManager.cs
@@ -342,46 +342,48 @@ namespace Oqtane.Infrastructure
if (!string.IsNullOrEmpty(moduledefinition.ReleaseVersions) && !string.IsNullOrEmpty(moduledefinition.ServerManagerType))
{
Type moduletype = Type.GetType(moduledefinition.ServerManagerType);
-
- string[] versions = moduledefinition.ReleaseVersions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- using (var db = new InstallationContext(NormalizeConnectionString(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
+ if (moduletype != null)
{
- foreach (var tenant in db.Tenant.ToList())
+ string[] versions = moduledefinition.ReleaseVersions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+ using (var db = new InstallationContext(NormalizeConnectionString(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
{
- int index = Array.FindIndex(versions, item => item == moduledefinition.Version);
- if (tenant.Name == install.TenantName && install.TenantName != Constants.MasterTenant)
+ foreach (var tenant in db.Tenant.ToList())
{
- index = -1;
- }
- if (index != (versions.Length - 1))
- {
- if (index == -1) index = 0;
- for (int i = index; i < versions.Length; i++)
+ int index = Array.FindIndex(versions, item => item == moduledefinition.Version);
+ if (tenant.Name == install.TenantName && install.TenantName != Constants.MasterTenant)
{
- try
+ index = -1;
+ }
+ if (index != (versions.Length - 1))
+ {
+ if (index == -1) index = 0;
+ for (int i = index; i < versions.Length; i++)
{
- if (moduletype.GetInterface("IInstallable") != null)
+ try
{
- var moduleobject = ActivatorUtilities.CreateInstance(scope.ServiceProvider, moduletype);
+ if (moduletype.GetInterface("IInstallable") != null)
+ {
+ var moduleobject = ActivatorUtilities.CreateInstance(scope.ServiceProvider, moduletype);
((IInstallable)moduleobject).Install(tenant, versions[i]);
+ }
+ else
+ {
+ sql.ExecuteScript(tenant, moduletype.Assembly, Utilities.GetTypeName(moduledefinition.ModuleDefinitionName) + "." + versions[i] + ".sql");
+ }
}
- else
+ catch (Exception ex)
{
- sql.ExecuteScript(tenant, moduletype.Assembly, Utilities.GetTypeName(moduledefinition.ModuleDefinitionName) + "." + versions[i] + ".sql");
+ result.Message = "An Error Occurred Installing " + moduledefinition.Name + " Version " + versions[i] + " - " + ex.Message.ToString();
}
}
- catch (Exception ex)
- {
- result.Message = "An Error Occurred Installing " + moduledefinition.Name + " Version " + versions[i] + " - " + ex.Message.ToString();
- }
}
}
- }
- if (string.IsNullOrEmpty(result.Message) && moduledefinition.Version != versions[versions.Length - 1])
- {
- moduledefinition.Version = versions[versions.Length - 1];
- db.Entry(moduledefinition).State = EntityState.Modified;
- db.SaveChanges();
+ if (string.IsNullOrEmpty(result.Message) && moduledefinition.Version != versions[versions.Length - 1])
+ {
+ moduledefinition.Version = versions[versions.Length - 1];
+ db.Entry(moduledefinition).State = EntityState.Modified;
+ db.SaveChanges();
+ }
}
}
}
@@ -461,7 +463,7 @@ namespace Oqtane.Infrastructure
userroles.AddUserRole(userRole);
// add user folder
- var folder = folders.GetFolder(user.SiteId, Utilities.PathCombine("Users", "\\"));
+ var folder = folders.GetFolder(user.SiteId, Utilities.PathCombine("Users", Path.DirectorySeparatorChar.ToString()));
if (folder != null)
{
folders.AddFolder(new Folder
@@ -469,7 +471,7 @@ namespace Oqtane.Infrastructure
SiteId = folder.SiteId,
ParentId = folder.FolderId,
Name = "My Folder",
- Path = Utilities.PathCombine(folder.Path, user.UserId.ToString(), "\\"),
+ Path = Utilities.PathCombine(folder.Path, user.UserId.ToString(), Path.DirectorySeparatorChar.ToString()),
Order = 1,
IsSystem = true,
Permissions = new List
diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs
index c6467c20..3fbf40cd 100644
--- a/Oqtane.Server/Infrastructure/InstallationManager.cs
+++ b/Oqtane.Server/Infrastructure/InstallationManager.cs
@@ -1,13 +1,13 @@
-using System.Reflection;
+using System;
+using System.Diagnostics;
using System.IO;
using System.IO.Compression;
-using Microsoft.Extensions.Hosting;
-using Microsoft.AspNetCore.Hosting;
+using System.Reflection;
using System.Xml;
-using Oqtane.Shared;
-using System;
-using System.Diagnostics;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Caching.Memory;
+using Microsoft.Extensions.Hosting;
+using Oqtane.Shared;
namespace Oqtane.Infrastructure
{
@@ -27,7 +27,7 @@ namespace Oqtane.Infrastructure
public void InstallPackages(string folders, bool restart)
{
var webRootPath = _environment.WebRootPath;
-
+
var install = InstallPackages(folders, webRootPath);
if (install && restart)
@@ -88,7 +88,7 @@ namespace Oqtane.Infrastructure
// deploy to appropriate locations
foreach (ZipArchiveEntry entry in archive.Entries)
{
- string foldername = Path.GetDirectoryName(entry.FullName).Split('\\')[0];
+ string foldername = Path.GetDirectoryName(entry.FullName).Split(Path.DirectorySeparatorChar)[0];
string filename = Path.GetFileName(entry.FullName);
switch (foldername)
@@ -98,7 +98,12 @@ namespace Oqtane.Infrastructure
ExtractFile(entry, filename);
break;
case "wwwroot":
- filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace("wwwroot/", "").Split('/')));
+ filename = Path.Combine(webRootPath.Replace(Path.DirectorySeparatorChar + "wwwroot", ""), Utilities.PathCombine(entry.FullName.Split('/')));
+ ExtractFile(entry, filename);
+ break;
+ case "runtimes":
+ var destSubFolder = Path.GetDirectoryName(entry.FullName);
+ filename = Path.Combine(binFolder, destSubFolder, filename);
ExtractFile(entry, filename);
break;
}
@@ -121,7 +126,15 @@ namespace Oqtane.Infrastructure
{
Directory.CreateDirectory(Path.GetDirectoryName(filename));
}
- entry.ExtractToFile(filename, true);
+
+ try
+ {
+ entry.ExtractToFile(filename, true);
+ }
+ catch
+ {
+ // an error occurred extracting the file
+ }
}
public void UpgradeFramework()
@@ -131,7 +144,7 @@ namespace Oqtane.Infrastructure
{
// get package with highest version and clean up any others
string packagename = "";
- foreach(string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg"))
+ foreach (string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg"))
{
if (packagename != "")
{
@@ -163,12 +176,13 @@ namespace Oqtane.Infrastructure
packageversion = node.InnerText;
}
reader.Close();
+ break;
}
}
}
- // ensure package version is higher than current framework version
- if (packageversion != "" && Version.Parse(Constants.Version).CompareTo(Version.Parse(packageversion)) < 0)
+ // ensure package version is greater than or equal to current framework version
+ if (packageversion != "" && Version.Parse(Constants.Version).CompareTo(Version.Parse(packageversion)) <= 0)
{
FinishUpgrade();
}
@@ -179,28 +193,26 @@ namespace Oqtane.Infrastructure
private void FinishUpgrade()
{
// check if upgrade application exists
+ string Upgrader = "Oqtane.Upgrade.dll";
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
- if (folder == null || !File.Exists(Path.Combine(folder, "Oqtane.Upgrade.exe"))) return;
+ if (folder == null || !File.Exists(Path.Combine(folder, Upgrader))) return;
// run upgrade application
- var process = new Process
+ using (var process = new Process())
{
- StartInfo =
+ process.StartInfo = new ProcessStartInfo
{
- FileName = Path.Combine(folder, "Oqtane.Upgrade.exe"),
- Arguments = "\"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"",
- ErrorDialog = false,
+ WorkingDirectory = folder,
+ FileName = "dotnet",
+ Arguments = Path.Combine(folder, Upgrader) + " \"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"",
UseShellExecute = false,
+ ErrorDialog = false,
CreateNoWindow = true,
RedirectStandardOutput = false,
RedirectStandardError = false
- }
+ };
+ process.Start();
};
- process.Start();
- process.Dispose();
-
- // stop application so upgrade application can proceed
- RestartApplication();
}
public void RestartApplication()
diff --git a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs
index 35b8b0a9..5fb49934 100644
--- a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs
+++ b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs
@@ -27,8 +27,10 @@ namespace Oqtane.Infrastructure
protected async Task ExecuteAsync(CancellationToken stoppingToken)
{
+ await Task.Yield(); // required so that this method does not block startup
+
try
- {
+ {
while (!stoppingToken.IsCancellationRequested)
{
using (var scope = _serviceScopeFactory.CreateScope())
@@ -41,21 +43,26 @@ namespace Oqtane.Infrastructure
Job job = jobs.GetJobs().Where(item => item.JobType == jobType).FirstOrDefault();
if (job != null && job.IsEnabled && !job.IsExecuting)
{
- // set next execution date
+ // get next execution date
+ DateTime NextExecution;
if (job.NextExecution == null)
{
if (job.StartDate != null)
{
- job.NextExecution = job.StartDate;
+ NextExecution = job.StartDate.Value;
}
else
{
- job.NextExecution = DateTime.UtcNow;
+ NextExecution = DateTime.UtcNow;
}
}
+ else
+ {
+ NextExecution = job.NextExecution.Value;
+ }
// determine if the job should be run
- if (job.NextExecution <= DateTime.UtcNow && (job.EndDate == null || job.EndDate >= DateTime.UtcNow))
+ if (NextExecution <= DateTime.UtcNow && (job.EndDate == null || job.EndDate >= DateTime.UtcNow))
{
IJobLogRepository jobLogs = scope.ServiceProvider.GetRequiredService();
@@ -89,7 +96,7 @@ namespace Oqtane.Infrastructure
jobLogs.UpdateJobLog(log);
// update the job
- job.NextExecution = CalculateNextExecution(job.NextExecution.Value, job.Frequency, job.Interval);
+ job.NextExecution = CalculateNextExecution(NextExecution, job.Frequency, job.Interval);
job.IsExecuting = false;
jobs.UpdateJob(job);
diff --git a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs
index 520533d9..2e18950f 100644
--- a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs
+++ b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs
@@ -20,11 +20,15 @@ namespace Oqtane.Infrastructure
{
string log = "";
- // iterate through aliases in this installation
+ // iterate through tenants in this installation
+ List tenants = new List();
var aliasRepository = provider.GetRequiredService();
List aliases = aliasRepository.GetAliases().ToList();
foreach (Alias alias in aliases)
{
+ if (tenants.Contains(alias.TenantId)) continue;
+ tenants.Add(alias.TenantId);
+
// use the SiteState to set the Alias explicitly so the tenant can be resolved
var siteState = provider.GetRequiredService();
siteState.Alias = alias;
@@ -34,11 +38,11 @@ namespace Oqtane.Infrastructure
var settingRepository = provider.GetRequiredService();
var notificationRepository = provider.GetRequiredService();
- // iterate through sites
+ // iterate through sites for this tenant
List sites = siteRepository.GetSites().ToList();
foreach (Site site in sites)
{
- log += "Processing Notifications For Site: " + site.Name + "\n\n";
+ log += "Processing Notifications For Site: " + site.Name + " ";
// get site settings
List sitesettings = settingRepository.GetSettings(EntityNames.Site, site.SiteId).ToList();
@@ -101,14 +105,14 @@ namespace Oqtane.Infrastructure
catch (Exception ex)
{
// error
- log += ex.Message + "\n\n";
+ log += ex.Message + " ";
}
}
- log += "Notifications Delivered: " + sent + "\n\n";
+ log += "Notifications Delivered: " + sent + " ";
}
else
{
- log += "SMTP Not Configured" + "\n\n";
+ log += "SMTP Not Configured" + " ";
}
}
}
@@ -116,7 +120,6 @@ namespace Oqtane.Infrastructure
return log;
}
-
private Dictionary GetSettings(List settings)
{
Dictionary dictionary = new Dictionary();
diff --git a/Oqtane.Server/Infrastructure/SiteTemplates/DefaultSiteTemplate.cs b/Oqtane.Server/Infrastructure/SiteTemplates/DefaultSiteTemplate.cs
index 4b56e443..8b71c33b 100644
--- a/Oqtane.Server/Infrastructure/SiteTemplates/DefaultSiteTemplate.cs
+++ b/Oqtane.Server/Infrastructure/SiteTemplates/DefaultSiteTemplate.cs
@@ -42,7 +42,6 @@ namespace Oqtane.SiteTemplates
Icon = "home",
IsNavigation = true,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List {
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -89,7 +88,6 @@ namespace Oqtane.SiteTemplates
Icon = "lock-locked",
IsNavigation = true,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List {
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -114,7 +112,6 @@ namespace Oqtane.SiteTemplates
Icon = "target",
IsNavigation = true,
IsPersonalizable = true,
- EditMode = false,
PagePermissions = new List {
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -134,7 +131,7 @@ namespace Oqtane.SiteTemplates
if (System.IO.File.Exists(Path.Combine(_environment.WebRootPath, "images", "logo-white.png")))
{
- string folderpath = Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", site.TenantId.ToString(), "Sites", site.SiteId.ToString(),"\\");
+ string folderpath = Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", site.TenantId.ToString(), "Sites", site.SiteId.ToString(), Path.DirectorySeparatorChar.ToString());
System.IO.Directory.CreateDirectory(folderpath);
if (!System.IO.File.Exists(Path.Combine(folderpath, "logo-white.png")))
{
diff --git a/Oqtane.Server/Infrastructure/SiteTemplates/EmptySiteTemplate.cs b/Oqtane.Server/Infrastructure/SiteTemplates/EmptySiteTemplate.cs
index 1dfefdf0..33ccaf32 100644
--- a/Oqtane.Server/Infrastructure/SiteTemplates/EmptySiteTemplate.cs
+++ b/Oqtane.Server/Infrastructure/SiteTemplates/EmptySiteTemplate.cs
@@ -30,7 +30,6 @@ namespace Oqtane.SiteTemplates
Icon = "home",
IsNavigation = true,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List {
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
new Permission(PermissionNames.View, Constants.AdminRole, true),
diff --git a/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs b/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
index fc9495fc..ba164d4f 100644
--- a/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
+++ b/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
@@ -8,24 +8,18 @@ using System;
using System.Collections.Generic;
using Oqtane.Enums;
using Oqtane.Infrastructure;
+using Oqtane.Controllers;
namespace Oqtane.Modules.HtmlText.Controllers
{
[Route("{alias}/api/[controller]")]
- public class HtmlTextController : Controller
+ public class HtmlTextController : ModuleControllerBase
{
private readonly IHtmlTextRepository _htmlText;
- private readonly ILogManager _logger;
- private int _entityId = -1; // passed as a querystring parameter for authorization and used for validation
- public HtmlTextController(IHtmlTextRepository htmlText, ILogManager logger, IHttpContextAccessor httpContextAccessor)
+ public HtmlTextController(IHtmlTextRepository htmlText, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
{
_htmlText = htmlText;
- _logger = logger;
- if (httpContextAccessor.HttpContext.Request.Query.ContainsKey("entityid"))
- {
- _entityId = int.Parse(httpContextAccessor.HttpContext.Request.Query["entityid"]);
- }
}
// GET api//5
diff --git a/Oqtane.Server/Oqtane.Server.csproj b/Oqtane.Server/Oqtane.Server.csproj
index 0db9ece5..495819fc 100644
--- a/Oqtane.Server/Oqtane.Server.csproj
+++ b/Oqtane.Server/Oqtane.Server.csproj
@@ -4,7 +4,7 @@
netcoreapp3.1
7.3
Debug;Release
- 1.0.0
+ 1.0.3
Oqtane
Shaun Walker
.NET Foundation
@@ -13,7 +13,7 @@
https://www.oqtane.org
https://github.com/oqtane
Git
- Not for production use.
+ https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3
Oqtane
true
@@ -31,6 +31,8 @@
+
+
@@ -48,4 +50,14 @@
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Oqtane.Server/Properties/launchSettings.json b/Oqtane.Server/Properties/launchSettings.json
index fcddfc65..d33ad7b2 100644
--- a/Oqtane.Server/Properties/launchSettings.json
+++ b/Oqtane.Server/Properties/launchSettings.json
@@ -26,4 +26,4 @@
"applicationUrl": "http://localhost:44357/"
}
}
-}
\ No newline at end of file
+}
diff --git a/Oqtane.Server/Repository/FileRepository.cs b/Oqtane.Server/Repository/FileRepository.cs
index f532bb6e..0e5fa798 100644
--- a/Oqtane.Server/Repository/FileRepository.cs
+++ b/Oqtane.Server/Repository/FileRepository.cs
@@ -45,7 +45,21 @@ namespace Oqtane.Repository
public File GetFile(int fileId)
{
- File file = _db.File.Where(item => item.FileId == fileId).Include(item => item.Folder).FirstOrDefault();
+ return GetFile(fileId, true);
+ }
+
+ public File GetFile(int fileId, bool tracking)
+ {
+ File file;
+ if (tracking)
+ {
+ file = _db.File.Where(item => item.FileId == fileId).Include(item => item.Folder).FirstOrDefault();
+
+ }
+ else
+ {
+ file = _db.File.AsNoTracking().Where(item => item.FileId == fileId).Include(item => item.Folder).FirstOrDefault();
+ }
if (file != null)
{
IEnumerable permissions = _permissions.GetPermissions(EntityNames.Folder, file.FolderId).ToList();
diff --git a/Oqtane.Server/Repository/FolderRepository.cs b/Oqtane.Server/Repository/FolderRepository.cs
index 56b42c7b..dbaed6c1 100644
--- a/Oqtane.Server/Repository/FolderRepository.cs
+++ b/Oqtane.Server/Repository/FolderRepository.cs
@@ -47,7 +47,20 @@ namespace Oqtane.Repository
public Folder GetFolder(int folderId)
{
- Folder folder = _db.Folder.Find(folderId);
+ return GetFolder(folderId, true);
+ }
+
+ public Folder GetFolder(int folderId, bool tracking)
+ {
+ Folder folder;
+ if (tracking)
+ {
+ folder = _db.Folder.Where(item => item.FolderId == folderId).FirstOrDefault();
+ }
+ else
+ {
+ folder = _db.Folder.AsNoTracking().Where(item => item.FolderId == folderId).FirstOrDefault();
+ }
if (folder != null)
{
folder.Permissions = _permissions.GetPermissionString(EntityNames.Folder, folder.FolderId);
diff --git a/Oqtane.Server/Repository/Interfaces/IFileRepository.cs b/Oqtane.Server/Repository/Interfaces/IFileRepository.cs
index 19715187..7ef99025 100644
--- a/Oqtane.Server/Repository/Interfaces/IFileRepository.cs
+++ b/Oqtane.Server/Repository/Interfaces/IFileRepository.cs
@@ -9,6 +9,7 @@ namespace Oqtane.Repository
File AddFile(File file);
File UpdateFile(File file);
File GetFile(int fileId);
+ File GetFile(int fileId, bool tracking);
void DeleteFile(int fileId);
}
}
diff --git a/Oqtane.Server/Repository/Interfaces/IFolderRepository.cs b/Oqtane.Server/Repository/Interfaces/IFolderRepository.cs
index 65256184..52b67e5b 100644
--- a/Oqtane.Server/Repository/Interfaces/IFolderRepository.cs
+++ b/Oqtane.Server/Repository/Interfaces/IFolderRepository.cs
@@ -9,6 +9,7 @@ namespace Oqtane.Repository
Folder AddFolder(Folder folder);
Folder UpdateFolder(Folder folder);
Folder GetFolder(int folderId);
+ Folder GetFolder(int folderId, bool tracking);
Folder GetFolder(int siteId, string path);
void DeleteFolder(int folderId);
}
diff --git a/Oqtane.Server/Repository/ModuleRepository.cs b/Oqtane.Server/Repository/ModuleRepository.cs
index a66517fc..9d83351a 100644
--- a/Oqtane.Server/Repository/ModuleRepository.cs
+++ b/Oqtane.Server/Repository/ModuleRepository.cs
@@ -123,7 +123,7 @@ namespace Oqtane.Repository
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
if (moduledefinition != null)
{
- ModuleContent modulecontent = JsonSerializer.Deserialize(content);
+ ModuleContent modulecontent = JsonSerializer.Deserialize(content.Replace("\n", ""));
if (modulecontent.ModuleDefinitionName == moduledefinition.ModuleDefinitionName)
{
if (moduledefinition.ServerManagerType != "")
@@ -147,9 +147,10 @@ namespace Oqtane.Repository
}
}
}
- catch
+ catch (Exception ex)
{
// error occurred during import
+ string error = ex.Message;
}
return success;
diff --git a/Oqtane.Server/Repository/NotificationRepository.cs b/Oqtane.Server/Repository/NotificationRepository.cs
index 4e6550d2..43025c3a 100644
--- a/Oqtane.Server/Repository/NotificationRepository.cs
+++ b/Oqtane.Server/Repository/NotificationRepository.cs
@@ -21,6 +21,7 @@ namespace Oqtane.Repository
return _db.Notification
.Where(item => item.SiteId == siteId)
.Where(item => item.IsDelivered == false)
+ .Where(item => item.SendOn == null || item.SendOn < System.DateTime.UtcNow)
.ToList();
}
diff --git a/Oqtane.Server/Repository/SiteRepository.cs b/Oqtane.Server/Repository/SiteRepository.cs
index ae179abe..6f77ed56 100644
--- a/Oqtane.Server/Repository/SiteRepository.cs
+++ b/Oqtane.Server/Repository/SiteRepository.cs
@@ -58,7 +58,6 @@ namespace Oqtane.Repository
Icon = Icons.LockLocked,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -88,7 +87,6 @@ namespace Oqtane.Repository
Icon = Icons.Person,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -119,7 +117,6 @@ namespace Oqtane.Repository
Icon = Icons.Person,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -149,7 +146,6 @@ namespace Oqtane.Repository
Icon = Icons.Person,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -175,7 +171,7 @@ namespace Oqtane.Repository
// admin pages
pageTemplates.Add(new PageTemplate
{
- Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -203,7 +199,6 @@ namespace Oqtane.Repository
Icon = Icons.Home,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -231,7 +226,6 @@ namespace Oqtane.Repository
Icon = Icons.Layers,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -259,7 +253,6 @@ namespace Oqtane.Repository
Icon = Icons.People,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -287,7 +280,6 @@ namespace Oqtane.Repository
Icon = Icons.Person,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -315,7 +307,6 @@ namespace Oqtane.Repository
Icon = Icons.LockLocked,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -343,7 +334,6 @@ namespace Oqtane.Repository
Icon = Icons.File,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -371,7 +361,6 @@ namespace Oqtane.Repository
Icon = Icons.Trash,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.AdminRole, true),
@@ -401,7 +390,6 @@ namespace Oqtane.Repository
Icon = Icons.MagnifyingGlass,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -428,7 +416,6 @@ namespace Oqtane.Repository
Icon = Icons.List,
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -450,7 +437,7 @@ namespace Oqtane.Repository
});
pageTemplates.Add(new PageTemplate
{
- Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = Icons.Globe, IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = Icons.Globe, IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -472,7 +459,7 @@ namespace Oqtane.Repository
});
pageTemplates.Add(new PageTemplate
{
- Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = Icons.Browser, IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = Icons.Browser, IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -494,7 +481,7 @@ namespace Oqtane.Repository
});
pageTemplates.Add(new PageTemplate
{
- Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = Icons.Brush, IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = Icons.Brush, IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -516,7 +503,7 @@ namespace Oqtane.Repository
});
pageTemplates.Add(new PageTemplate
{
- Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = Icons.Timer, IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = Icons.Timer, IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -544,7 +531,6 @@ namespace Oqtane.Repository
Icon = "spreadsheet",
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -572,7 +558,6 @@ namespace Oqtane.Repository
Icon = "medical-cross",
IsNavigation = false,
IsPersonalizable = false,
- EditMode = true,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -594,7 +579,7 @@ namespace Oqtane.Repository
});
pageTemplates.Add(new PageTemplate
{
- Name = "System Update", Parent = "Admin", Path = "admin/update", Icon = Icons.Aperture, IsNavigation = false, IsPersonalizable = false, EditMode = true,
+ Name = "System Update", Parent = "Admin", Path = "admin/update", Icon = Icons.Aperture, IsNavigation = false, IsPersonalizable = false,
PagePermissions = new List
{
new Permission(PermissionNames.View, Constants.HostRole, true),
@@ -692,7 +677,7 @@ namespace Oqtane.Repository
});
_folderRepository.AddFolder(new Folder
{
- SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = Utilities.PathCombine("Users","\\"), Order = 1, IsSystem = true,
+ SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = Utilities.PathCombine("Users",Path.DirectorySeparatorChar.ToString()), Order = 1, IsSystem = true,
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
});
@@ -754,7 +739,6 @@ namespace Oqtane.Repository
Order = 1,
Url = "",
IsNavigation = pagetemplate.IsNavigation,
- EditMode = pagetemplate.EditMode,
ThemeType = "",
LayoutType = "",
DefaultContainerType = "",
diff --git a/Oqtane.Server/Repository/ThemeRepository.cs b/Oqtane.Server/Repository/ThemeRepository.cs
index 4d8c26d3..24b57598 100644
--- a/Oqtane.Server/Repository/ThemeRepository.cs
+++ b/Oqtane.Server/Repository/ThemeRepository.cs
@@ -50,8 +50,9 @@ namespace Oqtane.Repository
foreach (Type themeControlType in themeControlTypes)
{
// Check if type should be ignored
- if (themeControlType.IsOqtaneIgnore()
- ) continue;
+ if (themeControlType.IsOqtaneIgnore() ||
+ themeControlType.GetInterfaces().Contains(typeof(ILayoutControl)) ||
+ themeControlType.GetInterfaces().Contains(typeof(IContainerControl))) continue;
// create namespace root typename
string qualifiedThemeType = themeControlType.Namespace + ", " + themeControlType.Assembly.GetName().Name;
@@ -109,7 +110,7 @@ namespace Oqtane.Repository
.Where(item => item.GetInterfaces().Contains(typeof(ILayoutControl))).ToArray();
foreach (Type layouttype in layouttypes)
{
- var layoutobject = Activator.CreateInstance(layouttype) as ILayoutControl;
+ var layoutobject = Activator.CreateInstance(layouttype) as IThemeControl;
theme.Layouts.Add(
new ThemeControl
{
@@ -126,7 +127,7 @@ namespace Oqtane.Repository
.Where(item => item.GetInterfaces().Contains(typeof(IContainerControl))).ToArray();
foreach (Type containertype in containertypes)
{
- var containerobject = Activator.CreateInstance(containertype) as IContainerControl;
+ var containerobject = Activator.CreateInstance(containertype) as IThemeControl;
theme.Containers.Add(
new ThemeControl
{
diff --git a/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql b/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql
new file mode 100644
index 00000000..76af104c
--- /dev/null
+++ b/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql
@@ -0,0 +1,12 @@
+/*
+
+Version 1.0.1 Notification migration script
+
+*/
+
+ALTER TABLE [dbo].[Notification] ADD
+ [SendOn] [datetime] NULL
+GO
+
+UPDATE [dbo].[Notification] SET SendOn = CreatedOn WHERE SendOn IS NULL
+GO
\ No newline at end of file
diff --git a/Oqtane.Server/Scripts/Tenant.01.00.02.01.sql b/Oqtane.Server/Scripts/Tenant.01.00.02.01.sql
new file mode 100644
index 00000000..409f4f10
--- /dev/null
+++ b/Oqtane.Server/Scripts/Tenant.01.00.02.01.sql
@@ -0,0 +1,9 @@
+/*
+
+Version 1.0.2.1 migration script
+
+*/
+
+ALTER TABLE [dbo].[Page]
+ DROP COLUMN EditMode
+GO
\ No newline at end of file
diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs
index b9f001bc..ee53f340 100644
--- a/Oqtane.Server/Startup.cs
+++ b/Oqtane.Server/Startup.cs
@@ -72,7 +72,7 @@ namespace Oqtane
});
}
- // register authorization services
+ // register custom authorization policies
services.AddAuthorizationCore(options =>
{
options.AddPolicy("ViewPage", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.View)));
diff --git a/Oqtane.Server/appsettings.json b/Oqtane.Server/appsettings.json
index cad2785c..0ab499f0 100644
--- a/Oqtane.Server/appsettings.json
+++ b/Oqtane.Server/appsettings.json
@@ -2,7 +2,7 @@
"ConnectionStrings": {
"DefaultConnection": ""
},
- "Runtime" : "Server",
+ "Runtime": "Server",
"Installation": {
"DefaultAlias": "",
"HostPassword": "",
@@ -12,4 +12,4 @@
"DefaultLayout": "",
"DefaultContainer": ""
}
-}
+}
\ No newline at end of file
diff --git a/Oqtane.Server/appsettings.release.json b/Oqtane.Server/appsettings.release.json
new file mode 100644
index 00000000..4fe3a03a
--- /dev/null
+++ b/Oqtane.Server/appsettings.release.json
@@ -0,0 +1,15 @@
+{
+ "Runtime": "Server",
+ "ConnectionStrings": {
+ "DefaultConnection": ""
+ },
+ "Installation": {
+ "DefaultAlias": "",
+ "HostPassword": "",
+ "HostEmail": "",
+ "SiteTemplate": "",
+ "DefaultTheme": "",
+ "DefaultLayout": "",
+ "DefaultContainer": ""
+ }
+}
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor
index 7df2397c..cd845092 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor
@@ -1,8 +1,8 @@
@using Oqtane.Modules.Controls
-@using [Owner].[Module]s.Services
-@using [Owner].[Module]s.Models
+@using [Owner].[Module].Services
+@using [Owner].[Module].Models
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager
@@ -31,6 +31,8 @@
public override string Actions => "Add,Edit";
+ public override string Title => "Manage [Module]";
+
public override List Resources => new List()
{
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
@@ -50,7 +52,7 @@
if (PageState.Action == "Edit")
{
_id = Int32.Parse(PageState.QueryString["id"]);
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id);
+ [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
if ([Module] != null)
{
_name = [Module].Name;
@@ -82,7 +84,7 @@
}
else
{
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id);
+ [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
[Module].Name = _name;
await [Module]Service.Update[Module]Async([Module]);
await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor
index c45943db..2ac9f31c 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor
@@ -1,7 +1,7 @@
-@using [Owner].[Module]s.Services
-@using [Owner].[Module]s.Models
+@using [Owner].[Module].Services
+@using [Owner].[Module].Models
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager
@@ -17,16 +17,16 @@ else
@if (@_[Module]s.Count != 0)
{
-
+
-
+
+
+ @context.Name
}
@@ -41,7 +41,7 @@ else
[Module] Module Created Successfully. Use Edit Mode To Add A [Module]. You Can Access The Files At The Following Locations:
[RootPath]Client\
-- [Owner].[Module]s.Client.csproj - client project
+- [Owner].[Module].Client.csproj - client project
- _Imports.razor - global imports for module components
- Edit.razor - component for adding or editing content
- Index.razor - main component for your module **the content you are reading is in this file**
@@ -50,22 +50,22 @@ else
- Services\I[Module]Service.cs - interface for defining service API methods
- Services\[Module]Service.cs - implements service API interface methods
[RootPath]Package\
-- [Owner].[Module]s.nuspec - nuget manifest for packaging module
-- [Owner].[Module]s.Package.csproj - packaging project
+- [Owner].[Module].nuspec - nuget manifest for packaging module
+- [Owner].[Module].Package.csproj - packaging project
- debug.cmd - copies assemblies to Oqtane bin folder when in Debug mode
- release.cmd - creates nuget package and deploys to Oqtane wwwroot/modules folder when in Release mode
[RootPath]Server\
-- [Owner].[Module]s.Server.csproj - server project
+- [Owner].[Module].Server.csproj - server project
- Controllers\[Module]Controller.cs - API methods implemented using a REST pattern
- Manager\[Module]Manager.cs - implements optional module interfaces for features such as import/export of content
- Repository\I[Module]Repository.cs - interface for defining repository methods
- Repository\[Module]Respository.cs - implements repository interface methods for data access using EF Core
- Repository\[Module]Context.cs - provides a DB Context for data access
-- Scripts\[Owner].[Module]s.1.0.0.sql - database schema definition script
-- Scripts\[Owner].[Module]s.Uninstall.sql - database uninstall script
+- Scripts\[Owner].[Module].1.0.0.sql - database schema definition script
+- Scripts\[Owner].[Module].Uninstall.sql - database uninstall script
- wwwroot\Module.css - module style sheet
[RootPath]Shared\
-- [Owner].[Module]s.csproj - shared project
+- [Owner].[Module].csproj - shared project
- Models\[Module].cs - model definition
@@ -95,7 +95,7 @@ else
{
try
{
- await [Module]Service.Delete[Module]Async([Module].[Module]Id);
+ await [Module]Service.Delete[Module]Async([Module].[Module]Id, ModuleState.ModuleId);
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
StateHasChanged();
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs
index d6664487..af85489c 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs
@@ -1,7 +1,7 @@
using Oqtane.Models;
using Oqtane.Modules;
-namespace [Owner].[Module]s
+namespace [Owner].[Module]
{
public class ModuleInfo : IModule
{
@@ -12,7 +12,7 @@ namespace [Owner].[Module]s
Version = "1.0.0",
ServerManagerType = "[ServerManagerType]",
ReleaseVersions = "1.0.0",
- Dependencies = "[Owner].[Module]s.Shared.Oqtane"
+ Dependencies = "[Owner].[Module].Shared.Oqtane"
};
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs
index e98da06d..601eba6a 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs
@@ -1,19 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Services
+namespace [Owner].[Module].Services
{
public interface I[Module]Service
{
- Task> Get[Module]sAsync(int ModuleId);
+ Task> Get[Module]sAsync(int ModuleId);
- Task<[Module]> Get[Module]Async(int [Module]Id);
+ Task Get[Module]Async(int [Module]Id, int ModuleId);
- Task<[Module]> Add[Module]Async([Module] [Module]);
+ Task Add[Module]Async(Models.[Module] [Module]);
- Task<[Module]> Update[Module]Async([Module] [Module]);
+ Task Update[Module]Async(Models.[Module] [Module]);
- Task Delete[Module]Async(int [Module]Id);
+ Task Delete[Module]Async(int [Module]Id, int ModuleId);
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs
index f95c41b9..05a85ac7 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs
@@ -5,9 +5,9 @@ using System.Threading.Tasks;
using Oqtane.Modules;
using Oqtane.Services;
using Oqtane.Shared;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Services
+namespace [Owner].[Module].Services
{
public class [Module]Service : ServiceBase, I[Module]Service, IService
{
@@ -18,32 +18,32 @@ namespace [Owner].[Module]s.Services
_siteState = siteState;
}
- private string Apiurl=> CreateApiUrl(_siteState.Alias, "[Module]");
+ private string Apiurl => CreateApiUrl(_siteState.Alias, "[Module]");
- public async Task> Get[Module]sAsync(int ModuleId)
+ public async Task> Get[Module]sAsync(int ModuleId)
{
- List<[Module]> [Module]s = await GetJsonAsync>($"{Apiurl}?moduleid={ModuleId}");
+ List [Module]s = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", ModuleId));
return [Module]s.OrderBy(item => item.Name).ToList();
}
- public async Task<[Module]> Get[Module]Async(int [Module]Id)
+ public async Task Get[Module]Async(int [Module]Id, int ModuleId)
{
- return await GetJsonAsync<[Module]>($"{Apiurl}/{[Module]Id}");
+ return await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
}
- public async Task<[Module]> Add[Module]Async([Module] [Module])
+ public async Task Add[Module]Async(Models.[Module] [Module])
{
- return await PostJsonAsync<[Module]>($"{Apiurl}?entityid={[Module].ModuleId}", [Module]);
+ return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", [Module].ModuleId), [Module]);
}
- public async Task<[Module]> Update[Module]Async([Module] [Module])
+ public async Task Update[Module]Async(Models.[Module] [Module])
{
- return await PutJsonAsync<[Module]>($"{Apiurl}/{[Module].[Module]Id}?entityid={[Module].ModuleId}", [Module]);
+ return await PutJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module].[Module]Id}", [Module].ModuleId), [Module]);
}
- public async Task Delete[Module]Async(int [Module]Id)
+ public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
{
- await DeleteAsync($"{Apiurl}/{[Module]Id}");
+ await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
}
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor
index fac25c7e..415b24ca 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor
@@ -1,4 +1,4 @@
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject ISettingService SettingService
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module]s.Client.csproj b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module].Client.csproj
similarity index 79%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module]s.Client.csproj
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module].Client.csproj
index 2cd5a042..4cd92d84 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module]s.Client.csproj
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module].Client.csproj
@@ -7,9 +7,9 @@
[Owner]
[Owner]
[Description]
- [Owner].[Module]s
+ [Owner].[Module]
[Owner]
- [Owner].[Module]s.Client.Oqtane
+ [Owner].[Module].Client.Oqtane
@@ -21,12 +21,12 @@
-
+
-
-
+
+
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.Package.csproj b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].Package.csproj
similarity index 65%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.Package.csproj
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].Package.csproj
index 31d02d8f..5f1dba1f 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.Package.csproj
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].Package.csproj
@@ -6,9 +6,9 @@
-
-
-
+
+
+
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.nuspec b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].nuspec
similarity index 73%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.nuspec
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].nuspec
index 6fa789e8..9ed078c4 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module]s.nuspec
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/[Owner].[Module].nuspec
@@ -1,12 +1,12 @@
- [Owner].[Module]s
+ [Owner].[Module]
1.0.0
[Owner]
[Owner]
- [Module]s
- [Module]s
+ [Module]
+ [Module]
[Owner]
false
MIT
@@ -20,12 +20,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/debug.cmd b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/debug.cmd
index 7ac65774..b9f4921e 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/debug.cmd
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/debug.cmd
@@ -1,7 +1,7 @@
-XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Client.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Client.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Server.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Server.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Shared.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Shared.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
-XCOPY "..\Server\wwwroot\Modules\[Owner].[Module]s\*" "..\..\[RootFolder]\Oqtane.Server\wwwroot\Modules\[Owner].[Module]s\" /Y /S /I
+XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module].Client.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module].Client.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module].Server.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module].Server.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module].Shared.Oqtane.dll" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module].Shared.Oqtane.pdb" "..\..\[RootFolder]\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
+XCOPY "..\Server\wwwroot\Modules\[Owner].[Module]\*" "..\..\[RootFolder]\Oqtane.Server\wwwroot\Modules\[Owner].[Module]\" /Y /S /I
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/release.cmd b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/release.cmd
index b294ccdf..aaa25f5d 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Package/release.cmd
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Package/release.cmd
@@ -1,2 +1,2 @@
-"..\..\[RootFolder]\oqtane.package\nuget.exe" pack [Owner].[Module]s.nuspec
+"..\..\[RootFolder]\oqtane.package\nuget.exe" pack [Owner].[Module].nuspec
XCOPY "*.nupkg" "..\..\[RootFolder]\Oqtane.Server\wwwroot\Modules\" /Y
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs
index 1ff6a0ab..c8fe7485 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs
@@ -1,50 +1,62 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
+using Microsoft.AspNetCore.Http;
using Oqtane.Shared;
using Oqtane.Enums;
using Oqtane.Infrastructure;
-using [Owner].[Module]s.Models;
-using [Owner].[Module]s.Repository;
+using [Owner].[Module].Models;
+using [Owner].[Module].Repository;
-namespace [Owner].[Module]s.Controllers
+namespace [Owner].[Module].Controllers
{
- [Route("{site}/api/[controller]")]
+ [Route("{alias}/api/[controller]")]
public class [Module]Controller : Controller
{
- private readonly I[Module]Repository _[Module]s;
+ private readonly I[Module]Repository _[Module]Repository;
private readonly ILogManager _logger;
+ protected int _entityId = -1;
- public [Module]Controller(I[Module]Repository [Module]s, ILogManager logger)
+ public [Module]Controller(I[Module]Repository [Module]Repository, ILogManager logger, IHttpContextAccessor accessor)
{
- _[Module]s = [Module]s;
+ _[Module]Repository = [Module]Repository;
_logger = logger;
+
+ if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
+ {
+ _entityId = int.Parse(accessor.HttpContext.Request.Query["entityid"]);
+ }
}
// GET: api/?moduleid=x
[HttpGet]
- [Authorize(Roles = Constants.RegisteredRole)]
- public IEnumerable<[Module]> Get(string moduleid)
+ [Authorize(Policy = "ViewModule")]
+ public IEnumerable Get(string moduleid)
{
- return _[Module]s.Get[Module]s(int.Parse(moduleid));
+ return _[Module]Repository.Get[Module]s(int.Parse(moduleid));
}
// GET api//5
[HttpGet("{id}")]
- [Authorize(Roles = Constants.RegisteredRole)]
- public [Module] Get(int id)
+ [Authorize(Policy = "ViewModule")]
+ public Models.[Module] Get(int id)
{
- return _[Module]s.Get[Module](id);
+ Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
+ if ([Module] != null && [Module].ModuleId != _entityId)
+ {
+ [Module] = null;
+ }
+ return [Module];
}
// POST api/
[HttpPost]
- [Authorize(Roles = Constants.AdminRole)]
- public [Module] Post([FromBody] [Module] [Module])
+ [Authorize(Policy = "EditModule")]
+ public Models.[Module] Post([FromBody] Models.[Module] [Module])
{
- if (ModelState.IsValid)
+ if (ModelState.IsValid && [Module].ModuleId == _entityId)
{
- [Module] = _[Module]s.Add[Module]([Module]);
+ [Module] = _[Module]Repository.Add[Module]([Module]);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
}
return [Module];
@@ -52,12 +64,12 @@ namespace [Owner].[Module]s.Controllers
// PUT api//5
[HttpPut("{id}")]
- [Authorize(Roles = Constants.AdminRole)]
- public [Module] Put(int id, [FromBody] [Module] [Module])
+ [Authorize(Policy = "EditModule")]
+ public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module])
{
- if (ModelState.IsValid)
+ if (ModelState.IsValid && [Module].ModuleId == _entityId)
{
- [Module] = _[Module]s.Update[Module]([Module]);
+ [Module] = _[Module]Repository.Update[Module]([Module]);
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
}
return [Module];
@@ -65,11 +77,15 @@ namespace [Owner].[Module]s.Controllers
// DELETE api//5
[HttpDelete("{id}")]
- [Authorize(Roles = Constants.AdminRole)]
+ [Authorize(Policy = "EditModule")]
public void Delete(int id)
{
- _[Module]s.Delete[Module](id);
- _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
+ Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
+ if ([Module] != null && [Module].ModuleId == _entityId)
+ {
+ _[Module]Repository.Delete[Module](id);
+ _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
+ }
}
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Manager/[Module]Manager.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Manager/[Module]Manager.cs
index 1fc55b78..486c8ddf 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Manager/[Module]Manager.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Manager/[Module]Manager.cs
@@ -5,36 +5,36 @@ using Oqtane.Modules;
using Oqtane.Models;
using Oqtane.Infrastructure;
using Oqtane.Repository;
-using [Owner].[Module]s.Models;
-using [Owner].[Module]s.Repository;
+using [Owner].[Module].Models;
+using [Owner].[Module].Repository;
-namespace [Owner].[Module]s.Manager
+namespace [Owner].[Module].Manager
{
public class [Module]Manager : IInstallable, IPortable
{
- private I[Module]Repository _[Module]s;
+ private I[Module]Repository _[Module]Repository;
private ISqlRepository _sql;
- public [Module]Manager(I[Module]Repository [Module]s, ISqlRepository sql)
+ public [Module]Manager(I[Module]Repository [Module]Repository, ISqlRepository sql)
{
- _[Module]s = [Module]s;
+ _[Module]Repository = [Module]Repository;
_sql = sql;
}
public bool Install(Tenant tenant, string version)
{
- return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]s." + version + ".sql");
+ return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]." + version + ".sql");
}
public bool Uninstall(Tenant tenant)
{
- return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]s.Uninstall.sql");
+ return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module].Uninstall.sql");
}
public string ExportModule(Module module)
{
string content = "";
- List<[Module]> [Module]s = _[Module]s.Get[Module]s(module.ModuleId).ToList();
+ List [Module]s = _[Module]Repository.Get[Module]s(module.ModuleId).ToList();
if ([Module]s != null)
{
content = JsonSerializer.Serialize([Module]s);
@@ -44,19 +44,16 @@ namespace [Owner].[Module]s.Manager
public void ImportModule(Module module, string content, string version)
{
- List<[Module]> [Module]s = null;
+ List [Module]s = null;
if (!string.IsNullOrEmpty(content))
{
- [Module]s = JsonSerializer.Deserialize>(content);
+ [Module]s = JsonSerializer.Deserialize>(content);
}
if ([Module]s != null)
{
- foreach([Module] [Module] in [Module]s)
+ foreach(var [Module] in [Module]s)
{
- [Module] _[Module] = new [Module]();
- _[Module].ModuleId = module.ModuleId;
- _[Module].Name = [Module].Name;
- _[Module]s.Add[Module](_[Module]);
+ _[Module]Repository.Add[Module](new Models.[Module] { ModuleId = module.ModuleId, Name = [Module].Name });
}
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/I[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/I[Module]Repository.cs
index f38a60d5..52b7913a 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/I[Module]Repository.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/I[Module]Repository.cs
@@ -1,14 +1,14 @@
using System.Collections.Generic;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Repository
+namespace [Owner].[Module].Repository
{
public interface I[Module]Repository
{
- IEnumerable<[Module]> Get[Module]s(int ModuleId);
- [Module] Get[Module](int [Module]Id);
- [Module] Add[Module]([Module] [Module]);
- [Module] Update[Module]([Module] [Module]);
+ IEnumerable Get[Module]s(int ModuleId);
+ Models.[Module] Get[Module](int [Module]Id);
+ Models.[Module] Add[Module](Models.[Module] [Module]);
+ Models.[Module] Update[Module](Models.[Module] [Module]);
void Delete[Module](int [Module]Id);
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Context.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Context.cs
index 2a14bbf4..a10d7219 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Context.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Context.cs
@@ -2,13 +2,13 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Http;
using Oqtane.Modules;
using Oqtane.Repository;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Repository
+namespace [Owner].[Module].Repository
{
public class [Module]Context : DBContextBase, IService
{
- public virtual DbSet<[Module]> [Module] { get; set; }
+ public virtual DbSet [Module] { get; set; }
public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
{
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Repository.cs
index 9b83b239..9c8c3628 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Repository.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]Repository.cs
@@ -2,9 +2,9 @@ using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections.Generic;
using Oqtane.Modules;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Repository
+namespace [Owner].[Module].Repository
{
public class [Module]Repository : I[Module]Repository, IService
{
@@ -15,24 +15,24 @@ namespace [Owner].[Module]s.Repository
_db = context;
}
- public IEnumerable<[Module]> Get[Module]s(int ModuleId)
+ public IEnumerable Get[Module]s(int ModuleId)
{
return _db.[Module].Where(item => item.ModuleId == ModuleId);
}
- public [Module] Get[Module](int [Module]Id)
+ public Models.[Module] Get[Module](int [Module]Id)
{
return _db.[Module].Find([Module]Id);
}
- public [Module] Add[Module]([Module] [Module])
+ public Models.[Module] Add[Module](Models.[Module] [Module])
{
_db.[Module].Add([Module]);
_db.SaveChanges();
return [Module];
}
- public [Module] Update[Module]([Module] [Module])
+ public Models.[Module] Update[Module](Models.[Module] [Module])
{
_db.Entry([Module]).State = EntityState.Modified;
_db.SaveChanges();
@@ -41,7 +41,7 @@ namespace [Owner].[Module]s.Repository
public void Delete[Module](int [Module]Id)
{
- [Module] [Module] = _db.[Module].Find([Module]Id);
+ Models.[Module] [Module] = _db.[Module].Find([Module]Id);
_db.[Module].Remove([Module]);
_db.SaveChanges();
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module]s.1.0.0.sql b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module].1.0.0.sql
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module]s.1.0.0.sql
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module].1.0.0.sql
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module]s.Uninstall.sql b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module].Uninstall.sql
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module]s.Uninstall.sql
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Server/Scripts/[Owner].[Module].Uninstall.sql
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module]s.Server.csproj b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module].Server.csproj
similarity index 68%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module]s.Server.csproj
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module].Server.csproj
index 4d0ae486..8d6f5b57 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module]s.Server.csproj
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/[Owner].[Module].Server.csproj
@@ -5,17 +5,17 @@
7.3
true
1.0.0
- [Owner].[Module]s
+ [Owner].[Module]
[Owner]
[Owner]
[Description]
[Owner]
- [Owner].[Module]s.Server.Oqtane
+ [Owner].[Module].Server.Oqtane
-
-
+
+
@@ -27,11 +27,11 @@
-
+
-
-
+
+
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/Module.css b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]/Module.css
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/Module.css
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]/Module.css
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/Module.js b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]/Module.js
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/Module.js
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]/Module.js
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/resources.txt b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/resources.txt
deleted file mode 100644
index 903815cf..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/wwwroot/Modules/[Owner].[Module]s/resources.txt
+++ /dev/null
@@ -1 +0,0 @@
-This is the location where static resources such as images, style sheets, or scripts for this module will be located. Static assets can be organized in subfolders. When the module package is deployed the assets will be extracted under the web root in a folder that matches the module namespace.
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/Models/[Module].cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/Models/[Module].cs
index 5a6d7896..94f73ffa 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/Models/[Module].cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/Models/[Module].cs
@@ -2,7 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations.Schema;
using Oqtane.Models;
-namespace [Owner].[Module]s.Models
+namespace [Owner].[Module].Models
{
[Table("[Owner][Module]")]
public class [Module] : IAuditable
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module]s.Shared.csproj b/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module].Shared.csproj
similarity index 74%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module]s.Shared.csproj
rename to Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module].Shared.csproj
index 72da9ca8..0e62a189 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module]s.Shared.csproj
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Shared/[Owner].[Module].Shared.csproj
@@ -4,12 +4,12 @@
netstandard2.1
7.3
1.0.0
- [Owner].[Module]s
+ [Owner].[Module]
[Owner]
[Owner]
[Description]
[Owner]
- [Owner].[Module]s.Shared.Oqtane
+ [Owner].[Module].Shared.Oqtane
@@ -17,7 +17,7 @@
-
+
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module]s.sln b/Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module].sln
similarity index 87%
rename from Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module]s.sln
rename to Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module].sln
index eb313e64..b06b40c0 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module]s.sln
+++ b/Oqtane.Server/wwwroot/Modules/Templates/External/[Owner].[Module].sln
@@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28621.142
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Client", "Client\[Owner].[Module]s.Client.csproj", "{AA8E58A1-CD09-4208-BF66-A8BB341FD669}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module].Client", "Client\[Owner].[Module].Client.csproj", "{AA8E58A1-CD09-4208-BF66-A8BB341FD669}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Server", "Server\[Owner].[Module]s.Server.csproj", "{04B05448-788F-433D-92C0-FED35122D45A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module].Server", "Server\[Owner].[Module].Server.csproj", "{04B05448-788F-433D-92C0-FED35122D45A}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Shared", "Shared\[Owner].[Module]s.Shared.csproj", "{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module].Shared", "Shared\[Owner].[Module].Shared.csproj", "{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "[Owner].[Module]s.Package", "Package\[Owner].[Module]s.Package.csproj", "{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "[Owner].[Module].Package", "Package\[Owner].[Module].Package.csproj", "{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Edit.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor
similarity index 87%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Edit.razor
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor
index 525590f5..cd845092 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Edit.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor
@@ -1,8 +1,8 @@
@using Oqtane.Modules.Controls
-@using [Owner].[Module]s.Services
-@using [Owner].[Module]s.Models
+@using [Owner].[Module].Services
+@using [Owner].[Module].Models
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager
@@ -28,8 +28,16 @@
@code {
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
+
public override string Actions => "Add,Edit";
+ public override string Title => "Manage [Module]";
+
+ public override List Resources => new List()
+ {
+ new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
+ };
+
int _id;
string _name;
string _createdby;
@@ -44,7 +52,7 @@
if (PageState.Action == "Edit")
{
_id = Int32.Parse(PageState.QueryString["id"]);
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id);
+ [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
if ([Module] != null)
{
_name = [Module].Name;
@@ -76,7 +84,7 @@
}
else
{
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id);
+ [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
[Module].Name = _name;
await [Module]Service.Update[Module]Async([Module]);
await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Index.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor
similarity index 82%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Index.razor
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor
index b683abf4..5f8f04e2 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Index.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor
@@ -1,7 +1,7 @@
-@using [Owner].[Module]s.Services
-@using [Owner].[Module]s.Models
+@using [Owner].[Module].Services
+@using [Owner].[Module].Models
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager
@@ -17,16 +17,16 @@ else
@if (@_[Module]s.Count != 0)
{
-
+
-
+
+
+ @context.Name
}
@@ -61,6 +61,11 @@ else
@code {
+ public override List Resources => new List()
+ {
+ new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
+ };
+
List<[Module]> _[Module]s;
protected override async Task OnInitializedAsync()
@@ -80,7 +85,7 @@ else
{
try
{
- await [Module]Service.Delete[Module]Async([Module].[Module]Id);
+ await [Module]Service.Delete[Module]Async([Module].[Module]Id, ModuleState.ModuleId);
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
StateHasChanged();
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/ModuleInfo.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs
similarity index 93%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/ModuleInfo.cs
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs
index 17af8d41..6586d51d 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/ModuleInfo.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs
@@ -1,7 +1,7 @@
using Oqtane.Models;
using Oqtane.Modules;
-namespace [Owner].[Module]s
+namespace [Owner].[Module]
{
public class ModuleInfo : IModule
{
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs
new file mode 100644
index 00000000..601eba6a
--- /dev/null
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using [Owner].[Module].Models;
+
+namespace [Owner].[Module].Services
+{
+ public interface I[Module]Service
+ {
+ Task> Get[Module]sAsync(int ModuleId);
+
+ Task Get[Module]Async(int [Module]Id, int ModuleId);
+
+ Task Add[Module]Async(Models.[Module] [Module]);
+
+ Task Update[Module]Async(Models.[Module] [Module]);
+
+ Task Delete[Module]Async(int [Module]Id, int ModuleId);
+ }
+}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs
new file mode 100644
index 00000000..05a85ac7
--- /dev/null
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Oqtane.Modules;
+using Oqtane.Services;
+using Oqtane.Shared;
+using [Owner].[Module].Models;
+
+namespace [Owner].[Module].Services
+{
+ public class [Module]Service : ServiceBase, I[Module]Service, IService
+ {
+ private readonly SiteState _siteState;
+
+ public [Module]Service(HttpClient http, SiteState siteState) : base(http)
+ {
+ _siteState = siteState;
+ }
+
+ private string Apiurl => CreateApiUrl(_siteState.Alias, "[Module]");
+
+ public async Task> Get[Module]sAsync(int ModuleId)
+ {
+ List [Module]s = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", ModuleId));
+ return [Module]s.OrderBy(item => item.Name).ToList();
+ }
+
+ public async Task Get[Module]Async(int [Module]Id, int ModuleId)
+ {
+ return await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
+ }
+
+ public async Task Add[Module]Async(Models.[Module] [Module])
+ {
+ return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", [Module].ModuleId), [Module]);
+ }
+
+ public async Task Update[Module]Async(Models.[Module] [Module])
+ {
+ return await PutJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module].[Module]Id}", [Module].ModuleId), [Module]);
+ }
+
+ public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
+ {
+ await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
+ }
+ }
+}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Settings.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor
similarity index 97%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Settings.razor
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor
index fac25c7e..415b24ca 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Settings.razor
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor
@@ -1,4 +1,4 @@
-@namespace [Owner].[Module]s
+@namespace [Owner].[Module]
@inherits ModuleBase
@inject ISettingService SettingService
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/I[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/I[Module]Service.cs
deleted file mode 100644
index e98da06d..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/I[Module]Service.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using [Owner].[Module]s.Models;
-
-namespace [Owner].[Module]s.Services
-{
- public interface I[Module]Service
- {
- Task> Get[Module]sAsync(int ModuleId);
-
- Task<[Module]> Get[Module]Async(int [Module]Id);
-
- Task<[Module]> Add[Module]Async([Module] [Module]);
-
- Task<[Module]> Update[Module]Async([Module] [Module]);
-
- Task Delete[Module]Async(int [Module]Id);
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/[Module]Service.cs
deleted file mode 100644
index f95c41b9..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]s/Services/[Module]Service.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Oqtane.Modules;
-using Oqtane.Services;
-using Oqtane.Shared;
-using [Owner].[Module]s.Models;
-
-namespace [Owner].[Module]s.Services
-{
- public class [Module]Service : ServiceBase, I[Module]Service, IService
- {
- private readonly SiteState _siteState;
-
- public [Module]Service(HttpClient http, SiteState siteState) : base(http)
- {
- _siteState = siteState;
- }
-
- private string Apiurl=> CreateApiUrl(_siteState.Alias, "[Module]");
-
- public async Task> Get[Module]sAsync(int ModuleId)
- {
- List<[Module]> [Module]s = await GetJsonAsync>($"{Apiurl}?moduleid={ModuleId}");
- return [Module]s.OrderBy(item => item.Name).ToList();
- }
-
- public async Task<[Module]> Get[Module]Async(int [Module]Id)
- {
- return await GetJsonAsync<[Module]>($"{Apiurl}/{[Module]Id}");
- }
-
- public async Task<[Module]> Add[Module]Async([Module] [Module])
- {
- return await PostJsonAsync<[Module]>($"{Apiurl}?entityid={[Module].ModuleId}", [Module]);
- }
-
- public async Task<[Module]> Update[Module]Async([Module] [Module])
- {
- return await PutJsonAsync<[Module]>($"{Apiurl}/{[Module].[Module]Id}?entityid={[Module].ModuleId}", [Module]);
- }
-
- public async Task Delete[Module]Async(int [Module]Id)
- {
- await DeleteAsync($"{Apiurl}/{[Module]Id}");
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs
new file mode 100644
index 00000000..c8fe7485
--- /dev/null
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs
@@ -0,0 +1,91 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Authorization;
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Http;
+using Oqtane.Shared;
+using Oqtane.Enums;
+using Oqtane.Infrastructure;
+using [Owner].[Module].Models;
+using [Owner].[Module].Repository;
+
+namespace [Owner].[Module].Controllers
+{
+ [Route("{alias}/api/[controller]")]
+ public class [Module]Controller : Controller
+ {
+ private readonly I[Module]Repository _[Module]Repository;
+ private readonly ILogManager _logger;
+ protected int _entityId = -1;
+
+ public [Module]Controller(I[Module]Repository [Module]Repository, ILogManager logger, IHttpContextAccessor accessor)
+ {
+ _[Module]Repository = [Module]Repository;
+ _logger = logger;
+
+ if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
+ {
+ _entityId = int.Parse(accessor.HttpContext.Request.Query["entityid"]);
+ }
+ }
+
+ // GET: api/?moduleid=x
+ [HttpGet]
+ [Authorize(Policy = "ViewModule")]
+ public IEnumerable Get(string moduleid)
+ {
+ return _[Module]Repository.Get[Module]s(int.Parse(moduleid));
+ }
+
+ // GET api//5
+ [HttpGet("{id}")]
+ [Authorize(Policy = "ViewModule")]
+ public Models.[Module] Get(int id)
+ {
+ Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
+ if ([Module] != null && [Module].ModuleId != _entityId)
+ {
+ [Module] = null;
+ }
+ return [Module];
+ }
+
+ // POST api/
+ [HttpPost]
+ [Authorize(Policy = "EditModule")]
+ public Models.[Module] Post([FromBody] Models.[Module] [Module])
+ {
+ if (ModelState.IsValid && [Module].ModuleId == _entityId)
+ {
+ [Module] = _[Module]Repository.Add[Module]([Module]);
+ _logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
+ }
+ return [Module];
+ }
+
+ // PUT api//5
+ [HttpPut("{id}")]
+ [Authorize(Policy = "EditModule")]
+ public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module])
+ {
+ if (ModelState.IsValid && [Module].ModuleId == _entityId)
+ {
+ [Module] = _[Module]Repository.Update[Module]([Module]);
+ _logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
+ }
+ return [Module];
+ }
+
+ // DELETE api//5
+ [HttpDelete("{id}")]
+ [Authorize(Policy = "EditModule")]
+ public void Delete(int id)
+ {
+ Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
+ if ([Module] != null && [Module].ModuleId == _entityId)
+ {
+ _[Module]Repository.Delete[Module](id);
+ _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
+ }
+ }
+ }
+}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs
new file mode 100644
index 00000000..486c8ddf
--- /dev/null
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs
@@ -0,0 +1,61 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using Oqtane.Modules;
+using Oqtane.Models;
+using Oqtane.Infrastructure;
+using Oqtane.Repository;
+using [Owner].[Module].Models;
+using [Owner].[Module].Repository;
+
+namespace [Owner].[Module].Manager
+{
+ public class [Module]Manager : IInstallable, IPortable
+ {
+ private I[Module]Repository _[Module]Repository;
+ private ISqlRepository _sql;
+
+ public [Module]Manager(I[Module]Repository [Module]Repository, ISqlRepository sql)
+ {
+ _[Module]Repository = [Module]Repository;
+ _sql = sql;
+ }
+
+ public bool Install(Tenant tenant, string version)
+ {
+ return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]." + version + ".sql");
+ }
+
+ public bool Uninstall(Tenant tenant)
+ {
+ return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module].Uninstall.sql");
+ }
+
+ public string ExportModule(Module module)
+ {
+ string content = "";
+ List [Module]s = _[Module]Repository.Get[Module]s(module.ModuleId).ToList();
+ if ([Module]s != null)
+ {
+ content = JsonSerializer.Serialize([Module]s);
+ }
+ return content;
+ }
+
+ public void ImportModule(Module module, string content, string version)
+ {
+ List [Module]s = null;
+ if (!string.IsNullOrEmpty(content))
+ {
+ [Module]s = JsonSerializer.Deserialize>(content);
+ }
+ if ([Module]s != null)
+ {
+ foreach(var [Module] in [Module]s)
+ {
+ _[Module]Repository.Add[Module](new Models.[Module] { ModuleId = module.ModuleId, Name = [Module].Name });
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs
new file mode 100644
index 00000000..52b7913a
--- /dev/null
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using [Owner].[Module].Models;
+
+namespace [Owner].[Module].Repository
+{
+ public interface I[Module]Repository
+ {
+ IEnumerable Get[Module]s(int ModuleId);
+ Models.[Module] Get[Module](int [Module]Id);
+ Models.[Module] Add[Module](Models.[Module] [Module]);
+ Models.[Module] Update[Module](Models.[Module] [Module]);
+ void Delete[Module](int [Module]Id);
+ }
+}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Context.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs
similarity index 74%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Context.cs
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs
index 2a14bbf4..a10d7219 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Context.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs
@@ -2,13 +2,13 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Http;
using Oqtane.Modules;
using Oqtane.Repository;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Repository
+namespace [Owner].[Module].Repository
{
public class [Module]Context : DBContextBase, IService
{
- public virtual DbSet<[Module]> [Module] { get; set; }
+ public virtual DbSet [Module] { get; set; }
public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
{
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs
similarity index 69%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Repository.cs
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs
index 9b83b239..9c8c3628 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/[Module]Repository.cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs
@@ -2,9 +2,9 @@ using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections.Generic;
using Oqtane.Modules;
-using [Owner].[Module]s.Models;
+using [Owner].[Module].Models;
-namespace [Owner].[Module]s.Repository
+namespace [Owner].[Module].Repository
{
public class [Module]Repository : I[Module]Repository, IService
{
@@ -15,24 +15,24 @@ namespace [Owner].[Module]s.Repository
_db = context;
}
- public IEnumerable<[Module]> Get[Module]s(int ModuleId)
+ public IEnumerable Get[Module]s(int ModuleId)
{
return _db.[Module].Where(item => item.ModuleId == ModuleId);
}
- public [Module] Get[Module](int [Module]Id)
+ public Models.[Module] Get[Module](int [Module]Id)
{
return _db.[Module].Find([Module]Id);
}
- public [Module] Add[Module]([Module] [Module])
+ public Models.[Module] Add[Module](Models.[Module] [Module])
{
_db.[Module].Add([Module]);
_db.SaveChanges();
return [Module];
}
- public [Module] Update[Module]([Module] [Module])
+ public Models.[Module] Update[Module](Models.[Module] [Module])
{
_db.Entry([Module]).State = EntityState.Modified;
_db.SaveChanges();
@@ -41,7 +41,7 @@ namespace [Owner].[Module]s.Repository
public void Delete[Module](int [Module]Id)
{
- [Module] [Module] = _db.[Module].Find([Module]Id);
+ Models.[Module] [Module] = _db.[Module].Find([Module]Id);
_db.[Module].Remove([Module]);
_db.SaveChanges();
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Scripts/[Owner].[Module]s.1.0.0.sql b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].1.0.0.sql
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Scripts/[Owner].[Module]s.1.0.0.sql
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].1.0.0.sql
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Scripts/[Owner].[Module]s.Uninstall.sql b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].Uninstall.sql
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Scripts/[Owner].[Module]s.Uninstall.sql
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].Uninstall.sql
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs
deleted file mode 100644
index 1ff6a0ab..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Authorization;
-using System.Collections.Generic;
-using Oqtane.Shared;
-using Oqtane.Enums;
-using Oqtane.Infrastructure;
-using [Owner].[Module]s.Models;
-using [Owner].[Module]s.Repository;
-
-namespace [Owner].[Module]s.Controllers
-{
- [Route("{site}/api/[controller]")]
- public class [Module]Controller : Controller
- {
- private readonly I[Module]Repository _[Module]s;
- private readonly ILogManager _logger;
-
- public [Module]Controller(I[Module]Repository [Module]s, ILogManager logger)
- {
- _[Module]s = [Module]s;
- _logger = logger;
- }
-
- // GET: api/?moduleid=x
- [HttpGet]
- [Authorize(Roles = Constants.RegisteredRole)]
- public IEnumerable<[Module]> Get(string moduleid)
- {
- return _[Module]s.Get[Module]s(int.Parse(moduleid));
- }
-
- // GET api//5
- [HttpGet("{id}")]
- [Authorize(Roles = Constants.RegisteredRole)]
- public [Module] Get(int id)
- {
- return _[Module]s.Get[Module](id);
- }
-
- // POST api/
- [HttpPost]
- [Authorize(Roles = Constants.AdminRole)]
- public [Module] Post([FromBody] [Module] [Module])
- {
- if (ModelState.IsValid)
- {
- [Module] = _[Module]s.Add[Module]([Module]);
- _logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
- }
- return [Module];
- }
-
- // PUT api//5
- [HttpPut("{id}")]
- [Authorize(Roles = Constants.AdminRole)]
- public [Module] Put(int id, [FromBody] [Module] [Module])
- {
- if (ModelState.IsValid)
- {
- [Module] = _[Module]s.Update[Module]([Module]);
- _logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
- }
- return [Module];
- }
-
- // DELETE api//5
- [HttpDelete("{id}")]
- [Authorize(Roles = Constants.AdminRole)]
- public void Delete(int id)
- {
- _[Module]s.Delete[Module](id);
- _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Manager/[Module]Manager.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Manager/[Module]Manager.cs
deleted file mode 100644
index ba4f667c..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Manager/[Module]Manager.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.Json;
-using Oqtane.Modules;
-using Oqtane.Models;
-using Oqtane.Infrastructure;
-using Oqtane.Repository;
-using [Owner].[Module]s.Models;
-using [Owner].[Module]s.Repository;
-
-namespace [Owner].[Module]s.Manager
-{
- public class [Module]Manager : IPortable
- {
- private I[Module]Repository _[Module]s;
-
- public [Module]Manager(I[Module]Repository [Module]s)
- {
- _[Module]s = [Module]s;
- }
-
- public string ExportModule(Module module)
- {
- string content = "";
- List<[Module]> [Module]s = _[Module]s.Get[Module]s(module.ModuleId).ToList();
- if ([Module]s != null)
- {
- content = JsonSerializer.Serialize([Module]s);
- }
- return content;
- }
-
- public void ImportModule(Module module, string content, string version)
- {
- List<[Module]> [Module]s = null;
- if (!string.IsNullOrEmpty(content))
- {
- [Module]s = JsonSerializer.Deserialize>(content);
- }
- if ([Module]s != null)
- {
- foreach([Module] [Module] in [Module]s)
- {
- [Module] _[Module] = new [Module]();
- _[Module].ModuleId = module.ModuleId;
- _[Module].Name = [Module].Name;
- _[Module]s.Add[Module](_[Module]);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/I[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/I[Module]Repository.cs
deleted file mode 100644
index f38a60d5..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Repository/I[Module]Repository.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Collections.Generic;
-using [Owner].[Module]s.Models;
-
-namespace [Owner].[Module]s.Repository
-{
- public interface I[Module]Repository
- {
- IEnumerable<[Module]> Get[Module]s(int ModuleId);
- [Module] Get[Module](int [Module]Id);
- [Module] Add[Module]([Module] [Module]);
- [Module] Update[Module]([Module] [Module]);
- void Delete[Module](int [Module]Id);
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/Module.css b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.css
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/Module.css
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.css
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/Module.js b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.js
similarity index 100%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/Module.js
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.js
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/resources.txt b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/resources.txt
deleted file mode 100644
index 903815cf..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]s/resources.txt
+++ /dev/null
@@ -1 +0,0 @@
-This is the location where static resources such as images, style sheets, or scripts for this module will be located. Static assets can be organized in subfolders. When the module package is deployed the assets will be extracted under the web root in a folder that matches the module namespace.
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]s/Models/[Module].cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs
similarity index 93%
rename from Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]s/Models/[Module].cs
rename to Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs
index 5a6d7896..94f73ffa 100644
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]s/Models/[Module].cs
+++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs
@@ -2,7 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations.Schema;
using Oqtane.Models;
-namespace [Owner].[Module]s.Models
+namespace [Owner].[Module].Models
{
[Table("[Owner][Module]")]
public class [Module] : IAuditable
diff --git a/Oqtane.Server/wwwroot/app_offline.bak b/Oqtane.Server/wwwroot/app_offline.bak
index d26d5e2b..e4ec3791 100644
--- a/Oqtane.Server/wwwroot/app_offline.bak
+++ b/Oqtane.Server/wwwroot/app_offline.bak
@@ -9,8 +9,8 @@
-
Please Wait... Upgrade In Progress....
-
+
+
Please Wait... Upgrade In Progress....