mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 07:55:36 +00:00
Merge branch 'events'
This commit is contained in:
75
templates/snippets/events.html
Normal file
75
templates/snippets/events.html
Normal file
@@ -0,0 +1,75 @@
|
||||
{% load seahub_tags avatar_tags group_avatar_tags %}
|
||||
{% load url from future %}
|
||||
<h3>最近事件</h3>
|
||||
<ul id="events" class="hide">
|
||||
{% for ev in events %}
|
||||
<li class="event-item w100 ovhd">
|
||||
{% if ev.etype == 'repo-update' %}
|
||||
{% with author=ev.commit.creator_name commit=ev.commit repo=ev.repo %}
|
||||
<div class="pic fleft" data="{{ author }}">
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{% avatar author 40 %}</a>
|
||||
</div>
|
||||
<div class="txt fright">
|
||||
<div class="event-hd">
|
||||
<span class="time">{{ commit.ctime|translate_commit_time }}</span>
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
</div>
|
||||
<p>更新了资料库 <a href="{{SITE_ROOT}}repo/{{repo.id}}">{{ repo.name }}</a></p>
|
||||
<p class="commit-msg ovhd">{{ commit.desc|translate_commit_desc }}
|
||||
{% if repo.encrypted %}
|
||||
{% if repo.password_set %}
|
||||
<a class="lsch-encrypted" password_set="true" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" repo_id="{{repo.id}}" repo_name="{{repo.name}}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
|
||||
{% else %}
|
||||
<a class="lsch-encrypted" password_set="false" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" repo_id="{{repo.id}}" repo_name="{{repo.name}}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-create' %}
|
||||
{% with author=ev.creator repo_id=ev.repo_id repo_name=ev.repo_name %}
|
||||
<div class="pic fleft" data="{{ author }}">
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{% avatar author 40 %}</a>
|
||||
</div>
|
||||
<div class="txt fright">
|
||||
<div class="event-hd">
|
||||
<span class="time">{{ ev.timestamp|translate_commit_time }}</span>
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
</div>
|
||||
<p>创建了资料库 <a href="{{SITE_ROOT}}repo/{{repo_id}}">{{ repo_name }}</a></p>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-delete' %}
|
||||
{% with author=ev.repo_owner repo_name=ev.repo_name %}
|
||||
<div class="pic fleft" data="{{ author }}">
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{% avatar author 40 %}</a>
|
||||
</div>
|
||||
<div class="txt fright">
|
||||
<div class="event-hd">
|
||||
<span class="time">{{ ev.timestamp|translate_commit_time }}</span>
|
||||
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
</div>
|
||||
<p>删除了资料库 {{ repo_name }}</p>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form id="repo-set-password-form" class="hide">
|
||||
<h3>资料库 <span class="repo-name"></span> 已加密</h3>
|
||||
<input type="hidden" name="repo_id" value="" />
|
||||
<label>密码:</label>
|
||||
<input type="password" name="password" maxlength="64" />
|
||||
<p class="tip">密码只会在服务器上暂存1小时</p>
|
||||
<p class="error"></p>
|
||||
<input type="submit" class="submit" value="提交" />
|
||||
<button class="simplemodal-close">取消</button>
|
||||
</form>
|
||||
<div id="ls-ch" class="hide"></div><!--list modification details of a commit-->
|
57
templates/snippets/events_js.html
Normal file
57
templates/snippets/events_js.html
Normal file
@@ -0,0 +1,57 @@
|
||||
{% include 'snippets/list_commit_detail.html' %}
|
||||
$('.event-item').each(function(index) {
|
||||
if (index > 0 && $(this).children('.pic').attr('data') == $(this).prev().children('.pic').attr('data')) {
|
||||
$(this).children('.pic').addClass('hide');
|
||||
}
|
||||
});
|
||||
$('#events').removeClass('hide');
|
||||
|
||||
// 查看加密 repo 的详情时, 先为其设置密码
|
||||
var cur_event;
|
||||
$('a.lsch-encrypted').click(function() {
|
||||
if ($(this).attr('password_set') == 'true') {
|
||||
list_commit_change($(this));
|
||||
} else {
|
||||
cur_event = $(this);
|
||||
$('#repo-set-password-form input[name="repo_id"]').val($(this).attr('repo_id'));
|
||||
$('#repo-set-password-form .repo-name').html($(this).attr('repo_name'));
|
||||
$('#repo-set-password-form').modal({appendTo:'#main'});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$('#repo-set-password-form .submit').click(function() {
|
||||
var input_password = $('#repo-set-password-form input[name="password"]');
|
||||
var repo_id = $('#repo-set-password-form input[name="repo_id"]').val();
|
||||
var password = input_password.val();
|
||||
if (!password) {
|
||||
apply_form_error('repo-set-password-form', "密码不能为空");
|
||||
} else {
|
||||
apply_form_error('repo-set-password-form', '');
|
||||
$.ajax({
|
||||
url: '{% url repo_set_password %}',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
cache: 'false',
|
||||
beforeSend: prepareCSRFToken,
|
||||
data: {
|
||||
repo_id: repo_id,
|
||||
password: password,
|
||||
username: '{{request.user.username}}'
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['success']) {
|
||||
$.modal.close();
|
||||
$('a.lsch-encrypted[repo_id="' + repo_id + '"]').attr('password_set', 'true');
|
||||
list_commit_change(cur_event);
|
||||
} else {
|
||||
input_password.val('');
|
||||
apply_form_error('repo-set-password-form', data['error']);
|
||||
}
|
||||
},
|
||||
error: function(data, textStatus, jqXHR) {
|
||||
apply_form_error('repo-set-password-form', '访问网站出错');
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
@@ -1,49 +1,66 @@
|
||||
$('.lsch').click(function() {
|
||||
var time = '<span class="commit-time">(' + $(this).attr('data') + ')</span>';
|
||||
$.ajax({
|
||||
url: $(this).attr('href'),
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
var title = '<h3>修改详情' + time + '</h3>',
|
||||
con = '';
|
||||
var show = function(data_) {
|
||||
con += '<ul>';
|
||||
for (var i = 0, len = data_.length; i < len; i++) {
|
||||
con += '<li>' + data_[i] + '</li>';
|
||||
}
|
||||
con += '</ul>';
|
||||
};
|
||||
if (data['new'].length > 0) {
|
||||
con += '<h4 id="ls-ch-new">新文件</h4>';
|
||||
show(data['new']);
|
||||
}
|
||||
if (data['removed'].length > 0) {
|
||||
con += '<h4 id="ls-ch-rm">删除的文件</h4>';
|
||||
show(data['removed']);
|
||||
}
|
||||
if (data['renamed'].length > 0) {
|
||||
con += '<h4 id="ls-ch-rn">重命名或移动的文件</h4>';
|
||||
show(data['renamed']);
|
||||
}
|
||||
if (data['modified'].length > 0) {
|
||||
con += '<h4 id="ls-ch-modi">修改的文件</h4>';
|
||||
show(data['modified']);
|
||||
}
|
||||
if (data['newdir'].length > 0) {
|
||||
con += '<h4 id="ls-ch-newdir">新目录</h4>';
|
||||
show(data['newdir']);
|
||||
}
|
||||
if (data['deldir'].length > 0) {
|
||||
con += '<h4 id="ls-ch-deldir">删除的目录</h4>';
|
||||
show(data['deldir']);
|
||||
}
|
||||
if (!con) {
|
||||
con = '<p>没有文件被改动</p>';
|
||||
}
|
||||
$('#ls-ch').html(title + con).modal({appendTo:'#main', maxHeight: window.innerHeight - 57, autoResize:true});
|
||||
<!-- <script type="text/javascript"> -->
|
||||
|
||||
function get_commit_diff(url, callback) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
var con = '';
|
||||
var show = function(data_) {
|
||||
con += '<ul>';
|
||||
for (var i = 0, len = data_.length; i < len; i++) {
|
||||
con += '<li>' + data_[i] + '</li>';
|
||||
}
|
||||
});
|
||||
return false;
|
||||
con += '</ul>';
|
||||
};
|
||||
if (data['new'].length > 0) {
|
||||
con += '<h4 id="ls-ch-new">新文件</h4>';
|
||||
show(data['new']);
|
||||
}
|
||||
if (data['removed'].length > 0) {
|
||||
con += '<h4 id="ls-ch-rm">删除的文件</h4>';
|
||||
show(data['removed']);
|
||||
}
|
||||
if (data['renamed'].length > 0) {
|
||||
con += '<h4 id="ls-ch-rn">重命名或移动的文件</h4>';
|
||||
show(data['renamed']);
|
||||
}
|
||||
if (data['modified'].length > 0) {
|
||||
con += '<h4 id="ls-ch-modi">修改的文件</h4>';
|
||||
show(data['modified']);
|
||||
}
|
||||
if (data['newdir'].length > 0) {
|
||||
con += '<h4 id="ls-ch-newdir">新目录</h4>';
|
||||
show(data['newdir']);
|
||||
}
|
||||
if (data['deldir'].length > 0) {
|
||||
con += '<h4 id="ls-ch-deldir">删除的目录</h4>';
|
||||
show(data['deldir']);
|
||||
}
|
||||
if (!con) {
|
||||
con = '<p>没有文件被改动</p>';
|
||||
}
|
||||
callback(con);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function list_commit_change(obj) {
|
||||
var url = obj.attr('href');
|
||||
get_commit_diff(url, function(content) {
|
||||
var time = '<span class="commit-time">(' + obj.attr('data') + ')</span>';
|
||||
var title = '<h3>修改详情' + time + '</h3>';
|
||||
$('#ls-ch').html(title + content).modal({
|
||||
appendTo:'#main',
|
||||
maxHeight: window.innerHeight - 57,
|
||||
autoResize:true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$('.lsch').click(function() {
|
||||
list_commit_change($(this));
|
||||
return false;
|
||||
});
|
||||
|
Reference in New Issue
Block a user