mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-27 11:10:10 +00:00
[sub-lib] add 'new sub-lib' in myhome, remove 'sync' for dir in repo page
This commit is contained in:
parent
579b7cdd85
commit
1df79b416a
@ -152,7 +152,7 @@ $('#personal-message-form').submit(function() {
|
||||
var new_msg = $(data['html']);
|
||||
if ($('.msg-list').length == 0) { // the new discussion is the first discussion in this page
|
||||
form.after('<ul class="msg-list"></ul>');
|
||||
}
|
||||
}
|
||||
$('.msg-list').prepend(new_msg);
|
||||
bind_del(new_msg);
|
||||
new_msg.slideDown(400);
|
||||
|
@ -43,6 +43,21 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||
<form id="sublib-create-form" class="file-choose-form hide">
|
||||
<h3>{% trans "Choose a directory:" %}</h3>
|
||||
<div class="dir-tree-cont">
|
||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
||||
</div>
|
||||
<input type="hidden" name="dst_repo" value="" />
|
||||
<input type="hidden" name="dst_path" value="" />
|
||||
<p class="error hide"></p>
|
||||
<input type="button" value="{% trans "Submit" %}" class="submit" />
|
||||
<button class="simplemodal-close">{% trans "Cancel"%}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}{{block.super}}
|
||||
@ -51,6 +66,83 @@
|
||||
$(function() {$('#guide-for-new').modal({appendTo: '#main', focus:false});});
|
||||
{% endif %}
|
||||
{% include "snippets/myhome_extra_script.html" %}
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||
var cur_tab = $('.ui-tabs-selected .a');
|
||||
var lib_create_btn = $('#repo-create'),
|
||||
sublib_create_btn = $('#sub-lib-create');
|
||||
// for initial state
|
||||
if (cur_tab.attr('id') == 'mylib-tab') {
|
||||
lib_create_btn.removeClass('hide');
|
||||
}
|
||||
if (cur_tab.attr('id') == 'sublib-tab') {
|
||||
sublib_create_btn.removeClass('hide');
|
||||
}
|
||||
$('#mylib-tab').click(function() {
|
||||
lib_create_btn.removeClass('hide');
|
||||
sublib_create_btn.addClass('hide');
|
||||
});
|
||||
$('#sublib-tab').click(function() {
|
||||
lib_create_btn.addClass('hide');
|
||||
sublib_create_btn.removeClass('hide');
|
||||
});
|
||||
$('#shared-lib-tab, #grp-lib-tab').click(function() {
|
||||
lib_create_btn.addClass('hide');
|
||||
sublib_create_btn.addClass('hide');
|
||||
});
|
||||
var sublib_create_form = $('#sublib-create-form');
|
||||
sublib_create_btn.click(function() {
|
||||
var dir_tree_cont = $('.dir-tree-cont', sublib_create_form);
|
||||
sublib_create_form.modal();
|
||||
$.ajax({
|
||||
url: '{% url 'get_my_unenc_repos' %}',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var file_tree = new FileTree();
|
||||
var repos = file_tree.format_repo_data(data);
|
||||
if (repos.length > 0) {
|
||||
file_tree.renderDirTree(dir_tree_cont.data('site_root', '{{SITE_ROOT}}'), sublib_create_form, repos);
|
||||
} else {
|
||||
dir_tree_cont.html('<p class="error">' + "{% trans "You don't have any library at present" %}" + '</p>');
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
if (!jqXHR.responseText) {
|
||||
dir_tree_cont.html('<p class="error">' + "{% trans "Failed. Please check the network." %}" + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.submit', sublib_create_form).click(function() {
|
||||
var ori_repo_id = $('[name="dst_repo"]', sublib_create_form).val();
|
||||
var path = $('[name="dst_path"]', sublib_create_form).val();
|
||||
|
||||
if (!path || path == '/') {
|
||||
$('.error', sublib_create_form).html("{% trans "Please choose a directory" %}").removeClass('hide');
|
||||
return false;
|
||||
}
|
||||
|
||||
// path ends with '/', rm it here
|
||||
path = path.substr(0, path.length - 1);
|
||||
$.ajax({
|
||||
url: '{{SITE_ROOT}}ajax/repo/' + ori_repo_id + '/dir/sub_repo/?p=' + e(path),
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
var err;
|
||||
if (xhr.responseText) {
|
||||
err = jQuery.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
err = "{% trans "Failed. Please check the network." %}";
|
||||
}
|
||||
$('.error', sublib_create_form).html(err).removeClass('hide');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
{% endif %}
|
||||
{% include "snippets/repo_create_js.html" with post_url=repo_create_url %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -205,16 +205,6 @@
|
||||
<button class="simplemodal-close">{% trans "Cancel"%}</button>
|
||||
</form>
|
||||
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled and not repo.is_virtual %}
|
||||
<div id="dir-sync-popup" class="hide">
|
||||
<h3 class="hd">{% trans "Sync %(dir_name)s" %}</h3>
|
||||
<p>{% trans "A sub-library will be created from this directory. It will be listed in your desktop client, and you can download it just like downloading a normal library." %}</p>
|
||||
<button class="create-sub-repo">{% trans "Create" %}</button>
|
||||
<button class="simplemodal-close hide" style="margin-left:0;">{% trans "Close" %}</button>
|
||||
<p class="error hide"></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include "snippets/file_share_popup.html" %}
|
||||
|
||||
{% with attach_type='dir' %}
|
||||
@ -1533,39 +1523,6 @@ $('.file-share, .dir-share', context).click(function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled and not repo.is_virtual %}
|
||||
$('.dir-sync', context).click(function() {
|
||||
var name = $(this).parents('.dir-item').attr('data-name');
|
||||
var popup = $('#dir-sync-popup'),
|
||||
hd = $('.hd', popup),
|
||||
create_btn = $('.create-sub-repo', popup);
|
||||
popup.modal({appendTo:'#main', focus:false, minWidth:250, maxWidth:400});
|
||||
$('#simplemodal-container').css({'height':'auto'});
|
||||
hd.html(hd.html().replace('%(dir_name)s', '<span class="op-target">' + name + '</span>'));
|
||||
|
||||
create_btn.click(function () {
|
||||
$.ajax({
|
||||
url: '{% url 'sub_repo' repo.id %}?p=' + e(cur_path + name) + '&name=' + e(name),
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
create_btn.replaceWith("<p>{% trans "Sub-library is created." %}</p>");
|
||||
$('.simplemodal-close', popup).removeClass('hide');
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
var err;
|
||||
if (xhr.responseText) {
|
||||
err = jQuery.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
err = "{% trans "Failed. Please check the network." %}";
|
||||
}
|
||||
$('.error', popup).html(err).removeClass('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
} //function 'opOnDirent' ends here
|
||||
|
||||
$('#add-new-file-form, #add-new-dir-form, #rename-form, #mv-form').submit(function() {
|
||||
@ -1992,7 +1949,7 @@ function updateCmt() {
|
||||
|
||||
// check if a sub-lib exists, if not, create one
|
||||
$.ajax({
|
||||
url: '{% url 'sub_repo' repo.id %}?p=' + e(form.data('dir-path')) + '&name=' + e(form.attr('data-name')),
|
||||
url: '{% url 'sub_repo' repo.id %}?p=' + e(form.data('dir-path')),
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$('[name="repo_id"]', form).val(data['sub_repo_id']);
|
||||
|
@ -12,22 +12,23 @@ $('.cancel', msg_form).click(function() {
|
||||
|
||||
$('.add-file').click(function(){
|
||||
$('#add-file-popup').modal();
|
||||
var file_tree_cont = $('#file-tree');
|
||||
$.ajax({
|
||||
'url': repos_get_url,
|
||||
'cache': false,
|
||||
'dataType': 'json',
|
||||
'success': function(data) {
|
||||
url: repos_get_url,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var file_tree = new FileTree();
|
||||
var repos = file_tree.format_repo_data(data);
|
||||
if (repos.length > 0) {
|
||||
file_tree.renderFileTree($('#file-tree').data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true});
|
||||
file_tree.renderFileTree(file_tree_cont.data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true});
|
||||
} else {
|
||||
$('#file-tree').html('<p class="error">' + "{% trans "You don't have any library at present" %}" + '</p>');
|
||||
file_tree_cont.html('<p class="error">' + "{% trans "You don't have any library at present" %}" + '</p>');
|
||||
}
|
||||
},
|
||||
'error': function(jqXHR, textStatus, errorThrown) {
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
if (!jqXHR.responseText) {
|
||||
$('#file-tree').html('<p class="error">' + "{% trans "Failed. Please check the network." %}" + '</p>');
|
||||
file_tree_cont.html('<p class="error">' + "{% trans "Failed. Please check the network." %}" + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,14 +3,21 @@
|
||||
<div id="tabs" class="tab-tabs">
|
||||
<div class="hd ovhd">
|
||||
<ul class="tab-tabs-nav fleft">
|
||||
<li class="tab"><a href="#my-own-repos" class="a">{% trans "Mine" %}</a></li>
|
||||
<li class="tab"><a href="#my-own-repos" class="a" id="mylib-tab">{% trans "Mine" %}</a></li>
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||
<li class="tab"><a href="#my-sub-repos" class="a">{% trans "Sub-libraries" %}</a></li>
|
||||
<li class="tab"><a href="#my-sub-repos" class="a" id="sublib-tab">{% trans "Sub-libraries" %}</a></li>
|
||||
{% endif %}
|
||||
<li class="tab"><a href="#repos-shared-to-me" class="a">{% trans "Shared" %}</a></li>
|
||||
<li class="tab"><a href="#group-repos" class="a">{% trans "Group" %}</a></li>
|
||||
<li class="tab"><a href="#repos-shared-to-me" class="a" id="shared-lib-tab">{% trans "Shared" %}</a></li>
|
||||
<li class="tab"><a href="#group-repos" class="a" id="grp-lib-tab">{% trans "Group" %}</a></li>
|
||||
</ul>
|
||||
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
||||
<div class="fright">
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||
<button id="repo-create" class="hide"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
||||
<button id="sub-lib-create" class="hide"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Sub-library" %}</span></button>
|
||||
{% else %}
|
||||
<button id="repo-create"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div id="my-own-repos" class="hide">
|
||||
{% if owned_repos %}
|
||||
|
@ -24,9 +24,6 @@
|
||||
<a class="op dir-download" href="{{dirent.dl_link}}">{% trans 'Download' %}</a>
|
||||
{% if not repo.encrypted %}
|
||||
<a class="op dir-share" href="#" data-link="{{ dirent.sharelink }}" data-token="{{ dirent.sharetoken }}" data-upload-link="{{ dirent.uploadlink }}" data-upload-token="{{ dirent.uploadtoken }}">{% trans "Share" %}</a>
|
||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled and not repo.is_virtual %}
|
||||
<a class="op dir-sync" href="#">{% trans "Sync" %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if user_perm == 'rw' %}
|
||||
|
@ -188,7 +188,7 @@ def get_my_unenc_repos(request):
|
||||
repos = seafile_api.get_owned_repo_list(request.user.username)
|
||||
repo_list = []
|
||||
for repo in repos:
|
||||
if repo.encrypted:
|
||||
if repo.encrypted or repo.is_virtual:
|
||||
continue
|
||||
repo_list.append({"name": repo.name, "id": repo.id})
|
||||
|
||||
@ -1140,10 +1140,10 @@ def sub_repo(request, repo_id):
|
||||
result = {}
|
||||
|
||||
path = request.GET.get('p')
|
||||
name = request.GET.get('name')
|
||||
if not (path and name):
|
||||
if not path:
|
||||
result['error'] = _('Argument missing')
|
||||
return HttpResponse(json.dumps(result), status=400, content_type=content_type)
|
||||
name = os.path.basename(path)
|
||||
|
||||
username = request.user.username
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user