Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b029581a
authored
Mar 07, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: edit template finished
fixes #62
parent
4f289756
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
4 deletions
+137
-4
one/static/script/cloud.js
+1
-1
one/templates/box/template/summary.html
+3
-3
one/templates/edit-template-flow.html
+112
-0
one/views.py
+21
-0
No files found.
one/static/script/cloud.js
View file @
b029581a
...
...
@@ -152,7 +152,7 @@ $(function() {
$
(
'#modal-container'
).
html
(
data
);
}
});
})
})
;
$
(
'#shadow'
).
click
(
function
()
{
$
(
'#modal'
).
hide
();
$
(
'#modal-container'
).
html
(
''
);
...
...
one/templates/box/template/summary.html
View file @
b029581a
...
...
@@ -47,6 +47,9 @@
{% endblock status %}
{% block actions %}
<a
href=
"#"
class=
"edit-template"
data-id=
"{{ t.id }}"
title=
"{% trans "
Edit
"
%}"
>
<img
src=
"{% static "
icons
/
pencil
.
png
"
%}"
alt=
"{% trans "
Edit
"
%}"
/>
</a>
{% if t.state == 'READY' %}
<a
href=
"#"
class=
"try-template"
data-id=
"{{t.id}}"
title=
"{% trans "
Try
"
%}"
>
<img
src=
"{% static "
icons
/
control
.
png
"
%}"
alt=
"{% trans "
Start
"
%}"
/>
...
...
@@ -61,7 +64,4 @@
<a
href=
"#"
class=
"delete-template"
data-id=
"{{ t.id }}"
data-name=
"{{ t.name }}"
title=
"{% trans "
Remove
"
%}"
>
<img
src=
"{% static "
icons
/
minus-circle
.
png
"
%}"
alt=
"{% trans "
Remove
"
%}"
/>
</a>
<!--<a href="#" class="edit-template" data-id="{{ t.id }}" title="{% trans "Edit" %}">
<img src="{% static "icons/pencil.png" %}" alt="{% trans "Edit" %}" />
</a>-->
{% endblock actions %}
one/templates/edit-template-flow.html
0 → 100644
View file @
b029581a
{% load i18n %}
{% load staticfiles %}
{% get_current_language as LANGUAGE_CODE %}
<form
action=
"{% url one.views.ajax_template_edit_wizard template.id %}"
method=
"post"
id=
"template-wizard"
>
{% csrf_token %}
<div
id=
"new-template-step-2"
class=
"wizard"
>
<h2>
{% blocktrans with step=2 %}Step {{step}}{% endblocktrans %}
</h2>
<p>
{% trans "Change the parameters as needed." %}
</p>
<ul>
<li>
<label
for=
"new-template-name"
>
{% trans "Name" %}
</label>
<input
type=
"text"
name=
"name"
id=
"new-template-name"
value=
"{{template.name}}"
class=
"validated"
/>
<div
class=
"clear"
></div>
</li>
<li
class=
"new-tpl-size"
>
<label
for=
"new-template-size"
>
{% trans "Size" %}
</label>
<ul
class=
"radio"
>
{% for s in sizes %}
<li>
<label>
<input
type=
"radio"
name=
"size"
value=
"{{s.id}}"
id=
"new-template-size-{{s.id}}"
{%
if
s =
=
template
.
instance_type
%}
checked=
"checked"
{%
endif
%}
/>
{{s.name}}
</label>
</li>
{% endfor %}
</ul>
{% for s in sizes %}
<p
id=
"new-template-size-summary-{{s.id}}"
class=
"size-summary clear"
{%
if
s
!=
template
.
instance_type
%}
style=
"display:none"
{%
endif
%}
>
<span
class=
"cpu"
>
{% blocktrans count n=s.CPU %}{{n}} core{% plural %}{{n}} cores{% endblocktrans %}
</span>
<span
class=
"memory"
>
{{s.RAM}} MiB
</span>
<span
class=
"credit"
>
{{s.credit}}
</span>
</p>
{% endfor %}
<div
class=
"clear"
></div>
</li>
<li
style=
"border: none"
>
<label
for=
"new-template-description"
>
{% trans "Description" %}
</label>
<textarea
name=
"description"
id=
"new-template-description"
style=
"text-align: left"
>
{{template.description}}
</textarea>
<div
class=
"clear"
></div>
</li>
</ul>
<nav>
<input
type=
"reset"
class=
"prev"
value=
"{% trans "
Cancel
"
%}"
/>
<input
type=
"submit"
class=
"next"
value=
"{% trans "
Save
"
%}"
/>
<div
class=
"clear"
></div>
</nav>
<script
type=
"text/javascript"
>
$
(
function
(){
var
original
=
'{{template.name}}'
;
$
(
'#new-template-step-2 nav .prev'
).
click
(
function
(){
$
(
'#modal'
).
hide
();
})
$
(
".new-tpl-size input[name='size']"
).
click
(
function
(
e
){
var
v
=
$
(
".new-tpl-size input[name='size']:checked"
).
val
();
$
(
"p.size-summary"
).
hide
();
$
(
"#new-template-size-summary-"
+
v
).
show
();
});
$
(
"#new-template-name"
).
keyup
(
function
(){
var
timer
;
return
function
(
e
){
var
self
=
this
;
clearTimeout
(
timer
);
timer
=
setTimeout
(
function
(){
var
s
=
$
(
self
).
val
();
$
.
ajax
({
'type'
:
'GET'
,
'url'
:
'{% url one.views.ajax_template_name_unique %}?name='
+
s
,
'success'
:
function
(
data
,
b
,
c
)
{
if
(
s
!=
$
(
"#new-template-name"
).
val
())
{
return
true
;
}
if
(
data
==
"True"
||
s
==
original
)
{
$
(
'#new-template-name'
).
removeClass
(
"error"
);
$
(
'#new-template-step-2 nav .next'
).
removeAttr
(
"disabled"
);
$
(
'#new-template-name'
).
removeProp
(
"title"
);
}
else
{
$
(
'#new-template-name'
).
addClass
(
"error"
);
$
(
'#new-template-step-2 nav .next'
).
attr
(
"disabled"
,
"disabled"
);
$
(
'#new-template-name'
).
prop
(
"title"
,
gettext
(
'Please choose a different name.'
));
}
}
});
},
1000
)
}
}());
$
(
"#template-wizard"
).
submit
(
function
(
e
){
e
.
preventDefault
();
$
.
ajax
({
'type'
:
'GET'
,
'url'
:
'{% url one.views.ajax_template_name_unique %}?name='
+
$
(
"#new-template-name"
).
val
(),
'success'
:
function
(
data
,
b
,
c
)
{
if
(
data
==
"True"
||
s
==
original
)
{
$
(
"#template-wizard"
).
unbind
(
'submit'
).
submit
()
}
else
{
$
(
'#new-template-name'
).
addClass
(
"error"
);
$
(
'#new-template-step-2 nav .next'
).
attr
(
"disabled"
,
"disabled"
);
$
(
'#new-template-name'
).
prop
(
"title"
,
gettext
(
'Please choose a different name.'
));
}
}
});
});
})
</script>
</div>
</form>
one/views.py
View file @
b029581a
...
...
@@ -135,6 +135,27 @@ class AjaxTemplateWizard(View):
}))
ajax_template_wizard
=
login_required
(
AjaxTemplateWizard
.
as_view
())
class
AjaxTemplateEditWizard
(
View
):
def
get
(
self
,
request
,
id
,
*
args
,
**
kwargs
):
template
=
get_object_or_404
(
Template
,
id
=
id
)
if
template
.
owner
!=
request
.
user
and
not
template
.
public
and
not
request
.
user
.
is_superuser
:
raise
PermissionDenied
()
return
render_to_response
(
'edit-template-flow.html'
,
RequestContext
(
request
,
{
'sizes'
:
InstanceType
.
objects
.
all
(),
'template'
:
template
,
}))
def
post
(
self
,
request
,
id
,
*
args
,
**
kwargs
):
template
=
get_object_or_404
(
Template
,
id
=
id
)
if
template
.
owner
!=
request
.
user
and
not
template
.
public
and
not
request
.
user
.
is_superuser
:
raise
PermissionDenied
()
template
.
instance_type_id
=
request
.
POST
[
'size'
]
template
.
description
=
request
.
POST
[
'description'
]
template
.
name
=
request
.
POST
[
'name'
]
template
.
save
()
return
redirect
(
home
)
ajax_template_edit_wizard
=
login_required
(
AjaxTemplateEditWizard
.
as_view
())
class
AjaxShareWizard
(
View
):
def
get
(
self
,
request
,
id
,
gid
=
None
,
*
args
,
**
kwargs
):
...
...
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