| @@ 1-52 (lines=52) @@ | ||
| 1 | import axios from 'axios' |
|
| 2 | ||
| 3 | export function createActions(route) { |
|
| 4 | return { |
|
| 5 | LOAD_COUNTERS: ({ commit }) => { |
|
| 6 | return new Promise(resolve => { |
|
| 7 | axios |
|
| 8 | .all([ |
|
| 9 | axios.get(route('admin.posts.draft.counter')), |
|
| 10 | axios.get(route('admin.posts.pending.counter')), |
|
| 11 | axios.get(route('admin.posts.published.counter')), |
|
| 12 | axios.get(route('admin.users.active.counter')), |
|
| 13 | axios.get(route('admin.form_submissions.counter')) |
|
| 14 | ]) |
|
| 15 | .then( |
|
| 16 | axios.spread( |
|
| 17 | ( |
|
| 18 | newPostsCount, |
|
| 19 | pendingPostsCount, |
|
| 20 | publishedPostsCount, |
|
| 21 | activeUsersCount, |
|
| 22 | formSubmissionsCount |
|
| 23 | ) => { |
|
| 24 | commit('SET_COUNTER', { |
|
| 25 | type: 'newPostsCount', |
|
| 26 | counter: newPostsCount.data |
|
| 27 | }) |
|
| 28 | commit('SET_COUNTER', { |
|
| 29 | type: 'pendingPostsCount', |
|
| 30 | counter: pendingPostsCount.data |
|
| 31 | }) |
|
| 32 | commit('SET_COUNTER', { |
|
| 33 | type: 'publishedPostsCount', |
|
| 34 | counter: publishedPostsCount.data |
|
| 35 | }) |
|
| 36 | commit('SET_COUNTER', { |
|
| 37 | type: 'activeUsersCount', |
|
| 38 | counter: activeUsersCount.data |
|
| 39 | }) |
|
| 40 | commit('SET_COUNTER', { |
|
| 41 | type: 'formSubmissionsCount', |
|
| 42 | counter: formSubmissionsCount.data |
|
| 43 | }) |
|
| 44 | ||
| 45 | resolve() |
|
| 46 | } |
|
| 47 | ) |
|
| 48 | ) |
|
| 49 | }) |
|
| 50 | } |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 1-52 (lines=52) @@ | ||
| 1 | import axios from 'axios' |
|
| 2 | ||
| 3 | export function createActions(route) { |
|
| 4 | return { |
|
| 5 | LOAD_COUNTERS: ({ commit }) => { |
|
| 6 | return new Promise(resolve => { |
|
| 7 | axios |
|
| 8 | .all([ |
|
| 9 | axios.get(route('admin.posts.draft.counter')), |
|
| 10 | axios.get(route('admin.posts.pending.counter')), |
|
| 11 | axios.get(route('admin.posts.published.counter')), |
|
| 12 | axios.get(route('admin.users.active.counter')), |
|
| 13 | axios.get(route('admin.form_submissions.counter')) |
|
| 14 | ]) |
|
| 15 | .then( |
|
| 16 | axios.spread( |
|
| 17 | ( |
|
| 18 | newPostsCount, |
|
| 19 | pendingPostsCount, |
|
| 20 | publishedPostsCount, |
|
| 21 | activeUsersCount, |
|
| 22 | formSubmissionsCount |
|
| 23 | ) => { |
|
| 24 | commit('SET_COUNTER', { |
|
| 25 | type: 'newPostsCount', |
|
| 26 | counter: newPostsCount.data |
|
| 27 | }) |
|
| 28 | commit('SET_COUNTER', { |
|
| 29 | type: 'pendingPostsCount', |
|
| 30 | counter: pendingPostsCount.data |
|
| 31 | }) |
|
| 32 | commit('SET_COUNTER', { |
|
| 33 | type: 'publishedPostsCount', |
|
| 34 | counter: publishedPostsCount.data |
|
| 35 | }) |
|
| 36 | commit('SET_COUNTER', { |
|
| 37 | type: 'activeUsersCount', |
|
| 38 | counter: activeUsersCount.data |
|
| 39 | }) |
|
| 40 | commit('SET_COUNTER', { |
|
| 41 | type: 'formSubmissionsCount', |
|
| 42 | counter: formSubmissionsCount.data |
|
| 43 | }) |
|
| 44 | ||
| 45 | resolve() |
|
| 46 | } |
|
| 47 | ) |
|
| 48 | ) |
|
| 49 | }) |
|
| 50 | } |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||