Skip to content

Commit 8fc6cdf

Browse files
committed
Add widgets on dashboard
1 parent 8f46b99 commit 8fc6cdf

File tree

12 files changed

+178
-19
lines changed

12 files changed

+178
-19
lines changed

dist/build.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

memo.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ sudo service apahce2 restart
1111

1212

1313
3.
14-
mkdir ~/.npm-global && npm config set prefix '~/.npm-global' && export PATH=~/.npm-global/bin:$PATH && source ~/.profile
14+
mkdir ~/.npm-global
15+
npm config set prefix '~/.npm-global' && export PATH=~/.npm-global/bin:$PATH && source ~/.profile
1516

1617

1718
4.

src/js/components/widget-highcharts-1.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
const api = 'src/js/fakeapi/widget-highcharts-1.json'
2727
2828
export default {
29-
name: 'widget-highcharts',
29+
name: 'widget-highcharts-1',
3030
data() {
3131
return {
3232
loading:true,

src/js/components/widget-highcharts-2.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
const api = 'src/js/fakeapi/widget-highcharts-2.json'
2727
2828
export default {
29-
name: 'widget-highcharts',
29+
name: 'widget-highcharts-2',
3030
data() {
3131
return {
3232
loading:true,

src/js/components/widget-highcharts-3.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
const api = 'src/js/fakeapi/widget-highcharts-3.json'
2727
2828
export default {
29-
name: 'widget-highcharts',
29+
name: 'widget-highcharts-3',
3030
data() {
3131
return {
3232
loading:true,
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<template>
2+
3+
<div class="wrap-widget">
4+
<div class="cc-loader" v-if="loading">
5+
<div class="spinner"></div>
6+
</div>
7+
8+
<div v-else>
9+
<div v-if="!fetchError" class="widget-lastusers">
10+
11+
<div class="columns">
12+
13+
<div v-for="(user, index) in users" class="user-item">
14+
15+
<router-link :to="{name:'user-profile', params:{id: user.id.value}}">
16+
<img :src="user.picture.medium" :alt="user.name.first" />
17+
18+
<p class="user-name">
19+
{{user.name.first|capitalize}} {{user.name.last|upper}}
20+
</p>
21+
<p class="user-date">
22+
{{user.registered | fromnow('fr')}}
23+
</p>
24+
</router-link>
25+
</div>
26+
</div>
27+
28+
</div>
29+
30+
<div v-else class="alert alert-error">
31+
{{fetchError}}
32+
</div>
33+
</div>
34+
</div>
35+
</template>
36+
37+
<script>
38+
import Vue from 'vue'
39+
40+
// Set const api url to get admins
41+
const api = 'https://randomuser.me/api/?results=5&nat=fr'
42+
43+
export default {
44+
// Name of the component
45+
name: 'widget-lastusers',
46+
47+
// Datas : model
48+
data () {
49+
return {
50+
// ============
51+
// General datas
52+
// ============
53+
// Is the page loading ?
54+
loading:true,
55+
56+
// If fetchData() returns an error, will be filled with error detail
57+
fetchError : '',
58+
59+
60+
// ============
61+
// last users datas
62+
// ============
63+
// Tab contains all last users
64+
users: []
65+
}
66+
},
67+
68+
// When view is created, launch ajax fetchData
69+
created () {
70+
this.fetchData()
71+
},
72+
73+
// Methods
74+
methods: {
75+
76+
// Ajax to get admins
77+
fetchData () {
78+
79+
// Reset error msg
80+
this.fetchError = ''
81+
82+
// It's loading dude :)
83+
this.loading = true
84+
85+
86+
// AJAX FIRE!
87+
Vue.axios.get(api, {
88+
89+
// params
90+
91+
}).then(response => {
92+
93+
if(response.data.error) {
94+
95+
this.showError('data.error : API return an error value')
96+
97+
} else {
98+
99+
// Loading is finished :)
100+
this.loading = false
101+
102+
// Contains 5 last users, sort by date asc
103+
this.users = _.reverse(_.sortBy(response.data.results, 'registered'))
104+
}
105+
106+
}).catch(error => {
107+
108+
// Set the error msg
109+
this.showError('API url not found')
110+
111+
})
112+
},
113+
114+
// Show Error message if fetching data return an error
115+
showError(msg) {
116+
this.fetchError = msg
117+
this.loading = false
118+
this.users = []
119+
}
120+
}
121+
}
122+
123+
</script>

src/js/fakeapi/widget-highcharts-1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"error": false,
33
"title": {
4-
"text": "Monthly Average Temperature",
4+
"text": "",
55
"x": -20
66
},
77
"subtitle": {

src/js/fakeapi/widget-highcharts-2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "pie"
88
},
99
"title": {
10-
"text": "Browser market shares January, 2015 to May, 2015"
10+
"text": ""
1111
},
1212
"tooltip": {
1313
"pointFormat": "{series.name}: <b>{point.percentage:.1f}%</b>"

src/js/fakeapi/widget-highcharts-3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "column"
55
},
66
"title": {
7-
"text": "Users Vs Admins"
7+
"text": ""
88
},
99
"xAxis": {
1010
"categories": [

0 commit comments

Comments
 (0)