mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-29 19:48:27 +00:00
user background
This commit is contained in:
@@ -14,7 +14,7 @@ erpnext.ActivityFeed = Class.extend({
|
||||
init: function(row, data) {
|
||||
this.scrub_data(data);
|
||||
this.add_date_separator(row, data);
|
||||
$(row).append(repl('<span %(onclick)s\
|
||||
$(row).append(sprintf('<span %(onclick)s\
|
||||
class="label %(add_class)s">%(feed_type)s</span>\
|
||||
%(link)s %(subject)s <span class="user-info">%(by)s</span>', data));
|
||||
},
|
||||
|
||||
@@ -26,13 +26,15 @@ MyProfile = function(wrapper) {
|
||||
|
||||
this.make = function() {
|
||||
this.head = new PageHeader(this.wrapper, 'My Profile Settings');
|
||||
this.head.add_button('Change Password', this.change_password)
|
||||
this.head.add_button('Change Password', this.change_password);
|
||||
this.head.add_button('Change Background', this.change_background);
|
||||
|
||||
this.tab = make_table($a(this.wrapper, 'div', '', {marginTop:'19px'}),
|
||||
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
|
||||
this.img = $a($td(this.tab, 0, 0), 'img');
|
||||
set_user_img(this.img, user);
|
||||
|
||||
$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image)
|
||||
$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image);
|
||||
|
||||
this.make_form();
|
||||
this.load_details();
|
||||
@@ -105,32 +107,42 @@ MyProfile = function(wrapper) {
|
||||
//
|
||||
|
||||
this.change_image = function() {
|
||||
if(!me.change_dialog) {
|
||||
|
||||
var d = new Dialog(400,200,'Set Your Profile Image');
|
||||
d.make_body([
|
||||
['HTML','wrapper']
|
||||
]);
|
||||
|
||||
var w = d.widgets['wrapper'];
|
||||
me.uploader = new Uploader(w,
|
||||
{
|
||||
modulename:'home.page.profile_settings.profile_settings',
|
||||
method: 'set_user_image'
|
||||
},
|
||||
pscript.user_image_upload, 1)
|
||||
me.change_dialog = d;
|
||||
}
|
||||
me.change_dialog.show();
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set your Profile'
|
||||
})
|
||||
me.uploader = new Uploader(d.body, {
|
||||
modulename:'home.page.profile_settings.profile_settings',
|
||||
method: 'set_user_image'
|
||||
},
|
||||
pscript.user_image_upload, 1)
|
||||
d.show();
|
||||
pscript.open_dialog = d;
|
||||
}
|
||||
|
||||
this.change_background = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set Background Image'
|
||||
})
|
||||
me.uploader = new Uploader(d.body, {
|
||||
modulename:'home.page.profile_settings.profile_settings',
|
||||
method: 'set_user_background'
|
||||
},
|
||||
pscript.background_change, 1)
|
||||
d.show();
|
||||
pscript.open_dialog = d;
|
||||
}
|
||||
this.make();
|
||||
}
|
||||
|
||||
pscript.background_change = function(fid) {
|
||||
//erpnext.set_background_image(fid);
|
||||
pscript.open_dialog.hide();
|
||||
}
|
||||
|
||||
pscript.user_image_upload = function(fid) {
|
||||
msgprint('File Uploaded');
|
||||
|
||||
if(fid) {
|
||||
pscript.myprofile.change_dialog.hide();
|
||||
pscript.open_dialog.hide();
|
||||
set_user_img(pscript.myprofile.img, user, null, fid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,31 @@ def set_user_image(fid, fname):
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
from webnotes.utils.file_manager import add_file_list, remove_all
|
||||
remove_all('Profile', webnotes.session['user'])
|
||||
add_file_list('Profile', webnotes.session['user'], fname, fid)
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file
|
||||
user = webnotes.session['user']
|
||||
|
||||
# remove old file
|
||||
old_image = webnotes.conn.get_value('Profile', user, 'user_image')
|
||||
if old_image:
|
||||
remove_file('Profile', user, old_image)
|
||||
|
||||
# add new file
|
||||
add_file_list('Profile', user, fname, fid)
|
||||
webnotes.conn.set_value('Profile', user, 'user_image', fid)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_background(fid, fname):
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file
|
||||
user = webnotes.session['user']
|
||||
|
||||
# remove old file
|
||||
old_image = webnotes.conn.get_value('Profile', user, 'background_image')
|
||||
if old_image:
|
||||
remove_file('Profile', user, old_image)
|
||||
|
||||
# add new file
|
||||
add_file_list('Profile', user, fname, fid)
|
||||
webnotes.conn.set_value('Profile', user, 'background_image', fid)
|
||||
|
||||
@@ -35,6 +35,7 @@ def execute():
|
||||
reload_doc('setup', 'page', 'modules_setup')
|
||||
reload_doc('utilities', 'page', 'users')
|
||||
reload_doc('home', 'page', 'activity')
|
||||
reload_doc('core', 'doctype', 'profile')
|
||||
|
||||
webnotes.conn.set_value('Control Panel', 'Control Panel', 'home_page',
|
||||
'desktop')
|
||||
|
||||
@@ -93,6 +93,8 @@ def boot_session(bootinfo):
|
||||
# if no company, show a dialog box to create a new company
|
||||
bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
|
||||
tabCompany limit 1""") and 'Yes' or 'No'
|
||||
|
||||
bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
|
||||
|
||||
def get_letter_heads():
|
||||
"""load letter heads with startup"""
|
||||
|
||||
@@ -50,6 +50,9 @@ erpnext.startup.start = function() {
|
||||
if(wn.boot.custom_css) {
|
||||
set_style(wn.boot.custom_css);
|
||||
}
|
||||
if(wn.boot.user_background) {
|
||||
erpnext.set_user_background(wn.boot.user_background);
|
||||
}
|
||||
|
||||
if(user == 'Guest'){
|
||||
if(wn.boot.website_settings.title_prefix) {
|
||||
@@ -132,6 +135,10 @@ erpnext.startup.set_periodic_updates = function() {
|
||||
wn.updates.id = setInterval(update_messages, 60000);
|
||||
}
|
||||
|
||||
erpnext.set_user_background = function(src) {
|
||||
set_style(repl('body { background: url("files/%(src)s") repeat !important;}', {src:src}))
|
||||
}
|
||||
|
||||
// =======================================
|
||||
|
||||
// start
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
body {
|
||||
{% if doc.background_image %}
|
||||
background: url("files/{{ doc.background_image }}") repeat !important;
|
||||
background: url("files/{{ doc.background_image }}") repeat;
|
||||
{% elif doc.background_color %}
|
||||
background-color: #{{ doc.background_color }};
|
||||
{% endif %}
|
||||
|
||||
@@ -129,13 +129,13 @@ return output.join('');};str_format.cache={};str_format.parse=function(fmt){var
|
||||
else{arg=argv[cursor++];}
|
||||
if(/[^s]/.test(match[8])&&(get_type(arg)!='number')){throw(sprintf('[sprintf] expecting number but found %s',get_type(arg)));}
|
||||
switch(match[8]){case'b':arg=arg.toString(2);break;case'c':arg=String.fromCharCode(arg);break;case'd':arg=parseInt(arg,10);break;case'e':arg=match[7]?arg.toExponential(match[7]):arg.toExponential();break;case'f':arg=match[7]?parseFloat(arg).toFixed(match[7]):parseFloat(arg);break;case'o':arg=arg.toString(8);break;case's':arg=((arg=String(arg))&&match[7]?arg.substring(0,match[7]):arg);break;case'u':arg=Math.abs(arg);break;case'x':arg=arg.toString(16);break;case'X':arg=arg.toString(16).toUpperCase();break;}
|
||||
arg=(/[def]/.test(match[8])&&match[3]&&arg>=0?'+'+arg:arg);pad_character=match[4]?match[4]=='0'?'0':match[4].charAt(1):' ';pad_length=match[6]-String(arg).length;pad=match[6]?str_repeat(pad_character,pad_length):'';output.push(match[5]?arg+pad:pad+arg);}}
|
||||
return output.join('');};str_format.cache={};str_format.parse=function(fmt){var _fmt=fmt,match=[],parse_tree=[],arg_names=0;while(_fmt){if((match=/^[^\x25]+/.exec(_fmt))!==null){parse_tree.push(match[0]);}
|
||||
arg=(/[def]/.test(match[8])&&match[3]&&arg>=0?'+'+arg:arg);pad_character=match[4]?match[4]=='0'?'0':match[4].charAt(1):' ';pad_length=match[6]-String(arg).length;pad=match[6]?str_repeat(pad_character,pad_length):'';output.push(match[5]?arg+pad:pad+arg);}}
|
||||
return output.join('');};str_format.cache={};str_format.parse=function(fmt){var _fmt=fmt,match=[],parse_tree=[],arg_names=0;while(_fmt){if((match=/^[^\x25]+/.exec(_fmt))!==null){parse_tree.push(match[0]);}
|
||||
else if((match=/^\x25{2}/.exec(_fmt))!==null){parse_tree.push('%');}
|
||||
else if((match=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt))!==null){if(match[2]){arg_names|=1;var field_list=[],replacement_field=match[2],field_match=[];if((field_match=/^([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);while((replacement_field=replacement_field.substring(field_match[0].length))!==''){if((field_match=/^\.([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);}
|
||||
else if((field_match=/^\[(\d+)\]/.exec(replacement_field))!==null){field_list.push(field_match[1]);}
|
||||
else{throw('[sprintf] huh?');}}}
|
||||
else{}
|
||||
else{throw('[sprintf] huh?');}
|
||||
match[2]=field_list;}
|
||||
else{arg_names|=2;}
|
||||
if(arg_names===3){throw('[sprintf] mixing positional and named placeholders is not (yet) supported');}
|
||||
@@ -280,7 +280,9 @@ var lstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var first_char=s.su
|
||||
return s.substr(0,len-3)+'...';else
|
||||
return s;}
|
||||
var strip=function(s,chars){var s=lstrip(s,chars)
|
||||
s=rstrip(s,chars);return s;}
|
||||
s=rstrip(s,chars);return s;}
|
||||
var lstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var first_char=s.substr(0,1);while(in_list(chars,first_char)){var s=s.substr(1);first_char=s.substr(0,1);}
|
||||
return s;}
|
||||
var rstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var last_char=s.substr(s.length-1);while(in_list(chars,last_char)){var s=s.substr(0,this.length-1);last_char=s.substr(this.length-1);}
|
||||
return s;}
|
||||
function repl_all(s,s1,s2){var idx=s.indexOf(s1);while(idx!=-1){s=s.replace(s1,s2);idx=s.indexOf(s1);}
|
||||
@@ -1677,7 +1679,7 @@ _f.Frm.prototype.setup=function(){var me=this;this.fields=[];this.fields_dict={}
|
||||
wn.provide('_f');_f.edit_record=function(dt,dn){d=_f.frm_dialog;var show_dialog=function(){var f=frms[dt];if(f.meta.istable){f.parent_doctype=cur_frm.doctype;f.parent_docname=cur_frm.docname;}
|
||||
d.cur_frm=f;d.dn=dn;d.table_form=f.meta.istable;f.refresh(dn);}
|
||||
if(!frms[dt]){_f.add_frm(dt,show_dialog,null);}else{show_dialog();}}
|
||||
_f.Frm=function(doctype,parent){this.docname='';this.doctype=doctype;this.display=0;var me=this;this.is_editable={};this.opendocs={};this.cur_section={};this.sections=[];this.sections_by_label={};this.section_count;this.grids=[];this.cscript={};this.pformat={};this.fetch_dict={};this.parent=parent;this.tinymce_id_list=[];frms[doctype]=this;this.setup_meta(doctype);rename_observers.push(this);}
|
||||
_f.Frm=function(doctype,parent){this.docname='';this.doctype=doctype;this.display=0;var me=this;this.is_editable={};this.opendocs={};this.cur_section={};this.sections=[];this.sections_by_label={};this.section_count;this.grids=[];this.cscript={};this.pformat={};this.fetch_dict={};this.parent=parent;this.tinymce_id_list=[];frms[doctype]=this;this.setup_meta(doctype);rename_observers.push(this);}
|
||||
_f.Frm.prototype.setup=function(){var me=this;this.fields=[];this.fields_dict={};this.wrapper=$a(this.parent.body,'div');this.setup_print_layout();this.saved_wrapper=$a(this.wrapper,'div');this.setup_std_layout();this.setup_client_script();this.setup_done=true;}
|
||||
_f.Frm.prototype.setup_print_layout=function(){this.print_wrapper=$a(this.wrapper,'div');this.print_head=$a(this.print_wrapper,'div');this.print_body=$a(this.print_wrapper,'div','layout_wrapper',{padding:'23px'});var t=make_table(this.print_head,1,2,'100%',[],{padding:'6px'});this.view_btn_wrapper=$a($td(t,0,0),'span','green_buttons');this.view_btn=$btn(this.view_btn_wrapper,'View Details',function(){cur_frm.edit_doc()},{marginRight:'4px'},'green');this.print_btn=$btn($td(t,0,0),'Print',function(){cur_frm.print_doc()});$y($td(t,0,1),{textAlign:'right'});this.print_close_btn=$btn($td(t,0,1),'Close',function(){nav_obj.show_last_open();});}
|
||||
_f.Frm.prototype.onhide=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();}
|
||||
@@ -2222,6 +2224,7 @@ var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext
|
||||
<i class="icon-home icon-white navbar-icon-home" ></i>').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});})
|
||||
/*
|
||||
* erpnext/startup/startup.js
|
||||
*/
|
||||
var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions'}
|
||||
erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
|
||||
if(inList(user_roles,'System Manager'))is_system_manager=1;}
|
||||
@@ -2234,6 +2237,7 @@ $c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.e
|
||||
else if(nm=='Accounts Browser')
|
||||
pscript.make_chart(chart_type);}
|
||||
loadpage(nm,call_back);}
|
||||
var update_messages=function(){if(inList(['Guest'],user)){return;}
|
||||
$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(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);}});}
|
||||
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
|
||||
|
||||
@@ -55,13 +55,13 @@ return output.join('');};str_format.cache={};str_format.parse=function(fmt){var
|
||||
else if((match=/^\x25{2}/.exec(_fmt))!==null){parse_tree.push('%');}
|
||||
else if((match=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt))!==null){if(match[2]){arg_names|=1;var field_list=[],replacement_field=match[2],field_match=[];if((field_match=/^([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);while((replacement_field=replacement_field.substring(field_match[0].length))!==''){if((field_match=/^\.([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);}
|
||||
else if((field_match=/^\[(\d+)\]/.exec(replacement_field))!==null){field_list.push(field_match[1]);}
|
||||
else{}}}
|
||||
else{}
|
||||
else{throw('[sprintf] huh?');}}}
|
||||
else{throw('[sprintf] huh?');}
|
||||
match[2]=field_list;}
|
||||
else{arg_names|=2;}
|
||||
if(arg_names===3){throw('[sprintf] mixing positional and named placeholders is not (yet) supported');}
|
||||
parse_tree.push(match);}
|
||||
else{}
|
||||
else{throw('[sprintf] huh?');}
|
||||
_fmt=_fmt.substring(match[0].length);}
|
||||
return parse_tree;};return str_format;})();var vsprintf=function(fmt,argv){argv.unshift(fmt);return sprintf.apply(null,argv);};
|
||||
/*
|
||||
@@ -206,7 +206,9 @@ var lstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var first_char=s.su
|
||||
return s;}
|
||||
var rstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var last_char=s.substr(s.length-1);while(in_list(chars,last_char)){var s=s.substr(0,this.length-1);last_char=s.substr(this.length-1);}
|
||||
return s;}
|
||||
function repl(s,dict){return sprintf(s,dict);}
|
||||
function repl_all(s,s1,s2){var idx=s.indexOf(s1);while(idx!=-1){s=s.replace(s1,s2);idx=s.indexOf(s1);}
|
||||
return s;}
|
||||
function repl(s,dict){if(s==null)return'';for(key in dict)s=repl_all(s,'%('+key+')s',dict[key]);return s;}
|
||||
function keys(obj){var mykeys=[];for(key in obj)mykeys[mykeys.length]=key;return mykeys;}
|
||||
function values(obj){var myvalues=[];for(key in obj)myvalues[myvalues.length]=obj[key];return myvalues;}
|
||||
function in_list(list,item){for(var i=0;i<list.length;i++)
|
||||
@@ -1070,6 +1072,7 @@ var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext
|
||||
erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
|
||||
if(inList(user_roles,'System Manager'))is_system_manager=1;}
|
||||
erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
|
||||
if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
|
||||
if(user=='Guest'){if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
|
||||
Powered by <a href="https://erpnext.com">ERPNext</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}}
|
||||
$('#startup_div').toggle(false);}
|
||||
@@ -1082,6 +1085,7 @@ $c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.e
|
||||
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);}});}
|
||||
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
|
||||
wn.updates.id=setInterval(update_messages,60000);}
|
||||
erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat !important;}',{src:src}))}
|
||||
$(document).bind('startup',function(){erpnext.startup.start();});
|
||||
/*
|
||||
* erpnext/website/js/topbar.js
|
||||
|
||||
@@ -1 +1 @@
|
||||
762
|
||||
768
|
||||
Reference in New Issue
Block a user