mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 08:28:11 +00:00
update
This commit is contained in:
80
static/scripts/sysadmin-app/views/trash-repo.js
Normal file
80
static/scripts/sysadmin-app/views/trash-repo.js
Normal file
@@ -0,0 +1,80 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'app/views/widgets/hl-item-view'
|
||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var TrashRepoView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#trash-library-item-tmpl').html()),
|
||||
|
||||
events: {
|
||||
'click .repo-delete-btn': 'deleteTrashLibrary',
|
||||
'click .repo-restore-btn': 'restoreTrashLibrary',
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
HLItemView.prototype.initialize.call(this);
|
||||
},
|
||||
|
||||
deleteTrashLibrary: function() {
|
||||
var _this = this;
|
||||
$.ajax({
|
||||
url: Common.getUrl({'name':'admin-trash-library', 'repo_id': _this.model.get('id')}),
|
||||
type: 'DELETE',
|
||||
beforeSend: Common.prepareCSRFToken,
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
_this.$el.remove();
|
||||
Common.feedback(gettext("Success"), 'success');
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
Common.ajaxErrorHandler(xhr, textStatus, errorThrown);
|
||||
}
|
||||
})
|
||||
return false;
|
||||
},
|
||||
|
||||
restoreTrashLibrary: function() {
|
||||
var _this = this;
|
||||
$.ajax({
|
||||
url: Common.getUrl({'name':'admin-trash-library', 'repo_id': _this.model.get('id')}),
|
||||
type: 'PUT',
|
||||
beforeSend: Common.prepareCSRFToken,
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
_this.$el.remove();
|
||||
Common.feedback(gettext("Success"), 'success');
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
Common.ajaxErrorHandler(xhr, textStatus, errorThrown);
|
||||
}
|
||||
})
|
||||
return false;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = this.model.toJSON(),
|
||||
icon_size = Common.isHiDPI() ? 96 : 24,
|
||||
icon_url = this.model.getIconUrl(icon_size),
|
||||
delete_time = Moment(data['delete_time']);
|
||||
|
||||
data['icon_url'] = icon_url;
|
||||
data['icon_title'] = this.model.getIconTitle();
|
||||
data['time'] = delete_time.format('LLLL');
|
||||
data['time_from_now'] = Common.getRelativeTimeStr(delete_time);
|
||||
|
||||
this.$el.html(this.template(data));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return TrashRepoView;
|
||||
});
|
Reference in New Issue
Block a user