Move active user profile halo check into nav pane macro on web app

This commit is contained in:
Debanjum Singh Solanky 2023-11-09 18:05:19 -08:00
parent ddac693762
commit 841ed95521
5 changed files with 27 additions and 13 deletions

View file

@ -15,7 +15,7 @@
<!--Add Header Logo and Nav Pane--> <!--Add Header Logo and Nav Pane-->
{% import 'utils.html' as utils %} {% import 'utils.html' as utils %}
{{ utils.heading_pane(user_photo, username) }} {{ utils.heading_pane(user_photo, username, is_active) }}
<div class="filler"></div> <div class="filler"></div>
</div> </div>
@ -26,9 +26,6 @@
</body> </body>
<script> <script>
document.getElementById("settings-nav").classList.add("khoj-nav-selected"); document.getElementById("settings-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script> </script>
<style> <style>
html, body { html, body {

View file

@ -363,7 +363,7 @@
<!--Add Header Logo and Nav Pane--> <!--Add Header Logo and Nav Pane-->
{% import 'utils.html' as utils %} {% import 'utils.html' as utils %}
{{ utils.heading_pane(user_photo, username) }} {{ utils.heading_pane(user_photo, username, is_active) }}
<!-- Chat Body --> <!-- Chat Body -->
<div id="chat-body"></div> <div id="chat-body"></div>
@ -376,9 +376,6 @@
</body> </body>
<script> <script>
document.getElementById("chat-nav").classList.add("khoj-nav-selected"); document.getElementById("chat-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script> </script>
<style> <style>
html, body { html, body {

View file

@ -272,7 +272,7 @@
<body> <body>
<!--Add Header Logo and Nav Pane--> <!--Add Header Logo and Nav Pane-->
{% import 'utils.html' as utils %} {% import 'utils.html' as utils %}
{{ utils.heading_pane(user_photo, username) }} {{ utils.heading_pane(user_photo, username, is_active) }}
<!--Add Text Box To Enter Query, Trigger Incremental Search OnChange --> <!--Add Text Box To Enter Query, Trigger Incremental Search OnChange -->
<input type="text" id="query" class="option" onkeyup=incrementalSearch(event) autofocus="autofocus" placeholder="Search your knowledge base using natural language"> <input type="text" id="query" class="option" onkeyup=incrementalSearch(event) autofocus="autofocus" placeholder="Search your knowledge base using natural language">
@ -287,9 +287,6 @@
</body> </body>
<script> <script>
document.getElementById("search-nav").classList.add("khoj-nav-selected"); document.getElementById("search-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script> </script>
<style> <style>

View file

@ -1,4 +1,4 @@
{% macro heading_pane(user_photo, username) -%} {% macro heading_pane(user_photo, username, is_active) -%}
<div class="khoj-header"> <div class="khoj-header">
<a class="khoj-logo" href="/" target="_blank"> <a class="khoj-logo" href="/" target="_blank">
<img class="khoj-logo" src="/static/assets/icons/khoj-logo-sideways-500.png" alt="Khoj"></img> <img class="khoj-logo" src="/static/assets/icons/khoj-logo-sideways-500.png" alt="Khoj"></img>
@ -9,9 +9,17 @@
<!-- Dropdown Menu --> <!-- Dropdown Menu -->
<div id="khoj-nav-menu-container" class="khoj-nav dropdown"> <div id="khoj-nav-menu-container" class="khoj-nav dropdown">
{% if user_photo and user_photo != "None" %} {% if user_photo and user_photo != "None" %}
{% if is_active %}
<img id="profile-picture" class="circle subscribed" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer">
{% else %}
<img id="profile-picture" class="circle" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer"> <img id="profile-picture" class="circle" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer">
{% endif %}
{% else %} {% else %}
{% if is_active %}
<div id="profile-picture" class="circle user-initial subscribed" alt="{{ username[0].upper() }}" onclick="toggleMenu()">{{ username[0].upper() }}</div> <div id="profile-picture" class="circle user-initial subscribed" alt="{{ username[0].upper() }}" onclick="toggleMenu()">{{ username[0].upper() }}</div>
{% else %}
<div id="profile-picture" class="circle user-initial" alt="{{ username[0].upper() }}" onclick="toggleMenu()">{{ username[0].upper() }}</div>
{% endif %}
{% endif %} {% endif %}
<div id="khoj-nav-menu" class="khoj-nav-dropdown-content"> <div id="khoj-nav-menu" class="khoj-nav-dropdown-content">
<div class="khoj-nav-username"> {{ username }} </div> <div class="khoj-nav-username"> {{ username }} </div>

View file

@ -37,6 +37,8 @@ templates = Jinja2Templates(directory=constants.web_directory)
def index(request: Request): def index(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
return templates.TemplateResponse( return templates.TemplateResponse(
"chat.html", "chat.html",
@ -44,6 +46,7 @@ def index(request: Request):
"request": request, "request": request,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -53,6 +56,8 @@ def index(request: Request):
def index_post(request: Request): def index_post(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
return templates.TemplateResponse( return templates.TemplateResponse(
"chat.html", "chat.html",
@ -60,6 +65,7 @@ def index_post(request: Request):
"request": request, "request": request,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -170,6 +176,8 @@ def config_page(request: Request):
def github_config_page(request: Request): def github_config_page(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
current_github_config = get_user_github_config(user) current_github_config = get_user_github_config(user)
if current_github_config: if current_github_config:
@ -198,6 +206,7 @@ def github_config_page(request: Request):
"current_config": current_config, "current_config": current_config,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -207,6 +216,8 @@ def github_config_page(request: Request):
def notion_config_page(request: Request): def notion_config_page(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
current_notion_config = get_user_notion_config(user) current_notion_config = get_user_notion_config(user)
current_config = NotionContentConfig( current_config = NotionContentConfig(
@ -222,6 +233,7 @@ def notion_config_page(request: Request):
"current_config": current_config, "current_config": current_config,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -231,6 +243,8 @@ def notion_config_page(request: Request):
def computer_config_page(request: Request): def computer_config_page(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
return templates.TemplateResponse( return templates.TemplateResponse(
"content_source_computer_input.html", "content_source_computer_input.html",
@ -238,5 +252,6 @@ def computer_config_page(request: Request):
"request": request, "request": request,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )