skeletal framework for non-admin dashboard
This commit is contained in:
parent
2d5c128fab
commit
7cefa0f084
11
django-openstack/src/django_openstack/auth/urls.py
Normal file
11
django-openstack/src/django_openstack/auth/urls.py
Normal file
@ -0,0 +1,11 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
urlpatterns = patterns('django_openstack.auth.views',
|
||||
url(r'login/$', 'login', name='auth_login'),
|
||||
url(r'logout/$', 'logout', name='auth_logout'),
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ from django_openstack.nova import forms as nova_forms
|
||||
from openstackx.api import exceptions as api_exceptions
|
||||
|
||||
|
||||
def token(request):
|
||||
def login(request):
|
||||
if request.method == 'POST':
|
||||
form = nova_forms.Login(request.POST)
|
||||
if form.is_valid():
|
||||
@ -24,9 +24,9 @@ def token(request):
|
||||
request.session['admin'] = info['admin']
|
||||
|
||||
if request.session['admin']:
|
||||
return shortcuts.redirect('syspanel_overview')
|
||||
return shortcuts.redirect('admin_overview')
|
||||
else:
|
||||
return shortcuts.redirect('nova_overview')
|
||||
return shortcuts.redirect('user_overview')
|
||||
|
||||
except api_exceptions.Unauthorized as e:
|
||||
messages.error(request, 'Error authenticating: %s' % e.message)
|
||||
@ -61,7 +61,7 @@ def switch_tenants(request, tenant_id):
|
||||
},context_instance=template.RequestContext(request))
|
||||
|
||||
|
||||
def destroy_token(request):
|
||||
def logout(request):
|
||||
request.session.clear()
|
||||
return shortcuts.redirect('novaO_instances')
|
||||
|
18
django-openstack/src/django_openstack/dash/urls.py
Normal file
18
django-openstack/src/django_openstack/dash/urls.py
Normal file
@ -0,0 +1,18 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
from django.conf import settings
|
||||
|
||||
urlpatterns = patterns('django_openstack.dash.views.instances',
|
||||
url(r'^(?P<tenant_id>[^/]+)/instances', 'index', name='dash_instances'),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('django_openstack.dash.views.images',
|
||||
url(r'^(?P<tenant_id>[^/]+)/images/$', 'index', name='dash_images'),
|
||||
url(r'^(?P<tenant_id>[^/]+)/images/upload/$',
|
||||
'upload',
|
||||
name='dash_images_upload'),
|
||||
url(r'^(?P<tenant_id>[^/]+)/images/(?P<image_id>[^/]+)/launch/$',
|
||||
'launch',
|
||||
name='dash_images_launch'),
|
||||
)
|
@ -63,14 +63,9 @@ def _image_lists(images, tenant_id):
|
||||
@handle_nova_error
|
||||
def index(request, tenant_id):
|
||||
tenant = api.get_tenant(request, request.user.tenant)
|
||||
logging.info('TENANT: %s', tenant)
|
||||
#project = shortcuts.get_project_or_404(request, project_id)
|
||||
images = api.glance_api(request).get_images_detailed()
|
||||
logging.info('IMAGES: %s', images)
|
||||
|
||||
return render_to_response('django_openstack/nova/images/index.html', {
|
||||
'form': nova_forms.LaunchForm(),
|
||||
#'region': project.region,
|
||||
return render_to_response('dash_images.html', {
|
||||
'tenant': tenant,
|
||||
'image_lists': _image_lists(images, request.user.tenant),
|
||||
}, context_instance=template.RequestContext(request))
|
||||
@ -138,6 +133,18 @@ def detail(request, tenant_id, image_id):
|
||||
'image': image,
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@handle_nova_error
|
||||
def upload(request, tenant_id):
|
||||
tenant = api.get_tenant(request, request.user.tenant)
|
||||
return render_to_response('dash_upload.html', {
|
||||
'form': None, #nova_forms.UploadForm(),
|
||||
'tenant': tenant,
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# TODO(termie): below = NotImplemented
|
||||
|
@ -47,12 +47,8 @@ LOG = logging.getLogger('django_openstack.nova')
|
||||
def index(request, tenant_id):
|
||||
tenant = api.get_tenant(request, request.user.tenant)
|
||||
instances = api.compute_api(request).servers.list()
|
||||
logging.info('instances: %s', instances)
|
||||
#instances = sorted(project.get_instances(),
|
||||
# key=lambda k: k.public_dns_name)
|
||||
|
||||
return render_to_response('django_openstack/nova/instances/index.html', {
|
||||
#'region': project.region,
|
||||
return render_to_response('dash_instances.html', {
|
||||
'tenant': tenant,
|
||||
'instances': instances,
|
||||
'detail': False,
|
@ -1,4 +1,4 @@
|
||||
<form action="{% url auth_token %}" method="post">
|
||||
<form action="{% url auth_login %}" method="post">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
{% for hidden in form.hidden_fields %}
|
||||
|
10
django-openstack/src/django_openstack/urls.py
Normal file
10
django-openstack/src/django_openstack/urls.py
Normal file
@ -0,0 +1,10 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
from django.conf import settings
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^auth/', include('django_openstack.auth.urls')),
|
||||
url(r'^dash/', include('django_openstack.dash.urls')),
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
SIDEBAR
|
||||
<a href="{% url dash_instances request.user.tenant %}">instances</a>
|
||||
<a href="{% url dash_images request.user.tenant %}">images</a>
|
1
openstack-dashboard/dashboard/templates/_footer.html
Normal file
1
openstack-dashboard/dashboard/templates/_footer.html
Normal file
@ -0,0 +1 @@
|
||||
FOOTER
|
1
openstack-dashboard/dashboard/templates/_header.html
Normal file
1
openstack-dashboard/dashboard/templates/_header.html
Normal file
@ -0,0 +1 @@
|
||||
HEADER
|
1
openstack-dashboard/dashboard/templates/_image_list.html
Normal file
1
openstack-dashboard/dashboard/templates/_image_list.html
Normal file
@ -0,0 +1 @@
|
||||
IMAGE_LIST
|
@ -0,0 +1 @@
|
||||
INSTANCE_LIST
|
1
openstack-dashboard/dashboard/templates/_topbar.html
Normal file
1
openstack-dashboard/dashboard/templates/_topbar.html
Normal file
@ -0,0 +1 @@
|
||||
TOPBAR
|
1
openstack-dashboard/dashboard/templates/_upload.html
Normal file
1
openstack-dashboard/dashboard/templates/_upload.html
Normal file
@ -0,0 +1 @@
|
||||
UPLOAD_FORM
|
6
openstack-dashboard/dashboard/templates/admin_base.html
Normal file
6
openstack-dashboard/dashboard/templates/admin_base.html
Normal file
@ -0,0 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block topbar %}{% endblock %}
|
||||
{% block sidebar %}{% endblock %}
|
||||
{% block main %}{% endblock %}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{% extends 'admin_base.html' %}
|
||||
|
||||
{# default landing page for a admin user #}
|
||||
{# nav bar on top, sidebar, overview info in main #}
|
@ -1,59 +1,83 @@
|
||||
{% load branding i18n %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xml:lang="en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
||||
<title>{% site_branding %} Dashboard{% block title %}{% endblock %}{% block subtitle %}{% endblock %}</title>
|
||||
<link rel="stylesheet" type="text/css" href="/media/dashboard/css/openstack.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/media/dashboard/css/cupertino/jquery-ui-1.7.2.custom.css"/>
|
||||
{% block headercss %}{% endblock %}
|
||||
<!--[if IE 7]><link rel="stylesheet" href="/media/dashboard/css/ie7.css" type="text/css" media="screen, projection"><![endif]-->
|
||||
|
||||
<script type="text/javascript" src="/media/dashboard/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="/media/dashboard/js/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="/media/dashboard/js/dashboard.js"></script>
|
||||
|
||||
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
||||
<title>OpenStack Dashboard{% block title %}{% endblock %}</title>
|
||||
<script charset='utf-8' src='/media/dashboard/js/jquery.min.js' type='text/javascript'></script>
|
||||
<script charset='utf-8' src='/media/dashboard/js/jquery-ui.min.js' type='text/javascript'></script>
|
||||
<script charset='utf-8' src='/media/dashboard/js/jquery.quicksearch.js' type='text/javascript'></script>
|
||||
<script charset='utf-8' src='/media/dashboard/js/jquery.example.min.js' type='text/javascript'></script>
|
||||
<script charset='utf-8' src='/media/dashboard/js/form_examples.js' type='text/javascript'></script>
|
||||
<script charset='utf-8' src='/media/dashboard/js/application.js' type='text/javascript'></script>
|
||||
<link href='/media/dashboard/css/style.css' media='screen' rel='stylesheet' />
|
||||
{% block headerjs %}{% endblock %}
|
||||
{% block headercss %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="header">
|
||||
<h1><a href="/">{% site_branding %}<span> Cloud Computing</span></a></h1>
|
||||
{% if request.user.is_authenticated %}
|
||||
<div id="user_info">
|
||||
<span class="user">{% trans "Signed in as" %} <strong>{{ request.user.username }}</strong>.</span>
|
||||
<ul>
|
||||
<li><a id="lnk_logout" href="{% url auth_logout %}">{% trans "Sign Out"%}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="user_info">
|
||||
<a id="lnk_login" href="{% url auth_token %}">{% trans "Sign In"%}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id='wrapper'>
|
||||
<div id='header'>
|
||||
<h1><a href='{% url index %}'>OpenStack Dashboard</a></h1>
|
||||
<ul id="main_nav">
|
||||
{% block main_nav %}
|
||||
<li><a {% if navigation_selected == "dash" %} class="active" {% endif %} href="{% url nova_overview %}">User Dashboard</a></li>
|
||||
{% if current_user.is_admin %}
|
||||
<li><a {% if navigation_selected == "syspanel" %} class="active" {% endif %} href="{% url syspanel_overview %}">Admin Syspanel</a></li>
|
||||
{% endif %}
|
||||
{% endblock main_nav %}
|
||||
</ul>
|
||||
|
||||
<div id="content_wrap">
|
||||
{% block sidebar %}{% endblock %}
|
||||
{% block region %}{% endblock %}
|
||||
<div id="content" class="{% block pageclass %}{% endblock %}">
|
||||
{% block rootcontent %}{% endblock %}
|
||||
</div><!-- end content -->
|
||||
</div>
|
||||
<div id="login_box">
|
||||
{{media_url}}
|
||||
{% if not request.user %}
|
||||
<a id="login_btn" class="large-rounded" href="#">Login</a>
|
||||
<div class='large-rounded' id='login'>
|
||||
|
||||
<div id="footer">
|
||||
<div class="sitemap">
|
||||
<div class="sub">
|
||||
<a href="{% url index %}">Dashboard</a>
|
||||
<ul>
|
||||
<li><a href="{% url index %}">Home</a></li>
|
||||
</ul>
|
||||
<form accept-charset='utf-8' action='{% url auth_login %}' method='post'>
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
<label for='tenant'>Tenant</label>
|
||||
<input class='small-rounded' id='tenant' name='tenant' type='text' value='1234' />
|
||||
<label for='username'>Username</label>
|
||||
<input class='small-rounded' id='username' name='username' type='text' value='joeuser' />
|
||||
<label for='password'>Password</label>
|
||||
<input class='small-rounded' id='password' name='password' type='text' value='secrete' />
|
||||
<input class='small-rounded' type='submit' value='Login' />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="logged_in">
|
||||
<div id="user_bar">
|
||||
<a id="current_tenant" href="{% url nova_overview %}">
|
||||
<h4>{{ request.user.tenant }}</h4>
|
||||
<span>as {{ request.user.username }}</span>
|
||||
</a>
|
||||
<a id="drop_btn" href="#"> </a>
|
||||
<ul id="user_tenant_list">
|
||||
<li class="title"><h4>Available Tenants</h4></li>
|
||||
{% for tenant in tenants %}
|
||||
{% if tenant.enabled %}
|
||||
<li><a href="{% url nova_switch_tenants '1234' %}">{{ tenant.id }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<li id="sign_out"><a href="{% url auth_logout %}">Sign Out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
{% block footerjs %}{% endblock %}
|
||||
<div id='content'>
|
||||
{% block sidebar %}{% endblock sidebar %}
|
||||
<div id="main">
|
||||
{% block main_content %}{% endblock main_content %}
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
{% block footer %}{% endblock footer %}
|
||||
</div>
|
||||
<div id='mask'></div>
|
||||
</div>
|
||||
{% block footer_js %}{% endblock footer_js %}
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,5 +1,13 @@
|
||||
{% extends "base-root.html" %}
|
||||
{% include '_header.html' %}
|
||||
|
||||
{% block rootcontent %}
|
||||
{% block content %}{% endblock %}
|
||||
{% endblock %}
|
||||
{% block topbbar %}
|
||||
{% include '_topbar.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% endblock %}
|
||||
|
||||
{% include '_footer.html' %}
|
||||
|
11
openstack-dashboard/dashboard/templates/dash_base.html
Normal file
11
openstack-dashboard/dashboard/templates/dash_base.html
Normal file
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block topbar %}
|
||||
{% with current_dash="dash" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include '_dash_sidebar.html' %}{% endblock %}
|
||||
{% block main %}{% endblock %}
|
||||
|
15
openstack-dashboard/dashboard/templates/dash_images.html
Normal file
15
openstack-dashboard/dashboard/templates/dash_images.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
{# list of user's images #}
|
||||
{# standard nav, sidebar, list of images in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_section="images" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include '_image_list.html' %}
|
||||
<a href="{% url dash_images_upload request.user.tenant %}">upload</a>
|
||||
|
||||
{% endblock %}
|
13
openstack-dashboard/dashboard/templates/dash_instances.html
Normal file
13
openstack-dashboard/dashboard/templates/dash_instances.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
{# list of user's instances #}
|
||||
{# standard nav, sidebar, list of instances in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_section="instances" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include '_instance_list.html' %}
|
||||
{% endblock %}
|
13
openstack-dashboard/dashboard/templates/dash_launch.html
Normal file
13
openstack-dashboard/dashboard/templates/dash_launch.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
{# launch an instance based on image #}
|
||||
{# standard nav, sidebar, launch form in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_section="images" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include '_launch.html' %}
|
||||
{% endblock %}
|
16
openstack-dashboard/dashboard/templates/dash_overview.html
Normal file
16
openstack-dashboard/dashboard/templates/dash_overview.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
|
||||
{# default landing page for a non-admin user #}
|
||||
{# nav bar on top, sidebar, overview info in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_sidebar='overview' %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
OVERVIEW FOR A USER
|
||||
|
||||
{% endblock %}
|
13
openstack-dashboard/dashboard/templates/dash_upload.html
Normal file
13
openstack-dashboard/dashboard/templates/dash_upload.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'dash_base.html' %}
|
||||
{# launch an instance based on image #}
|
||||
{# standard nav, sidebar, launch form in main #}
|
||||
|
||||
{% block sidebar %}
|
||||
{% with current_section="images" %}
|
||||
{{block.super}}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include '_upload.html' %}
|
||||
{% endblock %}
|
@ -0,0 +1 @@
|
||||
{# redirected to this page if login is required #}
|
8
openstack-dashboard/dashboard/templates/splash.html
Normal file
8
openstack-dashboard/dashboard/templates/splash.html
Normal file
@ -0,0 +1,8 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{# pleasant landing page if not logged in #}
|
||||
{# redirected to overview if logged in #}
|
||||
|
||||
{% block main %}
|
||||
{% include '_login.html' with form=login_form %}
|
||||
{% endblock %}
|
@ -27,21 +27,24 @@ from django.views import generic as generic_views
|
||||
import django.views.i18n
|
||||
from registration import forms as reg_forms
|
||||
|
||||
|
||||
admin.autodiscover()
|
||||
from django_openstack import urls as django_openstack_urls
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', 'dashboard.views.index', name='index'),
|
||||
url(r'^overview$', 'dashboard.views.index', name='nova_overview'),
|
||||
url(r'^i18n/setlang', django.views.i18n.set_language),
|
||||
url(r'^tenant/', include('django_openstack.nova.urls.tenant')),
|
||||
url(r'^syspanel/', include('django_openstack.syspanel.urls')),
|
||||
url(r'^token/$', 'django_openstack.nova.views.auth.token', name='auth_token'),
|
||||
url(r'^login/$', 'django_openstack.nova.views.auth.token', name='auth_login'),
|
||||
url(r'^token/switch/(?P<tenant_id>\d+)?$', 'django_openstack.nova.views.auth.switch_tenants', name='auth_switch_tenants'),
|
||||
url(r'^token/destroy$', 'django_openstack.nova.views.auth.destroy_token', name='auth_logout'),
|
||||
url(r'^$', 'dashboard.views.splash', name='splash'),
|
||||
url(r'^dash/$', 'dashboard.views.user_overview', name='dash_overview'),
|
||||
)
|
||||
|
||||
# NOTE(termie): just append them since we want the routes at the root
|
||||
urlpatterns += django_openstack_urls.urlpatterns
|
||||
|
||||
#url(r'^i18n/setlang', django.views.i18n.set_language),
|
||||
#url(r'^tenant/', include('django_openstack.nova.urls.tenant')),
|
||||
#url(r'^syspanel/', include('django_openstack.syspanel.urls')),
|
||||
#url(r'^token/$', 'django_openstack.nova.views.auth.token', name='auth_token'),
|
||||
#url(r'^login/$', 'django_openstack.nova.views.auth.token', name='auth_login'),
|
||||
#url(r'^token/switch/(?P<tenant_id>\d+)?$', 'django_openstack.nova.views.auth.switch_tenants', name='auth_switch_tenants'),
|
||||
#url(r'^token/destroy$', 'django_openstack.nova.views.auth.destroy_token', name='auth_logout'),
|
||||
|
||||
|
||||
urlpatterns += patterns('',
|
||||
# TODO(devcamcar): Move permission denied template into django-openstack.
|
||||
|
@ -25,6 +25,8 @@ from django import template
|
||||
from django.shortcuts import render_to_response
|
||||
from django.views.decorators.vary import vary_on_cookie
|
||||
|
||||
from django import shortcuts
|
||||
|
||||
from django_openstack import api
|
||||
from django_openstack.nova import forms as nova_forms
|
||||
|
||||
@ -34,18 +36,20 @@ from django_openstack.nova.exceptions import handle_nova_error
|
||||
|
||||
@vary_on_cookie
|
||||
@handle_nova_error
|
||||
def index(request):
|
||||
tenants = None
|
||||
page_type = "home"
|
||||
|
||||
def splash(request):
|
||||
if request.user:
|
||||
tenants = api.auth_api().tenants.for_token(request.user.token)
|
||||
logging.info('tenants: %s', tenants)
|
||||
#pass
|
||||
#projects = get_projects(user=request.user)
|
||||
if request.user.is_admin():
|
||||
return shortcuts.redirect('admin_overview')
|
||||
else:
|
||||
return shortcuts.redirect('dash_overview')
|
||||
|
||||
return render_to_response('index.html', {
|
||||
'tenants': tenants,
|
||||
'page_type': page_type,
|
||||
return render_to_response('splash.html', {
|
||||
'login_form': nova_forms.Login(),
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
||||
|
||||
# login_required
|
||||
def user_overview(request, tenant_id=None):
|
||||
return render_to_response('dash_overview.html', {
|
||||
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
Loading…
x
Reference in New Issue
Block a user