Install Wizard

This commit is contained in:
Shaun Walker
2019-07-18 13:11:31 -04:00
parent af70f0a956
commit 1c0d2de9fe
36 changed files with 580 additions and 218 deletions

View File

@ -11,17 +11,19 @@ namespace Oqtane.Services
public class AliasService : ServiceBase, IAliasService
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public AliasService(HttpClient http, IUriHelper urihelper)
public AliasService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(urihelper.GetAbsoluteUri(), "Alias"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Alias"); }
}
public async Task<List<Alias>> GetAliasesAsync()

View File

@ -0,0 +1,12 @@
using Oqtane.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Oqtane.Services
{
public interface IInstallationService
{
Task<GenericResponse> IsInstalled();
Task<GenericResponse> Install(string connectionstring);
}
}

View File

@ -0,0 +1,39 @@
using Oqtane.Models;
using System.Threading.Tasks;
using System.Net.Http;
using System.Linq;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using Oqtane.Shared;
namespace Oqtane.Services
{
public class InstallationService : ServiceBase, IInstallationService
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public InstallationService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Installation"); }
}
public async Task<GenericResponse> IsInstalled()
{
return await http.GetJsonAsync<GenericResponse>(apiurl + "/installed");
}
public async Task<GenericResponse> Install(string connectionstring)
{
return await http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
}
}
}

View File

@ -14,16 +14,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public ModuleDefinitionService(HttpClient http, SiteState sitestate)
public ModuleDefinitionService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "ModuleDefinition"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "ModuleDefinition"); }
}
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()

View File

@ -12,16 +12,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public ModuleService(HttpClient http, SiteState sitestate)
public ModuleService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Module"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Module"); }
}
public async Task<List<Module>> GetModulesAsync(int PageId)

View File

@ -12,16 +12,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public PageModuleService(HttpClient http, SiteState sitestate)
public PageModuleService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "PageModule"); }
get { return CreateApiUrl(sitestate.Alias, "PageModule", urihelper.GetAbsoluteUri()); }
}
public async Task<List<PageModule>> GetPageModulesAsync()

View File

@ -12,16 +12,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public PageService(HttpClient http, SiteState sitestate)
public PageService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Page"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Page"); }
}
public async Task<List<Page>> GetPagesAsync(int SiteId)

View File

@ -1,4 +1,5 @@
using System;
using Microsoft.AspNetCore.Components;
using Oqtane.Models;
using Oqtane.Shared;
@ -6,21 +7,24 @@ namespace Oqtane.Services
{
public class ServiceBase
{
// method for alias agnostic api call
public string CreateApiUrl(string absoluteUri, string serviceName)
{
Uri uri = new Uri(absoluteUri);
string apiurl = uri.Scheme + "://" + uri.Authority + "/~/api/" + serviceName;
return apiurl;
}
// method for alias specific api call
public string CreateApiUrl(Alias alias, string serviceName)
public string CreateApiUrl(Alias alias, string absoluteUri, string serviceName)
{
string apiurl = alias.Url + "/";
if (alias.Path == "")
string apiurl = "";
if (alias != null)
{
apiurl += "~/";
// build a url which passes the alias that may include a subfolder for multi-tenancy
apiurl = alias.Url + "/";
if (alias.Path == "")
{
apiurl += "~/";
}
}
else
{
// build a url which ignores any subfolder for multi-tenancy
Uri uri = new Uri(absoluteUri);
apiurl = uri.Scheme + "://" + uri.Authority + "/~/";
}
apiurl += "api/" + serviceName;
return apiurl;

View File

@ -12,16 +12,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public SiteService(HttpClient http, SiteState sitestate)
public SiteService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Site"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Site"); }
}
public async Task<List<Site>> GetSitesAsync()

View File

@ -12,16 +12,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public TenantService(HttpClient http, SiteState sitestate)
public TenantService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Tenant"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Tenant"); }
}
public async Task<List<Tenant>> GetTenantsAsync()

View File

@ -14,16 +14,18 @@ namespace Oqtane.Services
{
private readonly HttpClient http;
private readonly SiteState sitestate;
private readonly IUriHelper urihelper;
public ThemeService(HttpClient http, SiteState sitestate)
public ThemeService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
{
this.http = http;
this.sitestate = sitestate;
this.urihelper = urihelper;
}
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Theme"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Theme"); }
}
public async Task<List<Theme>> GetThemesAsync()

View File

@ -24,7 +24,7 @@ namespace Oqtane.Services
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "User"); }
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "User"); }
}
public async Task<List<User>> GetUsersAsync()