1
0

Compare commits

..

6 Commits

5 changed files with 147 additions and 0 deletions

View File

@ -20,6 +20,12 @@
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="/todo">
<span class="bi bi-list-check-nav-menu" aria-hidden="true"></span> To-do list
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter

View File

@ -51,6 +51,10 @@
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-motherboard-fill' viewBox='0 0 16 16'%3E %3Cpath d='M5 7h3V4H5z'/%3E %3Cpath d='M1 2a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-2H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 9H1V8H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 6H1V5H.5a.5.5 0 0 1-.5-.5v-2A.5.5 0 0 1 .5 2zm11 .5a.5.5 0 0 0-1 0v7a.5.5 0 0 0 1 0zm2 0a.5.5 0 0 0-1 0v7a.5.5 0 0 0 1 0zM3.5 10a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zM4 4h-.5a.5.5 0 0 0 0 1H4v1h-.5a.5.5 0 0 0 0 1H4a1 1 0 0 0 1 1v.5a.5.5 0 0 0 1 0V8h1v.5a.5.5 0 0 0 1 0V8a1 1 0 0 0 1-1h.5a.5.5 0 0 0 0-1H9V5h.5a.5.5 0 0 0 0-1H9a1 1 0 0 0-1-1v-.5a.5.5 0 0 0-1 0V3H6v-.5a.5.5 0 0 0-1 0V3a1 1 0 0 0-1 1m7 7.5v1a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-2a.5.5 0 0 0-.5.5'/%3E%3C/svg%3E");
}
.bi-list-check-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-check' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5M3.854 2.146a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 3.293l1.146-1.147a.5.5 0 0 1 .708 0m0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 7.293l1.146-1.147a.5.5 0 0 1 .708 0m0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0'/%3E%3C/svg%3E");
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;

View File

@ -0,0 +1,50 @@
@page "/todo"
<h3>To-do list</h3>
<p>List of tasks that must be done for server management.</p>
<hr/>
<br/>
<button type="button" class="btn btn-primary" @onclick="AddTask">Add Task</button>
<br/>
<br/>
@if (items != null && items.Count > 0)
{
<ul class="list-unstyled">
@foreach (var item in items)
{
<li @key="item.Id">
<div class="row mb-2">
<div class="col-1" style="width: 30px;">
<input type="checkbox" class="form-check-input" style="vertical-align: middle" @bind-value="item.IsCompleted" checked="@item.IsCompleted"/>
</div>
<div class="col">
@if (item.IsCompleted)
{
<input type="text" class="form-control border-0 text-decoration-line-through" style="vertical-align: middle" @bind-value="item.Name" disabled/>
}
else
{
<input type="text" class="form-control border-0" style="vertical-align: middle" @bind-value="item.Name"/>
}
</div>
<div class="col">
@if (item.IsCompleted)
{
<text>Completed at: @item.DateCompleted.ToLongDateString()</text>
}
</div>
</div>
</li>
}
</ul>
}
@code {
private List<ToDoItem> items = ToDoItemsRepository.GetItems();
private void AddTask()
{
ToDoItemsRepository.AddItem(new ToDoItem { Name = "New Task"} );
items = ToDoItemsRepository.GetItems();
}
}

View File

@ -0,0 +1,21 @@
namespace ServerManagement.Models
{
public class ToDoItem
{
public int Id { get; set; }
public string Name { get; set; } = "";
private bool _isCompleted;
public bool IsCompleted {
get => _isCompleted;
set
{
_isCompleted = value;
if (value)
{
DateCompleted = DateTime.Now;
}
}
}
public DateTime DateCompleted { get; set; }
}
}

View File

@ -0,0 +1,66 @@
namespace ServerManagement.Models
{
public static class ToDoItemsRepository
{
private static List<ToDoItem> items = new List<ToDoItem>()
{
new ToDoItem { Id = 1, Name = "Update firmware of Brocade ICX 6430." },
new ToDoItem { Id = 2, Name = "Fix bug with missing icons on Windows server." },
new ToDoItem { Id = 3, Name = "Install Docker hub on Server D." },
new ToDoItem { Id = 4, Name = "Upgrade VM RAM." },
new ToDoItem { Id = 5, Name = "Investigate disk size of Debian server." },
};
public static void AddItem(ToDoItem item)
{
var maxId = items.Max(s => s.Id);
item.Id = (items.Count > 0) ? maxId + 1 : 1;
items.Add(item);
}
public static List<ToDoItem> GetItems()
{
var sortedItems = items
.OrderBy(item => item.IsCompleted)
.ThenByDescending(item => item.Id)
.ToList();
return sortedItems;
}
public static ToDoItem? GetItemById(int id)
{
var item = items.FirstOrDefault(item => item.Id == id);
if (item != null)
{
return new ToDoItem { Id = item.Id, Name = item.Name };
}
return null;
}
public static void UpdateItem(int itemId, ToDoItem item)
{
if (itemId != item.Id) return;
var itemToUpdate = items.FirstOrDefault(item => item.Id == itemId);
if (itemToUpdate != null)
{
itemToUpdate.Name = item.Name;
}
}
public static void DeleteItem(int itemId)
{
var itemToDelete = items.FirstOrDefault(item => item.Id == itemId);
if (itemToDelete != null)
{
items.Remove(itemToDelete);
}
}
public static List<ToDoItem> SearchItems(string itemFilter)
{
return items.Where(item => item.Name.Contains(itemFilter, StringComparison.OrdinalIgnoreCase))
.ToList();
}
}
}