extensibility enhancements for site templates

This commit is contained in:
Shaun Walker
2020-03-19 12:07:33 -04:00
parent 50bbc7f5b8
commit 18a843e74f
39 changed files with 758 additions and 194 deletions

View File

@ -24,19 +24,19 @@ namespace Oqtane.Services
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Installation"); }
}
public async Task<GenericResponse> IsInstalled()
public async Task<Installation> IsInstalled()
{
return await _http.GetJsonAsync<GenericResponse>(Apiurl + "/installed");
return await _http.GetJsonAsync<Installation>(Apiurl + "/installed");
}
public async Task<GenericResponse> Install(string connectionstring)
public async Task<Installation> Install(string connectionstring)
{
return await _http.PostJsonAsync<GenericResponse>(Apiurl, connectionstring);
return await _http.PostJsonAsync<Installation>(Apiurl, connectionstring);
}
public async Task<GenericResponse> Upgrade()
public async Task<Installation> Upgrade()
{
return await _http.GetJsonAsync<GenericResponse>(Apiurl + "/upgrade");
return await _http.GetJsonAsync<Installation>(Apiurl + "/upgrade");
}
}
}

View File

@ -5,8 +5,8 @@ namespace Oqtane.Services
{
public interface IInstallationService
{
Task<GenericResponse> IsInstalled();
Task<GenericResponse> Install(string connectionstring);
Task<GenericResponse> Upgrade();
Task<Installation> IsInstalled();
Task<Installation> Install(string connectionstring);
Task<Installation> Upgrade();
}
}

View File

@ -0,0 +1,11 @@
using Oqtane.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Oqtane.Services
{
public interface ISiteTemplateService
{
Task<List<SiteTemplate>> GetSiteTemplatesAsync();
}
}

View File

@ -0,0 +1,35 @@
using Oqtane.Models;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Oqtane.Shared;
namespace Oqtane.Services
{
public class SiteTemplateService : ServiceBase, ISiteTemplateService
{
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public SiteTemplateService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
}
private string Apiurl
{
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "SiteTemplate"); }
}
public async Task<List<SiteTemplate>> GetSiteTemplatesAsync()
{
List<SiteTemplate> siteTemplates = await _http.GetJsonAsync<List<SiteTemplate>>(Apiurl);
return siteTemplates.OrderBy(item => item.Name).ToList();
}
}
}