Skip to content

Commit

Permalink
Merge pull request #1142 from oqtane/dev
Browse files Browse the repository at this point in the history
merge dev with master for 2.0.1 release
  • Loading branch information
sbwalker authored Feb 27, 2021
2 parents 5273ae8 + 0eae1b6 commit 0d6413e
Show file tree
Hide file tree
Showing 178 changed files with 3,299 additions and 2,248 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Oqtane.Server/Data/*.mdf
Oqtane.Server/Data/*.ldf

/Oqtane.Server/Properties/PublishProfiles/FolderProfile.pubxml
Oqtane.Server/Content
4 changes: 2 additions & 2 deletions Oqtane.Client/Modules/Admin/Dashboard/Index.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace Oqtane.Modules.Admin.Dashboard
@namespace Oqtane.Modules.Admin.Dashboard
@inherits ModuleBase
@inject IPageService PageService
@inject IUserService UserService
Expand All @@ -11,7 +11,7 @@
string url = NavigateUrl(p.Path);
<div class="col-md-2 mx-auto text-center">
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
<h2><span class="oi oi-@p.Icon" aria-hidden="true"></span></h2>@p.Name
<h2><span class="@p.Icon" aria-hidden="true"></span></h2>@p.Name
</NavLink>
</div>
}
Expand Down
7 changes: 4 additions & 3 deletions Oqtane.Client/Modules/Admin/Error/Index.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@namespace Oqtane.Modules.Admin.Error
@namespace Oqtane.Modules.Admin.Error
@inherits ModuleBase
@inject IModuleService ModuleService
@inject IStringLocalizer<Index> Localizer

@code {
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
Expand All @@ -10,10 +11,10 @@
Module module = await ModuleService.GetModuleAsync(ModuleState.ModuleId);
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
{
string message = "A Problem Was Encountered Loading Module " + module.ModuleDefinitionName;
string message = Localizer["A Problem Was Encountered Loading Module {0}", module.ModuleDefinitionName];
AddModuleMessage(message, MessageType.Error);
}

await logger.LogCritical("Error Loading Module {Module}", module);
}
}
37 changes: 19 additions & 18 deletions Oqtane.Client/Modules/Admin/Files/Add.razor
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
@namespace Oqtane.Modules.Admin.Files
@namespace Oqtane.Modules.Admin.Files
@using System.IO
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IFileService FileService
@inject IFolderService FolderService
@inject IStringLocalizer<Add> Localizer

<TabStrip>
<TabPanel Name="Upload" Heading="Upload Files">
<TabPanel Name="Upload" Heading="Upload Files" ResourceKey="UploadFiles">
<table class="table table-borderless">
<tr>
<td>
<Label For="upload" HelpText="Upload the file you want">Upload: </Label>
<Label For="upload" HelpText="Upload the file you want" ResourceKey="Upload">Upload: </Label>
</td>
<td>
<FileManager UploadMultiple="true" ShowFiles="false" FolderId="@_folderId" />
</td>
</tr>
</table>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
</TabPanel>
<TabPanel Name="Download" Heading="Download Files">
<TabPanel Name="Download" Heading="Download Files" ResourceKey="DownloadFiles">
@if (_folders != null)
{
<table class="table table-borderless">
<tr>
<td>
<Label For="url" HelpText="Enter the url of the file you wish to download">Url: </Label>
<Label For="url" HelpText="Enter the url of the file you wish to download" ResourceKey="Url">Url: </Label>
</td>
<td>
<input id="url" class="form-control" @bind="@url" />
</td>
</tr>
<tr>
<td>
<Label For="folder" HelpText="Select the folder to save the file in">Folder: </Label>
<Label For="folder" HelpText="Select the folder to save the file in" ResourceKey="Folder">Folder: </Label>
</td>
<td>
<select id="folder" class="form-control" @bind="@_folderId">
<option value="-1">&lt;Select Folder&gt;</option>
<option value="-1">&lt;@Localizer["Select Folder"]&gt;</option>
@foreach (Folder folder in _folders)
{
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
Expand All @@ -46,8 +47,8 @@
</td>
</tr>
</table>
<button type="button" class="btn btn-success" @onclick="Download">Download</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<button type="button" class="btn btn-success" @onclick="Download">@Localizer["Download"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
}
</TabPanel>
</TabStrip>
Expand All @@ -73,35 +74,35 @@
{
if (url == string.Empty || _folderId == -1)
{
AddModuleMessage("You Must Enter A Url And Select A Folder", MessageType.Warning);
AddModuleMessage(Localizer["You Must Enter A Url And Select A Folder"], MessageType.Warning);
return;
}

var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);

if (!Constants.UploadableFiles.Split(',')
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
{
AddModuleMessage("File Could Not Be Downloaded From Url Due To Its File Extension", MessageType.Warning);
return ;
}
{
AddModuleMessage(Localizer["File Could Not Be Downloaded From Url Due To Its File Extension"], MessageType.Warning);
return;
}

if (!filename.IsPathOrFileValid())
{
AddModuleMessage("You Must Enter A Url With A Valid File Name", MessageType.Warning);
AddModuleMessage(Localizer["You Must Enter A Url With A Valid File Name"], MessageType.Warning);
return;
}

try
{
await FileService.UploadFileAsync(url, _folderId);
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
AddModuleMessage("File Downloaded Successfully From Url", MessageType.Success);
AddModuleMessage(Localizer["File Downloaded Successfully From Url"], MessageType.Success);
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message);
AddModuleMessage("Error Downloading File From Url. Please Verify That The Url Is Valid.", MessageType.Error);
AddModuleMessage(Localizer["Error Downloading File From Url. Please Verify That The Url Is Valid."], MessageType.Error);
}
}
}
19 changes: 10 additions & 9 deletions Oqtane.Client/Modules/Admin/Files/Details.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
@namespace Oqtane.Modules.Admin.Files
@namespace Oqtane.Modules.Admin.Files
@inherits ModuleBase
@inject IFileService FileService
@inject IFolderService FolderService
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Details> Localizer

@if (_folders != null)
{
<table class="table table-borderless">
<tr>
<td>
<Label for="name" HelpText="The name of the file">Name: </Label>
<Label for="name" HelpText="The name of the file" ResourceKey="Name">Name: </Label>
</td>
<td>
<input id="name" class="form-control" @bind="@_name" />
</td>
</tr>
<tr>
<td>
<Label For="parent" HelpText="The folder where the file is located">Folder: </Label>
<Label For="parent" HelpText="The folder where the file is located" ResourceKey="Folder">Folder: </Label>
</td>
<td>
<select id="parent" class="form-control" @bind="@_folderId">
Expand All @@ -30,15 +31,15 @@
</tr>
<tr>
<td>
<Label for="size" HelpText="The size of the file (in bytes)">Size: </Label>
<Label for="size" HelpText="The size of the file (in bytes)" ResourceKey="Size">Size: </Label>
</td>
<td>
<input id="size" class="form-control" @bind="@_size" readonly />
</td>
</tr>
</table>
<button type="button" class="btn btn-success" @onclick="SaveFile">Save</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<button type="button" class="btn btn-success" @onclick="SaveFile">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<br />
<br />
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
Expand Down Expand Up @@ -80,7 +81,7 @@
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading File {FileId} {Error}", _fileId, ex.Message);
AddModuleMessage("Error Loading File", MessageType.Error);
AddModuleMessage(Localizer["Error Loading File"], MessageType.Error);
}
}

Expand All @@ -99,13 +100,13 @@
}
else
{
AddModuleMessage("File Name Not Valid", MessageType.Warning);
AddModuleMessage(Localizer["File Name Not Valid"], MessageType.Warning);
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message);
AddModuleMessage("Error Saving File", MessageType.Error);
AddModuleMessage(Localizer["Error Saving File"], MessageType.Error);
}
}
}
33 changes: 17 additions & 16 deletions Oqtane.Client/Modules/Admin/Files/Edit.razor
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
@namespace Oqtane.Modules.Admin.Files
@namespace Oqtane.Modules.Admin.Files
@inherits ModuleBase
@inject IFolderService FolderService
@inject IFileService FileService
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Edit> Localizer

@if (_folders != null)
{
<table class="table table-borderless">
<tr>
<td>
<Label For="parent" HelpText="Select the parent folder">Parent: </Label>
<Label For="parent" HelpText="Select the parent folder" ResourceKey="Parent">Parent: </Label>
</td>
<td>
<select id="parent" class="form-control" @bind="@_parentId">
@if (PageState.QueryString.ContainsKey("id"))
{
<option value="-1">&lt;No Parent&gt;</option>
<option value="-1">&lt;@Localizer["No Parent"]&gt;</option>
}
@foreach (Folder folder in _folders)
{
Expand All @@ -26,27 +27,27 @@
</tr>
<tr>
<td>
<Label for="name" HelpText="Enter the folder name">Name: </Label>
<Label for="name" HelpText="Enter the folder name" ResourceKey="Name">Name: </Label>
</td>
<td>
<input id="name" class="form-control" @bind="@_name" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<Label For="permissions" HelpText="Select the permissions you want for the folder">Permissions: </Label>
<Label For="permissions" HelpText="Select the permissions you want for the folder" ResourceKey="Permissions">Permissions: </Label>
<PermissionGrid EntityName="@EntityNames.Folder" PermissionNames="Browse,View,Edit" Permissions="@_permissions" @ref="_permissionGrid" />
</td>
</tr>
</table>
@if (!_isSystem)
{
<button type="button" class="btn btn-success" @onclick="SaveFolder">Save</button>
<button type="button" class="btn btn-success" @onclick="SaveFolder">@Localizer["Save"]</button>
}
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
@if (!_isSystem && PageState.QueryString.ContainsKey("id"))
{
<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())" />
<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())" ResourceKey="DeleteFolder" />
}
<br />
<br />
Expand Down Expand Up @@ -107,21 +108,21 @@
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading Folder {FolderId} {Error}", _folderId, ex.Message);
AddModuleMessage("Error Loading Folder", MessageType.Error);
AddModuleMessage(Localizer["Error Loading Folder"], MessageType.Error);
}
}

private async Task SaveFolder()
{
if (_name == string.Empty || _parentId == -1)
{
AddModuleMessage("Folders Must Have A Parent And A Name", MessageType.Warning);
AddModuleMessage(Localizer["Folders Must Have A Parent And A Name"], MessageType.Warning);
return;
}

if (!_name.IsPathOrFileValid())
{
AddModuleMessage("Folder Name Not Valid.", MessageType.Warning);
AddModuleMessage(Localizer["Folder Name Not Valid."], MessageType.Warning);
return;
}

Expand Down Expand Up @@ -169,13 +170,13 @@
}
else
{
AddModuleMessage("An Error Was Encountered Saving The Folder", MessageType.Error);
AddModuleMessage(Localizer["An Error Was Encountered Saving The Folder"], MessageType.Error);
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message);
AddModuleMessage("Error Saving Folder", MessageType.Error);
AddModuleMessage(Localizer["Error Saving Folder"], MessageType.Error);
}
}

Expand Down Expand Up @@ -203,18 +204,18 @@
}
else
{
AddModuleMessage("Folder Has Files And Cannot Be Deleted", MessageType.Warning);
AddModuleMessage(Localizer["Folder Has Files And Cannot Be Deleted"], MessageType.Warning);
}
}
else
{
AddModuleMessage("Folder Has Subfolders And Cannot Be Deleted", MessageType.Warning);
AddModuleMessage(Localizer["Folder Has Subfolders And Cannot Be Deleted"], MessageType.Warning);
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting Folder {Folder} {Error}", _folderId, ex.Message);
AddModuleMessage("Error Deleting Folder", MessageType.Error);
AddModuleMessage(Localizer["Error Deleting Folder"], MessageType.Error);
}
}
}
Loading

0 comments on commit 0d6413e

Please sign in to comment.