minor adjustments to backend
This commit is contained in:
+18
-16
@@ -7,11 +7,6 @@ DELIMITER $$;
|
||||
|
||||
CREATE PROCEDURE CleanTables()
|
||||
BEGIN
|
||||
TRUNCATE TABLE Timelog;
|
||||
TRUNCATE TABLE Project;
|
||||
SET foreign_key_checks = 0;
|
||||
TRUNCATE TABLE User;
|
||||
SET foreign_key_checks = 1;
|
||||
END $$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -20,7 +15,13 @@ DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE InitDB()
|
||||
BEGIN
|
||||
CALL CleanTables();
|
||||
DECLARE i INT DEFAULT 1;
|
||||
TRUNCATE TABLE Timelog;
|
||||
TRUNCATE TABLE Project;
|
||||
SET foreign_key_checks = 0;
|
||||
TRUNCATE TABLE User;
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
INSERT INTO Project(name) VALUES("My own"),("Outcons"),("Free Time");
|
||||
|
||||
CREATE TEMPORARY TABLE temp_fname (fname VARCHAR(255));
|
||||
@@ -55,14 +56,15 @@ INSERT INTO temp_mail (mail) VALUES
|
||||
( "hotmail.com" ),
|
||||
( "gmail.com" ),
|
||||
( "live.com" );
|
||||
|
||||
INSERT INTO User (f_name, l_name, mail)
|
||||
SELECT
|
||||
(SELECT fname FROM temp_fname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT lname FROM temp_lname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT mail FROM temp_mail ORDER BY RAND() LIMIT 1)
|
||||
FROM
|
||||
(SELECT 1 FROM information_schema.tables LIMIT 100) AS temp;
|
||||
|
||||
WHILE i <= 100 DO
|
||||
INSERT INTO User (f_name, l_name, mail)
|
||||
SELECT
|
||||
(SELECT fname FROM temp_fname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT lname FROM temp_lname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT mail FROM temp_mail ORDER BY RAND() LIMIT 1);
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
|
||||
UPDATE User
|
||||
SET User.mail = CONCAT(User.f_name,".", User.l_name,"@", User.mail);
|
||||
@@ -83,7 +85,7 @@ BEGIN
|
||||
DECLARE logs INT;
|
||||
DECLARE hours FLOAT;
|
||||
DECLARE project INT;
|
||||
DECLARE curDate DATE DEFAULT "2024-11-18";
|
||||
DECLARE curDate DATE DEFAULT '2024-11-18';
|
||||
DECLARE h2 INT;
|
||||
|
||||
WHILE users <= 100 DO
|
||||
@@ -118,7 +120,7 @@ DELIMITER ;
|
||||
##
|
||||
-- get data
|
||||
SELECT t.time,t.date,p.name,u.f_name,u.l_name,u.mail FROM Timelog t INNER JOIN Project p ON p.id=t.project INNER JOIN User u ON u.id=t.user;
|
||||
|
||||
-- old timelog with adding each on a new day
|
||||
CREATE PROCEDURE fill_timelog ()
|
||||
BEGIN
|
||||
DECLARE j INT DEFAULT 1;
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
namespace Server
|
||||
{
|
||||
public class CreateProcedure
|
||||
{
|
||||
public static void run(MySqlConnection conn, HttpListenerRequest request, HttpListenerResponse response)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Open the connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = @"
|
||||
CREATE PROCEDURE fill_timelog ()
|
||||
BEGIN
|
||||
DECLARE j INT DEFAULT 1;
|
||||
DECLARE users INT DEFAULT 1;
|
||||
DECLARE logs INT;
|
||||
DECLARE hours FLOAT;
|
||||
DECLARE project INT;
|
||||
DECLARE curDate DATE DEFAULT '2024-11-18';
|
||||
DECLARE h2 INT;
|
||||
|
||||
WHILE users <= 100 DO
|
||||
SET logs = FLOOR(1 + (RAND() * 20));
|
||||
SET j = 1;
|
||||
WHILE j <= logs DO
|
||||
SET project = FLOOR(1 + (RAND() * 3));
|
||||
SET curDate = DATE_ADD('2020-01-01', INTERVAL FLOOR(RAND() * DATEDIFF('2020-02-01', '2020-01-01')) DAY);
|
||||
SET hours = (RAND() * (8 - 0.25)) + 0.25;
|
||||
|
||||
SELECT SUM(time) INTO h2
|
||||
FROM Timelog
|
||||
WHERE date = curdate && user = users;
|
||||
|
||||
WHILE(h2 + hours) > 8 DO
|
||||
SET curDate = DATE_ADD('2020-01-01', INTERVAL FLOOR(RAND() * DATEDIFF('2020-02-01', '2020-01-01')) DAY);
|
||||
|
||||
SELECT SUM(time)INTO h2
|
||||
FROM Timelog
|
||||
WHERE date = curdate && user = users;
|
||||
|
||||
END WHILE;
|
||||
INSERT INTO Timelog(user, project, date, time) VALUES(users, project, curDate, hours);
|
||||
SET j = j + 1;
|
||||
END WHILE;
|
||||
SET users = users + 1;
|
||||
END WHILE;
|
||||
END;";
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.CommandText = @"CREATE PROCEDURE InitDB()
|
||||
BEGIN
|
||||
DECLARE i INT DEFAULT 1;
|
||||
TRUNCATE TABLE Timelog;
|
||||
TRUNCATE TABLE Project;
|
||||
SET foreign_key_checks = 0;
|
||||
TRUNCATE TABLE User;
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
INSERT INTO Project(name) VALUES('My own'),('Outcons'),('Free Time');
|
||||
|
||||
CREATE TEMPORARY TABLE temp_fname (fname VARCHAR(255));
|
||||
INSERT INTO temp_fname (fname) VALUES
|
||||
( 'John' ),
|
||||
( 'Gringo' ),
|
||||
( 'Mark' ),
|
||||
( 'Lisa' ),
|
||||
( 'Maria' ),
|
||||
( 'Sonya' ),
|
||||
( 'Philip' ),
|
||||
( 'Jose' ),
|
||||
( 'Lorenzo' ),
|
||||
( 'George' ),
|
||||
( 'Justin' );
|
||||
|
||||
CREATE TEMPORARY TABLE temp_lname (lname VARCHAR(255));
|
||||
INSERT INTO temp_lname (lname) VALUES
|
||||
( 'Johnson' ),
|
||||
( 'Lamas' ),
|
||||
( 'Jackson' ),
|
||||
( 'Brown' ),
|
||||
( 'Mason' ),
|
||||
( 'Rodriguez' ),
|
||||
( 'Roberts' ),
|
||||
( 'Thomas' ),
|
||||
( 'Rose' ),
|
||||
( 'McDonalds' );
|
||||
|
||||
CREATE TEMPORARY TABLE temp_mail (mail VARCHAR(255));
|
||||
INSERT INTO temp_mail (mail) VALUES
|
||||
( 'hotmail.com' ),
|
||||
( 'gmail.com' ),
|
||||
( 'live.com' );
|
||||
|
||||
WHILE i <= 100 DO
|
||||
INSERT INTO User (f_name, l_name, mail)
|
||||
SELECT
|
||||
(SELECT fname FROM temp_fname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT lname FROM temp_lname ORDER BY RAND() LIMIT 1),
|
||||
(SELECT mail FROM temp_mail ORDER BY RAND() LIMIT 1);
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
|
||||
UPDATE User
|
||||
SET User.mail = CONCAT(User.f_name,'.', User.l_name,'@', User.mail);
|
||||
|
||||
CALL fill_timelog();
|
||||
DROP TABLE temp_mail;
|
||||
DROP TABLE temp_fname;
|
||||
DROP TABLE temp_lname;
|
||||
END;";
|
||||
cmd.ExecuteNonQuery();
|
||||
// prepare response
|
||||
response.StatusCode = (int)HttpStatusCode.OK;
|
||||
response.StatusDescription = "Status OK";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Handle any connection errors
|
||||
string errorMessage = $"Error: {ex.Message}";
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
||||
response.ContentType = "text/plain";
|
||||
response.ContentLength64 = buffer.Length;
|
||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
-21
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
@@ -6,15 +5,16 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
// there should be a better way to deal with data comming from sql
|
||||
public class All
|
||||
{
|
||||
public object f_name { get; set; }
|
||||
public object l_name { get; set; }
|
||||
public object mail { get; set; }
|
||||
public object name { get; set; }
|
||||
public object time { get; set; }
|
||||
public object date { get; set; }
|
||||
public object user { get; set; }
|
||||
public object? f_name { get; set; }
|
||||
public object? l_name { get; set; }
|
||||
public object? mail { get; set; }
|
||||
public object? name { get; set; }
|
||||
public object? time { get; set; }
|
||||
public object? date { get; set; }
|
||||
public object? user { get; set; }
|
||||
}
|
||||
|
||||
public class Getall
|
||||
@@ -26,14 +26,16 @@ namespace Server
|
||||
// Open the connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
MySqlCommand myCommand = new MySqlCommand();
|
||||
myCommand.Connection = conn;
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
// get url params
|
||||
var queryString = request.QueryString;
|
||||
string from = queryString["from"];
|
||||
string to = queryString["to"];
|
||||
string sortby = queryString["sortby"];
|
||||
string offset = queryString["offset"];
|
||||
|
||||
string? from = queryString["from"];
|
||||
string? to = queryString["to"];
|
||||
string? sortby = queryString["sortby"];
|
||||
string? offset = queryString["offset"];
|
||||
string? order = queryString["order"];
|
||||
order = order == "true" ? "ASC" : "DESC";
|
||||
// this shenanigan is needed to remove the "" around
|
||||
// group by
|
||||
string sqlQ = @"SELECT u.f_name,u.l_name,u.mail,p.name,t.time,t.date,t.user
|
||||
@@ -41,6 +43,7 @@ namespace Server
|
||||
INNER JOIN Project p ON p.id=t.project
|
||||
INNER JOIN User u ON u.id=t.user ";
|
||||
string offsetQ = " LIMIT 10 OFFSET " + offset + ";";
|
||||
// depending on the incoming parameters construct a Query
|
||||
if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(from))
|
||||
{
|
||||
string whereQ = " WHERE t.date BETWEEN @from AND @to ";
|
||||
@@ -48,15 +51,18 @@ namespace Server
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sortby))
|
||||
{
|
||||
string orderQ = " ORDER BY " + sortby;
|
||||
string orderQ = " ORDER BY " + sortby + " " + order;
|
||||
sqlQ = sqlQ + orderQ;
|
||||
}
|
||||
myCommand.CommandText = sqlQ + offsetQ;
|
||||
myCommand.Parameters.AddWithValue("@from", from);
|
||||
myCommand.Parameters.AddWithValue("@to", to);
|
||||
// add the final line to the query
|
||||
cmd.CommandText = sqlQ + offsetQ;
|
||||
// those don't produce error if they don't find their variables
|
||||
cmd.Parameters.AddWithValue("@from", from);
|
||||
cmd.Parameters.AddWithValue("@to", to);
|
||||
|
||||
// Execute the query and read the results
|
||||
MySqlDataReader reader = myCommand.ExecuteReader();
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
|
||||
List<All> entries = new List<All>();
|
||||
while (reader.Read())
|
||||
{
|
||||
@@ -71,7 +77,7 @@ namespace Server
|
||||
mail = reader["mail"],
|
||||
});
|
||||
}
|
||||
// Serialize the data to JSON
|
||||
// serialize the data to JSON
|
||||
string jsonResponse = JsonConvert.SerializeObject(entries);
|
||||
// prepare response
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(jsonResponse);
|
||||
|
||||
+16
-17
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
@@ -8,13 +7,13 @@ namespace Server
|
||||
{
|
||||
public class TopTen
|
||||
{
|
||||
public object user { get; set; }
|
||||
public object date { get; set; }
|
||||
public object project { get; set; }
|
||||
public object f_name { get; set; }
|
||||
public object l_name { get; set; }
|
||||
public object name { get; set; }
|
||||
public object total_time { get; set; }
|
||||
public object? user { get; set; }
|
||||
public object? date { get; set; }
|
||||
public object? project { get; set; }
|
||||
public object? f_name { get; set; }
|
||||
public object? l_name { get; set; }
|
||||
public object? name { get; set; }
|
||||
public object? total_time { get; set; }
|
||||
}
|
||||
public class Gettopten
|
||||
{
|
||||
@@ -25,12 +24,12 @@ namespace Server
|
||||
// Open the connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
MySqlCommand myCommand = new MySqlCommand();
|
||||
myCommand.Connection = conn;
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
var queryString = request.QueryString;
|
||||
string from = queryString["from"];
|
||||
string to = queryString["to"];
|
||||
string filterBy = queryString["filterBy"];
|
||||
string? from = queryString["from"];
|
||||
string? to = queryString["to"];
|
||||
string? filterBy = queryString["filterBy"];
|
||||
// this shenanigan is needed to remove the "" around
|
||||
// group by
|
||||
string req = @"SELECT t.user,t.date,t.project,u.f_name,u.l_name,p.name,SUM(t.time) as total_time
|
||||
@@ -40,12 +39,12 @@ namespace Server
|
||||
WHERE t.date BETWEEN @from AND @to
|
||||
GROUP BY " + filterBy + @" ORDER BY total_time DESC
|
||||
LIMIT 10;";
|
||||
myCommand.CommandText = req;
|
||||
myCommand.Parameters.AddWithValue("@from", from);
|
||||
myCommand.Parameters.AddWithValue("@to", to);
|
||||
cmd.CommandText = req;
|
||||
cmd.Parameters.AddWithValue("@from", from);
|
||||
cmd.Parameters.AddWithValue("@to", to);
|
||||
|
||||
// Execute the query and read the results
|
||||
MySqlDataReader reader = myCommand.ExecuteReader();
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
List<TopTen> entries = new List<TopTen>();
|
||||
while (reader.Read())
|
||||
{
|
||||
|
||||
+10
-36
@@ -1,37 +1,11 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Dynamic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
class DynamicObject
|
||||
{
|
||||
// A dictionary to store dynamic properties/fields
|
||||
public Dictionary<object, object> Fields { get; set; }
|
||||
|
||||
public DynamicObject()
|
||||
{
|
||||
Fields = new Dictionary<object, object>();
|
||||
}
|
||||
|
||||
// Adding a dynamic field
|
||||
public void AddField(object key, object value)
|
||||
{
|
||||
Fields[key] = value;
|
||||
}
|
||||
|
||||
// Retrieving a dynamic field
|
||||
public object GetField(object key)
|
||||
{
|
||||
if (Fields.ContainsKey(key))
|
||||
{
|
||||
return Fields[key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public class Getuser
|
||||
{
|
||||
public static void run(MySqlConnection conn, HttpListenerRequest request, HttpListenerResponse response)
|
||||
@@ -41,27 +15,27 @@ namespace Server
|
||||
// Open the connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
MySqlCommand myCommand = new MySqlCommand();
|
||||
myCommand.Connection = conn;
|
||||
myCommand.CommandText = @"SELECT p.name, SUM(t.time)
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = @"SELECT p.name, SUM(t.time)
|
||||
FROM Timelog t
|
||||
INNER JOIN Project p ON p.id=t.project
|
||||
INNER JOIN User u ON u.id=t.user
|
||||
WHERE User = @userid
|
||||
GROUP BY name;";
|
||||
var queryString = request.QueryString;
|
||||
string userid = queryString["userid"];
|
||||
myCommand.Parameters.AddWithValue("@userid", userid);
|
||||
string? userid = queryString["userid"];
|
||||
cmd.Parameters.AddWithValue("@userid", userid);
|
||||
// Execute the query and read the results
|
||||
MySqlDataReader reader = myCommand.ExecuteReader();
|
||||
DynamicObject dO = new DynamicObject();
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
dynamic expando = new ExpandoObject();
|
||||
while (reader.Read())
|
||||
{
|
||||
dO.AddField(reader["name"], reader["SUM(t.time)"]);
|
||||
((IDictionary<string?, object>)expando)[reader["name"].ToString()] = reader["SUM(t.time)"];
|
||||
|
||||
}
|
||||
// Serialize the data to JSON
|
||||
string jsonResponse = JsonConvert.SerializeObject(dO);
|
||||
string jsonResponse = JsonConvert.SerializeObject(expando);
|
||||
// prepare response
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(jsonResponse);
|
||||
response.ContentType = "application/json";
|
||||
|
||||
+57
-47
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
/* using System.Threading; */
|
||||
|
||||
|
||||
namespace Server
|
||||
@@ -20,56 +17,69 @@ namespace Server
|
||||
listener.Prefixes.Add("http://localhost:5000/api/gettopten/");
|
||||
listener.Prefixes.Add("http://localhost:5000/api/getuser/");
|
||||
listener.Prefixes.Add("http://localhost:5000/api/reset/");
|
||||
listener.Prefixes.Add("http://localhost:5000/api/createp/");
|
||||
|
||||
// Start listening for incoming requests
|
||||
listener.Start();
|
||||
Console.WriteLine("Server is listening on http://localhost:5000/");
|
||||
// god knows what that is
|
||||
Thread listenerThread = new Thread(() =>
|
||||
/* Thread listenerThread = new Thread(() => */
|
||||
/* { */
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
// wait for request
|
||||
HttpListenerContext context = listener.GetContext();
|
||||
// get response and request
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
// mysql connection
|
||||
string connectionString = "server=127.0.0.1;uid=monty;pwd=some_pass;database=timelog";
|
||||
MySqlConnection conn = new MySqlConnection(connectionString);
|
||||
|
||||
// url after localhost:5000/
|
||||
// i think the validation is unnecessry but the compiler has
|
||||
// more experience
|
||||
string uri;
|
||||
if (request != null && request.Url != null)
|
||||
{
|
||||
// wait for request
|
||||
HttpListenerContext context = listener.GetContext();
|
||||
// get response and request
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
// mysql connection
|
||||
string connectionString = "server=127.0.0.1;uid=monty;pwd=some_pass;database=timelog";
|
||||
MySqlConnection conn = new MySqlConnection(connectionString);
|
||||
|
||||
// url after localhost:5000/
|
||||
var uri = request.Url.AbsolutePath;
|
||||
|
||||
switch (uri)
|
||||
{
|
||||
case "/api/reset":
|
||||
Reset.run(conn, request, response);
|
||||
break;
|
||||
case "/api/getall":
|
||||
Getall.run(conn, request, response);
|
||||
break;
|
||||
case "/api/gettopten":
|
||||
Gettopten.run(conn, request, response);
|
||||
break;
|
||||
case "/api/getuser":
|
||||
Getuser.run(conn, request, response);
|
||||
break;
|
||||
default:
|
||||
response.StatusCode = 404;
|
||||
string errorMessage = "Not Found";
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
||||
response.ContentType = "text/plain";
|
||||
response.ContentLength64 = buffer.Length;
|
||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
break;
|
||||
}
|
||||
// Close the response
|
||||
response.OutputStream.Close();
|
||||
uri = request.Url.AbsolutePath;
|
||||
}
|
||||
});
|
||||
// Start the listener thread
|
||||
listenerThread.Start();
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (uri)
|
||||
{
|
||||
case "/api/reset":
|
||||
Reset.run(conn, request, response);
|
||||
break;
|
||||
case "/api/getall":
|
||||
Getall.run(conn, request, response);
|
||||
break;
|
||||
case "/api/gettopten":
|
||||
Gettopten.run(conn, request, response);
|
||||
break;
|
||||
case "/api/getuser":
|
||||
Getuser.run(conn, request, response);
|
||||
break;
|
||||
case "/api/createp":
|
||||
CreateProcedure.run(conn, request, response);
|
||||
break;
|
||||
default:
|
||||
response.StatusCode = 404;
|
||||
string errorMessage = "Not Found";
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
||||
response.ContentType = "text/plain";
|
||||
response.ContentLength64 = buffer.Length;
|
||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
break;
|
||||
}
|
||||
// Close the response
|
||||
response.OutputStream.Close();
|
||||
}
|
||||
/* }); */
|
||||
/* // Start the listener thread */
|
||||
/* listenerThread.Start(); */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
||||
public class Reset
|
||||
{
|
||||
public static void run(MySqlConnection conn, HttpListenerRequest request, HttpListenerResponse response)
|
||||
@@ -15,11 +13,12 @@ namespace Server
|
||||
// Open the connection
|
||||
conn.Open();
|
||||
// Prepare the SQL query
|
||||
MySqlCommand myCommand = new MySqlCommand();
|
||||
myCommand.Connection = conn;
|
||||
myCommand.CommandText = "CALL InitDB";
|
||||
MySqlDataReader reader = myCommand.ExecuteReader();
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "CALL InitDB";
|
||||
// execute query
|
||||
cmd.ExecuteNonQuery();
|
||||
// set up and send response
|
||||
response.StatusCode = (int)HttpStatusCode.OK;
|
||||
response.StatusDescription = "Status OK";
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("TimelogBackend")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4496672d19c31da56be4394168028d97a19d3a6b")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("TimelogBackend")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("TimelogBackend")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
4dc0d476a06a0877992a3936924b0e881bcf70b32aef70b9fa285a64b7d9395c
|
||||
9366787f5f967306279f95e5eb689ad57d8d916a1aff008ae6b71d7ccaf910fe
|
||||
|
||||
@@ -8,6 +8,6 @@ build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = TimelogBackend
|
||||
build_property.ProjectDir = /home/arch/temp/HelloWorldApp/
|
||||
build_property.ProjectDir = /home/arch/projects/wip/timelog-interview/backendCs/
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
a26e25722337c85065d06325a739b066cff412c2c9a8e669c741ff1bfb48e5f6
|
||||
8cb7b4e3896ea6e4199194b8ade89330b75c191994f715b16fe2d035c7102d40
|
||||
|
||||
@@ -36,3 +36,41 @@
|
||||
/home/arch/temp/HelloWorldApp/obj/Debug/net8.0/TimelogBackend.pdb
|
||||
/home/arch/temp/HelloWorldApp/obj/Debug/net8.0/TimelogBackend.genruntimeconfig.cache
|
||||
/home/arch/temp/HelloWorldApp/obj/Debug/net8.0/ref/TimelogBackend.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/TimelogBackend
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/TimelogBackend.deps.json
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/TimelogBackend.runtimeconfig.json
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/TimelogBackend.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/TimelogBackend.pdb
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/BouncyCastle.Cryptography.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/Google.Protobuf.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/K4os.Compression.LZ4.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/K4os.Compression.LZ4.Streams.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/K4os.Hash.xxHash.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/MySql.Data.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/Newtonsoft.Json.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.Configuration.ConfigurationManager.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.Diagnostics.EventLog.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.IO.Pipelines.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.Security.Cryptography.ProtectedData.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.Security.Permissions.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/System.Windows.Extensions.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/ZstdSharp.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/comerr64.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/gssapi64.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/k5sprt64.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/krb5_64.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/krbcc64.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Windows.Extensions.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.AssemblyReference.cache
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.GeneratedMSBuildEditorConfig.editorconfig
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.AssemblyInfoInputs.cache
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.AssemblyInfo.cs
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.CoreCompileInputs.cache
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.CopyComplete
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/refint/TimelogBackend.dll
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.pdb
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/TimelogBackend.genruntimeconfig.cache
|
||||
/home/arch/projects/wip/timelog-interview/backendCs/obj/Debug/net8.0/ref/TimelogBackend.dll
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
349d85780636e3e61d35aee10e34ef55954b239c07ad0a356798a097ceae0148
|
||||
b9db7be95623da1c56ce81f0a2fe43bd17220a8c9689f0c3bac4131258accda2
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"/home/arch/temp/HelloWorldApp/TimelogBackend.csproj": {}
|
||||
"/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"/home/arch/temp/HelloWorldApp/TimelogBackend.csproj": {
|
||||
"/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "/home/arch/temp/HelloWorldApp/TimelogBackend.csproj",
|
||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj",
|
||||
"projectName": "TimelogBackend",
|
||||
"projectPath": "/home/arch/temp/HelloWorldApp/TimelogBackend.csproj",
|
||||
"projectPath": "/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj",
|
||||
"packagesPath": "/home/arch/.nuget/packages/",
|
||||
"outputPath": "/home/arch/temp/HelloWorldApp/obj/",
|
||||
"outputPath": "/home/arch/projects/wip/timelog-interview/backendCs/obj/",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||
|
||||
@@ -1658,11 +1658,11 @@
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "/home/arch/temp/HelloWorldApp/TimelogBackend.csproj",
|
||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj",
|
||||
"projectName": "TimelogBackend",
|
||||
"projectPath": "/home/arch/temp/HelloWorldApp/TimelogBackend.csproj",
|
||||
"projectPath": "/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj",
|
||||
"packagesPath": "/home/arch/.nuget/packages/",
|
||||
"outputPath": "/home/arch/temp/HelloWorldApp/obj/",
|
||||
"outputPath": "/home/arch/projects/wip/timelog-interview/backendCs/obj/",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "p6MNaUN/SYJSFf9M574e8kcv9EqEwjPgKKmmL1309Lwqd26TTBeTctoKZziGbcJiysFehsYg0kxDJKBlru2uCA==",
|
||||
"dgSpecHash": "05fTwHDwROQn3aS1fZFUfkni+eNLFijwdR49kiMZyADYQWkBGYKVh4QK8CMaBFfif3DNASYK7goRXVy8COyb4A==",
|
||||
"success": true,
|
||||
"projectFilePath": "/home/arch/temp/HelloWorldApp/TimelogBackend.csproj",
|
||||
"projectFilePath": "/home/arch/projects/wip/timelog-interview/backendCs/TimelogBackend.csproj",
|
||||
"expectedPackageFiles": [
|
||||
"/home/arch/.nuget/packages/bouncycastle.cryptography/2.3.1/bouncycastle.cryptography.2.3.1.nupkg.sha512",
|
||||
"/home/arch/.nuget/packages/google.protobuf/3.26.1/google.protobuf.3.26.1.nupkg.sha512",
|
||||
|
||||
@@ -8,7 +8,7 @@ function App() {
|
||||
const [reset, setReset] = useState(true);
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<Grid size={6}>
|
||||
<Grid size={{ lg: 12, xl: 6 }}>
|
||||
<LeftSide reset={reset} setReset={setReset} />
|
||||
</Grid>
|
||||
<Grid size={6}>
|
||||
|
||||
@@ -7,18 +7,37 @@ import {
|
||||
TableCell,
|
||||
TableHead,
|
||||
Table,
|
||||
Button,
|
||||
} from "@mui/material";
|
||||
|
||||
const LeftSide = ({ reset, setReset }) => {
|
||||
// next prev and sort
|
||||
const [users, setUsers] = useState();
|
||||
const [params, setParams] = useState({ offset: 0, sortby: "f_name" });
|
||||
// reset button
|
||||
// const [reset, setReset] = useState(true);
|
||||
interface User {
|
||||
date: string;
|
||||
f_name: string;
|
||||
l_name: string;
|
||||
mail: string;
|
||||
name: string;
|
||||
time: number;
|
||||
user: number;
|
||||
}
|
||||
|
||||
// date
|
||||
const [date, setDate] = useState({ from: "2021-01-01", to: "2028-01-01" });
|
||||
const [dateToSubmit, setDateToSubmit] = useState({
|
||||
const LeftSide = ({
|
||||
reset,
|
||||
setReset,
|
||||
}: {
|
||||
reset: boolean;
|
||||
setReset: Function;
|
||||
}) => {
|
||||
// next prev and sort buttons
|
||||
const [users, setUsers] = useState<User[]>();
|
||||
const [params, setParams] = useState({
|
||||
offset: 0,
|
||||
sortby: "f_name",
|
||||
from: "2000-01-01",
|
||||
to: "2028-01-01",
|
||||
order: true,
|
||||
});
|
||||
// date buttons
|
||||
const [date, setDate] = useState({
|
||||
from: "2021-01-01",
|
||||
to: "2028-01-01",
|
||||
});
|
||||
@@ -28,7 +47,7 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
const resp = await api.get("/getall", {
|
||||
params,
|
||||
});
|
||||
setUsers(resp.data);
|
||||
if (resp.data.length) setUsers(resp.data);
|
||||
}
|
||||
async function resetData() {
|
||||
await api.get("/reset");
|
||||
@@ -39,15 +58,14 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
}
|
||||
|
||||
fetchData();
|
||||
}, [reset, params, dateToSubmit]);
|
||||
}, [reset, params]);
|
||||
|
||||
const viewProjectHours = (user) => {
|
||||
const viewProjectHours = (userid: number) => {
|
||||
async function fetchHours() {
|
||||
const resp = await api.get("/getuser", {
|
||||
params: { userid: user },
|
||||
params: { userid },
|
||||
});
|
||||
// const entriesArray = Object.entries(resp.data);
|
||||
const entriesArray = Object.entries(resp.data.Fields);
|
||||
const entriesArray = Object.entries(resp.data);
|
||||
alert(entriesArray);
|
||||
}
|
||||
fetchHours();
|
||||
@@ -56,7 +74,7 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
if (!users) return <></>;
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<Grid size={5}>
|
||||
<Grid size={12}>
|
||||
<label htmlFor="date">From: </label>
|
||||
<input
|
||||
type="date"
|
||||
@@ -70,31 +88,15 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
type="date"
|
||||
id="to"
|
||||
name="to"
|
||||
value={date.to}
|
||||
value={params.to}
|
||||
onChange={(event) => setDate({ ...date, to: event.target.value })}
|
||||
/>
|
||||
<button onClick={() => setDateToSubmit(date)}>Submit Date</button>
|
||||
</Grid>
|
||||
<Grid size={3}>
|
||||
<span>Select a sort:</span>
|
||||
<select
|
||||
value={params.sortby}
|
||||
onChange={(event) =>
|
||||
setParams((prevParams) => {
|
||||
return { ...prevParams, sortby: event.target.value };
|
||||
})
|
||||
}
|
||||
<button
|
||||
onClick={() => setParams({ ...params, from: date.from, to: date.to })}
|
||||
>
|
||||
<option value="">--Select--</option>
|
||||
<option value="f_name">First name</option>
|
||||
<option value="l_name">Last Name</option>
|
||||
<option value="mail">Email</option>
|
||||
<option value="date">Date</option>
|
||||
<option value="time">Time</option>
|
||||
</select>
|
||||
Submit Date
|
||||
</button>
|
||||
</Grid>
|
||||
<Grid size={4}></Grid>
|
||||
<Grid size={4}></Grid>
|
||||
<Grid size={4}>
|
||||
<button
|
||||
onClick={() => {
|
||||
@@ -106,6 +108,9 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
>
|
||||
Prev users
|
||||
</button>
|
||||
</Grid>
|
||||
<Grid size={4}></Grid>
|
||||
<Grid size={4}>
|
||||
<button
|
||||
onClick={() =>
|
||||
setParams((prevParams) => {
|
||||
@@ -119,12 +124,73 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>First Name</TableCell>
|
||||
<TableCell>Last Name</TableCell>
|
||||
<TableCell>Email</TableCell>
|
||||
<TableCell>Project name</TableCell>
|
||||
<TableCell>Date</TableCell>
|
||||
<TableCell>Hours</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({
|
||||
...params,
|
||||
sortby: "f_name",
|
||||
order: !params.order,
|
||||
})
|
||||
}
|
||||
>
|
||||
First Name
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({
|
||||
...params,
|
||||
sortby: "l_name",
|
||||
order: !params.order,
|
||||
})
|
||||
}
|
||||
>
|
||||
Last Name
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({ ...params, sortby: "mail", order: !params.order })
|
||||
}
|
||||
>
|
||||
Email
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({
|
||||
...params,
|
||||
sortby: "project",
|
||||
order: !params.order,
|
||||
})
|
||||
}
|
||||
>
|
||||
Project
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({ ...params, sortby: "date", order: !params.order })
|
||||
}
|
||||
>
|
||||
Date
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
onClick={() =>
|
||||
setParams({ ...params, sortby: "time", order: !params.order })
|
||||
}
|
||||
>
|
||||
Hours
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell />
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
@@ -139,13 +205,15 @@ const LeftSide = ({ reset, setReset }) => {
|
||||
<TableCell>{post.time} </TableCell>
|
||||
<TableCell>
|
||||
<button onClick={() => viewProjectHours(post.user)}>
|
||||
View Project Hours
|
||||
Hours
|
||||
</button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<div>No posts found...</div>
|
||||
<TableRow>
|
||||
<TableCell>No data found...</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
@@ -2,12 +2,9 @@ import { useEffect, useState } from "react";
|
||||
import api from "../utils/api";
|
||||
import { Chart } from "react-google-charts";
|
||||
|
||||
const RightSide = (reset) => {
|
||||
const RightSide = ({ reset }: { reset: boolean }) => {
|
||||
// graph date
|
||||
const [topten, setTopten] = useState({
|
||||
from: "2000-01-01",
|
||||
to: "2100-01-01",
|
||||
});
|
||||
const [chartData, setChartData] = useState<String[][]>();
|
||||
// date input field
|
||||
const [date, setDate] = useState({ from: "2000-01-01", to: "2100-01-01" });
|
||||
const [dateToSubmit, setDateToSubmit] = useState({
|
||||
@@ -15,7 +12,7 @@ const RightSide = (reset) => {
|
||||
to: "2100-01-01",
|
||||
});
|
||||
// radio button
|
||||
const [selectedOption, setSelectedOption] = useState("project");
|
||||
const [filter, setFilter] = useState("project");
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
@@ -23,26 +20,26 @@ const RightSide = (reset) => {
|
||||
params: {
|
||||
from: dateToSubmit.from,
|
||||
to: dateToSubmit.to,
|
||||
filterBy: selectedOption,
|
||||
filterBy: filter,
|
||||
},
|
||||
});
|
||||
resp.data.unshift(["User", "Hours"]);
|
||||
// turn the data into form suitable to charts
|
||||
if (selectedOption === "project")
|
||||
if (filter === "project")
|
||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||
resp.data[idx] = [resp.data[idx].name, resp.data[idx].total_time];
|
||||
}
|
||||
else if (selectedOption === "user")
|
||||
else if (filter === "user")
|
||||
for (let idx = 1; idx < resp.data.length; idx++) {
|
||||
resp.data[idx] = [
|
||||
resp.data[idx].f_name + " " + resp.data[idx].l_name,
|
||||
resp.data[idx].total_time,
|
||||
];
|
||||
}
|
||||
setTopten(resp.data);
|
||||
setChartData(resp.data);
|
||||
}
|
||||
fetchData();
|
||||
}, [dateToSubmit, selectedOption, reset]);
|
||||
}, [dateToSubmit, filter, reset]);
|
||||
|
||||
// Chart options
|
||||
const options = {
|
||||
@@ -53,11 +50,11 @@ const RightSide = (reset) => {
|
||||
minValue: 0,
|
||||
},
|
||||
vAxis: {
|
||||
title: selectedOption,
|
||||
title: filter,
|
||||
},
|
||||
};
|
||||
|
||||
if (!topten) <></>;
|
||||
if (!chartData) <></>;
|
||||
|
||||
return (
|
||||
<div style={{ flex: 1 }}>
|
||||
@@ -85,8 +82,8 @@ const RightSide = (reset) => {
|
||||
<input
|
||||
type="radio"
|
||||
value="user"
|
||||
checked={selectedOption === "user"}
|
||||
onChange={(event) => setSelectedOption(event.target.value)}
|
||||
checked={filter === "user"}
|
||||
onChange={(event) => setFilter(event.target.value)}
|
||||
/>
|
||||
User
|
||||
</label>
|
||||
@@ -94,19 +91,23 @@ const RightSide = (reset) => {
|
||||
<input
|
||||
type="radio"
|
||||
value="project"
|
||||
checked={selectedOption === "project"}
|
||||
onChange={(event) => setSelectedOption(event.target.value)}
|
||||
checked={filter === "project"}
|
||||
onChange={(event) => setFilter(event.target.value)}
|
||||
/>
|
||||
Project
|
||||
</label>
|
||||
</>
|
||||
<Chart
|
||||
chartType="BarChart"
|
||||
width="100%"
|
||||
height="400px"
|
||||
data={topten}
|
||||
options={options}
|
||||
></Chart>
|
||||
{chartData !== undefined && chartData.length < 2 ? (
|
||||
<div>No data</div>
|
||||
) : (
|
||||
<Chart
|
||||
chartType="BarChart"
|
||||
width="100%"
|
||||
height="400px"
|
||||
data={chartData}
|
||||
options={options}
|
||||
></Chart>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user