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
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
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
4 deletions
+148
-4
circle/dashboard/static/dashboard/dashboard.css
+27
-0
circle/dashboard/static/dashboard/dashboard.js
+20
-0
circle/dashboard/templates/dashboard/_notifications-timeline.html
+15
-0
circle/dashboard/templates/dashboard/base.html
+15
-3
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
...
@@ -206,6 +206,26 @@ $(function () {
...
@@ -206,6 +206,26 @@ $(function () {
}
}
});
});
/* 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,8 +23,19 @@
...
@@ -23,8 +23,19 @@
<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>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
".navbar-collapse"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
</div>
<!-- .navbar-header -->
<div
class=
"collapse navbar-collapse"
>
<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=
"/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>
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
>
Admin
</a>
{% if user.is_authenticated %}
{% if user.is_authenticated %}
...
@@ -32,7 +43,8 @@
...
@@ -32,7 +43,8 @@
{% else %}
{% else %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
>
Login
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
login
"
%}?
next=
{%
url
"
dashboard
.
index
"
%}"
style=
"color: white; font-size: 10px;"
>
Login
</a>
{% endif %}
{% endif %}
</div>
</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