105 lines
3.5 KiB
Plaintext
105 lines
3.5 KiB
Plaintext
@page "/site-info/{SiteId:int}"
|
|
@attribute [Authorize]
|
|
@using BLAIzor.Components.Layout
|
|
@using BLAIzor.Models
|
|
@using BLAIzor.Services
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@layout AdminLayout
|
|
@inject ContentEditorService _contentEditorService
|
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
|
@inject CustomAuthenticationStateProvider CustomAuthProvider
|
|
|
|
<EditForm Model="@siteInfo" OnValidSubmit="SaveSiteInfo">
|
|
<label>
|
|
Brand name
|
|
<InputText class="form-control my-3" id="siteName" @bind-Value="siteInfo.SiteName" />
|
|
</label>
|
|
<label>
|
|
Site description
|
|
<InputTextArea class="form-control my-3" style="height: 100px;" id="siteDescription" @bind-Value="siteInfo.SiteDescription" rows="3"/>
|
|
</label>
|
|
<label>
|
|
Logo url
|
|
<InputText class="form-control my-3" id="brandLogoUrl" @bind-Value="siteInfo.BrandLogoUrl" />
|
|
</label>
|
|
<label>
|
|
Default color (Do not bother with this)
|
|
<InputText class="form-control my-3" id="defaultColor" @bind-Value="siteInfo.DefaultColor" />
|
|
</label>
|
|
<label>
|
|
The Entity behind this website (eg. "company", "professional sportsman", "worldwide brand", etc);
|
|
<InputText class="form-control my-3" id="defaultColor" @bind-Value="siteInfo.Entity" />
|
|
</label>
|
|
<label>
|
|
Your agent Persona
|
|
<InputText class="form-control my-3" id="defaultColor" @bind-Value="siteInfo.Persona" />
|
|
</label>
|
|
<label>
|
|
Your domain url
|
|
<InputText class="form-control my-3" id="domainUrl" @bind-Value="siteInfo.DomainUrl" />
|
|
</label>
|
|
<label>
|
|
Chosen template
|
|
<InputNumber class="form-control my-3" id="templateId" @bind-Value="siteInfo.TemplateId" />
|
|
</label>
|
|
<label>
|
|
Published
|
|
<InputCheckbox class="my-3" id="ispublished" @bind-Value="siteInfo.IsPublished" />
|
|
</label>
|
|
<button class="btn btn-primary" type="submit">Save</button>
|
|
</EditForm>
|
|
|
|
<hr />
|
|
<h4 class="mt-4">Forms linked to this site</h4>
|
|
|
|
@if (siteInfo.FormDefinitions?.Count > 0)
|
|
{
|
|
<ul class="list-group mb-3">
|
|
@foreach (var form in siteInfo.FormDefinitions)
|
|
{
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<span>
|
|
<strong>@form.Title</strong><br />
|
|
<small class="text-muted">@form.CreatedAt.ToString("yyyy-MM-dd HH:mm")</small>
|
|
</span>
|
|
<a class="btn btn-sm btn-outline-secondary" href="/form-editor/@form.Id">Edit</a>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-muted">No forms added yet.</p>
|
|
}
|
|
|
|
<a class="btn btn-success" href="/createform/@SiteId">
|
|
<i class="fas fa-plus-circle"></i> Add New Form
|
|
</a>
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
public int SiteId { get; set; }
|
|
private SiteInfo siteInfo = new();
|
|
private string? userId;
|
|
private string? userName;
|
|
private AuthenticationState? authState;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
if (authState.User.Identity?.IsAuthenticated == true)
|
|
{
|
|
userId = CustomAuthProvider.GetUserId();
|
|
userName = CustomAuthProvider.GetUserName();
|
|
}
|
|
siteInfo = await _contentEditorService.GetSiteInfoWithFormsByIdAsync(SiteId) ?? new SiteInfo();
|
|
}
|
|
|
|
private async Task SaveSiteInfo()
|
|
{
|
|
await _contentEditorService.UpdateSiteInfoAsync(siteInfo);
|
|
}
|
|
}
|
|
|