FEATURE: add all email logs tab
This commit is contained in:
parent
3f3c9ca7cb
commit
683bf8c0a4
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
This controller supports email logs functionality.
|
||||||
|
|
||||||
|
@class AdminEmailSentController
|
||||||
|
@extends Discourse.Controller
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.AdminEmailSentController = Discourse.Controller.extend({
|
||||||
|
|
||||||
|
filterEmailLogs: Discourse.debounce(function() {
|
||||||
|
var self = this;
|
||||||
|
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
||||||
|
self.set("model", logs);
|
||||||
|
});
|
||||||
|
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.reply_key"),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
This controller supports email logs functionality.
|
||||||
|
|
||||||
|
@class AdminEmailSkippedController
|
||||||
|
@extends Discourse.Controller
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.AdminEmailSkippedController = Discourse.Controller.extend({
|
||||||
|
|
||||||
|
filterEmailLogs: Discourse.debounce(function() {
|
||||||
|
var self = this;
|
||||||
|
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
||||||
|
self.set("model", logs);
|
||||||
|
});
|
||||||
|
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.skipped_reason"),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Discourse.AdminEmailAllController = Discourse.AdminEmailSkippedController.extend({});
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
This controller supports email logs functionality.
|
|
||||||
|
|
||||||
@class AdminEmailSkippedController
|
|
||||||
@extends Discourse.Controller
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.AdminEmailSkippedController = Discourse.Controller.extend({
|
|
||||||
|
|
||||||
filterEmailLogs: Discourse.debounce(function() {
|
|
||||||
var self = this;
|
|
||||||
this.set("loading", true);
|
|
||||||
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
|
||||||
self.set("model", false);
|
|
||||||
self.set("model", logs);
|
|
||||||
});
|
|
||||||
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.reason"),
|
|
||||||
|
|
||||||
});
|
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
This controller supports email logs functionality.
|
|
||||||
|
|
||||||
@class AdminEmailSentController
|
|
||||||
@extends Discourse.Controller
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.AdminEmailSentController = Discourse.Controller.extend({
|
|
||||||
|
|
||||||
filterEmailLogs: Discourse.debounce(function() {
|
|
||||||
var self = this;
|
|
||||||
this.set("loading", true);
|
|
||||||
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
|
||||||
self.set("loading", false);
|
|
||||||
self.set("model", logs);
|
|
||||||
});
|
|
||||||
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.reply_key"),
|
|
||||||
|
|
||||||
});
|
|
|
@ -22,7 +22,7 @@ Discourse.EmailLog.reopenClass({
|
||||||
|
|
||||||
findAll: function(filter) {
|
findAll: function(filter) {
|
||||||
filter = filter || {};
|
filter = filter || {};
|
||||||
var status = filter.status || "sent";
|
var status = filter.status || "all";
|
||||||
filter = _.omit(filter, "status");
|
filter = _.omit(filter, "status");
|
||||||
|
|
||||||
return Discourse.ajax("/admin/email/" + status + ".json", { data: filter }).then(function(logs) {
|
return Discourse.ajax("/admin/email/" + status + ".json", { data: filter }).then(function(logs) {
|
||||||
|
|
|
@ -23,5 +23,6 @@ Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Discourse.AdminEmailAllRoute = Discourse.AdminEmailLogsRoute.extend({ status: "all" });
|
||||||
Discourse.AdminEmailSentRoute = Discourse.AdminEmailLogsRoute.extend({ status: "sent" });
|
Discourse.AdminEmailSentRoute = Discourse.AdminEmailLogsRoute.extend({ status: "sent" });
|
||||||
Discourse.AdminEmailSkippedRoute = Discourse.AdminEmailLogsRoute.extend({ status: "skipped" });
|
Discourse.AdminEmailSkippedRoute = Discourse.AdminEmailLogsRoute.extend({ status: "skipped" });
|
||||||
|
|
|
@ -16,6 +16,7 @@ Discourse.Route.buildRoutes(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resource('adminEmail', { path: '/email'}, function() {
|
this.resource('adminEmail', { path: '/email'}, function() {
|
||||||
|
this.route('all');
|
||||||
this.route('sent');
|
this.route('sent');
|
||||||
this.route('skipped');
|
this.route('skipped');
|
||||||
this.route('previewDigest', { path: '/preview-digest' });
|
this.route('previewDigest', { path: '/preview-digest' });
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<div class='span15'>
|
<div class='span15'>
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li>{{#link-to 'adminEmail.index'}}{{i18n admin.email.settings}}{{/link-to}}</li>
|
<li>{{#link-to 'adminEmail.index'}}{{i18n admin.email.settings}}{{/link-to}}</li>
|
||||||
|
<li>{{#link-to 'adminEmail.all'}}{{i18n admin.email.all}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'adminEmail.sent'}}{{i18n admin.email.sent}}{{/link-to}}</li>
|
<li>{{#link-to 'adminEmail.sent'}}{{i18n admin.email.sent}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'adminEmail.skipped'}}{{i18n admin.email.skipped}}{{/link-to}}</li>
|
<li>{{#link-to 'adminEmail.skipped'}}{{i18n admin.email.skipped}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'adminEmail.previewDigest'}}{{i18n admin.email.preview_digest}}{{/link-to}}</li>
|
<li>{{#link-to 'adminEmail.previewDigest'}}{{i18n admin.email.preview_digest}}{{/link-to}}</li>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<table class='table'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{i18n admin.email.time}}</th>
|
||||||
|
<th>{{i18n admin.email.user}}</th>
|
||||||
|
<th>{{i18n admin.email.to_address}}</th>
|
||||||
|
<th>{{i18n admin.email.email_type}}</th>
|
||||||
|
<th>{{i18n admin.email.skipped_reason}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tr class="filters">
|
||||||
|
<td>{{i18n admin.email.logs.filters.title}}</td>
|
||||||
|
<td>{{textField value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}</td>
|
||||||
|
<td>{{textField value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}</td>
|
||||||
|
<td>{{textField value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}</td>
|
||||||
|
<td>{{textField value=filter.skipped_reason placeholderKey="admin.email.logs.filters.skipped_reason_placeholder"}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{{#each model}}
|
||||||
|
<tr>
|
||||||
|
<td>{{unboundDate created_at}}</td>
|
||||||
|
<td>
|
||||||
|
{{#if user}}
|
||||||
|
{{#link-to 'adminUser' user}}{{avatar user imageSize="tiny"}}{{/link-to}}
|
||||||
|
{{#link-to 'adminUser' user}}{{user.username}}{{/link-to}}
|
||||||
|
{{else}}
|
||||||
|
—
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
<td><a href='mailto:{{unbound to_address}}'>{{to_address}}</a></td>
|
||||||
|
<td>{{email_type}}</td>
|
||||||
|
<td>{{skipped_reason}}</td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
<tr><td colspan="5">{{i18n admin.email.logs.none}}</td></tr>
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
</table>
|
|
@ -17,8 +17,7 @@
|
||||||
<td>{{textField value=filter.reply_key placeholderKey="admin.email.logs.filters.reply_key_placeholder"}}</td>
|
<td>{{textField value=filter.reply_key placeholderKey="admin.email.logs.filters.reply_key_placeholder"}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{{#if model}}
|
{{#each model}}
|
||||||
{{#groupedEach model}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{unboundDate created_at}}</td>
|
<td>{{unboundDate created_at}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -33,9 +32,8 @@
|
||||||
<td>{{email_type}}</td>
|
<td>{{email_type}}</td>
|
||||||
<td>{{reply_key}}</td>
|
<td>{{reply_key}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/groupedEach}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr><td colspan="5">{{i18n admin.email.logs.none}}</td></tr>
|
<tr><td colspan="5">{{i18n admin.email.logs.none}}</td></tr>
|
||||||
{{/if}}
|
{{/each}}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<th>{{i18n admin.email.user}}</th>
|
<th>{{i18n admin.email.user}}</th>
|
||||||
<th>{{i18n admin.email.to_address}}</th>
|
<th>{{i18n admin.email.to_address}}</th>
|
||||||
<th>{{i18n admin.email.email_type}}</th>
|
<th>{{i18n admin.email.email_type}}</th>
|
||||||
<th>{{i18n admin.email.skip_reason}}</th>
|
<th>{{i18n admin.email.skipped_reason}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
|
@ -14,11 +14,10 @@
|
||||||
<td>{{textField value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}</td>
|
<td>{{textField value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}</td>
|
||||||
<td>{{textField value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}</td>
|
<td>{{textField value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}</td>
|
||||||
<td>{{textField value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}</td>
|
<td>{{textField value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}</td>
|
||||||
<td>{{textField value=filter.skipReason placeholderKey="admin.email.logs.filters.skip_reason_placeholder"}}</td>
|
<td>{{textField value=filter.skipped_reason placeholderKey="admin.email.logs.filters.skipped_reason_placeholder"}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{{#if model}}
|
{{#each model}}
|
||||||
{{#groupedEach model}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{unboundDate created_at}}</td>
|
<td>{{unboundDate created_at}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -33,9 +32,8 @@
|
||||||
<td>{{email_type}}</td>
|
<td>{{email_type}}</td>
|
||||||
<td>{{skipped_reason}}</td>
|
<td>{{skipped_reason}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/groupedEach}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr><td colspan="5">{{i18n admin.email.logs.none}}</td></tr>
|
<tr><td colspan="5">{{i18n admin.email.logs.none}}</td></tr>
|
||||||
{{/if}}
|
{{/each}}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -13,6 +13,11 @@ class Admin::EmailController < Admin::AdminController
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def all
|
||||||
|
email_logs = filter_email_logs(EmailLog.all, params)
|
||||||
|
render_serialized(email_logs, EmailLogSerializer)
|
||||||
|
end
|
||||||
|
|
||||||
def sent
|
def sent
|
||||||
email_logs = filter_email_logs(EmailLog.sent, params)
|
email_logs = filter_email_logs(EmailLog.sent, params)
|
||||||
render_serialized(email_logs, EmailLogSerializer)
|
render_serialized(email_logs, EmailLogSerializer)
|
||||||
|
@ -37,7 +42,7 @@ class Admin::EmailController < Admin::AdminController
|
||||||
email_logs = email_logs.where("email_logs.to_address LIKE ?", "%#{params[:address]}%") if params[:address].present?
|
email_logs = email_logs.where("email_logs.to_address LIKE ?", "%#{params[:address]}%") if params[:address].present?
|
||||||
email_logs = email_logs.where("email_logs.email_type LIKE ?", "%#{params[:type]}%") if params[:type].present?
|
email_logs = email_logs.where("email_logs.email_type LIKE ?", "%#{params[:type]}%") if params[:type].present?
|
||||||
email_logs = email_logs.where("email_logs.reply_key LIKE ?", "%#{params[:reply_key]}%") if params[:reply_key].present?
|
email_logs = email_logs.where("email_logs.reply_key LIKE ?", "%#{params[:reply_key]}%") if params[:reply_key].present?
|
||||||
email_logs = email_logs.where("email_logs.skipped_reason LIKE ?", "%#{params[:reason]}%") if params[:reason].present?
|
email_logs = email_logs.where("email_logs.skipped_reason LIKE ?", "%#{params[:skipped_reason]}%") if params[:skipped_reason].present?
|
||||||
email_logs.to_a
|
email_logs.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1382,6 +1382,7 @@ en:
|
||||||
email:
|
email:
|
||||||
title: "Email"
|
title: "Email"
|
||||||
settings: "Settings"
|
settings: "Settings"
|
||||||
|
all: "All"
|
||||||
sent: "Sent"
|
sent: "Sent"
|
||||||
skipped: "Skipped"
|
skipped: "Skipped"
|
||||||
sent_at: "Sent At"
|
sent_at: "Sent At"
|
||||||
|
@ -1401,7 +1402,7 @@ en:
|
||||||
text: "text"
|
text: "text"
|
||||||
last_seen_user: "Last Seen User:"
|
last_seen_user: "Last Seen User:"
|
||||||
reply_key: "Reply Key"
|
reply_key: "Reply Key"
|
||||||
skip_reason: "Skip Reason"
|
skipped_reason: "Skip Reason"
|
||||||
logs:
|
logs:
|
||||||
none: "No logs found."
|
none: "No logs found."
|
||||||
filters:
|
filters:
|
||||||
|
@ -1410,7 +1411,7 @@ en:
|
||||||
address_placeholder: "em@il.com"
|
address_placeholder: "em@il.com"
|
||||||
type_placeholder: "digest, signup..."
|
type_placeholder: "digest, signup..."
|
||||||
reply_key_placeholder: ""
|
reply_key_placeholder: ""
|
||||||
skip_reason_placeholder: "reason"
|
skipped_reason_placeholder: "reason"
|
||||||
|
|
||||||
logs:
|
logs:
|
||||||
title: "Logs"
|
title: "Logs"
|
||||||
|
|
|
@ -67,6 +67,7 @@ Discourse::Application.routes.draw do
|
||||||
resources :email do
|
resources :email do
|
||||||
collection do
|
collection do
|
||||||
post "test"
|
post "test"
|
||||||
|
get "all"
|
||||||
get "sent"
|
get "sent"
|
||||||
get "skipped"
|
get "skipped"
|
||||||
get "preview-digest" => "email#preview_digest"
|
get "preview-digest" => "email#preview_digest"
|
||||||
|
|
Loading…
Reference in New Issue