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
cfc2fc67
authored
Jan 10, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: search vms from the landing page
parent
8943cc40
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
5 deletions
+61
-5
circle/dashboard/static/dashboard/dashboard.js
+42
-0
circle/dashboard/templates/dashboard/index-vm.html
+7
-5
circle/dashboard/views.py
+12
-0
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
cfc2fc67
...
@@ -95,9 +95,51 @@ $(function () {
...
@@ -95,9 +95,51 @@ $(function () {
return
false
;
return
false
;
});
});
/* search for vms */
var
my_vms
=
[]
$
(
"#dashboard-vm-search-input"
).
keyup
(
function
()
{
// if my_vms is empty get a list of our vms
if
(
my_vms
.
length
<
1
)
{
$
.
ajaxSetup
(
{
"async"
:
false
}
);
$
.
get
(
"/dashboard/vm/list/"
,
function
(
result
)
{
for
(
var
i
in
result
)
{
my_vms
.
push
({
'pk'
:
result
[
i
].
pk
,
'name'
:
result
[
i
].
fields
.
name
,
'state'
:
result
[
i
].
fields
.
state
,
});
}
});
$
.
ajaxSetup
(
{
"async"
:
true
}
);
}
input
=
$
(
"#dashboard-vm-search-input"
).
val
();
var
search_result
=
[]
var
html
=
''
;
for
(
var
i
in
my_vms
)
{
if
(
my_vms
[
i
].
name
.
indexOf
(
input
)
!=
-
1
)
{
search_result
.
push
(
my_vms
[
i
]);
}
}
for
(
var
i
=
0
;
i
<
5
&&
i
<
search_result
.
length
;
i
++
)
html
+=
generateVmHTML
(
search_result
[
i
].
pk
,
search_result
[
i
].
name
)
if
(
search_result
.
length
==
0
)
html
+=
'<div class="list-group-item">No result</div>'
;
$
(
"#dashboard-vm-list"
).
html
(
html
);
});
});
});
function
generateVmHTML
(
pk
,
name
)
{
return
'<a href="/dashboard/vm/'
+
pk
+
'/" class="list-group-item">'
+
'<i class="icon-play-sign"></i> '
+
name
+
'<div class="pull-right">'
+
'<i class="icon-star text-primary" title="" data-original-title="Mark as favorite."></i>'
+
'</div>'
+
'</a>'
;
}
function
addSliderMiscs
()
{
function
addSliderMiscs
()
{
$
(
'.vm-slider'
).
each
(
function
()
{
$
(
'.vm-slider'
).
each
(
function
()
{
$
(
"<span>"
).
addClass
(
"output"
).
html
(
$
(
this
).
val
()).
insertAfter
(
$
(
this
));
$
(
"<span>"
).
addClass
(
"output"
).
html
(
$
(
this
).
val
()).
insertAfter
(
$
(
this
));
...
...
circle/dashboard/templates/dashboard/index-vm.html
View file @
cfc2fc67
...
@@ -13,15 +13,17 @@
...
@@ -13,15 +13,17 @@
</h3>
</h3>
</div>
</div>
<div
class=
"list-group"
id=
"vm-list-view"
>
<div
class=
"list-group"
id=
"vm-list-view"
>
{% for i in instances %}
<div
id=
"dashboard-vm-list"
>
<a
href=
"{{ i.get_absolute_url }}"
class=
"list-group-item"
>
{% for i in instances %}
<i
class=
"icon-{% if i.state == "
RUNNING
"
%}
play-sign
{%
else
%}
pause
{%
endif
%}"
></i>
{{ i.name }}
<div
class=
"pull-right"
><i
class=
"icon-star text-primary"
title=
"Mark as favorite."
></i></div>
<a
href=
"{{ i.get_absolute_url }}"
class=
"list-group-item"
>
<i
class=
"icon-{% if i.state == "
RUNNING
"
%}
play-sign
{%
else
%}
pause
{%
endif
%}"
></i>
{{ i.name }}
<div
class=
"pull-right"
><i
class=
"icon-star text-primary"
title=
"Mark as favorite."
></i></div>
</a>
</a>
{% endfor %}
{% endfor %}
</div>
<div
href=
"#"
class=
"list-group-item list-group-footer"
>
<div
href=
"#"
class=
"list-group-item list-group-footer"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-6 col-xs-6 input-group input-group-sm"
>
<div
class=
"col-sm-6 col-xs-6 input-group input-group-sm"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"Search..."
/>
<input
id=
"dashboard-vm-search-input"
type=
"text"
class=
"form-control"
placeholder=
"Search..."
/>
<div
class=
"input-group-btn"
>
<div
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"form-control btn btn-primary"
title=
"search"
><i
class=
"icon-search"
></i></button>
<button
type=
"submit"
class=
"form-control btn btn-primary"
title=
"search"
><i
class=
"icon-search"
></i></button>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
cfc2fc67
...
@@ -17,6 +17,7 @@ from django.views.generic.detail import SingleObjectMixin
...
@@ -17,6 +17,7 @@ from django.views.generic.detail import SingleObjectMixin
from
django.views.generic
import
(
TemplateView
,
DetailView
,
View
,
DeleteView
,
from
django.views.generic
import
(
TemplateView
,
DetailView
,
View
,
DeleteView
,
UpdateView
,
CreateView
)
UpdateView
,
CreateView
)
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.core
import
serializers
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.forms.models
import
inlineformset_factory
from
django.forms.models
import
inlineformset_factory
...
@@ -431,6 +432,17 @@ class VmList(LoginRequiredMixin, SingleTableView):
...
@@ -431,6 +432,17 @@ class VmList(LoginRequiredMixin, SingleTableView):
table_pagination
=
False
table_pagination
=
False
model
=
Instance
model
=
Instance
def
get
(
self
,
*
args
,
**
kwargs
):
if
self
.
request
.
is_ajax
():
vms
=
serializers
.
serialize
(
'json'
,
self
.
get_queryset
(),
fields
=
(
'pk'
,
'name'
,
'state'
))
return
HttpResponse
(
vms
,
content_type
=
"application/json"
,
)
else
:
return
super
(
VmList
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
logger
.
debug
(
'VmList.get_queryset() called. User:
%
s'
,
logger
.
debug
(
'VmList.get_queryset() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
unicode
(
self
.
request
.
user
))
...
...
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