From 5eedc0e2ddebff15c9de84d7fba75ecf460128d0 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Wed, 8 Apr 2020 18:38:14 -0300 Subject: [PATCH 1/7] add user card popover --- app/app/urls.py | 1 + app/assets/v2/css/base.css | 15 ++ app/assets/v2/js/user_card.js | 267 ++++++++++++++++++++++++++++++++++ app/dashboard/views.py | 78 ++++++++++ 4 files changed, 361 insertions(+) create mode 100644 app/assets/v2/js/user_card.js diff --git a/app/app/urls.py b/app/app/urls.py index 05bb53eef01..a0b5972e711 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -135,6 +135,7 @@ name='profile_job_opportunity' ), url(r'^api/v0.1/profile/(?P.*)', dashboard.views.profile_details, name='profile_details'), + url(r'^api/v0.1/user_card/(?P.*)', dashboard.views.user_card, name='user_card'), url(r'^api/v0.1/banners', dashboard.views.load_banners, name='load_banners'), url( r'^api/v0.1/get_suggested_contributors', diff --git a/app/assets/v2/css/base.css b/app/assets/v2/css/base.css index f578c8de564..9fff7e7a58c 100644 --- a/app/assets/v2/css/base.css +++ b/app/assets/v2/css/base.css @@ -1516,6 +1516,21 @@ div.busyOverlay { padding: 1.4em 1.3em 1.3em; } +.popover-user-card { + background-color: #FFF; + padding: 0; + width: 100%; + max-width: 30em; + font-size: 12px; +} + +.user-card_donut-chart { + width: 46px; +} +.user-card_pie-chart { + width: 30px; +} + .big-popover { max-width: 482px; } diff --git a/app/assets/v2/js/user_card.js b/app/assets/v2/js/user_card.js new file mode 100644 index 00000000000..a990dae7d00 --- /dev/null +++ b/app/assets/v2/js/user_card.js @@ -0,0 +1,267 @@ +$('body').on('mouseover', '[data-username][data-toggle="popover"]', function(e) { + openContributorPopOver($(this).data('username'), $(this)); +}); + +$('body').on('show.bs.popover', '[data-username][data-toggle="popover"]', function () { + $('body [data-username][data-toggle="popover"]').not(this).popover('hide'); +}) + + +let popoverData = []; +let controller = null; + +const renderPopOverData = data => { + const unique_orgs = data.profile.orgs ? Array.from(new Set(data.profile.orgs)) : []; + // const unique_orgs = data.profile.organizations ? Object.keys(data.profile.organizations) : []; + let orgs = unique_orgs && unique_orgs.map((_organization, index) => { + if (index < 5) { + return `${_organization}`; + } + return `+${data.orgs.length - 5}`; + }).join(' '); + + function percentCalc(value, total){ + let result = value * 100 / total; + return isNaN(result) ? 0 : result + } + let dashoffset = 25; + function calcDashoffset(thispercentage) { + let oldOffset = dashoffset; //25 , 85 + accumulate += thispercentage //40 , 60 + dashoffset = (100 - accumulate) + 25 //= 85 , 65 + return oldOffset; + } + + function objSetup(sent, received, total, color, colorlight, stringsOverwrite) { + let prodTotal = sent + received; + + return { + 'percent': percentCalc(prodTotal, total), + 'percentsent': percentCalc(sent, prodTotal), + 'amountsent': sent, + 'percentreceived': percentCalc(received, prodTotal), + 'amountreceived': received, + 'color': color, + 'colorlight': colorlight, + 'dashoffset': calcDashoffset(percentCalc(prodTotal, total)), + 'strings': stringsOverwrite + } + } + + let tips_total = data.profile_dict.total_tips_sent + data.profile_dict.total_tips_received; + let bounties_total = data.profile_dict.funded_bounties_count + data.profile_dict.count_bounties_completed; + let grants_total = data.profile_dict.total_grant_created + data.profile_dict.total_grant_contributions; + let total = tips_total + bounties_total + grants_total; + let accumulate = 0; + let tips_total_percent = objSetup( + data.profile_dict.total_tips_sent, + data.profile_dict.total_tips_received, + total, + '#89CD69', + '#BFE1AF', + {'type': 'Tips', 'sent': 'Sent', 'received':'Received'} + ) + let bounties_total_percent = objSetup( + data.profile_dict.funded_bounties_count, + data.profile_dict.count_bounties_completed, + total, + '#8E98FF', + '#ADB4FF', + {'type': 'Bounties', 'sent': 'Created', 'received':'Worked'} + ) + let grants_total_percent = objSetup( + data.profile_dict.total_grant_created, + data.profile_dict.total_grant_contributions, + total, + '#FF83FA', + '#FFB2FC', + {'type': 'Grants', 'sent': 'Fund', 'received':'Contrib'} + ) + + let mount_graph = [tips_total_percent, bounties_total_percent, grants_total_percent] + let graphs = mount_graph.map((graph) => { + return ``; + }) + + + // const bounties = data.related_bounties && data.related_bounties.map(bounty => { + // const title = bounty.title <= 30 ? bounty.title : bounty.title.slice(0, 27) + '...'; + + // let ratings = []; + + // if (bounty.rating && bounty.rating[0] > 0) { + // for (let i = 0; i < 5; i++) { + // ratings.push(``); + // } + // } + + // return `
  • + // ${title} + // by ${bounty.org} + // ${ratings.length > 0 ? + // ` + // ${ratings.join(' ')} + // ` : ''} + //
  • `; + // }).join(' '); + + // + + const renderAvatarData = function(){ + return ` + + + ${graphs} + + + + + + + + + + `; + }; + + const renderPie = function(dataGraph) { + return ` +
    + ${dataGraph.strings.type} +
    + + + + + +
    +
    + ${dataGraph.amountsent} + ${dataGraph.strings.sent} +
    +
    + ${dataGraph.amountreceived} + ${dataGraph.strings.received} +
    +
    +
    +
    + `; + }; + + + + return ` +
    +
    +
    + ${renderAvatarData()} +
    + ${orgs.length ? orgs : ''} +
    +
    +
    + +
    +
    +

    ${data.profile.data.name || data.profile.handle}

    + @${data.profile.handle} + +
    + ${data.profile.keywords.map((keyword, index) => { + if (index < 5) { + return `${keyword}`; + } + return `+${data.profile.keywords.length - 5}`; + }).join(' ')} +
    +
    + + Joined + + ${data.profile_dict.scoreboard_position_funder ? `#${data.profile_dict.scoreboard_position_funder} Funder` : data.profile_dict.scoreboard_position_contributor ? `#${data.profile_dict.scoreboard_position_contributor} Contributor` : '' } +
    + + + +
    + ${mount_graph.map((graph)=> renderPie(graph)).join(' ')} +
    + +
    + ${data.stats.followers} Followers + ${data.stats.following} Following +
    + + + +
    + `; +}; + + +function openContributorPopOver(contributor, element) { + console.log(contributor, element) + + const contributorURL = `/api/v0.1/user_card/${contributor}`; + + if (popoverData.filter(index => index[contributor]).length === 0) { + if (controller) { + controller.abort(); + } + controller = new AbortController(); + const signal = controller.signal; + + userRequest = fetch(contributorURL, { method: 'GET', signal }) + .then(response => response.json()) + .then(response => { + popoverData.push({ [contributor]: response }); + controller = null; + setupPopover(element, response); + }) + .catch(err => { + return console.warn({ message: err }); + }); + } else { + setupPopover(element, popoverData.filter(item => item[contributor])[0][contributor]); + } +} + +function setupPopover (element, data){ + element.popover({ + sanitizeFn: function (content) { + return DOMPurify.sanitize(content) + }, + placement: 'auto', + // container: element, + trigger: 'manual', + delay: { 'show': 200, 'hide': 500 }, + template: ` + `, + content: renderPopOverData(data), + html: true + }).on('mouseenter', function() { + var _this = this; + + $(this).popover('show'); + $('.popover').on('mouseleave', function() { + $(_this).popover('hide'); + }); + }).on('mouseleave', function() { + var _this = this; + + setTimeout(function() { + if (!$('.popover:hover').length) { + $(_this).popover('hide'); + } + }, 100); + }); + $(element).popover('show'); + joinTribe(); + +} diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 680c1580eea..84727903929 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2107,6 +2107,84 @@ def profile_details(request, handle): return JsonResponse(response, safe=False) +def user_card(request, handle): + """Display profile keywords. + + Args: + handle (str): The profile handle. + + """ + try: + profile = profile_helper(handle, True) + except (ProfileNotFoundException, ProfileHiddenException): + raise Http404 + + if not settings.DEBUG: + network = 'mainnet' + else: + network = 'rinkeby' + + # bounties = Bounty.objects.current().prefetch_related( + # 'fulfillments', + # 'interested', + # 'interested__profile', + # ).filter( + # interested__profile=profile, + # network=network, + # ).filter( + # interested__status='okay' + # ).filter( + # interested__pending=False + # ).filter( + # idx_status='done' + # ).distinct('pk')[:3] + + # _bounties = [] + # _orgs = [] + # if bounties : + # for bounty in bounties: + + # _bounty = { + # 'title': bounty.title, + # 'id': bounty.id, + # 'org': bounty.org_name, + # 'rating': [feedback.rating for feedback in bounty.feedbacks.all().distinct('bounty_id')], + # } + # _org = bounty.org_name + # _orgs.append(_org) + # _bounties.append(_bounty) + profile_dict = profile.as_dict + followers = TribeMember.objects.filter(org=profile).count() + following = TribeMember.objects.filter(profile=profile).count() + response = { + # 'avatar': profile.avatar_url, + # 'handle': profile.handle, + # 'contributed_to': _orgs, + # 'orgs' : profile.organizations, + # 'profile' : profile.as_representation, + 'profile' : { + 'avatar_url': profile.avatar_url, + 'handle': profile.handle, + 'orgs' : profile.organizations, + 'created_on' : profile.created_on, + 'keywords' : profile.keywords, + 'data': profile.data + }, + 'profile_dict':profile_dict, + 'stats': { + # 'total_grant_created': profile.total_grant_created, + 'position': profile.get_contributor_leaderboard_index(), + 'completed_bounties': profile.completed_bounties, + 'success_rate': profile.success_rate, + 'earnings': profile.get_eth_sum(), + 'followers':followers, + 'following':following, + } + } + + return JsonResponse(response, safe=False) + + def profile_keywords(request, handle): """Display profile details. From 5bf62125be7cd724c9f00cb3ccdb0975300cb8b2 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Wed, 8 Apr 2020 18:40:09 -0300 Subject: [PATCH 2/7] apply user card to townsquare --- app/assets/v2/js/activity.js | 18 +++++++++--------- app/retail/templates/shared/activity.html | 4 ++-- app/townsquare/templates/townsquare/index.html | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/assets/v2/js/activity.js b/app/assets/v2/js/activity.js index 93002720234..3d943cf8435 100644 --- a/app/assets/v2/js/activity.js +++ b/app/assets/v2/js/activity.js @@ -7,7 +7,7 @@ $(document).ready(function() { var linkify = function(new_text) { new_text = new_text.replace(/(?:^|\s)#([a-zA-Z\d-]+)/g, ' #$1'); - new_text = new_text.replace(/\B@([a-zA-Z0-9_-]*)/g, ' @$1'); + new_text = new_text.replace(/\B@([a-zA-Z0-9_-]*)/g, ' @$1'); return new_text; }; // inserts links into the text where there are URLS detected @@ -58,9 +58,9 @@ $(document).ready(function() { const $target = $(this).parents('.activity_detail_content'); const html = `

    - Full Screen | - Pop Out | - Open in New Tab | + Full Screen | + Pop Out | + Open in New Tab | Leave Video Call

    `; @@ -669,7 +669,7 @@ $(document).ready(function() { ${show_more_box}
    @@ -680,9 +680,9 @@ $(document).ready(function() { - + ${comment['name']} - + @${comment['profile_handle']} ${comment['match_this_round'] ? ` @@ -905,7 +905,7 @@ $(document).ready(function() { // auto open new comment threads setInterval(function() { - $('[data-toggle="popover"]').popover(); + // $('[data-toggle="popover"]').popover(); $('[data-toggle="tooltip"]').bootstrapTooltip(); openChat(); @@ -950,7 +950,7 @@ function throttle(fn, wait) { } }; } - + window.addEventListener('scroll', throttle(function() { var offset = 800; diff --git a/app/retail/templates/shared/activity.html b/app/retail/templates/shared/activity.html index d33748f2bd1..31a366c7fbc 100644 --- a/app/retail/templates/shared/activity.html +++ b/app/retail/templates/shared/activity.html @@ -64,7 +64,7 @@ {% include 'profiles/presence_indicator.html' with last_chat_status=row.profile.last_chat_status chat_id=row.profile.chat_id handle=row.profile.handle additionalclasses="mini" show_even_if_offline=1 %} {% firstof row.profile.data.name or row.profile.handle %} - @{{ row.profile.handle }} + @{{ row.profile.handle }} {% if row.hackathonevent %} @@ -89,7 +89,7 @@
    {% if row.activity_type == 'new_tip' %} {% trans "tipped" %} - + @{{ row.metadata.to_username }} {% elif row.activity_type == 'mini_clr_payout' %} diff --git a/app/townsquare/templates/townsquare/index.html b/app/townsquare/templates/townsquare/index.html index 6b7aa35dfd6..7ec5816ce7d 100644 --- a/app/townsquare/templates/townsquare/index.html +++ b/app/townsquare/templates/townsquare/index.html @@ -186,5 +186,6 @@ + From 0663b0cd009deb0a275cc1566f7a71a736781c7e Mon Sep 17 00:00:00 2001 From: octavioamu Date: Thu, 9 Apr 2020 00:07:56 -0300 Subject: [PATCH 3/7] dynamic follow/unfollow --- app/assets/v2/js/pages/join_tribe.js | 17 +++ app/assets/v2/js/user_card.js | 140 +++++++++++----------- app/dashboard/views.py | 52 ++------ app/retail/templates/shared/activity.html | 4 +- 4 files changed, 97 insertions(+), 116 deletions(-) diff --git a/app/assets/v2/js/pages/join_tribe.js b/app/assets/v2/js/pages/join_tribe.js index 8623d7e3709..9d1cc4c7ea3 100644 --- a/app/assets/v2/js/pages/join_tribe.js +++ b/app/assets/v2/js/pages/join_tribe.js @@ -58,6 +58,23 @@ const joinTribeDirect = (elem) => { }; +const followRequest = (handle, elem, cb, cbError) => { + if (!document.contxt.github_handle) { + _alert('Please login first.', 'error'); + return; + } + + const url = `/tribe/${handle}/join/`; + const sendJoin = fetchData (url, 'POST', {}, {'X-CSRFToken': $("input[name='csrfmiddlewaretoken']").val()}); + + $.when(sendJoin).then(function(response) { + return cb(handle, elem, response); + }).fail(function(error) { + return cbError(error); + }); +}; + + const tribeLeader = () => { $('[data-tribeleader]').each(function(index, elem) { diff --git a/app/assets/v2/js/user_card.js b/app/assets/v2/js/user_card.js index a990dae7d00..9b47ed958a2 100644 --- a/app/assets/v2/js/user_card.js +++ b/app/assets/v2/js/user_card.js @@ -1,18 +1,16 @@ -$('body').on('mouseover', '[data-username][data-toggle="popover"]', function(e) { - openContributorPopOver($(this).data('username'), $(this)); +$('body').on('mouseover', '[data-usercard]', function(e) { + openContributorPopOver($(this).data('usercard'), $(this)); }); -$('body').on('show.bs.popover', '[data-username][data-toggle="popover"]', function () { - $('body [data-username][data-toggle="popover"]').not(this).popover('hide'); -}) - +$('body').on('show.bs.popover', '[data-usercard]', function() { + $('body [data-usercard]').not(this).popover('hide'); +}); let popoverData = []; let controller = null; -const renderPopOverData = data => { +const renderPopOverData = function(data) { const unique_orgs = data.profile.orgs ? Array.from(new Set(data.profile.orgs)) : []; - // const unique_orgs = data.profile.organizations ? Object.keys(data.profile.organizations) : []; let orgs = unique_orgs && unique_orgs.map((_organization, index) => { if (index < 5) { return `${_organization} { return `+${data.orgs.length - 5}`; }).join(' '); - function percentCalc(value, total){ + function percentCalc(value, total) { let result = value * 100 / total; - return isNaN(result) ? 0 : result + + return isNaN(result) ? 0 : result; } + let dashoffset = 25; + function calcDashoffset(thispercentage) { - let oldOffset = dashoffset; //25 , 85 - accumulate += thispercentage //40 , 60 - dashoffset = (100 - accumulate) + 25 //= 85 , 65 + let oldOffset = dashoffset; + + accumulate += thispercentage; + dashoffset = (100 - accumulate) + 25; return oldOffset; } @@ -46,69 +48,45 @@ const renderPopOverData = data => { 'colorlight': colorlight, 'dashoffset': calcDashoffset(percentCalc(prodTotal, total)), 'strings': stringsOverwrite - } + }; } let tips_total = data.profile_dict.total_tips_sent + data.profile_dict.total_tips_received; let bounties_total = data.profile_dict.funded_bounties_count + data.profile_dict.count_bounties_completed; let grants_total = data.profile_dict.total_grant_created + data.profile_dict.total_grant_contributions; let total = tips_total + bounties_total + grants_total; - let accumulate = 0; + let accumulate = 0; let tips_total_percent = objSetup( data.profile_dict.total_tips_sent, data.profile_dict.total_tips_received, total, '#89CD69', '#BFE1AF', - {'type': 'Tips', 'sent': 'Sent', 'received':'Received'} - ) + {'type': 'Tips', 'sent': 'Sent', 'received': 'Received'} + ); let bounties_total_percent = objSetup( data.profile_dict.funded_bounties_count, data.profile_dict.count_bounties_completed, total, '#8E98FF', '#ADB4FF', - {'type': 'Bounties', 'sent': 'Created', 'received':'Worked'} - ) + {'type': 'Bounties', 'sent': 'Created', 'received': 'Worked'} + ); let grants_total_percent = objSetup( data.profile_dict.total_grant_created, data.profile_dict.total_grant_contributions, total, '#FF83FA', '#FFB2FC', - {'type': 'Grants', 'sent': 'Fund', 'received':'Contrib'} - ) + {'type': 'Grants', 'sent': 'Fund', 'received': 'Contrib'} + ); - let mount_graph = [tips_total_percent, bounties_total_percent, grants_total_percent] + let mount_graph = [ tips_total_percent, bounties_total_percent, grants_total_percent ]; let graphs = mount_graph.map((graph) => { return ``; - }) - - - // const bounties = data.related_bounties && data.related_bounties.map(bounty => { - // const title = bounty.title <= 30 ? bounty.title : bounty.title.slice(0, 27) + '...'; - - // let ratings = []; - - // if (bounty.rating && bounty.rating[0] > 0) { - // for (let i = 0; i < 5; i++) { - // ratings.push(``); - // } - // } - - // return `
  • - // ${title} - // by ${bounty.org} - // ${ratings.length > 0 ? - // ` - // ${ratings.join(' ')} - // ` : ''} - //
  • `; - // }).join(' '); - - // + }); - const renderAvatarData = function(){ + const renderAvatarData = function() { return ` @@ -150,7 +128,12 @@ const renderPopOverData = data => { `; }; - + const followBtn = function(data) { + if (data.is_following) { + return ``; + } + return ``; + }; return `
    @@ -162,29 +145,26 @@ const renderPopOverData = data => {
    - + ${data.is_authenticated && data.profile.handle !== document.contxt.github_handle ? followBtn(data) : ''}

    ${data.profile.data.name || data.profile.handle}

    @${data.profile.handle} -
    - ${data.profile.keywords.map((keyword, index) => { - if (index < 5) { - return `${keyword}`; - } - return `+${data.profile.keywords.length - 5}`; - }).join(' ')} -
    +
    ${data.profile.keywords.map( + (keyword, index) => { + if (index < 5) { + return `${keyword}`; + } + return `+${data.profile.keywords.length - 5}`; + }).join(' ')}
    Joined - ${data.profile_dict.scoreboard_position_funder ? `#${data.profile_dict.scoreboard_position_funder} Funder` : data.profile_dict.scoreboard_position_contributor ? `#${data.profile_dict.scoreboard_position_contributor} Contributor` : '' } + ${data.profile_dict.scoreboard_position_funder ? `#${data.profile_dict.scoreboard_position_funder} Funder` : data.profile_dict.scoreboard_position_contributor ? `#${data.profile_dict.scoreboard_position_contributor} Contributor` : '' }
    - -
    ${mount_graph.map((graph)=> renderPie(graph)).join(' ')}
    @@ -193,16 +173,33 @@ const renderPopOverData = data => { ${data.stats.followers} Followers ${data.stats.following} Following - - - `; }; +const cb = (handle, elem, response) => { + $(elem).attr('disabled', false); + popoverData.filter(item => item[handle])[0][handle].is_following = response.is_member; + response.is_member ? $(elem).html('Unfollow ') : $(elem).html('Follow '); +}; + +const addFollowAction = () => { + $('[data-follow]').each(function(index, elem) { + $(elem).on('click', function(e) { + $(elem).attr('disabled', true); + + const handle = $(elem).data('follow'); + const error = () => { + $(elem).attr('disabled', false); + }; + + followRequest(handle, elem, cb, error); + }); + + }); +}; function openContributorPopOver(contributor, element) { - console.log(contributor, element) const contributorURL = `/api/v0.1/user_card/${contributor}`; @@ -228,10 +225,10 @@ function openContributorPopOver(contributor, element) { } } -function setupPopover (element, data){ +function setupPopover(element, data) { element.popover({ - sanitizeFn: function (content) { - return DOMPurify.sanitize(content) + sanitizeFn: function(content) { + return DOMPurify.sanitize(content); }, placement: 'auto', // container: element, @@ -243,7 +240,9 @@ function setupPopover (element, data){

    `, - content: renderPopOverData(data), + content: function() { + return renderPopOverData(data); + }, html: true }).on('mouseenter', function() { var _this = this; @@ -262,6 +261,7 @@ function setupPopover (element, data){ }, 100); }); $(element).popover('show'); - joinTribe(); + + addFollowAction(); } diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 84727903929..19cabf4bfd3 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2124,44 +2124,17 @@ def user_card(request, handle): else: network = 'rinkeby' - # bounties = Bounty.objects.current().prefetch_related( - # 'fulfillments', - # 'interested', - # 'interested__profile', - # ).filter( - # interested__profile=profile, - # network=network, - # ).filter( - # interested__status='okay' - # ).filter( - # interested__pending=False - # ).filter( - # idx_status='done' - # ).distinct('pk')[:3] - - # _bounties = [] - # _orgs = [] - # if bounties : - # for bounty in bounties: - - # _bounty = { - # 'title': bounty.title, - # 'id': bounty.id, - # 'org': bounty.org_name, - # 'rating': [feedback.rating for feedback in bounty.feedbacks.all().distinct('bounty_id')], - # } - # _org = bounty.org_name - # _orgs.append(_org) - # _bounties.append(_bounty) + if request.user.is_authenticated: + is_following = True if TribeMember.objects.filter(profile=request.user.profile, org=profile).count() else False + else: + is_following = False + profile_dict = profile.as_dict followers = TribeMember.objects.filter(org=profile).count() following = TribeMember.objects.filter(profile=profile).count() response = { - # 'avatar': profile.avatar_url, - # 'handle': profile.handle, - # 'contributed_to': _orgs, - # 'orgs' : profile.organizations, - # 'profile' : profile.as_representation, + 'is_authenticated': request.user.is_authenticated, + 'is_following': is_following, 'profile' : { 'avatar_url': profile.avatar_url, 'handle': profile.handle, @@ -2170,16 +2143,7 @@ def user_card(request, handle): 'keywords' : profile.keywords, 'data': profile.data }, - 'profile_dict':profile_dict, - 'stats': { - # 'total_grant_created': profile.total_grant_created, - 'position': profile.get_contributor_leaderboard_index(), - 'completed_bounties': profile.completed_bounties, - 'success_rate': profile.success_rate, - 'earnings': profile.get_eth_sum(), - 'followers':followers, - 'following':following, - } + 'profile_dict':profile_dict } return JsonResponse(response, safe=False) diff --git a/app/retail/templates/shared/activity.html b/app/retail/templates/shared/activity.html index 31a366c7fbc..3a4bf504a95 100644 --- a/app/retail/templates/shared/activity.html +++ b/app/retail/templates/shared/activity.html @@ -64,7 +64,7 @@ {% include 'profiles/presence_indicator.html' with last_chat_status=row.profile.last_chat_status chat_id=row.profile.chat_id handle=row.profile.handle additionalclasses="mini" show_even_if_offline=1 %} {% firstof row.profile.data.name or row.profile.handle %} - @{{ row.profile.handle }} + @{{ row.profile.handle }} {% if row.hackathonevent %} @@ -89,7 +89,7 @@
    {% if row.activity_type == 'new_tip' %} {% trans "tipped" %} - + @{{ row.metadata.to_username }} {% elif row.activity_type == 'mini_clr_payout' %} From 4d609b9bc337b904cd51b128eaee47af24b4e50e Mon Sep 17 00:00:00 2001 From: octavioamu Date: Thu, 9 Apr 2020 00:17:38 -0300 Subject: [PATCH 4/7] missing attr changes --- app/assets/v2/js/activity.js | 8 ++++---- app/assets/v2/js/user_card.js | 4 ++-- app/dashboard/views.py | 9 ++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/assets/v2/js/activity.js b/app/assets/v2/js/activity.js index 3d943cf8435..57164931a30 100644 --- a/app/assets/v2/js/activity.js +++ b/app/assets/v2/js/activity.js @@ -7,7 +7,7 @@ $(document).ready(function() { var linkify = function(new_text) { new_text = new_text.replace(/(?:^|\s)#([a-zA-Z\d-]+)/g, ' #$1'); - new_text = new_text.replace(/\B@([a-zA-Z0-9_-]*)/g, ' @$1'); + new_text = new_text.replace(/\B@([a-zA-Z0-9_-]*)/g, ' @$1'); return new_text; }; // inserts links into the text where there are URLS detected @@ -669,7 +669,7 @@ $(document).ready(function() { ${show_more_box}
    @@ -682,7 +682,7 @@ $(document).ready(function() { ${comment['name']} - + @${comment['profile_handle']} ${comment['match_this_round'] ? ` @@ -905,7 +905,7 @@ $(document).ready(function() { // auto open new comment threads setInterval(function() { - // $('[data-toggle="popover"]').popover(); + $('[data-toggle="popover"]').popover(); $('[data-toggle="tooltip"]').bootstrapTooltip(); openChat(); diff --git a/app/assets/v2/js/user_card.js b/app/assets/v2/js/user_card.js index 9b47ed958a2..9d50ad4c9d7 100644 --- a/app/assets/v2/js/user_card.js +++ b/app/assets/v2/js/user_card.js @@ -170,8 +170,8 @@ const renderPopOverData = function(data) {
    - ${data.stats.followers} Followers - ${data.stats.following} Following + ${data.profile.followers} Followers + ${data.profile.following} Following
    `; diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 19cabf4bfd3..07b8923e2b9 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2135,13 +2135,20 @@ def user_card(request, handle): response = { 'is_authenticated': request.user.is_authenticated, 'is_following': is_following, + # 'avatar': profile.avatar_url, + # 'handle': profile.handle, + # 'contributed_to': _orgs, + # 'orgs' : profile.organizations, + # 'profile' : profile.as_representation, 'profile' : { 'avatar_url': profile.avatar_url, 'handle': profile.handle, 'orgs' : profile.organizations, 'created_on' : profile.created_on, 'keywords' : profile.keywords, - 'data': profile.data + 'data': profile.data, + 'followers':followers, + 'following':following, }, 'profile_dict':profile_dict } From 4713be378a5a50febae84c8a53caf5cfaa3411c0 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Thu, 9 Apr 2020 00:18:33 -0300 Subject: [PATCH 5/7] remove commented code --- app/dashboard/views.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 07b8923e2b9..b230587a773 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2135,11 +2135,6 @@ def user_card(request, handle): response = { 'is_authenticated': request.user.is_authenticated, 'is_following': is_following, - # 'avatar': profile.avatar_url, - # 'handle': profile.handle, - # 'contributed_to': _orgs, - # 'orgs' : profile.organizations, - # 'profile' : profile.as_representation, 'profile' : { 'avatar_url': profile.avatar_url, 'handle': profile.handle, From 5b54965d21982bc820de1f3e1af75d56c0e63d66 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Thu, 9 Apr 2020 20:16:34 -0300 Subject: [PATCH 6/7] add social btns and fix closing popover --- app/assets/v2/css/base.css | 2 +- app/assets/v2/js/user_card.js | 54 ++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/assets/v2/css/base.css b/app/assets/v2/css/base.css index 9fff7e7a58c..ef59419fe2f 100644 --- a/app/assets/v2/css/base.css +++ b/app/assets/v2/css/base.css @@ -1525,7 +1525,7 @@ div.busyOverlay { } .user-card_donut-chart { - width: 46px; + width: 56px; } .user-card_pie-chart { width: 30px; diff --git a/app/assets/v2/js/user_card.js b/app/assets/v2/js/user_card.js index 9d50ad4c9d7..db67f397dc6 100644 --- a/app/assets/v2/js/user_card.js +++ b/app/assets/v2/js/user_card.js @@ -13,10 +13,12 @@ const renderPopOverData = function(data) { const unique_orgs = data.profile.orgs ? Array.from(new Set(data.profile.orgs)) : []; let orgs = unique_orgs && unique_orgs.map((_organization, index) => { if (index < 5) { - return `${_organization}`; + return ` + ${_organization} + `; + } else if (index < 6) { + return `+${data.orgs.length - 5}`; } - return `+${data.orgs.length - 5}`; }).join(' '); function percentCalc(value, total) { @@ -83,17 +85,17 @@ const renderPopOverData = function(data) { let mount_graph = [ tips_total_percent, bounties_total_percent, grants_total_percent ]; let graphs = mount_graph.map((graph) => { - return ``; - }); + return ``; + }).join(' '); const renderAvatarData = function() { return ` - + ${graphs} - + @@ -151,18 +153,42 @@ const renderPopOverData = function(data) {

    ${data.profile.data.name || data.profile.handle}

    @${data.profile.handle} -
    ${data.profile.keywords.map( +
    + + + + + + + + + + + + + + | + + + +
    + +
    ${data.profile.keywords.map( (keyword, index) => { if (index < 5) { - return `${keyword}`; + return `${keyword}`; + } else if (index < 6) { + return `+${data.profile.keywords.length - 5}`; } - return `+${data.profile.keywords.length - 5}`; }).join(' ')}
    -
    +
    Joined - ${data.profile_dict.scoreboard_position_funder ? `#${data.profile_dict.scoreboard_position_funder} Funder` : data.profile_dict.scoreboard_position_contributor ? `#${data.profile_dict.scoreboard_position_contributor} Contributor` : '' } + ${data.profile_dict.scoreboard_position_funder ? `#${data.profile_dict.scoreboard_position_funder} Funder` : '' } + ${data.profile_dict.scoreboard_position_contributor ? `#${data.profile_dict.scoreboard_position_contributor} Contributor` : '' }
    @@ -248,14 +274,14 @@ function setupPopover(element, data) { var _this = this; $(this).popover('show'); - $('.popover').on('mouseleave', function() { + $('.popover-user-card').on('mouseleave', function() { $(_this).popover('hide'); }); }).on('mouseleave', function() { var _this = this; setTimeout(function() { - if (!$('.popover:hover').length) { + if (!$('.popover-user-card:hover').length) { $(_this).popover('hide'); } }, 100); From 7f7834f7b15f52f1fc7b6c9236302fb8bd1731e7 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Fri, 10 Apr 2020 14:46:19 -0300 Subject: [PATCH 7/7] fix eslint --- app/assets/v2/js/grants/fund.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 64bb8c5e0e1..2fe84f40785 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -360,8 +360,8 @@ $(document).ready(function() { let realTokenAmount = Number(data.amount_per_period * Math.pow(10, decimals)); let realApproval; - const approve_buffer = 100000; + if (data.contract_version == 1 || data.num_periods == 1) { realApproval = Number(((grant_amount + gitcoin_grant_amount) * data.num_periods * Math.pow(10, decimals)) + approve_buffer);