rr19tech commited on
Commit
83ff3fe
·
verified ·
1 Parent(s): adff1a3

Updated index.html with login logic

Browse files
Files changed (1) hide show
  1. index.html +37 -28
index.html CHANGED
@@ -17,15 +17,15 @@
17
  <div class="login-card">
18
 
19
  <div id="login-section">
20
- <span>Login Coming Soon ..</span><br>
21
- <input type="email" id="email" placeholder="Email" required size="28" disabled><br>
22
- <input type="password" id="password" placeholder="Password" required size="28" disabled><br>
23
- <button onclick="doLogin()" disabled>Sign In</button>
24
  </div>
25
  <div id="user-section" class="hidden">
26
  <!--<span>Welcome!</span><br>-->
27
  <p id="user-email"></p>
28
- <button onclick="doLogout()" style="background: #f44336;" disabled>Logout</button>
29
  </div>
30
  <p id="message"></p>
31
  </div>
@@ -48,7 +48,7 @@
48
 
49
  <div class="tabs">
50
 
51
- <button disabled class="tab-link" onclick="openTab(event, 'Plnb')"><span class="tab-heading">NUTRITION</span></button>
52
  <button class="tab-link" onclick="openTab(event, 'Hcs')"><span class="tab-heading">CAKES</span></button>
53
  <button class="tab-link" onclick="openTab(event, 'Jobs')"><span class="tab-heading">JOB-POSTINGS</span></button>
54
  <button class="tab-link" onclick="openTab(event, 'Training')"><span class="tab-heading">TRAINING</span></button>
@@ -59,8 +59,8 @@
59
  <button class="tab-link" onclick="openTab(event, 'About')"><span class="tab-heading">ABOUT</span></button>
60
 
61
  </div>
62
- <!--
63
- <div id="Plnb" class="tab-content">
64
  <h4>Project LeanNation </h4>
65
  <table >
66
  <tr>
@@ -75,17 +75,15 @@
75
  convenient, and sustainable for busy professionals.<br>
76
  These are great ways to sample meals, try protein snacks, and learn more about the nutrition program in a fun, low-pressure setting.<br>
77
  We would love to connect you with Shweta and explore potential wellness initiatives for your teams!<br>
78
- Please use the link to avial the introductary founding member discounts, <a href="https://pln.fit/e/M-ARUN" alt="Singup link" target="_blank" rel="noopener noreferrer">Signup</a>
79
  <br> If you're open to it, we would be happy to make an introduction.
80
  </p>
81
  </td>
82
- <td>
83
- <img src="images/QR_PLNB.png" height="150" width="150" style="background-position: top right;"></img>
84
- </td>
85
  </tr>
86
  </table>
87
  </div>
88
- -->
89
 
90
  <div id="Hcs" class="tab-content">
91
  <h4>Harshali Custom Cake Shop</h4>
@@ -123,7 +121,7 @@
123
  <p>Postings from known recruiters will be posted here!</p>
124
  </div>
125
 
126
- <div id="Training" class="tab-content">
127
  <h4>Training</h4>
128
  <p>
129
  We are extremely happy to introduce Apache Cassandra training offered by Sarma on Udemy. <br>
@@ -140,7 +138,7 @@
140
  </p>
141
  </div>
142
 
143
- <div id="Portfolio" class="tab-content">
144
  <h4>Projects Yard</h4>
145
  <p>
146
  We are very excited to introduce <a href="https://www.projectsyard.com" target="_blank" rel="noopener noreferrer"" alt="Projects Yard">Projects Yard</a>.
@@ -163,6 +161,7 @@
163
  </div>
164
 
165
  <div id="Nature" class="tab-content">
 
166
  <h4>Nature</h4>
167
  <p>
168
  Every <span class="fallen-leaf">leaf</span> holds a tiny story, a silent promise of growth and life. <br>
@@ -177,6 +176,7 @@
177
  <br>
178
  If you like to hear more, we would be happy to guide you through.
179
  </p>
 
180
  </div>
181
 
182
  <div id="About" class="tab-content">
@@ -257,7 +257,7 @@
257
  console.log("Result:", result.data);
258
  return result.data;
259
  }
260
-
261
  const consoleArea = document.getElementById('console');
262
  const assistantAvatar = document.getElementById('net-ai');
263
  const chatBubble = document.getElementById('net');
@@ -361,6 +361,7 @@
361
  }
362
  postAdv();//posting it one time
363
  const intervalId = setInterval(postAdv, 300000);
 
364
  function get_api_results(result, container, api_method){
365
  callGradioAPI(result, api_method)
366
  .then(data => {
@@ -461,7 +462,7 @@
461
  }
462
  }
463
 
464
-
465
  </script>
466
 
467
  <script>
@@ -481,12 +482,18 @@
481
 
482
  try {
483
  // 3. Authenticate
484
- await pb.collection('users').authWithPassword(email, pass);
485
- message.innerText = "Login successful!";
486
- // Redirect the user to a custom page
487
- window.location.href = './NetworkTest.html';
488
- message.style.color = "green";
489
- updateUI();
 
 
 
 
 
 
490
  } catch (err) {
491
  message.innerText = "Error: " + err.message;
492
  message.style.color = "red";
@@ -497,7 +504,7 @@
497
  pb.authStore.clear();
498
  updateUI();
499
  // Redirect the user to a custom page
500
- window.location.href = './Client_Demo.html';
501
  message.innerText = "Logged out.";
502
  }
503
 
@@ -513,17 +520,19 @@
513
  }
514
 
515
  async function loadArticles() {
516
-
517
  try {
518
  // Fetch records. API rules enforce that only 'published' items return.
519
- const records = await pb.collection('articles').getFullList({
520
  sort: '-created',
521
  });
522
  if (records.length === 0) {
523
  console.log("No records");
524
  return;
525
  }
526
- records.map(article => {console.log(article.content);});
 
 
527
  }
528
  catch (error) {
529
  console.error('Failed to load articles:', error);
@@ -532,7 +541,7 @@
532
 
533
  }
534
 
535
- loadArticles();
536
  //console.log("Articles are: " + articles);
537
  </script>
538
 
 
17
  <div class="login-card">
18
 
19
  <div id="login-section">
20
+ <span>Business Login</span><br>
21
+ <input type="email" id="email" placeholder="Email" required size="28" ><br>
22
+ <input type="password" id="password" placeholder="Password" required size="28" ><br>
23
+ <button onclick="doLogin()" >Sign In</button>
24
  </div>
25
  <div id="user-section" class="hidden">
26
  <!--<span>Welcome!</span><br>-->
27
  <p id="user-email"></p>
28
+ <button onclick="doLogout()" style="background: #f44336;" >Logout</button>
29
  </div>
30
  <p id="message"></p>
31
  </div>
 
48
 
49
  <div class="tabs">
50
 
51
+ <button class="tab-link" onclick="openTab(event, 'Plnb')"><span class="tab-heading">NUTRITION</span></button>
52
  <button class="tab-link" onclick="openTab(event, 'Hcs')"><span class="tab-heading">CAKES</span></button>
53
  <button class="tab-link" onclick="openTab(event, 'Jobs')"><span class="tab-heading">JOB-POSTINGS</span></button>
54
  <button class="tab-link" onclick="openTab(event, 'Training')"><span class="tab-heading">TRAINING</span></button>
 
59
  <button class="tab-link" onclick="openTab(event, 'About')"><span class="tab-heading">ABOUT</span></button>
60
 
61
  </div>
62
+
63
+ <div id="Plnb" class="tab-content" inert class="disabled-div">
64
  <h4>Project LeanNation </h4>
65
  <table >
66
  <tr>
 
75
  convenient, and sustainable for busy professionals.<br>
76
  These are great ways to sample meals, try protein snacks, and learn more about the nutrition program in a fun, low-pressure setting.<br>
77
  We would love to connect you with Shweta and explore potential wellness initiatives for your teams!<br>
78
+
79
  <br> If you're open to it, we would be happy to make an introduction.
80
  </p>
81
  </td>
82
+
 
 
83
  </tr>
84
  </table>
85
  </div>
86
+
87
 
88
  <div id="Hcs" class="tab-content">
89
  <h4>Harshali Custom Cake Shop</h4>
 
121
  <p>Postings from known recruiters will be posted here!</p>
122
  </div>
123
 
124
+ <div id="Training" class="tab-content" inert class="disabled-div">
125
  <h4>Training</h4>
126
  <p>
127
  We are extremely happy to introduce Apache Cassandra training offered by Sarma on Udemy. <br>
 
138
  </p>
139
  </div>
140
 
141
+ <div id="Portfolio" class="tab-content" inert class="disabled-div">
142
  <h4>Projects Yard</h4>
143
  <p>
144
  We are very excited to introduce <a href="https://www.projectsyard.com" target="_blank" rel="noopener noreferrer"" alt="Projects Yard">Projects Yard</a>.
 
161
  </div>
162
 
163
  <div id="Nature" class="tab-content">
164
+
165
  <h4>Nature</h4>
166
  <p>
167
  Every <span class="fallen-leaf">leaf</span> holds a tiny story, a silent promise of growth and life. <br>
 
176
  <br>
177
  If you like to hear more, we would be happy to guide you through.
178
  </p>
179
+
180
  </div>
181
 
182
  <div id="About" class="tab-content">
 
257
  console.log("Result:", result.data);
258
  return result.data;
259
  }
260
+ /**
261
  const consoleArea = document.getElementById('console');
262
  const assistantAvatar = document.getElementById('net-ai');
263
  const chatBubble = document.getElementById('net');
 
361
  }
362
  postAdv();//posting it one time
363
  const intervalId = setInterval(postAdv, 300000);
364
+
365
  function get_api_results(result, container, api_method){
366
  callGradioAPI(result, api_method)
367
  .then(data => {
 
462
  }
463
  }
464
 
465
+ **/
466
  </script>
467
 
468
  <script>
 
482
 
483
  try {
484
  // 3. Authenticate
485
+ //await pb.collection('users').authWithPassword(email, pass);
486
+ const authData = await pb.collection('users').authWithPassword(email, pass);
487
+ //get the role
488
+ const userRole = authData.record.role;
489
+ console.log("User Role is: " + userRole);
490
+ if (userRole == "writer"){
491
+ message.innerText = "Login successful!";
492
+ // Redirect the user to a custom page
493
+ window.location.href = './Nature_Articles.html';
494
+ message.style.color = "green";
495
+ updateUI();
496
+ }
497
  } catch (err) {
498
  message.innerText = "Error: " + err.message;
499
  message.style.color = "red";
 
504
  pb.authStore.clear();
505
  updateUI();
506
  // Redirect the user to a custom page
507
+ window.location.href = './index.html';
508
  message.innerText = "Logged out.";
509
  }
510
 
 
520
  }
521
 
522
  async function loadArticles() {
523
+ const natureContainer = document.getElementById("Nature");
524
  try {
525
  // Fetch records. API rules enforce that only 'published' items return.
526
+ const records = await pb.collection('nature_posts').getFullList({
527
  sort: '-created',
528
  });
529
  if (records.length === 0) {
530
  console.log("No records");
531
  return;
532
  }
533
+ const articles = records.map(article => {console.log(article.short_summary); return article.full_text;});
534
+ console.log("Total articles: " + records.length);
535
+ //natureContainer.innerHTML = articles;
536
  }
537
  catch (error) {
538
  console.error('Failed to load articles:', error);
 
541
 
542
  }
543
 
544
+ //loadArticles();
545
  //console.log("Articles are: " + articles);
546
  </script>
547