-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
105 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ToDoList.Frontend.Clients; | ||
using ToDoList.Frontend.Views; | ||
|
||
public interface IToDoItemsClient | ||
{ | ||
public List<ToDoItemView> ReadItems(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace ToDoList.Frontend.Clients; | ||
|
||
using ToDoList.Domain.DTOs; | ||
using ToDoList.Frontend.Views; | ||
|
||
public class ToDoItemsClient : IToDoItemsClient | ||
{ | ||
private readonly HttpClient httpClient; | ||
public ToDoItemsClient(HttpClient httpClient) | ||
Check warning on line 9 in ToDoList/src/ToDoList.Frontend/Clients/ToDoItemsClient.cs GitHub Actions / build
|
||
{ | ||
httpClient = httpClient; | ||
} | ||
|
||
public List<ToDoItemView> ReadItems() | ||
{ | ||
var toDoItemsView = new List<ToDoItemView>(); | ||
var response = httpClient.GetFromJsonAsync<List<ToDoItemGetResponseDto>>("api/ToDoItems"); | ||
|
||
toDoItemsView = response.Result.Select(dto => new ToDoItemView | ||
Check warning on line 19 in ToDoList/src/ToDoList.Frontend/Clients/ToDoItemsClient.cs GitHub Actions / build
|
||
{ | ||
ToDoItemId = dto.Id, | ||
Name = dto.Name, | ||
Description = dto.Description, | ||
IsCompleted = dto.IsCompleted | ||
}).ToList(); | ||
|
||
return toDoItemsView; | ||
} | ||
} |
32 changes: 20 additions & 12 deletions
32
ToDoList/src/ToDoList.Frontend/Components/Dashboard.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
@rendermode InteractiveServer | ||
@using ToDoList.Frontend.Views | ||
@using ToDoList.Frontend.Clients | ||
@inject IToDoItemsClient ToDoItemsClient | ||
@rendermode InteractiveServer | ||
|
||
<h1>Dashboard</h1> | ||
|
||
<table> | ||
<tr> | ||
<td><button @onclick="OrderById">Seradit Podle Id</button></td> | ||
<td><button @onclick="OrderByName">Seradit Podle Jmena</button></td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
|
||
@foreach (var toDoItem in toDoItems) | ||
{ | ||
<tr> | ||
<td>@toDoItem.ToDoItemId</td> | ||
<td>@toDoItem.Name</td> | ||
<td>@toDoItem.IsCompleted</td> | ||
<td>@toDoItem.Description</td> | ||
<td>@toDoItem.IsCompleted</td> | ||
</tr> | ||
} | ||
</table> | ||
|
||
@code | ||
{ | ||
private List<ToDoItemView> toDoItems = | ||
[ | ||
new ToDoItemView() {ToDoItemId = 1, Name = "Udelat ukol na Czechitas", IsCompleted = false}, | ||
new ToDoItemView() {ToDoItemId = 2, Name = "Udelat nepovinny ukol na Czechitas", IsCompleted = false} | ||
]; | ||
private List<ToDoItemView> toDoItems = ToDoItemsClient.ReadItems(); | ||
Check failure on line 29 in ToDoList/src/ToDoList.Frontend/Components/Dashboard.razor GitHub Actions / build
|
||
|
||
public class ToDoItemView | ||
public void OrderByName() | ||
{ | ||
toDoItems = toDoItems.OrderBy(item => item.Name).ToList(); | ||
} | ||
public void OrderById() | ||
{ | ||
public int ToDoItemId { get; set; } | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public bool IsCompleted { get; set; } | ||
toDoItems = toDoItems.OrderBy(item => item.ToDoItemId).ToList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
<PageTitle>Home</PageTitle> | ||
|
||
<Dashboard/> | ||
<Dashboard /> | ||
|
||
<h1>@ahojSvete</h1> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 31 additions & 31 deletions
62
ToDoList/src/ToDoList.Frontend/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:64752", | ||
"sslPort": 44304 | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:64752", | ||
"sslPort": 44304 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "http://localhost:5001", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "https://localhost:7001;http://localhost:5001", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5174", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7006;http://localhost:5174", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ToDoList.Frontend.Views; | ||
|
||
public class ToDoItemView | ||
{ | ||
public int ToDoItemId { get; set; } | ||
public string Name { get; set; } | ||
Check warning on line 6 in ToDoList/src/ToDoList.Frontend/Views/ToDoItemView.cs GitHub Actions / build
|
||
public string Description { get; set; } | ||
Check warning on line 7 in ToDoList/src/ToDoList.Frontend/Views/ToDoItemView.cs GitHub Actions / build
|
||
public bool IsCompleted { get; set; } | ||
} |