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
972e987f
authored
Mar 11, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: search and filter for storage disk list
parent
1a0c4303
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
5 deletions
+74
-5
circle/dashboard/static/dashboard/dashboard.less
+6
-0
circle/dashboard/tables.py
+2
-1
circle/dashboard/templates/dashboard/storage/detail.html
+27
-0
circle/dashboard/views/storage.py
+39
-4
No files found.
circle/dashboard/static/dashboard/dashboard.less
View file @
972e987f
...
@@ -1269,3 +1269,9 @@ textarea[name="new_members"] {
...
@@ -1269,3 +1269,9 @@ textarea[name="new_members"] {
background: #f9f9f9;
background: #f9f9f9;
margin-top: 20px;
margin-top: 20px;
}
}
#disk-list-table {
td:last-child {
text-align: center;
}
}
circle/dashboard/tables.py
View file @
972e987f
...
@@ -350,4 +350,5 @@ class DiskListTable(Table):
...
@@ -350,4 +350,5 @@ class DiskListTable(Table):
fields
=
(
"pk"
,
"appliance"
,
"filename"
,
"size"
,
"is_ready"
)
fields
=
(
"pk"
,
"appliance"
,
"filename"
,
"size"
,
"is_ready"
)
prefix
=
"disk-"
prefix
=
"disk-"
order_by
=
(
"-pk"
,
)
order_by
=
(
"-pk"
,
)
per_page
=
65536
per_page
=
15
empty_text
=
_
(
"No disk found."
)
circle/dashboard/templates/dashboard/storage/detail.html
View file @
972e987f
...
@@ -70,6 +70,33 @@
...
@@ -70,6 +70,33 @@
<h3
class=
"no-margin"
><i
class=
"fa fa-file"
></i>
{% trans "Disks" %}
</h3>
<h3
class=
"no-margin"
><i
class=
"fa fa-file"
></i>
{% trans "Disks" %}
</h3>
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-md-9"
>
<ul
class=
"nav nav-pills"
style=
"margin: 5px 0 20px 0;"
>
<li
class=
"disabled"
><a
href=
"#"
>
{% trans "Filter by type" %}
</a></li>
<li
{%
if
not
request
.
GET
.
filter
%}
class=
"active"
{%
endif
%}
>
<a
href=
"{{ request.path }}?s={{ request.GET.s }}"
>
{% trans "ALL" %}
</a>
</li>
{% for f in filter_names %}
<li
{%
if
request
.
GET
.
filter =
=
f
.
0
%}
class=
"active"
{%
endif
%}
>
<a
href=
"?filter={{ f.0 }}&s={{ request.GET.s }}"
>
{{ f.1|capfirst }}
</a>
</li>
{% endfor %}
</ul>
</div>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-host-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
id=
"network-host-list-input"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
<input
type=
"hidden"
name=
"filter"
value=
"{{ request.GET.filter }}"
/>
</div>
</form>
</div>
</div>
<!-- .row -->
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table disk_table %}
{% render_table disk_table %}
</div>
</div>
...
...
circle/dashboard/views/storage.py
View file @
972e987f
...
@@ -16,9 +16,10 @@
...
@@ -16,9 +16,10 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
unicode_literals
,
absolute_import
from
__future__
import
unicode_literals
,
absolute_import
from
django.db.models
import
Q
from
django.views.generic
import
UpdateView
from
django.views.generic
import
UpdateView
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.utils.translation
import
ugettext_lazy
as
_
from
sizefield.utils
import
filesizeformat
from
sizefield.utils
import
filesizeformat
from
braces.views
import
SuperuserRequiredMixin
from
braces.views
import
SuperuserRequiredMixin
...
@@ -43,12 +44,46 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
...
@@ -43,12 +44,46 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
context
[
'stats'
]
=
self
.
_get_stats
()
context
[
'stats'
]
=
self
.
_get_stats
()
context
[
'missing_disks'
]
=
ds
.
get_missing_disks
()
context
[
'missing_disks'
]
=
ds
.
get_missing_disks
()
context
[
'orphan_disks'
]
=
ds
.
get_orphan_disks
()
context
[
'orphan_disks'
]
=
ds
.
get_orphan_disks
()
qs
=
Disk
.
objects
.
filter
(
datastore
=
ds
,
destroyed
=
None
)
context
[
'disk_table'
]
=
DiskListTable
(
context
[
'disk_table'
]
=
DiskListTable
(
qs
,
request
=
self
.
request
,
self
.
get_table_data
(),
request
=
self
.
request
,
template
=
"django_tables2/table_no_page.html"
)
template
=
"django_tables2/with_pagination.html"
)
context
[
'filter_names'
]
=
(
(
'vm'
,
_
(
"virtual machine"
)),
(
'template'
,
_
(
"template"
)),
(
'none'
,
_
(
"none"
)),
)
return
context
return
context
def
get_table_data
(
self
):
ds
=
self
.
get_object
()
qs
=
Disk
.
objects
.
filter
(
datastore
=
ds
,
destroyed
=
None
)
filter_name
=
self
.
request
.
GET
.
get
(
"filter"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
filter_queries
=
{
'vm'
:
{
'instance_set__isnull'
:
False
,
},
'template'
:
{
'template_set__isnull'
:
False
,
},
'none'
:
{
'template_set__isnull'
:
True
,
'instance_set__isnull'
:
True
,
}
}
if
filter_name
:
qs
=
qs
.
filter
(
**
filter_queries
.
get
(
filter_name
,
{}))
if
search
:
search
=
search
.
strip
()
qs
=
qs
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
filename__icontains
=
search
))
return
qs
def
_get_stats
(
self
):
def
_get_stats
(
self
):
stats
=
self
.
object
.
get_statistics
()
stats
=
self
.
object
.
get_statistics
()
free_space
=
int
(
stats
[
'free_space'
])
free_space
=
int
(
stats
[
'free_space'
])
...
...
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