Compare commits
1 Commits
ec40145c69
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e28bde1cfe |
@@ -120,7 +120,7 @@ public class UnitTest1
|
|||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/getuser");
|
HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/getuser");
|
||||||
|
|
||||||
Assert.AreEqual((int)response.StatusCode, 400);
|
Assert.AreEqual((int)response.StatusCode, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|||||||
+17
-17
@@ -7,23 +7,6 @@ namespace TimelogBackend;
|
|||||||
|
|
||||||
public class Getuser : Route
|
public class Getuser : Route
|
||||||
{
|
{
|
||||||
private static dynamic ExtractDataFromDB(MySqlCommand cmd)
|
|
||||||
{
|
|
||||||
using MySqlConnection conn = new(connectionString);
|
|
||||||
conn.Open();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
// execute query and read results
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
dynamic expando = new ExpandoObject();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
((IDictionary<string?, object>)expando)[reader["name"].ToString()] = reader[
|
|
||||||
"SUM(t.time)"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return expando;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -56,4 +39,21 @@ public class Getuser : Route
|
|||||||
SendError(response, ex);
|
SendError(response, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static dynamic ExtractDataFromDB(MySqlCommand cmd)
|
||||||
|
{
|
||||||
|
using MySqlConnection conn = new(connectionString);
|
||||||
|
conn.Open();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
// execute query and read results
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
dynamic expando = new ExpandoObject();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
((IDictionary<string?, object>)expando)[reader["name"].ToString()] = reader[
|
||||||
|
"SUM(t.time)"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return expando;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
date: string;
|
Date: string;
|
||||||
f_name: string;
|
FName: string;
|
||||||
l_name: string;
|
LName: string;
|
||||||
mail: string;
|
Mail: string;
|
||||||
name: string;
|
Name: string;
|
||||||
time: number;
|
Time: number;
|
||||||
user: number;
|
User: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO date input should send error when there is no data in the response
|
//TODO date input should send error when there is no data in the response
|
||||||
@@ -47,6 +47,7 @@ const LeftSide = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
const resp = await api.get("/getall", { params });
|
const resp = await api.get("/getall", { params });
|
||||||
|
console.log(resp.data);
|
||||||
if (resp.data.length) setUsers(resp.data);
|
if (resp.data.length) setUsers(resp.data);
|
||||||
}
|
}
|
||||||
async function resetData() {
|
async function resetData() {
|
||||||
@@ -156,14 +157,14 @@ const LeftSide = ({
|
|||||||
{users.length > 0 && Array.isArray(users) ? (
|
{users.length > 0 && Array.isArray(users) ? (
|
||||||
users.map((post, idx) => (
|
users.map((post, idx) => (
|
||||||
<TableRow key={idx}>
|
<TableRow key={idx}>
|
||||||
<TableCell>{post.f_name} </TableCell>
|
<TableCell>{post.FName} </TableCell>
|
||||||
<TableCell>{post.l_name} </TableCell>
|
<TableCell>{post.LName} </TableCell>
|
||||||
<TableCell>{post.mail} </TableCell>
|
<TableCell>{post.Mail} </TableCell>
|
||||||
<TableCell>{post.name} </TableCell>
|
<TableCell>{post.Name} </TableCell>
|
||||||
<TableCell>{post.date.slice(0, 10)} </TableCell>
|
<TableCell>{post.Date.slice(0, 10)} </TableCell>
|
||||||
<TableCell>{post.time} </TableCell>
|
<TableCell>{post.Time} </TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<button onClick={() => viewProjectHours(post.user)}>
|
<button onClick={() => viewProjectHours(post.User)}>
|
||||||
Hours
|
Hours
|
||||||
</button>
|
</button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ const RightSide = ({ reset }: { reset: boolean }) => {
|
|||||||
// turn the data into form suitable to charts
|
// turn the data into form suitable to charts
|
||||||
if (filter === "project")
|
if (filter === "project")
|
||||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||||
resp.data[idx] = [resp.data[idx].name, resp.data[idx].total_time];
|
resp.data[idx] = [resp.data[idx].Name, resp.data[idx].TotalTime];
|
||||||
}
|
}
|
||||||
else if (filter === "user")
|
else if (filter === "user")
|
||||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||||
resp.data[idx] = [
|
resp.data[idx] = [
|
||||||
resp.data[idx].f_name + " " + resp.data[idx].l_name,
|
resp.data[idx].FName + " " + resp.data[idx].LName,
|
||||||
resp.data[idx].total_time,
|
resp.data[idx].TotalTime,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
setChartData(resp.data);
|
setChartData(resp.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user