Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
726fec74
authored
Oct 07, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add javascript create vm modal
parent
fec5c8ab
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
2 deletions
+46
-2
circle/dashboard/static/dashboard/dashboard.js
+19
-0
circle/dashboard/templates/dashboard/ajax-wrapper.html
+5
-0
circle/dashboard/templates/dashboard/index-vm.html
+1
-1
circle/dashboard/templates/dashboard/vm-create.html
+1
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+17
-0
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
726fec74
$
(
function
()
{
$
(
'.vm-create'
).
click
(
function
(
e
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/dashboard/vm/create/'
,
success
:
function
(
data
)
{
// TODO this is ugly
var
html
=
'<div class="modal fade" id="vm-create-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">Modal title</h4></div><div class="modal-body"> '
+
data
+
'</div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button><button type="button" class="btn btn-primary">Save changes</button></div></div><!-- /.modal-content --></div><!-- /.modal-dialog --></div><!-- /.modal -->'
;
$
(
'.container'
).
append
(
html
);
$
(
'#vm-create-modal'
).
modal
(
'show'
);
$
(
'#vm-create-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#vm-create-modal'
).
remove
();
});
}
});
return
false
;
});
$
(
'[href=#vm-graph-view]'
).
click
(
function
(
e
)
{
$
(
'#vm-list-view'
).
hide
();
$
(
'#vm-graph-view'
).
show
();
...
...
circle/dashboard/templates/dashboard/ajax-wrapper.html
0 → 100644
View file @
726fec74
{% extends "dashboard/base.html" %}
{% block content %}
{% include template %}
{% endblock %}
circle/dashboard/templates/dashboard/index-vm.html
View file @
726fec74
...
...
@@ -32,7 +32,7 @@
<i
class=
"icon-chevron-sign-right"
></i>
<strong>
{{ more_instances }}
</strong>
more
</a>
{% endif %}
<a
class=
"btn btn-success btn-xs"
><i
class=
"icon-plus-sign"
></i>
new
</a>
<a
class=
"btn btn-success btn-xs
vm-create"
href=
"{% url "
dashboard
.
views
.
vm-create
"
%}
"
><i
class=
"icon-plus-sign"
></i>
new
</a>
</div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/vm-create.html
0 → 100644
View file @
726fec74
Create a VM
circle/dashboard/urls.py
View file @
726fec74
from
django.conf.urls
import
patterns
,
url
from
.views
import
IndexView
,
VmDetailView
,
VmList
from
.views
import
IndexView
,
VmDetailView
,
VmList
,
VmCreate
urlpatterns
=
patterns
(
''
,
...
...
@@ -8,4 +8,6 @@ urlpatterns = patterns(
url
(
r'^vm/(?P<pk>\d+)/$'
,
VmDetailView
.
as_view
(),
name
=
'dashboard.views.detail'
),
url
(
r'^vm/list/$'
,
VmList
.
as_view
(),
name
=
'dashboard.views.vm-list'
),
url
(
r'^vm/create/$'
,
VmCreate
.
as_view
(),
name
=
'dashboard.views.vm-create'
),
)
circle/dashboard/views.py
View file @
726fec74
...
...
@@ -51,3 +51,20 @@ class VmList(SingleTableView):
model
=
Instance
table_class
=
VmListTable
table_pagination
=
False
class
VmCreate
(
TemplateView
):
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
return
[
'dashboard/vm-create.html'
]
else
:
return
[
'dashboard/ajax-wrapper.html'
]
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
context
=
self
.
get_context_data
(
**
kwargs
)
if
not
request
.
is_ajax
():
context
.
update
({
'template'
:
'dashboard/vm-create.html'
})
return
self
.
render_to_response
(
context
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment