[frontend] Cleanup template assets, add placeholders

This commit is contained in:
Laura Hausmann 2024-04-01 21:24:29 +02:00
parent 530e4ac65d
commit 8811e3c2b9
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
13 changed files with 32 additions and 147 deletions

View file

@ -2,7 +2,6 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NpgsqlTypes; using NpgsqlTypes;
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
namespace Iceshrimp.Backend.Core.Database.Tables; namespace Iceshrimp.Backend.Core.Database.Tables;

View file

@ -5,7 +5,6 @@ using Iceshrimp.Backend.Controllers.Mastodon.Renderers;
using Iceshrimp.Backend.Controllers.Mastodon.Schemas; using Iceshrimp.Backend.Controllers.Mastodon.Schemas;
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Controllers.Schemas;
using Iceshrimp.Shared.Schemas;
using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Database;
using Iceshrimp.Backend.Core.Database.Tables; using Iceshrimp.Backend.Core.Database.Tables;
using Iceshrimp.Backend.Core.Middleware; using Iceshrimp.Backend.Core.Middleware;

View file

@ -6,7 +6,7 @@
<NotFound> <NotFound>
<PageTitle>Not found</PageTitle> <PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)"> <LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p> <p role="alert">Page not found.</p>
</LayoutView> </LayoutView>
</NotFound> </NotFound>
</Router> </Router>

View file

@ -4,5 +4,5 @@ namespace Iceshrimp.Frontend.Core.Services;
internal class ApiService(HttpClient client) internal class ApiService(HttpClient client)
{ {
internal NoteControllerModel Notes = new(client); internal readonly NoteControllerModel Notes = new(client);
} }

View file

@ -26,6 +26,7 @@
<ItemGroup> <ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\assets\logo.png" /> <_ContentIncludedByDefault Remove="wwwroot\assets\logo.png" />
<_ContentIncludedByDefault Remove="wwwroot\assets\transparent.png" /> <_ContentIncludedByDefault Remove="wwwroot\assets\transparent.png" />
<_ContentIncludedByDefault Remove="wwwroot\sample-data\weather.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -15,13 +15,8 @@
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="counter"> <NavLink class="nav-link" href="hub">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter <span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Hub demo
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink> </NavLink>
</div> </div>
</nav> </nav>

View file

@ -29,10 +29,6 @@
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
} }
.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
.nav-item { .nav-item {
font-size: 0.9rem; font-size: 0.9rem;
padding-bottom: 0.5rem; padding-bottom: 0.5rem;

View file

@ -1,19 +0,0 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count (edited): @_currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int _currentCount;
private void IncrementCount()
{
_currentCount++;
}
}

View file

@ -2,6 +2,6 @@
<PageTitle>Home</PageTitle> <PageTitle>Home</PageTitle>
<h1>Hello, world!</h1> <h1>Placeholder</h1>
Welcome to your new app. A frontend is being constructed here. This page will soon be more interesting.

View file

@ -5,68 +5,69 @@
<PageTitle>Home</PageTitle> <PageTitle>Home</PageTitle>
<div class="form-group"> <div class="form-group mb-3">
<label> <label>
User: User:
<input @bind="userInput" /> <input class="form-control" @bind="_userInput"/>
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group mb-3">
<label> <label>
Message: Message:
<input @bind="messageInput" size="50" /> <input class="form-control" @bind="_messageInput" size="50"/>
</label> </label>
</div> </div>
<button @onclick="Send" disabled="@(!IsConnected)">Send</button> <button class="btn btn-primary" @onclick="Send" disabled="@(!IsConnected)">Send</button>
<hr> <hr>
<ul id="messagesList"> <ul id="messagesList">
@foreach (var message in messages) @foreach (var message in _messages)
{ {
<li>@message</li> <li>@message</li>
} }
</ul> </ul>
@code { @code {
private HubConnection? hubConnection; private HubConnection? _hubConnection;
private List<string> messages = []; private List<string> _messages = [];
private string? userInput; private string? _userInput;
private string? messageInput; private string? _messageInput;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
hubConnection = new HubConnectionBuilder() _hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri("/hubs/example")) .WithUrl(Navigation.ToAbsoluteUri("/hubs/example"))
.AddMessagePackProtocol() .AddMessagePackProtocol()
.Build(); .Build();
hubConnection.On<string, string>("ReceiveMessage", (user, message) => _hubConnection.On<string, string>("ReceiveMessage", (user, message) =>
{ {
var encodedMsg = $"{user}: {message}"; var encodedMsg = $"{user}: {message}";
messages.Add(encodedMsg); _messages.Add(encodedMsg);
InvokeAsync(StateHasChanged); InvokeAsync(StateHasChanged);
}); });
await hubConnection.StartAsync(); await _hubConnection.StartAsync();
} }
private async Task Send() private async Task Send()
{ {
if (hubConnection is not null) if (_hubConnection is not null)
{ {
await hubConnection.SendAsync("SendMessage", userInput, messageInput); await _hubConnection.SendAsync("SendMessage", _userInput, _messageInput);
} }
} }
public bool IsConnected => public bool IsConnected =>
hubConnection?.State == HubConnectionState.Connected; _hubConnection?.State == HubConnectionState.Connected;
public async ValueTask DisposeAsync() public async ValueTask DisposeAsync()
{ {
if (hubConnection is not null) if (_hubConnection is not null)
{ {
await hubConnection.DisposeAsync(); await _hubConnection.DisposeAsync();
} }
} }
} }

View file

@ -1,9 +1,9 @@
@page "/TestNote/{id}" @page "/notes/{id}"
@using Iceshrimp.Frontend.Core.Miscellaneous @using Iceshrimp.Frontend.Core.Miscellaneous
@using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Shared.Schemas @using Iceshrimp.Shared.Schemas
@inject ApiService Api @inject ApiService Api
<h3>TestNote</h3> <h3>Authenticated note preview</h3>
@if (_note != null) @if (_note != null)
{ {

View file

@ -1,60 +0,0 @@
@page "/weather"
@inject HttpClient Http
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This component demonstrates fetching data from the server.</p>
@if (_forecasts == null)
{
<p>
<em>Loading...</em>
</p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in _forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? _forecasts;
protected override async Task OnInitializedAsync()
{
_forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}

View file

@ -1,27 +0,0 @@
[
{
"date": "2022-01-06",
"temperatureC": 1,
"summary": "Freezing"
},
{
"date": "2022-01-07",
"temperatureC": 14,
"summary": "Bracing"
},
{
"date": "2022-01-08",
"temperatureC": -13,
"summary": "Freezing"
},
{
"date": "2022-01-09",
"temperatureC": -16,
"summary": "Balmy"
},
{
"date": "2022-01-10",
"temperatureC": -2,
"summary": "Chilly"
}
]