Spaces:
Sleeping
Sleeping
Commit
·
da561f9
1
Parent(s):
898b233
add firebase head
Browse files
app.py
CHANGED
|
@@ -862,48 +862,84 @@ def create_chat_interface():
|
|
| 862 |
cursor: progress;
|
| 863 |
}
|
| 864 |
"""
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 900 |
"""
|
| 901 |
|
| 902 |
with gr.Blocks(
|
| 903 |
fill_height=True,
|
| 904 |
fill_width=True,
|
| 905 |
css=css,
|
| 906 |
-
|
| 907 |
theme=gr.themes.Default(
|
| 908 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"]
|
| 909 |
),
|
|
|
|
| 862 |
cursor: progress;
|
| 863 |
}
|
| 864 |
"""
|
| 865 |
+
head = f"""
|
| 866 |
+
<script defer src="https://www.gstatic.com/firebasejs/11.1.0/firebase-firestore.js"></script>
|
| 867 |
+
<script type="module">
|
| 868 |
+
// Import the functions you need from the SDKs you need
|
| 869 |
+
import {{ initializeApp }} from "https://www.gstatic.com/firebasejs/11.1.0/firebase-app.js";
|
| 870 |
+
import {{ getDatabase, ref, set }} from "https://www.gstatic.com/firebasejs/11.1.0/firebase-database.js";
|
| 871 |
+
// TODO: Add SDKs for Firebase products that you want to use
|
| 872 |
+
// https://firebase.google.com/docs/web/setup#available-libraries
|
| 873 |
+
console.log("Initializing Firebase");
|
| 874 |
+
// Your web app's Firebase configuration
|
| 875 |
+
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
|
| 876 |
+
const firebaseConfig = {{
|
| 877 |
+
"apiKey": "AIzaSyDzhYytalbHOMaLJa8KXy6nvyTdp2PaY4Y",
|
| 878 |
+
"authDomain": "gfh-agora-video.firebaseapp.com",
|
| 879 |
+
"databaseURL": "https://gfh-agora-video.firebaseio.com",
|
| 880 |
+
"projectId": "gfh-agora-video",
|
| 881 |
+
"storageBucket": "gfh-agora-video.appspot.com",
|
| 882 |
+
"messagingSenderId": "229903401215",
|
| 883 |
+
"appId": "1:229903401215:web:f007bdf575a25063d04cca",
|
| 884 |
+
"measurementId": "G-ZT6PG5M8EV"
|
| 885 |
+
}};
|
| 886 |
+
|
| 887 |
+
// Initialize Firebase
|
| 888 |
+
const app = initializeApp(firebaseConfig);
|
| 889 |
+
const realtimeDB = getDatabase(app);
|
| 890 |
+
const rollAccount = "roll-prod-account";
|
| 891 |
+
const COLLECTIONS = {{
|
| 892 |
+
COLLAB_EDIT_LINK: "collab_link_handler",
|
| 893 |
+
}};
|
| 894 |
+
|
| 895 |
+
// Event listener for click
|
| 896 |
+
document.addEventListener('click', function (event) {{
|
| 897 |
+
var link = event.target.closest('a');
|
| 898 |
+
event.preventDefault();
|
| 899 |
+
if (link && link.href) {{
|
| 900 |
+
|
| 901 |
+
// Parse the URL to extract 'st' and 'et'
|
| 902 |
+
const url = new URL(link.href);
|
| 903 |
+
const startTime = url.searchParams.get('st');
|
| 904 |
+
const endTime = url.searchParams.get('et');
|
| 905 |
+
const userId = url.searchParams.get('uid') || "";
|
| 906 |
+
|
| 907 |
+
if (startTime || endTime) {{
|
| 908 |
+
let components = url.pathname.split("/");
|
| 909 |
+
let callId = components[2];
|
| 910 |
+
let recordingSessionId = components[3];
|
| 911 |
+
|
| 912 |
+
let data = {{
|
| 913 |
+
startTime: parseInt(startTime, 10),
|
| 914 |
+
endTime: parseInt(endTime, 10),
|
| 915 |
+
}};
|
| 916 |
+
|
| 917 |
+
console.log("Data to save:", data);
|
| 918 |
+
|
| 919 |
+
// Firebase reference
|
| 920 |
+
let reference = ref(
|
| 921 |
+
realtimeDB,
|
| 922 |
+
`${{rollAccount}}/${{COLLECTIONS.COLLAB_EDIT_LINK}}/${{userId}}/${{callId}}/${{recordingSessionId}}`
|
| 923 |
+
);
|
| 924 |
+
|
| 925 |
+
set(reference, data)
|
| 926 |
+
.then(() => {{
|
| 927 |
+
console.log("Data saved successfully:", data);
|
| 928 |
+
}})
|
| 929 |
+
.catch((error) => {{
|
| 930 |
+
console.error("Error saving data:", error);
|
| 931 |
+
}});
|
| 932 |
+
}}
|
| 933 |
+
}}
|
| 934 |
+
}});
|
| 935 |
+
</script>
|
| 936 |
"""
|
| 937 |
|
| 938 |
with gr.Blocks(
|
| 939 |
fill_height=True,
|
| 940 |
fill_width=True,
|
| 941 |
css=css,
|
| 942 |
+
head=head,
|
| 943 |
theme=gr.themes.Default(
|
| 944 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"]
|
| 945 |
),
|