Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1199,20 +1199,52 @@ def create_ui() -> gr.Blocks:
|
|
| 1199 |
],
|
| 1200 |
js="""(repo_id) => {
|
| 1201 |
console.log('DEBUG: JS called with repo_id:', repo_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1202 |
setTimeout(() => {
|
| 1203 |
window.scrollTo({top: 0, behavior: 'smooth'});
|
| 1204 |
window.dispatchEvent(new Event('repoExplorerNavigation'));
|
| 1205 |
|
| 1206 |
-
//
|
| 1207 |
-
const inputs = document.querySelectorAll('input[placeholder*="microsoft/DialoGPT-medium"], input[placeholder*="Repository ID"]');
|
| 1208 |
-
console.log('DEBUG: Found inputs:', inputs.length);
|
| 1209 |
inputs.forEach((input, index) => {
|
| 1210 |
-
console.log('DEBUG: Setting input', index, 'to value:',
|
| 1211 |
-
|
| 1212 |
-
|
| 1213 |
-
|
|
|
|
|
|
|
| 1214 |
});
|
| 1215 |
-
},
|
| 1216 |
}"""
|
| 1217 |
)
|
| 1218 |
cancel_modal_btn.click(
|
|
@@ -1230,14 +1262,44 @@ def create_ui() -> gr.Blocks:
|
|
| 1230 |
df_output.select(
|
| 1231 |
fn=handle_dataframe_select,
|
| 1232 |
inputs=[df_output],
|
| 1233 |
-
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1234 |
)
|
| 1235 |
|
| 1236 |
# Add selection event for top repositories dataframe too
|
| 1237 |
top_repos_df.select(
|
| 1238 |
fn=handle_dataframe_select,
|
| 1239 |
inputs=[top_repos_df],
|
| 1240 |
-
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1241 |
)
|
| 1242 |
|
| 1243 |
# Reset button event
|
|
|
|
| 1199 |
],
|
| 1200 |
js="""(repo_id) => {
|
| 1201 |
console.log('DEBUG: JS called with repo_id:', repo_id);
|
| 1202 |
+
console.log('DEBUG: repo_id type:', typeof repo_id);
|
| 1203 |
+
|
| 1204 |
+
// Try multiple ways to get the repo_id
|
| 1205 |
+
let actualRepoId = repo_id;
|
| 1206 |
+
|
| 1207 |
+
// Check if repo_id is valid
|
| 1208 |
+
if (!actualRepoId || actualRepoId === 'None' || actualRepoId === null || actualRepoId === 'null') {
|
| 1209 |
+
console.log('DEBUG: repo_id is null/undefined, trying alternatives...');
|
| 1210 |
+
|
| 1211 |
+
// Try to get from global variable
|
| 1212 |
+
if (window.selectedRepoId) {
|
| 1213 |
+
actualRepoId = window.selectedRepoId;
|
| 1214 |
+
console.log('DEBUG: Found repo_id in global variable:', actualRepoId);
|
| 1215 |
+
}
|
| 1216 |
+
|
| 1217 |
+
// Try to get from the modal text input
|
| 1218 |
+
if (!actualRepoId) {
|
| 1219 |
+
const modalTextboxes = document.querySelectorAll('label:contains("Selected Repository") + textarea, label:contains("Selected Repository") + input');
|
| 1220 |
+
console.log('DEBUG: Found modal textboxes:', modalTextboxes.length);
|
| 1221 |
+
modalTextboxes.forEach((input, index) => {
|
| 1222 |
+
console.log('DEBUG: Modal input', index, 'value:', input.value);
|
| 1223 |
+
if (input.value && input.value.trim()) {
|
| 1224 |
+
actualRepoId = input.value.trim();
|
| 1225 |
+
}
|
| 1226 |
+
});
|
| 1227 |
+
}
|
| 1228 |
+
}
|
| 1229 |
+
|
| 1230 |
+
console.log('DEBUG: Final repo_id to use:', actualRepoId);
|
| 1231 |
+
|
| 1232 |
setTimeout(() => {
|
| 1233 |
window.scrollTo({top: 0, behavior: 'smooth'});
|
| 1234 |
window.dispatchEvent(new Event('repoExplorerNavigation'));
|
| 1235 |
|
| 1236 |
+
// Find and set the repo explorer input
|
| 1237 |
+
const inputs = document.querySelectorAll('input[placeholder*="microsoft/DialoGPT-medium"], input[placeholder*="Repository ID"], label:contains("Repository ID") + input');
|
| 1238 |
+
console.log('DEBUG: Found repo explorer inputs:', inputs.length);
|
| 1239 |
inputs.forEach((input, index) => {
|
| 1240 |
+
console.log('DEBUG: Setting repo explorer input', index, 'to value:', actualRepoId);
|
| 1241 |
+
if (actualRepoId) {
|
| 1242 |
+
input.value = actualRepoId;
|
| 1243 |
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
| 1244 |
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
| 1245 |
+
}
|
| 1246 |
});
|
| 1247 |
+
}, 300);
|
| 1248 |
}"""
|
| 1249 |
)
|
| 1250 |
cancel_modal_btn.click(
|
|
|
|
| 1262 |
df_output.select(
|
| 1263 |
fn=handle_dataframe_select,
|
| 1264 |
inputs=[df_output],
|
| 1265 |
+
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal],
|
| 1266 |
+
js="""(evt, df) => {
|
| 1267 |
+
console.log('DEBUG: Dataframe selection event:', evt);
|
| 1268 |
+
if (evt && evt.index && evt.index.length >= 2) {
|
| 1269 |
+
const row = evt.index[0];
|
| 1270 |
+
const col = evt.index[1];
|
| 1271 |
+
console.log('DEBUG: Selected row', row, 'col', col);
|
| 1272 |
+
|
| 1273 |
+
// Store selected repo_id globally for backup
|
| 1274 |
+
if (col === 0 && df && df.length > row) {
|
| 1275 |
+
const repoId = df[row][0];
|
| 1276 |
+
console.log('DEBUG: Storing global repo_id:', repoId);
|
| 1277 |
+
window.selectedRepoId = repoId;
|
| 1278 |
+
}
|
| 1279 |
+
}
|
| 1280 |
+
}"""
|
| 1281 |
)
|
| 1282 |
|
| 1283 |
# Add selection event for top repositories dataframe too
|
| 1284 |
top_repos_df.select(
|
| 1285 |
fn=handle_dataframe_select,
|
| 1286 |
inputs=[top_repos_df],
|
| 1287 |
+
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal],
|
| 1288 |
+
js="""(evt, df) => {
|
| 1289 |
+
console.log('DEBUG: Top repos dataframe selection event:', evt);
|
| 1290 |
+
if (evt && evt.index && evt.index.length >= 2) {
|
| 1291 |
+
const row = evt.index[0];
|
| 1292 |
+
const col = evt.index[1];
|
| 1293 |
+
console.log('DEBUG: Selected row', row, 'col', col);
|
| 1294 |
+
|
| 1295 |
+
// Store selected repo_id globally for backup
|
| 1296 |
+
if (col === 0 && df && df.length > row) {
|
| 1297 |
+
const repoId = df[row][0];
|
| 1298 |
+
console.log('DEBUG: Storing global repo_id:', repoId);
|
| 1299 |
+
window.selectedRepoId = repoId;
|
| 1300 |
+
}
|
| 1301 |
+
}
|
| 1302 |
+
}"""
|
| 1303 |
)
|
| 1304 |
|
| 1305 |
# Reset button event
|