mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-31 22:57:47 +00:00
Add repo operations
This commit is contained in:
parent
a7eecaeff4
commit
8d12ea22c7
@ -1183,6 +1183,24 @@ textarea:-moz-placeholder {/* for FF */
|
||||
.user-item .txt-item {
|
||||
margin:0;
|
||||
}
|
||||
/**** dropdown menu ******/
|
||||
.dropdown-menu {
|
||||
position:absolute;
|
||||
background:#fff;
|
||||
padding:6px 1px;
|
||||
border:1px solid #eee;
|
||||
border-radius:5px;
|
||||
z-index:10;
|
||||
}
|
||||
.dropdown-menu li a,
|
||||
.dropdown-menu a {
|
||||
display:block;
|
||||
padding:4px 12px;
|
||||
width:180px;
|
||||
}
|
||||
.dropdown-menu a:hover {
|
||||
background:#eee;
|
||||
}
|
||||
/********** container ***********/
|
||||
#main, #footer {
|
||||
width:950px;
|
||||
@ -1945,25 +1963,25 @@ textarea:-moz-placeholder {/* for FF */
|
||||
#mv-dir-list .icon-caret-right {
|
||||
margin-right:15px;
|
||||
}
|
||||
#rename-form .input {
|
||||
.inline-rename-form .input {
|
||||
font-size:14px;
|
||||
}
|
||||
.web-setting-form .submit,
|
||||
#rename-form .submit {
|
||||
.inline-rename-form .submit {
|
||||
color:green;
|
||||
}
|
||||
.web-setting-form .cancel,
|
||||
#rename-form .cancel {
|
||||
.inline-rename-form .cancel {
|
||||
color:#666;
|
||||
}
|
||||
#rename-form .input,
|
||||
#rename-form .submit {
|
||||
.inline-rename-form .input,
|
||||
.inline-rename-form .submit {
|
||||
margin:0;
|
||||
}
|
||||
.web-setting-form .submit,
|
||||
.web-setting-form .cancel,
|
||||
#rename-form .submit,
|
||||
#rename-form .cancel {
|
||||
.inline-rename-form .submit,
|
||||
.inline-rename-form .cancel {
|
||||
font-size:16px;
|
||||
line-height:1;
|
||||
}
|
||||
@ -2090,7 +2108,7 @@ textarea:-moz-placeholder {/* for FF */
|
||||
.fixed-upload-file-dialog .op-icon {
|
||||
font-size:18px;
|
||||
color: #b8b8b8;
|
||||
margin:0;
|
||||
margin:0;
|
||||
}
|
||||
.fixed-upload-file-dialog .close,
|
||||
.fileupload-buttonbar .cancel {
|
||||
|
@ -32,7 +32,7 @@
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="rename-form-template">
|
||||
<form id="rename-form" action="" method="post">
|
||||
<form id="rename-form" class="inline-rename-form" action="" method="post">
|
||||
<input type="text" name="newname" value="<%- dirent_name %>" class="input vam" maxlength="{{max_file_name}}" />
|
||||
<button type="submit" class="submit sf2-icon-tick vam" title="{% trans "Submit" %}"></button>
|
||||
<button type="button" class="cancel sf2-icon-x2 vam" title="{% trans "Cancel" %}"></button>
|
||||
@ -127,3 +127,11 @@
|
||||
<button class="no">{% trans "No" %}</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="repo-rename-form-template">
|
||||
<form id="repo-rename-form" class="inline-rename-form" action="" method="post">
|
||||
<input type="text" name="newname" value="<%- repo_name %>" class="input vam" maxlength="{{max_file_name}}" />
|
||||
<button type="submit" class="submit sf2-icon-tick vam" title="{% trans "Submit" %}"></button>
|
||||
<button type="button" class="cancel sf2-icon-x2 vam" title="{% trans "Cancel" %}"></button>
|
||||
</form>
|
||||
</script>
|
||||
|
@ -37,14 +37,24 @@
|
||||
<% } %>
|
||||
</td>
|
||||
<% if (name) { %>
|
||||
<td><a href="#my-libs/lib/<%= id %>"><%- name %></a></td>
|
||||
<td><span class="repo-name-span"><a href="#my-libs/lib/<%= id %>"><%- name %></a></span></td>
|
||||
<% } else { %>
|
||||
<td>{% trans "Broken (please contact your administrator to fix this library)" %}</td>
|
||||
<% } %>
|
||||
<td>
|
||||
<td class="repo-op-td">
|
||||
<div class="op-container">
|
||||
<span class="sf2-icon-share sf2-x repo-share-btn op-icon vh" title="{% trans "Share" %}"></span>
|
||||
<span class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}"></span>
|
||||
<span class="sf2-icon-caret-down more-op-icon op-icon vh js-toggle-popup" title="{% trans "More operations" %}"></span>
|
||||
<ul class="hidden-op repo-hidden-op hide dropdown-menu">
|
||||
<li><a class="op js-repo-rename" href="#">{% trans "Rename" %}</a></li>
|
||||
<li><a class="op js-repo-transfer" href="#">{% trans "Transfer" %}</a></li>
|
||||
<li><a class="op js-popup-permission-settings" href="#">{% trans "Permissions" %}</a></li>
|
||||
<% if (enable_repo_history_setting) { %>
|
||||
<li><a class="op js-popup-history-settings" href="#">{% trans "History Settings" %}</a></li>
|
||||
<% } %>
|
||||
<li><a class="op js-view-links" href="#">{% trans "Sharing Links" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= size_formatted %></td>
|
||||
@ -218,7 +228,7 @@
|
||||
</div>
|
||||
<% if (dirent.perm == 'rw') { %>
|
||||
<span class="more-op-icon sf2-icon-caret-down op-icon" title="{% trans "More operations" %}"></span>
|
||||
<ul class="hidden-op hide">
|
||||
<ul class="hidden-op dirent-hidden-op hide">
|
||||
<li><a class="op rename" href="#">{% trans "Rename" %}</a></li>
|
||||
<li><a class="op mv" href="#">{% trans "Move" %}</a></li>
|
||||
<li><a class="op cp" href="#">{% trans "Copy" %}</a></li>
|
||||
@ -299,7 +309,7 @@
|
||||
</div>
|
||||
<% if (dirent.perm == 'rw') { %>
|
||||
<span class="more-op-icon sf2-icon-caret-down op-icon" title="{% trans "More Operations"%}"></span>
|
||||
<ul class="hidden-op hide">
|
||||
<ul class="hidden-op dirent-hidden-op hide">
|
||||
<li><a class="op rename" href="#">{% trans "Rename" %}</a></li>
|
||||
<li><a class="op mv" href="#">{% trans "Move" %}</a></li>
|
||||
<li><a class="op cp" href="#">{% trans "Copy" %}</a></li>
|
||||
@ -732,7 +742,7 @@
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<span class="sf2-icon-delete delete-icon op-icon vh" title="{% trans "Delete" %}"></span>
|
||||
<span class="sf2-icon-delete delete-icon op-icon vh" title="{% trans "Delete" %}"></span>
|
||||
</td>
|
||||
</script>
|
||||
<script type="text/template" id="folder-perm-popup-tmpl">
|
||||
@ -802,14 +812,14 @@
|
||||
<td><%- repo_name %></td>
|
||||
<td><%= mtime_relative %></td>
|
||||
<td>
|
||||
<span class="sf2-icon-delete unstar op-icon vh" title="{% trans "Unstar" %}"></span>
|
||||
<span class="sf2-icon-delete unstar op-icon vh" title="{% trans "Unstar" %}"></span>
|
||||
</td>
|
||||
</script>
|
||||
<script type="text/template" id="my-repos-hd-tmpl">
|
||||
<tr>
|
||||
<th width="4%"><!--icon--></th>
|
||||
<th width="46%" class="by-name cspt">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
|
||||
<th width="10%"><!--op--></th>
|
||||
<th width="42%" class="by-name cspt">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
|
||||
<th width="14%"><!--op--></th>
|
||||
<th width="20%">{% trans "Size" %}</th>
|
||||
<th width="20%" class="by-time cspt">{% trans "Last Update" %} <span class="sort-icon icon-caret-up"></span></th>
|
||||
</tr>
|
||||
@ -939,6 +949,7 @@
|
||||
<p class="txt-item ellipsis" title="<%- contact_email %>"><%- contact_email %></p>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="group-settings-tmpl">
|
||||
<% if (is_owner) { %>
|
||||
<ul class="group-setting-list">
|
||||
@ -966,21 +977,23 @@
|
||||
</ul>
|
||||
<% } %>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="group-rename-form-tmpl">
|
||||
<form method="post" action="">
|
||||
<h3>{% trans "Rename Group To" %}</h3>
|
||||
<input type="text" name="new_name" value="" class="input" /><br />
|
||||
<p class="error hide"></p>
|
||||
<input type="submit" value="{% trans "Submit" %}" />
|
||||
</form>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="group-transfer-form-tmpl">
|
||||
<form method="post" action="">
|
||||
<h3>{% trans "Transfer Group To" %}</h3>
|
||||
<input type="hidden" name="email" /><br />
|
||||
<p class="error hide"></p>
|
||||
<input type="submit" value="{% trans "Submit" %}" />
|
||||
</form>
|
||||
</form>
|
||||
</script>
|
||||
<script type="text/template" id="group-import-members-form-tmpl">
|
||||
<form enctype="multipart/form-data" method="post" action="">
|
||||
@ -991,6 +1004,7 @@
|
||||
<p class="error hide"></p>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="group-manage-members-tmpl">
|
||||
<h3><%= title %></h3>
|
||||
<form method="post" action="" id="add-group-members-form">
|
||||
@ -1023,6 +1037,7 @@
|
||||
<p class="error hide"></p>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="group-manage-member-tmpl">
|
||||
<td>
|
||||
<img src="<%= avatar_url %>" alt="" width="20" class="avatar" />
|
||||
@ -1070,3 +1085,24 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="history-settings-dialog-tmpl">
|
||||
<h3><%= title %></h3>
|
||||
<form id="repo-basic-info-form" action="" method="post" class="form">{% csrf_token %}
|
||||
<input type="radio" name="history" value="full_history"
|
||||
<% if (full_history_checked) { %> checked="checked"{ <% } %>
|
||||
class="vam" />
|
||||
<span class="vam">{% trans "Keep full history" %}</span><br />
|
||||
<input type="radio" name="history" value="no_history"
|
||||
<% if (no_history_checked) { %>checked="checked"<% } %>
|
||||
class="vam" />
|
||||
<span class="vam">{% trans "Don't keep history" %}</span><br />
|
||||
<input type="radio" name="history" value="partial_history"
|
||||
<% if (partial_history_checked) { %>checked="checked"<% } %>
|
||||
class="vam" />
|
||||
<span calss="vam">{% trans "Only keep a period of history:" %}
|
||||
<input type="text" name="days" size="4" disabled="disabled"
|
||||
class="input-disabled" value="<%- history_limit %>" /> {% trans "days" %}</span><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
||||
</script>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<h3 class="fleft">{% trans "Mine" %}</h3>
|
||||
<button class="repo-create fright"><span class="icon-plus-square add vam"></span><span class="vam">{% trans "New Library" %}</span></button>
|
||||
</div>
|
||||
<table class="hide">
|
||||
<table class="my-own-repos-table hide">
|
||||
<thead></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
@ -278,6 +278,7 @@ app["pageOptions"] = {
|
||||
enable_resumable_fileupload: {% if enable_resumable_fileupload %} true {% else %} false {% endif %},
|
||||
enable_thumbnail: {% if enable_thumbnail %} true {% else %} false {% endif %},
|
||||
enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
|
||||
enable_repo_history_setting: {% if enable_repo_history_setting %} true {% else %} false {% endif %},
|
||||
max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %},
|
||||
folder_perm_enabled: {% if folder_perm_enabled %} true {% else %} false {% endif %},
|
||||
is_pro: {% if is_pro %} true {% else %} false {% endif %},
|
||||
|
@ -1238,6 +1238,7 @@ def libraries(request):
|
||||
'enable_resumable_fileupload': settings.ENABLE_RESUMABLE_FILEUPLOAD,
|
||||
'enable_thumbnail': settings.ENABLE_THUMBNAIL,
|
||||
'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
|
||||
'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
|
||||
'max_upload_file_size': max_upload_file_size,
|
||||
'folder_perm_enabled': folder_perm_enabled,
|
||||
'is_pro': True if is_pro_version() else False,
|
||||
|
48
static/scripts/app/views/dialogs/history-settings.js
Normal file
48
static/scripts/app/views/dialogs/history-settings.js
Normal file
@ -0,0 +1,48 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var HistorySettingsDialog = Backbone.View.extend({
|
||||
tagName: 'div',
|
||||
id: 'history-settings-dialog',
|
||||
template: _.template($('#history-settings-dialog-tmpl').html()),
|
||||
|
||||
initialize: function(options) {
|
||||
this.repo_name = options.repo_name;
|
||||
this.repo_id = options.repo_id;
|
||||
|
||||
this.render();
|
||||
this.$el.modal();
|
||||
$("#simplemodal-container").css({'height':'auto'});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template({
|
||||
title: gettext("{placeholder} History Settings")
|
||||
.replace('{placeholder}',
|
||||
'<span class="op-target ellipsis ellipsis-op-target" title="'
|
||||
+ Common.HTMLescape(this.repo_name) + '">'
|
||||
+ Common.HTMLescape(this.repo_name) + '</span>'),
|
||||
repo_id: this.repo_id,
|
||||
// TODO: get settings from server
|
||||
full_history_checked: true,
|
||||
no_history_checked: false,
|
||||
partial_history_checked: false,
|
||||
history_limit: 30
|
||||
}));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
events: {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return HistorySettingsDialog;
|
||||
});
|
@ -73,7 +73,7 @@ define([
|
||||
// hide 'hidden-op' popup
|
||||
$(document).click(function(e) {
|
||||
var target = e.target || event.srcElement;
|
||||
var $popup = $('.hidden-op:visible');
|
||||
var $popup = $('.dirent-hidden-op:visible');
|
||||
if ($popup.length > 0 && // There is a visible popup
|
||||
!$('.more-op-icon', $popup.closest('tr')).is(target) &&
|
||||
!$popup.is(target) &&
|
||||
|
@ -144,7 +144,7 @@ define([
|
||||
return false;
|
||||
},
|
||||
|
||||
togglePopup: function () {
|
||||
togglePopup: function() {
|
||||
var icon = this.$('.more-op-icon'),
|
||||
popup = this.$('.hidden-op');
|
||||
|
||||
|
@ -31,6 +31,31 @@ define([
|
||||
this.repos = new RepoCollection();
|
||||
this.listenTo(this.repos, 'add', this.addOne);
|
||||
this.listenTo(this.repos, 'reset', this.reset);
|
||||
|
||||
// hide 'hidden-op' popup
|
||||
$(document).click(function(e) {
|
||||
var target = e.target || event.srcElement;
|
||||
var $popup = $('.repo-hidden-op:visible');
|
||||
if ($popup.length > 0 && // There is a visible repo op popup
|
||||
!$('.more-op-icon', $popup.closest('tr')).is(target) &&
|
||||
!$popup.is(target) &&
|
||||
!$popup.find('*').is(target)) {
|
||||
// when the popup and op-icon is not target
|
||||
// hide the popup and remove the highlight if the current repo
|
||||
// is not the target
|
||||
$popup.addClass('hide');
|
||||
var $tr = $popup.closest('tr');
|
||||
if (!$tr.find('*').is(target)) {
|
||||
$tr.removeClass('hl').find('.op-icon').addClass('vh');
|
||||
$('.my-own-repos-table tr:gt(0)').each(function() {
|
||||
if ($(this).find('*').is(target)) {
|
||||
$(this).addClass('hl').find('.op-icon').removeClass('vh');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
addOne: function(repo, collection, options) {
|
||||
|
@ -3,8 +3,9 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/views/share'
|
||||
], function($, _, Backbone, Common, ShareView) {
|
||||
'app/views/share',
|
||||
'app/views/dialogs/history-settings'
|
||||
], function($, _, Backbone, Common, ShareView, HistorySettingsDialog) {
|
||||
'use strict';
|
||||
|
||||
var RepoView = Backbone.View.extend({
|
||||
@ -12,31 +13,44 @@ define([
|
||||
|
||||
template: _.template($('#repo-tmpl').html()),
|
||||
repoDelConfirmTemplate: _.template($('#repo-del-confirm-template').html()),
|
||||
renameTemplate: _.template($("#repo-rename-form-template").html()),
|
||||
|
||||
events: {
|
||||
'mouseenter': 'highlight',
|
||||
'mouseleave': 'rmHighlight',
|
||||
'click .repo-delete-btn': 'del',
|
||||
'click .repo-share-btn': 'share'
|
||||
'click .repo-share-btn': 'share',
|
||||
'click .js-toggle-popup': 'togglePopup',
|
||||
'click .js-repo-rename': 'rename',
|
||||
'click .js-popup-history-settings': 'popupHistorySettings',
|
||||
'click .js-popup-permission-settings': 'popupPermissionSettings'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.model.toJSON()));
|
||||
var obj = this.model.toJSON();
|
||||
$.extend(obj, {
|
||||
enable_repo_history_setting: app.pageOptions.enable_repo_history_setting
|
||||
});
|
||||
this.$el.html(this.template(obj));
|
||||
return this;
|
||||
},
|
||||
|
||||
// disable 'hover' when 'repo-del-confirm' popup is shown
|
||||
highlight: function() {
|
||||
if ($('#my-own-repos .repo-del-confirm').length == 0) {
|
||||
if ($('#my-own-repos .repo-del-confirm').length == 0
|
||||
&& !$('.hidden-op:visible').length
|
||||
&& !$('#repo-rename-form').length) {
|
||||
this.$el.addClass('hl').find('.op-icon').removeClass('vh');
|
||||
}
|
||||
},
|
||||
|
||||
rmHighlight: function() {
|
||||
if ($('#my-own-repos .repo-del-confirm').length == 0) {
|
||||
if ($('#my-own-repos .repo-del-confirm').length == 0
|
||||
&& !$('.hidden-op:visible').length
|
||||
&& !$('#repo-rename-form').length) {
|
||||
this.$el.removeClass('hl').find('.op-icon').addClass('vh');
|
||||
}
|
||||
},
|
||||
@ -100,6 +114,78 @@ define([
|
||||
'obj_name': this.model.get('name')
|
||||
};
|
||||
new ShareView(options);
|
||||
},
|
||||
|
||||
togglePopup: function() {
|
||||
var icon = this.$('.js-toggle-popup'),
|
||||
popup = this.$('.hidden-op');
|
||||
|
||||
if (popup.hasClass('hide')) { // the popup is not shown
|
||||
popup.css({'left': icon.position().left});
|
||||
if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) {
|
||||
// below the icon
|
||||
popup.css('top', icon.position().top + icon.height() + 3);
|
||||
} else {
|
||||
popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3);
|
||||
}
|
||||
popup.removeClass('hide');
|
||||
} else {
|
||||
popup.addClass('hide');
|
||||
}
|
||||
},
|
||||
|
||||
rename: function() {
|
||||
var repo_name = this.model.get('name');
|
||||
|
||||
var form = $(this.renameTemplate({
|
||||
repo_name: repo_name
|
||||
}));
|
||||
|
||||
|
||||
var $name_span = this.$('.repo-name-span'),
|
||||
$op_td = this.$('.repo-op-td'),
|
||||
$name_td = $name_span.closest('td');
|
||||
$name_td.attr('colspan', 2).css({
|
||||
'width': $name_span.width() + $op_td.outerWidth(),
|
||||
'height': $name_span.height()
|
||||
}).append(form);
|
||||
$op_td.hide();
|
||||
$name_span.hide();
|
||||
|
||||
this.togglePopup();
|
||||
|
||||
var cancelRename = function() {
|
||||
form.remove();
|
||||
$op_td.show();
|
||||
$name_span.show();
|
||||
$name_td.attr('colspan', 1).css({
|
||||
'width': $name_span.width()
|
||||
});
|
||||
return false; // stop bubbling (to 'doc click to hide .hidden-op')
|
||||
};
|
||||
$('.cancel', form).click(cancelRename);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
popupHistorySettings: function() {
|
||||
var options = {
|
||||
'repo_name': this.model.get('name'),
|
||||
'repo_id': this.model.get('id')
|
||||
};
|
||||
this.togglePopup(); // close the popup
|
||||
new HistorySettingsDialog(options);
|
||||
return false;
|
||||
},
|
||||
|
||||
popupPermissionSettings: function() {
|
||||
var options = {
|
||||
'repo_name': this.model.get('name'),
|
||||
'repo_id': this.model.get('id')
|
||||
};
|
||||
this.togglePopup(); // close the popup
|
||||
new HistorySettingsDialog(options);
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user