Screened URLs list in admin

This commit is contained in:
Neil Lalonde
2013-08-15 10:48:30 -04:00
parent def134605d
commit 293361dcd3
16 changed files with 183 additions and 37 deletions
@@ -0,0 +1,21 @@
/**
This controller supports the interface for listing screened URLs in the admin section.
@class AdminLogsScreenedUrlsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
Discourse.AdminLogsScreenedUrlsController = Ember.ArrayController.extend(Discourse.Presence, {
loading: false,
content: [],
show: function() {
var self = this;
this.set('loading', true);
Discourse.ScreenedUrl.findAll().then(function(result) {
self.set('content', result);
self.set('loading', false);
});
}
});
@@ -9,7 +9,7 @@
**/
Discourse.ScreenedEmail = Discourse.Model.extend({
actionName: function() {
return I18n.t("admin.logs.screened_emails.actions." + this.get('action'));
return I18n.t("admin.logs.screened_actions." + this.get('action'));
}.property('action')
});
@@ -0,0 +1,23 @@
/**
Represents a URL that is watched for, and an action may be taken.
@class ScreenedUrl
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
Discourse.ScreenedUrl = Discourse.Model.extend({
actionName: function() {
return I18n.t("admin.logs.screened_actions." + this.get('action'));
}.property('action')
});
Discourse.ScreenedUrl.reopenClass({
findAll: function(filter) {
return Discourse.ajax("/admin/logs/screened_urls.json").then(function(screened_urls) {
return screened_urls.map(function(b) {
return Discourse.ScreenedUrl.create(b);
});
});
}
});
@@ -12,24 +12,6 @@ Discourse.AdminLogsIndexRoute = Discourse.Route.extend({
}
});
/**
The route that lists blocked email addresses.
@class AdminLogsScreenedEmailsRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminLogsScreenedEmailsRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('admin/templates/logs/screened_emails', {into: 'adminLogs'});
},
setupController: function() {
return this.controllerFor('adminLogsScreenedEmails').show();
}
});
/**
The route that lists staff actions that were logged.
@@ -57,4 +39,40 @@ Discourse.AdminLogsStaffActionLogsRoute = Discourse.Route.extend({
// Clear any filters when we leave the route
Discourse.URL.set('queryParams', null);
}
});
/**
The route that lists blocked email addresses.
@class AdminLogsScreenedEmailsRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminLogsScreenedEmailsRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('admin/templates/logs/screened_emails', {into: 'adminLogs'});
},
setupController: function() {
return this.controllerFor('adminLogsScreenedEmails').show();
}
});
/**
The route that lists screened URLs.
@class AdminLogsScreenedUrlsRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminLogsScreenedUrlsRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('admin/templates/logs/screened_urls', {into: 'adminLogs'});
},
setupController: function() {
return this.controllerFor('adminLogsScreenedUrls').show();
}
});
@@ -30,8 +30,9 @@ Discourse.Route.buildRoutes(function() {
});
this.resource('adminLogs', { path: '/logs' }, function() {
this.route('screenedEmails', { path: '/screened_emails' });
this.route('staffActionLogs', { path: '/staff_action_logs' });
this.route('screenedEmails', { path: '/screened_emails' });
this.route('screenedUrls', { path: '/screened_urls' });
});
this.route('groups', {path: '/groups'});
@@ -3,6 +3,7 @@
<ul class="nav nav-pills">
<li>{{#linkTo 'adminLogs.staffActionLogs'}}{{i18n admin.logs.staff_actions.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminLogs.screenedEmails'}}{{i18n admin.logs.screened_emails.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminLogs.screenedUrls'}}{{i18n admin.logs.screened_urls.title}}{{/linkTo}}</li>
</ul>
</div>
</div>
@@ -5,12 +5,12 @@
{{else}}
{{#if model.length}}
<div class='table blocked-emails'>
<div class='table screened-emails'>
<div class="heading-container">
<div class="col heading first email">{{i18n admin.logs.screened_emails.email}}</div>
<div class="col heading action">{{i18n admin.logs.action}}</div>
<div class="col heading match_count">{{i18n admin.logs.screened_emails.match_count}}</div>
<div class="col heading last_match_at">{{i18n admin.logs.screened_emails.last_match_at}}</div>
<div class="col heading match_count">{{i18n admin.logs.match_count}}</div>
<div class="col heading last_match_at">{{i18n admin.logs.last_match_at}}</div>
<div class="col heading created_at">{{i18n admin.logs.created_at}}</div>
<div class="clearfix"></div>
</div>
@@ -0,0 +1,24 @@
<p>{{i18n admin.logs.screened_urls.description}}</p>
{{#if loading}}
<div class='admin-loading'>{{i18n loading}}</div>
{{else}}
{{#if model.length}}
<div class='table screened-urls'>
<div class="heading-container">
<div class="col heading first url">{{i18n admin.logs.screened_urls.url}}</div>
<div class="col heading action">{{i18n admin.logs.action}}</div>
<div class="col heading match_count">{{i18n admin.logs.match_count}}</div>
<div class="col heading last_match_at">{{i18n admin.logs.last_match_at}}</div>
<div class="col heading created_at">{{i18n admin.logs.created_at}}</div>
<div class="clearfix"></div>
</div>
{{view Discourse.ScreenedUrlsListView contentBinding="controller"}}
</div>
{{else}}
{{i18n search.no_results}}
{{/if}}
{{/if}}
@@ -0,0 +1,6 @@
<div class="col first url">{{url}}</div>
<div class="col action">{{actionName}}</div>
<div class="col match_count">{{match_count}}</div>
<div class="col last_match_at">{{unboundAgeWithTooltip last_match_at}}</div>
<div class="col created_at">{{unboundAgeWithTooltip created_at}}</div>
<div class="clearfix"></div>
@@ -0,0 +1,5 @@
Discourse.ScreenedUrlsListView = Ember.ListView.extend({
height: 700,
rowHeight: 32,
itemViewClass: Ember.ListItemView.extend({templateName: "admin/templates/logs/screened_urls_list_item"})
});