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
db42d716
authored
Jan 12, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'notifications-enhancement'
Conflicts: circle/dashboard/static/dashboard/dashboard.less
parents
79e445c6
111d424d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
10 deletions
+100
-10
circle/bower.json
+2
-1
circle/circle/settings/base.py
+1
-0
circle/dashboard/models.py
+11
-2
circle/dashboard/static/dashboard/dashboard.js
+10
-1
circle/dashboard/static/dashboard/dashboard.less
+22
-0
circle/dashboard/templates/dashboard/_notifications-timeline.html
+1
-1
circle/dashboard/templates/dashboard/base.html
+5
-2
circle/dashboard/templates/dashboard/notifications.html
+35
-0
circle/dashboard/views/user.py
+13
-3
No files found.
circle/bower.json
View file @
db42d716
...
...
@@ -18,6 +18,7 @@
"jquery-knob"
:
"~1.2.9"
,
"jquery-simple-slider"
:
"https://github.com/BME-IK/jquery-simple-slider.git"
,
"bootbox"
:
"~4.3.0"
,
"intro.js"
:
"0.9.0"
"intro.js"
:
"0.9.0"
,
"favico.js"
:
"~0.3.5"
}
}
circle/circle/settings/base.py
View file @
db42d716
...
...
@@ -197,6 +197,7 @@ PIPELINE_JS = {
"intro.js/intro.js"
,
"jquery-knob/dist/jquery.knob.min.js"
,
"jquery-simple-slider/js/simple-slider.js"
,
"favico.js/favico.js"
,
"dashboard/dashboard.js"
,
"dashboard/activity.js"
,
"dashboard/group-details.js"
,
...
...
circle/dashboard/models.py
View file @
db42d716
...
...
@@ -31,6 +31,7 @@ from django.db.models import (
)
from
django.db.models.signals
import
post_save
,
pre_delete
,
post_delete
from
django.templatetags.static
import
static
from
django.utils.html
import
escape
from
django.utils.translation
import
ugettext_lazy
as
_
from
django_sshkey.models
import
UserKey
from
django.core.exceptions
import
ObjectDoesNotExist
...
...
@@ -87,7 +88,8 @@ class Notification(TimeStampedModel):
@property
def
subject
(
self
):
return
HumanReadableObject
.
from_dict
(
self
.
subject_data
)
return
HumanReadableObject
.
from_dict
(
self
.
escape_dict
(
self
.
subject_data
))
@subject.setter
def
subject
(
self
,
value
):
...
...
@@ -95,7 +97,14 @@ class Notification(TimeStampedModel):
@property
def
message
(
self
):
return
HumanReadableObject
.
from_dict
(
self
.
message_data
)
return
HumanReadableObject
.
from_dict
(
self
.
escape_dict
(
self
.
message_data
))
def
escape_dict
(
self
,
data
):
for
k
,
v
in
data
[
'params'
]
.
items
():
if
isinstance
(
v
,
basestring
):
data
[
'params'
][
k
]
=
escape
(
v
)
return
data
@message.setter
def
message
(
self
,
value
):
...
...
circle/dashboard/static/dashboard/dashboard.js
View file @
db42d716
$
(
function
()
{
var
favicon
=
new
Favico
({
animation
:
'none'
});
var
notifications
=
$
(
"#notification_count"
).
data
(
"notifications"
);
if
(
notifications
)
favicon
.
badge
(
notifications
);
$
(
".not-tab-pane"
).
removeClass
(
"not-tab-pane"
).
addClass
(
"tab-pane"
);
$
(
'.vm-create'
).
click
(
function
(
e
)
{
...
...
@@ -314,6 +322,8 @@ $(function () {
$
(
"#notification-button a"
).
click
(
function
()
{
$
(
'#notification-messages'
).
load
(
"/dashboard/notifications/"
);
$
(
'#notification-button a span[class*="badge-pulse"]'
).
remove
();
favicon
.
reset
();
});
/* on the client confirmation button fire the clientInstalledAction */
...
...
@@ -352,7 +362,6 @@ $(function () {
li
.
addClass
(
'panel-primary'
).
find
(
'input'
).
prop
(
"checked"
,
true
);
return
true
;
});
});
function
generateVmHTML
(
pk
,
name
,
host
,
icon
,
_status
,
fav
,
is_last
)
{
...
...
circle/dashboard/static/dashboard/dashboard.less
View file @
db42d716
...
...
@@ -1195,3 +1195,25 @@ textarea[name="new_members"] {
padding-left: 0px;
}
}
#notifications-upper-pagination {
margin-top: 4px;
}
#notifications-bottom-pagination {
* {
display: inline-block;
}
a {
font-size: 20px;
&:hover {
text-decoration: none;
}
}
.page-numbers {
padding: 25px;
}
}
circle/dashboard/templates/dashboard/_notifications-timeline.html
View file @
db42d716
{% load i18n %}
{% load hro %}
{% for n in
notifications
%}
{% for n in
page
%}
<li
class=
"notification-message"
id=
"msg-{{n.id}}"
>
<span
class=
"notification-message-subject"
>
{% if n.status == "new" %}
<i
class=
"fa fa-envelope-o"
></i>
{% endif %}
...
...
circle/dashboard/templates/dashboard/base.html
View file @
db42d716
...
...
@@ -48,10 +48,13 @@
</li>
<li
class=
"dropdown hidden-xs"
id=
"notification-button"
>
<a
href=
"{% url "
dashboard
.
views
.
notifications
"
%}"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
class=
"dropdown-toggle"
data-toggle=
"dropdown"
id=
"notification_count"
data-notifications=
"{{ NEW_NOTIFICATIONS_COUNT }}"
>
{% trans "Notifications" %}
{% if NEW_NOTIFICATIONS_COUNT > 0 %}
<span
class=
"badge badge-pulse"
>
{{ NEW_NOTIFICATIONS_COUNT }}
</span>
<span
class=
"badge badge-pulse"
>
{{ NEW_NOTIFICATIONS_COUNT }}
</span>
{% endif %}
</a>
<ul
class=
"dropdown-menu"
id=
"notification-messages"
>
...
...
circle/dashboard/templates/dashboard/notifications.html
View file @
db42d716
...
...
@@ -6,6 +6,18 @@
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
id=
"notifications-upper-pagination"
class=
"pull-right"
>
{% if page.has_previous %}
<a
href=
"?page={{ page.previous_page_number }}"
>
<i
class=
"fa fa-chevron-left"
></i></a>
</a>
{% endif %}
{{ page.number }} / {{ paginator.num_pages }}
{% if page.has_next %}
<a
href=
"?page={{ page.next_page_number }}"
><i
class=
"fa fa-chevron-right"
></i></a>
{% endif %}
</div>
<h3
class=
"no-margin"
><i
class=
"fa fa-desktop"
></i>
{% trans "Notifications" %}
</h3>
</div>
<div
class=
"panel-body"
>
...
...
@@ -13,6 +25,29 @@
{% include "dashboard/_notifications-timeline.html" %}
</ul>
</div>
<div
class=
"panel-body text-center"
id=
"notifications-bottom-pagination"
>
{% if page.has_previous %}
<a
href=
"?page=1"
>
<i
class=
"fa fa-angle-double-left"
></i>
</a>
<a
href=
"{% if page.has_previous %}?page={{ page.previous_page_number}}{% else %}#{% endif %}"
>
<i
class=
"fa fa-angle-left"
></i>
</a>
{% endif %}
<div
class=
"page-numbers"
>
{{ page.number }} / {{ paginator.num_pages }}
</div>
{% if page.has_next %}
<a
href=
"{% if page.has_next %}?page={{ page.next_page_number}}{% else %}#{% endif %}"
>
<i
class=
"fa fa-angle-right"
></i>
</a>
<a
href=
"?page={{ paginator.num_pages }}"
>
<i
class=
"fa fa-angle-double-right"
></i>
</a>
{% endif %}
</div>
</div>
</div>
</div>
...
...
circle/dashboard/views/user.py
View file @
db42d716
...
...
@@ -30,6 +30,7 @@ from django.core.exceptions import (
PermissionDenied
,
SuspiciousOperation
,
)
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.paginator
import
Paginator
,
InvalidPage
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
Http404
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -67,9 +68,18 @@ class NotificationView(LoginRequiredMixin, TemplateView):
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
NotificationView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
n
=
10
if
self
.
request
.
is_ajax
()
else
1000
context
[
'notifications'
]
=
list
(
self
.
request
.
user
.
notification_set
.
all
()[:
n
])
paginate_by
=
10
if
self
.
request
.
is_ajax
()
else
25
page
=
self
.
request
.
GET
.
get
(
"page"
,
1
)
notifications
=
self
.
request
.
user
.
notification_set
.
all
()
paginator
=
Paginator
(
notifications
,
paginate_by
)
try
:
current_page
=
paginator
.
page
(
page
)
except
InvalidPage
:
current_page
=
paginator
.
page
(
1
)
context
[
'page'
]
=
current_page
context
[
'paginator'
]
=
paginator
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
...
...
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