forked from misterGF/CoPilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboard.vue
More file actions
238 lines (228 loc) · 7.17 KB
/
Copy pathDashboard.vue
File metadata and controls
238 lines (228 loc) · 7.17 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
<!-- Main content -->
<section class="content">
<!-- GitHub hint -->
<div class="row">
<div class="col-xs-12">
<alert :dismissible="true"
type="success"
:iconClasses="['fa', 'fa-check']"
title="CoPilot is open source!">
<span>Click on icon to check it out on github.</span>
<a href="https://github.com/misterGF/CoPilot" target="_blank">
<i class="fa fa-github fa-2x"></i>
</a>
</alert>
</div>
<!-- Info boxes -->
<div class="col-md-3 col-sm-6 col-xs-12">
<info-box color-class="bg-aqua"
:icon-classes="['ion', 'ion-ios-gear-outline']"
text="CPU Traffic"
number="90%"></info-box>
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<info-box color-class="bg-red"
:icon-classes="['fa', 'fa-google-plus']"
text="Likes"
number="41,410"></info-box>
</div>
<!-- /.col -->
<!-- fix for small devices only -->
<div class="clearfix visible-sm-block"></div>
<div class="col-md-3 col-sm-6 col-xs-12">
<info-box color-class="bg-green"
:icon-classes="['ion', 'ion-ios-cart-outline']"
text="Sales"
number="760"></info-box>
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<info-box color-class="bg-yellow"
:icon-classes="['ion', 'ion-ios-people-outline']"
text="New Members"
number="2,000"></info-box>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"></h3>
<div class="box-body">
<div class="col-sm-6 col-xs-12">
<p class="text-center">
<strong>Web Traffic Overview</strong>
</p>
<canvas id="trafficBar" ></canvas>
</div>
<hr class="visible-xs-block">
<div class="col-sm-6 col-xs-12">
<p class="text-center">
<strong>Language Overview</strong>
</p>
<canvas id="languagePie"></canvas>
</div>
</div>
</div>
<div class="text-center">
<small><b>Pro Tip</b> Don't forget to star us on github!</small>
</div>
</div>
</div>
<!-- /.row -->
<!-- Main row -->
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
<process-info-box color-class="bg-yellow"
:icon-classes="['ion', 'ion-ios-pricetag-outline']"
text="Inventory"
number="5,200"
:progress="50"
description="50% increase since May"></process-info-box>
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<process-info-box color-class="bg-green"
:icon-classes="['ion', 'ion-ios-heart-outline']"
text="Mentions"
number="92,050"
:progress="20"
description="20% increase in 30 days"></process-info-box>
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<process-info-box color-class="bg-red"
:icon-classes="['ion', 'ion-ios-cloud-download-outline']"
text="Downloads"
number="114,381"
:progress="70"
description="70% increase since yesterday"></process-info-box>
</div>
<!-- /.col -->
<div class="col-md-3 col-sm-6 col-xs-12">
<process-info-box color-class="bg-aqua"
:icon-classes="['ion', 'ion-ios-chatbubble-outline']"
text="Direct Messages"
number="163,921"
:progress="40"
description="40% increase compared to last year"></process-info-box>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</template>
<script>
import Chart from 'chart.js'
import Alert from '../widgets/Alert'
import InfoBox from '../widgets/InfoBox'
import ProcessInfoBox from '../widgets/ProcessInfoBox'
export default {
name: 'Dashboard',
components: {
Alert,
InfoBox,
ProcessInfoBox
},
data () {
return {
generateRandomNumbers (numbers, max, min) {
var a = []
for (var i = 0; i < numbers; i++) {
a.push(Math.floor(Math.random() * (max - min + 1)) + max)
}
return a
}
}
},
computed: {
coPilotNumbers () {
return this.generateRandomNumbers(12, 1000000, 10000)
},
personalNumbers () {
return this.generateRandomNumbers(12, 1000000, 10000)
},
isMobile () {
return (window.innerWidth <= 800 && window.innerHeight <= 600)
}
},
mounted () {
this.$nextTick(() => {
var ctx = document.getElementById('trafficBar').getContext('2d')
var config = {
type: 'line',
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
label: 'CoPilot',
fill: false,
borderColor: '#284184',
pointBackgroundColor: '#284184',
backgroundColor: 'rgba(0, 0, 0, 0)',
data: this.coPilotNumbers
}, {
label: 'Personal Site',
borderColor: '#4BC0C0',
pointBackgroundColor: '#4BC0C0',
backgroundColor: 'rgba(0, 0, 0, 0)',
data: this.personalNumbers
}]
},
options: {
responsive: true,
maintainAspectRatio: !this.isMobile,
legend: {
position: 'bottom',
display: true
},
tooltips: {
mode: 'label',
xPadding: 10,
yPadding: 10,
bodySpacing: 10
}
}
}
new Chart(ctx, config) // eslint-disable-line no-new
var pieChartCanvas = document.getElementById('languagePie').getContext('2d')
var pieConfig = {
type: 'pie',
data: {
labels: ['HTML', 'JavaScript', 'CSS'],
datasets: [{
data: [56.6, 37.7, 4.1],
backgroundColor: ['#00a65a', '#f39c12', '#00c0ef'],
hoverBackgroundColor: ['#00a65a', '#f39c12', '#00c0ef']
}]
},
options: {
responsive: true,
maintainAspectRatio: !this.isMobile,
legend: {
position: 'bottom',
display: true
}
}
}
new Chart(pieChartCanvas, pieConfig) // eslint-disable-line no-new
})
}
}
</script>
<style>
.info-box {
cursor: pointer;
}
.info-box-content {
text-align: center;
vertical-align: middle;
display: inherit;
}
.fullCanvas {
width: 100%;
}
</style>