2018-02-19 16:37:09 +02:00
|
|
|
<template>
|
2018-04-19 21:56:58 +03:00
|
|
|
<div class="mk-activity">
|
|
|
|
<mk-widget-container :show-header="design == 0" :naked="design == 2">
|
|
|
|
<template slot="header">%fa:chart-bar%%i18n:@title%</template>
|
|
|
|
<button slot="func" title="%i18n:@toggle%" @click="toggle">%fa:sort%</button>
|
|
|
|
|
|
|
|
<p :class="$style.fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
|
|
|
|
<template v-else>
|
|
|
|
<x-calendar v-show="view == 0" :data="[].concat(activity)"/>
|
|
|
|
<x-chart v-show="view == 1" :data="[].concat(activity)"/>
|
|
|
|
</template>
|
|
|
|
</mk-widget-container>
|
2018-02-19 16:37:09 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-02-20 18:39:51 +02:00
|
|
|
import XCalendar from './activity.calendar.vue';
|
|
|
|
import XChart from './activity.chart.vue';
|
2018-02-19 16:37:09 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
2018-02-20 18:39:51 +02:00
|
|
|
XCalendar,
|
|
|
|
XChart
|
2018-02-19 16:37:09 +02:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
design: {
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
initView: {
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
activity: null,
|
|
|
|
view: this.initView
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
(this as any).api('aggregation/users/activity', {
|
2018-03-29 08:48:47 +03:00
|
|
|
userId: this.user.id,
|
2018-02-19 16:37:09 +02:00
|
|
|
limit: 20 * 7
|
|
|
|
}).then(activity => {
|
|
|
|
this.activity = activity;
|
|
|
|
this.fetching = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
if (this.view == 1) {
|
|
|
|
this.view = 0;
|
|
|
|
this.$emit('viewChanged', this.view);
|
|
|
|
} else {
|
|
|
|
this.view++;
|
|
|
|
this.$emit('viewChanged', this.view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2018-04-19 21:56:58 +03:00
|
|
|
<style lang="stylus" module>
|
|
|
|
.fetching
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
|
|
|
color #aaa
|
2018-02-19 16:37:09 +02:00
|
|
|
|
2018-04-19 21:56:58 +03:00
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
2018-02-19 16:37:09 +02:00
|
|
|
|
|
|
|
</style>
|