pvanand commited on
Commit
77f6e8e
·
verified ·
1 Parent(s): 070678d

Create mult-agent-auth.html

Browse files
Files changed (1) hide show
  1. static/mult-agent-auth.html +265 -0
static/mult-agent-auth.html ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Elevatics ai</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
8
+ <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
10
+ <style>
11
+ html, body {
12
+ height: 100%;
13
+ margin: 0;
14
+ padding: 0;
15
+ overflow: hidden;
16
+ font-family: 'Roboto', sans-serif;
17
+ }
18
+ #app {
19
+ height: 100%;
20
+ display: flex;
21
+ flex-direction: column;
22
+ }
23
+ .content-wrapper {
24
+ flex-grow: 1;
25
+ position: relative;
26
+ overflow: hidden;
27
+ }
28
+ iframe {
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ width: 100%;
33
+ height: 100%;
34
+ border: none;
35
+ }
36
+ .sidebar {
37
+ position: fixed;
38
+ left: 0;
39
+ top: 0;
40
+ bottom: 0;
41
+ width: 250px;
42
+ background-color: #2c3e50;
43
+ color: white;
44
+ display: flex;
45
+ flex-direction: column;
46
+ transition: transform 0.3s ease-in-out;
47
+ transform: translateX(-100%);
48
+ overflow-y: auto;
49
+ padding-top: 60px;
50
+ z-index: 1000;
51
+ }
52
+ .sidebar.open {
53
+ transform: translateX(0);
54
+ }
55
+ .sidebar button {
56
+ width: 80%;
57
+ margin: 10px auto;
58
+ padding: 15px;
59
+ background-color: #3498db;
60
+ color: white;
61
+ border: none;
62
+ border-radius: 10px;
63
+ font-size: 14px;
64
+ cursor: pointer;
65
+ text-align: center;
66
+ transition: all 0.3s ease;
67
+ display: block;
68
+ }
69
+ .sidebar button:hover {
70
+ background-color: #2980b9;
71
+ transform: translateY(-2px);
72
+ box-shadow: 0 4px 8px rgba(0,0,0,0.2);
73
+ }
74
+ .toggle-btn {
75
+ position: fixed;
76
+ left: 10px;
77
+ top: 10px;
78
+ background-color: #3498db;
79
+ color: white;
80
+ border: none;
81
+ border-radius: 10px;
82
+ font-size: 16px;
83
+ cursor: pointer;
84
+ padding: 7px 15px;
85
+ z-index: 1001;
86
+ transition: background-color 0.3s ease;
87
+ }
88
+ .toggle-btn:hover {
89
+ background-color: #2980b9;
90
+ }
91
+ .category {
92
+ width: 100%;
93
+ margin-bottom: 20px;
94
+ }
95
+ .category-title {
96
+ width: 80%;
97
+ margin: 10px auto;
98
+ padding: 10px;
99
+ background-color: #34495e;
100
+ color: white;
101
+ border-radius: 10px;
102
+ font-size: 16px;
103
+ text-align: center;
104
+ cursor: pointer;
105
+ }
106
+ .category-content {
107
+ display: none;
108
+ width: 100%;
109
+ }
110
+ .category-content.show {
111
+ display: block;
112
+ }
113
+ .user-info {
114
+ width: 80%;
115
+ margin: 20px auto;
116
+ text-align: center;
117
+ }
118
+ .user-name {
119
+ margin-bottom: 10px;
120
+ font-weight: bold;
121
+ }
122
+ .logout-btn {
123
+ background-color: #e74c3c;
124
+ }
125
+ .logout-btn:hover {
126
+ background-color: #c0392b;
127
+ }
128
+
129
+ @media (max-width: 768px) {
130
+ .sidebar {
131
+ width: 100%;
132
+ }
133
+ .sidebar button, .category-title, .user-info {
134
+ width: 90%;
135
+ }
136
+ }
137
+
138
+ @media (max-width: 480px) {
139
+ .sidebar button, .category-title, .user-info {
140
+ width: 95%;
141
+ }
142
+ }
143
+ </style>
144
+ </head>
145
+ <body>
146
+ <div id="app">
147
+ <div v-if="loading">Loading...</div>
148
+ <div v-else-if="error">{{ error }}</div>
149
+ <div v-else class="content-wrapper">
150
+ <div class="sidebar" :class="{ 'open': sidebarOpen }" id="sidebar">
151
+ <div v-for="(apps, category) in appData" :key="category" class="category">
152
+ <div class="category-title" @click="toggleCategory">{{ category }}</div>
153
+ <div class="category-content">
154
+ <button v-for="app in apps" :key="app.name" @click="switchToApp(app.url)">{{ app.name }}</button>
155
+ </div>
156
+ </div>
157
+ <div class="user-info">
158
+ <div class="user-name">{{ userName }}</div>
159
+ <button class="logout-btn" @click="logout">Logout</button>
160
+ </div>
161
+ </div>
162
+
163
+ <button class="toggle-btn" @click="toggleSidebar">☰</button>
164
+ <iframe :src="currentPage" id="iframe" allowfullscreen allow="clipboard-read; clipboard-write" sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-downloads"></iframe>
165
+ </div>
166
+ </div>
167
+
168
+ <script>
169
+ const { createApp } = Vue;
170
+
171
+ const client = new Appwrite.Client();
172
+ client.setEndpoint('https://cloud.appwrite.io/v1')
173
+ .setProject('66c2f6c7000abed7f1f9');
174
+
175
+ const account = new Appwrite.Account(client);
176
+
177
+ const app = createApp({
178
+ data() {
179
+ return {
180
+ appData: {},
181
+ currentPage: '',
182
+ loading: true,
183
+ error: null,
184
+ sidebarOpen: false,
185
+ userName: ''
186
+ }
187
+ },
188
+ methods: {
189
+ async checkAuth() {
190
+ try {
191
+ console.log("Checking authentication");
192
+ const session = await account.getSession('current');
193
+ console.log("Session:", session);
194
+ return session;
195
+ } catch (error) {
196
+ console.error("Not authenticated", error);
197
+ return null;
198
+ }
199
+ },
200
+ redirectToLogin() {
201
+ console.log("Redirecting to login");
202
+ window.location.href = '/';
203
+ },
204
+ async checkAllowlist(email) {
205
+ try {
206
+ console.log("Checking allowlist for email:", email);
207
+ const response = await axios.post('http://127.0.0.1:8000/check-allowlist', { email });
208
+ console.log("Received response:", response.data);
209
+ if (response.data.allowed) {
210
+ console.log("Access allowed, setting app data");
211
+ this.appData = response.data.app_data;
212
+ this.currentPage = this.appData["Updated Tools"][0].url;
213
+ } else {
214
+ console.log("Access denied");
215
+ this.error = 'Access Denied: Your email is not on the allowlist.';
216
+ }
217
+ } catch (error) {
218
+ console.error("Error checking allowlist:", error);
219
+ this.error = 'An error occurred while checking access.';
220
+ } finally {
221
+ console.log("Setting loading to false");
222
+ this.loading = false;
223
+ }
224
+ },
225
+ toggleSidebar() {
226
+ this.sidebarOpen = !this.sidebarOpen;
227
+ },
228
+ toggleCategory(event) {
229
+ const content = event.target.nextElementSibling;
230
+ content.classList.toggle('show');
231
+ },
232
+ switchToApp(url) {
233
+ this.currentPage = url;
234
+ localStorage.setItem('currentPage', url);
235
+ this.toggleSidebar();
236
+ },
237
+ async logout() {
238
+ try {
239
+ await account.deleteSession('current');
240
+ this.redirectToLogin();
241
+ } catch (error) {
242
+ console.error("Error during logout:", error);
243
+ this.error = 'An error occurred during logout.';
244
+ }
245
+ }
246
+ },
247
+ async mounted() {
248
+ console.log("Component mounted");
249
+ const session = await this.checkAuth();
250
+ if (!session) {
251
+ this.redirectToLogin();
252
+ } else {
253
+ console.log("Getting user account");
254
+ const user = await account.get();
255
+ console.log("User:", user);
256
+ this.userName = user.name;
257
+ await this.checkAllowlist(user.email);
258
+ }
259
+ }
260
+ });
261
+
262
+ app.mount('#app');
263
+ </script>
264
+ </body>
265
+ </html>