mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-25 06:33:48 +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()),
|
||||
|
Reference in New Issue
Block a user