mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +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) {
|
showDir: function(category, repo_id, path) {
|
||||||
this.$el.show();
|
this.$el.show();
|
||||||
this.$dirent_list.empty();
|
this.$dirent_list.empty();
|
||||||
var loading_tip = this.$('.loading-tip').show(),
|
var loading_tip = this.$('.loading-tip').show();
|
||||||
dir = this.dir;
|
var dir = this.dir;
|
||||||
dir.setPath(category, repo_id, path);
|
dir.setPath(category, repo_id, path);
|
||||||
|
var _this = this;
|
||||||
dir.fetch({
|
dir.fetch({
|
||||||
reset: true,
|
reset: true,
|
||||||
data: {'p': path},
|
data: {'p': path},
|
||||||
@@ -95,8 +96,46 @@ define([
|
|||||||
loading_tip.hide();
|
loading_tip.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () { // todo
|
error: function (collection, response, opts) {
|
||||||
loading_tip.hide();
|
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',
|
tagName: 'tr',
|
||||||
|
|
||||||
template: _.template(direntTemplate),
|
template: _.template(direntTemplate),
|
||||||
shareTemplate: _.template($("#share-popup-template").html()),
|
|
||||||
renameTemplate: _.template($("#rename-form-template").html()),
|
renameTemplate: _.template($("#rename-form-template").html()),
|
||||||
mvcpTemplate: _.template($("#mvcp-form-template").html()),
|
mvcpTemplate: _.template($("#mvcp-form-template").html()),
|
||||||
mvProgressTemplate: _.template($("#mv-progress-popup-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 'set_notices_seen': return siteRoot + 'ajax/set_notices_seen/';
|
||||||
case 'get_unseen_notices_num': return siteRoot + 'ajax/unseen-notices-count/';
|
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 'set_notice_seen_by_id': return siteRoot + 'ajax/set_notice_seen_by_id/';
|
||||||
|
|
||||||
|
case 'repo_set_password': return siteRoot + 'repo/set_password/';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -22,5 +22,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
|
<img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
|
||||||
|
<p class="error hide"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -103,28 +103,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--/script-->
|
<!--/script-->
|
||||||
|
|
||||||
<div id="update-file-dialog" class="hide">
|
<script type="text/template" id="repo-decrypt-form-template">
|
||||||
<h3 class="hd">{% trans "Update %(file_name)s" %}</h3>
|
<form id="repo-decrypt-form" action="">
|
||||||
<form id="update-file-form" enctype="multipart/form-data" method="post" action="">{% csrf_token %}
|
<label>{% trans 'Password:' %}</label><br />
|
||||||
<input type="hidden" name="target_file" />
|
<input type="password" name="password" class="input" />
|
||||||
<div class="fileupload-buttonbar">
|
<p class="tip">{% trans 'The password will be kept in the server for only 1 hour.' %}</p>
|
||||||
<span class="fileinput-button vam">
|
<p class="error hide"></p>
|
||||||
<span>{% trans "Choose a file" %}</span>
|
<button type="submit" class="submit">{% trans "Submit" %}</button>
|
||||||
<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>
|
</form>
|
||||||
</div>
|
|
||||||
<script type="text/template" id="share-popup-template">
|
|
||||||
</script>
|
</script>
|
||||||
|
@@ -203,6 +203,7 @@ app["pageOptions"] = {
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
return groups;
|
return groups;
|
||||||
})(),
|
})(),
|
||||||
|
username: "{{request.user.username}}",
|
||||||
repo_password_min_length: {{ repo_password_min_length }},
|
repo_password_min_length: {{ repo_password_min_length }},
|
||||||
enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %},
|
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 %},
|
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 \
|
if repo.encrypted \
|
||||||
and not seafile_api.is_password_set(repo.id, username):
|
and not seafile_api.is_password_set(repo.id, username):
|
||||||
err_msg = _(u'Library is encrypted.')
|
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)
|
status=403, content_type=content_type)
|
||||||
|
|
||||||
head_commit = get_commit(repo.id, repo.version, repo.head_cmmt_id)
|
head_commit = get_commit(repo.id, repo.version, repo.head_cmmt_id)
|
||||||
|
Reference in New Issue
Block a user