Shivraj8615 commited on
Commit
c26a560
·
verified ·
1 Parent(s): 5fb8e27

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +111 -38
src/streamlit_app.py CHANGED
@@ -1,40 +1,113 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
 
 
 
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import requests
3
+ import streamlit_authenticator as stauth
4
+ import datetime
5
 
6
+ # ---------------- LOGIN SETUP ----------------
7
+ credentials = {
8
+ "usernames": {
9
+ "admin": {
10
+ "name": "Admin",
11
+ "password": "12345" # Replace with hashed password for security
12
+ }
13
+ }
14
+ }
15
+
16
+ authenticator = stauth.Authenticate(credentials, "app_home", "abcdef", cookie_expiry_days=1)
17
+ name, auth_status, username = authenticator.login("Login", "main")
18
+
19
+ if auth_status is False:
20
+ st.error("Incorrect username/password")
21
+ elif auth_status is None:
22
+ st.warning("Enter your credentials")
23
+ elif auth_status:
24
+ authenticator.logout("Logout", "sidebar")
25
+
26
+ st.title("Boiler Production Tracking")
27
+
28
+ with st.form("entry_form"):
29
+ customer_name = st.text_input("CUSTOMER NAME")
30
+ boiler_no = st.text_input("BOILER NO")
31
+ capacity_tph = st.number_input("CAPACITY IN TPH", min_value=0.0, step=0.1)
32
+
33
+ material_offer_planned = st.date_input("MATERIAL OFFER PLANNED")
34
+ material_offer_actual = st.date_input("MATERIAL OFFER ACTUAL")
35
+ cutting_planned = st.date_input("CUTTING PLANNED")
36
+ cutting_actual = st.date_input("CUTTING ACTUAL")
37
+ rolling_planned = st.date_input("ROLLING PLANNED")
38
+ rolling_actual = st.date_input("ROLLING ACTUAL")
39
+ l_seam_rt_planned = st.date_input("L-SEAM RT PLANNED")
40
+ l_seam_rt_actual = st.date_input("L-SEAM RT ACTUAL")
41
+ c_seam_planned = st.date_input("C-SEAM PLANNED")
42
+ c_seam_actual = st.date_input("C-SEAM ACTUAL")
43
+ shell_ready_planned = st.date_input("SHELL READY PLANNED")
44
+ shell_ready_actual = st.date_input("SHELL READY ACTUAL")
45
+ test_plate_testing_planned = st.date_input("TEST PLATE TESTING PLANNED")
46
+ test_plate_testing_actual = st.date_input("TEST PLATE TESTING ACTUAL")
47
+ tube_plate_drilling_planned = st.date_input("TUBE PLATE DRILLING PLANNED")
48
+ tube_plate_drilling_actual = st.date_input("TUBE PLATE DRILLING ACTUAL")
49
+
50
+ material_shortage = st.text_area("MATERIAL SHORTAGE DETAILS")
51
+
52
+ ftp_setup_planned = st.date_input("FTP SETUP PLANNED")
53
+ ftp_setup_actual = st.date_input("FTP SETUP ACTUAL")
54
+ nozzle_setup_planned = st.date_input("NOZZLE SETUP PLANNED")
55
+ nozzle_setup_actual = st.date_input("NOZZLE SETUP ACTUAL")
56
+ final_setup_planned = st.date_input("FINAL SETUP PLANNED")
57
+ final_setup_actual = st.date_input("FINAL SETUP ACTUAL")
58
+ full_welding_planned = st.date_input("FULL WELDING PLANNED")
59
+ full_welding_actual = st.date_input("FULL WELDING ACTUAL")
60
+ hydro_planned = st.date_input("HYDRO DATE PLANNED")
61
+ hydro_actual = st.date_input("HYDRO DATE ACTUAL")
62
+ customer_hydro_planned = st.date_input("CUSTOMER HYDRO DATE PLANNED")
63
+ customer_hydro_actual = st.date_input("CUSTOMER HYDRO DATE ACTUAL")
64
+
65
+ remark = st.text_area("REMARK")
66
+
67
+ submitted = st.form_submit_button("Submit Data")
68
+
69
+ if submitted:
70
+ url = "https://script.google.com/a/macros/forbesmarshall.com/s/AKfycbyPTwzYNsy8D2M27O8ZZ90G1UYHP1aPExA_FX7VLh3iQquOt16Cc14tF7-xp8SGd1bE/exec" # Replace with your deployment URL
71
+
72
+ payload = {
73
+ "customer_name": customer_name,
74
+ "boiler_no": boiler_no,
75
+ "capacity_tph": capacity_tph,
76
+ "material_offer_planned": str(material_offer_planned),
77
+ "material_offer_actual": str(material_offer_actual),
78
+ "cutting_planned": str(cutting_planned),
79
+ "cutting_actual": str(cutting_actual),
80
+ "rolling_planned": str(rolling_planned),
81
+ "rolling_actual": str(rolling_actual),
82
+ "l_seam_rt_planned": str(l_seam_rt_planned),
83
+ "l_seam_rt_actual": str(l_seam_rt_actual),
84
+ "c_seam_planned": str(c_seam_planned),
85
+ "c_seam_actual": str(c_seam_actual),
86
+ "shell_ready_planned": str(shell_ready_planned),
87
+ "shell_ready_actual": str(shell_ready_actual),
88
+ "test_plate_testing_planned": str(test_plate_testing_planned),
89
+ "test_plate_testing_actual": str(test_plate_testing_actual),
90
+ "tube_plate_drilling_planned": str(tube_plate_drilling_planned),
91
+ "tube_plate_drilling_actual": str(tube_plate_drilling_actual),
92
+ "material_shortage": material_shortage,
93
+ "ftp_setup_planned": str(ftp_setup_planned),
94
+ "ftp_setup_actual": str(ftp_setup_actual),
95
+ "nozzle_setup_planned": str(nozzle_setup_planned),
96
+ "nozzle_setup_actual": str(nozzle_setup_actual),
97
+ "final_setup_planned": str(final_setup_planned),
98
+ "final_setup_actual": str(final_setup_actual),
99
+ "full_welding_planned": str(full_welding_planned),
100
+ "full_welding_actual": str(full_welding_actual),
101
+ "hydro_planned": str(hydro_planned),
102
+ "hydro_actual": str(hydro_actual),
103
+ "customer_hydro_planned": str(customer_hydro_planned),
104
+ "customer_hydro_actual": str(customer_hydro_actual),
105
+ "remark": remark
106
+ }
107
+
108
+ r = requests.post(url, json=payload)
109
+
110
+ if r.status_code == 200:
111
+ st.success("✅ Data added to Google Sheet successfully!")
112
+ else:
113
+ st.error("❌ Failed to send data. Please check the script URL.")