Skip to content

Commit 6f5f553

Browse files
committed
Continuacao...
1 parent d7500e5 commit 6f5f553

File tree

14 files changed

+677
-71
lines changed

14 files changed

+677
-71
lines changed

client/src/components/Hello.vue

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,64 @@
11
<template>
22
<div class="hello">
3-
ass
3+
<div class="col s6">
4+
<div class="row">
5+
<div class="col s6">
6+
<div class="card blue white-text">
7+
<div class="card-content">
8+
<span class="card-title">Total e aberturas</span>
9+
<h1>{{totals[0].opens}}</h1>
10+
</div>
11+
</div>
12+
</div>
13+
<div class="col s6">
14+
<div class="card blue white-text">
15+
<div class="card-content">
16+
<span class="card-title">Total de cliques</span>
17+
<h1>{{totals[0].clicks}}</h1>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
22+
</div>
23+
<div class="col s6">
24+
<div class="card">
25+
<div class="card-content">
26+
<span class="card-title">Dados por campanha</span>
27+
<table>
28+
<thead>
29+
<tr>
30+
<th>Campanha</th>
31+
<th>Aberturas</th>
32+
<th>Clicks</th>
33+
</tr>
34+
</thead>
35+
<tbody>
36+
<tr v-for="campaign in campaigns">
37+
<td><a :href="'#/emails/' + campaign._id">{{campaign.title}}</a></td>
38+
<td>{{campaign.opens}}</td>
39+
<td>{{campaign.clicks}}</td>
40+
</tr>
41+
</tbody>
42+
</table>
43+
</div>
44+
</div>
45+
</div>
446
</div>
547
</template>
648

749
<script>
8-
export default {
9-
name: 'hello',
10-
data () {
11-
return {
12-
msg: 'Welcome to Your Vue.js PWA'
50+
export default {
51+
computed: {
52+
campaigns: function () {
53+
return this.$store.state.email.emails
54+
},
55+
totals: function () {
56+
return this.$store.state.email.totals
57+
}
58+
},
59+
mounted () {
60+
this.$store.dispatch('getAll')
61+
this.$store.dispatch('totals')
1362
}
1463
}
15-
}
1664
</script>

client/src/components/email/email-edit.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<label for="campanhaStart">Data de inicio</label>
2929
</div>
3030
<div class="input-filter">
31+
<strong>Disparar para a lista</strong>
3132
<select multiple class="browser-default" v-model="email.lists">
3233
<option v-for="list in lists" :value="list._id">{{list.title}}</option>
3334
</select>
@@ -63,4 +64,4 @@ export default {
6364
this.$store.dispatch('getAllList')
6465
}
6566
}
66-
</script>
67+
</script>

client/src/components/email/email-new.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<label for="campanhaStart">Data de inicio</label>
2626
</div>
2727
<div class="input-filter">
28+
<strong>Disparar para a lista:</strong>
2829
<select multiple class="browser-default" v-model="data.lists">
2930
<option v-for="list in lists" :value="list._id">{{list.title}}</option>
3031
</select>

client/src/components/email/email-view.vue

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<span class="card-title">Detalhes</span>
1414
<table>
1515
<tr>
16-
<th>Titulo</th>
16+
<th>Título</th>
1717
<td>{{ email.title }}</td>
1818
</tr>
1919
<tr>
@@ -26,32 +26,88 @@
2626
</tr>
2727
<tr>
2828
<th>Cliques</th>
29-
<td>{{ email.click }}</td>
29+
<td>{{ email.clicks }}</td>
3030
</tr>
3131
<tr>
3232
<th>Descadastros</th>
3333
<td>{{ email.unsubscribe }}</td>
3434
</tr>
3535
<tr>
36-
<th>Bounces</th>
37-
<td>{{ email.bounce }}</td>
36+
<th>bounces</th>
37+
<td>{{ email.bounces }}</td>
3838
</tr>
3939
</table>
4040
</div>
4141
</div>
4242
</div>
43+
44+
<div class="col s6">
45+
<div class="card grey lighten-4">
46+
<div class="card-content">
47+
<span class="card-title">Campanha enviada</span>
48+
<iframe :src="rendered_mail" style="width: 100%; height: 300px; border: none"></iframe>
49+
</div>
50+
</div>
51+
</div>
52+
53+
<div class="col s12">
54+
<div class="card grey lighten-4">
55+
<div class="card-content">
56+
<span class="card-title">Leads enviados</span>
57+
58+
<table>
59+
<thead>
60+
<tr>
61+
<th>#</th>
62+
<th>email</th>
63+
<th>listas</th>
64+
<th></th>
65+
</tr>
66+
</thead>
67+
<tbody>
68+
<tr v-for="(lead, index) in leads">
69+
<td>{{ index + 1 }}</td>
70+
<td>{{ lead.email }}</td>
71+
<td>
72+
<div class="chip" v-for="chip in lead.lists">{{ chip.title }}</div>
73+
</td>
74+
<td>
75+
<a :href="'#/leads/' + lead._id" class="btn">ver</a>
76+
</td>
77+
</tr>
78+
</tbody>
79+
</table>
80+
</div>
81+
</div>
82+
</div>
4383
</div>
4484
</template>
45-
4685
<script>
4786
export default {
4887
computed: {
4988
email: function () {
5089
return this.$store.state.email.email
90+
},
91+
leads: function () {
92+
return this.$store.state.lead.leads
93+
},
94+
rendered_email: function () {
95+
return process.env.SERVER + '/campaigns/email-render/' + this.email._id
96+
}
97+
},
98+
methods: {
99+
getLeads: function () {
100+
if (this.email.lists) {
101+
let lists = this.email.lists.join(',')
102+
this.$store.dispatch('getAllLeads', lists)
103+
} else {
104+
setTimeout(this.getLeads, 2000)
105+
}
51106
}
52107
},
53108
mounted () {
54109
this.$store.dispatch('getOne', this.$route.params.id)
110+
this.getLeads()
55111
}
56112
}
57113
</script>

client/src/components/lists/lead.vue

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
<template>
22
<div class="row">
33
<div class="col s12">
4-
<h5>{{lead.email}}</h5>
4+
<h5>{{ lead.email }}</h5>
55
</div>
66

77
<div class="col s6">
88
<div class="card">
99
<div class="card-content">
10+
<span class="card-title">Informações coletadas</span>
1011
<table>
1112
<thead>
12-
<tr>
13-
<th>#</th>
14-
<th>campo</th>
15-
<th>valor</th>
16-
<th></th>
17-
</tr>
13+
<tr>
14+
<th>campo</th>
15+
<th>valor</th>
16+
</tr>
1817
</thead>
1918
<tbody>
20-
<tr v-for="data in lead.data">
21-
<td>{{data.label}}</td>
22-
<td>{{data.value}}</td>
23-
<td>
24-
<a :href="'#/lists/' + list._id" class="btn">ver</a>
25-
</td>
26-
</tr>
19+
<tr v-for="data in lead.data">
20+
<td>{{ data.label }}</td>
21+
<td>{{ data.value }}</td>
22+
</tr>
2723
</tbody>
2824
</table>
2925
</div>
@@ -36,25 +32,49 @@
3632
<span class="card-title">Listas ativas</span>
3733
<table>
3834
<thead>
39-
<tr>
40-
<th>#</th>
41-
<th>campo</th>
42-
<th>valor</th>
43-
<th></th>
44-
</tr>
35+
<tr>
36+
<th>titulo</th>
37+
</tr>
4538
</thead>
4639
<tbody>
47-
<tr v-for="(list) in lead.lists">
48-
<td>{{list.label}}</td>
49-
<td>
50-
<a :href="'#/lists/' + list._id" class="btn">ver</a>
51-
</td>
52-
</tr>
40+
<tr v-for="list in lead.lists">
41+
<td>{{ list.title }}</td>
42+
</tr>
5343
</tbody>
5444
</table>
5545
</div>
5646
</div>
5747
</div>
48+
49+
<div class="col s12">
50+
<div class="card">
51+
<div class="card-content">
52+
<span class="card-title">Ações em campanhas</span>
53+
<table>
54+
<thead>
55+
<tr>
56+
<th>#</th>
57+
<th>ação</th>
58+
<th>campanha</th>
59+
<th>data</th>
60+
</tr>
61+
</thead>
62+
<tbody>
63+
<tr v-for="(o, index) in lead.actions">
64+
<td>{{ index + 1 }}</td>
65+
<td>
66+
<span v-if="o.action[0].typeAction === 'open'">abertura</span>
67+
<span v-if="o.action[0].typeAction === 'click'">click em link: <a :href="o.action[0].link" target="_blank">{{ o.action[0].link }}</a></span>
68+
</td>
69+
<td><a :href="'#/emails/view/' + o.campaign._id">{{ o.campaign.title }}</a></td>
70+
<td>{{ o.action[0].date }}</td>
71+
</tr>
72+
</tbody>
73+
</table>
74+
</div>
75+
</div>
76+
</div>
77+
5878
</div>
5979
</template>
6080
<script>

client/src/states/modules/email.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ let qs = require('qs')
33
export default {
44
state: {
55
emails: [],
6+
totals: [],
67
email: {}
78
},
89
mutations: {
910
updateEmails (state, data) {
1011
state.emails = data
1112
},
13+
updateTotals (state, data) {
14+
state.totals = data
15+
},
1216
updateEmail (state, data) {
1317
state.email = data
1418
}
@@ -20,6 +24,12 @@ export default {
2024
return response
2125
})
2226
},
27+
totals (context) {
28+
return window.axios.get('/api/campaigns/totals').then((response) => {
29+
context.commit('updateTotals', response.data)
30+
return response
31+
})
32+
},
2333
getOne (context, id) {
2434
return window.axios.get('/api/campaigns/' + id).then((response) => {
2535
context.commit('updateEmail', response.data.data)

server/bin/send_email.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const connection = require('../src/db/connection');
2-
// const sender = require('../src/email/sender');
2+
const sender = require('../src/email/sender');
33
const campaignModel = require('../src/models/campaign');
44
const leadModel = require('../src/models/lead');
55
const tracker = require('../src/email/tracker');
@@ -15,7 +15,7 @@ async function send() {
1515
let leads = await leadModel.find({ lists: {$in: lists}});
1616

1717
leads.map((lead) => {
18-
console.log('send lead')
18+
console.log('send lead');
1919
let mailBody = tracker(campaigns[i].body, campaigns[i]._id, lead._id);
2020
console.log(lead.email, campaigns[i].title, mailBody);
2121
sender(lead.email, campaigns[i].title, mailBody); //envia o email

0 commit comments

Comments
 (0)