add auto module fetch on startup and finished module creation form for real now
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Server_Dashboard {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Server information class, this will probably scale pretty big later on
|
|
||||||
/// This will hold all the information the socket will gather
|
|
||||||
/// </summary>
|
|
||||||
internal class ServerInformation {
|
|
||||||
|
|
||||||
//The ServerName
|
|
||||||
public string ServerName { get; set; }
|
|
||||||
|
|
||||||
//The unix or windows username
|
|
||||||
public string OSUserName { get; set; }
|
|
||||||
|
|
||||||
//Cpu Temp in C
|
|
||||||
public string CpuTemp { get; set; }
|
|
||||||
|
|
||||||
//Gpu Temp in C
|
|
||||||
public string GpuTemp { get; set; }
|
|
||||||
|
|
||||||
//Server uptime
|
|
||||||
public string Uptime { get; set; }
|
|
||||||
|
|
||||||
//When the server was first deployed
|
|
||||||
public string DeployDate { get; set; }
|
|
||||||
|
|
||||||
//Public IPv4 Adress
|
|
||||||
public string PublicIpAdress { get; set; }
|
|
||||||
|
|
||||||
//Private IP adress from the servers network
|
|
||||||
public string PrivateIpAdress { get; set; }
|
|
||||||
|
|
||||||
//GPU usage in %
|
|
||||||
public string GpuUsage { get; set; }
|
|
||||||
|
|
||||||
//CPU usage in %
|
|
||||||
public string CpuUsage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ using System.Configuration;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace Server_Dashboard {
|
namespace Server_Dashboard {
|
||||||
@@ -65,12 +66,77 @@ namespace Server_Dashboard {
|
|||||||
//Open the connection
|
//Open the connection
|
||||||
con.Open();
|
con.Open();
|
||||||
//SQL Query
|
//SQL Query
|
||||||
string query = "SELECT UserID, Username, Email, CreationTime, ModuleName, MI.Image FROM UserData LEFT JOIN ModuleData MD on UserData.ID = MD.UserID LEFT JOIN ModuleIcon MI on MD.ID = MI.Module WHERE Username = @username";
|
string query = "SELECT ID, Username, Email, RegistrationDate FROM UserData WHERE Username = @username";
|
||||||
//Creates a new command
|
//Creates a new command
|
||||||
using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function
|
using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function
|
||||||
//this will avoid SQL Injections
|
//this will avoid SQL Injections
|
||||||
com.Parameters.AddWithValue("@username", username);
|
com.Parameters.AddWithValue("@username", username);
|
||||||
//Execute query and return number of rows affected
|
//Execute query and return number of rows affected
|
||||||
|
DataTable resultTable = new DataTable() { TableName = "Userdata" };
|
||||||
|
using SqlDataAdapter sda = new SqlDataAdapter(com);
|
||||||
|
sda.Fill(resultTable);
|
||||||
|
return resultTable;
|
||||||
|
//Checks if there are any rows successful
|
||||||
|
//If the query returns 0 the query wasn't successful
|
||||||
|
//if its any number above 0 it was successfull
|
||||||
|
//Catch any error
|
||||||
|
} catch (SqlException ex) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
//Always close the connection
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataTable GetUserModuleData(int uid) {
|
||||||
|
//Creates the database connection
|
||||||
|
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||||
|
try {
|
||||||
|
//Open the connection
|
||||||
|
con.Open();
|
||||||
|
//SQL Query
|
||||||
|
string query = "SELECT Creator, CreationTime, ModuleName, MI.Image FROM ModuleData LEFT JOIN ModuleIcon MI on ModuleData.ID = MI.Module WHERE UserID = @userID";
|
||||||
|
//Creates a new command
|
||||||
|
using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function
|
||||||
|
//this will avoid SQL Injections
|
||||||
|
com.Parameters.AddWithValue("@userID", uid);
|
||||||
|
//Execute query and return number of rows affected
|
||||||
|
DataTable resultTable = new DataTable();
|
||||||
|
using SqlDataAdapter sda = new SqlDataAdapter(com);
|
||||||
|
sda.Fill(resultTable);
|
||||||
|
return resultTable;
|
||||||
|
//Checks if there are any rows successful
|
||||||
|
//If the query returns 0 the query wasn't successful
|
||||||
|
//if its any number above 0 it was successfull
|
||||||
|
//Catch any error
|
||||||
|
} catch (SqlException ex) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
//Always close the connection
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This function will fetch every Serverdata for each module
|
||||||
|
/// This will need some optimization, for now we just asynchronously
|
||||||
|
/// fetch the serverdata for each module
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mid">ModuleID to fetch the data from</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable GetServerData(string mid) {
|
||||||
|
//Creates the database connection
|
||||||
|
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||||
|
try {
|
||||||
|
//Open the connection
|
||||||
|
con.Open();
|
||||||
|
//SQL Query
|
||||||
|
string query = "SELECT * FROM ServerData WHERE ModuleID = @mid";
|
||||||
|
//Creates a new command
|
||||||
|
using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function
|
||||||
|
//this will avoid SQL Injections
|
||||||
|
com.Parameters.AddWithValue("@mid", mid);
|
||||||
|
//Execute query and return number of rows affected
|
||||||
DataTable resultTable = new DataTable();
|
DataTable resultTable = new DataTable();
|
||||||
using SqlDataAdapter sda = new SqlDataAdapter(com);
|
using SqlDataAdapter sda = new SqlDataAdapter(com);
|
||||||
sda.Fill(resultTable);
|
sda.Fill(resultTable);
|
||||||
@@ -113,7 +179,10 @@ namespace Server_Dashboard {
|
|||||||
com.Parameters.AddWithValue("@time", DateTime.Now);
|
com.Parameters.AddWithValue("@time", DateTime.Now);
|
||||||
com.Parameters.AddWithValue("@moduleName", moduleName);
|
com.Parameters.AddWithValue("@moduleName", moduleName);
|
||||||
com.Parameters.AddWithValue("@serverName", serverName);
|
com.Parameters.AddWithValue("@serverName", serverName);
|
||||||
com.Parameters.Add("@moduleIcon", SqlDbType.VarBinary, int.MaxValue).Value = moduleIcon;
|
com.Parameters.Add("@moduleIcon", SqlDbType.VarBinary, -1).Value = moduleIcon;
|
||||||
|
if (moduleIcon == null)
|
||||||
|
com.Parameters["@moduleIcon"].Value = DBNull.Value;
|
||||||
|
//com.Parameters.AddWithValue("@moduleIcon", moduleIcon);
|
||||||
com.Parameters.AddWithValue("@ipAdress", ipAdress);
|
com.Parameters.AddWithValue("@ipAdress", ipAdress);
|
||||||
com.Parameters.AddWithValue("@port", port);
|
com.Parameters.AddWithValue("@port", port);
|
||||||
//Execute query and return number of rows affected
|
//Execute query and return number of rows affected
|
||||||
@@ -150,21 +219,19 @@ namespace Server_Dashboard {
|
|||||||
//Open the connection
|
//Open the connection
|
||||||
con.Open();
|
con.Open();
|
||||||
//SQL Query
|
//SQL Query
|
||||||
string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT";
|
string query = "((SELECT Cookie FROM UserData WHERE Username = @username) = @cookie)";
|
||||||
//Creates a new command
|
//Creates a new command
|
||||||
using SqlCommand com = new SqlCommand(query, con);
|
using SqlCommand com = new SqlCommand(query, con);
|
||||||
//For security reasons the values are added with this function
|
//For security reasons the values are added with this function
|
||||||
//this will avoid SQL Injections
|
//this will avoid SQL Injections
|
||||||
com.Parameters.AddWithValue("@cookie", cookie);
|
com.Parameters.AddWithValue("@cookie", cookie);
|
||||||
com.Parameters.AddWithValue("@username", username);
|
com.Parameters.AddWithValue("@username", username);
|
||||||
com.Parameters.Add("@valid", SqlDbType.Bit);
|
|
||||||
com.Parameters["@valid"].Direction = ParameterDirection.Output;
|
|
||||||
//Execute query and return number of rows affected
|
//Execute query and return number of rows affected
|
||||||
int sqlResponse = com.ExecuteNonQuery();
|
int sqlResponse = com.ExecuteNonQuery();
|
||||||
//Checks if there are any rows successful
|
//Checks if there are any rows successful
|
||||||
//If the query returns 0 the query wasn't successful
|
//If the query returns 0 the query wasn't successful
|
||||||
//if its any number above 0 it was successfull
|
//if its any number above 0 it was successfull
|
||||||
if ((int)com.Parameters["@Valid"].Value == 0) {
|
if (sqlResponse == 0) {
|
||||||
//Error, not successful
|
//Error, not successful
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -191,7 +258,7 @@ namespace Server_Dashboard {
|
|||||||
//Open the connection
|
//Open the connection
|
||||||
con.Open();
|
con.Open();
|
||||||
//SQL Query
|
//SQL Query
|
||||||
string query = "EXEC DeleteUserCookie @Username = @username";
|
string query = "UPDATE UserData SET Cookie = null WHERE Username = @username";
|
||||||
//Creates a new command
|
//Creates a new command
|
||||||
using SqlCommand com = new SqlCommand(query, con);
|
using SqlCommand com = new SqlCommand(query, con);
|
||||||
//For security reasons the values are added with this function
|
//For security reasons the values are added with this function
|
||||||
@@ -224,19 +291,19 @@ namespace Server_Dashboard {
|
|||||||
/// <param name="cookie">The delicious locally stored cookie</param>
|
/// <param name="cookie">The delicious locally stored cookie</param>
|
||||||
/// <param name="username">The User who deserves a cookie :3</param>
|
/// <param name="username">The User who deserves a cookie :3</param>
|
||||||
/// <returns>[0] is false, [1] is true, [2] connection error</returns>
|
/// <returns>[0] is false, [1] is true, [2] connection error</returns>
|
||||||
public static int AddCookie(string cookie, string username) {
|
public static int AddCookie(string username, string cookie) {
|
||||||
//Creates the database connection
|
//Creates the database connection
|
||||||
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||||
try {
|
try {
|
||||||
//Open the connection
|
//Open the connection
|
||||||
con.Open();
|
con.Open();
|
||||||
//SQL Query
|
//SQL Query
|
||||||
string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username";
|
string query = "UPDATE UserData SET Cookie = @cookie WHERE Username = @username";
|
||||||
//Creates a new command
|
//Creates a new command
|
||||||
using SqlCommand com = new SqlCommand(query, con);
|
using SqlCommand com = new SqlCommand(query, con);
|
||||||
//For security reasons the values are added with this function
|
//For security reasons the values are added with this function
|
||||||
//this will avoid SQL Injections
|
//this will avoid SQL Injections
|
||||||
com.Parameters.AddWithValue("@cookie", cookie);
|
com.Parameters.Add("@cookie", SqlDbType.NVarChar, -1).Value = cookie;
|
||||||
com.Parameters.AddWithValue("@username", username);
|
com.Parameters.AddWithValue("@username", username);
|
||||||
//Execute query and return number of rows affected
|
//Execute query and return number of rows affected
|
||||||
int sqlResponse = com.ExecuteNonQuery();
|
int sqlResponse = com.ExecuteNonQuery();
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ using System.Windows.Media.Imaging;
|
|||||||
|
|
||||||
namespace Server_Dashboard {
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
/// <summary>
|
internal class ModuleData {
|
||||||
/// Dashboard Module class that holds all the information that gets displayed
|
|
||||||
/// </summary>
|
|
||||||
internal class DashboardModule {
|
|
||||||
|
|
||||||
//The name the user gives the module
|
//The name the user gives the module
|
||||||
public string ModuleName { get; set; }
|
public string ModuleName { get; set; }
|
||||||
@@ -16,9 +13,6 @@ namespace Server_Dashboard {
|
|||||||
//The user who created it
|
//The user who created it
|
||||||
public string Creator { get; set; }
|
public string Creator { get; set; }
|
||||||
|
|
||||||
//All the information that the server had
|
|
||||||
public ServerInformation ServerInfo { get; set; }
|
|
||||||
|
|
||||||
//The status indicator
|
//The status indicator
|
||||||
public string StatusIndicator { get; set; }
|
public string StatusIndicator { get; set; }
|
||||||
|
|
||||||
@@ -32,13 +26,16 @@ namespace Server_Dashboard {
|
|||||||
public BitmapImage ModuleIcon { get; set; }
|
public BitmapImage ModuleIcon { get; set; }
|
||||||
|
|
||||||
//Creation date with System.DateTime.Now
|
//Creation date with System.DateTime.Now
|
||||||
public string CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
|
|
||||||
|
//List that contains all the serverinformation over a period of time(lifespan of the module)
|
||||||
|
public List<ServerInformation> ServerInformation { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This will set the Module status indicator red or green if the server is available or not
|
/// This will set the Module status indicator red or green if the server is available or not
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serverAvailable"></param>
|
/// <param name="serverAvailable"></param>
|
||||||
public DashboardModule(bool serverAvailable) {
|
public ModuleData(bool serverAvailable) {
|
||||||
ServerAvailable = serverAvailable;
|
ServerAvailable = serverAvailable;
|
||||||
StatusIndicator = ServerAvailable ? "#20c657" : "#e53935";
|
StatusIndicator = ServerAvailable ? "#20c657" : "#e53935";
|
||||||
StatusIndicatorBG = ServerAvailable ? "#94eeb0" : "#ef9a9a";
|
StatusIndicatorBG = ServerAvailable ? "#94eeb0" : "#ef9a9a";
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Server information class, this will probably scale pretty big later on
|
||||||
|
/// This will hold all the information the socket will gather
|
||||||
|
/// </summary>
|
||||||
|
internal class ServerInformation {
|
||||||
|
public string ServerName { get; set; }
|
||||||
|
public string OSUserName { get; set; }
|
||||||
|
public double CpuTemp { get; set; }
|
||||||
|
public double GpuTemp { get; set; }
|
||||||
|
public DateTime Uptime { get; set; }
|
||||||
|
public DateTime DeployDate { get; set; }
|
||||||
|
public string PublicIpAdress { get; set; }
|
||||||
|
public string PrivateIpAdress { get; set; }
|
||||||
|
public int GpuUsage { get; set; }
|
||||||
|
public int CpuUsage { get; set; }
|
||||||
|
public double NetworkUP { get; set; }
|
||||||
|
public double NetworkDown { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a single CPU and will be added
|
||||||
|
/// to a list to account for a multi CPU system
|
||||||
|
/// </summary>
|
||||||
|
internal class CPU {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a single drive on a server, this will be added
|
||||||
|
/// to a list to account for multiple drives
|
||||||
|
/// </summary>
|
||||||
|
internal class Drives {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a single GPU and will be added to a list
|
||||||
|
/// to account for multiple GPU's
|
||||||
|
/// </summary>
|
||||||
|
internal class GPU {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents the mainboard
|
||||||
|
/// It will hold information about the chipset, number of hardware etc...
|
||||||
|
/// </summary>
|
||||||
|
internal class Motherboard {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a single network interface and will be added
|
||||||
|
/// to a list to account for multiple networking interfaces
|
||||||
|
/// </summary>
|
||||||
|
internal class NetworkInterface {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents RAM
|
||||||
|
/// TODO: figure out if it makes sense to create a class for the entire system memory
|
||||||
|
/// or for each and every stick
|
||||||
|
/// </summary>
|
||||||
|
internal class RAM {
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Server Dashboard/User/User.cs
Normal file
26
Server Dashboard/User/User.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User class to store user informations
|
||||||
|
/// </summary>
|
||||||
|
internal class User {
|
||||||
|
public int UID { get; set; }
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public string Email { get; set; }
|
||||||
|
public DateTime RegistrationDate { get; set; }
|
||||||
|
|
||||||
|
public User(DataTable userData) {
|
||||||
|
foreach (DataRow row in userData.Rows) {
|
||||||
|
UID = (int)row[0];
|
||||||
|
UserName = (string)row[1];
|
||||||
|
Email = (string)row[2];
|
||||||
|
RegistrationDate = (DateTime)row[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,46 +14,40 @@ namespace Server_Dashboard {
|
|||||||
internal class DashboardModuleViewModel : BaseViewModel {
|
internal class DashboardModuleViewModel : BaseViewModel {
|
||||||
|
|
||||||
//List with all Modules inside
|
//List with all Modules inside
|
||||||
public ObservableCollection<DashboardModule> Modules { get; set; }
|
public ObservableCollection<ModuleData> Modules { get; set; }
|
||||||
|
|
||||||
//Creates Default Modules, remove before release and when implementing the actual data comming from the socket
|
//Creates Default Modules, remove before release and when implementing the actual data comming from the socket
|
||||||
public DashboardModuleViewModel(DataTable userdata) {
|
public DashboardModuleViewModel(DataTable moduleData) {
|
||||||
GetModules(userdata);
|
Modules = new ObservableCollection<ModuleData>();
|
||||||
|
foreach (DataRow row in moduleData.Rows) {
|
||||||
|
if (row[0] != null) {
|
||||||
|
byte[] iconBytes = row[3] == DBNull.Value ? null : (byte[])row[3];
|
||||||
|
Modules.Add(new ModuleData(true) {
|
||||||
|
ModuleName = (string)row?[2],
|
||||||
|
Creator = (string)row?[0],
|
||||||
|
ModuleIcon = ConvertByteToBitmapImage(iconBytes),
|
||||||
|
CreationDate = (DateTime)row?[1],
|
||||||
|
ServerInformation = null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetModules(DataTable userdata) {
|
private BitmapImage ConvertByteToBitmapImage(byte[] icon) {
|
||||||
Modules = new ObservableCollection<DashboardModule>();
|
if (icon != null) {
|
||||||
foreach (DataRow row in userdata.Rows) {
|
try {
|
||||||
BitmapImage moduleIcon = null;
|
using MemoryStream ms = new MemoryStream(icon);
|
||||||
if (row[5] != DBNull.Value) {
|
BitmapImage moduleIcon = new BitmapImage();
|
||||||
using MemoryStream ms = new MemoryStream((byte[])row[5]);
|
|
||||||
moduleIcon = new BitmapImage();
|
|
||||||
moduleIcon.BeginInit();
|
moduleIcon.BeginInit();
|
||||||
moduleIcon.StreamSource = ms;
|
moduleIcon.StreamSource = ms;
|
||||||
moduleIcon.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
|
moduleIcon.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
|
||||||
moduleIcon.CacheOption = BitmapCacheOption.OnLoad;
|
moduleIcon.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
moduleIcon.EndInit();
|
moduleIcon.EndInit();
|
||||||
moduleIcon.Freeze();
|
moduleIcon.Freeze();
|
||||||
|
return moduleIcon;
|
||||||
|
} catch { }
|
||||||
}
|
}
|
||||||
Modules.Add(new DashboardModule(true) {
|
return null;
|
||||||
ModuleName = (string)row[4],
|
|
||||||
Creator = (string)row[1],
|
|
||||||
ModuleIcon = moduleIcon,
|
|
||||||
CreationDate = DateTime.Now.ToString(),
|
|
||||||
ServerInfo = new ServerInformation() {
|
|
||||||
GpuUsage = "20",
|
|
||||||
CpuUsage = "20",
|
|
||||||
CpuTemp = "88.88",
|
|
||||||
DeployDate = DateTime.Now.ToString(),
|
|
||||||
GpuTemp = "69.69",
|
|
||||||
ServerName = "Ubuntu",
|
|
||||||
OSUserName = "crylia ",
|
|
||||||
PrivateIpAdress = "192.168.1.1",
|
|
||||||
PublicIpAdress = "85.69.102.58",
|
|
||||||
Uptime = DateTime.Now.ToString()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ using System.Windows.Input;
|
|||||||
using Server_Dashboard_Socket;
|
using Server_Dashboard_Socket;
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Server_Dashboard {
|
namespace Server_Dashboard {
|
||||||
|
|
||||||
@@ -16,28 +18,28 @@ namespace Server_Dashboard {
|
|||||||
|
|
||||||
#region Private Values
|
#region Private Values
|
||||||
|
|
||||||
private readonly DashboardModuleViewModel dmvm;
|
private DashboardModuleViewModel dmvm;
|
||||||
|
|
||||||
#endregion Private Values
|
#endregion Private Values
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
//The Username displayed defaults to Username
|
//The Username displayed defaults to Username
|
||||||
private string userName;
|
private User user;
|
||||||
|
|
||||||
public string UserName {
|
public User User {
|
||||||
get { return userName; }
|
get { return user; }
|
||||||
set {
|
set {
|
||||||
if (userName != value)
|
if (user != value)
|
||||||
userName = value;
|
user = value;
|
||||||
OnPropertyChanged(nameof(userName));
|
OnPropertyChanged(nameof(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//List that contains every Module
|
//List that contains every Module
|
||||||
private ObservableCollection<DashboardModule> modules;
|
private ObservableCollection<ModuleData> modules;
|
||||||
|
|
||||||
public ObservableCollection<DashboardModule> Modules {
|
public ObservableCollection<ModuleData> Modules {
|
||||||
get { return modules; }
|
get { return modules; }
|
||||||
set {
|
set {
|
||||||
if (value != modules)
|
if (value != modules)
|
||||||
@@ -51,15 +53,13 @@ namespace Server_Dashboard {
|
|||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
public DashboardViewModel(string username) {
|
public DashboardViewModel(string username) {
|
||||||
UserName = username;
|
|
||||||
//Command inits
|
//Command inits
|
||||||
OpenLinkCommand = new RelayCommand(OpenLink);
|
OpenLinkCommand = new RelayCommand(OpenLink);
|
||||||
OpenNewModuleWindowCommand = new RelayCommand(OpenNewModuleWindow);
|
OpenNewModuleWindowCommand = new RelayCommand(OpenNewModuleWindow);
|
||||||
|
|
||||||
DataTable Userdata = DatabaseHandler.GetUserData(username);
|
DataTable userData = DatabaseHandler.GetUserData(username);
|
||||||
dmvm = new DashboardModuleViewModel(Userdata);
|
User = new User(userData);
|
||||||
//Sets the local module to the dashboardviewmodule modules
|
GetModules();
|
||||||
Modules = dmvm.Modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Constructor
|
#endregion Constructor
|
||||||
@@ -88,12 +88,20 @@ namespace Server_Dashboard {
|
|||||||
private void OpenNewModuleWindow(object param) {
|
private void OpenNewModuleWindow(object param) {
|
||||||
//Creates a new CreateModulePopup and sets this view model as datacontext
|
//Creates a new CreateModulePopup and sets this view model as datacontext
|
||||||
CreateModulePopup cmp = new CreateModulePopup {
|
CreateModulePopup cmp = new CreateModulePopup {
|
||||||
DataContext = new CreateModuleViewModel(UserName)
|
DataContext = new CreateModuleViewModel(User.UserName)
|
||||||
};
|
};
|
||||||
//Opens it in the middle of the screen, setting the parent window as owner causes the
|
//Opens it in the middle of the screen, setting the parent window as owner causes the
|
||||||
//application to crash when NOT in debug mode(???)
|
//application to crash when NOT in debug mode(???)
|
||||||
cmp.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
cmp.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
cmp.ShowDialog();
|
cmp.ShowDialog();
|
||||||
|
GetModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetModules() {
|
||||||
|
DataTable moduleData = DatabaseHandler.GetUserModuleData(User.UID);
|
||||||
|
dmvm = new DashboardModuleViewModel(moduleData);
|
||||||
|
//Sets the local module to the dashboardviewmodule modules
|
||||||
|
Modules = dmvm.Modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Commands
|
#endregion Commands
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ namespace Server_Dashboard {
|
|||||||
DatabaseHandler.DeleteCookie(Username);
|
DatabaseHandler.DeleteCookie(Username);
|
||||||
}
|
}
|
||||||
//If the remember user option is checked and the cookie is not set save everything locally
|
//If the remember user option is checked and the cookie is not set save everything locally
|
||||||
if (RememberUser && String.IsNullOrEmpty(Settings.Default.Cookies)) {
|
if (RememberUser && Settings.Default.Username != Username) {
|
||||||
//Creates a new GUID with the username at the end, this is the cookie
|
//Creates a new GUID with the username at the end, this is the cookie
|
||||||
var cookie = new Guid().ToString() + Username;
|
var cookie = $"{Guid.NewGuid().ToString()}+user:{Username}";
|
||||||
//Saves cookie, Username Remember me option to the local storage (Settings.settings)
|
//Saves cookie, Username Remember me option to the local storage (Settings.settings)
|
||||||
Settings.Default.Cookies = cookie;
|
Settings.Default.Cookies = cookie;
|
||||||
Settings.Default.Username = Username;
|
Settings.Default.Username = Username;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Button.Template>
|
</Button.Template>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="4" Command="{Binding OpenLinkCommand}" Content="{Binding UserName}" Margin="10 0 10 0" Height="40" Cursor="Hand">
|
<Button Grid.Column="4" Command="{Binding OpenLinkCommand}" Content="{Binding User.UserName}" Margin="10 0 10 0" Height="40" Cursor="Hand">
|
||||||
<Button.Template>
|
<Button.Template>
|
||||||
<ControlTemplate TargetType="{x:Type Button}">
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
<Border x:Name="Border" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0">
|
<Border x:Name="Border" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0">
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
8e07e5d31c9ebebb14b8f8bc5efe2ebfac9affc7
|
2b8960a5d1dd9bf90d7fb0287515a1b0a7fb5d35
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,7 @@ TRACE;DEBUG;NETCOREAPP;NETCOREAPP3_1;
|
|||||||
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml
|
||||||
8-2121814096
|
8-2121814096
|
||||||
|
|
||||||
28614409893
|
35188129793
|
||||||
207-679868162
|
207-679868162
|
||||||
Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;Controls\LoadingIndicator\LoadingIndicator.xaml;Controls\ServerModules\ServerModule.xaml;LoginWindow.xaml;Views\DashboardWindow.xaml;Views\Dashboard\CRUD Popup\CreateModulePopup.xaml;Views\Pages\MainDashboardPage.xaml;
|
Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;Controls\LoadingIndicator\LoadingIndicator.xaml;Controls\ServerModules\ServerModule.xaml;LoginWindow.xaml;Views\DashboardWindow.xaml;Views\Dashboard\CRUD Popup\CreateModulePopup.xaml;Views\Pages\MainDashboardPage.xaml;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ TRACE;DEBUG;NETCOREAPP;NETCOREAPP3_1;
|
|||||||
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml
|
C:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\App.xaml
|
||||||
8-2121814096
|
8-2121814096
|
||||||
|
|
||||||
30-984917377
|
37-1411197477
|
||||||
207-679868162
|
207-679868162
|
||||||
Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;Controls\LoadingIndicator\LoadingIndicator.xaml;Controls\ServerModules\ServerModule.xaml;LoginWindow.xaml;Views\DashboardWindow.xaml;Views\Dashboard\CRUD Popup\CreateModulePopup.xaml;Views\Pages\MainDashboardPage.xaml;
|
Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;Controls\LoadingIndicator\LoadingIndicator.xaml;Controls\ServerModules\ServerModule.xaml;LoginWindow.xaml;Views\DashboardWindow.xaml;Views\Dashboard\CRUD Popup\CreateModulePopup.xaml;Views\Pages\MainDashboardPage.xaml;
|
||||||
|
|
||||||
True
|
False
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\DoubleRoundProgressBar\DoubleRoundProgressBar.xaml;;
|
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\HalfRoundProgressBar\HalfRoundProgressBar.xaml;;
|
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\LoadingIndicator\LoadingIndicator.xaml;;
|
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Controls\ServerModules\ServerModule.xaml;;
|
|
||||||
FC:\Users\Crylia\Documents\Git\Server Dashboard\Server Dashboard\Views\DashboardWindow.xaml;;
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
#pragma checksum "..\..\..\..\Views\DashboardWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A314D0E6AD6B6AD4D75AB6130829A86ACEBFF007"
|
#pragma checksum "..\..\..\..\Views\DashboardWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3593041613773C511381544197463CBAC4FA5B88"
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#pragma checksum "..\..\..\..\Views\DashboardWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A314D0E6AD6B6AD4D75AB6130829A86ACEBFF007"
|
#pragma checksum "..\..\..\..\Views\DashboardWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3593041613773C511381544197463CBAC4FA5B88"
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
|
|||||||
Reference in New Issue
Block a user