Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
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
c85691f6
authored
Sep 22, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add graph time options for node graphs
parent
83635528
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
9 deletions
+51
-9
circle/dashboard/templates/dashboard/node-detail/home.html
+13
-5
circle/dashboard/templates/dashboard/node-list.html
+10
-2
circle/dashboard/views/node.py
+5
-2
circle/dashboard/views/util.py
+23
-0
No files found.
circle/dashboard/templates/dashboard/node-detail/home.html
View file @
c85691f6
...
...
@@ -29,12 +29,20 @@
</div>
<!-- id:node-details-traits -->
</div>
<div
class=
"col-md-8"
>
<div
class=
"text-center"
>
{% for o in graph_time_options %}
<a
class=
"btn btn-default btn-xs"
href=
"?graph_time={{ o.time }}"
>
{{ o.name }}
</a>
{% endfor %}
</div>
{% if graphite_enabled %}
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
cpu
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
memory
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
network
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
vm
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
alloc
"
"
6h
"
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
cpu
"
graph_time
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
memory
"
graph_time
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
network
"
graph_time
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
vm
"
graph_time
%}"
style=
"width:100%"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-graph
"
node
.
pk
"
alloc
"
graph_time
%}"
style=
"width:100%"
/>
{% endif %}
</div>
</div>
...
...
circle/dashboard/templates/dashboard/node-list.html
View file @
c85691f6
...
...
@@ -25,11 +25,19 @@
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-right"
>
{% for o in graph_time_options %}
<a
class=
"btn btn-default btn-xs"
href=
"?graph_time={{ o.time }}"
>
{{ o.name }}
</a>
{% endfor %}
</div>
<h3
class=
"no-margin"
><i
class=
"fa fa-area-chart"
></i>
{% trans "Graphs" %}
</h3>
</div>
<div
class=
"text-center"
>
<img
src=
"{% url "
dashboard
.
views
.
node-list-graph
"
"
alloc
"
"
6h
"
%}"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-list-graph
"
"
vm
"
"
6h
"
%}"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-list-graph
"
"
alloc
"
graph_time
%}"
/>
<img
src=
"{% url "
dashboard
.
views
.
node-list-graph
"
"
vm
"
graph_time
%}"
/>
</div>
</div>
</div>
<!-- -col-md-12 -->
...
...
circle/dashboard/views/node.py
View file @
c85691f6
...
...
@@ -37,9 +37,11 @@ from vm.models import Node, NodeActivity, Trait
from
..forms
import
TraitForm
,
HostForm
,
NodeForm
from
..tables
import
NodeListTable
from
.util
import
GraphMixin
class
NodeDetailView
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DetailView
):
class
NodeDetailView
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
GraphMixin
,
DetailView
):
template_name
=
"dashboard/node-detail.html"
model
=
Node
form
=
None
...
...
@@ -106,7 +108,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return
redirect
(
self
.
object
.
get_absolute_url
())
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
GraphMixin
,
SingleTableView
):
template_name
=
"dashboard/node-list.html"
table_class
=
NodeListTable
table_pagination
=
False
...
...
circle/dashboard/views/util.py
View file @
c85691f6
...
...
@@ -535,5 +535,28 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin):
return
redirect
(
"
%
s#access"
%
self
.
instance
.
get_absolute_url
())
class
GraphMixin
(
object
):
graph_time_options
=
[
{
'time'
:
"1h"
,
'name'
:
_
(
"1 hour"
)},
{
'time'
:
"1d"
,
'name'
:
_
(
"1 day"
)},
{
'time'
:
"1w"
,
'name'
:
_
(
"1 week"
)},
{
'time'
:
"4w"
,
'name'
:
_
(
"1 month"
)},
]
default_graph_time
=
"6h"
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
GraphMixin
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
graph_time
=
self
.
request
.
GET
.
get
(
"graph_time"
,
self
.
default_graph_time
)
if
not
re
.
match
(
"^[0-9]{1,2}[hdwy]$"
,
graph_time
):
messages
.
warning
(
self
.
request
,
_
(
"Bad graph time format, "
"available periods are: "
"h, d, w, and y."
))
graph_time
=
self
.
default_graph_time
context
[
'graph_time'
]
=
graph_time
context
[
'graph_time_options'
]
=
self
.
graph_time_options
return
context
def
absolute_url
(
url
):
return
urljoin
(
settings
.
DJANGO_URL
,
url
)
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