From f00271eb75d8bfb4c701c038017fdf60b1ab2f06 Mon Sep 17 00:00:00 2001 From: francoisdillinger <elmojester@gmail.com> Date: Sun, 16 Apr 2023 21:46:22 -0500 Subject: [PATCH] Folder Restructuring and API foundation. --- __pycache__/.DS_Store | Bin 6148 -> 0 bytes __pycache__/CS_499_backend.cpython-311.pyc | Bin 18926 -> 0 bytes __pycache__/app.cpython-311.pyc | Bin 707 -> 0 bytes backend/.gitignore | 2 + backend/__init__.py | 0 backend/api/__init__.py | 25 ++ backend/api/requirements.txt | 1 + backend/api/routes/costData.py | 18 + backend/api/routes/powerData.py | 17 + backend/api/routes/tempData.py | 17 + backend/api/routes/waterData.py | 17 + backend/app.py | 9 + .../database/CS_499_backend.py | 80 ++--- backend/database/CS_499_create_db.py | 234 ++++++++++++ backend/database/__init__.py | 0 backend/database/db_connection.py | 15 + backend/database/requirements.txt | 4 + backend/requirements.txt | 8 + costData.py | 12 - frontend/public/weatherIcons/01d.svg | 1 + frontend/public/weatherIcons/01n.svg | 1 + frontend/public/weatherIcons/02d.svg | 1 + frontend/public/weatherIcons/02n.svg | 1 + frontend/public/weatherIcons/03d.svg | 1 + frontend/public/weatherIcons/03n.svg | 1 + frontend/public/weatherIcons/04d.svg | 1 + frontend/public/weatherIcons/04n.svg | 1 + frontend/public/weatherIcons/09d.svg | 1 + frontend/public/weatherIcons/09n.svg | 1 + frontend/public/weatherIcons/10d.svg | 1 + frontend/public/weatherIcons/10n.svg | 1 + frontend/public/weatherIcons/11d.svg | 1 + frontend/public/weatherIcons/11n.svg | 1 + frontend/public/weatherIcons/13d.svg | 1 + frontend/public/weatherIcons/13n.svg | 1 + frontend/public/weatherIcons/50d.svg | 1 + frontend/public/weatherIcons/50n.svg | 1 + frontend/src/App.js | 8 +- frontend/src/DesiredTemp.js | 2 +- frontend/src/costsCollection.js | 4 +- frontend/src/forecastCollection.js | 59 +++ frontend/src/index.css | 22 +- frontend/src/tempsCollection.js | 31 +- other/CS499_database2.py | 340 ++++++++++++++++++ .../CS_499_Webframe.fig | Bin .../CS_499_database.py | 0 .../Pseudo_Code_CS_499__2_.docx | Bin app.py => other/app.py | 2 +- .../erd499_finalized__1_.drawio.pdf | Bin main.py => other/main.py | 0 powerData.py | 12 - tempData.py | 12 - waterData.py | 12 - 53 files changed, 882 insertions(+), 99 deletions(-) delete mode 100644 __pycache__/.DS_Store delete mode 100644 __pycache__/CS_499_backend.cpython-311.pyc delete mode 100644 __pycache__/app.cpython-311.pyc create mode 100644 backend/.gitignore create mode 100644 backend/__init__.py create mode 100644 backend/api/__init__.py create mode 100644 backend/api/requirements.txt create mode 100644 backend/api/routes/costData.py create mode 100644 backend/api/routes/powerData.py create mode 100644 backend/api/routes/tempData.py create mode 100644 backend/api/routes/waterData.py create mode 100644 backend/app.py rename CS_499_backend.py => backend/database/CS_499_backend.py (81%) create mode 100644 backend/database/CS_499_create_db.py create mode 100644 backend/database/__init__.py create mode 100644 backend/database/db_connection.py create mode 100644 backend/database/requirements.txt create mode 100644 backend/requirements.txt delete mode 100644 costData.py create mode 100644 frontend/public/weatherIcons/01d.svg create mode 100644 frontend/public/weatherIcons/01n.svg create mode 100644 frontend/public/weatherIcons/02d.svg create mode 100644 frontend/public/weatherIcons/02n.svg create mode 100644 frontend/public/weatherIcons/03d.svg create mode 100644 frontend/public/weatherIcons/03n.svg create mode 100644 frontend/public/weatherIcons/04d.svg create mode 100644 frontend/public/weatherIcons/04n.svg create mode 100644 frontend/public/weatherIcons/09d.svg create mode 100644 frontend/public/weatherIcons/09n.svg create mode 100644 frontend/public/weatherIcons/10d.svg create mode 100644 frontend/public/weatherIcons/10n.svg create mode 100644 frontend/public/weatherIcons/11d.svg create mode 100644 frontend/public/weatherIcons/11n.svg create mode 100644 frontend/public/weatherIcons/13d.svg create mode 100644 frontend/public/weatherIcons/13n.svg create mode 100644 frontend/public/weatherIcons/50d.svg create mode 100644 frontend/public/weatherIcons/50n.svg create mode 100644 frontend/src/forecastCollection.js create mode 100644 other/CS499_database2.py rename CS_499_Webframe.fig => other/CS_499_Webframe.fig (100%) rename CS_499_database.py => other/CS_499_database.py (100%) rename Pseudo_Code_CS_499__2_.docx => other/Pseudo_Code_CS_499__2_.docx (100%) rename app.py => other/app.py (83%) rename erd499_finalized__1_.drawio.pdf => other/erd499_finalized__1_.drawio.pdf (100%) rename main.py => other/main.py (100%) delete mode 100644 powerData.py delete mode 100644 tempData.py delete mode 100644 waterData.py diff --git a/__pycache__/.DS_Store b/__pycache__/.DS_Store deleted file mode 100644 index ebc5a4b675bbcc66f8906eb255b434dbdc7be046..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%Sr?>5Ul7P7Q8G7;xRwqz_LFOmi6G-AJ82I4~w(-0&jEoWBf#|>W<>*Ts$Zu z-9x%MopdKDm^=Wa<^9DRm;sow2$PHvk$bdhr*;-5%h6(sN8I5G-AJOp=+fNxan5;f z(ct6!uW^J0=KLC4ReQ4O+V!SeGeUGdvotRzw15NL;u1G_F#WAu>FHB0OBgB`2nK?I zU?3Ry5e9f>OQw5{p@V^7AQ*UOK>I^x5tfR*qir2jx<0FYB9ze9<ye?2mWsV2TPVpx zi5{Bj6C-&z{kirl6?;byN3xNbr;hygcu6)o{n@%B701xQKrk?5VArcNo&U%DWkw(Q z!;q*21Hr&QV<1gdr>i9wRnOKh%hOq#S<YA_>etJl&>ma@SkXRmXpP>UWwT$Y*gGnV S{1#4(i+~XlDj4_$23`Ru^e@2x diff --git a/__pycache__/CS_499_backend.cpython-311.pyc b/__pycache__/CS_499_backend.cpython-311.pyc deleted file mode 100644 index 6e24384d334f3233bef3084999ebbd2c80db25cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18926 zcmeG@TToj^mRAozFP;+bhXux9Y=c2ygY7sr24igA2!kzSD}vjAFi2Puc8rOmWIS0p z!_0_;B+8UOR6DyFQrQoG%!fZxQ~8*!%E#{1y<7J~bw9SewNqQm&V1lXs&;n1_ME<Y zUdhDCOlB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ey`d4@C+wpcn3k1fT%# z2=ZI}mm)PSTusaNYfo%^O}|jn?;i|S^6Kh{IzL$W#;||DKd@WC6qmqlUZk{)V@e{X z;>`8044+!XDLj9lN(r7dv5;|+*PP@uH8{)Bz;&G09EXdy3_;*)G|He)BX9nPs8#o5 zNa&CAOqalPaZFdj^k0aUDWOk09YB)*0yNkg8W+Z6g&RXJK%fAWMwDH_Rkm<P&+?UL zx$beka-3(Z0%PSE>kIPBxbh=h^UHks%iNh!zI>Et#sp@JW5%NGE4eBQ*M6R_I?wf8 s;j6Cj%vFK8$}v}8kYCPKv~q1dd_@n}JIPl}^30ULOmVS)^q2qt2V3r{@Bjb+ diff --git a/__pycache__/app.cpython-311.pyc b/__pycache__/app.cpython-311.pyc deleted file mode 100644 index a1206b53895b002e4e92bbb27c613f3b18b36a4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 707 zcmZuu&ubGw6rQ&;yPM{R2v&3jp|n)Vq3%I@2#6r4(Mu7k2)Qh4W=v!EN0><j3&L6o z?XefJM^6#4NB@wm^bqD^!IQU0Z#ns9+mtFk=Dm6E@xAYTJNvm-D-*O!vkm?O@1Lfa z8aqvnzhUx`aKa%XF|+_oZbep1TQp`Z2E-x)hKTw)oh2<>*q@xU@?63xXC2tLhZf?| zPmDWT<R1oCl(@TIAmmkKo0($I-@LRxGX!KpKQUBSUM;*{`DI#l(B-xiVP6DcuUEIU z{U{36x^|UNs+%Sg@HK5de1<qT7X7u9tM(~ZaTx^^{n$Jez5{Tp3#+6~R}5aMup>4q zk3|%vb1zaE@h?PH3>=+I7X0T*NaZ7MnD}kAbf?i+io<T=-+%hVM?JTCZ?(N<rsV}3 zu+dcwLq?9Omv`UgmBpMb$|`nrDG1DD5E!X87cU2$m3mn_xZsVD(rDE7EAwsA{5xs5 zG{qg-mg%4`iUo!x31blin#w^^NG<54**YoRjZ;2|#65WhOY^Ae1BNjLfDyT#|9wVe zF8|*-axP}C-$z?fMn}N5y-jcD_TKW|&CEN1`9qi=TL3r41jBDitcA0VLs)fZ<2&_o e>W!GY-P~;MKFFE}%sXUWK0RYf*fm5Hvi|@Ra-!q_ diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..dad2b2b --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +.flaskenv \ No newline at end of file diff --git a/backend/__init__.py b/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/api/__init__.py b/backend/api/__init__.py new file mode 100644 index 0000000..0a071a2 --- /dev/null +++ b/backend/api/__init__.py @@ -0,0 +1,25 @@ +from flask import Flask + +# from database.db_connection import get_db_connection + + +def create_app(): + app = Flask(__name__) + + from api.routes.tempData import tempData_bp + from api.routes.powerData import powerData_bp + from api.routes.waterData import waterData_bp + from api.routes.costData import costData_bp + + app.register_blueprint(tempData_bp, url_prefix='/api') + app.register_blueprint(powerData_bp, url_prefix='/api') + app.register_blueprint(waterData_bp, url_prefix='/api') + app.register_blueprint(costData_bp, url_prefix='/api') + + # The following only needs to be run once to create the database. DO NOT UNCOMMENT!!! + + # with app.app_context(): + # from database.CS_499_create_db import create_and_seed_db + # create_and_seed_db() + + return app \ No newline at end of file diff --git a/backend/api/requirements.txt b/backend/api/requirements.txt new file mode 100644 index 0000000..fb0dec5 --- /dev/null +++ b/backend/api/requirements.txt @@ -0,0 +1 @@ +Flask==2.0.3 \ No newline at end of file diff --git a/backend/api/routes/costData.py b/backend/api/routes/costData.py new file mode 100644 index 0000000..35065ae --- /dev/null +++ b/backend/api/routes/costData.py @@ -0,0 +1,18 @@ +from flask import request, Blueprint, jsonify +from database.db_connection import get_db_connection + +costData_bp = Blueprint('costData', __name__) + +@costData_bp.route('/costData', methods = ['GET']) +def get_costData(): + all_costData = get_data() + return jsonify(all_costData) + + +def get_data(): + conn = get_db_connection() + cur = conn.cursor() + cur.execute('SELECT * FROM total_cost_watts;') + all_costData = cur.fetchall() + cur.close() + return all_costData \ No newline at end of file diff --git a/backend/api/routes/powerData.py b/backend/api/routes/powerData.py new file mode 100644 index 0000000..cb68aa1 --- /dev/null +++ b/backend/api/routes/powerData.py @@ -0,0 +1,17 @@ +from flask import request, Blueprint, jsonify +from database.db_connection import get_db_connection + +powerData_bp = Blueprint('powerData', __name__) + +@powerData_bp.route('/powerData', methods = ['GET']) +def get_powerData(): + all_powerData = get_data() + return jsonify(all_powerData) + +def get_data(): + conn = get_db_connection() + cur = conn.cursor() + cur.execute('SELECT * FROM power_testcases;') + all_powerData = cur.fetchall() + cur.close() + return all_powerData \ No newline at end of file diff --git a/backend/api/routes/tempData.py b/backend/api/routes/tempData.py new file mode 100644 index 0000000..fe9b68f --- /dev/null +++ b/backend/api/routes/tempData.py @@ -0,0 +1,17 @@ +from flask import request, Blueprint, jsonify +from database.db_connection import get_db_connection + +tempData_bp = Blueprint('tempData', __name__) + +@tempData_bp.route('/tempData', methods = ['GET']) +def get_temperatureData(): + all_tempData = get_data() + return jsonify(all_tempData) + +def get_data(): + conn = get_db_connection() + cur = conn.cursor() + cur.execute('SELECT * FROM temperature_data;') + all_tempData = cur.fetchall() + cur.close() + return all_tempData \ No newline at end of file diff --git a/backend/api/routes/waterData.py b/backend/api/routes/waterData.py new file mode 100644 index 0000000..a7ca8b0 --- /dev/null +++ b/backend/api/routes/waterData.py @@ -0,0 +1,17 @@ +from flask import request, Blueprint, jsonify +from database.db_connection import get_db_connection + +waterData_bp = Blueprint('waterData', __name__) + +@waterData_bp.route('/waterData', methods = ['GET']) +def get_waterData(): + all_waterData = get_data() + return jsonify(all_waterData) + +def get_data(): + conn = get_db_connection() + cur = conn.cursor() + cur.execute('SELECT * FROM appliance_with_water') + all_waterData = cur.fetchall() + cur.close() + return all_waterData \ No newline at end of file diff --git a/backend/app.py b/backend/app.py new file mode 100644 index 0000000..85711ff --- /dev/null +++ b/backend/app.py @@ -0,0 +1,9 @@ +from api import create_app +app = create_app() + +@app.route('/', methods=['GET']) +def hello(): + return {'message': 'Hello, world!'} + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/CS_499_backend.py b/backend/database/CS_499_backend.py similarity index 81% rename from CS_499_backend.py rename to backend/database/CS_499_backend.py index e23b21e..bc27be8 100644 --- a/CS_499_backend.py +++ b/backend/database/CS_499_backend.py @@ -37,8 +37,8 @@ for i in range(0,NUM_WEEKS): Door_Window_History[time_stamp] = Door_Window(WORKWEEK[j], door_opens, door_minutes, window_open, window_minutes) time_stamp += 1 -for i in Door_Window_History: - print(i, Door_Window_History[i].day, Door_Window_History[i].Door_status, Door_Window_History[i].Door_time, Door_Window_History[i].Window_status, Door_Window_History[i].Window_time) +# for i in Door_Window_History: +# print(i, Door_Window_History[i].day, Door_Window_History[i].Door_status, Door_Window_History[i].Door_time, Door_Window_History[i].Window_status, Door_Window_History[i].Window_time) class Appliance_1: @@ -106,7 +106,7 @@ monthly_power1_FEB=0 monthly_cost1_MAR=0 monthly_power1_MAR=0 -print("###################################################### TOTAL APP1 HISTORY FOR 77 DAYS ###################################################### \n") +# print("###################################################### TOTAL APP1 HISTORY FOR 77 DAYS ###################################################### \n") for i in App1_History: if i<=31: monthly_power1_JAN += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr @@ -118,14 +118,14 @@ for i in App1_History: monthly_power1_MAR += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr monthly_cost1_MAR += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct #print(i,App1_History[i].day,App1_History[i].micro_pwr,App1_History[i].stove_pwr,App1_History[i].oven_pwr,App1_History[i].Lrtv_pwr,App1_History[i].Brtv_pwr,App1_History[i].micro_ct,App1_History[i].stove_ct,App1_History[i].oven_ct,App1_History[i].Lrtv_ct,App1_History[i].Brtv_ct) -print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") -print( "Jan APP1 watts used : ",monthly_power1_JAN ) -print( "FEB APP1 watts used : ",monthly_power1_FEB ) -print( "MAR APP1 watts used : ",monthly_power1_MAR ) -print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") -print( "Jan APP1 cost used : ",monthly_cost1_JAN ) -print( "FEB APP1 cost used : ",monthly_cost1_FEB ) -print( "MAR APP1 cost used : ",monthly_cost1_MAR ) +# print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") +# print( "Jan APP1 watts used : ",monthly_power1_JAN ) +# print( "FEB APP1 watts used : ",monthly_power1_FEB ) +# print( "MAR APP1 watts used : ",monthly_power1_MAR ) +# print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") +# print( "Jan APP1 cost used : ",monthly_cost1_JAN ) +# print( "FEB APP1 cost used : ",monthly_cost1_FEB ) +# print( "MAR APP1 cost used : ",monthly_cost1_MAR ) #print("################################################################################################################################################################# \n") @@ -212,7 +212,7 @@ monthly_water_usg_FEB=0 monthly_cost2_MAR=0 monthly_power2_MAR=0 monthly_water_usg_MAR=0 -print("###################################################### TOTAL APP2 HISTORY FOR 77 DAYS ###################################################### \n") +# print("###################################################### TOTAL APP2 HISTORY FOR 77 DAYS ###################################################### \n") for i in App2_History: if i>=31: monthly_cost2_JAN+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct +App2_History[i].Water_ct + App2_History[i].bath_fans_ct @@ -227,18 +227,18 @@ for i in App2_History: monthly_power2_MAR+= App2_History[i].Water_Heat_pwr+ App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr monthly_water_usg_MAR+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug #print(i,App2_History[i].day,App2_History[i].Water_Heat_pwr,App2_History[i].DishWasher_pwr,App2_History[i].Clothes_Wash_pwr,App2_History[i].Clothes_dry_pwr,App2_History[i].bath_fans_pwr,App2_History[i].Water_Heat_ug,App2_History[i].Bath_water_ug,App2_History[i].Shower_water_ug,App2_History[i].DishWasher_ug,App2_History[i].Clothes_Wash_ug,App2_History[i].Water_Heat_ct,App2_History[i].DishWasher_ct,App2_History[i].Clothes_Wash_ct,App2_History[i].Clothes_dry_ct,App2_History[i].bath_fans_ct,App2_History[i].Water_ct,App2_History[i].bath,App2_History[i].shower) -print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 watts used : ",monthly_power2_JAN ) -print( "FEB APP2 watts used : ",monthly_power2_FEB ) -print( "MAR APP2 watts used : ",monthly_power2_MAR ) -print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 cost used : ",monthly_cost2_JAN ) -print( "FEB APP2 cost used : ",monthly_cost2_FEB ) -print( "MAR APP2 cost used : ",monthly_cost2_MAR ) -print( "_ - _ - _ - _ Gallons used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 water used : ",monthly_water_usg_JAN ) -print( "FEB APP2 water used : ",monthly_water_usg_FEB ) -print( "MAR APP2 water used : ",monthly_water_usg_MAR ) +# print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") +# print( "Jan APP2 watts used : ",monthly_power2_JAN ) +# print( "FEB APP2 watts used : ",monthly_power2_FEB ) +# print( "MAR APP2 watts used : ",monthly_power2_MAR ) +# print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") +# print( "Jan APP2 cost used : ",monthly_cost2_JAN ) +# print( "FEB APP2 cost used : ",monthly_cost2_FEB ) +# print( "MAR APP2 cost used : ",monthly_cost2_MAR ) +# print( "_ - _ - _ - _ Gallons used for each Month _ - _ - _ - _ \n") +# print( "Jan APP2 water used : ",monthly_water_usg_JAN ) +# print( "FEB APP2 water used : ",monthly_water_usg_FEB ) +# print( "MAR APP2 water used : ",monthly_water_usg_MAR ) #print( "################################################################################################################################################################# \n") @@ -299,7 +299,7 @@ monthly_temp_ct_FEB=0 monthly_temp_watts_FEB=0 monthly_temp_ct_MAR=0 monthly_temp_watts_MAR=0 -print("###################################################### TOTAL TEMP HISTORY FOR 77 DAYS ###################################################### \n") +# print("###################################################### TOTAL TEMP HISTORY FOR 77 DAYS ###################################################### \n") for i in App3_History: if i<=31: monthly_temp_watts_JAN+=App3_History[i].temp_power @@ -310,21 +310,21 @@ for i in App3_History: if i>59: monthly_temp_ct_MAR+=App3_History[i].temp_cost monthly_temp_watts_MAR+=App3_History[i].temp_power -print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") -print( "Jan APP3 watts used : ",monthly_temp_watts_JAN ) -print( "FEB APP3 watts used : ",monthly_temp_watts_FEB ) -print( "MAR APP3 watts used : ",monthly_temp_watts_MAR ) -print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") -print( "Jan APP3 cost used : ",monthly_temp_ct_JAN ) -print( "FEB APP3 cost used : ",monthly_temp_ct_FEB ) -print( "MAR APP3 cost used : ",monthly_temp_ct_MAR ) -print( "################################################################################################################################################################# \n") -print("January Total cost",monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN) -print("Febuary Total cost",monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB) -print("March Total cost",monthly_temp_ct_MAR+monthly_cost2_FEB+monthly_cost1_MAR) -print("January Total Watts",monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN) -print("Febuary Total Watts",monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB) -print("March Total Watts",monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR) +# print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") +# print( "Jan APP3 watts used : ",monthly_temp_watts_JAN ) +# print( "FEB APP3 watts used : ",monthly_temp_watts_FEB ) +# print( "MAR APP3 watts used : ",monthly_temp_watts_MAR ) +# print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") +# print( "Jan APP3 cost used : ",monthly_temp_ct_JAN ) +# print( "FEB APP3 cost used : ",monthly_temp_ct_FEB ) +# print( "MAR APP3 cost used : ",monthly_temp_ct_MAR ) +# print( "################################################################################################################################################################# \n") +# print("January Total cost",monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN) +# print("Febuary Total cost",monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB) +# print("March Total cost",monthly_temp_ct_MAR+monthly_cost2_FEB+monthly_cost1_MAR) +# print("January Total Watts",monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN) +# print("Febuary Total Watts",monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB) +# print("March Total Watts",monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR) diff --git a/backend/database/CS_499_create_db.py b/backend/database/CS_499_create_db.py new file mode 100644 index 0000000..66b74ec --- /dev/null +++ b/backend/database/CS_499_create_db.py @@ -0,0 +1,234 @@ + +# import CS_499_backend +from .CS_499_backend import Door_Window, Appliance_1, Appliance_with_Water, Temperature_data, Door_Window_History, App1_History, App2_History, App3_History, time_stamp, time_stamp2, time_stamp3, time_stamp4, monthly_cost1_FEB, monthly_cost1_MAR, monthly_cost1_JAN, monthly_power1_JAN, monthly_power1_FEB, monthly_power1_MAR, monthly_cost2_FEB, monthly_cost2_JAN, monthly_cost2_MAR, monthly_water_usg_MAR, monthly_water_usg_JAN, monthly_water_usg_FEB, monthly_power2_FEB, monthly_power2_JAN, monthly_power2_MAR, monthly_temp_watts_JAN, monthly_temp_watts_FEB, monthly_temp_watts_MAR, monthly_temp_ct_JAN, monthly_temp_ct_FEB, monthly_temp_ct_MAR +from .db_connection import get_db_connection + +def create_and_seed_db(): + conn = get_db_connection() + cur = conn.cursor() + + print("\033[33mCreating and seeding database...\033[33m") + + + # create a new table for Door_Window_History + print("\033[33mCreating table for Door_Window_History...\033[33m") + + cur.execute(""" + DROP TABLE IF EXISTS Door_Window_History; + CREATE TABLE Door_Window_History ( + id SERIAL PRIMARY KEY, + day VARCHAR(255), + door_status INTEGER, + door_time FLOAT, + window_status INTEGER, + window_time FLOAT + ); + """) + + conn.commit() + print("\033[32mDoor_Window_History table created successfully in PostgreSQL\033[32m") + + + #insert the data into the Door_Window_History table + for i in Door_Window_History: + print(" \033[34mInserting data into Door_Window_History table... \033[34m") + for time_stamp, data in Door_Window_History.items(): + cur.execute(""" + INSERT INTO Door_Window_History ( + day, door_status, door_time, window_status, window_time) + VALUES (%s, %s, %s, %s, %s); + """, ( + data.day, data.Door_status, data.Door_time, + data.Window_status, data.Window_time + )) + conn.commit() + + # create a new table for App1_History + print("\033[33mCreating table for App1_History...\033[33m") + cur.execute(""" + DROP TABLE IF EXISTS Appliance_1_History; + CREATE TABLE Appliance_1_History ( + id SERIAL PRIMARY KEY, + day VARCHAR(255), + micro_pwr FLOAT, + stove_pwr FLOAT, + oven_pwr FLOAT, + Lrtv_pwr FLOAT, + Brtv_pwr FLOAT, + fridge_pwr FLOAT, + micro_ct FLOAT, + stove_ct FLOAT, + oven_ct FLOAT, + Lrtv_ct FLOAT, + Brtv_ct FLOAT, + fridge_ct FLOAT, + lights_pwr FLOAT, + lights_ct FLOAT + ); + """) + print("\033[32mApp1_History table created successfully in PostgreSQL\033[32m ") + + + for time_stamp2, data in App1_History.items(): + print(" \033[34mInserting data into Appliance_1_History table... \033[34m") + cur.execute(""" + INSERT INTO Appliance_1_History ( + day, micro_pwr, stove_pwr, oven_pwr, Lrtv_pwr, Brtv_pwr, fridge_pwr, + micro_ct, stove_ct, oven_ct, Lrtv_ct, Brtv_ct, fridge_ct, lights_pwr, lights_ct) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); + """, ( + data.day, data.micro_pwr, data.stove_pwr, data.oven_pwr, data.Lrtv_pwr, data.Brtv_pwr, + data.fridge_pwr, data.micro_ct, data.stove_ct, data.oven_ct, data.Lrtv_ct, data.Brtv_ct, + data.fridge_ct, data.lights_pwr, data.lights_ct + )) + conn.commit() + + + + # create a new table for appliance_with_water + print("\033[33mCreating table for appliance_with_water...\033[33m") + cur.execute(""" + DROP TABLE IF EXISTS appliance_with_water; + CREATE TABLE appliance_with_water ( + id SERIAL PRIMARY KEY, + day TEXT, + water_heat_pwr FLOAT, + dishwasher_pwr FLOAT, + clothes_wash_pwr FLOAT, + clothes_dry_pwr FLOAT, + bath_fans_pwr FLOAT, + water_heat_ug FLOAT, + bath_water_ug FLOAT, + shower_water_ug FLOAT, + dishwasher_ug FLOAT, + clothes_wash_ug FLOAT, + water_heat_ct FLOAT, + dishwasher_ct FLOAT, + clothes_wash_ct FLOAT, + clothes_dry_ct FLOAT, + bath_fans_ct FLOAT, + water_ct FLOAT, + bath INT, + shower INT + ); + """) + conn.commit() + print("\033[32mappliance_with_water table created successfully in PostgreSQL\033[32m ") + + + # insert data into the App2_History table + for time_stamp3, data in App2_History.items(): + print(" \033[34mInserting data into appliance_with_water table... \033[34m") + cur.execute(""" + INSERT INTO appliance_with_water ( + day, water_heat_pwr, dishwasher_pwr, clothes_wash_pwr, + clothes_dry_pwr, bath_fans_pwr, water_heat_ug, bath_water_ug, + shower_water_ug, dishwasher_ug, clothes_wash_ug, water_heat_ct, + dishwasher_ct, clothes_wash_ct, clothes_dry_ct, bath_fans_ct, + water_ct, bath, shower + ) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); + """, ( + data.day, data.Water_Heat_pwr, data.DishWasher_pwr, data.Clothes_Wash_pwr, + data.Clothes_dry_pwr, data.bath_fans_pwr, data.Water_Heat_ug, data.Bath_water_ug, + data.Shower_water_ug, data.DishWasher_ug, data.Clothes_Wash_ug, data.Water_Heat_ct, + data.DishWasher_ct, data.Clothes_Wash_ct, data.Clothes_dry_ct, data.bath_fans_ct, + data.Water_ct, data.bath, data.shower + )) + conn.commit() + + # create a new table for Temperature_data + print("\033[33mCreating table for Temperature_data...\033[33m") + cur.execute(""" + DROP TABLE IF EXISTS Temperature_data; + CREATE TABLE Temperature_data ( + id SERIAL PRIMARY KEY, + temp_power FLOAT, + temp_cost FLOAT + ); + """) + conn.commit() + print("\033[32mTemperature_data table created successfully in PostgreSQL\033[32m") + + + # insert data into the App3_History Table + for time_stamp4, data in App3_History.items(): + print(" \033[34mInserting data into Temperature_data table... \033[34m") + cur = conn.cursor() + cur.execute(""" + INSERT INTO temperature_data ( + temp_power, temp_cost + ) + VALUES (%s, %s); + """, ( + data.temp_power, data.temp_cost + )) + conn.commit() + + + + ###################################################################################################################################### + ###################################################################################################################################### + ############################################ TEMPERATURE DATA TABLE WATTS & COST BY MONTH ############################################ + + # create a new table for temp_cost_watts + # conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") + # cur = conn.cursor() + cur.execute(""" + DROP TABLE IF EXISTS temp_cost_watts; + CREATE TABLE temp_cost_watts ( + month TEXT, + watts FLOAT, + cost FLOAT + ) + """) + conn.commit() + + # Insert the monthly power and cost values into the table + cur.execute(""" + INSERT INTO temp_cost_watts (month, watts, cost) + VALUES ('Temperature Data (January):', %s, %s), + ('Temperature Data (February):', %s, %s), + ('Temperature Data (March):', %s, %s) + """, (monthly_temp_watts_JAN, monthly_temp_ct_JAN, + monthly_temp_watts_FEB, monthly_temp_ct_FEB, + monthly_temp_watts_MAR, monthly_temp_ct_MAR)) + + # Commit the changes + conn.commit() + + ###################################################################################################################################### + ###################################################################################################################################### + ###################################################################################################################################### + + # create a new table for total_cost_watts + print("\033[33mCreating table for total_cost_watts...\033[33m") + cur.execute(""" + DROP TABLE IF EXISTS total_cost_watts; + CREATE TABLE total_cost_watts ( + month TEXT, + watts FLOAT, + cost FLOAT + ) + """) + conn.commit() + print("\033[32mtotal_cost_watts table created successfully in PostgreSQL\033[32m") + + + # Insert the monthly power and cost values into the table + cur.execute(""" + INSERT INTO total_cost_watts (month, watts, cost) + VALUES ('January', %s, %s), + ('February', %s, %s), + ('March', %s, %s) + """, (monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN, monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN, + monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB, monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB, + monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR, monthly_temp_ct_MAR+monthly_cost2_MAR+monthly_cost1_MAR)) + + # Commit the changes + conn.commit() + + # Close communication with the database + cur.close() + conn.close() + print("\033[32mDatabase generated successfully\033[32m") diff --git a/backend/database/__init__.py b/backend/database/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/database/db_connection.py b/backend/database/db_connection.py new file mode 100644 index 0000000..d496ba9 --- /dev/null +++ b/backend/database/db_connection.py @@ -0,0 +1,15 @@ +import psycopg2 + +def get_db_connection(): + print('Connecting to the PostgreSQL database...') + conn = psycopg2.connect( + database="Team3DB", + user="Team3", + password="team3", + host="138.26.48.83", + port="5432" + ) + print('Database connection successful') + return conn + + diff --git a/backend/database/requirements.txt b/backend/database/requirements.txt new file mode 100644 index 0000000..5f671b7 --- /dev/null +++ b/backend/database/requirements.txt @@ -0,0 +1,4 @@ +requests==2.26.0 +psycopg2-binary==2.9.1 +# If numpy won't install make sure your python version is < 3.10 +numpy==1.21.2 \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..2cdb95e --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,8 @@ +# These are the required packages to run this project +# As we use more packages this list will be updated +Flask==2.0.3 +psycopg2-binary==2.9.1 +#Flask_SQLAlchemy==2.5.1 + + + \ No newline at end of file diff --git a/costData.py b/costData.py deleted file mode 100644 index 277dac0..0000000 --- a/costData.py +++ /dev/null @@ -1,12 +0,0 @@ -from flask import request, Blueprint, jsonify -import psycopg2 - -costData_bp = Blueprint('costData', __name__) - -@costData_bp.route('/costData', methods = ['GET']) -def get_costData(): - conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") - cur = conn.cursor() - all_costData = cur.execute ('SELECT * FROM total_cost_watts;').fetchall() - - return jsonify(all_costData) \ No newline at end of file diff --git a/frontend/public/weatherIcons/01d.svg b/frontend/public/weatherIcons/01d.svg new file mode 100644 index 0000000..5bd9846 --- /dev/null +++ b/frontend/public/weatherIcons/01d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#f59e0b" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M42.5 32A10.5 10.5 0 1132 21.5 10.5 10.5 0 0142.5 32zM32 15.71V9.5m0 45v-6.21m11.52-27.81l4.39-4.39M16.09 47.91l4.39-4.39m0-23l-4.39-4.39m31.82 31.78l-4.39-4.39M15.71 32H9.5m45 0h-6.21"/><animateTransform attributeName="transform" dur="45s" from="0 32 32" repeatCount="indefinite" to="360 32 32" type="rotate"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/01n.svg b/frontend/public/weatherIcons/01n.svg new file mode 100644 index 0000000..529e18a --- /dev/null +++ b/frontend/public/weatherIcons/01n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#72b9d5" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M46.66 36.2a16.66 16.66 0 01-16.78-16.55 16.29 16.29 0 01.55-4.15A16.56 16.56 0 1048.5 36.1c-.61.06-1.22.1-1.84.1z"/><animateTransform attributeName="transform" dur="10s" repeatCount="indefinite" type="rotate" values="-5 32 32;15 32 32;-5 32 32"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/02d.svg b/frontend/public/weatherIcons/02d.svg new file mode 100644 index 0000000..dd40d02 --- /dev/null +++ b/frontend/public/weatherIcons/02d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#f59e0b" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M23.5 24a4.5 4.5 0 11-4.5-4.5 4.49 4.49 0 014.5 4.5zM19 15.67V12.5m0 23v-3.17m5.89-14.22l2.24-2.24M10.87 32.13l2.24-2.24m0-11.78l-2.24-2.24m16.26 16.26l-2.24-2.24M7.5 24h3.17m19.83 0h-3.17"/><animateTransform attributeName="transform" dur="45s" from="0 19 24" repeatCount="indefinite" to="360 19 24" type="rotate"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/02n.svg b/frontend/public/weatherIcons/02n.svg new file mode 100644 index 0000000..bdbe5f7 --- /dev/null +++ b/frontend/public/weatherIcons/02n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#72b9d5" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M29.33 26.68a10.61 10.61 0 01-10.68-10.54A10.5 10.5 0 0119 13.5a10.54 10.54 0 1011.5 13.11 11.48 11.48 0 01-1.17.07z"/><animateTransform attributeName="transform" dur="10s" repeatCount="indefinite" type="rotate" values="-10 19.22 24.293;10 19.22 24.293;-10 19.22 24.293"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/03d.svg b/frontend/public/weatherIcons/03d.svg new file mode 100644 index 0000000..41c1848 --- /dev/null +++ b/frontend/public/weatherIcons/03d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/><animateTransform attributeName="transform" dur="7s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/03n.svg b/frontend/public/weatherIcons/03n.svg new file mode 100644 index 0000000..41c1848 --- /dev/null +++ b/frontend/public/weatherIcons/03n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/><animateTransform attributeName="transform" dur="7s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/04d.svg b/frontend/public/weatherIcons/04d.svg new file mode 100644 index 0000000..41c1848 --- /dev/null +++ b/frontend/public/weatherIcons/04d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/><animateTransform attributeName="transform" dur="7s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/04n.svg b/frontend/public/weatherIcons/04n.svg new file mode 100644 index 0000000..41c1848 --- /dev/null +++ b/frontend/public/weatherIcons/04n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linejoin="round" stroke-width="3" d="M46.5 31.5h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0h28a7 7 0 000-14z"/><animateTransform attributeName="transform" dur="7s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/09d.svg b/frontend/public/weatherIcons/09d.svg new file mode 100644 index 0000000..f674ec9 --- /dev/null +++ b/frontend/public/weatherIcons/09d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M24.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M31.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.4s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.4s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M38.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.2s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.2s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/09n.svg b/frontend/public/weatherIcons/09n.svg new file mode 100644 index 0000000..f674ec9 --- /dev/null +++ b/frontend/public/weatherIcons/09n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M24.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M31.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.4s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.4s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M38.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.2s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.2s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/10d.svg b/frontend/public/weatherIcons/10d.svg new file mode 100644 index 0000000..7d3dfa8 --- /dev/null +++ b/frontend/public/weatherIcons/10d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#f59e0b" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M23.5 24a4.5 4.5 0 11-4.5-4.5 4.49 4.49 0 014.5 4.5zM19 15.67V12.5m0 23v-3.17m5.89-14.22l2.24-2.24M10.87 32.13l2.24-2.24m0-11.78l-2.24-2.24m16.26 16.26l-2.24-2.24M7.5 24h3.17m19.83 0h-3.17"/><animateTransform attributeName="transform" dur="45s" from="0 19 24" repeatCount="indefinite" to="360 19 24" type="rotate"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M24.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M31.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.4s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.4s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M38.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.2s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.2s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/10n.svg b/frontend/public/weatherIcons/10n.svg new file mode 100644 index 0000000..2e31ac3 --- /dev/null +++ b/frontend/public/weatherIcons/10n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#72b9d5" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M29.33 26.68a10.61 10.61 0 01-10.68-10.54A10.5 10.5 0 0119 13.5a10.54 10.54 0 1011.5 13.11 11.48 11.48 0 01-1.17.07z"/><animateTransform attributeName="transform" dur="10s" repeatCount="indefinite" type="rotate" values="-10 19.22 24.293;10 19.22 24.293;-10 19.22 24.293"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M24.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M31.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.4s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.4s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g><g><path fill="none" stroke="#2885c7" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M38.39 43.03l-.78 4.94"/><animateTransform attributeName="transform" begin="-0.2s" dur="0.7s" repeatCount="indefinite" type="translate" values="1 -5; -2 10"/><animate attributeName="opacity" begin="-0.2s" dur="0.7s" repeatCount="indefinite" values="0;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/11d.svg b/frontend/public/weatherIcons/11d.svg new file mode 100644 index 0000000..ce9b1f9 --- /dev/null +++ b/frontend/public/weatherIcons/11d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="#f59e0b" d="M30 36l-4 12h4l-2 10 10-14h-6l4-8h-6z"/><animate attributeName="opacity" dur="2s" repeatCount="indefinite" values="1;1;1;1;1;1;0.1;1;0.1;1;1;0.1;1;0.1;1"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/11n.svg b/frontend/public/weatherIcons/11n.svg new file mode 100644 index 0000000..ce9b1f9 --- /dev/null +++ b/frontend/public/weatherIcons/11n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><path fill="#f59e0b" d="M30 36l-4 12h4l-2 10 10-14h-6l4-8h-6z"/><animate attributeName="opacity" dur="2s" repeatCount="indefinite" values="1;1;1;1;1;1;0.1;1;0.1;1;1;0.1;1;0.1;1"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/13d.svg b/frontend/public/weatherIcons/13d.svg new file mode 100644 index 0000000..7a352c4 --- /dev/null +++ b/frontend/public/weatherIcons/13d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#f59e0b" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M23.5 24a4.5 4.5 0 11-4.5-4.5 4.49 4.49 0 014.5 4.5zM19 15.67V12.5m0 23v-3.17m5.89-14.22l2.24-2.24M10.87 32.13l2.24-2.24m0-11.78l-2.24-2.24m16.26 16.26l-2.24-2.24M7.5 24h3.17m19.83 0h-3.17"/><animateTransform attributeName="transform" dur="45s" from="0 19 24" repeatCount="indefinite" to="360 19 24" type="rotate"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><circle cx="31" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M33.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M31 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" dur="4s" repeatCount="indefinite" type="translate" values="-1 -6; 1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 31 45; 360 31 45"/><animate attributeName="opacity" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g><g><circle cx="24" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M26.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M24 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" begin="-2s" dur="4s" repeatCount="indefinite" type="translate" values="1 -6; -1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 24 45; 360 24 45"/><animate attributeName="opacity" begin="-2s" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g><g><circle cx="38" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M40.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M38 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" begin="-1s" dur="4s" repeatCount="indefinite" type="translate" values="1 -6; -1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 38 45; 360 38 45"/><animate attributeName="opacity" begin="-1s" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/13n.svg b/frontend/public/weatherIcons/13n.svg new file mode 100644 index 0000000..7a352c4 --- /dev/null +++ b/frontend/public/weatherIcons/13n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><clipPath id="a"><path fill="none" d="M12 35l-5.28-4.21-2-6 1-7 4-5 5-3h6l5 1 3 3L33 20l-6 4h-6l-3 3v4l-4 2-2 2z"/></clipPath></defs><g clip-path="url(#a)"><g><path fill="none" stroke="#f59e0b" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M23.5 24a4.5 4.5 0 11-4.5-4.5 4.49 4.49 0 014.5 4.5zM19 15.67V12.5m0 23v-3.17m5.89-14.22l2.24-2.24M10.87 32.13l2.24-2.24m0-11.78l-2.24-2.24m16.26 16.26l-2.24-2.24M7.5 24h3.17m19.83 0h-3.17"/><animateTransform attributeName="transform" dur="45s" from="0 19 24" repeatCount="indefinite" to="360 19 24" type="rotate"/></g></g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M43.67 45.5h2.83a7 7 0 000-14h-.32a10.49 10.49 0 00-19.11-8 7 7 0 00-10.57 6 7.21 7.21 0 00.1 1.14A7.5 7.5 0 0018 45.5a4.19 4.19 0 00.5 0v0"/><g><circle cx="31" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M33.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M31 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" dur="4s" repeatCount="indefinite" type="translate" values="-1 -6; 1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 31 45; 360 31 45"/><animate attributeName="opacity" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g><g><circle cx="24" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M26.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M24 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" begin="-2s" dur="4s" repeatCount="indefinite" type="translate" values="1 -6; -1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 24 45; 360 24 45"/><animate attributeName="opacity" begin="-2s" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g><g><circle cx="38" cy="45" r="1.25" fill="none" stroke="#72b8d4" stroke-miterlimit="10"/><path fill="none" stroke="#72b8d4" stroke-linecap="round" stroke-miterlimit="10" d="M40.17 46.25l-1.09-.63m-2.16-1.24l-1.09-.63M38 42.5v1.25m0 3.75v-1.25m-1.08-.63l-1.09.63m4.34-2.5l-1.09.63"/><animateTransform additive="sum" attributeName="transform" begin="-1s" dur="4s" repeatCount="indefinite" type="translate" values="1 -6; -1 12"/><animateTransform additive="sum" attributeName="transform" dur="9s" repeatCount="indefinite" type="rotate" values="0 38 45; 360 38 45"/><animate attributeName="opacity" begin="-1s" dur="4s" repeatCount="indefinite" values="0;1;1;1;0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/50d.svg b/frontend/public/weatherIcons/50d.svg new file mode 100644 index 0000000..47377b9 --- /dev/null +++ b/frontend/public/weatherIcons/50d.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 32h30"/><animateTransform attributeName="transform" begin="0s" dur="5s" repeatCount="indefinite" type="translate" values="-4 0; 4 0; -4 0"/></g><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 39h30"/><animateTransform attributeName="transform" begin="-2s" dur="5s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 25h30"/><animateTransform attributeName="transform" begin="-4s" dur="5s" repeatCount="indefinite" type="translate" values="-4 0; 4 0; -4 0"/></g></svg> \ No newline at end of file diff --git a/frontend/public/weatherIcons/50n.svg b/frontend/public/weatherIcons/50n.svg new file mode 100644 index 0000000..47377b9 --- /dev/null +++ b/frontend/public/weatherIcons/50n.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 32h30"/><animateTransform attributeName="transform" begin="0s" dur="5s" repeatCount="indefinite" type="translate" values="-4 0; 4 0; -4 0"/></g><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 39h30"/><animateTransform attributeName="transform" begin="-2s" dur="5s" repeatCount="indefinite" type="translate" values="-3 0; 3 0; -3 0"/></g><g><path fill="none" stroke="#e5e7eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M17 25h30"/><animateTransform attributeName="transform" begin="-4s" dur="5s" repeatCount="indefinite" type="translate" values="-4 0; 4 0; -4 0"/></g></svg> \ No newline at end of file diff --git a/frontend/src/App.js b/frontend/src/App.js index 5cb00d7..c5a4506 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -11,6 +11,7 @@ import DarkModeToggleButton from './darkModeToggleButton'; import ChartComponent from './chartComponent'; import CostsCollection from './costsCollection'; import TempsCollection from './tempsCollection'; +import ForecastCollection from './forecastCollection'; function App() { @@ -57,13 +58,13 @@ function App() { <ReactTooltip id="tooltip" place="top" effect="solid" /> <CarouselProvider isIntrinsicHeight={true} - totalSlides={2} + totalSlides={3} style={{display: 'flex', borderRadius: '10px'}}> <ButtonBack id="button1" style={{width: '10%', background: 'none', border: 'none'}}> <TfiArrowCircleLeft style={{width: '5em', height: '5em', color: 'rgba(0, 0, 0, 0.35)'}}/> </ButtonBack> - <Slider style={{width: '80%'}}> + <Slider style={{width: '80%',}}> <Slide index={0}> <TempsCollection /> <div data-tooltip-id="tooltip" @@ -78,6 +79,9 @@ function App() { <ChartComponent /> <CostsCollection /> </Slide> + <Slide index={2}> + <ForecastCollection /> + </Slide> </Slider> <ButtonNext id="button2" style={{width: '10%', background: 'none', border: 'none'}}> <TfiArrowCircleRight style={{width: '5em', height: '5em', color: 'rgba(0, 0, 0, 0.35)'}} /> diff --git a/frontend/src/DesiredTemp.js b/frontend/src/DesiredTemp.js index 0228da8..e653b34 100644 --- a/frontend/src/DesiredTemp.js +++ b/frontend/src/DesiredTemp.js @@ -18,7 +18,7 @@ const DesiredTemp = (props) => { <div id="tempsCollection"> <DecreaseTempButton handleDecreaseTempClick={handleDecreaseTempClick}/> <div id="currentTemp" className='temps'> - <p className='title'>Current</p> + <p className='title'>Desired</p> <p className='title'>Temperature</p> <p className='temperatures'>{desiredTemp} °F</p> </div> diff --git a/frontend/src/costsCollection.js b/frontend/src/costsCollection.js index 5a1309c..460505a 100644 --- a/frontend/src/costsCollection.js +++ b/frontend/src/costsCollection.js @@ -22,12 +22,12 @@ const CostsCollection = (props) => { <p className='title'>Cost</p> <p className='amounts'>81.00</p> </div> - <div id="outsideTemp" className='costs'> + {/* <div id="outsideTemp" className='costs'> <p className='title'>Total</p> <p className='title'>Monthly</p> <p className='title'>Cost</p> <p className='amounts'>81.00</p> - </div> + </div> */} </div> ); }; diff --git a/frontend/src/forecastCollection.js b/frontend/src/forecastCollection.js new file mode 100644 index 0000000..f47fa29 --- /dev/null +++ b/frontend/src/forecastCollection.js @@ -0,0 +1,59 @@ +import * as React from "react"; +import { useState, useEffect} from 'react'; + +const ForecastCollection = (props) => { + const [forecast, setForecast] = useState(null); + + const fetchData = async () => { + try { + const response = await fetch('https://api.openweathermap.org/data/2.5/forecast/daily?q=Birmingham,US&cnt=5&units=imperial&&appid=3563bf5e2d2996538b6ec9d50c045948'); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } + + const temp = await response.json(); + setForecast(temp); + console.log(temp) + } catch (error) { + console.error('There was a problem with the fetch operation:', error); + } + }; + + useEffect(() => { + fetchData(); + }, []); + + // https://api.openweathermap.org/data/2.5/forecast?lat=33.5186&lon=86.8104&appid=3563bf5e2d2996538b6ec9d50c045948 + // https://api.openweathermap.org/data/2.5/forecast?lat=33.5186&lon=86.8104&appid=96c71299fdf8ace053d64d762f029353 + + // Assume data is the object containing the weather forecast data + + // from ./public/weatherIcons/01d.svg + + + if (forecast && forecast.city) { + return ( + <div className="forecast-days"> + {forecast.list.map(day => ( + <div className="forecasted-day"> + <p>{new Date(day.dt * 1000).toLocaleDateString()}</p> + <p>Temperature: {day.temp.day.toFixed(0)}°F</p> + <img src={`${process.env.PUBLIC_URL}/weatherIcons/${day.weather[0].icon}.svg`} alt="weather icon" /> + </div> + ))} + </div> + ); + } else { + return <div>Loading...</div>; + } + +}; + +export default ForecastCollection; + + + + + + diff --git a/frontend/src/index.css b/frontend/src/index.css index 83e2252..214b20d 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -39,7 +39,7 @@ body { margin: 0; width: 100%; /* min-height: 100vh; */ - display: grid; + /* display: grid; */ align-items: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', @@ -1989,4 +1989,24 @@ animation-iteration-count: 1; 100% { stroke: #000 } +} + +/* .slideInner___2mfX9{ + position: unset; +} */ + +.forecast-days{ + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-evenly; + position: unset; +} + +.forecasted-day{ + display: flex; + flex-direction: column; + align-content: center; + align-items: center; + position: relative; } \ No newline at end of file diff --git a/frontend/src/tempsCollection.js b/frontend/src/tempsCollection.js index 349df2c..afacc4d 100644 --- a/frontend/src/tempsCollection.js +++ b/frontend/src/tempsCollection.js @@ -1,19 +1,42 @@ import * as React from "react"; -import { useState } from 'react'; +import { useState, useEffect} from 'react'; const TempsCollection = (props) => { + const [outdoorTemp, setOutdoorTemp] = useState(null); + + const fetchData = async () => { + try { + const response = await fetch('http://api.weatherapi.com/v1/current.json?key=6cfca6888bde479cb6b63543231504&q=35235&aqi=no'); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } + + const temp = await response.json(); + setOutdoorTemp(temp.current.temp_f); + } catch (error) { + console.error('There was a problem with the fetch operation:', error); + } + }; + + useEffect(() => { + fetchData(); + }, []); + + + return ( <div id="tempsCollection"> <div id="desiredTemp" className='temps'> <p className='title'>Outside</p> <p className='title'>Temperature</p> - <p className='temperatures'>81 °F</p> + <p className='temperatures'>{outdoorTemp} °F</p> </div> <div id="comfortTemp" className='temps'> - <p className='title'>Desired</p> + <p className='title'>Current</p> <p className='title'>Temperature</p> - <p className='temperatures'>81 °F</p> + <p className='temperatures'>70 °F</p> </div> <div id="outsideTemp" className='temps'> <p className='title'>Comfort</p> diff --git a/other/CS499_database2.py b/other/CS499_database2.py new file mode 100644 index 0000000..b8e716f --- /dev/null +++ b/other/CS499_database2.py @@ -0,0 +1,340 @@ +import psycopg2 + +# import CS_499_backend +from CS_499_backend import Door_Window, Appliance_1, Appliance_with_Water, Temperature_data, Door_Window_History, App1_History, App2_History, App3_History, time_stamp, time_stamp2, time_stamp3, time_stamp4, monthly_cost1_FEB, monthly_cost1_MAR, monthly_cost1_JAN, monthly_power1_JAN, monthly_power1_FEB, monthly_power1_MAR, monthly_cost2_FEB, monthly_cost2_JAN, monthly_cost2_MAR, monthly_water_usg_MAR, monthly_water_usg_JAN, monthly_water_usg_FEB, monthly_power2_FEB, monthly_power2_JAN, monthly_power2_MAR, monthly_temp_watts_JAN, monthly_temp_watts_FEB, monthly_temp_watts_MAR, monthly_temp_ct_JAN, monthly_temp_ct_FEB, monthly_temp_ct_MAR, TC_ct_MAR_lrtv, TC_ct_MAR_brtv, TC_pwr_MAR_brtv, TC_pwr_MAR_lrtv, TC_shower_cost2_MAR, TC_shower_power2_MAR, TC_shower_water_usg_MAR + +# create a new database +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +#cur.execute("CREATE DATABASE Team3 ") +conn.close() + +# create a new table for Door_Window_History +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS Door_Window_History; + CREATE TABLE Door_Window_History ( + id SERIAL PRIMARY KEY, + day VARCHAR(255), + door_status INTEGER, + door_time FLOAT, + window_status INTEGER, + window_time FLOAT + ); + """) + +conn.commit() + +#insert the data into the Door_Window_History table +for i in Door_Window_History: + for time_stamp, data in Door_Window_History.items(): + cur.execute(""" + INSERT INTO Door_Window_History ( + day, door_status, door_time, window_status, window_time) + VALUES (%s, %s, %s, %s, %s); + """, ( + data.day, data.Door_status, data.Door_time, + data.Window_status, data.Window_time + )) +conn.commit() + +# create a new table for App1_History +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS Appliance_1_History; + CREATE TABLE Appliance_1_History ( + id SERIAL PRIMARY KEY, + day VARCHAR(255), + micro_pwr FLOAT, + stove_pwr FLOAT, + oven_pwr FLOAT, + Lrtv_pwr FLOAT, + Brtv_pwr FLOAT, + fridge_pwr FLOAT, + micro_ct FLOAT, + stove_ct FLOAT, + oven_ct FLOAT, + Lrtv_ct FLOAT, + Brtv_ct FLOAT, + fridge_ct FLOAT, + lights_pwr FLOAT, + lights_ct FLOAT + ); + """) + +for time_stamp2, data in App1_History.items(): + cur.execute(""" + INSERT INTO Appliance_1_History ( + day, micro_pwr, stove_pwr, oven_pwr, Lrtv_pwr, Brtv_pwr, fridge_pwr, + micro_ct, stove_ct, oven_ct, Lrtv_ct, Brtv_ct, fridge_ct, lights_pwr, lights_ct) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); + """, ( + data.day, data.micro_pwr, data.stove_pwr, data.oven_pwr, data.Lrtv_pwr, data.Brtv_pwr, + data.fridge_pwr, data.micro_ct, data.stove_ct, data.oven_ct, data.Lrtv_ct, data.Brtv_ct, + data.fridge_ct, data.lights_pwr, data.lights_ct + )) +conn.commit() + + + +# create a new table for appliance_with_water +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS appliance_with_water; + CREATE TABLE appliance_with_water ( + id SERIAL PRIMARY KEY, + day TEXT, + water_heat_pwr FLOAT, + dishwasher_pwr FLOAT, + clothes_wash_pwr FLOAT, + clothes_dry_pwr FLOAT, + bath_fans_pwr FLOAT, + water_heat_ug FLOAT, + bath_water_ug FLOAT, + shower_water_ug FLOAT, + dishwasher_ug FLOAT, + clothes_wash_ug FLOAT, + water_heat_ct FLOAT, + dishwasher_ct FLOAT, + clothes_wash_ct FLOAT, + clothes_dry_ct FLOAT, + bath_fans_ct FLOAT, + water_ct FLOAT, + bath INT, + shower INT + ); +""") +conn.commit() + +# insert data into the App2_History table +for time_stamp3, data in App2_History.items(): + cur = conn.cursor() + cur.execute(""" + INSERT INTO appliance_with_water ( + day, water_heat_pwr, dishwasher_pwr, clothes_wash_pwr, + clothes_dry_pwr, bath_fans_pwr, water_heat_ug, bath_water_ug, + shower_water_ug, dishwasher_ug, clothes_wash_ug, water_heat_ct, + dishwasher_ct, clothes_wash_ct, clothes_dry_ct, bath_fans_ct, + water_ct, bath, shower + ) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); + """, ( + data.day, data.Water_Heat_pwr, data.DishWasher_pwr, data.Clothes_Wash_pwr, + data.Clothes_dry_pwr, data.bath_fans_pwr, data.Water_Heat_ug, data.Bath_water_ug, + data.Shower_water_ug, data.DishWasher_ug, data.Clothes_Wash_ug, data.Water_Heat_ct, + data.DishWasher_ct, data.Clothes_Wash_ct, data.Clothes_dry_ct, data.bath_fans_ct, + data.Water_ct, data.bath, data.shower + )) + conn.commit() + +# create a new table for Temperature_data +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS Temperature_data; + CREATE TABLE Temperature_data ( + id SERIAL PRIMARY KEY, + temp_power FLOAT, + temp_cost FLOAT + ); +""") +conn.commit() + +# insert data into the App3_History Table +for time_stamp4, data in App3_History.items(): + cur = conn.cursor() + cur.execute(""" + INSERT INTO temperature_data ( + temp_power, temp_cost + ) + VALUES (%s, %s); + """, ( + data.temp_power, data.temp_cost + )) + conn.commit() + + +#################### This is for + +# # create a new table for app1_cost_power +# conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +# cur = conn.cursor() +# cur.execute(""" +# DROP TABLE IF EXISTS app1_cost_power; +# CREATE TABLE app1_cost_power ( +# month TEXT, +# watts FLOAT, +# cost FLOAT +# ) +# """) +# conn.commit() + +# # Insert the monthly power and cost values into the table +# cur.execute(""" +# INSERT INTO app1_cost_power (month, watts, cost) +# VALUES ('January', %s, %s), +# ('February', %s, %s), +# ('March', %s, %s) +# """, (monthly_power1_JAN, monthly_cost1_JAN, +# monthly_power1_FEB, monthly_cost1_FEB, +# monthly_power1_MAR, monthly_cost1_MAR)) + +# # Commit the changes +# conn.commit() + +# # create a new table for app2_cost_power +# conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +# cur = conn.cursor() +# cur.execute(""" +# DROP TABLE IF EXISTS app2_cost_power; +# CREATE TABLE app2_cost_power ( +# month TEXT, +# watts FLOAT, +# water FLOAT, +# cost FLOAT +# ) +# """) +# conn.commit() + +# # Insert the monthly power and cost values into the table +# cur.execute(""" +# INSERT INTO app2_cost_power (month, watts, water, cost) +# VALUES ('January', %s, %s, %s), +# ('February', %s, %s, %s), +# ('March', %s, %s, %s) +# """, (monthly_power2_JAN, monthly_water_usg_JAN, monthly_cost2_JAN, +# monthly_power2_FEB, monthly_water_usg_FEB, monthly_cost2_FEB, +# monthly_power2_MAR, monthly_water_usg_MAR, monthly_cost2_MAR)) + +# # Commit the changes +# conn.commit() + + +###################################################################################################################################### +###################################################################################################################################### +############################################ TEMPERATURE DATA TABLE WATTS & COST BY MONTH ############################################ + +# create a new table for temp_cost_watts +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS temp_cost_watts; + CREATE TABLE temp_cost_watts ( + month TEXT, + watts FLOAT, + cost FLOAT + ) + """) +conn.commit() + +# Insert the monthly power and cost values into the table +cur.execute(""" + INSERT INTO temp_cost_watts (month, watts, cost) + VALUES ('Temperature Data (January):', %s, %s), + ('Temperature Data (February):', %s, %s), + ('Temperature Data (March):', %s, %s) + """, (monthly_temp_watts_JAN, monthly_temp_ct_JAN, + monthly_temp_watts_FEB, monthly_temp_ct_FEB, + monthly_temp_watts_MAR, monthly_temp_ct_MAR)) + +# Commit the changes +conn.commit() + +###################################################################################################################################### +###################################################################################################################################### +###################################################################################################################################### + + +# create a new table for total_cost_watts +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS total_cost_watts; + CREATE TABLE total_cost_watts ( + month TEXT, + watts FLOAT, + cost FLOAT + ) +""") +conn.commit() + +# Insert the monthly power and cost values into the table +cur.execute(""" + INSERT INTO total_cost_watts (month, watts, cost) + VALUES ('January', %s, %s), + ('February', %s, %s), + ('March', %s, %s) +""", (monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN, monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN, + monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB, monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB, + monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR, monthly_temp_ct_MAR+monthly_cost2_MAR+monthly_cost1_MAR)) + +# Commit the changes +conn.commit() + +# create a new table for power_testcases +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS power_testcases; + CREATE TABLE power_testcases ( + id SERIAL PRIMARY KEY, + test_case TEXT, + test_case_pwr FLOAT, + test_case_cost FLOAT + ) +""") +conn.commit() + +# Insert the two test case for living room TV & bedroom tv power and cost values into the table +cur.execute(""" + INSERT INTO power_testcases (test_case, test_case_pwr, test_case_cost) + VALUES ('Test case 1 (Living Room TV):', %s, %s), + ('Test case 2 (Bedroom TV):', %s, %s) +""", (TC_pwr_MAR_lrtv, TC_ct_MAR_lrtv, + TC_pwr_MAR_brtv, TC_ct_MAR_brtv)) + +# Commit the changes +conn.commit() + + + +##################################################################################################################### +##################################################################################################################### +############################################ WATER TEST CASE SHOWER CODE ############################################ + +# create a new table for water_testcase +conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") +cur = conn.cursor() +cur.execute(""" + DROP TABLE IF EXISTS water_testcase; + CREATE TABLE water_testcase ( + id SERIAL PRIMARY KEY, + test_case TEXT, + test_case_pwr FLOAT, + test_case_cost FLOAT, + test_case_usg FLOAT + ) +""") +conn.commit() + +# Insert a test case for shower and display power, cost, and water used into the table +cur.execute(""" + INSERT INTO water_testcase (test_case, test_case_pwr, test_case_cost, test_case_usg) + VALUES ('Test case (Shower):', %s, %s, %s) +""", (TC_shower_power2_MAR, TC_shower_cost2_MAR, TC_shower_water_usg_MAR)) + +# Commit the changes +conn.commit() + +##################################################################################################################### +##################################################################################################################### +##################################################################################################################### + + +# Commit changes +#conn.commit() +cur.close() +conn.close() diff --git a/CS_499_Webframe.fig b/other/CS_499_Webframe.fig similarity index 100% rename from CS_499_Webframe.fig rename to other/CS_499_Webframe.fig diff --git a/CS_499_database.py b/other/CS_499_database.py similarity index 100% rename from CS_499_database.py rename to other/CS_499_database.py diff --git a/Pseudo_Code_CS_499__2_.docx b/other/Pseudo_Code_CS_499__2_.docx similarity index 100% rename from Pseudo_Code_CS_499__2_.docx rename to other/Pseudo_Code_CS_499__2_.docx diff --git a/app.py b/other/app.py similarity index 83% rename from app.py rename to other/app.py index 6564906..947930d 100644 --- a/app.py +++ b/other/app.py @@ -1,5 +1,5 @@ from flask import Flask -from main import create_app +from backend.api import create_app app = create_app() diff --git a/erd499_finalized__1_.drawio.pdf b/other/erd499_finalized__1_.drawio.pdf similarity index 100% rename from erd499_finalized__1_.drawio.pdf rename to other/erd499_finalized__1_.drawio.pdf diff --git a/main.py b/other/main.py similarity index 100% rename from main.py rename to other/main.py diff --git a/powerData.py b/powerData.py deleted file mode 100644 index 2f044e2..0000000 --- a/powerData.py +++ /dev/null @@ -1,12 +0,0 @@ -from flask import request, Blueprint, jsonify -import psycopg2 - -powerData_bp = Blueprint('powerData', __name__) - -@powerData_bp.route('/powerData', methods = ['GET']) -def get_powerData(): - conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") - cur = conn.cursor() - all_powerData = cur.execute('SELECT * FROM') - - return jsonify(all_powerData) diff --git a/tempData.py b/tempData.py deleted file mode 100644 index de5bf49..0000000 --- a/tempData.py +++ /dev/null @@ -1,12 +0,0 @@ -from flask import request, Blueprint, jsonify -import psycopg2 - -tempData_bp = Blueprint('tempData', __name__) - -@tempData_bp.route('/tempData', methods = ['GET']) -def get_temperatureData(): - conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") - cur = conn.cursor() - all_tempData = cur.execute('SELECT * FROM ') - - return jsonify(all_tempData) diff --git a/waterData.py b/waterData.py deleted file mode 100644 index d0c960e..0000000 --- a/waterData.py +++ /dev/null @@ -1,12 +0,0 @@ -from flask import request, Blueprint, jsonify -import psycopg2 - -waterData_bp = Blueprint('waterData', __name__) - -@waterData_bp.route('/waterData', methods = ['GET']) -def get_waterData(): - conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432") - cur = conn.cursor() - all_waterData = cur.execute('SELECT * FROM') - - return jsonify(all_waterData) \ No newline at end of file -- GitLab