Skip to content

Commit

Permalink
Make installation required in access roles
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Dec 8, 2023
1 parent 50a4c20 commit f9745fa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
9 changes: 1 addition & 8 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public static class InitDb
private static List<AccessRole> GetAccessRoles()
{
var accessRole1 = new AccessRole
{
AccessLevel = RoleAccessLevel.USER,
RoleName = "Role.User"
};

var accessRole2 = new AccessRole
{
Installation = installations[0],
AccessLevel = RoleAccessLevel.ADMIN,
Expand All @@ -60,8 +54,7 @@ private static List<AccessRole> GetAccessRoles()

return new List<AccessRole>(new[]
{
accessRole1,
accessRole2
accessRole1
});
}

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Database/Models/AccessRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AccessRole
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }

public Installation? Installation { get; set; }
public Installation Installation { get; set; }

[Required]
public string RoleName { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<Robot> CreateFromQuery(CreateRobotQuery robotQuery)
context.Entry(robotModel).State = EntityState.Unchanged;
await context.Robots.AddAsync(newRobot);
await ApplyDatabaseUpdate(newRobot.CurrentInstallation);
_ = signalRService.SendMessageAsync("Robot added", newRobot?.CurrentInstallation, new RobotResponse(newRobot!));
_ = signalRService.SendMessageAsync("Robot added", newRobot!.CurrentInstallation, new RobotResponse(newRobot!));
return newRobot!;
}
throw new DbUpdateException("Could not create new robot in database as robot model does not exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const RobotStatusSection = () => {
}
const relevantRobots = sortRobotsByStatus(
enabledRobots.filter((robot) => {
return robot.currentInstallation.installationCode.toLocaleLowerCase() === installationCode.toLocaleLowerCase()
return (
robot.currentInstallation.installationCode.toLocaleLowerCase() ===
installationCode.toLocaleLowerCase()
)
})
)
setRobots(relevantRobots)
Expand Down

0 comments on commit f9745fa

Please sign in to comment.