improved file upload, enhanced module installation from Nuget to support upgrades, added ability to upgrade the framework from Nuget, completed isolated multitenancy and site alias management, created IPortable interface for importing data into modules, added default content to initial installation
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Oqtane.Shared;
|
||||
@ -7,12 +9,14 @@ namespace Oqtane.Services
|
||||
{
|
||||
public class FileService : ServiceBase, IFileService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly IJSRuntime jsRuntime;
|
||||
|
||||
public FileService(SiteState sitestate, NavigationManager NavigationManager, IJSRuntime jsRuntime)
|
||||
public FileService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager, IJSRuntime jsRuntime)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this.jsRuntime = jsRuntime;
|
||||
@ -23,15 +27,29 @@ namespace Oqtane.Services
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "File"); }
|
||||
}
|
||||
|
||||
public async Task UploadFilesAsync(string Folder)
|
||||
public async Task<List<string>> GetFilesAsync(string Folder)
|
||||
{
|
||||
await UploadFilesAsync(Folder, "");
|
||||
return await http.GetJsonAsync<List<string>>(apiurl + "?folder=" + Folder);
|
||||
}
|
||||
|
||||
public async Task UploadFilesAsync(string Folder, string FileUploadName)
|
||||
public async Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName)
|
||||
{
|
||||
bool success = false;
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.UploadFiles(apiurl + "/upload", Folder, FileUploadName);
|
||||
List<string> files = await GetFilesAsync(Folder);
|
||||
if (files.Count > 0)
|
||||
{
|
||||
success = true;
|
||||
foreach (string file in Files)
|
||||
{
|
||||
if (!files.Contains(file))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,5 +35,10 @@ namespace Oqtane.Services
|
||||
{
|
||||
return await http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> Upgrade()
|
||||
{
|
||||
return await http.GetJsonAsync<GenericResponse>(apiurl + "/upgrade");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace Oqtane.Services
|
||||
{
|
||||
public interface IFileService
|
||||
{
|
||||
Task UploadFilesAsync(string Folder);
|
||||
Task UploadFilesAsync(string Folder, string FileUploadName);
|
||||
Task<List<string>> GetFilesAsync(string Folder);
|
||||
Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
@ -8,5 +7,6 @@ namespace Oqtane.Services
|
||||
{
|
||||
Task<GenericResponse> IsInstalled();
|
||||
Task<GenericResponse> Install(string connectionstring);
|
||||
Task<GenericResponse> Upgrade();
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,5 +12,7 @@ namespace Oqtane.Services
|
||||
Task<Module> AddModuleAsync(Module Module);
|
||||
Task<Module> UpdateModuleAsync(Module Module);
|
||||
Task DeleteModuleAsync(int ModuleId);
|
||||
Task<bool> ImportModuleAsync(int ModuleId, string Content);
|
||||
Task<string> ExportModuleAsync(int ModuleId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,5 +60,15 @@ namespace Oqtane.Services
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<bool> ImportModuleAsync(int ModuleId, string Content)
|
||||
{
|
||||
return await http.PostJsonAsync<bool>(apiurl + "/import?moduleid=" + ModuleId, Content);
|
||||
}
|
||||
|
||||
public async Task<string> ExportModuleAsync(int ModuleId)
|
||||
{
|
||||
return await http.GetStringAsync(apiurl + "/export?moduleid=" + ModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user