UI Improvements: Added Custom Navbar

This commit is contained in:
scmmishra 2018-12-10 18:35:27 +05:30 committed by Aditya Hase
parent 87df23b52d
commit d02fd13bf0
5 changed files with 110 additions and 4 deletions

View File

@ -170,11 +170,9 @@ default_roles = [
]
role_home_page = {
"LMS User": "`lms`"
"LMS User": "/lms"
}
# get_website_user_home_page = "erpnext.education.utils.get_home_page"
has_website_permission = {
"Sales Order": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",

View File

@ -0,0 +1,84 @@
<template>
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<router-link tag="a" :class="'navbar-brand'" :to="{name: 'home'}">
<span>{{ portal.title }}</span>
</router-link>
<button class="navbar-toggler mr-3" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse mx-3" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
</ul>
<ul class="navbar-nav ml-auto justify-content-end">
<!-- post login tools -->
<li class="nav-item dropdown hide" id="website-post-login" data-label="website-post-login" style="display: none">
<li v-if="isLogin" class="nav-item dropdown" id="website-post-login" data-label="website-post-login"
style="">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
<span class="user-image-wrapper"><span class="avatar avatar-small" :title="fullName">
<span class="avatar-frame" :style="avatarStyle"
:title="fullName"></span>
</span></span>
<span class="full-name">{{ fullName }}</span>
<b class="caret"></b>
</a>
<div class="dropdown-menu" role="menu">
<router-link tag="a" :class="'dropdown-item'" :to="{name: 'profile'}">
My Profile
</router-link>
<router-link tag="a" :class="'dropdown-item'" :to="{name: 'logout'}">
Logout
</router-link>
</div>
</li>
<li v-else class="nav-item">
<router-link tag="a" :class="'nav-link'" :to="{name: 'login'}">
Login
</router-link>
</li>
<li class="nav-item btn-login-area" style="display: none;"><a class="nav-link" href="/login">Login</a></li>
</ul>
</div>
</div>
</nav>
</template>
<script>
export default {
name: "Home",
data() {
return{
portal: {},
avatar: frappe.get_cookie("user_image"),
fullName: frappe.get_cookie("full_name"),
isLogin: frappe.is_user_logged_in()
}
},
mounted() {
this.getPortalDetails().then(data => this.portal = data);
},
methods: {
getPortalDetails() {
return lms.call("get_portal_details")
}
},
computed: {
avatarStyle() {
return `background-image: url("${this.avatar}")`
},
// isLogin() {
// return frappe.is_user_logged_in()
// },
}
};
</script>
<style scoped>
a {
text-decoration: none;
}
</style>

View File

@ -1,10 +1,15 @@
<template>
<div id="lms-root">
<navbar></navbar>
<router-view :key="$route.fullPath"></router-view>
</div>
</template>
<script>
import Navbar from "./components/Navbar.vue"
export default {
name: "lmsRoot",
components: {
Navbar
}
};
</script>
</script>

View File

@ -48,6 +48,24 @@ const routes = [{
component: Home,
props: true
},
{
name: 'login',
path: '/Login',
beforeEnter(to, from, next) {
window.location = window.location.origin.toString() + '/login#login'
},
component: Home,
props: true
},
{
name: 'logout',
path: '/Logout',
beforeEnter(to, from, next) {
window.location = window.location.origin.toString() + '/?cmd=web_logout'
},
component: Home,
props: true
},
{
name: 'profile',
path: '/Profile',

View File

@ -2,6 +2,7 @@
{% block title %}{{ heading or "LMS"}}{% endblock %}
{% block navbar %}{% endblock %}
{% block page_content %}
<div id="lms-app"></div>
<script type="text/javascript" src="/assets/js/lms.min.js"></script>