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
a0c4edae
authored
Mar 24, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: wordwrap for ajax search too in vm list
parent
20631849
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
circle/dashboard/static/dashboard/dashboard.js
+18
-9
circle/dashboard/views.py
+3
-1
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
a0c4edae
...
@@ -188,6 +188,9 @@ $(function () {
...
@@ -188,6 +188,9 @@ $(function () {
'name'
:
result
[
i
].
name
.
toLowerCase
(),
'name'
:
result
[
i
].
name
.
toLowerCase
(),
'state'
:
result
[
i
].
state
,
'state'
:
result
[
i
].
state
,
'fav'
:
result
[
i
].
fav
,
'fav'
:
result
[
i
].
fav
,
'host'
:
result
[
i
].
host
,
'icon'
:
result
[
i
].
icon
,
'status'
:
result
[
i
].
status
,
});
});
}
}
});
});
...
@@ -204,7 +207,9 @@ $(function () {
...
@@ -204,7 +207,9 @@ $(function () {
}
}
search_result
.
sort
(
compareVmByFav
);
search_result
.
sort
(
compareVmByFav
);
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
search_result
[
i
].
fav
);
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
,
search_result
[
i
].
host
,
search_result
[
i
].
icon
,
search_result
[
i
].
status
,
search_result
[
i
].
fav
);
if
(
search_result
.
length
==
0
)
if
(
search_result
.
length
==
0
)
html
+=
'<div class="list-group-item">No result</div>'
;
html
+=
'<div class="list-group-item">No result</div>'
;
$
(
"#dashboard-vm-list"
).
html
(
html
);
$
(
"#dashboard-vm-list"
).
html
(
html
);
...
@@ -230,14 +235,18 @@ $(function () {
...
@@ -230,14 +235,18 @@ $(function () {
});
});
});
});
function
generateVmHTML
(
pk
,
name
,
fav
)
{
function
generateVmHTML
(
pk
,
name
,
host
,
icon
,
_status
,
fav
)
{
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item">'
+
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item">'
+
'<i class="icon-play-sign"></i> '
+
name
+
'<span class="index-vm-list-name">'
+
'<div class="pull-right dashboard-vm-favourite" data-vm="'
+
pk
+
'">'
+
'<i class="'
+
icon
+
'" title="'
+
_status
+
'"></i> '
+
name
+
'<i class="title-favourite icon-star'
+
(
fav
?
""
:
"-empty"
)
+
' text-primary" title="" data-original-title="'
+
'</span>'
+
(
fav
?
"Un"
:
"Mark as "
)
+
'favourite"></i>'
+
'<small class="text-muted"> '
+
host
+
'</small>'
+
'</div>'
+
'<div class="pull-right dashboard-vm-favourite" data-vm="'
+
pk
+
'">'
+
'</a>'
;
(
fav
?
'<i class="icon-star text-primary title-favourite" title="Unfavourite"></i>'
:
'<i class="icon-star-empty text-primary title-favourite" title="Mark as favorite"></i>'
)
+
'</div>'
+
'<div style="clear: both;"></div>'
+
'</a>'
;
}
}
function
compareVmByFav
(
a
,
b
)
{
function
compareVmByFav
(
a
,
b
)
{
...
...
circle/dashboard/views.py
View file @
a0c4edae
...
@@ -921,7 +921,9 @@ class VmList(LoginRequiredMixin, ListView):
...
@@ -921,7 +921,9 @@ class VmList(LoginRequiredMixin, ListView):
instances
=
[{
instances
=
[{
'pk'
:
i
.
pk
,
'pk'
:
i
.
pk
,
'name'
:
i
.
name
,
'name'
:
i
.
name
,
'state'
:
i
.
state
,
'icon'
:
i
.
get_status_icon
(),
'host'
:
""
if
not
i
.
primary_host
else
i
.
primary_host
.
hostname
,
'status'
:
i
.
get_status_display
(),
'fav'
:
i
.
pk
in
favs
}
for
i
in
instances
]
'fav'
:
i
.
pk
in
favs
}
for
i
in
instances
]
return
HttpResponse
(
return
HttpResponse
(
json
.
dumps
(
list
(
instances
)),
# instances is ValuesQuerySet
json
.
dumps
(
list
(
instances
)),
# instances is ValuesQuerySet
...
...
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