diff --git a/src/components/ActivityEntry.vue b/src/components/ActivityEntry.vue new file mode 100644 index 000000000..fe7f82d7c --- /dev/null +++ b/src/components/ActivityEntry.vue @@ -0,0 +1,77 @@ + + + + + + + {{ getTime(activity.datetime) }} + + + + + + diff --git a/src/components/board/TimelineTabSidebard.vue b/src/components/board/TimelineTabSidebard.vue index ff9cd5526..0b3cae224 100644 --- a/src/components/board/TimelineTabSidebard.vue +++ b/src/components/board/TimelineTabSidebard.vue @@ -1,15 +1,21 @@ - timeline + + + + Load More diff --git a/src/components/card/CardSidebar.vue b/src/components/card/CardSidebar.vue index f6022d406..96e806b81 100644 --- a/src/components/card/CardSidebar.vue +++ b/src/components/card/CardSidebar.vue @@ -77,7 +77,10 @@ - this is the activity tab + + + Load More @@ -88,10 +91,12 @@ import { mapState } from 'vuex' import VueEasymde from 'vue-easymde' import { Actions } from 'nextcloud-vue/dist/Components/Actions' import { ActionButton } from 'nextcloud-vue/dist/Components/ActionButton' +import ActivityEntry from '../ActivityEntry' export default { name: 'CardSidebar', components: { + ActivityEntry, AppSidebar, AppSidebarTab, Multiselect, @@ -122,13 +127,21 @@ export default { toolbar: false }, lastModifiedRelative: null, - lastCreatedRemative: null + lastCreatedRemative: null, + params: { + type: 'filter', + since: 0, + object_type: 'deck_card', + object_id: this.id + } } }, computed: { ...mapState({ currentBoard: state => state.currentBoard, - assignableUsers: state => state.assignableUsers + assignableUsers: state => state.assignableUsers, + cardActivity: 'activity', + activityLoadMore: 'activityLoadMore' }), currentCard() { return this.$store.getters.cardById(this.id) @@ -161,8 +174,16 @@ export default { handler() { this.copiedCard = JSON.parse(JSON.stringify(this.currentCard)) this.allLabels = this.currentCard.labels - this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant) + + if (this.currentCard.assignedUsers.length > 0) { + this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant) + } + + this.desc = this.currentCard.description this.updateRelativeTimestamps() + + this.params.object_id = this.id + this.loadCardActivity() } }, @@ -172,6 +193,7 @@ export default { }, created() { setInterval(this.updateRelativeTimestamps, 10000) + this.loadCardActivity() }, destroyed() { clearInterval(this.updateRelativeTimestamps) @@ -230,6 +252,19 @@ export default { } this.$store.dispatch('removeLabel', data) }, + loadCardActivity() { + this.isLoading = true + this.$store.dispatch('loadActivity', this.params).then(response => { + this.isLoading = false + }) + }, + loadMore() { + let array = Object.values(this.cardActivity) + let aId = (array[array.length - 1].activity_id) + + this.params.since = aId + this.loadCardActivity() + }, clickAddNewAttachmment() { } diff --git a/src/router.js b/src/router.js index 144d1d6f7..e9d7cb60a 100644 --- a/src/router.js +++ b/src/router.js @@ -92,6 +92,11 @@ export default new Router({ return { id: parseInt(route.params.id, 10) } + }, + sidebar: (route) => { + return { + id: parseInt(route.params.id, 10) + } } } }, diff --git a/src/store/main.js b/src/store/main.js index f7e2d4772..93aaba30b 100644 --- a/src/store/main.js +++ b/src/store/main.js @@ -54,7 +54,9 @@ export default new Vuex.Store({ boards: [], sharees: [], assignableUsers: [], - boardFilter: BOARD_FILTERS.ALL + boardFilter: BOARD_FILTERS.ALL, + activity: [], + activityLoadMore: true }, getters: { boards: state => { @@ -140,6 +142,20 @@ export default new Vuex.Store({ state.sharees = shareesUsersAndGroups.users state.sharees.push(...shareesUsersAndGroups.groups) }, + setActivity(state, activity) { + activity.forEach(element => { + if (element.subject_rich[1].board.id === state.currentBoard.id) { + state.activity.push(element) + } + }) + + }, + clearActivity(state) { + state.activity = [] + }, + setActivityLoadMore(state, value) { + state.activityLoadMore = value + }, setAssignableUsers(state, users) { state.assignableUsers = users }, @@ -268,6 +284,30 @@ export default new Vuex.Store({ commit('setSharees', response.data.ocs.data) }) }, + loadActivity({ commit }, obj) { + const params = new URLSearchParams() + params.append('format', 'json') + params.append('type', 'deck') + params.append('since', obj.since) + params.append('object_type', obj.object_type) + params.append('object_id', obj.object_id) + + if (obj.since === 0) { + commit('clearActivity') + } + + let keyword = 'deck' + if (obj.type === 'filter') { + keyword = 'filter' + } + axios.get(OC.linkToOCS('apps/activity/api/v2/activity') + keyword, { params }).then((response) => { + commit('setActivity', response.data.ocs.data) + commit('setActivityLoadMore', true) + if (response.data.ocs.meta.statuscode === 304) { + commit('setActivityLoadMore', false) + } + }) + }, setBoardFilter({ commmit }, filter) { commmit('setBoardFilter', filter) diff --git a/templates/main.php b/templates/main.php index d359d97e7..24c252935 100644 --- a/templates/main.php +++ b/templates/main.php @@ -23,6 +23,10 @@ use OCP\Util; +Util::addScript('activity', 'richObjectStringParser'); +Util::addScript('activity', 'templates'); +Util::addStyle('activity', 'style'); + style('deck', 'globalstyles'); script('deck', 'deck');