mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
[lib view] show error msg, added decryption for enc-lib, cleaned up some code
This commit is contained in:
@@ -82,9 +82,10 @@ define([
|
||||
showDir: function(category, repo_id, path) {
|
||||
this.$el.show();
|
||||
this.$dirent_list.empty();
|
||||
var loading_tip = this.$('.loading-tip').show(),
|
||||
dir = this.dir;
|
||||
var loading_tip = this.$('.loading-tip').show();
|
||||
var dir = this.dir;
|
||||
dir.setPath(category, repo_id, path);
|
||||
var _this = this;
|
||||
dir.fetch({
|
||||
reset: true,
|
||||
data: {'p': path},
|
||||
@@ -95,8 +96,46 @@ define([
|
||||
loading_tip.hide();
|
||||
}
|
||||
},
|
||||
error: function () { // todo
|
||||
error: function (collection, response, opts) {
|
||||
loading_tip.hide();
|
||||
var $el_con = _this.$('.repo-file-list-topbar, .repo-file-list').hide();
|
||||
var $error = _this.$('.error');
|
||||
var err_msg;
|
||||
if (response.responseText) {
|
||||
err_msg = response.responseJSON.error;
|
||||
} else {
|
||||
err_msg = gettext('Please check the network.');
|
||||
}
|
||||
$error.html(err_msg).show();
|
||||
|
||||
if (response.responseJSON.lib_need_decrypt) {
|
||||
var form = $($('#repo-decrypt-form-template').html());
|
||||
_this.$el.append(form);
|
||||
form.submit(function() {
|
||||
var passwd = $.trim($('[name="password"]', form).val());
|
||||
if (!passwd) {
|
||||
$('.error', form).html(gettext("Password is required.")).removeClass('hide');
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
post_url: Common.getUrl({'name':'repo_set_password'}),
|
||||
post_data: {
|
||||
repo_id: repo_id,
|
||||
password: passwd,
|
||||
username: app.pageOptions.username
|
||||
},
|
||||
after_op_success: function() {
|
||||
form.remove();
|
||||
$error.html('').hide();
|
||||
$el_con.show();
|
||||
_this.showDir(category, repo_id, path);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@@ -16,7 +16,6 @@ define([
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template(direntTemplate),
|
||||
shareTemplate: _.template($("#share-popup-template").html()),
|
||||
renameTemplate: _.template($("#rename-form-template").html()),
|
||||
mvcpTemplate: _.template($("#mvcp-form-template").html()),
|
||||
mvProgressTemplate: _.template($("#mv-progress-popup-template").html()),
|
||||
|
@@ -99,6 +99,8 @@ define([
|
||||
case 'set_notices_seen': return siteRoot + 'ajax/set_notices_seen/';
|
||||
case 'get_unseen_notices_num': return siteRoot + 'ajax/unseen-notices-count/';
|
||||
case 'set_notice_seen_by_id': return siteRoot + 'ajax/set_notice_seen_by_id/';
|
||||
|
||||
case 'repo_set_password': return siteRoot + 'repo/set_password/';
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -1,26 +1,26 @@
|
||||
{% load i18n %}
|
||||
<div id="dir-view" class="hide">
|
||||
<div class="repo-file-list-topbar">
|
||||
<p class="path"></p>
|
||||
<div class="repo-op"></div>
|
||||
</div>
|
||||
<table class="repo-file-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="select">
|
||||
<span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
|
||||
</th>
|
||||
<th class="star"></th>
|
||||
<th class="dirent-icon"></th>
|
||||
<th><span class="dirent-name">{% trans "Name"%} <span id="by-name" class="icon-caret-up cspt"></span></span></th>
|
||||
<th class="dirent-op"></th>
|
||||
<th class="dirent-size">{% trans "Size"%}</th>
|
||||
<th class="dirent-update">{% trans "Last Update" %} <span id="by-time" class="icon-caret-down cspt"></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
|
||||
<div class="repo-file-list-topbar">
|
||||
<p class="path"></p>
|
||||
<div class="repo-op"></div>
|
||||
</div>
|
||||
<table class="repo-file-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="select">
|
||||
<span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
|
||||
</th>
|
||||
<th class="star"></th>
|
||||
<th class="dirent-icon"></th>
|
||||
<th><span class="dirent-name">{% trans "Name"%} <span id="by-name" class="icon-caret-up cspt"></span></span></th>
|
||||
<th class="dirent-op"></th>
|
||||
<th class="dirent-size">{% trans "Size"%}</th>
|
||||
<th class="dirent-update">{% trans "Last Update" %} <span id="by-time" class="icon-caret-down cspt"></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
|
||||
<p class="error hide"></p>
|
||||
</div>
|
||||
|
||||
|
@@ -103,28 +103,12 @@
|
||||
</div>
|
||||
<!--/script-->
|
||||
|
||||
<div id="update-file-dialog" class="hide">
|
||||
<h3 class="hd">{% trans "Update %(file_name)s" %}</h3>
|
||||
<form id="update-file-form" enctype="multipart/form-data" method="post" action="">{% csrf_token %}
|
||||
<input type="hidden" name="target_file" />
|
||||
<div class="fileupload-buttonbar">
|
||||
<span class="fileinput-button vam">
|
||||
<span>{% trans "Choose a file" %}</span>
|
||||
<input type="file" name="file" />
|
||||
</span>
|
||||
{% if max_upload_file_size %}
|
||||
<span class="vam">({% blocktrans with max_file_size=max_upload_file_size|filesizeformat %}Smaller than {{ max_file_size }}{% endblocktrans %})</span>
|
||||
{% endif %}
|
||||
<div class="fileupload-progress fade">
|
||||
<div class="progress progress-success progres-striped active">
|
||||
<div class="bar" style="width:0%"></div>
|
||||
</div>
|
||||
<div class="progress-extended"></div>
|
||||
</div>
|
||||
<p class="saving-tip alc hide"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" style="margin-right:5px;" class="vam" />{% trans "Saving..." %}</p>
|
||||
</div>
|
||||
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/template" id="share-popup-template">
|
||||
<script type="text/template" id="repo-decrypt-form-template">
|
||||
<form id="repo-decrypt-form" action="">
|
||||
<label>{% trans 'Password:' %}</label><br />
|
||||
<input type="password" name="password" class="input" />
|
||||
<p class="tip">{% trans 'The password will be kept in the server for only 1 hour.' %}</p>
|
||||
<p class="error hide"></p>
|
||||
<button type="submit" class="submit">{% trans "Submit" %}</button>
|
||||
</form>
|
||||
</script>
|
||||
|
@@ -203,6 +203,7 @@ app["pageOptions"] = {
|
||||
{% endfor %}
|
||||
return groups;
|
||||
})(),
|
||||
username: "{{request.user.username}}",
|
||||
repo_password_min_length: {{ repo_password_min_length }},
|
||||
enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %},
|
||||
max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %},
|
||||
|
@@ -424,7 +424,7 @@ def list_lib_dir(request, repo_id):
|
||||
if repo.encrypted \
|
||||
and not seafile_api.is_password_set(repo.id, username):
|
||||
err_msg = _(u'Library is encrypted.')
|
||||
return HttpResponse(json.dumps({'error': err_msg}),
|
||||
return HttpResponse(json.dumps({'error': err_msg, 'lib_need_decrypt': True}),
|
||||
status=403, content_type=content_type)
|
||||
|
||||
head_commit = get_commit(repo.id, repo.version, repo.head_cmmt_id)
|
||||
|
Reference in New Issue
Block a user