horizon 左侧菜单加载
来源:互联网 发布:冰封三国杀淘宝 编辑:程序博客网 时间:2024/04/28 11:30
1.horizon/dashboard/nova settings syspanel/base.html中加载左侧菜单
{% block sidebar %}
{% include 'horizon/common/_sidebar.html' %}
{% endblock %}
2./horizon/templates/horizon/common/_sidebar.html 内容如下
{% load horizon i18n %}
<div class='sidebar'>
<h1 class="brand clearfix"><a href="{% url horizon:user_home %}">{% trans "OpenStack Dashboard" %}</a></h1>
{% horizon_main_nav %}
{% if request.horizon.dashboard.supports_tenants %}
<div id="tenant_switcher" class="dropdown switcher_bar" tabindex='1'>
<a class="dropdown-toggle" data-toggle="dropdown" href="#tenant_switcher">
<h4>{% trans "Project" %}</h4>
<h3>{{ request.user.tenant_name }}</h3>
</a>
<ul id="tenant_list" class="dropdown-menu">
<li class='divider'></li>
{% for tenant in authorized_tenants %}
{% if tenant.enabled %}
<li><a href="{% url horizon:auth_switch tenant.id %}">{{ tenant.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
{% horizon_dashboard_nav %}
</div>
解释:
1)、 {% horizon_main_nav %}
horizon/templatetags/horizon.py
@register.inclusion_tag('horizon/_nav_list.html', takes_context=True)
def horizon_main_nav(context):
horizon/templates/horizon/_nav_list.html
dashboards加载的文件(项目|管理者) 内容如下,由horizon\templatetags\horizon.py 中can_haz控制 。
{% load horizon i18n %}
<div class='clearfix'>
<ul class="nav nav-tabs">
{% for component in components %}
{% if user|can_haz:component %}
<li{% if current.slug == component.slug %} class="active"{% endif %}>
<a href="{{ component.get_absolute_url }}" tabindex='1'>{{ component.name }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
2)、{% horizon_dashboard_nav %}
horizon/templatetags/horizon.py
@register.inclusion_tag('horizon/_subnav_list.html', takes_context=True)
def horizon_dashboard_nav(context):
这里加载所有的模块,不管模块的panels.py中是否有roles = ("admin",)等。
看来权限不是这里控制的。
horizon/templates/horizon/_subnav_list.html
panels(菜单)加载的文件 由horizon\templatetags\horizon.py 中can_haz_list控制 。
{% load horizon %}
{% for heading, panels in components.iteritems %}
{% with panels|can_haz_list:user as filtered_panels %}
{% if filtered_panels %}
{% if heading %}<h4>{{ heading }}</h4>{% endif %}
<ul class="main_nav">
{% for panel in filtered_panels %}
<li>
<a href="{{ panel.get_absolute_url }}" {% if current == panel.slug %}class="active"{% endif %} tabindex='1'>{{ panel.name }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% endfor %}
3)、1) 2) 中间部分是看这个用户有几个tenant(项目),可以切换项目
- horizon 左侧菜单加载
- 左侧菜单加载过慢问题
- 左侧菜单
- horizon--权限菜单控制
- ajax实现点击左侧菜单,右侧加载不同网页
- C#——通过XML读取左侧菜单实现Extjs菜单动态加载
- 左侧导航菜单
- Prototype 左侧菜单
- 左侧栏显示菜单!!
- 后台管理菜单(左侧)
- jQuery左侧菜单效果
- 左侧树状菜单代码
- 实现左侧滑动菜单
- SlidingMenu 左侧滑动菜单
- 左侧菜单弹出
- 时尚的左侧菜单
- ecshop 添加左侧菜单
- ecshop左侧菜单修改
- linux命令之sync
- 露你的JavaScript技术很烂的五个表现
- 北大ACM2485 - Highways(最小生成树)
- 12种JavaScript MVC框架之比较
- C++11学习笔记(6) —— smart pointer: shared_ptr , auto_ptr
- horizon 左侧菜单加载
- USB gadget testing ---- New method
- 深入研究 C++中的 STL Deque 容器
- 可以让你少奋斗10年的工作经验
- JVM进阶系列一
- 如何组建软件测试团队
- 在Eclipse下搭建Android开发环境图文教程1
- 磁珠的作用
- Python uuid模块