Update app.py
Browse files
app.py
CHANGED
|
@@ -91,7 +91,8 @@ HIDDEN_COLUMNS = [
|
|
| 91 |
'# F IDs',
|
| 92 |
'Max kW',
|
| 93 |
'Länk till fysisk plats',
|
| 94 |
-
'Uppdatera Lat, Long'
|
|
|
|
| 95 |
]
|
| 96 |
|
| 97 |
# ============================================================================
|
|
@@ -1025,6 +1026,10 @@ def batch_update_cells_with_tracking(sheet, changes, df, editor_email, log_sheet
|
|
| 1025 |
sheet.batch_update(batch)
|
| 1026 |
time.sleep(REQUEST_DELAY)
|
| 1027 |
print("[SUCCESS] Tracking-uppdatering lyckades")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1028 |
except Exception as e:
|
| 1029 |
# Om timestamp-uppdateringen misslyckas, fortsätt ändå
|
| 1030 |
# eftersom huvuddatan är sparad
|
|
@@ -1146,7 +1151,7 @@ def get_column_config(df):
|
|
| 1146 |
# Dropdown för tillgänglighet
|
| 1147 |
config[col] = st.column_config.SelectboxColumn(
|
| 1148 |
col,
|
| 1149 |
-
help=
|
| 1150 |
width="medium",
|
| 1151 |
options=[
|
| 1152 |
"Alltid tillgängligt",
|
|
@@ -1154,25 +1159,33 @@ def get_column_config(df):
|
|
| 1154 |
],
|
| 1155 |
required=True
|
| 1156 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1157 |
elif col == 'Main Contact':
|
| 1158 |
# Dropdown för huvudkontakt
|
| 1159 |
config[col] = st.column_config.SelectboxColumn(
|
| 1160 |
col,
|
| 1161 |
-
help=
|
| 1162 |
width="medium",
|
| 1163 |
options=[
|
| 1164 |
"",
|
| 1165 |
"Huvudkontakt"
|
| 1166 |
],
|
| 1167 |
-
required=
|
| 1168 |
)
|
| 1169 |
else:
|
| 1170 |
-
# Vanlig textkolumn
|
| 1171 |
config[col] = st.column_config.TextColumn(
|
| 1172 |
col,
|
| 1173 |
-
help=
|
| 1174 |
width="medium",
|
| 1175 |
-
required=
|
| 1176 |
)
|
| 1177 |
|
| 1178 |
# Konfigurera readonly kolumner med hänglås-emoji
|
|
@@ -1794,13 +1807,15 @@ else:
|
|
| 1794 |
st.session_state.last_save_time = datetime.now()
|
| 1795 |
st.session_state.saving_in_progress = False
|
| 1796 |
|
|
|
|
|
|
|
|
|
|
| 1797 |
# Uppdatera data
|
| 1798 |
st.cache_resource.clear()
|
| 1799 |
new_df = get_sheet_data(sheet)
|
| 1800 |
if new_df is not None:
|
| 1801 |
st.session_state.df = new_df
|
| 1802 |
|
| 1803 |
-
time.sleep(1)
|
| 1804 |
st.rerun()
|
| 1805 |
else:
|
| 1806 |
st.session_state.saving_in_progress = False
|
|
@@ -1932,7 +1947,8 @@ else:
|
|
| 1932 |
</div>
|
| 1933 |
""", unsafe_allow_html=True)
|
| 1934 |
|
| 1935 |
-
|
|
|
|
| 1936 |
|
| 1937 |
# Uppdatera data
|
| 1938 |
st.cache_resource.clear()
|
|
|
|
| 91 |
'# F IDs',
|
| 92 |
'Max kW',
|
| 93 |
'Länk till fysisk plats',
|
| 94 |
+
'Uppdatera Lat, Long',
|
| 95 |
+
'Editor'
|
| 96 |
]
|
| 97 |
|
| 98 |
# ============================================================================
|
|
|
|
| 1026 |
sheet.batch_update(batch)
|
| 1027 |
time.sleep(REQUEST_DELAY)
|
| 1028 |
print("[SUCCESS] Tracking-uppdatering lyckades")
|
| 1029 |
+
|
| 1030 |
+
# Vänta lite extra för att Google Sheets ska propagera ändringarna
|
| 1031 |
+
time.sleep(2)
|
| 1032 |
+
|
| 1033 |
except Exception as e:
|
| 1034 |
# Om timestamp-uppdateringen misslyckas, fortsätt ändå
|
| 1035 |
# eftersom huvuddatan är sparad
|
|
|
|
| 1151 |
# Dropdown för tillgänglighet
|
| 1152 |
config[col] = st.column_config.SelectboxColumn(
|
| 1153 |
col,
|
| 1154 |
+
help="Vänligen fyll i detta fält",
|
| 1155 |
width="medium",
|
| 1156 |
options=[
|
| 1157 |
"Alltid tillgängligt",
|
|
|
|
| 1159 |
],
|
| 1160 |
required=True
|
| 1161 |
)
|
| 1162 |
+
elif col == 'Access info':
|
| 1163 |
+
# Access info med speciell text
|
| 1164 |
+
config[col] = st.column_config.TextColumn(
|
| 1165 |
+
col,
|
| 1166 |
+
help="Vi behöver information om hur vi får tillgång till ditt stängda område",
|
| 1167 |
+
width="medium",
|
| 1168 |
+
required=True
|
| 1169 |
+
)
|
| 1170 |
elif col == 'Main Contact':
|
| 1171 |
# Dropdown för huvudkontakt
|
| 1172 |
config[col] = st.column_config.SelectboxColumn(
|
| 1173 |
col,
|
| 1174 |
+
help="Vänligen fyll i detta fält",
|
| 1175 |
width="medium",
|
| 1176 |
options=[
|
| 1177 |
"",
|
| 1178 |
"Huvudkontakt"
|
| 1179 |
],
|
| 1180 |
+
required=True
|
| 1181 |
)
|
| 1182 |
else:
|
| 1183 |
+
# Vanlig textkolumn - ALLA med required=True
|
| 1184 |
config[col] = st.column_config.TextColumn(
|
| 1185 |
col,
|
| 1186 |
+
help="Vänligen fyll i detta fält",
|
| 1187 |
width="medium",
|
| 1188 |
+
required=True
|
| 1189 |
)
|
| 1190 |
|
| 1191 |
# Konfigurera readonly kolumner med hänglås-emoji
|
|
|
|
| 1807 |
st.session_state.last_save_time = datetime.now()
|
| 1808 |
st.session_state.saving_in_progress = False
|
| 1809 |
|
| 1810 |
+
# Vänta för att Google Sheets ska propagera Last update
|
| 1811 |
+
time.sleep(2)
|
| 1812 |
+
|
| 1813 |
# Uppdatera data
|
| 1814 |
st.cache_resource.clear()
|
| 1815 |
new_df = get_sheet_data(sheet)
|
| 1816 |
if new_df is not None:
|
| 1817 |
st.session_state.df = new_df
|
| 1818 |
|
|
|
|
| 1819 |
st.rerun()
|
| 1820 |
else:
|
| 1821 |
st.session_state.saving_in_progress = False
|
|
|
|
| 1947 |
</div>
|
| 1948 |
""", unsafe_allow_html=True)
|
| 1949 |
|
| 1950 |
+
# Vänta för att Google Sheets ska propagera Last update
|
| 1951 |
+
time.sleep(2)
|
| 1952 |
|
| 1953 |
# Uppdatera data
|
| 1954 |
st.cache_resource.clear()
|