stackalytics/stackalytics/dashboard/templates/_macros/activity_log.html

229 lines
9.7 KiB
HTML

{% 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,
show_twitter=False) -%}
{% set page_url = request.base_url %}
{% if show_twitter %}
<script>window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));
</script>
{% endif %}
<script type="text/javascript">
var page_size = 10;
var start_record = 0;
var uri_options = {};
{% if show_all %}
uri_options = {project_type: "all", release: "all", metric: "all"};
{% endif %}
{% if user_id %}
uri_options["user_id"] = "{{ user_id }}";
{% endif %}
{% if company %}
uri_options["company"] = "{{ company|safe }}";
{% endif %}
{% if blueprint_id %}
uri_options["blueprint_id"] = "{{ blueprint_id }}";
{% endif %}
function load_activity(extra_options) {
var options = {page_size: page_size, start_record: start_record, };
$.extend(options, extra_options);
$.ajax({
url: makeURI("/api/1.0/activity", options),
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();
}
$.each(data["activity"], function() {
extendWithGravatar(this, {{ gravatar_size }});
$.extend(this, {page_url: document.location.pathname});
{% if show_twitter %}
extendWithTweet(this);
{% endif %}
});
$("#activity_template").tmpl(data["activity"]).insertBefore('#more_button');
$('.ext_link').click(function (event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
$(".expand-button").click(function () {
$("#content-" + this.id).slideToggle('fast');
});
{% if show_twitter %}
if (window.twttr.widgets) {
window.twttr.widgets.load();
}
{% endif %}
}
});
}
$(document).ready(function () {
load_activity(uri_options);
});
$(document).ready(function () {
$('#activity_more')
.click(function () {
start_record += page_size;
load_activity(uri_options)
});
});
</script>
<script id="activity_template" type="text/x-jquery-tmpl">
<div class="record">
<div style='float: left; '>
{% if show_user_gravatar %}
<img src="${gravatar}">
{% else %}
<img src="//www.gravatar.com/avatar/a${parseInt(record_type,36)}?s={{ gravatar_size }}&d=identicon" style="width: {{ gravatar_size }}px; height: {{ gravatar_size }}px;">
{% endif %}
</div>
<div style="margin-left: {{ gravatar_size * 1.4 }}px;">
{% raw %}
{%if coauthor %}
<div class="header">
{%each(index,value) coauthor %}{%if index>0 %}, {%/if%} <a href="{%html + value.author_link.uri %}">{%html value.author_link.title%}</a> (<a href="{%html page_url + value.company_link.uri %}">{%html value.company_link.title %}</a>){%/each%}
</div>
{%else%}
<div class="header"><a href="{%html page_url + author_link.uri %}">{%html author_link.title %}</a> (<a href="{%html page_url + company_link.uri %}">{%html company_link.title %}</a>)</div>
{%/if%}
<div class="header">${date_str} in {%html module_link.title%}
{%if record_type == "mark" || record_type == "review" || record_type == "patch" || record_type == "tr" %}
{%if branch != "master" %}(${branch}){%/if%}
{%/if%}
{%if record_type == "commit" %}
{%if branches.indexOf("master") < 0 %}(${branches}){%/if%}
{%/if%}
</div>
{%if record_type == "commit" %}
<div class="header">Commit &ldquo;${subject}&rdquo;</div>
<div class="message">{%html message %}</div>
{%if commit_date_str != "" && commit_date_str != date_str %}
<div>Commit date: ${commit_date_str}</div>
{%/if%}
{%if correction_comment != "" %}
<div style='font-weight: bold; color: red;'>Commit corrected:
<span>${correction_comment}</span></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 class="header">Review &ldquo;${parent_subject}&rdquo;</div>
<div>Change request by: <a href="{%html page_url + parent_author_link.uri %}">{%html parent_author_link.title %}</a> (<a href="{%html parent_company_link.uri %}">{%html parent_company_link.title %}</a>)</div>
{%if patch_author_link != parent_author_link %}
<div>Patch by: <a href="{%html patch_author_link.uri %}">{%html patch_author_link.title %}</a> (<a href="{%html patch_company_link.uri %}">{%html patch_company_link.title %}</a>)</div>
{%/if%}
<div>Change Id: <a href="${parent_url}" target="_blank">${review_id}</a></div>
<div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">
{%if (type == "Workflow" && value == 1) %}
Approve
{%elif (type == "Self-Workflow" && value == 1) %}
Self-Approve
{%elif (type == "Workflow" && value == -1) %}
Work in progress
{%elif (type == "Abandon" || type == "Self-Abandon") %}
${type}
{%else%}
${type}: <span class="review_mark">${((value>0)? "+": "") + value}</span>
{%/if%}
</div>
{%elif record_type == "review" %}
<div class="header">Change request &ldquo;${subject}&rdquo;</div>
<div>Current Status: ${status}</div>
<div>Change Id: <a href="${url}" target="_blank">${id}</a></div>
{%elif record_type == "patch" %}
<div class="header">Patch #${number} &ldquo;${parent_subject}&rdquo;</div>
<div>Change Id: <a href="${parent_url}" target="_blank">${review_id}</a></div>
{%elif record_type == "email" %}
<div class="header">
{%if email_link != "" %}
<a href='${email_link}'>
{%/if%}
Email &ldquo;${subject}&rdquo;
{%if email_link != "" %}
</a>
{%/if%}
</div>
{%if blueprint_id_count %}
<div>Mentions blueprints:
{%each( index, value ) blueprint_links %}
{%html value %}
{%/each%}
</div>
{%/if%}
{%if body %}
<div>Email: <span class="expand-button" id="button-${record_id}">[+]</span></div>
<div id="content-button-${record_id}" class="message" style="display:none;">${body}</div>
{%/if%}
{%elif ((record_type == "bpd") || (record_type == "bpc")) %}
<div class="header">Blueprint &ldquo;${title}&rdquo; ({%html blueprint_link %})</div>
<div class="message">${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%}
{%elif ((record_type == "bugf") || (record_type == "bugr")) %}
<div class="header">Bug &ldquo;${title}&rdquo; (<a href="${web_link}" class="ext_link">${number}</a>)</div>
<div>Status: <span class="status${status_class}">${status}</span></div>
<div>Importance: <span class="importance${importance}">${importance}</span></div>
{%elif record_type == "member" %}
<div class="header"><a href="${member_uri}" target="_blank">Registered</a> in OpenInfra Foundation</div>
{%elif record_type == "tr" %}
<div class="header">Translated ${loc} words into ${language}</div>
{%/if%}
{%if tweet %}
<div style="margin-top: 1em;">
<a href="https://twitter.com/intent/tweet?text=${tweet}&url=${tweet_url}" class="twitter-share-button" data-via="stackalytics">Tweet</a>
</div>
{%/if%}
</div>
</div>
{% endraw %}
</script>
<div id="activity_container">
<h2 id="activity_header">Activity Log {% if company %} | {{ company_original }}{% endif %} </h2>
<div id="more_button" style="height: 44px;">
<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>
</div>
</div>
</div>
{%- endmacro %}