show todo, calendar and support desktop notifications
This commit is contained in:
parent
b5b39f0e48
commit
7854f81ca0
@ -69,14 +69,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hover and click effects */
|
/* Hover and click effects */
|
||||||
.case-border:hover, .circle:hover {
|
.case-border:hover, .circle:hover, .hover-effect {
|
||||||
box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
|
box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important;
|
||||||
-moz-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
|
-moz-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important;
|
||||||
-webkit-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
|
-webkit-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important;
|
||||||
-o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
|
-o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.case-border:active, .case-border:focus, .circle:active, .circle:focus {
|
.case-border:active, .case-border:focus, .case-border-click {
|
||||||
transform: scale(0.98, 0.98);
|
transform: scale(0.98, 0.98);
|
||||||
-ms-transform: scale(0.98, 0.98); /* IE 9 */
|
-ms-transform: scale(0.98, 0.98); /* IE 9 */
|
||||||
-webkit-transform: scale(0.98, 0.98); /* Safari and Chrome */
|
-webkit-transform: scale(0.98, 0.98); /* Safari and Chrome */
|
||||||
@ -84,6 +84,14 @@
|
|||||||
-moz-transform: scale(0.98, 0.98); /* Firefox */
|
-moz-transform: scale(0.98, 0.98); /* Firefox */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.circle:active, .circle:focus, .circle-click {
|
||||||
|
transform: scale(1, 1);
|
||||||
|
-ms-transform: scale(1, 1); /* IE 9 */
|
||||||
|
-webkit-transform: scale(1, 1); /* Safari and Chrome */
|
||||||
|
-o-transform: scale(1, 1); /* Opera */
|
||||||
|
-moz-transform: scale(1, 1); /* Firefox */
|
||||||
|
}
|
||||||
|
|
||||||
.circle {
|
.circle {
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
-moz-border-radius: 30px;
|
-moz-border-radius: 30px;
|
||||||
@ -93,9 +101,8 @@
|
|||||||
min-width: 15px;
|
min-width: 15px;
|
||||||
background: #B00D07;
|
background: #B00D07;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
z-index: 2;
|
|
||||||
float: right;
|
float: right;
|
||||||
margin-top: -10px;
|
margin-top: -74px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
box-shadow: 0 0 10px 1px black;
|
box-shadow: 0 0 10px 1px black;
|
||||||
@ -106,10 +113,8 @@
|
|||||||
|
|
||||||
.circle-text {
|
.circle-text {
|
||||||
color: white;
|
color: white;
|
||||||
vertical-align: middle;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: -3px;
|
margin-top: 1px;
|
||||||
text-shadow: 1px 1px 5px #000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +95,37 @@ erpnext.desktop.render = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.desktop.show_pending_notifications = function() {
|
erpnext.desktop.show_pending_notifications = function() {
|
||||||
$('#messages a:first').prepend('<div id="msg_count" class="circle" title="Unread Messages">\
|
var add_circle = function(str_module, id, title) {
|
||||||
<span class="circle-text"></span></div>');
|
var module = $('#'+str_module);
|
||||||
$('#msg_count').toggle(false);
|
module.find('a:first').append(
|
||||||
|
repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\
|
||||||
|
<span class="circle-text"></span>\
|
||||||
|
</div>', {id: id, title: title}));
|
||||||
|
|
||||||
|
var case_border = module.find('.case-border');
|
||||||
|
var circle = module.find('.circle');
|
||||||
|
|
||||||
|
var add_hover_and_click = function(primary, secondary, hover_class, click_class) {
|
||||||
|
primary
|
||||||
|
.hover(
|
||||||
|
function() { secondary.addClass(hover_class); },
|
||||||
|
function() { secondary.removeClass(hover_class); })
|
||||||
|
.mousedown(function() { secondary.addClass(click_class); })
|
||||||
|
.mouseup(function() { secondary.removeClass(click_class); })
|
||||||
|
.focusin(function() { $(this).mousedown(); })
|
||||||
|
.focusout(function() { $(this).mouseup(); })
|
||||||
|
}
|
||||||
|
|
||||||
|
add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click');
|
||||||
|
add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
add_circle('messages', 'unread_messages', 'Unread Messages');
|
||||||
|
add_circle('support', 'open_support_tickets', 'Open Support Tickets');
|
||||||
|
add_circle('todo', 'things_todo', 'Things To Do');
|
||||||
|
add_circle('calendar', 'todays_events', 'Todays Events');
|
||||||
|
|
||||||
update_messages();
|
update_messages();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ pscript.home_make_status = function() {
|
|||||||
// get values
|
// get values
|
||||||
$c_page('home', 'event_updates', 'get_status_details', user,
|
$c_page('home', 'event_updates', 'get_status_details', user,
|
||||||
function(r,rt) {
|
function(r,rt) {
|
||||||
page_body.wntoolbar.set_new_comments(r.message.unread_messages);
|
//page_body.wntoolbar.set_new_comments(r.message.unread_messages);
|
||||||
|
|
||||||
// render online users
|
// render online users
|
||||||
pscript.online_users_obj.render(r.message.online_users);
|
pscript.online_users_obj.render(r.message.online_users);
|
||||||
|
@ -26,8 +26,7 @@ def get_online_users(arg=None):
|
|||||||
and t1.user not in ('Guest','Administrator')
|
and t1.user not in ('Guest','Administrator')
|
||||||
and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or []
|
and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or []
|
||||||
|
|
||||||
@webnotes.whitelist()
|
def get_unread_messages():
|
||||||
def get_unread_messages(arg=None):
|
|
||||||
"returns unread (docstatus-0 messages for a user)"
|
"returns unread (docstatus-0 messages for a user)"
|
||||||
return webnotes.conn.sql("""\
|
return webnotes.conn.sql("""\
|
||||||
SELECT name, comment
|
SELECT name, comment
|
||||||
@ -37,6 +36,49 @@ def get_unread_messages(arg=None):
|
|||||||
AND ifnull(docstatus,0)=0
|
AND ifnull(docstatus,0)=0
|
||||||
""", webnotes.user.name, as_list=1)
|
""", webnotes.user.name, as_list=1)
|
||||||
|
|
||||||
|
def get_open_support_tickets():
|
||||||
|
"""
|
||||||
|
Returns a count of open support tickets
|
||||||
|
"""
|
||||||
|
from webnotes.utils import cint
|
||||||
|
open_support_tickets = webnotes.conn.sql("""\
|
||||||
|
SELECT COUNT(*) FROM `tabSupport Ticket`
|
||||||
|
WHERE status = 'Open'""")
|
||||||
|
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
|
||||||
|
|
||||||
|
def get_things_todo():
|
||||||
|
"""
|
||||||
|
Returns a count of incomplete todos
|
||||||
|
"""
|
||||||
|
from webnotes.utils import cint
|
||||||
|
incomplete_todos = webnotes.conn.sql("""\
|
||||||
|
SELECT COUNT(*) FROM `tabToDo Item`
|
||||||
|
WHERE IFNULL(checked, 0) = 0
|
||||||
|
AND owner = %s""", webnotes.session.get('user'))
|
||||||
|
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
|
||||||
|
|
||||||
|
def get_todays_events():
|
||||||
|
"""
|
||||||
|
Returns a count of todays events in calendar
|
||||||
|
"""
|
||||||
|
from webnotes.utils import nowdate, cint
|
||||||
|
todays_events = webnotes.conn.sql("""\
|
||||||
|
SELECT COUNT(*) FROM `tabEvent`
|
||||||
|
WHERE owner = %s
|
||||||
|
AND event_type != 'Cancel'
|
||||||
|
AND event_date = %s""", (
|
||||||
|
webnotes.session.get('user'), nowdate()))
|
||||||
|
return todays_events and cint(todays_events[0][0]) or 0
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_global_status_messages(arg=None):
|
||||||
|
return {
|
||||||
|
'unread_messages': get_unread_messages(),
|
||||||
|
'open_support_tickets': get_open_support_tickets(),
|
||||||
|
'things_todo': get_things_todo(),
|
||||||
|
'todays_events': get_todays_events(),
|
||||||
|
}
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_status_details(arg=None):
|
def get_status_details(arg=None):
|
||||||
"""get toolbar items"""
|
"""get toolbar items"""
|
||||||
@ -47,7 +89,8 @@ def get_status_details(arg=None):
|
|||||||
# system messages
|
# system messages
|
||||||
ret = {
|
ret = {
|
||||||
'user_count': len(online) or 0,
|
'user_count': len(online) or 0,
|
||||||
'unread_messages': get_unread_messages(),
|
#'unread_messages': get_unread_messages(),
|
||||||
|
#'open_support_tickets': get_open_support_tickets(),
|
||||||
'online_users': online or [],
|
'online_users': online or [],
|
||||||
'setup_status': get_setup_status(),
|
'setup_status': get_setup_status(),
|
||||||
'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No',
|
'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No',
|
||||||
|
@ -110,20 +110,29 @@ var update_messages = function(reset) {
|
|||||||
if(inList(['Guest'], user)) { return; }
|
if(inList(['Guest'], user)) { return; }
|
||||||
|
|
||||||
if(!reset) {
|
if(!reset) {
|
||||||
$c_page('home', 'event_updates', 'get_unread_messages', null,
|
$c_page('home', 'event_updates', 'get_global_status_messages', null,
|
||||||
function(r,rt) {
|
function(r,rt) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
// This function is defined in toolbar.js
|
// This function is defined in toolbar.js
|
||||||
page_body.wntoolbar.set_new_comments(r.message);
|
page_body.wntoolbar.set_new_comments(r.message.unread_messages);
|
||||||
var circle = $('#msg_count')
|
|
||||||
if(circle) {
|
var show_in_circle = function(parent_id, msg) {
|
||||||
if(r.message.length) {
|
var parent = $('#'+parent_id);
|
||||||
circle.find('span:first').text(r.message.length);
|
if(parent) {
|
||||||
circle.toggle(true);
|
if(msg) {
|
||||||
} else {
|
parent.find('span:first').text(msg);
|
||||||
circle.toggle(false);
|
parent.toggle(true);
|
||||||
|
} else {
|
||||||
|
parent.toggle(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_in_circle('unread_messages', r.message.unread_messages.length);
|
||||||
|
show_in_circle('open_support_tickets', r.message.open_support_tickets);
|
||||||
|
show_in_circle('things_todo', r.message.things_todo);
|
||||||
|
show_in_circle('todays_events', r.message.todays_events);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clearInterval(wn.updates.id);
|
clearInterval(wn.updates.id);
|
||||||
}
|
}
|
||||||
@ -131,7 +140,7 @@ var update_messages = function(reset) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
page_body.wntoolbar.set_new_comments(0);
|
page_body.wntoolbar.set_new_comments(0);
|
||||||
$('#msg_count').toggle(false);
|
$('#unread_messages').toggle(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1077,8 +1077,8 @@ else if(nm=='Accounts Browser')
|
|||||||
pscript.make_chart(chart_type);}
|
pscript.make_chart(chart_type);}
|
||||||
loadpage(nm,call_back);}
|
loadpage(nm,call_back);}
|
||||||
var update_messages=function(reset){if(inList(['Guest'],user)){return;}
|
var update_messages=function(reset){if(inList(['Guest'],user)){return;}
|
||||||
if(!reset){$c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message);var circle=$('#msg_count')
|
if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
|
||||||
if(circle){if(r.message.length){circle.find('span:first').text(r.message.length);circle.toggle(true);}else{circle.toggle(false);}}}else{clearInterval(wn.updates.id);}});}else{page_body.wntoolbar.set_new_comments(0);$('#msg_count').toggle(false);}}
|
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{page_body.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
|
||||||
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
|
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
|
||||||
wn.updates.id=setInterval(update_messages,60000);}
|
wn.updates.id=setInterval(update_messages,60000);}
|
||||||
erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))}
|
erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))}
|
||||||
|
@ -1 +1 @@
|
|||||||
821
|
829
|
10
wnf.py
10
wnf.py
@ -97,6 +97,9 @@ def setup_options():
|
|||||||
parser.add_option("--replace", nargs=3, default=False,
|
parser.add_option("--replace", nargs=3, default=False,
|
||||||
metavar = "search replace_by extension",
|
metavar = "search replace_by extension",
|
||||||
help="file search-replace")
|
help="file search-replace")
|
||||||
|
|
||||||
|
parser.add_option("--cci", nargs=1, metavar="CacheItem Key",
|
||||||
|
help="Clear Cache Item")
|
||||||
|
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
@ -209,6 +212,13 @@ def run():
|
|||||||
import webnotes.utils.scheduler
|
import webnotes.utils.scheduler
|
||||||
print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
|
print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
|
||||||
|
|
||||||
|
elif options.cci is not None:
|
||||||
|
if options.cci=='all':
|
||||||
|
webnotes.conn.sql("DELETE FROM __CacheItem")
|
||||||
|
else:
|
||||||
|
from webnotes.utils.cache import CacheItem
|
||||||
|
CacheItem(options.cci).clear()
|
||||||
|
|
||||||
# print messages
|
# print messages
|
||||||
if webnotes.message_log:
|
if webnotes.message_log:
|
||||||
print '\n'.join(webnotes.message_log)
|
print '\n'.join(webnotes.message_log)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user