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
a87215f0
authored
Sep 01, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: display multiple connections strings
Also add empty text and prefix to tables in profile
parent
69abf63b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
14 deletions
+33
-14
circle/dashboard/models.py
+12
-9
circle/dashboard/tables.py
+5
-0
circle/dashboard/templates/dashboard/vm-detail.html
+14
-2
circle/dashboard/views.py
+2
-3
No files found.
circle/dashboard/models.py
View file @
a87215f0
...
@@ -155,22 +155,25 @@ class Profile(Model):
...
@@ -155,22 +155,25 @@ class Profile(Model):
default
=
2048
*
1024
*
1024
,
default
=
2048
*
1024
*
1024
,
help_text
=
_
(
'Disk quota in mebibytes.'
))
help_text
=
_
(
'Disk quota in mebibytes.'
))
def
get_connect_command
(
self
,
instance
,
use_ipv6
=
False
):
def
get_connect_command
s
(
self
,
instance
,
use_ipv6
=
False
):
""" Generate connection command based on template."""
""" Generate connection command based on template."""
try
:
single_command
=
instance
.
get_connect_command
(
use_ipv6
)
command
=
self
.
user
.
command_set
.
get
(
if
single_command
:
# can we even connect to that VM
commands
=
self
.
user
.
command_set
.
filter
(
access_method
=
instance
.
access_method
)
access_method
=
instance
.
access_method
)
except
ConnectCommand
.
DoesNotExist
:
if
commands
.
count
()
<
1
:
# No template for this protocol return default
return
[
single_command
]
return
instance
.
get_connect_command
(
use_ipv6
)
else
:
else
:
return
command
.
template
%
{
return
[
command
.
template
%
{
'port'
:
instance
.
get_connect_port
(
use_ipv6
=
use_ipv6
),
'port'
:
instance
.
get_connect_port
(
use_ipv6
=
use_ipv6
),
'host'
:
instance
.
get_connect_host
(
use_ipv6
=
use_ipv6
),
'host'
:
instance
.
get_connect_host
(
use_ipv6
=
use_ipv6
),
'password'
:
instance
.
pw
,
'password'
:
instance
.
pw
,
'app'
:
command
.
application
,
'app'
:
command
.
application
,
'username'
:
'cloud'
'username'
:
'cloud'
,
}
}
for
command
in
commands
]
else
:
return
[]
def
notify
(
self
,
subject
,
template
,
context
=
None
,
valid_until
=
None
,
def
notify
(
self
,
subject
,
template
,
context
=
None
,
valid_until
=
None
,
**
kwargs
):
**
kwargs
):
...
...
circle/dashboard/tables.py
View file @
a87215f0
...
@@ -251,6 +251,8 @@ class UserKeyListTable(Table):
...
@@ -251,6 +251,8 @@ class UserKeyListTable(Table):
model
=
UserKey
model
=
UserKey
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
)}
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
)}
fields
=
(
'name'
,
'fingerprint'
,
'created'
,
'actions'
)
fields
=
(
'name'
,
'fingerprint'
,
'created'
,
'actions'
)
prefix
=
"key-"
empty_text
=
_
(
"You haven't added any public keys yet."
)
class
ConnectCommandListTable
(
Table
):
class
ConnectCommandListTable
(
Table
):
...
@@ -279,3 +281,6 @@ class ConnectCommandListTable(Table):
...
@@ -279,3 +281,6 @@ class ConnectCommandListTable(Table):
model
=
ConnectCommand
model
=
ConnectCommand
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
)}
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
)}
fields
=
(
'access_method'
,
'application'
,
'template'
,
'actions'
)
fields
=
(
'access_method'
,
'application'
,
'template'
,
'actions'
)
prefix
=
"cmd-"
empty_text
=
_
(
"You don't have any custom connection string, the "
"default ones will be used."
)
circle/dashboard/templates/dashboard/vm-detail.html
View file @
a87215f0
...
@@ -111,16 +111,28 @@
...
@@ -111,16 +111,28 @@
</div>
</div>
</dd>
</dd>
</dl>
</dl>
{% for c in connect_commands %}
<div
class=
"input-group"
id=
"dashboard-vm-details-connect-command"
>
<div
class=
"input-group"
id=
"dashboard-vm-details-connect-command"
>
<span
class=
"input-group-addon input-tags"
>
{% trans "Command" %}
</span>
<span
class=
"input-group-addon input-tags"
>
{% trans "Command" %}
</span>
<input
type=
"text"
spellcheck=
"false"
<input
type=
"text"
spellcheck=
"false"
value=
"{% if connect_command %}{{ connect_command }}{% else %}{% trans "
Connection
is
not
possible
."
%}{%
endif
%}"
value=
"{{ c }}"
id=
"vm-details-connection-string"
class=
"form-control input-tags"
/>
<span
class=
"input-group-addon input-tags"
id=
"vm-details-connection-string-copy"
>
<i
class=
"fa fa-copy"
title=
"{% trans "
Select
all
"
%}"
></i>
</span>
</div>
{% empty %}
<div
class=
"input-group"
id=
"dashboard-vm-details-connect-command"
>
<span
class=
"input-group-addon input-tags"
>
{% trans "Command" %}
</span>
<input
type=
"text"
spellcheck=
"false"
value=
"{% trans "
Connection
is
not
possible
."
%}"
id=
"vm-details-connection-string"
class=
"form-control input-tags"
/>
id=
"vm-details-connection-string"
class=
"form-control input-tags"
/>
<span
class=
"input-group-addon input-tags"
id=
"vm-details-connection-string-copy"
>
<span
class=
"input-group-addon input-tags"
id=
"vm-details-connection-string-copy"
>
<i
class=
"fa fa-copy"
title=
"{% trans "
Select
all
"
%}"
></i>
<i
class=
"fa fa-copy"
title=
"{% trans "
Select
all
"
%}"
></i>
</span>
</span>
</div>
</div>
{% endfor %}
</div>
</div>
<div
class=
"col-md-8"
id=
"vm-detail-pane"
>
<div
class=
"col-md-8"
id=
"vm-detail-pane"
>
<div
class=
"panel panel-default"
id=
"vm-detail-panel"
>
<div
class=
"panel panel-default"
id=
"vm-detail-panel"
>
...
...
circle/dashboard/views.py
View file @
a87215f0
...
@@ -304,7 +304,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -304,7 +304,7 @@ class VmDetailView(CheckedDetailView):
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
'ops'
:
ops
,
'ops'
:
ops
,
'op'
:
{
i
.
op
:
i
for
i
in
ops
},
'op'
:
{
i
.
op
:
i
for
i
in
ops
},
'connect_command
'
:
user
.
profile
.
get_connect_command
(
instance
)
'connect_command
s'
:
user
.
profile
.
get_connect_commands
(
instance
)
})
})
# activity data
# activity data
...
@@ -3201,8 +3201,7 @@ class ConnectCommandDetail(LoginRequiredMixin, SuccessMessageMixin,
...
@@ -3201,8 +3201,7 @@ class ConnectCommandDetail(LoginRequiredMixin, SuccessMessageMixin,
object
=
self
.
get_object
()
object
=
self
.
get_object
()
if
object
.
user
!=
request
.
user
:
if
object
.
user
!=
request
.
user
:
raise
PermissionDenied
()
raise
PermissionDenied
()
return
super
(
ConnectCommandDetail
,
self
)
.
post
(
self
,
request
,
return
super
(
ConnectCommandDetail
,
self
)
.
post
(
request
,
args
,
kwargs
)
args
,
kwargs
)
class
ConnectCommandDelete
(
LoginRequiredMixin
,
DeleteView
):
class
ConnectCommandDelete
(
LoginRequiredMixin
,
DeleteView
):
...
...
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