-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapprovid2.html
101 lines (81 loc) · 3.3 KB
/
approvid2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<title>Video Portal</title>
<style>
/* Hide the button by default */
#newVideoButton {
display: none;
}
</style>
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-4">
<h1 class="text-3xl font-bold mb-4">Video Portal</h1>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" id="videoGrid">
</div>
<button id="newVideoButton" class="fixed bottom-4 right-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
+
</button>
</div>
<script type="module">
// Import the createClient function from the Supabase JS library
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm';
// Supabase client initialization
const supabaseUrl = 'https://vlvbodwrtblttvwnxkjx.supabase.co';
const supabaseAnonKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZsdmJvZHdydGJsdHR2d254a2p4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODY3NDk2NzIsImV4cCI6MjAwMjMyNTY3Mn0.TRT1HeX85vP1zDxnU7qBz5GqNPgYZUj-BOdek4qmtEg';
const supabase = createClient(supabaseUrl, supabaseAnonKey);
async function loadVideos() {
try {
// Fetch video data directly from Supabase
const { data: videos, error } = await supabase
.from('Video')
.select('*');
if (error) {
console.error('Error loading videos:', error);
return;
}
const videoGrid = document.getElementById('videoGrid');
videoGrid.innerHTML = ''; // Clear existing videos
videos.forEach(video => {
const thumbnailUrl = video.thumbnail_url ? video.thumbnail_url : 'placeholder.jpg'; // Use a placeholder if thumbnail_url is undefined
const videoElement = `
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<img src="${thumbnailUrl}" alt="${video.title}" class="w-full">
<div class="p-4">
<h2 class="text-xl font-semibold mb-2">${video.title}</h2>
<p class="text-gray-600 text-sm">${video.description}</p>
<div class="flex justify-end mt-2">
<button class="text-blue-500 hover:text-blue-700 edit-button" data-video-id="${video.id}">Edit</button>
</div>
</div>
</div>
`;
videoGrid.innerHTML += videoElement;
});
videoGrid.innerHTML += videoElement;
});
} catch (error) {
console.error('Error loading videos:', error);
}
}
// Function to toggle the new video button
function toggleNewVideoButton() {
const isLoggedIn = true; // Replace with your actual login check or fake it
const newVideoButton = document.getElementById('newVideoButton');
if (isLoggedIn) {
newVideoButton.style.display = 'block';
} else {
newVideoButton.style.display = 'none';
}
}
// Load videos on page load
loadVideos();
// Toggle button visibility (you might want to call this after a login event)
toggleNewVideoButton();
</script>
</body>
</html>