Skip to content

Commit

Permalink
Add dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Aug 10, 2024
1 parent 0ce8adf commit 6fd5b7c
Show file tree
Hide file tree
Showing 40 changed files with 1,195 additions and 307 deletions.
3 changes: 2 additions & 1 deletion api/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public async Task<IActionResult> Edit([FromBody] EditUserModel model)
User.FindFirst("Id")!.Value,
model.Username,
model.Email,
model.Avatar
model.Avatar,
model.Theme
);

return result.ToActionResult();
Expand Down
2 changes: 2 additions & 0 deletions api/Data/Dto/AccountDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public class AccountDto
public required string Email { get; set; }

public string? AvatarPath { get; set; }

public InterfaceTheme Theme { get; set; }
}
2 changes: 2 additions & 0 deletions api/Data/Dto/UserDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public class UserDto
public required string Username { get; init; }

public string? AvatarPath { get; init; }

public InterfaceTheme Theme { get; set; }
}
7 changes: 7 additions & 0 deletions api/Data/InterfaceTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Planera.Data;

public enum InterfaceTheme
{
Light,
Dark,
}
2 changes: 2 additions & 0 deletions api/Data/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class User : IdentityUser
{
public string? AvatarPath { get; set; }

public InterfaceTheme Theme { get; set; }

public ICollection<Project> Projects { get; init; } = new List<Project>();

public ICollection<Ticket> Tickets { get; set; } = new List<Ticket>();
Expand Down
3 changes: 3 additions & 0 deletions api/Hubs/IUserHubContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Planera.Data;
using Planera.Data.Dto;

namespace Planera.Hubs;
Expand All @@ -7,4 +8,6 @@ public interface IUserHubContext
public Task OnAddProject(ProjectDto project);

public Task OnAddInvitation(ProjectDto project);

public Task SetTheme(InterfaceTheme theme);
}
36 changes: 21 additions & 15 deletions api/Hubs/UserHub.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using Planera.Data;
using Planera.Extensions;
using Planera.Services;

namespace Planera.Hubs;

[Authorize]
public class UserHub : Hub<IUserHubContext>
public class UserHub(UserService userService, IHubContext<ProjectHub, IProjectHubContext> projectHub)
: Hub<IUserHubContext>
{
private readonly UserService _userService;
private readonly IHubContext<ProjectHub, IProjectHubContext> _projectHub;

public UserHub(UserService userService, IHubContext<ProjectHub, IProjectHubContext> projectHub)
{
_userService = userService;
_projectHub = projectHub;
}

public async Task AcceptInvitation(string projectId)
{
string userId = Context.User!.FindFirst("Id")!.Value;
var result = await _userService.AcceptInvitation(userId, projectId);
var userId = Context.User!.FindFirst("Id")!.Value;
var result = await userService.AcceptInvitation(userId, projectId);

var invitation = result.Unwrap();
await Clients
.User(Context.User!.Identity!.Name!)
.OnAddProject(invitation.Project);
await _projectHub.Clients
await projectHub.Clients
.Group(projectId)
.OnAddParticipant(invitation.User);
}

public async Task DeclineInvitation(string projectId)
{
string userId = Context.User!.FindFirst("Id")!.Value;
var result = await _userService.DeclineInvitation(userId, projectId);
var userId = Context.User!.FindFirst("Id")!.Value;
var result = await userService.DeclineInvitation(userId, projectId);
result.Unwrap();
}

public async Task SetTheme(InterfaceTheme theme)
{
var userId = Context.User!.FindFirst("Id")!.Value;
var result = await userService.EditAsync(
userId,
null,
null,
null,
theme
);
result.Unwrap();
}
}
Loading

0 comments on commit 6fd5b7c

Please sign in to comment.