timeline for board and cards and small other fixes

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-08-23 09:53:07 +02:00
committed by Julius Härtl
parent bc7c5ea4b7
commit 6b8d42f176
4 changed files with 64 additions and 18 deletions

View File

@@ -2,7 +2,6 @@
<div> <div>
<div v-for="entry in boardActivity" :key="entry.activity_id"> <div v-for="entry in boardActivity" :key="entry.activity_id">
<img :src="entry.icon"> <img :src="entry.icon">
{{ entry.activity_id }}
{{ entry.subject }} {{ entry.subject }}
{{ getTime(entry.datetime) }} {{ getTime(entry.datetime) }}
</div> </div>
@@ -28,14 +27,15 @@ export default {
return { return {
isLoading: false, isLoading: false,
params: { params: {
limit: 50, type: 'deck',
since: 0 since: 0,
object_id: this.board.id
} }
} }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
boardActivity: 'boardActivity' boardActivity: 'activity'
}) })
}, },
created() { created() {
@@ -44,7 +44,7 @@ export default {
methods: { methods: {
loadBoardActivity() { loadBoardActivity() {
this.isLoading = true this.isLoading = true
this.$store.dispatch('loadBoardActivity', this.params).then(response => { this.$store.dispatch('loadActivity', this.params).then(response => {
this.isLoading = false this.isLoading = false
}) })
}, },

View File

@@ -77,7 +77,12 @@
</button> </button>
</AppSidebarTab> </AppSidebarTab>
<AppSidebarTab :order="2" name="Timeline" icon="icon-activity"> <AppSidebarTab :order="2" name="Timeline" icon="icon-activity">
this is the activity tab <div v-for="entry in cardActivity" :key="entry.activity_id">
<img :src="entry.icon">
{{ entry.subject }}
{{ getTime(entry.datetime) }}
</div>
<button @click="loadMore">Load More</button>
</AppSidebarTab> </AppSidebarTab>
</app-sidebar> </app-sidebar>
</template> </template>
@@ -122,13 +127,20 @@ export default {
toolbar: false toolbar: false
}, },
lastModifiedRelative: null, lastModifiedRelative: null,
lastCreatedRemative: null lastCreatedRemative: null,
params: {
type: 'filter',
since: 0,
object_type: 'deck_card',
object_id: this.id
}
} }
}, },
computed: { computed: {
...mapState({ ...mapState({
currentBoard: state => state.currentBoard, currentBoard: state => state.currentBoard,
assignableUsers: state => state.assignableUsers assignableUsers: state => state.assignableUsers,
cardActivity: 'activity'
}), }),
currentCard() { currentCard() {
return this.$store.getters.cardById(this.id) return this.$store.getters.cardById(this.id)
@@ -172,6 +184,7 @@ export default {
}, },
created() { created() {
setInterval(this.updateRelativeTimestamps, 10000) setInterval(this.updateRelativeTimestamps, 10000)
this.loadCardActivity()
}, },
destroyed() { destroyed() {
clearInterval(this.updateRelativeTimestamps) clearInterval(this.updateRelativeTimestamps)
@@ -230,6 +243,22 @@ export default {
} }
this.$store.dispatch('removeLabel', data) this.$store.dispatch('removeLabel', data)
}, },
loadCardActivity() {
this.isLoading = true
this.$store.dispatch('loadActivity', this.params).then(response => {
this.isLoading = false
})
},
getTime(timestamp) {
return OC.Util.relativeModifiedDate(timestamp)
},
loadMore() {
let array = Object.values(this.cardActivity)
let aId = (array[array.length - 1].activity_id)
this.params.since = aId
this.loadCardActivity()
},
clickAddNewAttachmment() { clickAddNewAttachmment() {
} }

View File

@@ -92,6 +92,11 @@ export default new Router({
return { return {
id: parseInt(route.params.id, 10) id: parseInt(route.params.id, 10)
} }
},
sidebar: (route) => {
return {
id: parseInt(route.params.id, 10)
}
} }
} }
}, },

View File

@@ -55,7 +55,7 @@ export default new Vuex.Store({
sharees: [], sharees: [],
assignableUsers: [], assignableUsers: [],
boardFilter: BOARD_FILTERS.ALL, boardFilter: BOARD_FILTERS.ALL,
boardActivity: [] activity: []
}, },
getters: { getters: {
boards: state => { boards: state => {
@@ -64,8 +64,8 @@ export default new Vuex.Store({
sharees: state => { sharees: state => {
return state.sharees return state.sharees
}, },
boardActivity: state => { activity: state => {
return state.boardActivity return state.activity
}, },
noneArchivedBoards: state => { noneArchivedBoards: state => {
return state.boards.filter(board => { return state.boards.filter(board => {
@@ -144,8 +144,13 @@ export default new Vuex.Store({
state.sharees = shareesUsersAndGroups.users state.sharees = shareesUsersAndGroups.users
state.sharees.push(...shareesUsersAndGroups.groups) state.sharees.push(...shareesUsersAndGroups.groups)
}, },
setBoardActivity(state, boardActivity) { setActivity(state, activity) {
state.boardActivity.push(...boardActivity) activity.forEach(element => {
if (element.subject_rich[1].board.id === state.currentBoard.id) {
state.activity.push(element)
}
})
}, },
setAssignableUsers(state, users) { setAssignableUsers(state, users) {
state.assignableUsers = users state.assignableUsers = users
@@ -275,13 +280,20 @@ export default new Vuex.Store({
commit('setSharees', response.data.ocs.data) commit('setSharees', response.data.ocs.data)
}) })
}, },
loadBoardActivity({ commit }, obj) { loadActivity({ commit }, obj) {
const params = new URLSearchParams() const params = new URLSearchParams()
params.append('format', 'json') params.append('format', 'json')
params.append('limit', obj.limit) params.append('type', 'deck')
params.append('since', obj.since) params.append('since', obj.since)
axios.get(OC.linkToOCS('apps/activity/api/v2/activity') + 'deck', { params }).then((response) => { params.append('object_type', obj.object_type)
commit('setBoardActivity', response.data.ocs.data) params.append('object_id', obj.object_id)
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)
}) })
}, },