commit
e34ffb716d
53
.editorconfig
Normal file
53
.editorconfig
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = crlf
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{json,csproj,props,targets}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.cs]
|
||||||
|
# Prefer "var" everywhere
|
||||||
|
csharp_style_var_for_built_in_types = true : suggestion
|
||||||
|
csharp_style_var_when_type_is_apparent = true : suggestion
|
||||||
|
csharp_style_var_elsewhere = true : suggestion
|
||||||
|
|
||||||
|
# Newline settings
|
||||||
|
csharp_new_line_before_open_brace = all
|
||||||
|
csharp_new_line_before_else = true
|
||||||
|
csharp_new_line_before_catch = true
|
||||||
|
csharp_new_line_before_finally = true
|
||||||
|
csharp_new_line_before_members_in_object_initializers = true
|
||||||
|
csharp_new_line_before_members_in_anonymous_types = true
|
||||||
|
|
||||||
|
# Sort using and Import directives with System.* appearing first
|
||||||
|
dotnet_sort_system_directives_first = true
|
||||||
|
|
||||||
|
# Avoid "this." if not necessary
|
||||||
|
dotnet_style_qualification_for_field = false : suggestion
|
||||||
|
dotnet_style_qualification_for_property = false : suggestion
|
||||||
|
dotnet_style_qualification_for_method = false : suggestion
|
||||||
|
dotnet_style_qualification_for_event = false : suggestion
|
||||||
|
|
||||||
|
# Use language keywords instead of framework type names for type references
|
||||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion
|
||||||
|
dotnet_style_predefined_type_for_member_access = false : suggestion
|
||||||
|
|
||||||
|
# Suggest more modern language features when available
|
||||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true : none
|
||||||
|
csharp_style_pattern_matching_over_as_with_null_check = true : none
|
||||||
|
csharp_style_inlined_variable_declaration = true : none
|
||||||
|
csharp_style_throw_expression = true : none
|
||||||
|
csharp_style_conditional_delegate_call = true : none
|
||||||
|
|
||||||
|
dotnet_style_object_initializer = true : suggestion
|
||||||
|
dotnet_style_collection_initializer = true : suggestion
|
||||||
|
dotnet_style_coalesce_expression = true : suggestion
|
||||||
|
dotnet_style_null_propagation = true : suggestion
|
||||||
|
dotnet_style_explicit_tuple_names = true : suggestion
|
||||||
|
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
3
Oqtane.Client/AssemblyInfo.cs
Normal file
3
Oqtane.Client/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
|
[assembly: RootNamespace("Oqtane")]
|
|
@ -8,7 +8,7 @@
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Module module = await ModuleService.GetModuleAsync(ModuleState.ModuleId);
|
Module module = await ModuleService.GetModuleAsync(ModuleState.ModuleId);
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, Constants.HostRole))
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
string message = "A Problem Was Encountered Loading Module " + module.ModuleDefinitionName;
|
string message = "A Problem Was Encountered Loading Module " + module.ModuleDefinitionName;
|
||||||
AddModuleMessage(message, MessageType.Error);
|
AddModuleMessage(message, MessageType.Error);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@namespace Oqtane.Modules.Admin.Files
|
@namespace Oqtane.Modules.Admin.Files
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IFolderService FolderService
|
@inject IFolderService FolderService
|
||||||
|
@inject IFileService FileService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
@if (_folders != null)
|
@if (_folders != null)
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
@if (!_isSystem && PageState.QueryString.ContainsKey("id"))
|
@if (!_isSystem && PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-danger" @onclick="DeleteFolder">Delete</button>
|
<ActionDialog Header="Delete Folder" Message="@("Are You Sure You Wish To Delete This Folder?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteFolder())" />
|
||||||
}
|
}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
@ -192,6 +193,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isparent)
|
if (!isparent)
|
||||||
|
{
|
||||||
|
var files = await FileService.GetFilesAsync(_folderId);
|
||||||
|
if (files.Count == 0)
|
||||||
{
|
{
|
||||||
await FolderService.DeleteFolderAsync(_folderId);
|
await FolderService.DeleteFolderAsync(_folderId);
|
||||||
await logger.LogInformation("Folder Deleted {Folder}", _folderId);
|
await logger.LogInformation("Folder Deleted {Folder}", _folderId);
|
||||||
|
@ -199,7 +203,12 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage("Folder Has Child Folders And Cannot Be Deleted", MessageType.Warning);
|
AddModuleMessage("Folder Has Files And Cannot Be Deleted", MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage("Folder Has Subfolders And Cannot Be Deleted", MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Admin.Login
|
@namespace Oqtane.Modules.Admin.Login
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
<ModuleMessage Message="You Are Already Logged In" Type="MessageType.Info" />
|
<ModuleMessage Message="You Are Already Logged In" Type="MessageType.Info" />
|
||||||
</Authorized>
|
</Authorized>
|
||||||
<NotAuthorized>
|
<NotAuthorized>
|
||||||
<div class="container">
|
<div class="container Oqtane-Modules-Admin-Login">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Username" class="control-label">Username: </label>
|
<label for="Username" class="control-label">Username: </label>
|
||||||
<input type="text" name="Username" class="form-control" placeholder="Username" @bind="@_username" id="Username" />
|
<input type="text" name="Username" class="form-control username" placeholder="Username" @bind="@_username" id="Username" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Password" class="control-label">Password: </label>
|
<label for="Password" class="control-label">Password: </label>
|
||||||
<input type="password" name="Password" class="form-control" placeholder="Password" @bind="@_password" id="Password" />
|
<input type="password" name="Password" class="form-control password" placeholder="Password" @bind="@_password" id="Password" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
|
@ -49,6 +49,11 @@
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
||||||
|
|
||||||
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
|
{
|
||||||
|
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
||||||
|
};
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (PageState.QueryString.ContainsKey("returnurl"))
|
if (PageState.QueryString.ContainsKey("returnurl"))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
@namespace Oqtane.Modules.Admin.ModuleCreator
|
@namespace Oqtane.Modules.Admin.ModuleCreator
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject ISystemService SystemService
|
@inject ISystemService SystemService
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation.">Owner Name: </Label>
|
<Label For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation.">Owner Name: </Label>
|
||||||
|
@ -42,6 +42,23 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="reference" HelpText="Select a framework reference version">Framework Reference: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="reference" class="form-control" @bind="@_reference">
|
||||||
|
@foreach (string version in Constants.ReleaseVersions.Split(','))
|
||||||
|
{
|
||||||
|
if (Version.Parse(version).CompareTo(Version.Parse("2.0.0")) >= 0)
|
||||||
|
{
|
||||||
|
<option value="@(version)">@(version)</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<option value="local">Local Version</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@if (!string.IsNullOrEmpty(_location))
|
@if (!string.IsNullOrEmpty(_location))
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -53,7 +70,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
|
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
|
||||||
|
|
||||||
|
@ -62,13 +79,14 @@
|
||||||
private string _module = string.Empty;
|
private string _module = string.Empty;
|
||||||
private string _description = string.Empty;
|
private string _description = string.Empty;
|
||||||
private string _template = "-";
|
private string _template = "-";
|
||||||
|
public string _reference = Constants.Version;
|
||||||
private string _location = string.Empty;
|
private string _location = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
AddModuleMessage("Please Note That Once You Select The Create Module Button The Application Must Restart In Order To Complete The Process. If You Create An External Module You Will Need To Compile The Source Code In Order To Make It Functional.", MessageType.Info);
|
AddModuleMessage("Please Note That Once You Select The Create Module Button The Application Must Restart In Order To Complete The Process. If You Create An External Module You Will Need To Compile The Source Code And Then Relaunch Your Site In Order To Make It Functional.", MessageType.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateModule()
|
private async Task CreateModule()
|
||||||
|
@ -77,7 +95,11 @@
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && _template != "-")
|
if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && _template != "-")
|
||||||
{
|
{
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ", ""), Name = _module.Replace(" ", ""), Description = _description, Template = _template };
|
ShowProgressIndicator();
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
await interop.RedirectBrowser(NavigateUrl(), 5);
|
||||||
|
|
||||||
|
var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ", ""), Name = _module.Replace(" ", ""), Description = _description, Template = _template, Version = _reference };
|
||||||
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -105,11 +127,11 @@
|
||||||
string[] path = systeminfo["serverpath"].Split('\\');
|
string[] path = systeminfo["serverpath"].Split('\\');
|
||||||
if (_template == "internal")
|
if (_template == "internal")
|
||||||
{
|
{
|
||||||
_location = string.Join("\\", path, 0, path.Length - 1) + "\\Oqtane.Client\\Modules\\" + _owner + "." + _module + "s";
|
_location = string.Join("\\", path, 0, path.Length - 1) + "\\Oqtane.Client\\Modules\\" + _owner + "." + _module;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_location = string.Join("\\", path, 0, path.Length - 2) + "\\" + _owner + "." + _module + "s";
|
_location = string.Join("\\", path, 0, path.Length - 2) + "\\" + _owner + "." + _module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@
|
||||||
Page page = null;
|
Page page = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
|
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || _layouttype != "-"))
|
||||||
{
|
{
|
||||||
page = new Page();
|
page = new Page();
|
||||||
page.SiteId = PageState.Page.SiteId;
|
page.SiteId = PageState.Page.SiteId;
|
||||||
|
@ -389,7 +389,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage("You Must Provide Page Name And Theme", MessageType.Warning);
|
AddModuleMessage("You Must Provide Page Name And Theme/Layout", MessageType.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Admin.Profiles
|
@namespace Oqtane.Modules.Admin.Profiles
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IProfileService ProfileService
|
@inject IProfileService ProfileService
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="name" HelpText="The name of this field">Name: </Label>
|
<Label For="name" HelpText="The name of this profile item">Name: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
<input id="name" class="form-control" @bind="@_name" />
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="title" HelpText="The title of the field">Title: </Label>
|
<Label For="title" HelpText="The title of the profile item to display to the user">Title: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="title" class="form-control" @bind="@_title" />
|
<input id="title" class="form-control" @bind="@_title" />
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="description" HelpText="What the profile field is">Description: </Label>
|
<Label For="description" HelpText="The help text displayed to the user for this profile item">Description: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="5"></textarea>
|
<textarea id="description" class="form-control" @bind="@_description" rows="5"></textarea>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="category" HelpText="What larger category does this field belong to">Category: </Label>
|
<Label For="category" HelpText="The category of this profile item (for grouping)">Category: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="category" class="form-control" @bind="@_category" />
|
<input id="category" class="form-control" @bind="@_category" />
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="order" HelpText="What place is this field in a larger category list">Order: </Label>
|
<Label For="order" HelpText="The index order of where this profile item should be displayed">Order: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="order" class="form-control" @bind="@_vieworder" />
|
<input id="order" class="form-control" @bind="@_vieworder" />
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="length" HelpText="What is the max amount of characters should this field accept">Length: </Label>
|
<Label For="length" HelpText="The max number of characters this profile item should accept (enter zero for unlimited)">Length: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="length" class="form-control" @bind="@_maxlength" />
|
<input id="length" class="form-control" @bind="@_maxlength" />
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="defaultVal" HelpText="What value do you want this field to start with">Default Value: </Label>
|
<Label For="defaultVal" HelpText="The default value for this profile item">Default Value: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" />
|
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" />
|
||||||
|
@ -62,7 +62,15 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="required" HelpText="Is a user required to input something into this field?">Required? </Label>
|
<Label For="options" HelpText="A comma delimited list of options the user can select from">Options: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="options" class="form-control" @bind="@_options" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="required" HelpText="Should a user be required to provide a value for this profile item?">Required? </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="required" class="form-control" @bind="@_isrequired">
|
<select id="required" class="form-control" @bind="@_isrequired">
|
||||||
|
@ -73,7 +81,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="private" HelpText="Is this field private?">Private? </Label>
|
<Label For="private" HelpText="Should this profile item be visible to all users?">Private? </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="private" class="form-control" @bind="@_isprivate">
|
<select id="private" class="form-control" @bind="@_isprivate">
|
||||||
|
@ -95,6 +103,7 @@
|
||||||
private string _vieworder = "0";
|
private string _vieworder = "0";
|
||||||
private string _maxlength = "0";
|
private string _maxlength = "0";
|
||||||
private string _defaultvalue = string.Empty;
|
private string _defaultvalue = string.Empty;
|
||||||
|
private string _options = string.Empty;
|
||||||
private string _isrequired = "False";
|
private string _isrequired = "False";
|
||||||
private string _isprivate = "False";
|
private string _isprivate = "False";
|
||||||
|
|
||||||
|
@ -119,6 +128,7 @@
|
||||||
_vieworder = profile.ViewOrder.ToString();
|
_vieworder = profile.ViewOrder.ToString();
|
||||||
_maxlength = profile.MaxLength.ToString();
|
_maxlength = profile.MaxLength.ToString();
|
||||||
_defaultvalue = profile.DefaultValue;
|
_defaultvalue = profile.DefaultValue;
|
||||||
|
_options = profile.Options;
|
||||||
_isrequired = profile.IsRequired.ToString();
|
_isrequired = profile.IsRequired.ToString();
|
||||||
_isprivate = profile.IsPrivate.ToString();
|
_isprivate = profile.IsPrivate.ToString();
|
||||||
}
|
}
|
||||||
|
@ -153,6 +163,7 @@
|
||||||
profile.ViewOrder = int.Parse(_vieworder);
|
profile.ViewOrder = int.Parse(_vieworder);
|
||||||
profile.MaxLength = int.Parse(_maxlength);
|
profile.MaxLength = int.Parse(_maxlength);
|
||||||
profile.DefaultValue = _defaultvalue;
|
profile.DefaultValue = _defaultvalue;
|
||||||
|
profile.Options = _options;
|
||||||
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
||||||
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
||||||
if (_profileid != -1)
|
if (_profileid != -1)
|
||||||
|
|
|
@ -88,7 +88,7 @@ else
|
||||||
Role role = await RoleService.GetRoleAsync(roleid);
|
Role role = await RoleService.GetRoleAsync(roleid);
|
||||||
name = role.Name;
|
name = role.Name;
|
||||||
users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
users = users.Where(item => item.Role.Name == Constants.RegisteredRole).ToList();
|
users = users.Where(item => item.Role.Name == RoleNames.Registered).ToList();
|
||||||
await GetUserRoles();
|
await GetUserRoles();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -448,7 +448,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Container", MessageType.Warning);
|
AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Layout/Container", MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -216,7 +216,7 @@ else
|
||||||
private string _username = string.Empty;
|
private string _username = string.Empty;
|
||||||
private string _password = string.Empty;
|
private string _password = string.Empty;
|
||||||
private bool _integratedsecurity = true;
|
private bool _integratedsecurity = true;
|
||||||
private string _hostusername = Constants.HostUser;
|
private string _hostusername = UserNames.Host;
|
||||||
private string _hostpassword = string.Empty;
|
private string _hostpassword = string.Empty;
|
||||||
|
|
||||||
private string _name = string.Empty;
|
private string _name = string.Empty;
|
||||||
|
@ -311,7 +311,7 @@ else
|
||||||
// validate host credentials
|
// validate host credentials
|
||||||
var user = new User();
|
var user = new User();
|
||||||
user.SiteId = PageState.Site.SiteId;
|
user.SiteId = PageState.Site.SiteId;
|
||||||
user.Username = Constants.HostUser;
|
user.Username = UserNames.Host;
|
||||||
user.Password = _hostpassword;
|
user.Password = _hostpassword;
|
||||||
user = await UserService.LoginUserAsync(user, false, false);
|
user = await UserService.LoginUserAsync(user, false, false);
|
||||||
if (user.IsAuthenticated)
|
if (user.IsAuthenticated)
|
||||||
|
@ -402,7 +402,7 @@ else
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Container, And Site Template", MessageType.Warning);
|
AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Layout/Container, And Site Template", MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<Label For="name" HelpText="The name of the tenant">Name: </Label>
|
<Label For="name" HelpText="The name of the tenant">Name: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (name == Constants.MasterTenant)
|
@if (name == TenantNames.Master)
|
||||||
{
|
{
|
||||||
<input id="name" class="form-control" @bind="@name" readonly />
|
<input id="name" class="form-control" @bind="@name" readonly />
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ else
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.TenantId.ToString())" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.TenantId.ToString())" /></td>
|
||||||
<td><ActionDialog Header="Delete Tenant" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Tenant?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTenant(context))" Disabled="@(context.Name == Constants.MasterTenant)" /></td>
|
<td><ActionDialog Header="Delete Tenant" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Tenant?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTenant(context))" Disabled="@(context.Name == TenantNames.Master)" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Admin.UserProfile
|
@namespace Oqtane.Modules.Admin.UserProfile
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -79,7 +79,7 @@ else
|
||||||
@foreach (Profile profile in profiles)
|
@foreach (Profile profile in profiles)
|
||||||
{
|
{
|
||||||
var p = profile;
|
var p = profile;
|
||||||
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole))
|
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
if (p.Category != category)
|
if (p.Category != category)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,24 @@ else
|
||||||
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@if (!string.IsNullOrEmpty(p.Options))
|
||||||
|
{
|
||||||
|
<select id="@p.Name" class="form-control" @onchange="@(e => ProfileChanged(e, p.Name))">
|
||||||
|
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
@if(GetProfileValue(p.Name, "") == option || (GetProfileValue(p.Name, "") == "" && p.DefaultValue == option))
|
||||||
|
{
|
||||||
|
<option value="@option" selected>@option</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@option">@option</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
@if (p.IsRequired)
|
@if (p.IsRequired)
|
||||||
{
|
{
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
|
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||||
|
@ -103,6 +121,7 @@ else
|
||||||
{
|
{
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
@ -299,7 +318,7 @@ else
|
||||||
{
|
{
|
||||||
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
||||||
}
|
}
|
||||||
if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole))
|
if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,10 +58,10 @@ else
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_search))
|
if (string.IsNullOrEmpty(_search))
|
||||||
{
|
{
|
||||||
return allroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList();
|
return allroles.Where(item => item.Role.Name == RoleNames.Registered).ToList();
|
||||||
}
|
}
|
||||||
return allroles
|
return allroles
|
||||||
.Where(item => item.Role.Name == Constants.RegisteredRole &&
|
.Where(item => item.Role.Name == RoleNames.Registered &&
|
||||||
(
|
(
|
||||||
item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||||
item.User.Email.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
item.User.Email.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
|
@ -63,7 +63,7 @@ else
|
||||||
<Row>
|
<Row>
|
||||||
<td>@context.Role.Name</td>
|
<td>@context.Role.Name</td>
|
||||||
<td>
|
<td>
|
||||||
@if (context.Role.Name != Constants.RegisteredRole)
|
@if (context.Role.Name != RoleNames.Registered)
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>Delete</button>
|
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>Delete</button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits LocalizableComponent
|
||||||
|
|
||||||
@if (_visible)
|
@if (_visible)
|
||||||
{
|
{
|
||||||
<div class="app-admin-modal">
|
<div class="app-actiondialog">
|
||||||
<div class="modal" tabindex="-1" role="dialog">
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -17,9 +17,9 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@if (!string.IsNullOrEmpty(Action))
|
@if (!string.IsNullOrEmpty(Action))
|
||||||
{
|
{
|
||||||
<button type="button" class="@Class" @onclick="Confirm">@((MarkupString)_iconSpan) @Action</button>
|
<button type="button" class="@Class" @onclick="Confirm">@((MarkupString)_iconSpan) @Localize(Action)</button>
|
||||||
}
|
}
|
||||||
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">Cancel</button>
|
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">@Localize("Cancel")</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,6 +76,8 @@
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
|
base.OnParametersSet();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Text))
|
if (string.IsNullOrEmpty(Text))
|
||||||
{
|
{
|
||||||
Text = Action;
|
Text = Action;
|
||||||
|
@ -95,6 +97,12 @@
|
||||||
_iconSpan = $"<span class=\"oi oi-{IconName}\"></span> ";
|
_iconSpan = $"<span class=\"oi oi-{IconName}\"></span> ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsLocalizable)
|
||||||
|
{
|
||||||
|
Header = Localize(nameof(Header));
|
||||||
|
Message = Localize(nameof(Message));
|
||||||
|
}
|
||||||
|
|
||||||
_authorized = IsAuthorized();
|
_authorized = IsAuthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,10 +142,10 @@
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, ModuleState.Permissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, ModuleState.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Admin:
|
case SecurityAccessLevel.Admin:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Host:
|
case SecurityAccessLevel.Host:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits LocalizableComponent
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
@if (_authorized)
|
@if (_authorized)
|
||||||
|
@ -56,6 +56,8 @@
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
|
base.OnParametersSet();
|
||||||
|
|
||||||
_text = Action;
|
_text = Action;
|
||||||
if (!string.IsNullOrEmpty(Text))
|
if (!string.IsNullOrEmpty(Text))
|
||||||
{
|
{
|
||||||
|
@ -93,6 +95,11 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsLocalizable)
|
||||||
|
{
|
||||||
|
_text = Localize(nameof(Text));
|
||||||
|
}
|
||||||
|
|
||||||
_url = EditUrl(Action, _parameters);
|
_url = EditUrl(Action, _parameters);
|
||||||
_authorized = IsAuthorized();
|
_authorized = IsAuthorized();
|
||||||
}
|
}
|
||||||
|
@ -135,10 +142,10 @@
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Admin:
|
case SecurityAccessLevel.Admin:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Host:
|
case SecurityAccessLevel.Host:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits ModuleControlBase
|
||||||
|
|
||||||
@if (_text != string.Empty)
|
@if (_text != string.Empty)
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
public string CreatedBy { get; set; }
|
public string CreatedBy { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime? CreatedOn { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string ModifiedBy { get; set; }
|
public string ModifiedBy { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public DateTime ModifiedOn { get; set; }
|
public DateTime? ModifiedOn { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string DeletedBy { get; set; }
|
public string DeletedBy { get; set; }
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
_text = string.Empty;
|
_text = string.Empty;
|
||||||
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
|
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn.HasValue)
|
||||||
{
|
{
|
||||||
_text += "<p style=\"" + Style + "\">Created ";
|
_text += "<p style=\"" + Style + "\">Created ";
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@
|
||||||
|
|
||||||
if (CreatedOn != null)
|
if (CreatedOn != null)
|
||||||
{
|
{
|
||||||
_text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
_text += " on <b>" + CreatedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
_text += "</p>";
|
_text += "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
|
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn.HasValue)
|
||||||
{
|
{
|
||||||
_text += "<p style=\"" + Style + "\">Last modified ";
|
_text += "<p style=\"" + Style + "\">Last modified ";
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
if (ModifiedOn != null)
|
if (ModifiedOn != null)
|
||||||
{
|
{
|
||||||
_text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
_text += " on <b>" + ModifiedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
_text += "</p>";
|
_text += "</p>";
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@((MarkupString) _message)
|
<ModuleMessage Message="@_message" Type="@_messagetype"></ModuleMessage>
|
||||||
</div>
|
</div>
|
||||||
@if (_image != string.Empty)
|
@if (_image != string.Empty)
|
||||||
{
|
{
|
||||||
|
@ -91,9 +91,10 @@
|
||||||
private string _progressbarid = string.Empty;
|
private string _progressbarid = string.Empty;
|
||||||
private string _filter = "*";
|
private string _filter = "*";
|
||||||
private bool _haseditpermission = false;
|
private bool _haseditpermission = false;
|
||||||
private string _message = string.Empty;
|
|
||||||
private string _image = string.Empty;
|
private string _image = string.Empty;
|
||||||
private string _guid;
|
private string _guid;
|
||||||
|
private string _message = string.Empty;
|
||||||
|
private MessageType _messagetype;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Id { get; set; } // optional - for setting the id of the FileManager component for accessibility
|
public string Id { get; set; } // optional - for setting the id of the FileManager component for accessibility
|
||||||
|
@ -172,7 +173,7 @@
|
||||||
_haseditpermission = false;
|
_haseditpermission = false;
|
||||||
if (!string.IsNullOrEmpty(Folder))
|
if (!string.IsNullOrEmpty(Folder))
|
||||||
{
|
{
|
||||||
_haseditpermission = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
_haseditpermission = UserSecurity.IsAuthorized(PageState.User, RoleNames.Host);
|
||||||
_files = await FileService.GetFilesAsync(Folder);
|
_files = await FileService.GetFilesAsync(Folder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -217,7 +218,9 @@
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
||||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Loading Files</div>";
|
|
||||||
|
_message = "Error Loading Files";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +257,7 @@
|
||||||
|
|
||||||
private async Task UploadFile()
|
private async Task UploadFile()
|
||||||
{
|
{
|
||||||
|
_message = string.Empty;
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
var upload = await interop.GetFiles(_fileinputid);
|
var upload = await interop.GetFiles(_fileinputid);
|
||||||
if (upload.Length > 0)
|
if (upload.Length > 0)
|
||||||
|
@ -273,7 +277,10 @@
|
||||||
if (result == string.Empty)
|
if (result == string.Empty)
|
||||||
{
|
{
|
||||||
await logger.LogInformation("File Upload Succeeded {Files}", upload);
|
await logger.LogInformation("File Upload Succeeded {Files}", upload);
|
||||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
|
|
||||||
|
_message = "File Upload Succeeded";
|
||||||
|
_messagetype = MessageType.Success;
|
||||||
|
|
||||||
await GetFiles();
|
await GetFiles();
|
||||||
|
|
||||||
if (upload.Length == 1)
|
if (upload.Length == 1)
|
||||||
|
@ -290,30 +297,37 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError("File Upload Failed For {Files}", result.Replace(",", ", "));
|
await logger.LogError("File Upload Failed For {Files}", result.Replace(",", ", "));
|
||||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
|
||||||
|
_message = "File Upload Failed";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "File Upload Failed {Error}", ex.Message);
|
await logger.LogError(ex, "File Upload Failed {Error}", ex.Message);
|
||||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
|
||||||
|
_message = "File Upload Failed";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Have Not Selected A File To Upload</div>";
|
_message = "You Have Not Selected A File To Upload";
|
||||||
|
_messagetype = MessageType.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteFile()
|
private async Task DeleteFile()
|
||||||
{
|
{
|
||||||
_message = string.Empty;
|
_message = string.Empty;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await FileService.DeleteFileAsync(FileId);
|
await FileService.DeleteFileAsync(FileId);
|
||||||
await logger.LogInformation("File Deleted {File}", FileId);
|
await logger.LogInformation("File Deleted {File}", FileId);
|
||||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Deleted</div>";
|
|
||||||
|
_message = "File Deleted";
|
||||||
|
_messagetype = MessageType.Success;
|
||||||
|
|
||||||
await GetFiles();
|
await GetFiles();
|
||||||
FileId = -1;
|
FileId = -1;
|
||||||
await SetImage();
|
await SetImage();
|
||||||
|
@ -322,7 +336,9 @@
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting File {File} {Error}", FileId, ex.Message);
|
await logger.LogError(ex, "Error Deleting File {File} {Error}", FileId, ex.Message);
|
||||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Deleting File</div>";
|
|
||||||
|
_message = "Error Deleting File";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits LocalizableComponent
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(HelpText))
|
@if (!string.IsNullOrEmpty(HelpText))
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ else
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
|
base.OnParametersSet();
|
||||||
|
|
||||||
_openLabel = "<label";
|
_openLabel = "<label";
|
||||||
if (!string.IsNullOrEmpty(For))
|
if (!string.IsNullOrEmpty(For))
|
||||||
{
|
{
|
||||||
|
@ -40,5 +42,11 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
_openLabel += ">";
|
_openLabel += ">";
|
||||||
|
|
||||||
|
if (IsLocalizable)
|
||||||
|
{
|
||||||
|
ChildContent =@<text>@Localize("Text")</text>;
|
||||||
|
HelpText = Localize(nameof(HelpText));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
56
Oqtane.Client/Modules/Controls/LocalizableComponent.cs
Normal file
56
Oqtane.Client/Modules/Controls/LocalizableComponent.cs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Modules.Controls
|
||||||
|
{
|
||||||
|
public class LocalizableComponent : ModuleControlBase
|
||||||
|
{
|
||||||
|
private IStringLocalizer _localizer;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string ResourceKey { get; set; }
|
||||||
|
|
||||||
|
protected bool IsLocalizable { get; private set; }
|
||||||
|
|
||||||
|
protected string Localize(string name)
|
||||||
|
{
|
||||||
|
var key = $"{ResourceKey}.{name}";
|
||||||
|
|
||||||
|
// TODO: we should have a ShowMissingResourceKeys option which developers/translators can enable to find missing translations which would display the key rather than the name
|
||||||
|
if (!IsLocalizable)
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _localizer?[key] ?? name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(ResourceKey))
|
||||||
|
{
|
||||||
|
if (ModuleState?.ModuleType != null)
|
||||||
|
{
|
||||||
|
var moduleType = Type.GetType(ModuleState.ModuleType);
|
||||||
|
if (moduleType != null)
|
||||||
|
{
|
||||||
|
using (var scope = ServiceActivator.GetScope())
|
||||||
|
{
|
||||||
|
var localizerFactory = scope.ServiceProvider.GetService<IStringLocalizerFactory>();
|
||||||
|
_localizer = localizerFactory.Create(moduleType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IsLocalizable = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsLocalizable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits ModuleControlBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
{
|
{
|
||||||
<div class="@_classname" role="alert">
|
<div class="@_classname" role="alert">
|
||||||
@_message
|
@_message
|
||||||
@if (Type == MessageType.Error && UserSecurity.IsAuthorized(PageState.User, Constants.HostRole))
|
@if (Type == MessageType.Error && PageState != null && UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
@((MarkupString)" ")<NavLink href="@NavigateUrl("admin/log")">View Details</NavLink>
|
@((MarkupString)" ")<NavLink href="@NavigateUrl("admin/log")">View Details</NavLink>
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _message = string.Empty;
|
private string _message = string.Empty;
|
||||||
private string _classname = "alert alert-danger";
|
private string _classname = string.Empty;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
|
@ -25,24 +25,17 @@
|
||||||
public MessageType Type { get; set; }
|
public MessageType Type { get; set; }
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(Message))
|
|
||||||
{
|
{
|
||||||
_message = Message;
|
_message = Message;
|
||||||
|
if (!string.IsNullOrEmpty(_message))
|
||||||
|
{
|
||||||
_classname = GetMessageType(Type);
|
_classname = GetMessageType(Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetModuleMessage(string message, MessageType type)
|
|
||||||
{
|
|
||||||
_message = message;
|
|
||||||
_classname = GetMessageType(type);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetMessageType(MessageType type)
|
private string GetMessageType(MessageType type)
|
||||||
{
|
{
|
||||||
var classname = string.Empty;
|
string classname = string.Empty;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case MessageType.Success:
|
case MessageType.Success:
|
||||||
|
|
|
@ -103,14 +103,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
_roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||||
_roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
_roles.Insert(0, new Role { Name = RoleNames.Everyone });
|
||||||
|
|
||||||
_permissions = new List<PermissionString>();
|
_permissions = new List<PermissionString>();
|
||||||
|
|
||||||
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
// initialize with admin role
|
// initialize with admin role
|
||||||
_permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = Constants.AdminRole });
|
_permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = RoleNames.Admin });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Permissions))
|
if (!string.IsNullOrEmpty(Permissions))
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool GetPermissionDisabled(string roleName)
|
private bool GetPermissionDisabled(string roleName)
|
||||||
=> roleName == Constants.AdminRole
|
=> roleName == RoleNames.Admin
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
@ -226,8 +226,8 @@
|
||||||
{
|
{
|
||||||
permission = _permissions[i];
|
permission = _permissions[i];
|
||||||
List<string> ids = permission.Permissions.Split(';').ToList();
|
List<string> ids = permission.Permissions.Split(';').ToList();
|
||||||
ids.Remove("!" + Constants.AllUsersRole); // remove deny all users
|
ids.Remove("!" + RoleNames.Everyone); // remove deny all users
|
||||||
ids.Remove("!" + Constants.RegisteredRole); // remove deny registered users
|
ids.Remove("!" + RoleNames.Registered); // remove deny registered users
|
||||||
permission.Permissions = string.Join(";", ids.ToArray());
|
permission.Permissions = string.Join(";", ids.ToArray());
|
||||||
_permissions[i] = permission;
|
_permissions[i] = permission;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
@if (_filemanagervisible)
|
@if (_filemanagervisible)
|
||||||
{
|
{
|
||||||
<FileManager @ref="_fileManager" Filter="@Constants.ImageFiles" />
|
<FileManager @ref="_fileManager" Filter="@Constants.ImageFiles" />
|
||||||
@((MarkupString)_message)
|
<ModuleMessage Message="@_message" Type="MessageType.Warning"></ModuleMessage>
|
||||||
<br />
|
<br />
|
||||||
}
|
}
|
||||||
<div class="row justify-content-center" style="margin-bottom: 20px;">
|
<div class="row justify-content-center" style="margin-bottom: 20px;">
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
public string DebugLevel { get; set; } = "info";
|
public string DebugLevel { get; set; } = "info";
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
{
|
{
|
||||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill1.3.6.min.js" },
|
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-blot-formatter.min.js" },
|
||||||
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" }
|
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" }
|
||||||
|
@ -181,6 +181,7 @@
|
||||||
|
|
||||||
public async Task InsertImage()
|
public async Task InsertImage()
|
||||||
{
|
{
|
||||||
|
_message = string.Empty;
|
||||||
if (_filemanagervisible)
|
if (_filemanagervisible)
|
||||||
{
|
{
|
||||||
var fileid = _fileManager.GetFileId();
|
var fileid = _fileManager.GetFileId();
|
||||||
|
@ -189,17 +190,15 @@
|
||||||
var interop = new RichTextEditorInterop(JSRuntime);
|
var interop = new RichTextEditorInterop(JSRuntime);
|
||||||
await interop.InsertImage(_editorElement, ContentUrl(fileid));
|
await interop.InsertImage(_editorElement, ContentUrl(fileid));
|
||||||
_filemanagervisible = false;
|
_filemanagervisible = false;
|
||||||
_message = string.Empty;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Must Select An Image To Insert</div>";
|
_message = "You Must Select An Image To Insert";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_filemanagervisible = true;
|
_filemanagervisible = true;
|
||||||
_message = string.Empty;
|
|
||||||
}
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits LocalizableComponent
|
||||||
|
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<div>
|
<div>
|
||||||
|
@ -41,4 +41,16 @@
|
||||||
_heading = (!string.IsNullOrEmpty(Heading)) ? Heading : Name;
|
_heading = (!string.IsNullOrEmpty(Heading)) ? Heading : Name;
|
||||||
_expanded = (!string.IsNullOrEmpty(Expanded)) ? Expanded : "false";
|
_expanded = (!string.IsNullOrEmpty(Expanded)) ? Expanded : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
base.OnParametersSet();
|
||||||
|
|
||||||
|
if (IsLocalizable)
|
||||||
|
{
|
||||||
|
_heading = !string.IsNullOrEmpty(Heading)
|
||||||
|
? Localize(nameof(Heading))
|
||||||
|
: Localize(nameof(Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits LocalizableComponent
|
||||||
|
|
||||||
@if (Name == Parent.ActiveTab)
|
@if (Name == Parent.ActiveTab)
|
||||||
{
|
{
|
||||||
|
@ -27,9 +27,34 @@ else
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Heading { get; set; } // optional - defaults to name if not specified
|
public string Heading { get; set; } // optional - defaults to name if not specified
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public SecurityAccessLevel? Security { get; set; } // optional - can be used to specify SecurityAccessLevel
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
Parent.AddTabPanel((TabPanel)this);
|
Parent.AddTabPanel((TabPanel)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
base.OnParametersSet();
|
||||||
|
|
||||||
|
if (IsLocalizable)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Heading))
|
||||||
|
{
|
||||||
|
Name = Localize(nameof(Name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Heading = Localize(nameof(Heading));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DisplayHeading()
|
||||||
|
{
|
||||||
|
return (string.IsNullOrEmpty(Heading)) ? Name : Heading;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleControlBase
|
@inherits ModuleControlBase
|
||||||
|
|
||||||
<CascadingValue Value="this">
|
<CascadingValue Value="this">
|
||||||
|
@ -6,22 +6,25 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
@foreach (TabPanel tabPanel in _tabPanels)
|
@foreach (TabPanel tabPanel in _tabPanels)
|
||||||
|
{
|
||||||
|
@if (IsAuthorized(tabPanel))
|
||||||
{
|
{
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
@if (tabPanel.Name == ActiveTab)
|
@if (tabPanel.Name == ActiveTab)
|
||||||
{
|
{
|
||||||
<a class="nav-link active" data-toggle="tab" href="#@tabPanel.Name" role="tab" @onclick:preventDefault="true">
|
<a class="nav-link active" data-toggle="tab" href="#@tabPanel.Name" role="tab" @onclick:preventDefault="true">
|
||||||
@DisplayHeading(tabPanel.Name, tabPanel.Heading)
|
@tabPanel.DisplayHeading()
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<a class="nav-link" data-toggle="tab" href="#@tabPanel.Name" role="tab" @onclick:preventDefault="true">
|
<a class="nav-link" data-toggle="tab" href="#@tabPanel.Name" role="tab" @onclick:preventDefault="true">
|
||||||
@DisplayHeading(tabPanel.Name, tabPanel.Heading)
|
@tabPanel.DisplayHeading()
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<br />
|
<br />
|
||||||
|
@ -58,8 +61,30 @@
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string DisplayHeading(string Name, string Heading)
|
private bool IsAuthorized(TabPanel tabPanel)
|
||||||
{
|
{
|
||||||
return (string.IsNullOrEmpty(Heading)) ? Name : Heading;
|
var authorized = false;
|
||||||
|
switch (tabPanel.Security)
|
||||||
|
{
|
||||||
|
case null: // security not specified - assume SecurityAccessLevel.Anonymous
|
||||||
|
authorized = true;
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Anonymous:
|
||||||
|
authorized = true;
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.View:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, ModuleState.Permissions);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Edit:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Admin:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Host:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Host);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return authorized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
Success,
|
Success,
|
||||||
Info,
|
Info,
|
||||||
Warning,
|
Warning,
|
||||||
Error
|
Error,
|
||||||
|
Undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -53,15 +53,18 @@ namespace Oqtane.Modules
|
||||||
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
||||||
{
|
{
|
||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script))
|
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
|
||||||
{
|
{
|
||||||
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
|
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
|
||||||
}
|
}
|
||||||
|
if (scripts.Any())
|
||||||
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
await interop.IncludeScripts(scripts.ToArray());
|
await interop.IncludeScripts(scripts.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// path method
|
// path method
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<LangVersion>7.3</LangVersion>
|
|
||||||
<RazorLangVersion>3.0</RazorLangVersion>
|
<RazorLangVersion>3.0</RazorLangVersion>
|
||||||
<Configurations>Debug;Release</Configurations>
|
<Configurations>Debug;Release</Configurations>
|
||||||
<Version>1.0.3</Version>
|
<Version>2.0.0</Version>
|
||||||
<Product>Oqtane</Product>
|
<Product>Oqtane</Product>
|
||||||
<Authors>Shaun Walker</Authors>
|
<Authors>Shaun Walker</Authors>
|
||||||
<Company>.NET Foundation</Company>
|
<Company>.NET Foundation</Company>
|
||||||
|
@ -15,7 +14,7 @@
|
||||||
<PackageProjectUrl>https://www.oqtane.org</PackageProjectUrl>
|
<PackageProjectUrl>https://www.oqtane.org</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/oqtane</RepositoryUrl>
|
<RepositoryUrl>https://github.com/oqtane</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<PackageReleaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</PackageReleaseNotes>
|
<PackageReleaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</PackageReleaseNotes>
|
||||||
<RootNamespace>Oqtane</RootNamespace>
|
<RootNamespace>Oqtane</RootNamespace>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -28,11 +27,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.4" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
|
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Oqtane.Services;
|
|
||||||
using System.Reflection;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Reflection;
|
||||||
using Oqtane.Modules;
|
using System.Threading.Tasks;
|
||||||
using Oqtane.Shared;
|
using System.Runtime.Loader;
|
||||||
using Oqtane.Providers;
|
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using System.IO.Compression;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
using System.IO;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
using Oqtane.Providers;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
using Oqtane.Services;
|
||||||
|
|
||||||
namespace Oqtane.Client
|
namespace Oqtane.Client
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,9 @@ namespace Oqtane.Client
|
||||||
builder.Services.AddSingleton(httpClient);
|
builder.Services.AddSingleton(httpClient);
|
||||||
builder.Services.AddOptions();
|
builder.Services.AddOptions();
|
||||||
|
|
||||||
|
// Register localization services
|
||||||
|
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
|
||||||
|
|
||||||
// register auth services
|
// register auth services
|
||||||
builder.Services.AddAuthorizationCore();
|
builder.Services.AddAuthorizationCore();
|
||||||
builder.Services.AddScoped<IdentityAuthenticationStateProvider>();
|
builder.Services.AddScoped<IdentityAuthenticationStateProvider>();
|
||||||
|
@ -62,32 +65,33 @@ namespace Oqtane.Client
|
||||||
|
|
||||||
await LoadClientAssemblies(httpClient);
|
await LoadClientAssemblies(httpClient);
|
||||||
|
|
||||||
// dynamically register module contexts and repository services
|
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
||||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
foreach (var assembly in assemblies)
|
||||||
foreach (Assembly assembly in assemblies)
|
|
||||||
{
|
{
|
||||||
var implementationTypes = assembly.GetTypes()
|
// dynamically register module services
|
||||||
.Where(item => item.GetInterfaces().Contains(typeof(IService)));
|
var implementationTypes = assembly.GetInterfaces<IService>();
|
||||||
|
foreach (var implementationType in implementationTypes)
|
||||||
foreach (Type implementationtype in implementationTypes)
|
|
||||||
{
|
{
|
||||||
Type servicetype = Type.GetType(implementationtype.AssemblyQualifiedName.Replace(implementationtype.Name, "I" + implementationtype.Name));
|
if (implementationType.AssemblyQualifiedName != null)
|
||||||
if (servicetype != null)
|
|
||||||
{
|
{
|
||||||
builder.Services.AddScoped(servicetype, implementationtype); // traditional service interface
|
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}"));
|
||||||
}
|
builder.Services.AddScoped(serviceType ?? implementationType, implementationType);
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.Services.AddScoped(implementationtype, implementationtype); // no interface defined for service
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assembly.GetInstances<IClientStartup>()
|
// register client startup services
|
||||||
.ToList()
|
var startUps = assembly.GetInstances<IClientStartup>();
|
||||||
.ForEach(x => x.ConfigureServices(builder.Services));
|
foreach (var startup in startUps)
|
||||||
|
{
|
||||||
|
startup.ConfigureServices(builder.Services);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await builder.Build().RunAsync();
|
var host = builder.Build();
|
||||||
|
|
||||||
|
ServiceActivator.Configure(host.Services);
|
||||||
|
|
||||||
|
await host.RunAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task LoadClientAssemblies(HttpClient http)
|
private static async Task LoadClientAssemblies(HttpClient http)
|
||||||
|
@ -101,8 +105,8 @@ namespace Oqtane.Client
|
||||||
// asemblies and debug symbols are packaged in a zip file
|
// asemblies and debug symbols are packaged in a zip file
|
||||||
using (ZipArchive archive = new ZipArchive(new MemoryStream(zip)))
|
using (ZipArchive archive = new ZipArchive(new MemoryStream(zip)))
|
||||||
{
|
{
|
||||||
Dictionary<string, byte[]> dlls = new Dictionary<string, byte[]>();
|
var dlls = new Dictionary<string, byte[]>();
|
||||||
Dictionary<string, byte[]> pdbs = new Dictionary<string, byte[]>();
|
var pdbs = new Dictionary<string, byte[]>();
|
||||||
|
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
{
|
{
|
||||||
|
@ -129,11 +133,11 @@ namespace Oqtane.Client
|
||||||
{
|
{
|
||||||
if (pdbs.ContainsKey(item.Key))
|
if (pdbs.ContainsKey(item.Key))
|
||||||
{
|
{
|
||||||
Assembly.Load(item.Value, pdbs[item.Key]);
|
AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(item.Value), new MemoryStream(pdbs[item.Key]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assembly.Load(item.Value);
|
AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(item.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,13 +173,15 @@ namespace Oqtane.Services
|
||||||
// add entityid parameter to url for custom authorization policy
|
// add entityid parameter to url for custom authorization policy
|
||||||
public string CreateAuthorizationPolicyUrl(string url, int entityId)
|
public string CreateAuthorizationPolicyUrl(string url, int entityId)
|
||||||
{
|
{
|
||||||
|
string qs = "entityid=" + entityId.ToString();
|
||||||
|
|
||||||
if (url.Contains("?"))
|
if (url.Contains("?"))
|
||||||
{
|
{
|
||||||
return url + "&entityid=" + entityId.ToString();
|
return url + "&" + qs;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return url + "?entityid=" + entityId.ToString();
|
return url + "?" + qs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="@BodyClass">
|
<div class="@BodyClass">
|
||||||
|
|
||||||
@if (UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole))
|
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(Constants.AllUsersRole))
|
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
||||||
{
|
{
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Publish("unpublish"))>Unpublish Page</button>
|
<button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Publish("unpublish"))>Unpublish Page</button>
|
||||||
|
@ -510,8 +510,8 @@
|
||||||
if (permissionstring.PermissionName == PermissionNames.View)
|
if (permissionstring.PermissionName == PermissionNames.View)
|
||||||
{
|
{
|
||||||
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
||||||
if (!ids.Contains(Constants.AllUsersRole)) ids.Add(Constants.AllUsersRole);
|
if (!ids.Contains(RoleNames.Everyone)) ids.Add(RoleNames.Everyone);
|
||||||
if (!ids.Contains(Constants.RegisteredRole)) ids.Add(Constants.RegisteredRole);
|
if (!ids.Contains(RoleNames.Registered)) ids.Add(RoleNames.Registered);
|
||||||
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,12 +531,12 @@
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "publish":
|
case "publish":
|
||||||
if (!ids.Contains(Constants.AllUsersRole)) ids.Add(Constants.AllUsersRole);
|
if (!ids.Contains(RoleNames.Everyone)) ids.Add(RoleNames.Everyone);
|
||||||
if (!ids.Contains(Constants.RegisteredRole)) ids.Add(Constants.RegisteredRole);
|
if (!ids.Contains(RoleNames.Registered)) ids.Add(RoleNames.Registered);
|
||||||
break;
|
break;
|
||||||
case "unpublish":
|
case "unpublish":
|
||||||
ids.Remove(Constants.AllUsersRole);
|
ids.Remove(RoleNames.Everyone);
|
||||||
ids.Remove(Constants.RegisteredRole);
|
ids.Remove(RoleNames.Registered);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Oqtane.Themes.Controls
|
||||||
{
|
{
|
||||||
actionList.Add(new ActionViewModel {Icon = Icons.Cog, 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))
|
if (UserSecurity.GetPermissionStrings(ModuleState.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
||||||
{
|
{
|
||||||
actionList.Add(new ActionViewModel {Icon=Icons.CircleX, 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) });
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ namespace Oqtane.Themes.Controls
|
||||||
if (permissionstring.PermissionName == PermissionNames.View)
|
if (permissionstring.PermissionName == PermissionNames.View)
|
||||||
{
|
{
|
||||||
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
||||||
if (!ids.Contains(Constants.AllUsersRole)) ids.Add(Constants.AllUsersRole);
|
if (!ids.Contains(RoleNames.Everyone)) ids.Add(RoleNames.Everyone);
|
||||||
if (!ids.Contains(Constants.RegisteredRole)) ids.Add(Constants.RegisteredRole);
|
if (!ids.Contains(RoleNames.Registered)) ids.Add(RoleNames.Registered);
|
||||||
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,8 +159,8 @@ namespace Oqtane.Themes.Controls
|
||||||
if (permissionstring.PermissionName == PermissionNames.View)
|
if (permissionstring.PermissionName == PermissionNames.View)
|
||||||
{
|
{
|
||||||
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
List<string> ids = permissionstring.Permissions.Split(';').ToList();
|
||||||
ids.Remove(Constants.AllUsersRole);
|
ids.Remove(RoleNames.Everyone);
|
||||||
ids.Remove(Constants.RegisteredRole);
|
ids.Remove(RoleNames.Registered);
|
||||||
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
permissionstring.Permissions = string.Join(";", ids.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Themes.Controls
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
@attribute [OqtaneIgnore]
|
@attribute [OqtaneIgnore]
|
||||||
|
|
||||||
|
@ -17,6 +17,13 @@
|
||||||
{
|
{
|
||||||
title = PageState.Action;
|
title = PageState.Action;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(ModuleState.ControlTitle))
|
||||||
|
{
|
||||||
|
title = ModuleState.ControlTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,18 @@ namespace Oqtane.Themes
|
||||||
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
||||||
{
|
{
|
||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script))
|
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
|
||||||
{
|
{
|
||||||
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
|
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
|
||||||
}
|
}
|
||||||
|
if (scripts.Any())
|
||||||
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
await interop.IncludeScripts(scripts.ToArray());
|
await interop.IncludeScripts(scripts.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// path method
|
// path method
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="mx-auto text-center">
|
<div class="mx-auto text-center">
|
||||||
<button type="button" class="btn btn-success" @onclick="Install">Install Now</button><br /><br />
|
<button type="button" class="btn btn-success" @onclick="Install">Install Now</button><br /><br />
|
||||||
@((MarkupString) _message)
|
<ModuleMessage Message="@_message" Type="MessageType.Error"></ModuleMessage>
|
||||||
</div>
|
</div>
|
||||||
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
|
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,13 +129,13 @@
|
||||||
private string _databaseType = "LocalDB";
|
private string _databaseType = "LocalDB";
|
||||||
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
|
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
|
||||||
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||||
private string _username = "";
|
private string _username = string.Empty;
|
||||||
private string _password = "";
|
private string _password = string.Empty;
|
||||||
private string _hostUsername = Constants.HostUser;
|
private string _hostUsername = UserNames.Host;
|
||||||
private string _hostPassword = "";
|
private string _hostPassword = string.Empty;
|
||||||
private string _confirmPassword = "";
|
private string _confirmPassword = string.Empty;
|
||||||
private string _hostEmail = "";
|
private string _hostEmail = string.Empty;
|
||||||
private string _message = "";
|
private string _message = string.Empty;
|
||||||
private string _integratedSecurityDisplay = "display: none;";
|
private string _integratedSecurityDisplay = "display: none;";
|
||||||
private string _loadingDisplay = "display: none;";
|
private string _loadingDisplay = "display: none;";
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@
|
||||||
Aliases = uri.Authority,
|
Aliases = uri.Authority,
|
||||||
HostEmail = _hostEmail,
|
HostEmail = _hostEmail,
|
||||||
HostPassword = _hostPassword,
|
HostPassword = _hostPassword,
|
||||||
HostName = Constants.HostUser,
|
HostName = UserNames.Host,
|
||||||
TenantName = Constants.MasterTenant,
|
TenantName = TenantNames.Master,
|
||||||
IsNewTenant = true,
|
IsNewTenant = true,
|
||||||
SiteName = Constants.DefaultSite
|
SiteName = Constants.DefaultSite
|
||||||
};
|
};
|
||||||
|
@ -201,13 +201,13 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_message = "<div class=\"alert alert-danger\" role=\"alert\">" + installation.Message + "</div>";
|
_message = installation.Message;
|
||||||
_loadingDisplay = "display: none;";
|
_loadingDisplay = "display: none;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
|
_message = "Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
|
|
||||||
<ModuleMessage Message="@_message" Type="MessageType.Error" />
|
<ModuleMessage Message="@_message" Type="@_messagetype" />
|
||||||
<CascadingValue Value="this">
|
<CascadingValue Value="this">
|
||||||
<ModuleMessage @ref="ModuleMessage" />
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
@if (_progressindicator)
|
@if (_progressindicator)
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _message;
|
private string _message;
|
||||||
|
private MessageType _messagetype;
|
||||||
private bool _progressindicator = false;
|
private bool _progressindicator = false;
|
||||||
|
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
|
@ -49,11 +49,13 @@
|
||||||
{
|
{
|
||||||
// module does not exist with typename specified
|
// module does not exist with typename specified
|
||||||
_message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
|
_message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_message = "Something is wrong with moduletype";
|
_message = "Something is wrong with moduletype";
|
||||||
|
_messagetype = MessageType.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -61,9 +63,10 @@
|
||||||
|
|
||||||
public void AddModuleMessage(string message, MessageType type)
|
public void AddModuleMessage(string message, MessageType type)
|
||||||
{
|
{
|
||||||
|
_message = message;
|
||||||
|
_messagetype = type;
|
||||||
_progressindicator = false;
|
_progressindicator = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
ModuleMessage.SetModuleMessage(message, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowProgressIndicator()
|
public void ShowProgressIndicator()
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
@using Microsoft.AspNetCore.Components.Rendering
|
@using Microsoft.AspNetCore.Components.Rendering
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
|
|
||||||
<div class="@_paneadminborder">
|
@if (_useadminborder)
|
||||||
@if (_panetitle != "")
|
{
|
||||||
{
|
<div class="@_paneadminborder">
|
||||||
@((MarkupString)_panetitle)
|
@((MarkupString)_panetitle)
|
||||||
}
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@DynamicComponent
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _paneadminborder = "";
|
private bool _useadminborder = false;
|
||||||
|
private string _paneadminborder = "container";
|
||||||
private string _panetitle = "";
|
private string _panetitle = "";
|
||||||
|
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
|
@ -26,8 +31,9 @@
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
if (PageState.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 != PaneNames.Admin)
|
||||||
{
|
{
|
||||||
|
_useadminborder = true;
|
||||||
_paneadminborder = "app-pane-admin-border";
|
_paneadminborder = "app-pane-admin-border";
|
||||||
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
||||||
}
|
}
|
||||||
|
@ -41,7 +47,7 @@
|
||||||
{
|
{
|
||||||
if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
|
if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
|
||||||
{
|
{
|
||||||
if (Name.ToLower() == Constants.AdminPane.ToLower())
|
if (Name.ToLower() == PaneNames.Admin.ToLower())
|
||||||
{
|
{
|
||||||
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
||||||
if (module != null && !module.IsDeleted)
|
if (module != null && !module.IsDeleted)
|
||||||
|
@ -75,20 +81,16 @@
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.Permissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Admin:
|
case SecurityAccessLevel.Admin:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevel.Host:
|
case SecurityAccessLevel.Host:
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authorized)
|
if (authorized)
|
||||||
{
|
{
|
||||||
if (!Constants.DefaultModuleActions.Contains(PageState.Action) && module.ControlTitle != "")
|
|
||||||
{
|
|
||||||
module.Title = module.ControlTitle;
|
|
||||||
}
|
|
||||||
CreateComponent(builder, module);
|
CreateComponent(builder, module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@using System.Diagnostics.CodeAnalysis
|
@using System.Diagnostics.CodeAnalysis
|
||||||
@using System.Runtime.InteropServices
|
@using System.Runtime.InteropServices
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
User user = null;
|
User user = null;
|
||||||
List<Module> modules;
|
List<Module> modules;
|
||||||
var moduleid = -1;
|
var moduleid = -1;
|
||||||
var action = string.Empty;
|
var action = Constants.DefaultAction;
|
||||||
var urlparameters = string.Empty;
|
var urlparameters = string.Empty;
|
||||||
var editmode = false;
|
var editmode = false;
|
||||||
var reload = Reload.None;
|
var reload = Reload.None;
|
||||||
|
@ -202,20 +202,15 @@
|
||||||
{
|
{
|
||||||
modIdPos = i + 1;
|
modIdPos = i + 1;
|
||||||
actionPos = modIdPos + 1;
|
actionPos = modIdPos + 1;
|
||||||
if (actionPos > segments.Length - 1)
|
if (actionPos <= segments.Length - 1)
|
||||||
{
|
|
||||||
action = Constants.DefaultAction;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
action = segments[actionPos];
|
action = segments[actionPos];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if path has moduleid and action specification ie. pagename/moduleid/action/
|
// check if path has moduleid and action specification ie. pagename/*/moduleid/action/
|
||||||
if (modIdPos > 0)
|
if (modIdPos > 0)
|
||||||
{
|
{
|
||||||
int.TryParse(segments[modIdPos], out result);
|
int.TryParse(segments[modIdPos], out result);
|
||||||
|
@ -280,15 +275,15 @@
|
||||||
reload = Reload.Page;
|
reload = Reload.Page;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState == null || reload >= Reload.Page)
|
if (PageState == null || reload >= Reload.Site)
|
||||||
{
|
{
|
||||||
modules = await ModuleService.GetModulesAsync(site.SiteId);
|
modules = await ModuleService.GetModulesAsync(site.SiteId);
|
||||||
(page, modules) = ProcessModules(page, modules, moduleid, action, (!string.IsNullOrEmpty(page.DefaultContainerType)) ? page.DefaultContainerType : site.DefaultContainerType);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
modules = PageState.Modules;
|
modules = PageState.Modules;
|
||||||
}
|
}
|
||||||
|
(page, modules) = ProcessModules(page, modules, moduleid, action, (!string.IsNullOrEmpty(page.DefaultContainerType)) ? page.DefaultContainerType : site.DefaultContainerType);
|
||||||
|
|
||||||
_pagestate = new PageState
|
_pagestate = new PageState
|
||||||
{
|
{
|
||||||
|
@ -390,6 +385,10 @@
|
||||||
if (string.IsNullOrEmpty(page.ThemeType))
|
if (string.IsNullOrEmpty(page.ThemeType))
|
||||||
{
|
{
|
||||||
page.ThemeType = site.DefaultThemeType;
|
page.ThemeType = site.DefaultThemeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(page.LayoutType))
|
||||||
|
{
|
||||||
page.LayoutType = site.DefaultLayoutType;
|
page.LayoutType = site.DefaultLayoutType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +442,13 @@
|
||||||
var paneindex = new Dictionary<string, int>();
|
var paneindex = new Dictionary<string, int>();
|
||||||
foreach (Module module in modules)
|
foreach (Module module in modules)
|
||||||
{
|
{
|
||||||
if (module.PageId == page.PageId || module.ModuleId == moduleid)
|
// initialize module control properties
|
||||||
|
module.SecurityAccessLevel = SecurityAccessLevel.Host;
|
||||||
|
module.ControlTitle = "";
|
||||||
|
module.Actions = "";
|
||||||
|
module.UseAdminContainer = false;
|
||||||
|
|
||||||
|
if ((module.PageId == page.PageId || module.ModuleId == moduleid) && module.ModuleDefinition != null)
|
||||||
{
|
{
|
||||||
var typename = string.Empty;
|
var typename = string.Empty;
|
||||||
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(GetRuntime().ToString())))
|
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(GetRuntime().ToString())))
|
||||||
|
@ -455,9 +460,13 @@
|
||||||
typename = Constants.ErrorModule;
|
typename = Constants.ErrorModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.ModuleId == moduleid && action != "")
|
// handle default action
|
||||||
|
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
|
||||||
{
|
{
|
||||||
// check if the module defines custom routes
|
action = module.ModuleDefinition.DefaultAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the module defines custom action routes
|
||||||
if (module.ModuleDefinition.ControlTypeRoutes != "")
|
if (module.ModuleDefinition.ControlTypeRoutes != "")
|
||||||
{
|
{
|
||||||
foreach (string route in module.ModuleDefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string route in module.ModuleDefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
@ -469,11 +478,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.ModuleType = typename.Replace(Constants.ActionToken, action);
|
module.ModuleType = typename.Replace(Constants.ActionToken, action);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
module.ModuleType = typename.Replace(Constants.ActionToken, Constants.DefaultAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get additional metadata from IModuleControl interface
|
// get additional metadata from IModuleControl interface
|
||||||
typename = module.ModuleType;
|
typename = module.ModuleType;
|
||||||
|
@ -507,7 +511,7 @@
|
||||||
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
||||||
if (page.Panes == null || page.Panes.FindIndex(item => item.Equals(module.Pane, StringComparison.OrdinalIgnoreCase)) == -1)
|
if (page.Panes == null || page.Panes.FindIndex(item => item.Equals(module.Pane, StringComparison.OrdinalIgnoreCase)) == -1)
|
||||||
{
|
{
|
||||||
module.Pane = Constants.AdminPane;
|
module.Pane = PaneNames.Admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate module position within pane
|
// calculate module position within pane
|
||||||
|
@ -522,6 +526,7 @@
|
||||||
|
|
||||||
module.PaneModuleIndex = paneindex[module.Pane.ToLower()];
|
module.PaneModuleIndex = paneindex[module.Pane.ToLower()];
|
||||||
|
|
||||||
|
// container fallback
|
||||||
if (string.IsNullOrEmpty(module.ContainerType))
|
if (string.IsNullOrEmpty(module.ContainerType))
|
||||||
{
|
{
|
||||||
module.ContainerType = defaultcontainertype;
|
module.ContainerType = defaultcontainertype;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
@inject IJSRuntime JsRuntime
|
@inject IJSRuntime JsRuntime
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
@ -33,11 +33,14 @@
|
||||||
// manage stylesheets for this page
|
// manage stylesheets for this page
|
||||||
string batch = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
string batch = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
||||||
var links = new List<object>();
|
var links = new List<object>();
|
||||||
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet))
|
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet && item.Declaration != ResourceDeclaration.Global))
|
||||||
{
|
{
|
||||||
links.Add(new { id = "app-stylesheet-" + batch + "-" + (links.Count + 1).ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" });
|
links.Add(new { id = "app-stylesheet-" + batch + "-" + (links.Count + 1).ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" });
|
||||||
}
|
}
|
||||||
|
if (links.Any())
|
||||||
|
{
|
||||||
await interop.IncludeLinks(links.ToArray());
|
await interop.IncludeLinks(links.ToArray());
|
||||||
|
}
|
||||||
await interop.RemoveElementsById("app-stylesheet", "", "app-stylesheet-" + batch + "-00");
|
await interop.RemoveElementsById("app-stylesheet", "", "app-stylesheet-" + batch + "-00");
|
||||||
|
|
||||||
// add favicon
|
// add favicon
|
||||||
|
@ -46,7 +49,7 @@
|
||||||
await interop.IncludeLink("app-favicon", "shortcut icon", Utilities.ContentUrl(PageState.Alias, PageState.Site.FaviconFileId.Value), "image/x-icon", "", "", "id");
|
await interop.IncludeLink("app-favicon", "shortcut icon", Utilities.ContentUrl(PageState.Alias, PageState.Site.FaviconFileId.Value), "image/x-icon", "", "", "id");
|
||||||
}
|
}
|
||||||
// add PWA support
|
// add PWA support
|
||||||
if (PageState.Site.PwaIsEnabled)
|
if (PageState.Site.PwaIsEnabled && PageState.Site.PwaAppIconFileId != null && PageState.Site.PwaSplashIconFileId != null)
|
||||||
{
|
{
|
||||||
await InitializePwa(interop);
|
await InitializePwa(interop);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +82,7 @@
|
||||||
"\"sizes\": \"512x512\", " +
|
"\"sizes\": \"512x512\", " +
|
||||||
"\"type\": \"image/png\" " +
|
"\"type\": \"image/png\" " +
|
||||||
"}] " +
|
"}] " +
|
||||||
"} " +
|
"}; " +
|
||||||
"const serialized = JSON.stringify(manifest); " +
|
"const serialized = JSON.stringify(manifest); " +
|
||||||
"const blob = new Blob([serialized], {type: 'application/javascript'}); " +
|
"const blob = new Blob([serialized], {type: 'application/javascript'}); " +
|
||||||
"const url = URL.createObjectURL(blob); " +
|
"const url = URL.createObjectURL(blob); " +
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
@using System
|
@using System
|
||||||
@using System.Linq
|
@using System.Linq
|
||||||
@using System.Collections.Generic
|
@using System.Collections.Generic
|
||||||
@using System.Net.Http
|
@using System.Net.Http
|
||||||
|
@using System.Net.Http.Json
|
||||||
|
|
||||||
@using Microsoft.AspNetCore.Components.Authorization
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Oqtane.Client</id>
|
<id>Oqtane.Client</id>
|
||||||
<version>1.0.3</version>
|
<version>2.0.0</version>
|
||||||
<authors>Shaun Walker</authors>
|
<authors>Shaun Walker</authors>
|
||||||
<owners>.NET Foundation</owners>
|
<owners>.NET Foundation</owners>
|
||||||
<title>Oqtane Framework</title>
|
<title>Oqtane Framework</title>
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
||||||
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
||||||
<tags>oqtane</tags>
|
<tags>oqtane</tags>
|
||||||
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</releaseNotes>
|
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</releaseNotes>
|
||||||
<summary>A modular application framework for Blazor</summary>
|
<summary>A modular application framework for Blazor</summary>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="..\Oqtane.Client\bin\Release\netstandard2.1\Oqtane.Client.dll" target="lib\netstandard2.1" />
|
<file src="..\Oqtane.Client\bin\Release\net5.0\Oqtane.Client.dll" target="lib\net5.0" />
|
||||||
<file src="..\Oqtane.Client\bin\Release\netstandard2.1\Oqtane.Client.pdb" target="lib\netstandard2.1" />
|
<file src="..\Oqtane.Client\bin\Release\net5.0\Oqtane.Client.pdb" target="lib\net5.0" />
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Oqtane.Framework</id>
|
<id>Oqtane.Framework</id>
|
||||||
<version>1.0.3</version>
|
<version>2.0.0</version>
|
||||||
<authors>Shaun Walker</authors>
|
<authors>Shaun Walker</authors>
|
||||||
<owners>.NET Foundation</owners>
|
<owners>.NET Foundation</owners>
|
||||||
<title>Oqtane Framework</title>
|
<title>Oqtane Framework</title>
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
||||||
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
||||||
<tags>oqtane framework</tags>
|
<tags>oqtane framework</tags>
|
||||||
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</releaseNotes>
|
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</releaseNotes>
|
||||||
<summary>A modular application framework for Blazor</summary>
|
<summary>A modular application framework for Blazor</summary>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\*.*" target="lib\netcoreapp3.1" />
|
<file src="..\Oqtane.Server\bin\Release\net5.0\publish\*.*" target="lib\net5.0" />
|
||||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\wwwroot\**\*.*" target="wwwroot" />
|
<file src="..\Oqtane.Server\bin\Release\net5.0\publish\wwwroot\**\*.*" target="wwwroot" />
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Oqtane.Server</id>
|
<id>Oqtane.Server</id>
|
||||||
<version>1.0.3</version>
|
<version>2.0.0</version>
|
||||||
<authors>Shaun Walker</authors>
|
<authors>Shaun Walker</authors>
|
||||||
<owners>.NET Foundation</owners>
|
<owners>.NET Foundation</owners>
|
||||||
<title>Oqtane Framework</title>
|
<title>Oqtane Framework</title>
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
||||||
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
||||||
<tags>oqtane</tags>
|
<tags>oqtane</tags>
|
||||||
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</releaseNotes>
|
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</releaseNotes>
|
||||||
<summary>A modular application framework for Blazor</summary>
|
<summary>A modular application framework for Blazor</summary>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Server.dll" target="lib\netcoreapp3.1" />
|
<file src="..\Oqtane.Server\bin\Release\net5.0\Oqtane.Server.dll" target="lib\net5.0" />
|
||||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Server.pdb" target="lib\netcoreapp3.1" />
|
<file src="..\Oqtane.Server\bin\Release\net5.0\Oqtane.Server.pdb" target="lib\net5.0" />
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Oqtane.Shared</id>
|
<id>Oqtane.Shared</id>
|
||||||
<version>1.0.3</version>
|
<version>2.0.0</version>
|
||||||
<authors>Shaun Walker</authors>
|
<authors>Shaun Walker</authors>
|
||||||
<owners>.NET Foundation</owners>
|
<owners>.NET Foundation</owners>
|
||||||
<title>Oqtane Framework</title>
|
<title>Oqtane Framework</title>
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
||||||
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
||||||
<tags>oqtane</tags>
|
<tags>oqtane</tags>
|
||||||
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</releaseNotes>
|
<releaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</releaseNotes>
|
||||||
<summary>A modular application framework for Blazor</summary>
|
<summary>A modular application framework for Blazor</summary>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="..\Oqtane.Shared\bin\Release\netstandard2.1\Oqtane.Shared.dll" target="lib\netstandard2.1" />
|
<file src="..\Oqtane.Shared\bin\Release\net5.0\Oqtane.Shared.dll" target="lib\net5.0" />
|
||||||
<file src="..\Oqtane.Shared\bin\Release\netstandard2.1\Oqtane.Shared.pdb" target="lib\netstandard2.1" />
|
<file src="..\Oqtane.Shared\bin\Release\net5.0\Oqtane.Shared.pdb" target="lib\net5.0" />
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
|
@ -1 +1 @@
|
||||||
Compress-Archive -Path "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.1.0.3.Install.zip" -Force
|
Compress-Archive -Path "..\Oqtane.Server\bin\Release\net5.0\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.2.0.0.Install.zip" -Force
|
|
@ -4,15 +4,15 @@ dotnet build -c Release ..\Oqtane.sln
|
||||||
nuget.exe pack Oqtane.Client.nuspec
|
nuget.exe pack Oqtane.Client.nuspec
|
||||||
nuget.exe pack Oqtane.Server.nuspec
|
nuget.exe pack Oqtane.Server.nuspec
|
||||||
nuget.exe pack Oqtane.Shared.nuspec
|
nuget.exe pack Oqtane.Shared.nuspec
|
||||||
del /F/Q/S "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish" > NUL
|
del /F/Q/S "..\Oqtane.Server\bin\Release\net5.0\publish" > NUL
|
||||||
rmdir /Q/S "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish"
|
rmdir /Q/S "..\Oqtane.Server\bin\Release\net5.0\publish"
|
||||||
dotnet publish ..\Oqtane.Server\Oqtane.Server.csproj /p:Configuration=Release
|
dotnet publish ..\Oqtane.Server\Oqtane.Server.csproj /p:Configuration=Release
|
||||||
del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.json"
|
del "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.json"
|
||||||
ren "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.release.json" "appsettings.json"
|
ren "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.release.json" "appsettings.json"
|
||||||
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\install.ps1"
|
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\install.ps1"
|
||||||
del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\appsettings.json"
|
del "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.json"
|
||||||
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\upgrade.ps1"
|
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\upgrade.ps1"
|
||||||
del "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\Oqtane.Upgrade.*"
|
del "..\Oqtane.Server\bin\Release\net5.0\publish\Oqtane.Upgrade.*"
|
||||||
nuget.exe pack Oqtane.Framework.nuspec
|
nuget.exe pack Oqtane.Framework.nuspec
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Compress-Archive -Path "..\Oqtane.Server\bin\Release\netcoreapp3.1\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.1.0.3.Upgrade.zip" -Force
|
Compress-Archive -Path "..\Oqtane.Server\bin\Release\net5.0\publish\*" -DestinationPath "..\Oqtane.Server\bin\Release\Oqtane.Framework.2.0.0.Upgrade.zip" -Force
|
|
@ -14,7 +14,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class AliasController : Controller
|
public class AliasController : Controller
|
||||||
{
|
{
|
||||||
private readonly IAliasRepository _aliases;
|
private readonly IAliasRepository _aliases;
|
||||||
|
@ -32,7 +32,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public IEnumerable<Alias> Get()
|
public IEnumerable<Alias> Get()
|
||||||
{
|
{
|
||||||
return _aliases.GetAliases();
|
return _aliases.GetAliases();
|
||||||
|
@ -40,7 +40,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Alias Get(int id)
|
public Alias Get(int id)
|
||||||
{
|
{
|
||||||
return _aliases.GetAlias(id);
|
return _aliases.GetAlias(id);
|
||||||
|
@ -86,7 +86,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Alias Post([FromBody] Alias alias)
|
public Alias Post([FromBody] Alias alias)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -99,7 +99,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Alias Put(int id, [FromBody] Alias alias)
|
public Alias Put(int id, [FromBody] Alias alias)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -112,7 +112,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_aliases.DeleteAlias(id);
|
_aliases.DeleteAlias(id);
|
||||||
|
|
|
@ -22,7 +22,7 @@ using Microsoft.AspNetCore.Routing.Constraints;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class FileController : Controller
|
public class FileController : Controller
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _environment;
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
@ -58,7 +58,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (User.IsInRole(Constants.HostRole))
|
if (User.IsInRole(RoleNames.Host))
|
||||||
{
|
{
|
||||||
folder = GetFolderPath(folder);
|
folder = GetFolderPath(folder);
|
||||||
if (Directory.Exists(folder))
|
if (Directory.Exists(folder))
|
||||||
|
@ -132,7 +132,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Models.File Put(int id, [FromBody] Models.File file)
|
public Models.File Put(int id, [FromBody] Models.File file)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.FolderId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.FolderId, PermissionNames.Edit))
|
||||||
|
@ -164,7 +164,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
Models.File file = _files.GetFile(id);
|
Models.File file = _files.GetFile(id);
|
||||||
|
@ -282,7 +282,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (User.IsInRole(Constants.HostRole))
|
if (User.IsInRole(RoleNames.Host))
|
||||||
{
|
{
|
||||||
folderPath = GetFolderPath(folder);
|
folderPath = GetFolderPath(folder);
|
||||||
}
|
}
|
||||||
|
@ -444,8 +444,8 @@ namespace Oqtane.Controllers
|
||||||
string filepath = Path.Combine(GetFolderPath(file.Folder), file.Name);
|
string filepath = Path.Combine(GetFolderPath(file.Folder), file.Name);
|
||||||
if (System.IO.File.Exists(filepath))
|
if (System.IO.File.Exists(filepath))
|
||||||
{
|
{
|
||||||
byte[] filebytes = System.IO.File.ReadAllBytes(filepath);
|
var stream = new FileStream(filepath, FileMode.Open);
|
||||||
return File(filebytes, "application/octet-stream", file.Name);
|
return File(stream, "application/octet-stream", file.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -453,8 +453,8 @@ namespace Oqtane.Controllers
|
||||||
HttpContext.Response.StatusCode = 404;
|
HttpContext.Response.StatusCode = 404;
|
||||||
if (System.IO.File.Exists(errorpath))
|
if (System.IO.File.Exists(errorpath))
|
||||||
{
|
{
|
||||||
byte[] filebytes = System.IO.File.ReadAllBytes(errorpath);
|
var stream = new FileStream(errorpath, FileMode.Open);
|
||||||
return File(filebytes, "application/octet-stream", file.Name);
|
return File(stream, "application/octet-stream", file.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,16 +462,16 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {FileId}", id);
|
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {FileId}", id);
|
||||||
HttpContext.Response.StatusCode = 401;
|
HttpContext.Response.StatusCode = 401;
|
||||||
byte[] filebytes = System.IO.File.ReadAllBytes(errorpath);
|
var stream = new FileStream(errorpath, FileMode.Open);
|
||||||
return File(filebytes, "application/octet-stream", file.Name);
|
return File(stream, "application/octet-stream", file.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "File Not Found {FileId}", id);
|
_logger.Log(LogLevel.Error, this, LogFunction.Read, "File Not Found {FileId}", id);
|
||||||
HttpContext.Response.StatusCode = 404;
|
HttpContext.Response.StatusCode = 404;
|
||||||
byte[] filebytes = System.IO.File.ReadAllBytes(errorpath);
|
var stream = new FileStream(errorpath, FileMode.Open);
|
||||||
return File(filebytes, "application/octet-stream", "error.png");
|
return File(stream, "application/octet-stream", file.Name);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class FolderController : Controller
|
public class FolderController : Controller
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _environment;
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
@ -93,7 +93,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Folder Post([FromBody] Folder folder)
|
public Folder Post([FromBody] Folder folder)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -106,7 +106,7 @@ namespace Oqtane.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permissions = new List<Permission> {
|
permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true),
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true),
|
||||||
}.EncodePermissions();
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
if (_userPermissions.IsAuthorized(User, PermissionNames.Edit, permissions))
|
if (_userPermissions.IsAuthorized(User, PermissionNames.Edit, permissions))
|
||||||
|
@ -141,7 +141,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Folder Put(int id, [FromBody] Folder folder)
|
public Folder Put(int id, [FromBody] Folder folder)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, folder.FolderId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, folder.FolderId, PermissionNames.Edit))
|
||||||
|
@ -182,7 +182,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/?siteid=x&folderid=y&parentid=z
|
// PUT api/<controller>/?siteid=x&folderid=y&parentid=z
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Put(int siteid, int folderid, int? parentid)
|
public void Put(int siteid, int folderid, int? parentid)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, folderid, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, folderid, PermissionNames.Edit))
|
||||||
|
@ -209,11 +209,16 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
|
Models.Folder _folder = _folders.GetFolder(id, false);
|
||||||
|
if (Directory.Exists(GetFolderPath(_folder)))
|
||||||
|
{
|
||||||
|
Directory.Delete(GetFolderPath(_folder));
|
||||||
|
}
|
||||||
_folders.DeleteFolder(id);
|
_folders.DeleteFolder(id);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,36 @@
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Oqtane.Models;
|
|
||||||
using Oqtane.Shared;
|
|
||||||
using Oqtane.Infrastructure;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
|
using Oqtane.Models;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
using Oqtane.Shared;
|
||||||
using Oqtane.Themes;
|
using Oqtane.Themes;
|
||||||
using System.Diagnostics;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class InstallationController : Controller
|
public class InstallationController : Controller
|
||||||
{
|
{
|
||||||
private readonly IConfigurationRoot _config;
|
private readonly IConfigurationRoot _config;
|
||||||
private readonly IInstallationManager _installationManager;
|
private readonly IInstallationManager _installationManager;
|
||||||
private readonly IDatabaseManager _databaseManager;
|
private readonly IDatabaseManager _databaseManager;
|
||||||
|
private readonly ILocalizationManager _localizationManager;
|
||||||
|
private readonly IMemoryCache _cache;
|
||||||
|
|
||||||
public InstallationController(IConfigurationRoot config, IInstallationManager installationManager, IDatabaseManager databaseManager)
|
public InstallationController(IConfigurationRoot config, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_installationManager = installationManager;
|
_installationManager = installationManager;
|
||||||
_databaseManager = databaseManager;
|
_databaseManager = databaseManager;
|
||||||
|
_localizationManager = localizationManager;
|
||||||
|
_cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
|
@ -35,7 +39,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
var installation = new Installation {Success = false, Message = ""};
|
var installation = new Installation {Success = false, Message = ""};
|
||||||
|
|
||||||
if (ModelState.IsValid && (User.IsInRole(Constants.HostRole) || string.IsNullOrEmpty(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
|
if (ModelState.IsValid && (User.IsInRole(RoleNames.Host) || string.IsNullOrEmpty(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
|
||||||
{
|
{
|
||||||
installation = _databaseManager.Install(config);
|
installation = _databaseManager.Install(config);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +60,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("upgrade")]
|
[HttpGet("upgrade")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Installation Upgrade()
|
public Installation Upgrade()
|
||||||
{
|
{
|
||||||
var installation = new Installation {Success = true, Message = ""};
|
var installation = new Installation {Success = true, Message = ""};
|
||||||
|
@ -70,63 +74,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
if (_config.GetSection("Runtime").Value == "WebAssembly")
|
if (_config.GetSection("Runtime").Value == "WebAssembly")
|
||||||
{
|
{
|
||||||
// get list of assemblies which should be downloaded to browser
|
return File(GetAssemblies(), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.zip");
|
||||||
var assemblies = AppDomain.CurrentDomain.GetOqtaneClientAssemblies();
|
|
||||||
var list = assemblies.Select(a => a.GetName().Name).ToList();
|
|
||||||
|
|
||||||
// get module and theme dependencies
|
|
||||||
foreach (var assembly in assemblies)
|
|
||||||
{
|
|
||||||
foreach (var type in assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IModule))))
|
|
||||||
{
|
|
||||||
var instance = Activator.CreateInstance(type) as IModule;
|
|
||||||
foreach (string name in instance.ModuleDefinition.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
if (!list.Contains(name)) list.Add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var type in assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(ITheme))))
|
|
||||||
{
|
|
||||||
var instance = Activator.CreateInstance(type) as ITheme;
|
|
||||||
foreach (string name in instance.Theme.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
if (!list.Contains(name)) list.Add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create zip file containing assemblies and debug symbols
|
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
||||||
byte[] zipfile;
|
|
||||||
using (var memoryStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
|
|
||||||
{
|
|
||||||
ZipArchiveEntry entry;
|
|
||||||
foreach (string file in list)
|
|
||||||
{
|
|
||||||
entry = archive.CreateEntry(file + ".dll");
|
|
||||||
using (var filestream = new FileStream(Path.Combine(binfolder, file + ".dll"), FileMode.Open, FileAccess.Read))
|
|
||||||
using (var entrystream = entry.Open())
|
|
||||||
{
|
|
||||||
filestream.CopyTo(entrystream);
|
|
||||||
}
|
|
||||||
|
|
||||||
// include debug symbols ( we may want to consider restricting this to only host users or when running in debug mode for performance )
|
|
||||||
if (System.IO.File.Exists(Path.Combine(binfolder, file + ".pdb")))
|
|
||||||
{
|
|
||||||
entry = archive.CreateEntry(file + ".pdb");
|
|
||||||
using (var filestream = new FileStream(Path.Combine(binfolder, file + ".pdb"), FileMode.Open, FileAccess.Read))
|
|
||||||
using (var entrystream = entry.Open())
|
|
||||||
{
|
|
||||||
filestream.CopyTo(entrystream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zipfile = memoryStream.ToArray();
|
|
||||||
}
|
|
||||||
return File(zipfile, "application/octet-stream", "oqtane.zip");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -134,5 +82,86 @@ namespace Oqtane.Controllers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] GetAssemblies()
|
||||||
|
{
|
||||||
|
return _cache.GetOrCreate("assemblies", entry =>
|
||||||
|
{
|
||||||
|
// get list of assemblies which should be downloaded to client
|
||||||
|
var assemblies = AppDomain.CurrentDomain.GetOqtaneClientAssemblies();
|
||||||
|
var list = assemblies.Select(a => a.GetName().Name).ToList();
|
||||||
|
var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
|
|
||||||
|
// insert satellite assemblies at beginning of list
|
||||||
|
foreach (var culture in _localizationManager.GetSupportedCultures())
|
||||||
|
{
|
||||||
|
var assembliesFolderPath = Path.Combine(binFolder, culture);
|
||||||
|
if (culture == Constants.DefaultCulture)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(assembliesFolderPath))
|
||||||
|
{
|
||||||
|
foreach (var resourceFile in Directory.EnumerateFiles(assembliesFolderPath))
|
||||||
|
{
|
||||||
|
list.Insert(0, Path.Combine(culture, Path.GetFileNameWithoutExtension(resourceFile)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert module and theme dependencies at beginning of list
|
||||||
|
foreach (var assembly in assemblies)
|
||||||
|
{
|
||||||
|
foreach (var type in assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IModule))))
|
||||||
|
{
|
||||||
|
var instance = Activator.CreateInstance(type) as IModule;
|
||||||
|
foreach (string name in instance.ModuleDefinition.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (!list.Contains(name)) list.Insert(0, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var type in assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(ITheme))))
|
||||||
|
{
|
||||||
|
var instance = Activator.CreateInstance(type) as ITheme;
|
||||||
|
foreach (string name in instance.Theme.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (!list.Contains(name)) list.Insert(0, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create zip file containing assemblies and debug symbols
|
||||||
|
using (var memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
|
||||||
|
{
|
||||||
|
foreach (string file in list)
|
||||||
|
{
|
||||||
|
using (var filestream = new FileStream(Path.Combine(binFolder, file + ".dll"), FileMode.Open, FileAccess.Read))
|
||||||
|
using (var entrystream = archive.CreateEntry(file + ".dll").Open())
|
||||||
|
{
|
||||||
|
filestream.CopyTo(entrystream);
|
||||||
|
}
|
||||||
|
|
||||||
|
// include debug symbols
|
||||||
|
if (System.IO.File.Exists(Path.Combine(binFolder, file + ".pdb")))
|
||||||
|
{
|
||||||
|
using (var filestream = new FileStream(Path.Combine(binFolder, file + ".pdb"), FileMode.Open, FileAccess.Read))
|
||||||
|
using (var entrystream = archive.CreateEntry(file + ".pdb").Open())
|
||||||
|
{
|
||||||
|
filestream.CopyTo(entrystream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return memoryStream.ToArray();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class JobController : Controller
|
public class JobController : Controller
|
||||||
{
|
{
|
||||||
private readonly IJobRepository _jobs;
|
private readonly IJobRepository _jobs;
|
||||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public IEnumerable<Job> Get()
|
public IEnumerable<Job> Get()
|
||||||
{
|
{
|
||||||
return _jobs.GetJobs();
|
return _jobs.GetJobs();
|
||||||
|
@ -36,7 +36,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Job Get(int id)
|
public Job Get(int id)
|
||||||
{
|
{
|
||||||
return _jobs.GetJob(id);
|
return _jobs.GetJob(id);
|
||||||
|
@ -44,7 +44,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Job Post([FromBody] Job job)
|
public Job Post([FromBody] Job job)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Job Put(int id, [FromBody] Job job)
|
public Job Put(int id, [FromBody] Job job)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -70,7 +70,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_jobs.DeleteJob(id);
|
_jobs.DeleteJob(id);
|
||||||
|
@ -79,7 +79,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/start
|
// GET api/<controller>/start
|
||||||
[HttpGet("start/{id}")]
|
[HttpGet("start/{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Start(int id)
|
public void Start(int id)
|
||||||
{
|
{
|
||||||
Job job = _jobs.GetJob(id);
|
Job job = _jobs.GetJob(id);
|
||||||
|
@ -93,7 +93,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/stop
|
// GET api/<controller>/stop
|
||||||
[HttpGet("stop/{id}")]
|
[HttpGet("stop/{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Stop(int id)
|
public void Stop(int id)
|
||||||
{
|
{
|
||||||
Job job = _jobs.GetJob(id);
|
Job job = _jobs.GetJob(id);
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class JobLogController : Controller
|
public class JobLogController : Controller
|
||||||
{
|
{
|
||||||
private readonly IJobLogRepository _jobLogs;
|
private readonly IJobLogRepository _jobLogs;
|
||||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public IEnumerable<JobLog> Get()
|
public IEnumerable<JobLog> Get()
|
||||||
{
|
{
|
||||||
return _jobLogs.GetJobLogs();
|
return _jobLogs.GetJobLogs();
|
||||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public JobLog Get(int id)
|
public JobLog Get(int id)
|
||||||
{
|
{
|
||||||
return _jobLogs.GetJobLog(id);
|
return _jobLogs.GetJobLog(id);
|
||||||
|
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public JobLog Post([FromBody] JobLog jobLog)
|
public JobLog Post([FromBody] JobLog jobLog)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public JobLog Put(int id, [FromBody] JobLog jobLog)
|
public JobLog Put(int id, [FromBody] JobLog jobLog)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_jobLogs.DeleteJobLog(id);
|
_jobLogs.DeleteJobLog(id);
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Shared;
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class LogController : Controller
|
public class LogController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?siteid=x&level=y&function=z&rows=50
|
// GET: api/<controller>?siteid=x&level=y&function=z&rows=50
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public IEnumerable<Log> Get(string siteid, string level, string function, string rows)
|
public IEnumerable<Log> Get(string siteid, string level, string function, string rows)
|
||||||
{
|
{
|
||||||
return _logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
|
return _logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
|
||||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Log Get(int id)
|
public Log Get(int id)
|
||||||
{
|
{
|
||||||
return _logs.GetLog(id);
|
return _logs.GetLog(id);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
@ -11,23 +11,29 @@ using Oqtane.Security;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class ModuleController : Controller
|
public class ModuleController : Controller
|
||||||
{
|
{
|
||||||
private readonly IModuleRepository _modules;
|
private readonly IModuleRepository _modules;
|
||||||
private readonly IPageModuleRepository _pageModules;
|
private readonly IPageModuleRepository _pageModules;
|
||||||
private readonly IPageRepository _pages;
|
private readonly IPageRepository _pages;
|
||||||
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
||||||
|
private readonly ISettingRepository _settings;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
|
private readonly ITenantResolver _tenants;
|
||||||
|
private readonly ISyncManager _syncManager;
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
|
|
||||||
public ModuleController(IModuleRepository modules, IPageModuleRepository pageModules, IPageRepository pages, IModuleDefinitionRepository moduleDefinitions, IUserPermissions userPermissions, ILogManager logger)
|
public ModuleController(IModuleRepository modules, IPageModuleRepository pageModules, IPageRepository pages, IModuleDefinitionRepository moduleDefinitions, ISettingRepository settings, IUserPermissions userPermissions, ITenantResolver tenants, ISyncManager syncManager, ILogManager logger)
|
||||||
{
|
{
|
||||||
_modules = modules;
|
_modules = modules;
|
||||||
_pageModules = pageModules;
|
_pageModules = pageModules;
|
||||||
_pages = pages;
|
_pages = pages;
|
||||||
_moduleDefinitions = moduleDefinitions;
|
_moduleDefinitions = moduleDefinitions;
|
||||||
|
_settings = settings;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
|
_tenants = tenants;
|
||||||
|
_syncManager = syncManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +42,8 @@ namespace Oqtane.Controllers
|
||||||
public IEnumerable<Module> Get(string siteid)
|
public IEnumerable<Module> Get(string siteid)
|
||||||
{
|
{
|
||||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList();
|
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList();
|
||||||
|
List<Setting> settings = _settings.GetSettings(EntityNames.Module).ToList();
|
||||||
|
|
||||||
List<Module> modules = new List<Module>();
|
List<Module> modules = new List<Module>();
|
||||||
foreach (PageModule pagemodule in _pageModules.GetPageModules(int.Parse(siteid)))
|
foreach (PageModule pagemodule in _pageModules.GetPageModules(int.Parse(siteid)))
|
||||||
{
|
{
|
||||||
|
@ -61,6 +69,8 @@ namespace Oqtane.Controllers
|
||||||
module.ContainerType = pagemodule.ContainerType;
|
module.ContainerType = pagemodule.ContainerType;
|
||||||
|
|
||||||
module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
||||||
|
module.Settings = settings.Where(item => item.EntityId == pagemodule.ModuleId)
|
||||||
|
.ToDictionary(setting => setting.SettingName, setting => setting.SettingValue);
|
||||||
|
|
||||||
modules.Add(module);
|
modules.Add(module);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +87,9 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||||
module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
||||||
|
module.Settings = _settings.GetSettings(EntityNames.Module, id)
|
||||||
|
.ToDictionary(setting => setting.SettingName, setting => setting.SettingValue);
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -89,12 +102,13 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Module Post([FromBody] Module module)
|
public Module Post([FromBody] Module module)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, module.PageId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, module.PageId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
module = _modules.AddModule(module);
|
module = _modules.AddModule(module);
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", module);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", module);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -108,7 +122,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Module Put(int id, [FromBody] Module module)
|
public Module Put(int id, [FromBody] Module module)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
||||||
|
@ -128,6 +142,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -140,12 +155,13 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Module, id, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Module, id, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
_modules.DeleteModule(id);
|
_modules.DeleteModule(id);
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleId}", id);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleId}", id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -157,7 +173,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/export?moduleid=x
|
// GET api/<controller>/export?moduleid=x
|
||||||
[HttpGet("export")]
|
[HttpGet("export")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public string Export(int moduleid)
|
public string Export(int moduleid)
|
||||||
{
|
{
|
||||||
string content = "";
|
string content = "";
|
||||||
|
@ -175,7 +191,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>/import?moduleid=x
|
// POST api/<controller>/import?moduleid=x
|
||||||
[HttpPost("import")]
|
[HttpPost("import")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public bool Import(int moduleid, [FromBody] string content)
|
public bool Import(int moduleid, [FromBody] string content)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
@ -15,10 +15,11 @@ using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class ModuleDefinitionController : Controller
|
public class ModuleDefinitionController : Controller
|
||||||
{
|
{
|
||||||
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
||||||
|
@ -80,7 +81,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public void Put(int id, [FromBody] ModuleDefinition moduleDefinition)
|
public void Put(int id, [FromBody] ModuleDefinition moduleDefinition)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -91,7 +92,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("install")]
|
[HttpGet("install")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void InstallModules()
|
public void InstallModules()
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
|
||||||
|
@ -100,7 +101,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5?siteid=x
|
// DELETE api/<controller>/5?siteid=x
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(int id, int siteid)
|
public void Delete(int id, int siteid)
|
||||||
{
|
{
|
||||||
ModuleDefinition moduledefinition = _moduleDefinitions.GetModuleDefinition(id, siteid);
|
ModuleDefinition moduledefinition = _moduleDefinitions.GetModuleDefinition(id, siteid);
|
||||||
|
@ -110,6 +111,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
Type moduletype = Type.GetType(moduledefinition.ServerManagerType);
|
Type moduletype = Type.GetType(moduledefinition.ServerManagerType);
|
||||||
|
|
||||||
|
// execute uninstall logic
|
||||||
foreach (Tenant tenant in _tenants.GetTenants())
|
foreach (Tenant tenant in _tenants.GetTenants())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -131,24 +133,27 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use assets.json to clean up file resources
|
||||||
|
string assetfilepath = Path.Combine(_environment.WebRootPath, "Modules", Utilities.GetTypeName(moduledefinition.ModuleDefinitionName), "assets.json");
|
||||||
|
if (System.IO.File.Exists(assetfilepath))
|
||||||
|
{
|
||||||
|
List<string> assets = JsonSerializer.Deserialize<List<string>>(System.IO.File.ReadAllText(assetfilepath));
|
||||||
|
foreach(string asset in assets)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(asset))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Assets Removed For {ModuleDefinitionName}", moduledefinition.ModuleDefinitionName);
|
||||||
|
}
|
||||||
|
|
||||||
// clean up module static resource folder
|
// clean up module static resource folder
|
||||||
string folder = Path.Combine(_environment.WebRootPath, Path.Combine("Modules", Utilities.GetTypeName(moduledefinition.ModuleDefinitionName)));
|
string folder = Path.Combine(_environment.WebRootPath, Path.Combine("Modules", Utilities.GetTypeName(moduledefinition.ModuleDefinitionName)));
|
||||||
if (Directory.Exists(folder))
|
if (Directory.Exists(folder))
|
||||||
{
|
{
|
||||||
Directory.Delete(folder, true);
|
Directory.Delete(folder, true);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Static Resources Removed For {ModuleDefinitionName}", moduledefinition.ModuleDefinitionName);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Resources Folder Removed For {ModuleDefinitionName}", moduledefinition.ModuleDefinitionName);
|
||||||
}
|
|
||||||
|
|
||||||
// get root assembly name ( note that this only works if modules follow a specific naming convention for their assemblies )
|
|
||||||
string assemblyname = Utilities.GetAssemblyName(moduledefinition.ModuleDefinitionName).ToLower();
|
|
||||||
assemblyname = assemblyname.Replace(".client", "").Replace(".oqtane", "");
|
|
||||||
|
|
||||||
// remove module assemblies from /bin
|
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
||||||
foreach (string file in Directory.EnumerateFiles(binfolder, assemblyname + "*.*"))
|
|
||||||
{
|
|
||||||
System.IO.File.Delete(file);
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Assembly {Filename} Removed For {ModuleDefinitionName}", file, moduledefinition.ModuleDefinitionName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove module definition
|
// remove module definition
|
||||||
|
@ -163,7 +168,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>?moduleid=x
|
// POST api/<controller>?moduleid=x
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Post([FromBody] ModuleDefinition moduleDefinition, string moduleid)
|
public void Post([FromBody] ModuleDefinition moduleDefinition, string moduleid)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -235,7 +240,20 @@ namespace Oqtane.Controllers
|
||||||
text = text.Replace("[ServerManagerType]", moduleDefinition.ServerManagerType);
|
text = text.Replace("[ServerManagerType]", moduleDefinition.ServerManagerType);
|
||||||
text = text.Replace("[Folder]", folderPath);
|
text = text.Replace("[Folder]", folderPath);
|
||||||
text = text.Replace("[File]", Path.GetFileName(filePath));
|
text = text.Replace("[File]", Path.GetFileName(filePath));
|
||||||
|
if (moduleDefinition.Version == "local")
|
||||||
|
{
|
||||||
text = text.Replace("[FrameworkVersion]", Constants.Version);
|
text = text.Replace("[FrameworkVersion]", Constants.Version);
|
||||||
|
text = text.Replace("[ClientReference]", "<Reference Include=\"Oqtane.Client\"><HintPath>..\\..\\oqtane.framework\\Oqtane.Server\\bin\\Debug\\net5.0\\Oqtane.Client.dll</HintPath></Reference>");
|
||||||
|
text = text.Replace("[ServerReference]", "<Reference Include=\"Oqtane.Server\"><HintPath>..\\..\\oqtane.framework\\Oqtane.Server\\bin\\Debug\\net5.0\\Oqtane.Server.dll</HintPath></Reference>");
|
||||||
|
text = text.Replace("[SharedReference]", "<Reference Include=\"Oqtane.Shared\"><HintPath>..\\..\\oqtane.framework\\Oqtane.Server\\bin\\Debug\\net5.0\\Oqtane.Shared.dll</HintPath></Reference>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = text.Replace("[FrameworkVersion]", moduleDefinition.Version);
|
||||||
|
text = text.Replace("[ClientReference]", "<PackageReference Include=\"Oqtane.Client\" Version=\"" + moduleDefinition.Version + "\" />");
|
||||||
|
text = text.Replace("[ServerReference]", "<PackageReference Include=\"Oqtane.Server\" Version=\"" + moduleDefinition.Version + "\" />");
|
||||||
|
text = text.Replace("[SharedReference]", "<PackageReference Include=\"Oqtane.Shared\" Version=\"" + moduleDefinition.Version + "\" />");
|
||||||
|
}
|
||||||
System.IO.File.WriteAllText(filePath, text);
|
System.IO.File.WriteAllText(filePath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Oqtane.Security;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class NotificationController : Controller
|
public class NotificationController : Controller
|
||||||
{
|
{
|
||||||
private readonly INotificationRepository _notifications;
|
private readonly INotificationRepository _notifications;
|
||||||
|
@ -26,7 +26,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?siteid=x&type=y&userid=z
|
// GET: api/<controller>?siteid=x&type=y&userid=z
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public IEnumerable<Notification> Get(string siteid, string direction, string userid)
|
public IEnumerable<Notification> Get(string siteid, string direction, string userid)
|
||||||
{
|
{
|
||||||
IEnumerable<Notification> notifications = null;
|
IEnumerable<Notification> notifications = null;
|
||||||
|
@ -46,7 +46,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Notification Get(int id)
|
public Notification Get(int id)
|
||||||
{
|
{
|
||||||
Notification notification = _notifications.GetNotification(id);
|
Notification notification = _notifications.GetNotification(id);
|
||||||
|
@ -59,7 +59,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Notification Post([FromBody] Notification notification)
|
public Notification Post([FromBody] Notification notification)
|
||||||
{
|
{
|
||||||
if (IsAuthorized(notification.FromUserId))
|
if (IsAuthorized(notification.FromUserId))
|
||||||
|
@ -72,7 +72,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Notification Put(int id, [FromBody] Notification notification)
|
public Notification Put(int id, [FromBody] Notification notification)
|
||||||
{
|
{
|
||||||
if (IsAuthorized(notification.FromUserId))
|
if (IsAuthorized(notification.FromUserId))
|
||||||
|
@ -85,7 +85,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
Notification notification = _notifications.GetNotification(id);
|
Notification notification = _notifications.GetNotification(id);
|
||||||
|
|
|
@ -15,7 +15,7 @@ using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class PackageController : Controller
|
public class PackageController : Controller
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _environment;
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
@ -27,15 +27,14 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?tag=x
|
// GET: api/<controller>?tag=x
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public async Task<IEnumerable<Package>> Get(string tag)
|
public async Task<IEnumerable<Package>> Get(string tag)
|
||||||
{
|
{
|
||||||
List<Package> packages = new List<Package>();
|
List<Package> packages = new List<Package>();
|
||||||
|
|
||||||
using (var httpClient = new HttpClient())
|
using (var httpClient = new HttpClient())
|
||||||
{
|
{
|
||||||
CancellationToken token;
|
var searchResult = await GetJson<SearchResult>(httpClient, "https://azuresearch-usnc.nuget.org/query?q=tags:oqtane");
|
||||||
var searchResult = await GetJson<SearchResult>(httpClient, "https://azuresearch-usnc.nuget.org/query?q=tags:oqtane", token);
|
|
||||||
foreach(Data data in searchResult.Data)
|
foreach(Data data in searchResult.Data)
|
||||||
{
|
{
|
||||||
if (data.Tags.Contains(tag))
|
if (data.Tags.Contains(tag))
|
||||||
|
@ -56,14 +55,13 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public async Task Post(string packageid, string version, string folder)
|
public async Task Post(string packageid, string version, string folder)
|
||||||
{
|
{
|
||||||
using (var httpClient = new HttpClient())
|
using (var httpClient = new HttpClient())
|
||||||
{
|
{
|
||||||
CancellationToken token;
|
|
||||||
folder = Path.Combine(_environment.WebRootPath, folder);
|
folder = Path.Combine(_environment.WebRootPath, folder);
|
||||||
var response = await httpClient.GetAsync("https://www.nuget.org/api/v2/package/" + packageid.ToLower() + "/" + version, token).ConfigureAwait(false);
|
var response = await httpClient.GetAsync("https://www.nuget.org/api/v2/package/" + packageid.ToLower() + "/" + version).ConfigureAwait(false);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
string filename = packageid + "." + version + ".nupkg";
|
string filename = packageid + "." + version + ".nupkg";
|
||||||
using (var fileStream = new FileStream(Path.Combine(folder, filename), FileMode.Create, FileAccess.Write, FileShare.None))
|
using (var fileStream = new FileStream(Path.Combine(folder, filename), FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
@ -73,10 +71,10 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<T> GetJson<T>(HttpClient httpClient, string url, CancellationToken token)
|
private async Task<T> GetJson<T>(HttpClient httpClient, string url)
|
||||||
{
|
{
|
||||||
Uri uri = new Uri(url);
|
Uri uri = new Uri(url);
|
||||||
var response = await httpClient.GetAsync(uri, token).ConfigureAwait(false);
|
var response = await httpClient.GetAsync(uri).ConfigureAwait(false);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var stream = await response.Content.ReadAsStreamAsync();
|
var stream = await response.Content.ReadAsStreamAsync();
|
||||||
using (var streamReader = new StreamReader(stream))
|
using (var streamReader = new StreamReader(stream))
|
||||||
|
|
|
@ -13,7 +13,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class PageController : Controller
|
public class PageController : Controller
|
||||||
{
|
{
|
||||||
private readonly IPageRepository _pages;
|
private readonly IPageRepository _pages;
|
||||||
|
@ -102,7 +102,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Page Post([FromBody] Page page)
|
public Page Post([FromBody] Page page)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -115,7 +115,7 @@ namespace Oqtane.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permissions = new List<Permission> {
|
permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions();
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>/5?userid=x
|
// POST api/<controller>/5?userid=x
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Page Post(int id, string userid)
|
public Page Post(int id, string userid)
|
||||||
{
|
{
|
||||||
Page page = null;
|
Page page = null;
|
||||||
|
@ -213,7 +213,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Page Put(int id, [FromBody] Page page)
|
public Page Put(int id, [FromBody] Page page)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, page.PageId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, page.PageId, PermissionNames.Edit))
|
||||||
|
@ -233,7 +233,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/?siteid=x&pageid=y&parentid=z
|
// PUT api/<controller>/?siteid=x&pageid=y&parentid=z
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Put(int siteid, int pageid, int? parentid)
|
public void Put(int siteid, int pageid, int? parentid)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
||||||
|
@ -261,7 +261,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
Page page = _pages.GetPage(id);
|
Page page = _pages.GetPage(id);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
@ -11,7 +11,7 @@ using Oqtane.Security;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class PageModuleController : Controller
|
public class PageModuleController : Controller
|
||||||
{
|
{
|
||||||
private readonly IPageModuleRepository _pageModules;
|
private readonly IPageModuleRepository _pageModules;
|
||||||
|
@ -65,13 +65,13 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public PageModule Post([FromBody] PageModule pageModule)
|
public PageModule Post([FromBody] PageModule pageModule)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, pageModule.PageId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, pageModule.PageId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
pageModule = _pageModules.AddPageModule(pageModule);
|
pageModule = _pageModules.AddPageModule(pageModule);
|
||||||
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Page, pageModule.PageId);
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", pageModule);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", pageModule);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,13 +85,13 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public PageModule Put(int id, [FromBody] PageModule pageModule)
|
public PageModule Put(int id, [FromBody] PageModule pageModule)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, pageModule.ModuleId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, pageModule.ModuleId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
pageModule = _pageModules.UpdatePageModule(pageModule);
|
pageModule = _pageModules.UpdatePageModule(pageModule);
|
||||||
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Page, pageModule.PageId);
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", pageModule);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", pageModule);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -105,7 +105,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/?pageid=x&pane=y
|
// PUT api/<controller>/?pageid=x&pane=y
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Put(int pageid, string pane)
|
public void Put(int pageid, string pane)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
||||||
|
@ -121,7 +121,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
order += 2;
|
order += 2;
|
||||||
}
|
}
|
||||||
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Page, pageid);
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Order Updated {PageId} {Pane}", pageid, pane);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Order Updated {PageId} {Pane}", pageid, pane);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -133,14 +133,14 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
PageModule pagemodule = _pageModules.GetPageModule(id);
|
PageModule pagemodule = _pageModules.GetPageModule(id);
|
||||||
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pagemodule.PageId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pagemodule.PageId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
_pageModules.DeletePageModule(id);
|
_pageModules.DeletePageModule(id);
|
||||||
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Page, pagemodule.PageId);
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Module Deleted {PageModuleId}", id);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Module Deleted {PageModuleId}", id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class ProfileController : Controller
|
public class ProfileController : Controller
|
||||||
{
|
{
|
||||||
private readonly IProfileRepository _profiles;
|
private readonly IProfileRepository _profiles;
|
||||||
|
@ -37,7 +37,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Profile Post([FromBody] Profile profile)
|
public Profile Post([FromBody] Profile profile)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -50,7 +50,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Profile Put(int id, [FromBody] Profile profile)
|
public Profile Put(int id, [FromBody] Profile profile)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -63,7 +63,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_profiles.DeleteProfile(id);
|
_profiles.DeleteProfile(id);
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class RoleController : Controller
|
public class RoleController : Controller
|
||||||
{
|
{
|
||||||
private readonly IRoleRepository _roles;
|
private readonly IRoleRepository _roles;
|
||||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?siteid=x
|
// GET: api/<controller>?siteid=x
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public IEnumerable<Role> Get(string siteid)
|
public IEnumerable<Role> Get(string siteid)
|
||||||
{
|
{
|
||||||
return _roles.GetRoles(int.Parse(siteid));
|
return _roles.GetRoles(int.Parse(siteid));
|
||||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public Role Get(int id)
|
public Role Get(int id)
|
||||||
{
|
{
|
||||||
return _roles.GetRole(id);
|
return _roles.GetRole(id);
|
||||||
|
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Role Post([FromBody] Role role)
|
public Role Post([FromBody] Role role)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Role Put(int id, [FromBody] Role role)
|
public Role Put(int id, [FromBody] Role role)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_roles.DeleteRole(id);
|
_roles.DeleteRole(id);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
@ -10,19 +10,23 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class SettingController : Controller
|
public class SettingController : Controller
|
||||||
{
|
{
|
||||||
private readonly ISettingRepository _settings;
|
private readonly ISettingRepository _settings;
|
||||||
private readonly IPageModuleRepository _pageModules;
|
private readonly IPageModuleRepository _pageModules;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
|
private readonly ITenantResolver _tenants;
|
||||||
|
private readonly ISyncManager _syncManager;
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
|
|
||||||
public SettingController(ISettingRepository settings, IPageModuleRepository pageModules, IUserPermissions userPermissions, ILogManager logger)
|
public SettingController(ISettingRepository settings, IPageModuleRepository pageModules, IUserPermissions userPermissions, ITenantResolver tenants, ISyncManager syncManager, ILogManager logger)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
_pageModules = pageModules;
|
_pageModules = pageModules;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
|
_tenants = tenants;
|
||||||
|
_syncManager = syncManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +71,10 @@ namespace Oqtane.Controllers
|
||||||
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
setting = _settings.AddSetting(setting);
|
setting = _settings.AddSetting(setting);
|
||||||
|
if (setting.EntityName == EntityNames.Module)
|
||||||
|
{
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
|
}
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", setting);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", setting);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,6 +93,10 @@ namespace Oqtane.Controllers
|
||||||
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
setting = _settings.UpdateSetting(setting);
|
setting = _settings.UpdateSetting(setting);
|
||||||
|
if (setting.EntityName == EntityNames.Module)
|
||||||
|
{
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
|
}
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", setting);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", setting);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -104,6 +116,10 @@ namespace Oqtane.Controllers
|
||||||
if (IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
if (IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
_settings.DeleteSetting(id);
|
_settings.DeleteSetting(id);
|
||||||
|
if (setting.EntityName == EntityNames.Module)
|
||||||
|
{
|
||||||
|
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, _tenants.GetAlias().SiteId);
|
||||||
|
}
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Setting Deleted {Setting}", setting);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Setting Deleted {Setting}", setting);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -124,10 +140,10 @@ namespace Oqtane.Controllers
|
||||||
switch (entityName)
|
switch (entityName)
|
||||||
{
|
{
|
||||||
case EntityNames.Tenant:
|
case EntityNames.Tenant:
|
||||||
authorized = User.IsInRole(Constants.HostRole);
|
authorized = User.IsInRole(RoleNames.Host);
|
||||||
break;
|
break;
|
||||||
case EntityNames.Site:
|
case EntityNames.Site:
|
||||||
authorized = User.IsInRole(Constants.AdminRole);
|
authorized = User.IsInRole(RoleNames.Admin);
|
||||||
break;
|
break;
|
||||||
case EntityNames.Page:
|
case EntityNames.Page:
|
||||||
case EntityNames.Module:
|
case EntityNames.Module:
|
||||||
|
@ -138,7 +154,7 @@ namespace Oqtane.Controllers
|
||||||
authorized = true;
|
authorized = true;
|
||||||
if (permissionName == PermissionNames.Edit)
|
if (permissionName == PermissionNames.Edit)
|
||||||
{
|
{
|
||||||
authorized = User.IsInRole(Constants.AdminRole) || (_userPermissions.GetUser(User).UserId == entityId);
|
authorized = User.IsInRole(RoleNames.Admin) || (_userPermissions.GetUser(User).UserId == entityId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class SiteController : Controller
|
public class SiteController : Controller
|
||||||
{
|
{
|
||||||
private readonly ISiteRepository _sites;
|
private readonly ISiteRepository _sites;
|
||||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public IEnumerable<Site> Get()
|
public IEnumerable<Site> Get()
|
||||||
{
|
{
|
||||||
return _sites.GetSites();
|
return _sites.GetSites();
|
||||||
|
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
authorized = User.IsInRole(Constants.HostRole);
|
authorized = User.IsInRole(RoleNames.Host);
|
||||||
}
|
}
|
||||||
if (authorized)
|
if (authorized)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Site Put(int id, [FromBody] Site site)
|
public Site Put(int id, [FromBody] Site site)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -84,7 +84,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_sites.DeleteSite(id);
|
_sites.DeleteSite(id);
|
||||||
|
|
|
@ -7,7 +7,7 @@ using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class SiteTemplateController : Controller
|
public class SiteTemplateController : Controller
|
||||||
{
|
{
|
||||||
private readonly ISiteTemplateRepository _siteTemplates;
|
private readonly ISiteTemplateRepository _siteTemplates;
|
||||||
|
@ -19,7 +19,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public IEnumerable<SiteTemplate> Get()
|
public IEnumerable<SiteTemplate> Get()
|
||||||
{
|
{
|
||||||
return _siteTemplates.GetSiteTemplates();
|
return _siteTemplates.GetSiteTemplates();
|
||||||
|
|
|
@ -14,7 +14,7 @@ using System;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class SqlController : Controller
|
public class SqlController : Controller
|
||||||
{
|
{
|
||||||
private readonly ITenantRepository _tenants;
|
private readonly ITenantRepository _tenants;
|
||||||
|
@ -30,7 +30,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST: api/<controller>
|
// POST: api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public SqlQuery Post([FromBody] SqlQuery sqlquery)
|
public SqlQuery Post([FromBody] SqlQuery sqlquery)
|
||||||
{
|
{
|
||||||
var results = new List<Dictionary<string, string>>();
|
var results = new List<Dictionary<string, string>>();
|
||||||
|
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class SystemController : Controller
|
public class SystemController : Controller
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _environment;
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
@ -19,7 +19,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Dictionary<string, string> Get()
|
public Dictionary<string, string> Get()
|
||||||
{
|
{
|
||||||
Dictionary<string, string> systeminfo = new Dictionary<string, string>();
|
Dictionary<string, string> systeminfo = new Dictionary<string, string>();
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class TenantController : Controller
|
public class TenantController : Controller
|
||||||
{
|
{
|
||||||
private readonly ITenantRepository _tenants;
|
private readonly ITenantRepository _tenants;
|
||||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public IEnumerable<Tenant> Get()
|
public IEnumerable<Tenant> Get()
|
||||||
{
|
{
|
||||||
return _tenants.GetTenants();
|
return _tenants.GetTenants();
|
||||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public Tenant Get(int id)
|
public Tenant Get(int id)
|
||||||
{
|
{
|
||||||
return _tenants.GetTenant(id);
|
return _tenants.GetTenant(id);
|
||||||
|
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Tenant Post([FromBody] Tenant tenant)
|
public Tenant Post([FromBody] Tenant tenant)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public Tenant Put(int id, [FromBody] Tenant tenant)
|
public Tenant Put(int id, [FromBody] Tenant tenant)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
_tenants.DeleteTenant(id);
|
_tenants.DeleteTenant(id);
|
||||||
|
|
|
@ -10,12 +10,13 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class ThemeController : Controller
|
public class ThemeController : Controller
|
||||||
{
|
{
|
||||||
private readonly IThemeRepository _themes;
|
private readonly IThemeRepository _themes;
|
||||||
|
@ -33,14 +34,14 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = RoleNames.Registered)]
|
||||||
public IEnumerable<Theme> Get()
|
public IEnumerable<Theme> Get()
|
||||||
{
|
{
|
||||||
return _themes.GetThemes();
|
return _themes.GetThemes();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("install")]
|
[HttpGet("install")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void InstallThemes()
|
public void InstallThemes()
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
|
||||||
|
@ -49,47 +50,39 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/xxx
|
// DELETE api/<controller>/xxx
|
||||||
[HttpDelete("{themename}")]
|
[HttpDelete("{themename}")]
|
||||||
[Authorize(Roles = Constants.HostRole)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public void Delete(string themename)
|
public void Delete(string themename)
|
||||||
{
|
{
|
||||||
List<Theme> themes = _themes.GetThemes().ToList();
|
List<Theme> themes = _themes.GetThemes().ToList();
|
||||||
Theme theme = themes.Where(item => item.ThemeName == themename).FirstOrDefault();
|
Theme theme = themes.Where(item => item.ThemeName == themename).FirstOrDefault();
|
||||||
if (theme != null && Utilities.GetAssemblyName(theme.ThemeName) != "Oqtane.Client")
|
if (theme != null && Utilities.GetAssemblyName(theme.ThemeName) != "Oqtane.Client")
|
||||||
{
|
{
|
||||||
|
// use assets.json to clean up file resources
|
||||||
|
string assetfilepath = Path.Combine(_environment.WebRootPath, "Themes", Utilities.GetTypeName(theme.ThemeName), "assets.json");
|
||||||
|
if (System.IO.File.Exists(assetfilepath))
|
||||||
|
{
|
||||||
|
List<string> assets = JsonSerializer.Deserialize<List<string>>(System.IO.File.ReadAllText(assetfilepath));
|
||||||
|
foreach (string asset in assets)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(asset))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Assets Removed For {ThemeName}", theme.ThemeName);
|
||||||
|
}
|
||||||
|
|
||||||
// clean up theme static resource folder
|
// clean up theme static resource folder
|
||||||
string folder = Path.Combine(_environment.WebRootPath, "Themes" , Utilities.GetTypeName(theme.ThemeName));
|
string folder = Path.Combine(_environment.WebRootPath, "Themes" , Utilities.GetTypeName(theme.ThemeName));
|
||||||
if (Directory.Exists(folder))
|
if (Directory.Exists(folder))
|
||||||
{
|
{
|
||||||
Directory.Delete(folder, true);
|
Directory.Delete(folder, true);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Static Resources Removed For {ThemeName}", theme.ThemeName);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Resource Folder Removed For {ThemeName}", theme.ThemeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove theme assembly from /bin
|
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
||||||
System.IO.File.Delete(Path.Combine(binfolder, Utilities.GetAssemblyName(theme.ThemeName) + ".dll"));
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Assembly {Filename} Removed For {ThemeName}", Utilities.GetAssemblyName(theme.ThemeName) + ".dll", themename);
|
|
||||||
|
|
||||||
_installationManager.RestartApplication();
|
_installationManager.RestartApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET api/<controller>/load/assembyname
|
|
||||||
[HttpGet("load/{assemblyname}")]
|
|
||||||
public IActionResult Load(string assemblyname)
|
|
||||||
{
|
|
||||||
if (Path.GetExtension(assemblyname).ToLower() == ".dll")
|
|
||||||
{
|
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
||||||
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, assemblyname));
|
|
||||||
return File(file, "application/octet-stream", assemblyname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Download Assembly {Assembly}", assemblyname);
|
|
||||||
HttpContext.Response.StatusCode = 401;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,11 @@ using System.Net;
|
||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
|
using Oqtane.Extensions;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class UserController : Controller
|
public class UserController : Controller
|
||||||
{
|
{
|
||||||
private readonly IUserRepository _users;
|
private readonly IUserRepository _users;
|
||||||
|
@ -76,7 +77,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
private User Filter(User user)
|
private User Filter(User user)
|
||||||
{
|
{
|
||||||
if (user != null && !User.IsInRole(Constants.AdminRole) && User.Identity.Name?.ToLower() != user.Username.ToLower())
|
if (user != null && !User.IsInRole(RoleNames.Admin) && User.Identity.Name?.ToLower() != user.Username.ToLower())
|
||||||
{
|
{
|
||||||
user.DisplayName = "";
|
user.DisplayName = "";
|
||||||
user.Email = "";
|
user.Email = "";
|
||||||
|
@ -117,7 +118,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
bool verified;
|
bool verified;
|
||||||
bool allowregistration;
|
bool allowregistration;
|
||||||
if (user.Username == Constants.HostUser || User.IsInRole(Constants.AdminRole))
|
if (user.Username == UserNames.Host || User.IsInRole(RoleNames.Admin))
|
||||||
{
|
{
|
||||||
verified = true;
|
verified = true;
|
||||||
allowregistration = true;
|
allowregistration = true;
|
||||||
|
@ -163,9 +164,9 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign to host role if this is the host user ( initial installation )
|
// assign to host role if this is the host user ( initial installation )
|
||||||
if (user.Username == Constants.HostUser)
|
if (user.Username == UserNames.Host)
|
||||||
{
|
{
|
||||||
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == RoleNames.Host).FirstOrDefault().RoleId;
|
||||||
UserRole userrole = new UserRole();
|
UserRole userrole = new UserRole();
|
||||||
userrole.UserId = newUser.UserId;
|
userrole.UserId = newUser.UserId;
|
||||||
userrole.RoleId = hostroleid;
|
userrole.RoleId = hostroleid;
|
||||||
|
@ -186,8 +187,12 @@ namespace Oqtane.Controllers
|
||||||
Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),Path.DirectorySeparatorChar.ToString()),
|
Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),Path.DirectorySeparatorChar.ToString()),
|
||||||
Order = 1,
|
Order = 1,
|
||||||
IsSystem = true,
|
IsSystem = true,
|
||||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" +
|
Permissions = new List<Permission>
|
||||||
newUser.UserId.ToString() + "]\"}]"
|
{
|
||||||
|
new Permission(PermissionNames.Browse, newUser.UserId, true),
|
||||||
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
|
new Permission(PermissionNames.Edit, newUser.UserId, true)
|
||||||
|
}.EncodePermissions()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +206,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newUser != null && user.Username != Constants.HostUser)
|
if (newUser != null && user.Username != UserNames.Host)
|
||||||
{
|
{
|
||||||
// add auto assigned roles to user for site
|
// add auto assigned roles to user for site
|
||||||
List<Role> roles = _roles.GetRoles(user.SiteId).Where(item => item.IsAutoAssigned).ToList();
|
List<Role> roles = _roles.GetRoles(user.SiteId).Where(item => item.IsAutoAssigned).ToList();
|
||||||
|
@ -237,7 +242,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
if (User.IsInRole(Constants.AdminRole) || User.Identity.Name == user.Username)
|
if (User.IsInRole(RoleNames.Admin) || User.Identity.Name == user.Username)
|
||||||
{
|
{
|
||||||
if (user.Password != "")
|
if (user.Password != "")
|
||||||
{
|
{
|
||||||
|
@ -265,7 +270,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5?siteid=x
|
// DELETE api/<controller>/5?siteid=x
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public async Task Delete(int id)
|
public async Task Delete(int id)
|
||||||
{
|
{
|
||||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(_users.GetUser(id).Username);
|
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(_users.GetUser(id).Username);
|
||||||
|
@ -455,9 +460,9 @@ namespace Oqtane.Controllers
|
||||||
foreach (UserRole userrole in userroles)
|
foreach (UserRole userrole in userroles)
|
||||||
{
|
{
|
||||||
roles += userrole.Role.Name + ";";
|
roles += userrole.Role.Name + ";";
|
||||||
if (userrole.Role.Name == Constants.HostRole && userroles.Where(item => item.Role.Name == Constants.AdminRole).FirstOrDefault() == null)
|
if (userrole.Role.Name == RoleNames.Host && userroles.Where(item => item.Role.Name == RoleNames.Admin).FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
roles += Constants.AdminRole + ";";
|
roles += RoleNames.Admin + ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (roles != "") roles = ";" + roles;
|
if (roles != "") roles = ";" + roles;
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Oqtane.Repository;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class UserRoleController : Controller
|
public class UserRoleController : Controller
|
||||||
{
|
{
|
||||||
private readonly IUserRoleRepository _userRoles;
|
private readonly IUserRoleRepository _userRoles;
|
||||||
|
@ -27,7 +27,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?siteid=x
|
// GET: api/<controller>?siteid=x
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public IEnumerable<UserRole> Get(string siteid)
|
public IEnumerable<UserRole> Get(string siteid)
|
||||||
{
|
{
|
||||||
return _userRoles.GetUserRoles(int.Parse(siteid));
|
return _userRoles.GetUserRoles(int.Parse(siteid));
|
||||||
|
@ -35,7 +35,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public UserRole Get(int id)
|
public UserRole Get(int id)
|
||||||
{
|
{
|
||||||
return _userRoles.GetUserRole(id);
|
return _userRoles.GetUserRole(id);
|
||||||
|
@ -43,7 +43,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public UserRole Post([FromBody] UserRole userRole)
|
public UserRole Post([FromBody] UserRole userRole)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public UserRole Put(int id, [FromBody] UserRole userRole)
|
public UserRole Put(int id, [FromBody] UserRole userRole)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
@ -71,7 +71,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = RoleNames.Admin)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
UserRole userRole = _userRoles.GetUserRole(id);
|
UserRole userRole = _userRoles.GetUserRole(id);
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
|
|
||||||
namespace Oqtane.Extensions
|
namespace Oqtane.Extensions
|
||||||
|
@ -22,5 +24,22 @@ namespace Oqtane.Extensions
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IApplicationBuilder UseOqtaneLocalization(this IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
var localizationManager = app.ApplicationServices.GetService<ILocalizationManager>();
|
||||||
|
var defaultCulture = localizationManager.GetDefaultCulture();
|
||||||
|
var supportedCultures = localizationManager.GetSupportedCultures();
|
||||||
|
|
||||||
|
CultureInfo.CurrentUICulture = new CultureInfo(defaultCulture);
|
||||||
|
|
||||||
|
app.UseRequestLocalization(options => {
|
||||||
|
options.SetDefaultCulture(defaultCulture)
|
||||||
|
.AddSupportedUICultures(supportedCultures)
|
||||||
|
.AddSupportedUICultures(supportedCultures);
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Hosting;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
|
using Oqtane.Shared;
|
||||||
using Oqtane.UI;
|
using Oqtane.UI;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
|
@ -14,10 +15,12 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
public static class OqtaneServiceCollectionExtensions
|
public static class OqtaneServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddOqtaneParts(this IServiceCollection services, Runtime runtime)
|
public static IServiceCollection AddOqtane(this IServiceCollection services, Runtime runtime, string[] supportedCultures)
|
||||||
{
|
{
|
||||||
LoadAssemblies();
|
LoadAssemblies();
|
||||||
|
LoadSatelliteAssemblies(supportedCultures);
|
||||||
services.AddOqtaneServices(runtime);
|
services.AddOqtaneServices(runtime);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
}
|
}
|
||||||
|
|
||||||
var hostedServiceType = typeof(IHostedService);
|
var hostedServiceType = typeof(IHostedService);
|
||||||
|
|
||||||
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
||||||
foreach (var assembly in assemblies)
|
foreach (var assembly in assemblies)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +57,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register server startup services
|
||||||
var startUps = assembly.GetInstances<IServerStartup>();
|
var startUps = assembly.GetInstances<IServerStartup>();
|
||||||
foreach (var startup in startUps)
|
foreach (var startup in startUps)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +66,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
if (runtime == Runtime.Server)
|
if (runtime == Runtime.Server)
|
||||||
{
|
{
|
||||||
|
// register client startup services if running on server
|
||||||
assembly.GetInstances<IClientStartup>()
|
assembly.GetInstances<IClientStartup>()
|
||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(x => x.ConfigureServices(services));
|
.ForEach(x => x.ConfigureServices(services));
|
||||||
|
@ -119,6 +125,58 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LoadSatelliteAssemblies(string[] supportedCultures)
|
||||||
|
{
|
||||||
|
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||||
|
if (assemblyPath == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssemblyLoadContext.Default.Resolving += ResolveDependencies;
|
||||||
|
|
||||||
|
foreach (var culture in supportedCultures)
|
||||||
|
{
|
||||||
|
if (culture == Constants.DefaultCulture)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var assembliesFolder = new DirectoryInfo(Path.Combine(assemblyPath, culture));
|
||||||
|
if (assembliesFolder.Exists)
|
||||||
|
{
|
||||||
|
foreach (var assemblyFile in assembliesFolder.EnumerateFiles(Constants.SatelliteAssemblyExtension))
|
||||||
|
{
|
||||||
|
AssemblyName assemblyName;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assemblyName = AssemblyName.GetAssemblyName(assemblyFile.FullName);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Not Satellite Assembly : {assemblyFile.Name}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assembly assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(assemblyFile.FullName)));
|
||||||
|
Console.WriteLine($"Loaded : {assemblyName}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Failed : {assemblyName}\n{e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Assembly ResolveDependencies(AssemblyLoadContext context, AssemblyName name)
|
private static Assembly ResolveDependencies(AssemblyLoadContext context, AssemblyName name)
|
||||||
{
|
{
|
||||||
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "\\" + name.Name + ".dll";
|
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "\\" + name.Name + ".dll";
|
||||||
|
|
21
Oqtane.Server/Extensions/WebHostBuilderExtensions.cs
Normal file
21
Oqtane.Server/Extensions/WebHostBuilderExtensions.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
|
{
|
||||||
|
public static class WebHostBuilderExtensions
|
||||||
|
{
|
||||||
|
public static IWebHostBuilder ConfigureLocalizationSettings(this IWebHostBuilder builder)
|
||||||
|
{
|
||||||
|
return builder.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
var config = context.Configuration;
|
||||||
|
|
||||||
|
services.Configure<LocalizationOptions>(config.GetSection("Localization"));
|
||||||
|
services.AddSingleton(ctx => ctx.GetService<IOptions<LocalizationOptions>>().Value);
|
||||||
|
services.AddTransient<ILocalizationManager, LocalizationManager>();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ namespace Oqtane.Infrastructure
|
||||||
if (install == null)
|
if (install == null)
|
||||||
{
|
{
|
||||||
// startup or silent installation
|
// startup or silent installation
|
||||||
install = new InstallConfig { ConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey), TenantName = Constants.MasterTenant, IsNewTenant = false };
|
install = new InstallConfig { ConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey), TenantName = TenantNames.Master, IsNewTenant = false };
|
||||||
|
|
||||||
if (!IsInstalled())
|
if (!IsInstalled())
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ namespace Oqtane.Infrastructure
|
||||||
if (!string.IsNullOrEmpty(install.ConnectionString) && !string.IsNullOrEmpty(install.Aliases) && !string.IsNullOrEmpty(install.HostPassword) && !string.IsNullOrEmpty(install.HostEmail))
|
if (!string.IsNullOrEmpty(install.ConnectionString) && !string.IsNullOrEmpty(install.Aliases) && !string.IsNullOrEmpty(install.HostPassword) && !string.IsNullOrEmpty(install.HostEmail))
|
||||||
{
|
{
|
||||||
// silent install
|
// silent install
|
||||||
install.HostName = Constants.HostUser;
|
install.HostName = UserNames.Host;
|
||||||
install.SiteTemplate = GetInstallationConfig(SettingKeys.SiteTemplateKey, Constants.DefaultSiteTemplate);
|
install.SiteTemplate = GetInstallationConfig(SettingKeys.SiteTemplateKey, Constants.DefaultSiteTemplate);
|
||||||
install.DefaultTheme = GetInstallationConfig(SettingKeys.DefaultThemeKey, Constants.DefaultTheme);
|
install.DefaultTheme = GetInstallationConfig(SettingKeys.DefaultThemeKey, Constants.DefaultTheme);
|
||||||
install.DefaultLayout = GetInstallationConfig(SettingKeys.DefaultLayoutKey, Constants.DefaultLayout);
|
install.DefaultLayout = GetInstallationConfig(SettingKeys.DefaultLayoutKey, Constants.DefaultLayout);
|
||||||
|
@ -192,7 +192,7 @@ namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
var result = new Installation { Success = false, Message = string.Empty };
|
var result = new Installation { Success = false, Message = string.Empty };
|
||||||
|
|
||||||
if (install.TenantName == Constants.MasterTenant)
|
if (install.TenantName == TenantNames.Master)
|
||||||
{
|
{
|
||||||
MigrateScriptNamingConvention("Master", install.ConnectionString);
|
MigrateScriptNamingConvention("Master", install.ConnectionString);
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ namespace Oqtane.Infrastructure
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
_cache.Remove("tenants");
|
_cache.Remove("tenants");
|
||||||
|
|
||||||
if (install.TenantName == Constants.MasterTenant)
|
if (install.TenantName == TenantNames.Master)
|
||||||
{
|
{
|
||||||
var job = new Job { Name = "Notification Job", JobType = "Oqtane.Infrastructure.NotificationJob, Oqtane.Server", Frequency = "m", Interval = 1, StartDate = null, EndDate = null, IsEnabled = false, IsStarted = false, IsExecuting = false, NextExecution = null, RetentionHistory = 10, CreatedBy = "", CreatedOn = DateTime.UtcNow, ModifiedBy = "", ModifiedOn = DateTime.UtcNow };
|
var job = new Job { Name = "Notification Job", JobType = "Oqtane.Infrastructure.NotificationJob, Oqtane.Server", Frequency = "m", Interval = 1, StartDate = null, EndDate = null, IsEnabled = false, IsStarted = false, IsExecuting = false, NextExecution = null, RetentionHistory = 10, CreatedBy = "", CreatedOn = DateTime.UtcNow, ModifiedBy = "", ModifiedOn = DateTime.UtcNow };
|
||||||
db.Job.Add(job);
|
db.Job.Add(job);
|
||||||
|
@ -350,7 +350,7 @@ namespace Oqtane.Infrastructure
|
||||||
foreach (var tenant in db.Tenant.ToList())
|
foreach (var tenant in db.Tenant.ToList())
|
||||||
{
|
{
|
||||||
int index = Array.FindIndex(versions, item => item == moduledefinition.Version);
|
int index = Array.FindIndex(versions, item => item == moduledefinition.Version);
|
||||||
if (tenant.Name == install.TenantName && install.TenantName != Constants.MasterTenant)
|
if (tenant.Name == install.TenantName && install.TenantName != TenantNames.Master)
|
||||||
{
|
{
|
||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
|
@ -439,17 +439,17 @@ namespace Oqtane.Infrastructure
|
||||||
};
|
};
|
||||||
site = sites.AddSite(site);
|
site = sites.AddSite(site);
|
||||||
|
|
||||||
IdentityUser identityUser = identityUserManager.FindByNameAsync(Constants.HostUser).GetAwaiter().GetResult();
|
IdentityUser identityUser = identityUserManager.FindByNameAsync(UserNames.Host).GetAwaiter().GetResult();
|
||||||
if (identityUser == null)
|
if (identityUser == null)
|
||||||
{
|
{
|
||||||
identityUser = new IdentityUser { UserName = Constants.HostUser, Email = install.HostEmail, EmailConfirmed = true };
|
identityUser = new IdentityUser { UserName = UserNames.Host, Email = install.HostEmail, EmailConfirmed = true };
|
||||||
var create = identityUserManager.CreateAsync(identityUser, install.HostPassword).GetAwaiter().GetResult();
|
var create = identityUserManager.CreateAsync(identityUser, install.HostPassword).GetAwaiter().GetResult();
|
||||||
if (create.Succeeded)
|
if (create.Succeeded)
|
||||||
{
|
{
|
||||||
var user = new User
|
var user = new User
|
||||||
{
|
{
|
||||||
SiteId = site.SiteId,
|
SiteId = site.SiteId,
|
||||||
Username = Constants.HostUser,
|
Username = UserNames.Host,
|
||||||
Password = install.HostPassword,
|
Password = install.HostPassword,
|
||||||
Email = install.HostEmail,
|
Email = install.HostEmail,
|
||||||
DisplayName = install.HostName,
|
DisplayName = install.HostName,
|
||||||
|
@ -458,7 +458,7 @@ namespace Oqtane.Infrastructure
|
||||||
};
|
};
|
||||||
|
|
||||||
user = users.AddUser(user);
|
user = users.AddUser(user);
|
||||||
var hostRoleId = roles.GetRoles(user.SiteId, true).FirstOrDefault(item => item.Name == Constants.HostRole)?.RoleId ?? 0;
|
var hostRoleId = roles.GetRoles(user.SiteId, true).FirstOrDefault(item => item.Name == RoleNames.Host)?.RoleId ?? 0;
|
||||||
var userRole = new UserRole { UserId = user.UserId, RoleId = hostRoleId, EffectiveDate = null, ExpiryDate = null };
|
var userRole = new UserRole { UserId = user.UserId, RoleId = hostRoleId, EffectiveDate = null, ExpiryDate = null };
|
||||||
userroles.AddUserRole(userRole);
|
userroles.AddUserRole(userRole);
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ namespace Oqtane.Infrastructure
|
||||||
Permissions = new List<Permission>
|
Permissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.Browse, user.UserId, true),
|
new Permission(PermissionNames.Browse, user.UserId, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, user.UserId, true),
|
new Permission(PermissionNames.Edit, user.UserId, true),
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
@ -80,6 +82,8 @@ namespace Oqtane.Infrastructure
|
||||||
// if compatible with framework version
|
// if compatible with framework version
|
||||||
if (frameworkversion == "" || Version.Parse(Constants.Version).CompareTo(Version.Parse(frameworkversion)) >= 0)
|
if (frameworkversion == "" || Version.Parse(Constants.Version).CompareTo(Version.Parse(frameworkversion)) >= 0)
|
||||||
{
|
{
|
||||||
|
List<string> assets = new List<string>();
|
||||||
|
|
||||||
// module and theme packages must be in form of name.1.0.0.nupkg
|
// module and theme packages must be in form of name.1.0.0.nupkg
|
||||||
string name = Path.GetFileNameWithoutExtension(packagename);
|
string name = Path.GetFileNameWithoutExtension(packagename);
|
||||||
string[] segments = name?.Split('.');
|
string[] segments = name?.Split('.');
|
||||||
|
@ -96,18 +100,32 @@ namespace Oqtane.Infrastructure
|
||||||
case "lib":
|
case "lib":
|
||||||
filename = Path.Combine(binFolder, filename);
|
filename = Path.Combine(binFolder, filename);
|
||||||
ExtractFile(entry, filename);
|
ExtractFile(entry, filename);
|
||||||
|
assets.Add(filename);
|
||||||
break;
|
break;
|
||||||
case "wwwroot":
|
case "wwwroot":
|
||||||
filename = Path.Combine(webRootPath.Replace(Path.DirectorySeparatorChar + "wwwroot", ""), Utilities.PathCombine(entry.FullName.Split('/')));
|
filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace("wwwroot/", "").Split('/')));
|
||||||
ExtractFile(entry, filename);
|
ExtractFile(entry, filename);
|
||||||
|
assets.Add(filename);
|
||||||
break;
|
break;
|
||||||
case "runtimes":
|
case "runtimes":
|
||||||
var destSubFolder = Path.GetDirectoryName(entry.FullName);
|
var destSubFolder = Path.GetDirectoryName(entry.FullName);
|
||||||
filename = Path.Combine(binFolder, destSubFolder, filename);
|
filename = Path.Combine(binFolder, destSubFolder, filename);
|
||||||
ExtractFile(entry, filename);
|
ExtractFile(entry, filename);
|
||||||
|
assets.Add(filename);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save list of assets
|
||||||
|
if (assets.Count != 0)
|
||||||
|
{
|
||||||
|
string assetfilepath = Path.Combine(webRootPath, folder, name, "assets.json");
|
||||||
|
if (File.Exists(assetfilepath))
|
||||||
|
{
|
||||||
|
File.Delete(assetfilepath);
|
||||||
|
}
|
||||||
|
File.WriteAllText(assetfilepath, JsonSerializer.Serialize(assets));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
Oqtane.Server/Infrastructure/Interfaces/IHostResources.cs
Normal file
12
Oqtane.Server/Infrastructure/Interfaces/IHostResources.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Oqtane.Infrastructure
|
||||||
|
{
|
||||||
|
// this interface is for declaring global resources and is useful for scenarios where you want to declare resources in a single location for the entire application
|
||||||
|
public interface IHostResources
|
||||||
|
{
|
||||||
|
List<Resource> Resources { get; } // identifies global resources for an application
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Oqtane.Infrastructure
|
||||||
|
{
|
||||||
|
public interface ILocalizationManager
|
||||||
|
{
|
||||||
|
string GetDefaultCulture();
|
||||||
|
|
||||||
|
string[] GetSupportedCultures();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Oqtane.Infrastructure
|
||||||
|
{
|
||||||
|
public class LocalizationOptions
|
||||||
|
{
|
||||||
|
public string DefaultCulture { get; set; }
|
||||||
|
|
||||||
|
public string[] SupportedCultures { get; set; }
|
||||||
|
}
|
||||||
|
}
|
29
Oqtane.Server/Infrastructure/LocalizationManager.cs
Normal file
29
Oqtane.Server/Infrastructure/LocalizationManager.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Collections;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Infrastructure
|
||||||
|
{
|
||||||
|
public class LocalizationManager : ILocalizationManager
|
||||||
|
{
|
||||||
|
private static readonly string DefaultCulture = Constants.DefaultCulture;
|
||||||
|
private static readonly string[] SupportedCultures = new[] { DefaultCulture };
|
||||||
|
|
||||||
|
private readonly LocalizationOptions _localizationOptions;
|
||||||
|
|
||||||
|
public LocalizationManager(IOptions<LocalizationOptions> localizationOptions)
|
||||||
|
{
|
||||||
|
_localizationOptions = localizationOptions.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetDefaultCulture()
|
||||||
|
=> string.IsNullOrEmpty(_localizationOptions.DefaultCulture)
|
||||||
|
? DefaultCulture
|
||||||
|
: _localizationOptions.DefaultCulture;
|
||||||
|
|
||||||
|
public string[] GetSupportedCultures()
|
||||||
|
=> _localizationOptions.SupportedCultures.IsNullOrEmpty()
|
||||||
|
? SupportedCultures
|
||||||
|
: _localizationOptions.SupportedCultures;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
|
@ -43,27 +43,27 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions() ,
|
}.EncodePermissions() ,
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Welcome To Oqtane...", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Welcome To Oqtane...", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> that provides advanced functionality for developing web and mobile applications on ASP.NET Core. It leverages the revolutionary new Blazor component model to compose a <b>fully dynamic</b> web development experience which can be hosted either client-side or server-side. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> that provides advanced functionality for developing web and mobile applications on ASP.NET Core. It leverages the revolutionary new Blazor component model to compose a <b>fully dynamic</b> web development experience which can be hosted either client-side or server-side. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
||||||
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img class=\"img-fluid\" src=\"oqtane-white.png\"></a></p><p align=\"center\"><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a></p>" +
|
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img class=\"img-fluid\" src=\"oqtane-glow.png\"></a></p><p align=\"center\"><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a></p>" +
|
||||||
"<p><a href=\"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor\" target=\"_new\">Blazor</a> is an open source and cross-platform web UI framework for building single-page apps using .NET and C# instead of JavaScript. Blazor WebAssembly relies on Wasm, an open web standard that does not require plugins or code transpilation in order to run natively in a web browser. Blazor Server uses SignalR to host your application on a web server and provide a responsive and robust development experience. Blazor applications work in all modern web browsers, including mobile browsers.</p>" +
|
"<p><a href=\"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor\" target=\"_new\">Blazor</a> is an open source and cross-platform web UI framework for building single-page apps using .NET and C# instead of JavaScript. Blazor WebAssembly relies on Wasm, an open web standard that does not require plugins or code transpilation in order to run natively in a web browser. Blazor Server uses SignalR to host your application on a web server and provide a responsive and robust development experience. Blazor applications work in all modern web browsers, including mobile browsers.</p>" +
|
||||||
"<p>Blazor is a feature of <a href=\"https://dotnet.microsoft.com/apps/aspnet\" target=\"_new\">ASP.NET Core 3</a>, the popular cross platform web development framework from Microsoft that extends the <a href=\"https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet\" target=\"_new\" >.NET developer platform</a> with tools and libraries for building web apps.</p>"
|
"<p>Blazor is a feature of <a href=\"https://dotnet.microsoft.com/apps/aspnet\" target=\"_new\">ASP.NET Core 3</a>, the popular cross platform web development framework from Microsoft that extends the <a href=\"https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet\" target=\"_new\" >.NET developer platform</a> with tools and libraries for building web apps.</p>"
|
||||||
},
|
},
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "MIT License", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "MIT License", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Copyright (c) 2019-2020 .NET Foundation</p>" +
|
Content = "<p>Copyright (c) 2019-2020 .NET Foundation</p>" +
|
||||||
"<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>" +
|
"<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>" +
|
||||||
|
@ -72,9 +72,9 @@ namespace Oqtane.SiteTemplates
|
||||||
},
|
},
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, RoleNames.Registered, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane allows you to control access to your content using security roles. This module is only visible to Registered Users of the site.</p>"
|
Content = "<p>Oqtane allows you to control access to your content using security roles. This module is only visible to Registered Users of the site.</p>"
|
||||||
}
|
}
|
||||||
|
@ -89,16 +89,16 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, RoleNames.Registered, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, RoleNames.Registered, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane allows you to control access to your content using security roles. This page is only visible to Registered Users of the site.</p>"
|
Content = "<p>Oqtane allows you to control access to your content using security roles. This page is only visible to Registered Users of the site.</p>"
|
||||||
}
|
}
|
||||||
|
@ -113,16 +113,16 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = true,
|
IsPersonalizable = true,
|
||||||
PagePermissions = new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "My Page", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "My Page", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane offers native support for user personalized pages. If a page is identified as personalizable by the site administrator in the page settings, when an authenticated user visits the page they will see an edit button at the top right corner of the page next to their username. When they click this button the sytem will create a new version of the page and allow them to edit the page content.</p>"
|
Content = "<p>Oqtane offers native support for user personalized pages. If a page is identified as personalizable by the site administrator in the page settings, when an authenticated user visits the page they will see an edit button at the top right corner of the page next to their username. When they click this button the sytem will create a new version of the page and allow them to edit the page content.</p>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>()
|
PageTemplateModules = new List<PageTemplateModule>()
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace Oqtane.Infrastructure
|
||||||
// EditMode = false,
|
// EditMode = false,
|
||||||
// PagePermissions = new List<Permission>
|
// PagePermissions = new List<Permission>
|
||||||
// {
|
// {
|
||||||
// new Permission(PermissionNames.View, Constants.AdminRole, true),
|
// new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
// new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
// new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
// new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
// new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
// }.EncodePermissions(),
|
// }.EncodePermissions(),
|
||||||
// PageTemplateModules = new List<PageTemplateModule>
|
// PageTemplateModules = new List<PageTemplateModule>
|
||||||
// {
|
// {
|
||||||
|
@ -51,9 +51,9 @@ namespace Oqtane.Infrastructure
|
||||||
// ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Login.Index).ToModuleDefinitionName(), Title = "Test", Pane = "Content",
|
// ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Login.Index).ToModuleDefinitionName(), Title = "Test", Pane = "Content",
|
||||||
// ModulePermissions = new List<Permission>
|
// ModulePermissions = new List<Permission>
|
||||||
// {
|
// {
|
||||||
// new Permission(PermissionNames.View, Constants.AdminRole, true),
|
// new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
// new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
// new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
// new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
// new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
// }.EncodePermissions(),
|
// }.EncodePermissions(),
|
||||||
// Content = ""
|
// Content = ""
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Oqtane.Controllers;
|
||||||
|
|
||||||
namespace Oqtane.Modules.HtmlText.Controllers
|
namespace Oqtane.Modules.HtmlText.Controllers
|
||||||
{
|
{
|
||||||
[Route("{alias}/api/[controller]")]
|
[Route(ControllerRoutes.Default)]
|
||||||
public class HtmlTextController : ModuleControllerBase
|
public class HtmlTextController : ModuleControllerBase
|
||||||
{
|
{
|
||||||
private readonly IHtmlTextRepository _htmlText;
|
private readonly IHtmlTextRepository _htmlText;
|
||||||
|
@ -24,7 +24,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[Authorize(Policy = "ViewModule")]
|
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||||
public List<HtmlTextInfo> Get(int id)
|
public List<HtmlTextInfo> Get(int id)
|
||||||
{
|
{
|
||||||
var list = new List<HtmlTextInfo>();
|
var list = new List<HtmlTextInfo>();
|
||||||
|
@ -47,7 +47,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Policy = "EditModule")]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public HtmlTextInfo Post([FromBody] HtmlTextInfo htmlText)
|
public HtmlTextInfo Post([FromBody] HtmlTextInfo htmlText)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -68,7 +68,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Policy = "EditModule")]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo htmlText)
|
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo htmlText)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -89,7 +89,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Policy = "EditModule")]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
<Configurations>Debug;Release</Configurations>
|
<Configurations>Debug;Release</Configurations>
|
||||||
<Version>1.0.3</Version>
|
<Version>2.0.0</Version>
|
||||||
<Product>Oqtane</Product>
|
<Product>Oqtane</Product>
|
||||||
<Authors>Shaun Walker</Authors>
|
<Authors>Shaun Walker</Authors>
|
||||||
<Company>.NET Foundation</Company>
|
<Company>.NET Foundation</Company>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<PackageProjectUrl>https://www.oqtane.org</PackageProjectUrl>
|
<PackageProjectUrl>https://www.oqtane.org</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/oqtane</RepositoryUrl>
|
<RepositoryUrl>https://github.com/oqtane</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<PackageReleaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v1.0.3</PackageReleaseNotes>
|
<PackageReleaseNotes>https://github.com/oqtane/oqtane.framework/releases/tag/v2.0.0</PackageReleaseNotes>
|
||||||
<RootNamespace>Oqtane</RootNamespace>
|
<RootNamespace>Oqtane</RootNamespace>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -33,28 +33,31 @@
|
||||||
<EmbeddedResource Include="Scripts\Tenant.01.00.01.00.sql" />
|
<EmbeddedResource Include="Scripts\Tenant.01.00.01.00.sql" />
|
||||||
<EmbeddedResource Include="Scripts\Tenant.01.00.01.01.sql" />
|
<EmbeddedResource Include="Scripts\Tenant.01.00.01.01.sql" />
|
||||||
<EmbeddedResource Include="Scripts\Tenant.01.00.02.01.sql" />
|
<EmbeddedResource Include="Scripts\Tenant.01.00.02.01.sql" />
|
||||||
|
<EmbeddedResource Include="Scripts\Tenant.02.00.00.01.sql" />
|
||||||
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.1.0.0.sql" />
|
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.1.0.0.sql" />
|
||||||
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.Uninstall.sql" />
|
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.Uninstall.sql" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dbup" Version="4.3.0" />
|
<PackageReference Include="dbup" Version="4.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
||||||
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
|
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
|
||||||
|
<ProjectReference Include="..\Oqtane.Upgrade\Oqtane.Upgrade.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.deps.json" />
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\net5.0\Oqtane.Upgrade.deps.json" />
|
||||||
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.dll" />
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\net5.0\Oqtane.Upgrade.dll" />
|
||||||
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.pdb" />
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\net5.0\Oqtane.Upgrade.pdb" />
|
||||||
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.runtimeconfig.json" />
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\net5.0\Oqtane.Upgrade.runtimeconfig.json" />
|
||||||
<TemplateFiles Include="$(ProjectDir)wwwroot\Modules\Templates\**\*.*" />
|
<TemplateFiles Include="$(ProjectDir)wwwroot\Modules\Templates\**\*.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
|
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
@page "/"
|
@page "/"
|
||||||
@namespace Oqtane.Pages
|
@namespace Oqtane.Pages
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
@using System.Globalization
|
||||||
|
@using Microsoft.AspNetCore.Localization
|
||||||
@using Microsoft.Extensions.Configuration
|
@using Microsoft.Extensions.Configuration
|
||||||
@inject IConfiguration Configuration
|
@inject IConfiguration Configuration
|
||||||
|
@model Oqtane.Pages.HostModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
// Set localization cookie
|
||||||
|
var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture));
|
||||||
|
HttpContext.Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue);
|
||||||
|
}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -16,6 +24,7 @@
|
||||||
<link id="app-manifest" rel="manifest" />
|
<link id="app-manifest" rel="manifest" />
|
||||||
<link rel="stylesheet" href="css/app.css" />
|
<link rel="stylesheet" href="css/app.css" />
|
||||||
<script src="js/loadjs.min.js"></script>
|
<script src="js/loadjs.min.js"></script>
|
||||||
|
@Html.Raw(@Model.HeadResources)
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@(Html.AntiForgeryToken())
|
@(Html.AntiForgeryToken())
|
||||||
|
@ -30,7 +39,7 @@
|
||||||
<environment include="Development">
|
<environment include="Development">
|
||||||
An unhandled exception has occurred. See browser dev tools for details.
|
An unhandled exception has occurred. See browser dev tools for details.
|
||||||
</environment>
|
</environment>
|
||||||
<a href="~/" class="reload">Reload</a>
|
<a href="" class="reload">Reload</a>
|
||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -44,5 +53,6 @@
|
||||||
{
|
{
|
||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
}
|
}
|
||||||
|
@Html.Raw(@Model.BodyResources)
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
138
Oqtane.Server/Pages/_Host.cshtml.cs
Normal file
138
Oqtane.Server/Pages/_Host.cshtml.cs
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Themes;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Oqtane.Pages
|
||||||
|
{
|
||||||
|
public class HostModel : PageModel
|
||||||
|
{
|
||||||
|
public string HeadResources = "";
|
||||||
|
public string BodyResources = "";
|
||||||
|
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
||||||
|
foreach (Assembly assembly in assemblies)
|
||||||
|
{
|
||||||
|
ProcessHostResources(assembly);
|
||||||
|
ProcessModuleControls(assembly);
|
||||||
|
ProcessThemeControls(assembly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessHostResources(Assembly assembly)
|
||||||
|
{
|
||||||
|
var types = assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IHostResources)));
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
var obj = Activator.CreateInstance(type) as IHostResources;
|
||||||
|
foreach (var resource in obj.Resources)
|
||||||
|
{
|
||||||
|
ProcessResource(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessModuleControls(Assembly assembly)
|
||||||
|
{
|
||||||
|
var types = assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IModuleControl)));
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
// Check if type should be ignored
|
||||||
|
if (type.IsOqtaneIgnore()) continue;
|
||||||
|
|
||||||
|
var obj = Activator.CreateInstance(type) as IModuleControl;
|
||||||
|
if (obj.Resources != null)
|
||||||
|
{
|
||||||
|
foreach (var resource in obj.Resources)
|
||||||
|
{
|
||||||
|
if (resource.Declaration == ResourceDeclaration.Global)
|
||||||
|
{
|
||||||
|
ProcessResource(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessThemeControls(Assembly assembly)
|
||||||
|
{
|
||||||
|
var types = assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IThemeControl)));
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
// Check if type should be ignored
|
||||||
|
if (type.IsOqtaneIgnore()) continue;
|
||||||
|
|
||||||
|
var obj = Activator.CreateInstance(type) as IThemeControl;
|
||||||
|
if (obj.Resources != null)
|
||||||
|
{
|
||||||
|
foreach (var resource in obj.Resources)
|
||||||
|
{
|
||||||
|
if (resource.Declaration == ResourceDeclaration.Global)
|
||||||
|
{
|
||||||
|
ProcessResource(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessResource(Resource resource)
|
||||||
|
{
|
||||||
|
switch (resource.ResourceType)
|
||||||
|
{
|
||||||
|
case ResourceType.Stylesheet:
|
||||||
|
if (!HeadResources.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
HeadResources += "<link rel=\"stylesheet\" href=\"" + resource.Url + "\"" + CrossOrigin(resource.CrossOrigin) + Integrity(resource.Integrity) + " />" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ResourceType.Script:
|
||||||
|
if (resource.Location == Shared.ResourceLocation.Body)
|
||||||
|
{
|
||||||
|
if (!BodyResources.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
BodyResources += "<script src=\"" + resource.Url + "\"" + CrossOrigin(resource.CrossOrigin) + Integrity(resource.Integrity) + "></script>" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!HeadResources.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
HeadResources += "<script src=\"" + resource.Url + "\"" + CrossOrigin(resource.CrossOrigin) + Integrity(resource.Integrity) + "></script>" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string CrossOrigin(string crossorigin)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(crossorigin))
|
||||||
|
{
|
||||||
|
return " crossorigin=\"" + crossorigin + "\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string Integrity(string integrity)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(integrity))
|
||||||
|
{
|
||||||
|
return " integrity=\"" + integrity + "\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ namespace Oqtane.Server
|
||||||
.AddCommandLine(args)
|
.AddCommandLine(args)
|
||||||
.Build())
|
.Build())
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
|
.ConfigureLocalizationSettings()
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
public interface ISettingRepository
|
public interface ISettingRepository
|
||||||
{
|
{
|
||||||
|
IEnumerable<Setting> GetSettings(string entityName);
|
||||||
IEnumerable<Setting> GetSettings(string entityName, int entityId);
|
IEnumerable<Setting> GetSettings(string entityName, int entityId);
|
||||||
Setting AddSetting(Setting setting);
|
Setting AddSetting(Setting setting);
|
||||||
Setting UpdateSetting(Setting setting);
|
Setting UpdateSetting(Setting setting);
|
||||||
|
|
|
@ -239,15 +239,15 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
moduledefinition.Permissions = new List<Permission>
|
moduledefinition.Permissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.Utilize, Constants.AdminRole, true)
|
new Permission(PermissionNames.Utilize, RoleNames.Admin, true)
|
||||||
}.EncodePermissions();
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moduledefinition.Permissions = new List<Permission>
|
moduledefinition.Permissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.Utilize, Constants.AdminRole, true),
|
new Permission(PermissionNames.Utilize, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Utilize, Constants.RegisteredRole, true)
|
new Permission(PermissionNames.Utilize, RoleNames.Registered, true)
|
||||||
}.EncodePermissions();
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
@ -14,6 +14,11 @@ namespace Oqtane.Repository
|
||||||
_db = context;
|
_db = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Setting> GetSettings(string entityName)
|
||||||
|
{
|
||||||
|
return _db.Setting.Where(item => item.EntityName == entityName);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Setting> GetSettings(string entityName, int entityId)
|
public IEnumerable<Setting> GetSettings(string entityName, int entityId)
|
||||||
{
|
{
|
||||||
return _db.Setting.Where(item => item.EntityName == entityName)
|
return _db.Setting.Where(item => item.EntityName == entityName)
|
||||||
|
|
|
@ -60,9 +60,9 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -71,9 +71,9 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Login.Index).ToModuleDefinitionName(), Title = "User Login", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Login.Index).ToModuleDefinitionName(), Title = "User Login", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -100,9 +100,9 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Register.Index).ToModuleDefinitionName(), Title = "User Registration", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Register.Index).ToModuleDefinitionName(), Title = "User Registration", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -130,9 +130,9 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Reset.Index).ToModuleDefinitionName(), Title = "Password Reset", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Reset.Index).ToModuleDefinitionName(), Title = "Password Reset", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,9 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, RoleNames.Registered, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -159,9 +159,9 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.UserProfile.Index).ToModuleDefinitionName(), Title = "User Profile", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.UserProfile.Index).ToModuleDefinitionName(), Title = "User Profile", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, RoleNames.Registered, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ namespace Oqtane.Repository
|
||||||
Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false,
|
Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -184,8 +184,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Dashboard.Index).ToModuleDefinitionName(), Title = "Admin Dashboard", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Dashboard.Index).ToModuleDefinitionName(), Title = "Admin Dashboard", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -211,8 +211,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Site.Index).ToModuleDefinitionName(), Title = "Site Settings", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Site.Index).ToModuleDefinitionName(), Title = "Site Settings", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -238,8 +238,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Pages.Index).ToModuleDefinitionName(), Title = "Page Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Pages.Index).ToModuleDefinitionName(), Title = "Page Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -265,8 +265,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Users.Index).ToModuleDefinitionName(), Title = "User Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Users.Index).ToModuleDefinitionName(), Title = "User Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -282,8 +282,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -292,8 +292,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Profiles.Index).ToModuleDefinitionName(), Title = "Profile Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Profiles.Index).ToModuleDefinitionName(), Title = "Profile Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -309,8 +309,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -319,8 +319,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Roles.Index).ToModuleDefinitionName(), Title = "Role Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Roles.Index).ToModuleDefinitionName(), Title = "Role Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -346,8 +346,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Files.Index).ToModuleDefinitionName(), Title = "File Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Files.Index).ToModuleDefinitionName(), Title = "File Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -363,8 +363,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -373,8 +373,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.RecycleBin.Index).ToModuleDefinitionName(), Title = "Recycle Bin", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.RecycleBin.Index).ToModuleDefinitionName(), Title = "Recycle Bin", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -392,8 +392,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -402,8 +402,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Logs.Index).ToModuleDefinitionName(), Title = "Event Log", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Logs.Index).ToModuleDefinitionName(), Title = "Event Log", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -418,8 +418,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -428,8 +428,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Tenants.Index).ToModuleDefinitionName(), Title = "Tenant Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Tenants.Index).ToModuleDefinitionName(), Title = "Tenant Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -440,8 +440,8 @@ namespace Oqtane.Repository
|
||||||
Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = Icons.Globe, IsNavigation = false, IsPersonalizable = false,
|
Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = Icons.Globe, IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -450,8 +450,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Sites.Index).ToModuleDefinitionName(), Title = "Site Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Sites.Index).ToModuleDefinitionName(), Title = "Site Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -462,8 +462,8 @@ namespace Oqtane.Repository
|
||||||
Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = Icons.Browser, IsNavigation = false, IsPersonalizable = false,
|
Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = Icons.Browser, IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -472,8 +472,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.ModuleDefinitions.Index).ToModuleDefinitionName(), Title = "Module Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.ModuleDefinitions.Index).ToModuleDefinitionName(), Title = "Module Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -484,8 +484,8 @@ namespace Oqtane.Repository
|
||||||
Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = Icons.Brush, IsNavigation = false, IsPersonalizable = false,
|
Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = Icons.Brush, IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -494,8 +494,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Themes.Index).ToModuleDefinitionName(), Title = "Theme Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Themes.Index).ToModuleDefinitionName(), Title = "Theme Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -506,8 +506,8 @@ namespace Oqtane.Repository
|
||||||
Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = Icons.Timer, IsNavigation = false, IsPersonalizable = false,
|
Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = Icons.Timer, IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -516,8 +516,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Jobs.Index).ToModuleDefinitionName(), Title = "Scheduled Jobs", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Jobs.Index).ToModuleDefinitionName(), Title = "Scheduled Jobs", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -533,8 +533,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -543,8 +543,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Sql.Index).ToModuleDefinitionName(), Title = "Sql Management", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Sql.Index).ToModuleDefinitionName(), Title = "Sql Management", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -560,8 +560,8 @@ namespace Oqtane.Repository
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -570,8 +570,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.SystemInfo.Index).ToModuleDefinitionName(), Title = "System Info", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.SystemInfo.Index).ToModuleDefinitionName(), Title = "System Info", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -582,8 +582,8 @@ namespace Oqtane.Repository
|
||||||
Name = "System Update", Parent = "Admin", Path = "admin/update", Icon = Icons.Aperture, IsNavigation = false, IsPersonalizable = false,
|
Name = "System Update", Parent = "Admin", Path = "admin/update", Icon = Icons.Aperture, IsNavigation = false, IsPersonalizable = false,
|
||||||
PagePermissions = new List<Permission>
|
PagePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>
|
PageTemplateModules = new List<PageTemplateModule>
|
||||||
{
|
{
|
||||||
|
@ -592,8 +592,8 @@ namespace Oqtane.Repository
|
||||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Upgrade.Index).ToModuleDefinitionName(), Title = "System Update", Pane = "Content",
|
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Upgrade.Index).ToModuleDefinitionName(), Title = "System Update", Pane = "Content",
|
||||||
ModulePermissions = new List<Permission>
|
ModulePermissions = new List<Permission>
|
||||||
{
|
{
|
||||||
new Permission(PermissionNames.View, Constants.HostRole, true),
|
new Permission(PermissionNames.View, RoleNames.Host, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.HostRole, true)
|
new Permission(PermissionNames.Edit, RoleNames.Host, true)
|
||||||
}.EncodePermissions(),
|
}.EncodePermissions(),
|
||||||
Content = ""
|
Content = ""
|
||||||
}
|
}
|
||||||
|
@ -640,18 +640,18 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
// create default entities for site
|
// create default entities for site
|
||||||
List<Role> roles = _roleRepository.GetRoles(site.SiteId, true).ToList();
|
List<Role> roles = _roleRepository.GetRoles(site.SiteId, true).ToList();
|
||||||
if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any())
|
if (!roles.Where(item => item.Name == RoleNames.Everyone).Any())
|
||||||
{
|
{
|
||||||
_roleRepository.AddRole(new Role {SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true});
|
_roleRepository.AddRole(new Role {SiteId = null, Name = RoleNames.Everyone, Description = "All Users", IsAutoAssigned = false, IsSystem = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!roles.Where(item => item.Name == Constants.HostRole).Any())
|
if (!roles.Where(item => item.Name == RoleNames.Host).Any())
|
||||||
{
|
{
|
||||||
_roleRepository.AddRole(new Role {SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true});
|
_roleRepository.AddRole(new Role {SiteId = null, Name = RoleNames.Host, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
_roleRepository.AddRole(new Role {SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true});
|
_roleRepository.AddRole(new Role {SiteId = site.SiteId, Name = RoleNames.Registered, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true});
|
||||||
_roleRepository.AddRole(new Role {SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true});
|
_roleRepository.AddRole(new Role {SiteId = site.SiteId, Name = RoleNames.Admin, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true});
|
||||||
|
|
||||||
_profileRepository.AddProfile(new Profile
|
_profileRepository.AddProfile(new Profile
|
||||||
{SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false});
|
{SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false});
|
||||||
|
@ -673,12 +673,22 @@ namespace Oqtane.Repository
|
||||||
Folder folder = _folderRepository.AddFolder(new Folder
|
Folder folder = _folderRepository.AddFolder(new Folder
|
||||||
{
|
{
|
||||||
SiteId = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true,
|
SiteId = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true,
|
||||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
|
Permissions = new List<Permission>
|
||||||
|
{
|
||||||
|
new Permission(PermissionNames.Browse, RoleNames.Admin, true),
|
||||||
|
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||||
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
|
}.EncodePermissions()
|
||||||
});
|
});
|
||||||
_folderRepository.AddFolder(new Folder
|
_folderRepository.AddFolder(new Folder
|
||||||
{
|
{
|
||||||
SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = Utilities.PathCombine("Users",Path.DirectorySeparatorChar.ToString()), 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\"}]"
|
Permissions = new List<Permission>
|
||||||
|
{
|
||||||
|
new Permission(PermissionNames.Browse, RoleNames.Admin, true),
|
||||||
|
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||||
|
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||||
|
}.EncodePermissions()
|
||||||
});
|
});
|
||||||
|
|
||||||
// process site template first
|
// process site template first
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
var oldTenant =_db.Tenant.AsNoTracking().FirstOrDefault(t=> t.TenantId == tenant.TenantId);
|
var oldTenant =_db.Tenant.AsNoTracking().FirstOrDefault(t=> t.TenantId == tenant.TenantId);
|
||||||
|
|
||||||
if (oldTenant != null && (oldTenant.Name.Equals(Constants.MasterTenant, StringComparison.OrdinalIgnoreCase) && !oldTenant.Name.Equals(tenant.Name)))
|
if (oldTenant != null && (oldTenant.Name.Equals(TenantNames.Master, StringComparison.OrdinalIgnoreCase) && !oldTenant.Name.Equals(tenant.Name)))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Unable to rename the master tenant.");
|
throw new InvalidOperationException("Unable to rename the master tenant.");
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace Oqtane.Repository
|
||||||
public void DeleteTenant(int tenantId)
|
public void DeleteTenant(int tenantId)
|
||||||
{
|
{
|
||||||
var tenant = GetTenant(tenantId);
|
var tenant = GetTenant(tenantId);
|
||||||
if (tenant != null && !tenant.Name.Equals(Constants.MasterTenant, StringComparison.OrdinalIgnoreCase))
|
if (tenant != null && !tenant.Name.Equals(TenantNames.Master, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_db.Tenant.Remove(tenant);
|
_db.Tenant.Remove(tenant);
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
|
|
16
Oqtane.Server/Scripts/Tenant.02.00.00.01.sql
Normal file
16
Oqtane.Server/Scripts/Tenant.02.00.00.01.sql
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Version 2.0.0 Tenant migration script
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[Page]
|
||||||
|
ALTER COLUMN [Path] [nvarchar](256) NOT NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[Profile] ADD
|
||||||
|
[Options] [nvarchar](2000) NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
UPDATE [dbo].[Profile] SET Options = ''
|
||||||
|
GO
|
|
@ -39,15 +39,15 @@ namespace Oqtane.Security
|
||||||
{
|
{
|
||||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, userrole.Role.Name));
|
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, userrole.Role.Name));
|
||||||
// host users are members of every site
|
// host users are members of every site
|
||||||
if (userrole.Role.Name == Constants.HostRole)
|
if (userrole.Role.Name == RoleNames.Host)
|
||||||
{
|
{
|
||||||
if (userroles.Where(item => item.Role.Name == Constants.RegisteredRole).FirstOrDefault() == null)
|
if (userroles.Where(item => item.Role.Name == RoleNames.Registered).FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, Constants.RegisteredRole));
|
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, RoleNames.Registered));
|
||||||
}
|
}
|
||||||
if (userroles.Where(item => item.Role.Name == Constants.AdminRole).FirstOrDefault() == null)
|
if (userroles.Where(item => item.Role.Name == RoleNames.Admin).FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, Constants.AdminRole));
|
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, RoleNames.Admin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
@ -26,18 +27,23 @@ namespace Oqtane
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public IConfigurationRoot Configuration { get; }
|
|
||||||
private string _webRoot;
|
private string _webRoot;
|
||||||
private Runtime _runtime;
|
private Runtime _runtime;
|
||||||
private bool _useSwagger;
|
private bool _useSwagger;
|
||||||
|
private IWebHostEnvironment _env;
|
||||||
|
private string[] _supportedCultures;
|
||||||
|
|
||||||
public Startup(IWebHostEnvironment env)
|
public IConfigurationRoot Configuration { get; }
|
||||||
|
|
||||||
|
public Startup(IWebHostEnvironment env, ILocalizationManager localizationManager)
|
||||||
{
|
{
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(env.ContentRootPath)
|
.SetBasePath(env.ContentRootPath)
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
|
|
||||||
|
_supportedCultures = localizationManager.GetSupportedCultures();
|
||||||
|
|
||||||
_runtime = (Configuration.GetSection("Runtime").Value == "WebAssembly") ? Runtime.WebAssembly : Runtime.Server;
|
_runtime = (Configuration.GetSection("Runtime").Value == "WebAssembly") ? Runtime.WebAssembly : Runtime.Server;
|
||||||
|
|
||||||
//add possibility to switch off swagger on production.
|
//add possibility to switch off swagger on production.
|
||||||
|
@ -45,13 +51,24 @@ namespace Oqtane
|
||||||
|
|
||||||
_webRoot = env.WebRootPath;
|
_webRoot = env.WebRootPath;
|
||||||
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(env.ContentRootPath, "Data"));
|
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(env.ContentRootPath, "Data"));
|
||||||
|
|
||||||
|
_env = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddServerSideBlazor();
|
// Register localization services
|
||||||
|
services.AddLocalization(options => options.ResourcesPath = "Resources");
|
||||||
|
|
||||||
|
services.AddServerSideBlazor().AddCircuitOptions(options =>
|
||||||
|
{
|
||||||
|
if (_env.IsDevelopment())
|
||||||
|
{
|
||||||
|
options.DetailedErrors = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// setup HttpClient for server side in a client side compatible fashion ( with auth cookie )
|
// setup HttpClient for server side in a client side compatible fashion ( with auth cookie )
|
||||||
if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
|
if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
|
||||||
|
@ -75,13 +92,13 @@ namespace Oqtane
|
||||||
// register custom authorization policies
|
// register custom authorization policies
|
||||||
services.AddAuthorizationCore(options =>
|
services.AddAuthorizationCore(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("ViewPage", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.View)));
|
options.AddPolicy(PolicyNames.ViewPage, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.View)));
|
||||||
options.AddPolicy("EditPage", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.Edit)));
|
options.AddPolicy(PolicyNames.EditPage, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.Edit)));
|
||||||
options.AddPolicy("ViewModule", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.View)));
|
options.AddPolicy(PolicyNames.ViewModule, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.View)));
|
||||||
options.AddPolicy("EditModule", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.Edit)));
|
options.AddPolicy(PolicyNames.EditModule, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.Edit)));
|
||||||
options.AddPolicy("ViewFolder", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.View)));
|
options.AddPolicy(PolicyNames.ViewFolder, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.View)));
|
||||||
options.AddPolicy("EditFolder", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.Edit)));
|
options.AddPolicy(PolicyNames.EditFolder, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.Edit)));
|
||||||
options.AddPolicy("ListFolder", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.Browse)));
|
options.AddPolicy(PolicyNames.ListFolder, policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Folder, PermissionNames.Browse)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// register scoped core services
|
// register scoped core services
|
||||||
|
@ -116,7 +133,7 @@ namespace Oqtane
|
||||||
|
|
||||||
services.AddDbContext<MasterDBContext>(options =>
|
services.AddDbContext<MasterDBContext>(options =>
|
||||||
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")
|
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")
|
||||||
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString())
|
.Replace("|DataDirectory|", AppContext.GetData("DataDirectory")?.ToString())
|
||||||
));
|
));
|
||||||
services.AddDbContext<TenantDBContext>(options => { });
|
services.AddDbContext<TenantDBContext>(options => { });
|
||||||
|
|
||||||
|
@ -187,6 +204,7 @@ namespace Oqtane
|
||||||
services.AddTransient<ISettingRepository, SettingRepository>();
|
services.AddTransient<ISettingRepository, SettingRepository>();
|
||||||
services.AddTransient<ILogRepository, LogRepository>();
|
services.AddTransient<ILogRepository, LogRepository>();
|
||||||
services.AddTransient<ILogManager, LogManager>();
|
services.AddTransient<ILogManager, LogManager>();
|
||||||
|
services.AddTransient<ILocalizationManager, LocalizationManager>();
|
||||||
services.AddTransient<IJobRepository, JobRepository>();
|
services.AddTransient<IJobRepository, JobRepository>();
|
||||||
services.AddTransient<IJobLogRepository, JobLogRepository>();
|
services.AddTransient<IJobLogRepository, JobLogRepository>();
|
||||||
services.AddTransient<INotificationRepository, NotificationRepository>();
|
services.AddTransient<INotificationRepository, NotificationRepository>();
|
||||||
|
@ -197,7 +215,7 @@ namespace Oqtane
|
||||||
services.AddTransient<IUpgradeManager, UpgradeManager>();
|
services.AddTransient<IUpgradeManager, UpgradeManager>();
|
||||||
|
|
||||||
// load the external assemblies into the app domain, install services
|
// load the external assemblies into the app domain, install services
|
||||||
services.AddOqtaneParts(_runtime);
|
services.AddOqtane(_runtime, _supportedCultures);
|
||||||
|
|
||||||
services.AddMvc()
|
services.AddMvc()
|
||||||
.AddNewtonsoftJson()
|
.AddNewtonsoftJson()
|
||||||
|
@ -213,6 +231,8 @@ namespace Oqtane
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
|
ServiceActivator.Configure(app.ApplicationServices);
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
@ -225,6 +245,10 @@ namespace Oqtane
|
||||||
}
|
}
|
||||||
// to allow install middleware it should be moved up
|
// to allow install middleware it should be moved up
|
||||||
app.ConfigureOqtaneAssemblies(env);
|
app.ConfigureOqtaneAssemblies(env);
|
||||||
|
|
||||||
|
// Allow oqtane localization middleware
|
||||||
|
app.UseOqtaneLocalization();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseBlazorFrameworkFiles();
|
app.UseBlazorFrameworkFiles();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user