1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-24 22:22:38 +00:00
seahub/static/scripts/sysadmin-app/views/abuse-reports.js
sniper-py 37b743fe3a Illegal report by react (#3415)
* illegal report

1, add illegal report at shared file page
2, list all illegal reports at admin page

* add ENABLE_SHARE_LINK_REPORT_ILLEGAL setting

* UserRateThrottle -> AnonRateThrottle

* use to_python_boolean

* frontend by React

* remove illegal report dialog in shared dir view

* add migrations dir

* add illegal_reports migrations

* rename illegal to abuse in api

* rename illegal to abuse in test

* rename illegal to abuse in share file view

* rename illegal to abuse in react

* rename illegal to abuse in Backbone

* add enableShareLinkReportAbuse in templates

* add ReportAbuse

* update ReportAbuse

* update ReportAbuse urls

* update ReportAbuse api-js

* sysadmin_react_app.html

* sysadmin.py

* fix

* fix

* fix

* can not abuse own file

* Contact Information is required.

* fix review

* remove repo icon
2019-11-05 17:46:06 +08:00

88 lines
2.5 KiB
JavaScript

define([
'jquery',
'underscore',
'backbone',
'common',
'sysadmin-app/views/abuse-report',
'sysadmin-app/collection/abuse-reports'
], function($, _, Backbone, Common, AbuseReportView, AbuseReportsCollection) {
'use strict';
var AbuseReportsView = Backbone.View.extend({
id: 'admin-abuse-reports',
template: _.template($("#abuse-reports-tmpl").html()),
initialize: function() {
this.abuseReportsCollection = new AbuseReportsCollection();
this.listenTo(this.abuseReportsCollection, 'add', this.addOne);
this.listenTo(this.abuseReportsCollection, 'reset', this.reset);
this.render();
},
render: function() {
this.$el.html(this.template());
this.$table = this.$('table');
this.$tableBody = $('tbody', this.$table);
this.$loadingTip = this.$('.loading-tip');
this.$emptyTip = this.$('.empty-tips');
this.$error = this.$('.error');
},
initPage: function() {
this.$loadingTip.show();
this.$table.hide();
this.$tableBody.empty();
this.$emptyTip.hide();
this.$error.hide();
},
hide: function() {
this.$el.detach();
this.attached = false;
},
show: function() {
if (!this.attached) {
this.attached = true;
$("#right-panel").html(this.$el);
}
this.getContent();
},
getContent: function() {
this.initPage();
var _this = this;
this.abuseReportsCollection.fetch({
cache: false,
reset: true,
error: function(collection, response, opts) {
var err_msg = Common.prepareCollectionFetchErrorMsg(collection, response, opts);
_this.$error.html(err_msg).show();
}
})
},
addOne: function(report) {
var view = new AbuseReportView({model: report});
this.$tableBody.append(view.render().el);
},
reset: function() {
this.initPage();
this.$loadingTip.hide();
if (this.abuseReportsCollection.length > 0) {
this.abuseReportsCollection.each(this.addOne, this);
this.$table.show();
} else {
this.$emptyTip.show();
}
}
});
return AbuseReportsView;
});