Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
e62d7a9b
authored
Feb 25, 2014
by
Kálmán Viktor
Committed by
Őry Máté
Feb 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add notifications templates and view
parent
12426296
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
156 additions
and
12 deletions
+156
-12
circle/dashboard/static/dashboard/dashboard.css
+27
-0
circle/dashboard/static/dashboard/dashboard.js
+21
-1
circle/dashboard/templates/dashboard/_notifications-timeline.html
+15
-0
circle/dashboard/templates/dashboard/base.html
+22
-10
circle/dashboard/templates/dashboard/index.html
+11
-0
circle/dashboard/templates/dashboard/notifications.html
+20
-0
circle/dashboard/urls.py
+4
-1
circle/dashboard/views.py
+36
-0
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
e62d7a9b
...
@@ -331,3 +331,30 @@ a.hover-black {
...
@@ -331,3 +331,30 @@ a.hover-black {
display
:
block
;
display
:
block
;
}
}
.notification-messages
{
padding
:
10px
8px
;
width
:
350px
;
}
.notification-message
{
margin-bottom
:
10px
;
padding
:
0
0
4px
0
;
border-bottom
:
1px
dotted
#D3D3D3
;
}
.notification-messages
.notification-message
:last-child
{
margin-bottom
:
0px
;
padding
:
0px
;
border-bottom
:
none
;
}
.notification-message-text
{
padding
:
8px
15px
;
display
:
none
;
}
.notification-message
.notification-message-subject
{
cursor
:
pointer
;
}
circle/dashboard/static/dashboard/dashboard.js
View file @
e62d7a9b
...
@@ -205,7 +205,27 @@ $(function () {
...
@@ -205,7 +205,27 @@ $(function () {
window
.
location
.
href
=
"/dashboard/vm/list/?s="
+
input
;
window
.
location
.
href
=
"/dashboard/vm/list/?s="
+
input
;
}
}
});
});
/* notification message toggle */
$
(
".notification-message-subject"
).
click
(
function
()
{
$
(
".notification-message-text"
,
$
(
this
).
parent
()).
slideToggle
();
return
false
;
});
/* notification read */
$
(
"#notification-button"
).
click
(
function
()
{
$
.
ajax
({
type
:
"POST"
,
url
:
"/dashboard/notifications/"
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
re
,
textStatus
,
xhr
)
{
//console.log("success");
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
'Uh oh :('
,
'danger'
)
}
});
});
});
});
function
generateVmHTML
(
pk
,
name
,
fav
)
{
function
generateVmHTML
(
pk
,
name
,
fav
)
{
...
...
circle/dashboard/templates/dashboard/_notifications-timeline.html
0 → 100644
View file @
e62d7a9b
{% for n in notifications %}
<li
class=
"notification-message"
>
<span
class=
"notification-message-subject"
>
{% if n.status == "new" %}
<i
class=
"icon-envelope-alt"
></i>
{% endif %}
{{ n.subject }}
</span>
<span
class=
"notification-message-date pull-right"
>
{{ n.created|timesince }}
</span>
<div
style=
"clear: both;"
></div>
<div
class=
"notification-message-text"
>
{{ n.message }}
</div>
</li>
{% endfor %}
circle/dashboard/templates/dashboard/base.html
View file @
e62d7a9b
...
@@ -23,16 +23,28 @@
...
@@ -23,16 +23,28 @@
<body>
<body>
<div
class=
"navbar navbar-inverse navbar-fixed-top"
>
<div
class=
"navbar navbar-inverse navbar-fixed-top"
>
<a
class=
"navbar-brand"
href=
"/dashboard/"
>
{% block header-site %}CIRCLE{% endblock %}
</a>
<div
class=
"navbar-header"
>
<!-- temporarily -->
<a
class=
"navbar-brand"
href=
"{% url "
dashboard
.
index
"
%}"
>
CIRCLE
</a>
<a
class=
"navbar-brand pull-right"
href=
"/network/"
style=
"color: white; font-size: 10px;"
>
Network
</a>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
".navbar-collapse"
>
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
>
Admin
</a>
<span
class=
"icon-bar"
></span>
{% if user.is_authenticated %}
<span
class=
"icon-bar"
></span>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
logout
"
%}?
next=
{%
url
"
login
"
%}"
style=
"color: white; font-size: 10px;"
>
Log out {{user}}
</a>
<span
class=
"icon-bar"
></span>
{% else %}
</button>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
>
Login
</a>
</div>
<!-- .navbar-header -->
{% endif %}
<div
class=
"collapse navbar-collapse"
>
</div>
<ul
class=
"nav navbar-nav pull-right"
>
{% block navbar-ul %}
{% endblock %}
</ul>
<a
class=
"navbar-brand pull-right"
href=
"/network/"
style=
"color: white; font-size: 10px;"
>
Network
</a>
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
>
Admin
</a>
{% if user.is_authenticated %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
logout
"
%}?
next=
{%
url
"
login
"
%}"
style=
"color: white; font-size: 10px;"
>
Log out {{user}}
</a>
{% else %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
>
Login
</a>
{% endif %}
</div>
<!-- .collapse .navbar-collapse -->
</div>
<!-- navbar navbar-inverse navbar-fixed-top -->
<div
class=
"container"
>
<div
class=
"container"
>
{% block messages %}
{% block messages %}
...
...
circle/dashboard/templates/dashboard/index.html
View file @
e62d7a9b
...
@@ -3,6 +3,17 @@
...
@@ -3,6 +3,17 @@
{% block title-page %}{% trans "Dashboard" %}{% endblock %}
{% block title-page %}{% trans "Dashboard" %}{% endblock %}
{% block navbar-ul %}
<li
class=
"dropdown"
id=
"notification-button"
>
<a
href=
"{% url "
dashboard
.
views
.
notifications
"
%}"
style=
"color: white; font-size: 12px;"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Notifications{% if new_notifications > 0 %}
<span
class=
"badge"
>
{{ new_notifications }}
</span>
{% endif %}
</a>
<ul
class=
"dropdown-menu notification-messages"
>
{% include "dashboard/_notifications-timeline.html" %}
</ul>
</li>
{% endblock %}
{% block content %}
{% block content %}
<div
class=
"body-content dashboard-index"
>
<div
class=
"body-content dashboard-index"
>
<div
class=
"row"
>
<div
class=
"row"
>
...
...
circle/dashboard/templates/dashboard/notifications.html
0 → 100644
View file @
e62d7a9b
{% extends "dashboard/base.html" %}
{% load i18n %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h3
class=
"no-margin"
><i
class=
"icon-desktop"
></i>
{% trans "Notifications" %}
</h3>
</div>
<div
class=
"panel-body"
>
<ul
style=
"list-style: none;"
>
{% include "dashboard/_notifications-timeline.html" %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
e62d7a9b
...
@@ -8,7 +8,7 @@ from .views import (
...
@@ -8,7 +8,7 @@ from .views import (
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
VmGraphView
,
TemplateAclUpdateView
,
GroupDetailView
,
GroupDelete
,
VmGraphView
,
TemplateAclUpdateView
,
GroupDetailView
,
GroupDelete
,
GroupAclUpdateView
,
GroupUserDelete
,
No
deGraphView
GroupAclUpdateView
,
GroupUserDelete
,
No
tificationView
,
NodeGraphView
,
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -81,4 +81,7 @@ urlpatterns = patterns(
...
@@ -81,4 +81,7 @@ urlpatterns = patterns(
name
=
'dashboard.views.group-acl'
),
name
=
'dashboard.views.group-acl'
),
url
(
r'^groupuser/delete/(?P<pk>\d+)/$'
,
GroupUserDelete
.
as_view
(),
url
(
r'^groupuser/delete/(?P<pk>\d+)/$'
,
GroupUserDelete
.
as_view
(),
name
=
"dashboard.views.delete-groupuser"
),
name
=
"dashboard.views.delete-groupuser"
),
url
(
r'^notifications/$'
,
NotificationView
.
as_view
(),
name
=
"dashboard.views.notifications"
),
)
)
circle/dashboard/views.py
View file @
e62d7a9b
...
@@ -83,6 +83,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
...
@@ -83,6 +83,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
if
user
is
not
None
:
if
user
is
not
None
:
context
[
'notifications'
]
=
user
.
notification_set
.
all
()[:
10
]
context
[
'notifications'
]
=
user
.
notification_set
.
all
()[:
10
]
context
[
'new_notifications'
]
=
user
.
notification_set
.
filter
(
status
=
"new"
)
.
count
()
nodes
=
Node
.
objects
.
all
()
nodes
=
Node
.
objects
.
all
()
groups
=
Group
.
objects
.
all
()
groups
=
Group
.
objects
.
all
()
...
@@ -1655,3 +1657,37 @@ class NodeGraphView(SuperuserRequiredMixin, GraphViewBase):
...
@@ -1655,3 +1657,37 @@ class NodeGraphView(SuperuserRequiredMixin, GraphViewBase):
def
get_object
(
self
,
request
,
pk
):
def
get_object
(
self
,
request
,
pk
):
return
self
.
model
.
objects
.
get
(
id
=
pk
)
return
self
.
model
.
objects
.
get
(
id
=
pk
)
class
NotificationView
(
LoginRequiredMixin
,
TemplateView
):
template_name
=
"dashboard/notifications.html"
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
NotificationView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
# we need to convert it to list, otherwise it's gonna be
# similar to a QuerySet and update everything to
# read status after get
context
[
'notifications'
]
=
list
(
self
.
request
.
user
.
notification_set
.
values
())
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
response
=
super
(
NotificationView
,
self
)
.
get
(
*
args
,
**
kwargs
)
un
=
self
.
request
.
user
.
notification_set
.
filter
(
status
=
"new"
)
for
u
in
un
:
u
.
status
=
"read"
u
.
save
()
return
response
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
# unread notifications
un
=
request
.
user
.
notification_set
.
filter
(
status
=
"new"
)
for
u
in
un
:
u
.
status
=
"read"
u
.
save
()
if
request
.
is_ajax
():
return
HttpResponse
({
'result'
:
'ok'
})
else
:
pass
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