提交 0a8d7b8e 编写于 作者: R rsercano

email subscribe

上级 56849e10
......@@ -33,3 +33,4 @@ kadira:flow-router
kadira:blaze-layout
arillo:flow-router-helpers
reactive-var@1.0.11
universe:mailchimp-v3-api
......@@ -80,6 +80,7 @@ tracker@1.1.2
twbs:bootstrap@3.3.6
ui@1.0.12
underscore@1.0.10
universe:mailchimp-v3-api@1.0.2
url@1.1.0
webapp@1.3.14
webapp-hashing@1.0.9
......
......@@ -220,10 +220,27 @@
Welcome to Mongoclient world !
</h1>
<small>
You can connect a new database by pressing <strong>Connect</strong> button.
<p>
You can connect a new database by pressing <strong>Connect</strong> button.
</p>
<p>
Subscribe to Mongoclient Newsletter by filling your e-mail address to below input,
and pressing <b>Subscribe</b>
</p>
</small>
<br/>
<div class="row">
<div class="col-lg-offset-4 col-lg-4">
<input id="txtEmailToSubscribe" type="email"
placeholder="E-mail, don't worry we hate spam !"
class="form-control required"/>
</div>
</div>
<br/>
<button id="btnSubscribe" type="button" class="btn btn-primary ladda-button"
data-style="contract">Subscribe
</button>
</div>
</div>
</div>
......
......@@ -14,6 +14,8 @@ require('datatables.net-buttons-bs')(window, $);
require('datatables.net-responsive-bs')(window, $);
require('bootstrap-filestyle');
const toastr = require('toastr');
const Ladda = require('ladda');
/**
* Created by RSercan on 26.12.2015.
*/
......@@ -634,6 +636,23 @@ const initMemoryChart = function (data, text) {
}
};
Template.databaseStats.events({
'click #btnSubscribe'(){
Ladda.create(document.querySelector('#btnSubscribe')).start();
Meteor.call("handleSubscriber", $('#txtEmailToSubscribe').val(), function (err) {
if (err) {
toastr.error("Failed: " + err.message);
}
else {
toastr.success("Thank you for subscription !");
}
Ladda.stopAll();
});
}
});
Template.databaseStats.onRendered(function () {
let settings = this.subscribe('settings');
let connections = this.subscribe('connections');
......
......@@ -7,6 +7,7 @@ import {QueryHistory} from "/lib/imports/collections/query_history";
import {Dumps} from "/lib/imports/collections/dumps";
import {Settings} from "/lib/imports/collections/settings";
import {Connections} from "/lib/imports/collections/connections";
import mailchimpAPI from "meteor/universe:mailchimp-v3-api";
import SchemaAnalyzeResult from "/lib/imports/collections/schema_analyze_result";
import {HTTP} from "meteor/http";
import LOGGER from "../internal/logger";
......@@ -97,6 +98,26 @@ const saveConnectionToDB = function (connection) {
};
Meteor.methods({
handleSubscriber(email){
LOGGER.info('[subscriber]', email);
const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!regex.test(email)) {
LOGGER.error('[subscriber]', 'not valid email: ' + email);
throw new Meteor.Error(400, 'Not a valid email address !');
}
return mailchimpAPI.setApiKey('96b3d560f7ce4cdf78a65383375ee73b-us15').addANewListMember({
list_id: 'ff8b28a54d',
body: {
email_address: email,
status: 'subscribed'
}
}).then(null, function (reason) {
LOGGER.error('[subscribe]', reason.response.statusCode, JSON.parse(reason.response.content).title);
throw new Meteor.Error(reason.response.statusCode, JSON.parse(reason.response.content).title);
});
},
checkMongoclientVersion(){
try {
const response = HTTP.get('https://api.github.com/repos/mongoclient/mongoclient/releases/latest', {headers: {"User-Agent": "Mongoclient"}});
......
......@@ -139,7 +139,7 @@ Meteor.startup(function () {
connectionTimeoutInSeconds: 3,
dbStatsScheduler: 3000,
showDBStats: true,
showLiveChat: false,
showLiveChat: true,
singleTabResultSets: false,
dumpPath: home + "/myDumps/"
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册