FEATURE: add filters on email logs

This commit is contained in:
Régis Hanol
2014-02-15 00:50:08 +01:00
parent 21f757fd72
commit 3f3c9ca7cb
16 changed files with 145 additions and 67 deletions
@@ -8,13 +8,11 @@
**/
Discourse.AdminEmailIndexRoute = Discourse.Route.extend({
setupController: function(controller) {
Discourse.EmailSettings.find().then(function (model) {
controller.set('model', model);
});
model: function() {
return Discourse.EmailSettings.find();
},
renderTemplate: function() {
this.render('admin/templates/email_index', {into: 'adminEmail'});
this.render('admin/templates/email_index', { into: 'adminEmail' });
}
});
@@ -1,17 +0,0 @@
/**
Handles routes related to viewing email logs.
@class AdminEmailLogsRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
model: function() {
return Discourse.EmailLog.findAll();
},
renderTemplate: function() {
this.render('admin/templates/email_logs', {into: 'adminEmail'});
}
});
@@ -0,0 +1,27 @@
/**
Handles routes related to viewing email logs.
@class AdminEmailSentRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
model: function() {
return Discourse.EmailLog.findAll({ status: this.get("status") });
},
setupController: function(controller) {
// resets the filters
controller.set("filter", { status: this.get("status") });
},
renderTemplate: function() {
this.render("admin/templates/email_" + this.get("status"), { into: "adminEmail" });
}
});
Discourse.AdminEmailSentRoute = Discourse.AdminEmailLogsRoute.extend({ status: "sent" });
Discourse.AdminEmailSkippedRoute = Discourse.AdminEmailLogsRoute.extend({ status: "skipped" });
@@ -1,17 +0,0 @@
/**
Handles routes related to viewing email logs of emails that were NOT sent.
@class AdminEmailSkippedRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminEmailSkippedRoute = Discourse.Route.extend({
model: function() {
return Discourse.EmailLog.findAll('skipped');
},
renderTemplate: function() {
this.render('admin/templates/email_skipped', {into: 'adminEmail'});
}
});
@@ -16,7 +16,7 @@ Discourse.Route.buildRoutes(function() {
});
this.resource('adminEmail', { path: '/email'}, function() {
this.route('logs');
this.route('sent');
this.route('skipped');
this.route('previewDigest', { path: '/preview-digest' });
});