2018-02-19 16:37:09 +02:00
|
|
|
<template>
|
2018-02-21 18:08:49 +02:00
|
|
|
<div class="mk-activity" :data-melt="design == 2">
|
2018-02-19 16:37:09 +02:00
|
|
|
<template v-if="design == 0">
|
|
|
|
<p class="title">%fa:chart-bar%%i18n:desktop.tags.mk-activity-widget.title%</p>
|
|
|
|
<button @click="toggle" title="%i18n:desktop.tags.mk-activity-widget.toggle%">%fa:sort%</button>
|
|
|
|
</template>
|
|
|
|
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
|
|
|
|
<template v-else>
|
2018-02-21 18:08:49 +02:00
|
|
|
<x-calendar v-show="view == 0" :data="[].concat(activity)"/>
|
2018-02-20 18:39:51 +02:00
|
|
|
<x-chart v-show="view == 1" :data="[].concat(activity)"/>
|
2018-02-19 16:37:09 +02:00
|
|
|
</template>
|
|
|
|
</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>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.mk-activity
|
|
|
|
background #fff
|
|
|
|
border solid 1px rgba(0, 0, 0, 0.075)
|
|
|
|
border-radius 6px
|
|
|
|
|
|
|
|
&[data-melt]
|
|
|
|
background transparent !important
|
|
|
|
border none !important
|
|
|
|
|
|
|
|
> .title
|
|
|
|
z-index 1
|
|
|
|
margin 0
|
|
|
|
padding 0 16px
|
|
|
|
line-height 42px
|
|
|
|
font-size 0.9em
|
|
|
|
font-weight bold
|
|
|
|
color #888
|
|
|
|
box-shadow 0 1px rgba(0, 0, 0, 0.07)
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
> button
|
|
|
|
position absolute
|
|
|
|
z-index 2
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
padding 0
|
|
|
|
width 42px
|
|
|
|
font-size 0.9em
|
|
|
|
line-height 42px
|
|
|
|
color #ccc
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
color #aaa
|
|
|
|
|
|
|
|
&:active
|
|
|
|
color #999
|
|
|
|
|
|
|
|
> .fetching
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
|
|
|
color #aaa
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
</style>
|