56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/replication.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
error: "",
|
|
loading: false,
|
|
master: {},
|
|
slave: []
|
|
},
|
|
mutations: {
|
|
update_loading(state,val) {
|
|
state.loading = val
|
|
},
|
|
update_master(state, val) {
|
|
state.master = val
|
|
},
|
|
update_slave(state, val) {
|
|
state.slave= val
|
|
},
|
|
update_error(state, val) {
|
|
state.error = val
|
|
}
|
|
},
|
|
actions: {
|
|
async load(context) {
|
|
context.commit("update_loading", true)
|
|
context.commit("update_error", "")
|
|
try {
|
|
context.commit("update_slave",[])
|
|
let resp = await api.load()
|
|
if (resp.status != "OK") {
|
|
context.commit("update_loading", false)
|
|
context.commit("update_error", resp.message)
|
|
} else {
|
|
context.commit("update_loading", false)
|
|
context.commit("update_error", "")
|
|
for(let idx=0;idx < resp.slave.length; idx++) {
|
|
for(let j=0;j<resp.slave[idx].Table.length; j++) {
|
|
resp.slave[idx].Table[j] = resp.slave[idx].Table[j].replace('one.','')
|
|
}
|
|
}
|
|
context.commit("update_master", resp.master)
|
|
context.commit("update_slave", resp.slave)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_loading", false)
|
|
context.commit("update_error", e.message )
|
|
}
|
|
},
|
|
}
|
|
}
|