continue development
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -57,9 +57,6 @@ def display_account_info(account_id):
|
||||
label_key.grid(row=0, column=i*2, sticky='w', padx=10)
|
||||
label_value.grid(row=0, column=i*2+1, sticky='w', padx=10)
|
||||
|
||||
|
||||
|
||||
|
||||
##############
|
||||
### Layout ###
|
||||
##############
|
||||
@@ -87,6 +84,16 @@ display_account_info(account_id)
|
||||
table_frame = customtkinter.CTkFrame(root)
|
||||
table_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
# Add buttons for adding a new transaction, requesting the OTP, and editing the account details
|
||||
button_frame = customtkinter.CTkFrame(root)
|
||||
button_frame.pack(fill=tk.X, pady=10)
|
||||
add_transaction_button = customtkinter.CTkButton(button_frame, text="Add Transaction", command=add_transaction)
|
||||
add_transaction_button.grid(row=0, column=0, padx=10)
|
||||
request_otp_button = customtkinter.CTkButton(button_frame, text="Request OTP", command=request_otp)
|
||||
request_otp_button.grid(row=0, column=1, padx=10)
|
||||
edit_account_details_button = customtkinter.CTkButton(button_frame, text="Edit Account Details", command=edit_account_details)
|
||||
edit_account_details_button.grid(row=0, column=2, padx=10)
|
||||
|
||||
# Create the transactions table
|
||||
transactions_table = ttk.Treeview(table_frame, columns=("Transaction ID", "Transaction Type", "Amount", "Timestamp", "Description", "Account ID", "Recipient Account ID"), show="headings")
|
||||
transactions_table.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
@@ -8,6 +8,6 @@ dark_theme = dark
|
||||
theme = dark-blue
|
||||
|
||||
[client]
|
||||
default_id = 31d90aad
|
||||
default_id = d18e5ae0
|
||||
default_password = Happymeal1
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import requests
|
||||
from requests.models import Response
|
||||
from config import CONFIG
|
||||
import json
|
||||
from tkinter import messagebox
|
||||
|
||||
##############
|
||||
### System ###
|
||||
@@ -65,9 +66,14 @@ def update_client(client_id, otp_code, email=None, phone_number=None, address=No
|
||||
params['phone_number'] = phone_number
|
||||
if address is not None:
|
||||
params['address'] = address
|
||||
response = requests.put(CONFIG["server"]["url"] + "/Client", cookies=session_data['session_cookie'], params=params)
|
||||
response = requests.post(CONFIG["server"]["url"] + "/Client", cookies=session_data['session_cookie'], params=params)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if response.status_code == 400:
|
||||
return {'success': False, 'message': "Invalid OTP."}
|
||||
print(f"HTTPError: {e}")
|
||||
return {'success': False, 'message': "Could not connect to the server. Please try again later."}
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"RequestException: {e}")
|
||||
return {'success': False, 'message': "Could not connect to the server. Please try again later."}
|
||||
@@ -153,10 +159,12 @@ def generate_otp():
|
||||
try:
|
||||
with open('application\\session_data.json', 'r') as f:
|
||||
session_data = json.load(f)
|
||||
client_id = session_data['client_id']
|
||||
response = requests.post(CONFIG["server"]["url"] + "/OTP/Generate", cookies=session_data['session_cookie'], params={'client_id': client_id})
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
client_id = session_data['client_id']
|
||||
response = requests.post(f"{CONFIG['server']['url']}/OTP/Generate", cookies=session_data['session_cookie'], params={'client_id': client_id})
|
||||
if response.status_code == 200:
|
||||
messagebox.showinfo("OTP", "OTP has been sent to your email.")
|
||||
else:
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"RequestException: {e}")
|
||||
return {'success': False, 'message': "Could not connect to the server. Please try again later."}
|
||||
messagebox.showerror("Error", f"Could not generate OTP: {e}")
|
||||
@@ -5,6 +5,7 @@ import os
|
||||
from config import CONFIG
|
||||
from connection import logout_client, get_client, update_client, get_accounts, format_balance, generate_otp
|
||||
|
||||
|
||||
# Global variables
|
||||
email_entry = None
|
||||
phone_entry = None
|
||||
@@ -31,6 +32,16 @@ def logout():
|
||||
else:
|
||||
messagebox.showerror("Logout failed", json_response['message'])
|
||||
|
||||
def exit_application():
|
||||
"""Logs out the client and exits the application."""
|
||||
response = logout_client()
|
||||
json_response = response.json()
|
||||
if json_response['success']:
|
||||
messagebox.showinfo("Logout", "You have been logged out.")
|
||||
root.quit()
|
||||
else:
|
||||
messagebox.showerror("Logout failed", json_response['message'])
|
||||
|
||||
def display_client_info():
|
||||
"""Displays the client's information on the dashboard."""
|
||||
global frame
|
||||
@@ -70,7 +81,7 @@ def edit_details():
|
||||
global edit_window, email_entry, phone_entry, address_entry, otp_entry
|
||||
edit_window = customtkinter.CTkToplevel(root)
|
||||
edit_window.title("Edit Details")
|
||||
edit_window.geometry("300x300")
|
||||
edit_window.geometry("300x350")
|
||||
edit_window.iconbitmap("application/luxbank.ico")
|
||||
edit_window.attributes('-topmost', True)
|
||||
|
||||
@@ -89,16 +100,17 @@ def edit_details():
|
||||
address_label.pack()
|
||||
address_entry.pack()
|
||||
|
||||
# Add MFA verify button and text box
|
||||
mfa_button = customtkinter.CTkButton(edit_window, text="Get OTP Code", command=generate_otp)
|
||||
mfa_button.pack()
|
||||
customtkinter.CTkLabel(edit_window, text=" ").pack() # Add space under the address box
|
||||
|
||||
mfa_label = customtkinter.CTkLabel(edit_window, text="OTP Code: ")
|
||||
otp_button = customtkinter.CTkButton(edit_window, text="Get OTP Code", command=generate_otp)
|
||||
otp_button.pack()
|
||||
|
||||
otp_label = customtkinter.CTkLabel(edit_window, text="OTP Code: ")
|
||||
otp_entry = customtkinter.CTkEntry(edit_window)
|
||||
mfa_label.pack()
|
||||
otp_label.pack()
|
||||
otp_entry.pack()
|
||||
|
||||
save_button = customtkinter.CTkButton(edit_window, text="Verify MFA and Save", command=save_details)
|
||||
save_button = customtkinter.CTkButton(edit_window, text="Verify OTP and Save", command=save_details)
|
||||
save_button.pack()
|
||||
edit_window.lift()
|
||||
|
||||
@@ -109,18 +121,33 @@ def save_details():
|
||||
new_phone = phone_entry.get() if phone_entry.get() != '' else None
|
||||
new_address = address_entry.get() if address_entry.get() != '' else None
|
||||
otp_code = otp_entry.get()
|
||||
|
||||
if not otp_code:
|
||||
messagebox.showerror("Error", "OTP code must be entered.")
|
||||
return
|
||||
|
||||
with open('application\\session_data.json', 'r') as f:
|
||||
session_data = json.load(f)
|
||||
client_id = session_data['client_id']
|
||||
|
||||
if not messagebox.askyesno("Confirmation", "Are you sure you want to update the details?"):
|
||||
return
|
||||
result = update_client(client_id, otp_code, new_email, new_phone, new_address)
|
||||
if result['success']:
|
||||
display_client_info()
|
||||
else:
|
||||
messagebox.showerror("Update Failed", result.get('message', 'Unknown error'))
|
||||
edit_window.destroy()
|
||||
|
||||
|
||||
try:
|
||||
result = update_client(client_id, otp_code, new_email, new_phone, new_address)
|
||||
if result['success']:
|
||||
display_client_info()
|
||||
messagebox.showinfo("Success", "Details updated successfully.")
|
||||
edit_window.destroy()
|
||||
else:
|
||||
if result['message'] == "Invalid OTP.":
|
||||
messagebox.showerror("Error", "MFA details not correct. Please try again.")
|
||||
else:
|
||||
messagebox.showerror("Update Failed", result.get('message', 'Unknown error'))
|
||||
except Exception as e:
|
||||
messagebox.showerror("Error", f"An error occurred: {e}")
|
||||
|
||||
|
||||
def populate_table():
|
||||
"""Populates the accounts table with client accounts."""
|
||||
try:
|
||||
@@ -169,13 +196,21 @@ welcome_label.pack(pady=20)
|
||||
|
||||
display_client_info()
|
||||
|
||||
# Create a logout button
|
||||
logout_button = customtkinter.CTkButton(root, text="Logout", command=logout)
|
||||
logout_button.pack(pady=15)
|
||||
# Create a frame for buttons
|
||||
button_frame = customtkinter.CTkFrame(root)
|
||||
button_frame.pack(pady=15, side='top')
|
||||
|
||||
# Create the MFA button
|
||||
mfa_button = customtkinter.CTkButton(root, text="MFA", command=generate_otp)
|
||||
mfa_button.pack(pady=15, side='left')
|
||||
# Create the OTP button
|
||||
otp_button = customtkinter.CTkButton(button_frame, text="Get OTP Code", command=generate_otp)
|
||||
otp_button.pack(side='left', padx=5)
|
||||
|
||||
# Create the logout button
|
||||
logout_button = customtkinter.CTkButton(button_frame, text="Logout", command=logout)
|
||||
logout_button.pack(side='left', padx=5)
|
||||
|
||||
# Create the exit button
|
||||
exit_button = customtkinter.CTkButton(button_frame, text="Exit", command=exit_application)
|
||||
exit_button.pack(side='left', padx=5)
|
||||
|
||||
# Create a frame for the table
|
||||
table_frame = ttk.Frame(root)
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"session_cookie": {"session": "mMTYW-c_n0BE-l7MENT8A1h2Rg4UUrNRJYl7NvXTcS4"}, "client_id": "31d90aad"}
|
||||
{"session_cookie": {"session": "CjjpiVUxx009emp27lUSxMpJ4Dt1sUi3fV-_VILXFrw"}, "client_id": "d18e5ae0"}
|
||||
Reference in New Issue
Block a user