1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
<!--
Matomo - free/libre analytics platform
@link https://matomo.org
@license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
-->
<template>
<tr
:class="{'groupedWebsite': website.group, 'website': !website.group, 'group': website.isGroup}"
>
<td
class="multisites-label label"
v-if="!website.isGroup"
>
<a
title="View reports"
class="value truncated-text-line"
:href="dashboardUrl(website)"
>
{{ websiteLabel }}
</a>
<span>
<a
rel="noreferrer noopener"
target="_blank"
:href="website.main_url"
:title="translate('General_GoTo', website.main_url)"
>
<span class="icon icon-outlink" /></a>
</span>
</td>
<td
class="multisites-label label"
v-if="website.isGroup"
>
<span class="value">{{ websiteLabel }}</span>
</td>
<td class="multisites-column">
<span class="value">{{ website.nb_visits }}</span>
</td>
<td class="multisites-column">
<span class="value">{{ website.nb_pageviews }}</span>
</td>
<td
class="multisites-column"
v-if="displayRevenueColumn"
>
<span class="value">{{ website.revenue }}</span>
</td>
<td
class="multisites-evolution"
v-if="period !== 'range'"
:title="website.tooltip"
>
<div
class="visits value"
v-if="!website.isGroup"
>
<span v-show="website[`${evolutionMetric}_trend`] === 1">
<img
class="multisites_icon"
src="plugins/MultiSites/images/arrow_up.png"
alt
/> <span style="color: green;">{{ website[evolutionMetric] }}</span>
</span>
<span v-show="website[`${evolutionMetric}_trend`] === 0">
<img
class="multisites_icon"
src="plugins/MultiSites/images/stop.png"
alt
/> <span>{{ website[evolutionMetric] }}</span>
</span>
<span v-show="website[`${evolutionMetric}_trend`] === -1">
<img
class="multisites_icon"
src="plugins/MultiSites/images/arrow_down.png"
alt
/> <span style="color: red;">{{ website[evolutionMetric] }}</span>
</span>
</div>
</td>
<td
style="width:180px;"
v-if="showSparklines"
>
<div
class="sparkline"
style="width: 100px; margin: auto;"
v-if="!website.isGroup"
>
<a
rel="noreferrer noopener"
target="_blank"
:href="dashboardUrl(website)"
:title="translate('General_GoTo', translate('Dashboard_DashboardOf', websiteLabel))"
>
<img
alt
width="100"
height="25"
:src="sparklineImage(website)"
/>
</a>
</div>
</td>
</tr>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { Matomo, MatomoUrl, Site } from 'CoreHome';
export default defineComponent({
props: {
website: {
type: Object,
required: true,
},
evolutionMetric: {
type: String,
required: true,
},
showSparklines: Boolean,
dateSparkline: String,
displayRevenueColumn: Boolean,
metric: String,
},
methods: {
dashboardUrl(website: Site) {
return `index.php?module=CoreHome&action=index&date=${this.date}&period=${this.period}`
+ `&idSite=${website.idsite}${this.tokenParam}`;
},
sparklineImage(website: Site) {
let { metric } = this;
switch (this.evolutionMetric) {
case 'visits_evolution':
metric = 'nb_visits';
break;
case 'pageviews_evolution':
metric = 'nb_pageviews';
break;
case 'revenue_evolution':
metric = 'revenue';
break;
default:
break;
}
return `index.php?module=MultiSites&action=getEvolutionGraph&period=${this.period}&date=`
+ `${this.dateSparkline}&evolutionBy=${metric}&columns=${metric}&idSite=${website.idsite}`
+ `&idsite=${website.idsite}&viewDataTable=sparkline${this.tokenParam}&colors=`
+ `${encodeURIComponent(JSON.stringify(Matomo.getSparklineColors()))}`;
},
},
computed: {
tokenParam() {
const token_auth = MatomoUrl.urlParsed.value.token_auth as string;
return token_auth ? `&token_auth=${token_auth}` : '';
},
period() {
return Matomo.period;
},
date() {
return MatomoUrl.urlParsed.value.date as string;
},
websiteLabel() {
return Matomo.helper.htmlDecode(this.website.label);
},
},
});
</script>
|