diff --git a/backend/Api/AMQP/AMQPPublisher.cs b/backend/Api/AMQP/AMQPPublisher.cs
index 5da1861..5318d56 100644
--- a/backend/Api/AMQP/AMQPPublisher.cs
+++ b/backend/Api/AMQP/AMQPPublisher.cs
@@ -31,7 +31,7 @@ namespace Api.AMQP
string message = JsonSerializer.Serialize(deviceLimit);
var body = Encoding.UTF8.GetBytes(message);
- await _channel.BasicPublishAsync(exchange: string.Empty, routingKey: _queue, body: body);
+ await _channel.BasicPublishAsync(exchange: _queue, routingKey: _queue, body: body);
// Short delay before disconnecting from rabbitMQ
diff --git a/backend/Api/BusinessLogic/DeviceLogic.cs b/backend/Api/BusinessLogic/DeviceLogic.cs
index e841509..9b317a2 100644
--- a/backend/Api/BusinessLogic/DeviceLogic.cs
+++ b/backend/Api/BusinessLogic/DeviceLogic.cs
@@ -92,7 +92,7 @@ namespace Api.BusinessLogic
/// The updated info
/// The device to be edited
/// returns the updated device in a OkObjectResult and if there is some error it returns a ConflictObjectResult and a message that explain the reason
- public async Task EditDevice(EditDeviceRequest request, int deviceId)
+ public async Task EditDevice(UpdateDeviceRequest request, int deviceId)
{
var device = await _dbAccess.ReadDevice(deviceId);
if (device != null)
@@ -111,7 +111,7 @@ namespace Api.BusinessLogic
publisher.Handle_Push_Device_Limits(deviceLimit);
}
- return await _dbAccess.EditDevice(device);
+ return await _dbAccess.UpdateDevice(device);
}
///
diff --git a/backend/Api/BusinessLogic/UserLogic.cs b/backend/Api/BusinessLogic/UserLogic.cs
index b3c7183..73b2710 100644
--- a/backend/Api/BusinessLogic/UserLogic.cs
+++ b/backend/Api/BusinessLogic/UserLogic.cs
@@ -118,7 +118,7 @@ namespace Api.BusinessLogic
/// Contains the updated user info
/// Has the id for the user that is to be updated
/// returns the updated user in a OkObjectResult and if there is some error it returns a ConflictObjectResult and a message that explain the reason
- public async Task EditProfile(EditUserRequest userRequest, int userId)
+ public async Task EditProfile(UpdateUserRequest userRequest, int userId)
{
var profile = await _dbAccess.ReadUser(userId);
var users = await _dbAccess.ReadAllUsers();
@@ -173,7 +173,7 @@ namespace Api.BusinessLogic
string hashedNewPassword = ComputeHash(passwordRequest.NewPassword, SHA256.Create(), user.Salt);
user.Password = hashedNewPassword;
- return await _dbAccess.updatePassword(user);
+ return await _dbAccess.UpdatePassword(user);
}
///
diff --git a/backend/Api/Controllers/DeviceController.cs b/backend/Api/Controllers/DeviceController.cs
index ffafd8e..c98ac83 100644
--- a/backend/Api/Controllers/DeviceController.cs
+++ b/backend/Api/Controllers/DeviceController.cs
@@ -24,7 +24,7 @@ namespace Api.Controllers
// Sends the userId to deviceLogic
[Authorize]
[HttpGet]
- public async Task GetDevices()
+ public async Task ReadDevices()
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
@@ -34,8 +34,8 @@ namespace Api.Controllers
// Sends the device and userId to deviceLogic
[Authorize]
- [HttpPost("adddevice/{referenceId}")]
- public async Task AddDevice(string referenceId)
+ [HttpPost("add/{referenceId}")]
+ public async Task CreateDevice(string referenceId)
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
@@ -46,7 +46,7 @@ namespace Api.Controllers
// Sends the deviceId to deviceLogic
[Authorize]
[HttpGet("logs/{deviceId}")]
- public async Task GetLogs(int deviceId, DateTime? dateTimeStart = null, DateTime? dateTimeEnd = null)
+ public async Task ReadLogs(int deviceId, DateTime? dateTimeStart = null, DateTime? dateTimeEnd = null)
{
DateTimeRange dateTimeRange = new DateTimeRange();
if (dateTimeStart != null && dateTimeEnd != null)
@@ -65,19 +65,16 @@ namespace Api.Controllers
// Sends the deviceId to deviceLogic
[Authorize]
[HttpPut("update/{deviceId}")]
- public async Task EditDevice([FromBody] EditDeviceRequest device, int deviceId)
+ public async Task UpdateDevice([FromBody] UpdateDeviceRequest device, int deviceId)
{
return await _deviceLogic.EditDevice(device, deviceId);
}
// Sends the userId to userLogic
[Authorize]
- [HttpDelete("Delete/{deviceId}")]
+ [HttpDelete("delete/{deviceId}")]
public async Task DeleteDevice(int deviceId)
{
- //var claims = HttpContext.User.Claims;
- //string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
- //int userId = Convert.ToInt32(userIdString);
return await _deviceLogic.DeleteDevice(deviceId);
}
}
diff --git a/backend/Api/Controllers/HealthController.cs b/backend/Api/Controllers/HealthController.cs
index ea57ff2..3deae06 100644
--- a/backend/Api/Controllers/HealthController.cs
+++ b/backend/Api/Controllers/HealthController.cs
@@ -14,10 +14,10 @@ namespace Api.Controllers
_dbAccess = dbAccess;
}
- [HttpGet("API")]
+ [HttpGet("api")]
public async Task HealthAPI() { return Ok(true); }
- [HttpGet("DB")]
+ [HttpGet("db")]
public async Task HealthDB() { return Ok(_dbAccess.Test()); }
}
}
diff --git a/backend/Api/Controllers/UserController.cs b/backend/Api/Controllers/UserController.cs
index 16dfb3f..2cff6a3 100644
--- a/backend/Api/Controllers/UserController.cs
+++ b/backend/Api/Controllers/UserController.cs
@@ -19,8 +19,8 @@ namespace Api.Controllers
}
//[Authorize]
- [HttpGet("Get")]
- public async Task GetUSer()
+ [HttpGet("get")]
+ public async Task ReadUser()
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
@@ -28,14 +28,14 @@ namespace Api.Controllers
return await _userLogic.getUser(userId);
}
- [HttpPost("Login")]
+ [HttpPost("login")]
public async Task Login([FromBody] Login login)
{
return await _userLogic.Login(login);
}
// Sends the user to userLogic
- [HttpPost("Create")]
+ [HttpPost("create")]
public async Task CreateUser([FromBody] CreateUserRequest user)
{
return await _userLogic.RegisterUser(user);
@@ -43,7 +43,7 @@ namespace Api.Controllers
[Authorize]
[HttpPut("change-password")]
- public async Task changePassword([FromBody] ChangePasswordRequest passwordRequest)
+ public async Task ChangePassword([FromBody] ChangePasswordRequest passwordRequest)
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
@@ -54,8 +54,8 @@ namespace Api.Controllers
// Sends the user and userId to userLogic
[Authorize]
- [HttpPut("Update")]
- public async Task EditUser([FromBody] EditUserRequest userRequest)
+ [HttpPut("update")]
+ public async Task UpdateUser([FromBody] UpdateUserRequest userRequest)
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
@@ -65,7 +65,7 @@ namespace Api.Controllers
// Sends the userId to userLogic
[Authorize]
- [HttpDelete("Delete")]
+ [HttpDelete("delete")]
public async Task DeleteUser()
{
var claims = HttpContext.User.Claims;
@@ -74,7 +74,7 @@ namespace Api.Controllers
return await _userLogic.DeleteUser(userId);
}
- [HttpPost("RefreshToken/{refreshToken}")]
+ [HttpPost("refreshToken/{refreshToken}")]
public async Task RefreshToken(string refreshToken)
{
return await _userLogic.RefreshToken(refreshToken);
diff --git a/backend/Api/DBAccess/DBAccess.cs b/backend/Api/DBAccess/DBAccess.cs
index fd887ac..5a7e863 100644
--- a/backend/Api/DBAccess/DBAccess.cs
+++ b/backend/Api/DBAccess/DBAccess.cs
@@ -103,7 +103,7 @@ namespace Api.DBAccess
}
- public async Task updatePassword(User user)
+ public async Task UpdatePassword(User user)
{
_context.Entry(user).State = EntityState.Modified;
@@ -170,7 +170,7 @@ namespace Api.DBAccess
/// Contains the updated device info
/// Has the id for the device that is to be updated
/// returns the updated device in a OkObjectResult and if there is some error it returns a ConflictObjectResult and a message that explain the reason
- public async Task EditDevice(Device device)
+ public async Task UpdateDevice(Device device)
{
_context.Entry(device).State = EntityState.Modified;
diff --git a/backend/Api/Models/Devices/EditDeviceRequest.cs b/backend/Api/Models/Devices/UpdateDeviceRequest.cs
similarity index 82%
rename from backend/Api/Models/Devices/EditDeviceRequest.cs
rename to backend/Api/Models/Devices/UpdateDeviceRequest.cs
index 919f80e..74bfd0c 100644
--- a/backend/Api/Models/Devices/EditDeviceRequest.cs
+++ b/backend/Api/Models/Devices/UpdateDeviceRequest.cs
@@ -1,6 +1,6 @@
namespace Api.Models.Devices
{
- public class EditDeviceRequest
+ public class UpdateDeviceRequest
{
public string Name { get; set; }
diff --git a/backend/Api/Models/Users/EditUserRequest.cs b/backend/Api/Models/Users/UpdateUserRequest.cs
similarity index 79%
rename from backend/Api/Models/Users/EditUserRequest.cs
rename to backend/Api/Models/Users/UpdateUserRequest.cs
index d4e9c43..15e9bdb 100644
--- a/backend/Api/Models/Users/EditUserRequest.cs
+++ b/backend/Api/Models/Users/UpdateUserRequest.cs
@@ -1,6 +1,6 @@
namespace Api.Models.Users
{
- public class EditUserRequest
+ public class UpdateUserRequest
{
public string UserName { get; set; }
public string Email { get; set; }
diff --git a/frontend/scripts/home.js b/frontend/scripts/home.js
index 35521b1..9f00008 100644
--- a/frontend/scripts/home.js
+++ b/frontend/scripts/home.js
@@ -90,7 +90,7 @@ async function fetchData() {
const deviceData = [];
for (const device of devices) {
- const data = await getLogsOnDeviceId(device.id, startDate.setZone("UTC"), endDate.setZone("UTC"))
+ const data = await getLogsOnDeviceId(device.id, startDate?.setZone("UTC"), endDate?.setZone("UTC"))
.catch(handleError);
deviceData.push(data);
@@ -148,7 +148,7 @@ async function fetchData() {
});
}
- chart.options.scales.x.time.unit = startDate.hasSame(endDate, "day") ? "hour" : "day";
+ chart.options.scales.x.time.unit = startDate?.hasSame(endDate, "day") ? "hour" : "day";
chart.data.datasets = deviceData.map((dataset, i) => {
const color = new Array(3)