diff --git a/src/api/reports.js b/src/api/reports.js new file mode 100644 index 00000000..500ecfef --- /dev/null +++ b/src/api/reports.js @@ -0,0 +1,6 @@ +import { reports } from './reportsData' + +export function fetchReports(index, size) { + const response = reports.slice(index, index + size) + return response +} diff --git a/src/api/reportsData.js b/src/api/reportsData.js new file mode 100644 index 00000000..bc86469b --- /dev/null +++ b/src/api/reportsData.js @@ -0,0 +1,218 @@ +export const reports = [ + { + id: '1', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #1', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '2', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #2', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '3', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #3', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + }, + { + id: '4', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #4', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '5', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #5', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '6', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #6', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + }, + { + id: '7', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #7', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '8', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #8', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '9', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #9', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + }, + { + id: '10', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #10', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '11', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #11', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '12', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #12', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + }, + { + id: '13', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #13', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '14', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #14', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '15', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #15', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + }, + { + id: '16', + timestamp: '2019/4/12', + local: true, + from: 'John', // actor nickname + object: 'Bob', // user nickname + header: 'Report #16', // content + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, + { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } + ] + }, + { + id: '17', + timestamp: '2019/4/1', + local: true, + from: 'Max', + object: 'Vic', + header: 'Report #17', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [ + { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, + { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } + ] + }, + { + id: '18', + timestamp: '2019/2/28', + local: true, + from: 'Tim', + object: 'Jen', + header: 'Report #18', + content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', + notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] + } +] diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js index cb0bdd22..279f1994 100644 --- a/src/store/modules/reports.js +++ b/src/store/modules/reports.js @@ -1,50 +1,35 @@ +import { fetchReports } from '@/api/reports' + const reports = { state: { - fetchedReports: [ - { - id: '1', - timestamp: '2019/4/12', - local: true, - from: 'John', // actor nickname - object: 'Bob', // user nickname - header: 'Report #1', // content - content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', - notes: [ - { author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' }, - { author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' } - ] - }, - { - id: '2', - timestamp: '2019/4/1', - local: true, - from: 'Max', - object: 'Vic', - header: 'Report #2', - content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', - notes: [ - { author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' }, - { author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' } - ] - }, - { - id: '3', - timestamp: '2019/2/28', - local: true, - from: 'Tim', - object: 'Jen', - header: 'Report #3', - content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', - notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }] - } - ] + fetchedReports: [], + indexOfLastShownReport: 0, + size: 3, + loading: true }, mutations: { + SET_REPORTS: (state, reports) => { + state.fetchedReports = state.fetchedReports.concat(reports) + }, SET_REPORT: (state, { index, report }) => { state.fetchedReports[index] = report + }, + SET_LOADING: (state, status) => { + state.loading = status + }, + SET_INDEX: (state) => { + state.indexOfLastShownReport = state.indexOfLastShownReport + state.size } }, actions: { + async FetchReports({ commit, state, getters }) { + commit('SET_LOADING', true) + const response = fetchReports(state.indexOfLastShownReport, state.size) + + commit('SET_REPORTS', response) + commit('SET_INDEX') + commit('SET_LOADING', false) + }, async AddNote({ commit, state, getters }, { reportId, note }) { const report = state.fetchedReports.find(report => report.id === reportId) report.notes = [...report.notes, note] diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 56eb07a0..4e6faf08 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -48,11 +48,11 @@ const users = { }, actions: { async FetchUsers({ commit, state, getters }, { page }) { + commit('SET_LOADING', true) + const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() const response = await fetchUsers(filters, getters.authHost, getters.token, page) - commit('SET_LOADING', true) - loadUsers(commit, page, response.data) }, async ToggleUserActivation({ commit, getters }, nickname) { diff --git a/src/views/reports/index.vue b/src/views/reports/index.vue index 83393c5c..322f9b54 100644 --- a/src/views/reports/index.vue +++ b/src/views/reports/index.vue @@ -3,7 +3,7 @@