Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
670c0eb9
authored
Apr 15, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: update description and name from home tab
parent
66329dac
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
38 deletions
+180
-38
circle/dashboard/static/dashboard/dashboard.css
+26
-2
circle/dashboard/static/dashboard/vm-details.js
+81
-28
circle/dashboard/templates/dashboard/vm-detail.html
+8
-4
circle/dashboard/templates/dashboard/vm-detail/home.html
+40
-2
circle/dashboard/views.py
+25
-2
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
670c0eb9
...
@@ -187,7 +187,7 @@ html {
...
@@ -187,7 +187,7 @@ html {
height
:
300px
;
height
:
300px
;
}
}
#vm-details-rename
,
#vm-details-
rename
*,
#vm-details-h1-name
,
#vm-list-rename
,
#vm-list-rename
*
,
#vm-details-rename
,
#vm-details-
h1-name
,
#vm-details-rename
,
#node-details-rename
,
#node-details-rename
*,
#node-details-h1-name
,
#node-list-rename
,
#node-list-rename
*
#group-details-rename
,
#group-details-rename
*,
#group-details-h1-name
,
#group-list-rename
,
#group-list-rename
*
{
#node-details-rename
,
#node-details-rename
*,
#node-details-h1-name
,
#node-list-rename
,
#node-list-rename
*
#group-details-rename
,
#group-details-rename
*,
#group-details-h1-name
,
#group-list-rename
,
#group-list-rename
*
{
display
:
inline
;
display
:
inline
;
...
@@ -197,7 +197,11 @@ html {
...
@@ -197,7 +197,11 @@ html {
display
:
none
;
display
:
none
;
}
}
#vm-details-rename-name
,
#node-details-rename-name
,
#group-details-rename-name
{
.vm-details-home-name
{
max-width
:
401px
;
}
#node-details-rename-name
,
#group-details-rename-name
{
max-width
:
160px
;
max-width
:
160px
;
}
}
...
@@ -467,3 +471,23 @@ footer a, footer a:hover, footer a:visited {
...
@@ -467,3 +471,23 @@ footer a, footer a:hover, footer a:visited {
overflow
:
hidden
;
overflow
:
hidden
;
padding-left
:
10px
;
padding-left
:
10px
;
}
}
#vm-details-home-description
{
display
:
inline-block
;
position
:
relative
;
}
#vm-details-home-description
textarea
{
min-width
:
240px
;
min-height
:
250px
;
}
.vm-details-home-edit-description-click
,
.vm-details-home-edit-name-click
{
cursor
:
pointer
;
}
.vm-details-description-submit
{
position
:
absolute
;
bottom
:
10px
;
right
:
20px
;
}
circle/dashboard/static/dashboard/vm-details.js
View file @
670c0eb9
...
@@ -31,33 +31,6 @@ $(function() {
...
@@ -31,33 +31,6 @@ $(function() {
return
false
;
return
false
;
});
});
/* rename */
$
(
"#vm-details-h1-name, .vm-details-rename-button"
).
click
(
function
()
{
$
(
"#vm-details-h1-name"
).
hide
();
$
(
"#vm-details-rename"
).
css
(
'display'
,
'inline'
);
$
(
"#vm-details-rename-name"
).
focus
();
});
/* rename ajax */
$
(
'#vm-details-rename-submit'
).
click
(
function
()
{
var
name
=
$
(
'#vm-details-rename-name'
).
val
();
$
.
ajax
({
method
:
'POST'
,
url
:
location
.
href
,
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
"#vm-details-h1-name"
).
text
(
data
[
'new_name'
]).
show
();
$
(
'#vm-details-rename'
).
hide
();
// addMessage(data['message'], "success");
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
}
});
return
false
;
});
/* remove tag */
/* remove tag */
$
(
'.vm-details-remove-tag'
).
click
(
function
()
{
$
(
'.vm-details-remove-tag'
).
click
(
function
()
{
var
to_remove
=
$
.
trim
(
$
(
this
).
parent
(
'div'
).
text
());
var
to_remove
=
$
.
trim
(
$
(
this
).
parent
(
'div'
).
text
());
...
@@ -166,7 +139,6 @@ $(function() {
...
@@ -166,7 +139,6 @@ $(function() {
$
(
".vm-details-help"
).
stop
().
slideToggle
();
$
(
".vm-details-help"
).
stop
().
slideToggle
();
});
});
/* for interface remove buttons */
/* for interface remove buttons */
$
(
'.interface-remove'
).
click
(
function
()
{
$
(
'.interface-remove'
).
click
(
function
()
{
var
interface_pk
=
$
(
this
).
data
(
'interface-pk'
);
var
interface_pk
=
$
(
this
).
data
(
'interface-pk'
);
...
@@ -178,6 +150,87 @@ $(function() {
...
@@ -178,6 +150,87 @@ $(function() {
});
});
return
false
;
return
false
;
});
});
/* rename */
$
(
"#vm-details-h1-name, .vm-details-rename-button"
).
click
(
function
()
{
$
(
"#vm-details-h1-name"
).
hide
();
$
(
"#vm-details-rename"
).
css
(
'display'
,
'inline'
);
$
(
"#vm-details-rename-name"
).
focus
();
});
/* rename in home tab */
$
(
".vm-details-home-edit-name-click"
).
click
(
function
()
{
$
(
".vm-details-home-edit-name-click"
).
hide
();
$
(
"#vm-details-home-rename"
).
show
();
$
(
"input"
,
$
(
"#vm-details-home-rename"
)).
focus
();
});
/* rename ajax */
$
(
'.vm-details-rename-submit'
).
click
(
function
()
{
var
name
=
$
(
this
).
parent
(
"span"
).
prev
(
"input"
).
val
();
$
.
ajax
({
method
:
'POST'
,
url
:
location
.
href
,
data
:
{
'new_name'
:
name
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
".vm-details-home-edit-name"
).
text
(
data
[
'new_name'
]).
show
();
$
(
".vm-details-home-edit-name"
).
parent
(
"div"
).
show
();
$
(
".vm-details-home-edit-name-click"
).
show
();
$
(
".vm-details-home-rename-form-div"
).
hide
();
// update the inputs too
$
(
".vm-details-rename-submit"
).
parent
(
"span"
).
prev
(
"input"
).
val
(
data
[
'new_name'
]);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
}
});
return
false
;
});
/* update description click */
$
(
".vm-details-home-edit-description-click"
).
click
(
function
()
{
$
(
".vm-details-home-edit-description-click"
).
hide
();
$
(
"#vm-details-home-description"
).
show
();
return
false
;
});
/* description update ajax */
$
(
'.vm-details-description-submit'
).
click
(
function
()
{
var
description
=
$
(
this
).
prev
(
"textarea"
).
val
();
console
.
log
(
description
);
$
.
ajax
({
method
:
'POST'
,
url
:
location
.
href
,
data
:
{
'new_description'
:
description
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
var
new_desc
=
data
[
'new_description'
];
/* we can't simply use $.text, because we need new lines */
var
tagsToReplace
=
{
'&'
:
"&"
,
'<'
:
"<"
,
'>'
:
">"
,
};
new_desc
=
new_desc
.
replace
(
/
[
&<>
]
/g
,
function
(
tag
)
{
return
tagsToReplace
[
tag
]
||
tag
;
});
$
(
".vm-details-home-edit-description"
)
.
html
(
new_desc
.
replace
(
/
\n
/g
,
"<br />"
));
$
(
".vm-details-home-edit-description-click"
).
show
();
$
(
"#vm-details-home-description"
).
hide
();
// update the textareia
$
(
"vm-details-home-description textarea"
).
text
(
data
[
'new_description'
]);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"Error during renaming!"
,
"danger"
);
}
});
return
false
;
});
});
});
...
...
circle/dashboard/templates/dashboard/vm-detail.html
View file @
670c0eb9
...
@@ -56,14 +56,18 @@
...
@@ -56,14 +56,18 @@
<a
title=
"{% trans "
Help
"
%}"
href=
"#"
class=
"btn btn-default btn-xs vm-details-help-button"
><i
class=
"icon-question"
></i></a>
<a
title=
"{% trans "
Help
"
%}"
href=
"#"
class=
"btn btn-default btn-xs vm-details-help-button"
><i
class=
"icon-question"
></i></a>
</div>
</div>
<h1>
<h1>
<div
id=
"vm-details-rename"
>
<div
id=
"vm-details-rename"
class=
"vm-details-home-rename-form-div"
>
<form
action=
""
method=
"POST"
id=
"vm-details-rename-form"
>
<form
action=
""
method=
"POST"
id=
"vm-details-rename-form"
>
{% csrf_token %}
{% csrf_token %}
<input
id=
"vm-details-rename-name"
class=
"form-control"
name=
"new_name"
type=
"text"
value=
"{{ instance.name }}"
/>
<div
class=
"input-group vm-details-home-name"
>
<button
type=
"submit"
id=
"vm-details-rename-submit"
class=
"btn"
>
{% trans "Rename" %}
</button>
<input
id=
"vm-details-rename-name"
class=
"form-control input-sm"
name=
"new_name"
type=
"text"
value=
"{{ instance.name }}"
/>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-sm vm-details-rename-submit"
>
{% trans "Rename" %}
</button>
</span>
</div>
</form>
</form>
</div>
</div>
<div
id=
"vm-details-h1-name"
>
<div
id=
"vm-details-h1-name"
class=
"vm-details-home-edit-name"
>
{{ instance.name }}
{{ instance.name }}
</div>
</div>
<small>
{{ instance.primary_host.get_fqdn }}
</small>
<small>
{{ instance.primary_host.get_fqdn }}
</small>
...
...
circle/dashboard/templates/dashboard/vm-detail/home.html
View file @
670c0eb9
...
@@ -4,8 +4,46 @@
...
@@ -4,8 +4,46 @@
<dl>
<dl>
<dt>
{% trans "System" %}:
</dt>
<dt>
{% trans "System" %}:
</dt>
<dd><i
class=
"icon-{{ os_type_icon }}"
></i>
{{ instance.system }}
</dd>
<dd><i
class=
"icon-{{ os_type_icon }}"
></i>
{{ instance.system }}
</dd>
<dt
style=
"margin-top: 5px;"
>
{% trans "Description" %}:
</dt>
<dt
style=
"margin-top: 5px;"
>
<dd><small>
{{ instance.description }}
</small></dd>
{% trans "Name" %}:
<a
href=
"#"
class=
"vm-details-home-edit-name-click"
><i
class=
"icon-pencil"
></i></a>
</dt>
<dd>
<div
class=
"vm-details-home-edit-name-click"
>
<small
class=
"vm-details-home-edit-name"
>
{{ instance.name }}
</small>
</div>
<div
class=
"js-hidden vm-details-home-rename-form-div"
id=
"vm-details-home-rename"
>
<form
method=
"POST"
>
{% csrf_token %}
<div
class=
"input-group"
>
<input
type=
"text"
name=
"new_name"
value=
"{{ instance.name }}"
class=
"form-control input-sm"
/>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-success btn-sm vm-details-rename-submit"
>
<i
class=
"icon-pencil"
></i>
{% trans "Rename" %}
</button>
</span>
</div>
</form>
</div>
</dd>
<dt
style=
"margin-top: 5px;"
>
{% trans "Description" %}:
<a
href=
"#"
class=
"vm-details-home-edit-description-click"
><i
class=
"icon-pencil"
></i></a>
</dt>
<dd>
{% csrf_token %}
<div
class=
"vm-details-home-edit-description-click"
>
<small
class=
"vm-details-home-edit-description"
>
{{ instance.description|linebreaks }}
</small>
</div>
<div
id=
"vm-details-home-description"
class=
"js-hidden"
>
<form
method=
"POST"
>
<textarea
name=
"new_description"
class=
"form-control"
>
{{ instance.description }}
</textarea>
<button
type=
"submit"
class=
"btn btn-xs btn-success vm-details-description-submit"
>
<i
class=
"icon-pencil"
></i>
{% trans "Update" %}
</button>
</form>
</div>
</dd>
</dl>
</dl>
<h4>
{% trans "Expiration" %} {% if instance.is_expiring %}
<i
class=
"icon-warning-sign text-danger"
></i>
{% endif %}
<h4>
{% trans "Expiration" %} {% if instance.is_expiring %}
<i
class=
"icon-warning-sign text-danger"
></i>
{% endif %}
...
...
circle/dashboard/views.py
View file @
670c0eb9
...
@@ -238,6 +238,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -238,6 +238,7 @@ class VmDetailView(CheckedDetailView):
options
=
{
options
=
{
'change_password'
:
self
.
__change_password
,
'change_password'
:
self
.
__change_password
,
'new_name'
:
self
.
__set_name
,
'new_name'
:
self
.
__set_name
,
'new_description'
:
self
.
__set_description
,
'new_tag'
:
self
.
__add_tag
,
'new_tag'
:
self
.
__add_tag
,
'to_remove'
:
self
.
__remove_tag
,
'to_remove'
:
self
.
__remove_tag
,
'port'
:
self
.
__add_port
,
'port'
:
self
.
__add_port
,
...
@@ -316,8 +317,30 @@ class VmDetailView(CheckedDetailView):
...
@@ -316,8 +317,30 @@ class VmDetailView(CheckedDetailView):
)
)
else
:
else
:
messages
.
success
(
request
,
success_message
)
messages
.
success
(
request
,
success_message
)
return
redirect
(
reverse_lazy
(
"dashboard.views.detail"
,
return
redirect
(
self
.
object
.
get_absolute_url
())
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
def
__set_description
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
new_description
=
request
.
POST
.
get
(
"new_description"
)
Instance
.
objects
.
filter
(
pk
=
self
.
object
.
pk
)
.
update
(
**
{
'description'
:
new_description
})
success_message
=
_
(
"VM description successfully updated!"
)
if
request
.
is_ajax
():
response
=
{
'message'
:
success_message
,
'new_description'
:
new_description
,
}
return
HttpResponse
(
json
.
dumps
(
response
),
content_type
=
"application/json"
)
else
:
messages
.
success
(
request
,
success_message
)
return
redirect
(
self
.
object
.
get_absolute_url
())
def
__add_tag
(
self
,
request
):
def
__add_tag
(
self
,
request
):
new_tag
=
request
.
POST
.
get
(
'new_tag'
)
new_tag
=
request
.
POST
.
get
(
'new_tag'
)
...
...
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