De-dup code of activity log
There were 2 copies of the code for activity log: the one used on main screens and the other user in the report. Latter code is located in jinja macros. Now it is used in main screens too. Closes bug: 1262192 Change-Id: I7bd3f4efe083c835efcf55bc8054cda1ab818da9
This commit is contained in:
		| @@ -157,11 +157,6 @@ div#right_list_wrapper { | |||||||
|     margin-top: 20px; |     margin-top: 20px; | ||||||
| } | } | ||||||
|  |  | ||||||
| .message { |  | ||||||
|     white-space: pre-wrap; |  | ||||||
|     margin-top: 0.8em; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .label { | .label { | ||||||
|     font-weight: bold; |     font-weight: bold; | ||||||
|     line-height: 135%; |     line-height: 135%; | ||||||
| @@ -181,6 +176,18 @@ div#right_list_wrapper { | |||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .record { | ||||||
|  |     margin-bottom: 1em; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .record .header { | ||||||
|  |     font-weight: bold; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .record .message { | ||||||
|  |     white-space: pre-wrap; | ||||||
|  | } | ||||||
|  |  | ||||||
| a[href^="https://blueprints"]:after { | a[href^="https://blueprints"]:after { | ||||||
|     content: "↗"; |     content: "↗"; | ||||||
|     opacity: 0.3; |     opacity: 0.3; | ||||||
| @@ -308,7 +315,7 @@ a[href^="https://launchpad"]:after { | |||||||
| .statusInProgress, .statusInProgress a { | .statusInProgress, .statusInProgress a { | ||||||
|     color: #000000; |     color: #000000; | ||||||
| } | } | ||||||
| .statusFixCommitted, .statusFixCommitted a { | .statusComplete, .statusComplete a, .statusFixCommitted, .statusFixCommitted a { | ||||||
|     color: #005500; |     color: #005500; | ||||||
| } | } | ||||||
| .statusFixReleased, .statusFixReleased a { | .statusFixReleased, .statusFixReleased a { | ||||||
|   | |||||||
| @@ -1,9 +1,13 @@ | |||||||
| {% macro show_activity_log(user_id=None, company=None, blueprint_id=None, show_record_type=True, show_user_gravatar=True, gravatar_size=32) -%} | {% macro show_activity_log(user_id=None, company=None, blueprint_id=None, | ||||||
|  | show_record_type=True, show_user_gravatar=True, gravatar_size=32, show_all=True) -%} | ||||||
|  |  | ||||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||||
|     var page_size = 10; |     var page_size = 10; | ||||||
|     var start_record = 0; |     var start_record = 0; | ||||||
|     var uri_options = {project_type: "all", release: "all", metric: "all"}; |     var uri_options = {}; | ||||||
|  |     {% if show_all %} | ||||||
|  |         uri_options = {project_type: "all", release: "all", metric: "all"}; | ||||||
|  |     {% endif %} | ||||||
|     {% if user_id %} |     {% if user_id %} | ||||||
|         uri_options["user_id"] = "{{ user_id }}"; |         uri_options["user_id"] = "{{ user_id }}"; | ||||||
|     {% endif %} |     {% endif %} | ||||||
| @@ -53,7 +57,7 @@ | |||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <script id="activity_template" type="text/x-jquery-tmpl"> | <script id="activity_template" type="text/x-jquery-tmpl"> | ||||||
|     <div style="margin-bottom: 1em;"> |     <div class="record"> | ||||||
|     <div style='float: left; '> |     <div style='float: left; '> | ||||||
|         {% if show_user_gravatar %} |         {% if show_user_gravatar %} | ||||||
|             <img src="${gravatar}" style="width: {{ gravatar_size }}px; height: {{ gravatar_size }}px;"> |             <img src="${gravatar}" style="width: {{ gravatar_size }}px; height: {{ gravatar_size }}px;"> | ||||||
| @@ -65,12 +69,12 @@ | |||||||
|     <div style="margin-left: {{ gravatar_size * 1.4 }}px;"> |     <div style="margin-left: {{ gravatar_size * 1.4 }}px;"> | ||||||
|  |  | ||||||
|     {% raw %} |     {% raw %} | ||||||
|         <div style="font-weight: bold;">{%html author_link %} ({%html company_link %})</div> |         <div class="header">{%html author_link %} ({%html company_link %})</div> | ||||||
|         <div style="font-weight: bold;">${date_str} in {%html module_link%}</div> |         <div class="header">${date_str} in {%html module_link%}</div> | ||||||
|  |  | ||||||
|         {%if record_type == "commit" %} |         {%if record_type == "commit" %} | ||||||
|             <div style='font-weight: bold;'>Commit “${subject}”</div> |             <div class="header">Commit “${subject}”</div> | ||||||
|             <div style='white-space: pre-wrap; '>{%html message %}</div> |             <div class="message">{%html message %}</div> | ||||||
|             {%if commit_date_str != "" %} |             {%if commit_date_str != "" %} | ||||||
|                 <div>Commit date: ${commit_date_str}</div> |                 <div>Commit date: ${commit_date_str}</div> | ||||||
|             {%/if%} |             {%/if%} | ||||||
| @@ -81,16 +85,16 @@ | |||||||
|             <div><span style="color: green">+<span>${lines_added}</span></span> |             <div><span style="color: green">+<span>${lines_added}</span></span> | ||||||
|                 <span style="color: blue">- <span>${lines_deleted}</span></span></div> |                 <span style="color: blue">- <span>${lines_deleted}</span></span></div> | ||||||
|         {%elif record_type == "mark" %} |         {%elif record_type == "mark" %} | ||||||
|             <div style='font-weight: bold;'>Review “${subject}”</div> |             <div class="header">Review “${subject}”</div> | ||||||
|             <div>${review_number} review submitted by {%html parent_author_link %} ({%html parent_company_link %})</div> |             <div>Submitted by: {%html parent_author_link %} ({%html parent_company_link %}) (#${review_number})</div> | ||||||
|             <div>Change Id: <a href="${url}">${review_id}</a></div> |             <div>Change Id: <a href="${url}">${review_id}</a></div> | ||||||
|             <div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">${description}: <span class="review_mark">${value}</span></div> |             <div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">${description}: <span class="review_mark">${value}</span></div> | ||||||
|         {%elif record_type == "review" %} |         {%elif record_type == "review" %} | ||||||
|             <div style='font-weight: bold;'>Patch “${subject}”</div> |             <div class="header">Patch “${subject}”</div> | ||||||
|             <div>Current Status: ${status}</div> |             <div>Current Status: ${status}</div> | ||||||
|             <div>Change Id: <a href="${url}">${id}</a></div> |             <div>Change Id: <a href="${url}">${id}</a></div> | ||||||
|         {%elif record_type == "email" %} |         {%elif record_type == "email" %} | ||||||
|             <div style='font-weight: bold;'> |             <div class="header"> | ||||||
|             {%if email_link != "" %} |             {%if email_link != "" %} | ||||||
|             <a href='${email_link}'> |             <a href='${email_link}'> | ||||||
|             {%/if%} |             {%/if%} | ||||||
| @@ -111,8 +115,8 @@ | |||||||
|             <div id="content-button-${record_id}" class="message" style="display:none;">${body}</div> |             <div id="content-button-${record_id}" class="message" style="display:none;">${body}</div> | ||||||
|             {%/if%} |             {%/if%} | ||||||
|         {%elif ((record_type == "bpd") || (record_type == "bpc")) %} |         {%elif ((record_type == "bpd") || (record_type == "bpc")) %} | ||||||
|             <div style='font-weight: bold;'>Blueprint “${title}” ({%html blueprint_link %})</div> |             <div class="header">Blueprint “${title}” ({%html blueprint_link %})</div> | ||||||
|             <div style='white-space: pre-wrap;'>${summary}</div> |             <div class="message">${summary}</div> | ||||||
|  |  | ||||||
|             <div>Priority: <span class="specpriority${priority}">${priority}</span></div> |             <div>Priority: <span class="specpriority${priority}">${priority}</span></div> | ||||||
|             <div>Status: <span class="status${lifecycle_status}">${lifecycle_status}</span> |             <div>Status: <span class="status${lifecycle_status}">${lifecycle_status}</span> | ||||||
| @@ -131,7 +135,7 @@ | |||||||
|     <div id="activity_container"></div> |     <div id="activity_container"></div> | ||||||
|  |  | ||||||
|     <div style="height: 44px;"> |     <div style="height: 44px;"> | ||||||
|         <div class="dataTables_paginate paging_full_numbers" id="activity_paginate"> |         <div class="paging_full_numbers" id="activity_paginate" style="margin-left: {{ gravatar_size * 1.4 }}px;"> | ||||||
|             <a class="last paginate_button" tabindex="0" id="activity_more">More...</a> |             <a class="last paginate_button" tabindex="0" id="activity_more">More...</a> | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| {% extends "layout.html" %} | {% extends "layout.html" %} | ||||||
|  | {% import '_macros/activity_log.html' as activity_log %} | ||||||
|  |  | ||||||
| {% set show_company_breakdown = (not company) and (not user_id) %} | {% set show_company_breakdown = (not company) and (not user_id) %} | ||||||
| {% set show_engineer_breakdown = (not user_id) %} | {% set show_engineer_breakdown = (not user_id) %} | ||||||
| @@ -38,43 +39,6 @@ | |||||||
|     renderTableAndChart("/api/1.0/stats/modules", "module_container", "module_table", "module_chart", "module"); |     renderTableAndChart("/api/1.0/stats/modules", "module_container", "module_table", "module_chart", "module"); | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  |  | ||||||
|     {% if show_activity %} |  | ||||||
|  |  | ||||||
|         var page_size = 10; |  | ||||||
|         var start_record = 0; |  | ||||||
|  |  | ||||||
|         function load_activity() { |  | ||||||
|             $.ajax({ |  | ||||||
|                 url: make_uri("/api/1.0/activity", {page_size: page_size, start_record: start_record}), |  | ||||||
|                 dataType: "json", |  | ||||||
|                 success: function (data) { |  | ||||||
|                     if (data["activity"].length < page_size) { |  | ||||||
|                         $('#activity_more').hide(); |  | ||||||
|                     } |  | ||||||
|                     if ((start_record == 0) && (data["activity"].length == 0)) { |  | ||||||
|                         $('#activity_header').hide(); |  | ||||||
|                     } |  | ||||||
|                     $("#activity_template").tmpl(data["activity"]).appendTo("#activity_container"); |  | ||||||
|                     $('.ext_link').click(function(event) { |  | ||||||
|                         event.preventDefault(); |  | ||||||
|                         event.stopPropagation(); |  | ||||||
|                         window.open(this.href, '_blank'); |  | ||||||
|                     }); |  | ||||||
|                 } |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|         $(document).ready(function () { |  | ||||||
|             load_activity(); |  | ||||||
|         }); |  | ||||||
|         $(document).ready(function () { |  | ||||||
|             $('#activity_more') |  | ||||||
|                 .click(function() { |  | ||||||
|                         start_record += page_size; |  | ||||||
|                         load_activity() }); |  | ||||||
|         }); |  | ||||||
|  |  | ||||||
|     {% endif %} |  | ||||||
|  |  | ||||||
|     {% if show_user_profile %} |     {% if show_user_profile %} | ||||||
|         $(document).ready(function () { |         $(document).ready(function () { | ||||||
|             $.ajax({ |             $.ajax({ | ||||||
| @@ -101,66 +65,6 @@ | |||||||
| </script> | </script> | ||||||
|  |  | ||||||
| {# Templates #} | {# Templates #} | ||||||
| <script id="activity_template" type="text/x-jquery-tmpl"> |  | ||||||
|     {% raw %} |  | ||||||
|     <div style="margin-bottom: 1em;"> |  | ||||||
|     <div style='float: left; '><img src="${gravatar}" style="width: 32px; height: 32px;"></div> |  | ||||||
|     <div style="margin-left: 40px;"> |  | ||||||
|         <div style="font-weight: bold;">{%html author_link %} ({%html company_link %})</div> |  | ||||||
|         <div style="font-weight: bold;">${date_str} in {%html module_link%}</div> |  | ||||||
|     </div> |  | ||||||
|     <div style="margin-left: 40px;"> |  | ||||||
|         {%if record_type == "commit" %} |  | ||||||
|             {%if correction_comment != "" %} |  | ||||||
|             <div style='font-weight: bold; color: red;'>Commit corrected: |  | ||||||
|                 <span>${correction_comment}</span></div> |  | ||||||
|             {%/if%} |  | ||||||
|             <div style='font-weight: bold;'>${subject}</div> |  | ||||||
|             <div style='white-space: pre-wrap; '>{%html message %}</div> |  | ||||||
|             {%if commit_date_str != "" %} |  | ||||||
|                 <div>Commit date: ${commit_date_str}</div> |  | ||||||
|             {%/if%} |  | ||||||
|             <div><span style="color: green">+<span>${lines_added}</span></span> |  | ||||||
|                 <span style="color: blue">- <span>${lines_deleted}</span></span></div> |  | ||||||
|         {%elif record_type == "mark" %} |  | ||||||
|             <div>Review #${review_number} submitted by {%html parent_author_link %}</div> |  | ||||||
|             <div style='font-weight: bold;'>${subject}</div> |  | ||||||
|             <div>Change Id: <a href="${url}">${review_id}</a></div> |  | ||||||
|             <div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">${description}: <span class="review_mark">${value}</span></div> |  | ||||||
|         {%elif record_type == "email" %} |  | ||||||
|             <div style='font-weight: bold;'> |  | ||||||
|             {%if email_link != "" %} |  | ||||||
|             <a href='${email_link}'> |  | ||||||
|             {%/if%} |  | ||||||
|             ${subject} |  | ||||||
|             {%if email_link != "" %} |  | ||||||
|             </a> |  | ||||||
|             {%/if%} |  | ||||||
|             </div> |  | ||||||
|             {%if blueprint_id_count %} |  | ||||||
|             <div>Mentions blueprints: |  | ||||||
|             {%each( index, value ) blueprint_id %} |  | ||||||
|                 ${value} |  | ||||||
|             {%/each%} |  | ||||||
|             </div> |  | ||||||
|             {%/if%} |  | ||||||
|         {%elif ((record_type == "bpd") || (record_type == "bpc")) %} |  | ||||||
|             <div style='font-weight: bold;'>${title} ({%html blueprint_link %})</div> |  | ||||||
|             <div style='white-space: pre-wrap;'>${summary}</div> |  | ||||||
|  |  | ||||||
|             <div>Priority: <span class="specpriority${priority}">${priority}</span></div> |  | ||||||
|             <div>Status: <span class="status${lifecycle_status}">${lifecycle_status}</span> |  | ||||||
|                 (<span class="specstatus${definition_status}">${definition_status}</span>, |  | ||||||
|                 <span class="specdelivery${implementation_status}">${implementation_status}</span>)</div> |  | ||||||
|             {%if mention_count %} |  | ||||||
|             <div><b>Mention count: ${mention_count}, last mention on ${mention_date_str}</b></div> |  | ||||||
|             {%/if%} |  | ||||||
|         {%/if%} |  | ||||||
|     </div> |  | ||||||
|     </div> |  | ||||||
|     {% endraw %} |  | ||||||
| </script> |  | ||||||
|  |  | ||||||
| <script id="user_profile_template" type="text/x-jquery-tmpl"> | <script id="user_profile_template" type="text/x-jquery-tmpl"> | ||||||
|     {% raw %} |     {% raw %} | ||||||
|     <div> |     <div> | ||||||
| @@ -294,14 +198,7 @@ | |||||||
|         <div id="user_profile_container" style="margin-bottom: 2em;"></div> |         <div id="user_profile_container" style="margin-bottom: 2em;"></div> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|     {% if show_user_activity %} |     {% if show_user_activity %} | ||||||
|         <h2 id="activity_header">Activity log</h2> |         {{ activity_log.show_activity_log(gravatar_size=32, show_all=False) }} | ||||||
|         <div id="activity_container"></div> |  | ||||||
|  |  | ||||||
|         <div style="height: 44px;"> |  | ||||||
|         <div class="dataTables_paginate paging_full_numbers" id="activity_paginate"> |  | ||||||
|             <a class="last paginate_button" tabindex="0" id="activity_more">More...</a> |  | ||||||
|         </div> |  | ||||||
|         </div> |  | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  |  | ||||||
|     {% if show_module_contribution %} |     {% if show_module_contribution %} | ||||||
| @@ -365,14 +262,7 @@ | |||||||
|     {% endif %} |     {% endif %} | ||||||
|  |  | ||||||
|     {% if show_module_activity %} |     {% if show_module_activity %} | ||||||
|         <h2 id="activity_header">Activity log</h2> |         {{ activity_log.show_activity_log(gravatar_size=32, show_all=False) }} | ||||||
|         <div id="activity_container"></div> |  | ||||||
|  |  | ||||||
|         <div style="height: 44px;"> |  | ||||||
|         <div class="dataTables_paginate paging_full_numbers" id="activity_paginate"> |  | ||||||
|             <a class="last paginate_button" tabindex="0" id="activity_more">More...</a> |  | ||||||
|         </div> |  | ||||||
|         </div> |  | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ilya Shakhat
					Ilya Shakhat