mirror of
https://github.com/crater-invoice/crater.git
synced 2026-02-09 12:22:40 -05:00
build version 400
This commit is contained in:
84
resources/assets/js/store/modules/disk/actions.js
Normal file
84
resources/assets/js/store/modules/disk/actions.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const fetchDisks = ({ commit }, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get(`/api/v1/disks`, { params })
|
||||
.then((response) => {
|
||||
commit(types.SET_DISKS, response.data.disks.data)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchDiskDrivers = ({ commit }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get(`/api/v1/disk/drivers`)
|
||||
.then((response) => {
|
||||
commit(types.SET_DISK_DRIVER, response.data)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchDiskEnv = ({ commit }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get(`/api/v1/disks/${data.disk}`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const createDisk = ({ commit }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post(`/api/v1/disks`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const updateDisk = ({ commit }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.put(`/api/v1/disks/${data.id}`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteFileDisk = ({ commit, dispatch, state }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.delete(`/api/v1/disks/${id}`)
|
||||
.then((response) => {
|
||||
if (response.data.success) {
|
||||
commit(types.DELETE_DISK, id)
|
||||
}
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
2
resources/assets/js/store/modules/disk/getters.js
Normal file
2
resources/assets/js/store/modules/disk/getters.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export const getDisks = (state) => state.disks
|
||||
export const getDiskDrivers = (state) => state.diskDrivers
|
||||
20
resources/assets/js/store/modules/disk/index.js
Normal file
20
resources/assets/js/store/modules/disk/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
disks: [],
|
||||
diskDrivers: [],
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations,
|
||||
}
|
||||
4
resources/assets/js/store/modules/disk/mutation-types.js
Normal file
4
resources/assets/js/store/modules/disk/mutation-types.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export const SET_DISKS = 'SET_DISKS'
|
||||
export const SET_DISK_DRIVER = 'SET_DISK_DRIVER'
|
||||
export const ADD_DISKS = 'ADD_DISKS'
|
||||
export const DELETE_DISK = 'DELETE_DISK'
|
||||
20
resources/assets/js/store/modules/disk/mutations.js
Normal file
20
resources/assets/js/store/modules/disk/mutations.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_DISKS](state, disks) {
|
||||
state.disks = disks
|
||||
},
|
||||
|
||||
[types.SET_DISK_DRIVER](state, data) {
|
||||
state.diskDrivers = data.drivers
|
||||
},
|
||||
|
||||
[types.ADD_DISKS](state, data) {
|
||||
state.disks.push(data.disk)
|
||||
},
|
||||
|
||||
[types.DELETE_DISK](state, id) {
|
||||
let pos = state.disks.findIndex((disk) => disk.id === id)
|
||||
state.disks.splice(pos, 1)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user