mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-17 10:52:55 -05:00
build version 400
This commit is contained in:
41
resources/assets/js/store/modules/backup/actions.js
Normal file
41
resources/assets/js/store/modules/backup/actions.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const fetchBackups = ({ commit, dispatch, state }, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get(`/api/v1/backups`, { params })
|
||||
.then((response) => {
|
||||
commit(types.SET_BACKUPS, response.data)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const createBackup = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post(`/api/v1/backups`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const removeBackup = ({ commit, dispatch, state }, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.delete(`/api/v1/backups/${params.disk}`, { params })
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
3
resources/assets/js/store/modules/backup/getters.js
Normal file
3
resources/assets/js/store/modules/backup/getters.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export const getBackups = (state) => state.backups
|
||||
export const getBackupDisks = (state) => state.backupDisks
|
||||
export const getBackupDisksInfo = (state) => state.backupDisksInfo
|
||||
21
resources/assets/js/store/modules/backup/index.js
Normal file
21
resources/assets/js/store/modules/backup/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
backups: [],
|
||||
backupDisks: [],
|
||||
backupDisksInfo: [],
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations,
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export const SET_BACKUPS = 'SET_BACKUPS'
|
||||
export const ADD_BACKUPS = 'ADD_BACKUPS'
|
||||
export const DELETE_BACKUPS = 'DELETE_BACKUPS'
|
||||
export const SET_BACKUP_DISKS = 'SET_BACKUP_DISKS'
|
||||
21
resources/assets/js/store/modules/backup/mutations.js
Normal file
21
resources/assets/js/store/modules/backup/mutations.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_BACKUPS](state, data) {
|
||||
state.backups = data.backups
|
||||
state.backupDisks = data.disks
|
||||
},
|
||||
|
||||
[types.SET_BACKUP_DISKS](state, data) {
|
||||
state.backupDisksInfo = data.disks
|
||||
},
|
||||
|
||||
[types.ADD_BACKUPS](state, data) {
|
||||
state.backups.push(data.backup)
|
||||
},
|
||||
|
||||
[types.DELETE_BACKUPS](state, id) {
|
||||
let index = state.backups.findIndex((backup) => backup.id === id)
|
||||
state.backups.splice(index, 1)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user