diff --git a/frontend/src/components/AppSidebar.vue b/frontend/src/components/AppSidebar.vue
index cb22560f..03b4f6ec 100644
--- a/frontend/src/components/AppSidebar.vue
+++ b/frontend/src/components/AppSidebar.vue
@@ -8,7 +8,7 @@
:class="isSidebarCollapsed ? 'items-center' : ''"
>
-
+
{
socket.on('publish_lms_notifications', (data) => {
unreadNotifications.reload()
})
+
+ if (user) {
+ sidebarLinks.value.push({
+ label: 'Notifications',
+ icon: Bell,
+ to: 'Notifications',
+ activeFor: ['Notifications'],
+ count: unreadCount.value,
+ })
+ }
})
const unreadNotifications = createResource({
@@ -72,22 +83,40 @@ const unreadNotifications = createResource({
},
onSuccess(data) {
unreadCount.value = data
+ sidebarLinks.value = sidebarLinks.value.map((link) => {
+ if (link.label === 'Notifications') {
+ link.count = data
+ }
+ return link
+ })
},
- auto: true,
+ auto: user ? true : false,
})
-const sidebarLinks = computed(() => {
- const links = getSidebarLinks()
- if (user) {
- links.push({
- label: 'Notifications',
- icon: Bell,
- to: 'Notifications',
- activeFor: ['Notifications'],
- count: unreadCount.value,
+const sidebarSettings = createResource({
+ url: 'lms.lms.api.get_sidebar_settings',
+ cache: 'Sidebar Settings',
+ auto: true,
+ onSuccess(data) {
+ Object.keys(data).forEach((key) => {
+ if (!parseInt(data[key])) {
+ sidebarLinks.value = sidebarLinks.value.filter(
+ (link) => link.label.toLowerCase() !== key
+ )
+ }
})
- }
- return links
+ if (data.nav_items) {
+ data.nav_items.forEach((item) => {
+ sidebarLinks.value.push({
+ label: item.label,
+ icon: File,
+ to: item.url,
+ activeFor: [item.label],
+ })
+ })
+ }
+ console.log(data)
+ },
})
const getSidebarFromStorage = () => {
diff --git a/frontend/src/components/SidebarLink.vue b/frontend/src/components/SidebarLink.vue
index 37432a78..57cdafd3 100644
--- a/frontend/src/components/SidebarLink.vue
+++ b/frontend/src/components/SidebarLink.vue
@@ -14,7 +14,7 @@
@@ -55,7 +55,11 @@ const props = defineProps({
})
function handleClick() {
- router.push({ name: props.link.to })
+ if (props.link.to.includes('/')) {
+ window.location.href = props.link.to
+ } else {
+ router.push({ name: props.link.to })
+ }
}
let isActive = computed(() => {
diff --git a/lms/lms/api.py b/lms/lms/api.py
index 2a4e4f48..9b0e4cc6 100644
--- a/lms/lms/api.py
+++ b/lms/lms/api.py
@@ -416,3 +416,30 @@ def mark_all_as_read():
for notification in notifications:
mark_as_read(notification)
+
+
+@frappe.whitelist(allow_guest=True)
+def get_sidebar_settings():
+ lms_settings = frappe.get_single("LMS Settings")
+ sidebar_items = frappe._dict()
+
+ items = [
+ "courses",
+ "batches",
+ "certified_participants",
+ "jobs",
+ "statistics",
+ "notifications",
+ ]
+ for item in items:
+ sidebar_items[item] = lms_settings.get(item)
+
+ if lms_settings.show_navbar_items:
+ nav_items = frappe.get_all(
+ "Top Bar Item",
+ ["label", "url"],
+ {"parenttype": "Website Settings", "parentfield": "top_bar_items"},
+ )
+ sidebar_items.nav_items = nav_items
+
+ return sidebar_items
diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json
index 375f49aa..4801fd17 100644
--- a/lms/lms/doctype/lms_settings/lms_settings.json
+++ b/lms/lms/doctype/lms_settings/lms_settings.json
@@ -38,6 +38,17 @@
"column_break_12",
"cookie_policy",
"cookie_policy_page",
+ "sidebar_tab",
+ "items_in_sidebar_section",
+ "courses",
+ "batches",
+ "certified_participants",
+ "column_break_exdz",
+ "jobs",
+ "statistics",
+ "notifications",
+ "section_break_qlss",
+ "show_navbar_items",
"mentor_request_tab",
"mentor_request_section",
"mentor_request_creation",
@@ -349,18 +360,78 @@
"default": "0",
"fieldname": "show_day_view",
"fieldtype": "Check",
- "label": "Show Day View in Timetable"
+ "label": "Show day view in timetable"
},
{
"fieldname": "unsplash_access_key",
"fieldtype": "Data",
"label": "Unsplash Access Key"
+ },
+ {
+ "fieldname": "sidebar_tab",
+ "fieldtype": "Tab Break",
+ "label": "Sidebar"
+ },
+ {
+ "default": "1",
+ "fieldname": "courses",
+ "fieldtype": "Check",
+ "label": "Courses"
+ },
+ {
+ "default": "1",
+ "fieldname": "batches",
+ "fieldtype": "Check",
+ "label": "Batches"
+ },
+ {
+ "default": "1",
+ "fieldname": "certified_participants",
+ "fieldtype": "Check",
+ "label": "Certified Participants"
+ },
+ {
+ "default": "1",
+ "fieldname": "jobs",
+ "fieldtype": "Check",
+ "label": "Jobs"
+ },
+ {
+ "default": "1",
+ "fieldname": "statistics",
+ "fieldtype": "Check",
+ "label": "Statistics"
+ },
+ {
+ "default": "1",
+ "fieldname": "notifications",
+ "fieldtype": "Check",
+ "label": "Notifications"
+ },
+ {
+ "fieldname": "items_in_sidebar_section",
+ "fieldtype": "Section Break",
+ "label": "Items in Sidebar"
+ },
+ {
+ "fieldname": "column_break_exdz",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "section_break_qlss",
+ "fieldtype": "Section Break"
+ },
+ {
+ "default": "0",
+ "fieldname": "show_navbar_items",
+ "fieldtype": "Check",
+ "label": "Show Navbar Items"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2024-04-16 12:18:14.670978",
+ "modified": "2024-05-28 18:29:31.609637",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",
diff --git a/lms/lms/doctype/lms_sidebar_item/__init__.py b/lms/lms/doctype/lms_sidebar_item/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.js b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.js
new file mode 100644
index 00000000..be95d8a5
--- /dev/null
+++ b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2024, Frappe and contributors
+// For license information, please see license.txt
+
+// frappe.ui.form.on("LMS Sidebar Item", {
+// refresh(frm) {
+
+// },
+// });
diff --git a/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.json b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.json
new file mode 100644
index 00000000..e2df0640
--- /dev/null
+++ b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.json
@@ -0,0 +1,67 @@
+{
+ "actions": [],
+ "allow_rename": 1,
+ "creation": "2024-05-29 16:44:43.778291",
+ "doctype": "DocType",
+ "engine": "InnoDB",
+ "field_order": [
+ "web_page",
+ "route",
+ "column_break_glmh",
+ "title",
+ "icon"
+ ],
+ "fields": [
+ {
+ "fieldname": "column_break_glmh",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "icon",
+ "fieldtype": "Data",
+ "label": "Icon"
+ },
+ {
+ "fieldname": "web_page",
+ "fieldtype": "Link",
+ "label": "Web Page",
+ "options": "Web Page"
+ },
+ {
+ "fetch_from": "web_page.route",
+ "fieldname": "route",
+ "fieldtype": "Data",
+ "label": "Route"
+ },
+ {
+ "fetch_from": "web_page.title",
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "label": "Title"
+ }
+ ],
+ "index_web_pages_for_search": 1,
+ "links": [],
+ "modified": "2024-05-29 17:14:30.525055",
+ "modified_by": "Administrator",
+ "module": "LMS",
+ "name": "LMS Sidebar Item",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "share": 1,
+ "write": 1
+ }
+ ],
+ "sort_field": "creation",
+ "sort_order": "DESC",
+ "states": []
+}
\ No newline at end of file
diff --git a/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.py b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.py
new file mode 100644
index 00000000..96a35079
--- /dev/null
+++ b/lms/lms/doctype/lms_sidebar_item/lms_sidebar_item.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2024, Frappe and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+
+class LMSSidebarItem(Document):
+ pass
diff --git a/lms/lms/doctype/lms_sidebar_item/test_lms_sidebar_item.py b/lms/lms/doctype/lms_sidebar_item/test_lms_sidebar_item.py
new file mode 100644
index 00000000..2747cc91
--- /dev/null
+++ b/lms/lms/doctype/lms_sidebar_item/test_lms_sidebar_item.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2024, Frappe and Contributors
+# See license.txt
+
+# import frappe
+from frappe.tests.utils import FrappeTestCase
+
+
+class TestLMSSidebarItem(FrappeTestCase):
+ pass
diff --git a/lms/lms/utils.py b/lms/lms/utils.py
index 48b3e1ff..46b57492 100644
--- a/lms/lms/utils.py
+++ b/lms/lms/utils.py
@@ -646,7 +646,8 @@ def handle_notifications(doc, method):
def create_notification_log(doc, topic):
users = []
- if topic.reference_doctype == "LMS Course":
+ print(topic.reference_doctype == "Course Lesson")
+ if topic.reference_doctype == "Course Lesson":
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
course_title = frappe.db.get_value("LMS Course", course, "title")
instructors = frappe.db.get_all(
@@ -689,7 +690,7 @@ def notify_mentions_on_portal(doc, topic):
from_user_name = get_fullname(doc.owner)
- if topic.reference_doctype == "LMS Course":
+ if topic.reference_doctype == "Course Lesson":
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
subject = _("{0} mentioned you in a comment in {1}").format(
from_user_name, topic.title
diff --git a/lms/patches.txt b/lms/patches.txt
index 923b906c..0c9109ac 100644
--- a/lms/patches.txt
+++ b/lms/patches.txt
@@ -88,4 +88,5 @@ lms.patches.v1_0.rename_evaluator_role
lms.patches.v1_0.change_navbar_urls
lms.patches.v1_0.set_published_on
lms.patches.v2_0.fix_progress_percentage
-lms.patches.v2_0.add_discussion_topic_titles
\ No newline at end of file
+lms.patches.v2_0.add_discussion_topic_titles
+lms.patches.v2_0.sidebar_settings
\ No newline at end of file
diff --git a/lms/patches/v2_0/sidebar_settings.py b/lms/patches/v2_0/sidebar_settings.py
new file mode 100644
index 00000000..d17dd244
--- /dev/null
+++ b/lms/patches/v2_0/sidebar_settings.py
@@ -0,0 +1,15 @@
+import frappe
+
+
+def execute():
+ fields = [
+ "courses",
+ "batches",
+ "certified_participants",
+ "jobs",
+ "statistics",
+ "notifications",
+ ]
+
+ for field in fields:
+ frappe.db.set_single_value("LMS Settings", field, 1)
diff --git a/lms/public/frontend/index.html b/lms/public/frontend/index.html
index 558e94fc..c9610df4 100644
--- a/lms/public/frontend/index.html
+++ b/lms/public/frontend/index.html
@@ -15,7 +15,7 @@
-
+