Skip to content

Commit

Permalink
make dashboard page interactive (epicmaxco#654)
Browse files Browse the repository at this point in the history
* feat: print dashboard pipe chart, show in more detail line chart

* feat: dashboard contributors list

* feat: dashboard detailed table

* feat: dashboard library

* feat: dashboard billing address to the map

* fix: fixes

* fix: minor
  • Loading branch information
nastassiadanilova authored and asvae committed Dec 3, 2019
1 parent eff39e6 commit bef8fa7
Show file tree
Hide file tree
Showing 26 changed files with 644 additions and 324 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
presets: [[
'@vue/app',
{
'useBuiltIns': 'entry',
useBuiltIns: 'entry',
},
]],
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"@types/jest": "^24.0.11",
"amcharts3": "^3.21.14",
"ammap3": "^3.21.14",
"approximate-number": "^2.0.0",
"asva-executors": "^0.1.22",
"axios": "^0.19.0",
"babel-polyfill": "^6.26.0",
"chart.js": "^2.9.3",
"core-js": "3",
"detect-browser": "^4.8.0",
Expand All @@ -30,6 +34,10 @@
"lodash": "4.17.15",
"medium-editor": "^5.23.3",
"normalize.css": "^8.0.1",
"vee-validate": "^2.2.13",
"vue-chartjs": "^3.4.0",
"vue-color": "^2.7.0",
"vue-epic-bus": "^0.1.2",
"popper.js": "^1.16.0",
"regenerator-runtime": "^0.13.3",
"register-service-worker": "^1.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
<script>
import { colorArray } from '../../../../../services/vuestic-ui/components'
let themeCache = {}
const themeCache = {}
export default {
data () {
let proxyHandler = {
const proxyHandler = {
set: function (target, property, value) {
if (!themeCache[property] && typeof target[property] === 'string') themeCache[property] = target[property]
target[property] = value
Expand All @@ -95,7 +95,7 @@ export default {
},
methods: {
restoreDefaultTheme () {
for (let i in themeCache) {
for (const i in themeCache) {
this.$themes[i] = themeCache[i]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<va-icon slot="anchor" :name="['flag-icon flag-icon-large', flagIconClass(currentLanguage())]"/>
<div class="language-dropdown__content pl-4 pr-4 pt-2 pb-2">
<div class="language-dropdown__item row align--center pt-1 pb-1 mt-2 mb-2"
v-for="(option, id) in options"
:key="id"
:class="{ active: option.code === currentLanguage() }"
@click="setLanguage(option.code)"
v-for="(option, id) in options"
:key="id"
:class="{ active: option.code === currentLanguage() }"
@click="setLanguage(option.code)"
>
<va-icon :name="['flag-icon flag-icon-small', flagIconClass(option.code)]"/>
<span class="dropdown-item__text">
{{ $t(`language.${option.name}`) }}
</span>
{{ $t(`language.${option.name}`) }}
</span>
</div>
</div>
</va-dropdown>
Expand Down
44 changes: 22 additions & 22 deletions src/components/auth/AuthLayout.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<template>
<div class="auth-layout row align-content--center">
<div class="flex xs12 pa-3 flex-center">
<router-link class="py-5 flex-center" to="/">
<va-icon-vuestic />
</router-link>
</div>
<div class="auth-layout row align-content--center">
<div class="flex xs12 pa-3 flex-center">
<router-link class="py-5 flex-center" to="/">
<va-icon-vuestic />
</router-link>
</div>

<div class="flex xs12 pa-3">
<div class="d-flex justify--center">
<va-card class="auth-layout__card">
<va-tabs
v-model="tabIndex"
center
>
<va-tab>{{ $t('auth.login') }}</va-tab>
<va-tab>{{ $t('auth.createNewAccount') }}</va-tab>
</va-tabs>
<div class="flex xs12 pa-3">
<div class="d-flex justify--center">
<va-card class="auth-layout__card">
<va-tabs
v-model="tabIndex"
center
>
<va-tab>{{ $t('auth.login') }}</va-tab>
<va-tab>{{ $t('auth.createNewAccount') }}</va-tab>
</va-tabs>

<va-separator/>
<va-separator/>

<div class="pa-3">
<router-view/>
</div>
</va-card>
<div class="pa-3">
<router-view/>
</div>
</va-card>
</div>
</div>
</div>
</div>
</template>

<script>
Expand Down
18 changes: 4 additions & 14 deletions src/components/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
</div>
<div class="row row-equal">
<div class="flex xs12 lg6">
<dashboard-tabs />
<dashboard-tabs @submit="addAddressToMap"/>
</div>
<div class="flex xs12 lg6">
<dashboard-map />
<dashboard-map ref="dashboardMap"/>
</div>
</div>
</div>
Expand All @@ -34,19 +34,9 @@ export default {
DashboardTabs,
DashboardMap,
},
methods: {
launchEpicmaxToast () {
this.showToast(`Let's work together!`, {
icon: 'fa-star-o',
position: 'top-right',
duration: Infinity,
action: {
text: 'Hire us',
href: 'http://epicmax.co/#/contact',
class: 'vuestic-toasted-link',
},
})
addAddressToMap ({ city, country }) {
this.$refs.dashboardMap.addAddress({ city: city.text, country })
},
},
}
Expand Down
76 changes: 30 additions & 46 deletions src/components/dashboard/DashboardCharts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
slot="actions"
color="danger"
class="mr-0"
@click="deleteSection"
:disabled="lineChartData.labels.length < 2"
>
{{ $t('dashboard.charts.deleteSection') }}
{{ $t('dashboard.charts.showInMoreDetail') }}
</va-button>
<va-chart class="chart" :data="lineChartData" type="line"/>
<va-chart class="chart" ref="lineChart" :data="lineChartData" type="line"/>
</va-card>
</div>

Expand All @@ -21,67 +23,31 @@
flat
slot="actions"
class="mr-0"
@click="printChart"
/>
<va-chart class="chart" :data="donutChartData" type="donut"/>
<va-chart class="chart chart--donut" :data="donutChartData" type="donut"/>
</va-card>
</div>

<div class="flex xs12 md6 xl3">
<va-card :title="$t('dashboard.charts.topContributors')">
<va-button flat small slot="actions" class="mr-0">
{{ $t('dashboard.charts.showAll') }}
</va-button>

<div
class="mb-3"
v-for="(progress, idx) in progressData"
:key="idx"
>
<va-progress-bar
:value="getPercent(progress.value)"
:color="progress.color"
>
{{ progress.value }} {{ $t('dashboard.charts.commits') }}
</va-progress-bar>
<p class="mt-2">{{ progress.text }}</p>
</div>
</va-card>
<dashboard-contributors-chart/>
</div>
</div>
</template>

<script>
import { getDonutChartData } from '../../data/charts/DonutChartData'
import { getLineChartData } from '../../data/charts/LineChartData'
import DashboardContributorsChart from './DashboardContributorsList'
export default {
name: 'dashboard-charts',
components: { DashboardContributorsChart },
data () {
return {
lineChartData: getLineChartData(this.$themes),
donutChartData: getDonutChartData(this.$themes),
progressMax: 328,
progressData: [{
color: 'success',
value: '328',
text: 'Nathaniel Andrews',
}, {
color: 'info',
value: '271',
text: 'Gora Gilbert',
}, {
color: 'warning',
value: '69',
text: 'Landon Hudson',
}, {
color: 'danger',
value: '31',
text: 'Aiden Berry',
}, {
color: 'gray',
value: '28',
text: 'Winnie Holloway',
}],
lineChartFirstMonthIndex: 0,
}
},
watch: {
Expand All @@ -100,8 +66,26 @@ export default {
},
},
methods: {
getPercent (val) {
return (val / this.progressMax) * 100
deleteSection () {
this.lineChartFirstMonthIndex += 1
this.lineChartData = getLineChartData(this.$themes, this.lineChartFirstMonthIndex)
this.$refs.lineChart.$refs.chart.refresh()
},
printChart () {
let win = window.open('', 'Print', 'height=600,width=800')
win.document.write(`<br><img src='${this.donutChartDataURL}'/>`)
// TODO: find better solution how to remove timeout
setTimeout(() => {
win.document.close()
win.focus()
win.print()
win.close()
}, 200)
},
},
computed: {
donutChartDataURL () {
return document.querySelector('.chart--donut canvas').toDataURL('image/png')
},
},
}
Expand Down
81 changes: 81 additions & 0 deletions src/components/dashboard/DashboardContributorsList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<va-card
:title="$t('dashboard.charts.topContributors')"
class="d-flex dashboard-contributors-list"
>
<va-button
flat small
slot="actions"
class="mr-0"
:disabled="contributors.length <= step"
@click="showNext"
>
{{ $t('dashboard.charts.showNextFive') }}
</va-button>
<va-inner-loading :loading="loading">
<div
class="mb-3"
v-for="(contributor, idx) in visibleList"
:key="idx"
>
<va-progress-bar
:value="getPercent(contributor.contributions)"
:color="getRandomColor()"
>
{{ contributor.contributions }} {{ $t('dashboard.charts.commits') }}
</va-progress-bar>
<p class="mt-2">{{ contributor.login }}</p>
</div>
</va-inner-loading>
</va-card>
</template>

<script>
import axios from 'axios'
export default {
name: 'DashboardContributorsList',
data () {
return {
contributors: [],
loading: false,
progressMax: 392,
visibleList: [],
step: 5,
}
},
mounted () {
this.loadContributorsList()
},
methods: {
async loadContributorsList () {
this.loading = true
const { data } = await axios.get('https://api.github.com/repos/epicmaxco/vuestic-admin/contributors')
this.contributors = data
this.progressMax = Math.max(...this.contributors.map(({ contributions }) => contributions))
this.showNext()
this.loading = false
},
getPercent (val) {
return (val / this.progressMax) * 100
},
showNext () {
this.visibleList = this.contributors.splice(0, this.step)
},
getRandomColor () {
const keys = Object.keys(this.$themes)
return this.$themes[keys[keys.length * Math.random() << 0]]
},
},
}
</script>

<style scoped lang="scss">
.dashboard-contributors-list {
flex-direction: column;
.inner-loading {
height: 100%;
}
}
</style>
Loading

0 comments on commit bef8fa7

Please sign in to comment.