mirror of https://github.com/nocodb/nocodb
128 lines
3.5 KiB
128 lines
3.5 KiB
4 years ago
|
export const state = () => ({
|
||
|
|
||
3 years ago
|
servers: {}
|
||
4 years ago
|
|
||
3 years ago
|
})
|
||
4 years ago
|
|
||
|
export const mutations = {
|
||
|
|
||
3 years ago
|
MutAddServer(state, args) {
|
||
3 years ago
|
args.alive = true
|
||
|
state.servers[args.key] = args
|
||
|
state.servers = { ...state.servers }
|
||
|
// state.servers[args.key].alive = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
MutRemoveServer(state, args) {
|
||
4 years ago
|
if (args.key in state.servers) {
|
||
3 years ago
|
const temp = state.servers
|
||
|
delete temp[args.key]
|
||
|
state.servers = { ...temp }
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
MutCloudUrl(state, args) {
|
||
4 years ago
|
if (args.key in state.servers) {
|
||
3 years ago
|
const temp = state.servers
|
||
|
state.servers[args.key].cloudUrl = args.cloudUrl
|
||
|
state.servers = { ...temp }
|
||
4 years ago
|
}
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
export const getters = {}
|
||
4 years ago
|
|
||
|
export const actions = {
|
||
|
|
||
3 years ago
|
async start({ commit, state, rootState }, args) {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', true, { root: true })
|
||
4 years ago
|
|
||
|
try {
|
||
|
// let result = await rootState.sqlMgr.sqlMgr.projectAPIServerStart(args);
|
||
3 years ago
|
const result = await this.dispatch('sqlMgr/ActSqlOp', [null, 'projectAPIServerStart', args])
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
3 years ago
|
const serverResult = { ...args, ...result.data.object }
|
||
|
commit('MutAddServer', serverResult)
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
throw e
|
||
|
} finally {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', false, { root: true })
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async stop({ commit, state, rootState }, args) {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', true, { root: true })
|
||
4 years ago
|
|
||
|
try {
|
||
|
// let result = await rootState.sqlMgr.sqlMgr.projectAPIServerStop(args);
|
||
3 years ago
|
const result = await this.dispatch('sqlMgr/ActSqlOp', [null, 'projectAPIServerStop', args])
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
3 years ago
|
commit('MutRemoveServer', args)
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
throw e
|
||
|
} finally {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', false, { root: true })
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async getCloudUrl({ commit, state, rootState }, args) {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', true, { root: true })
|
||
4 years ago
|
|
||
|
try {
|
||
3 years ago
|
const result = await rootState.sqlMgr.sqlMgr.projectAPIServerGetCloudUrl(args)
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
3 years ago
|
commit('MutCloudUrl', { ...args, ...result.data })
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
throw e
|
||
|
} finally {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', false, { root: true })
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async cloudSendNotification({ commit, state, rootState }, args) {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', true, { root: true })
|
||
4 years ago
|
|
||
|
try {
|
||
3 years ago
|
await rootState.sqlMgr.sqlMgr.projectAPIServerSendNotification(args)
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
throw e
|
||
|
} finally {
|
||
3 years ago
|
commit('notification/MutToggleProgressBar', false, { root: true })
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
}
|
||
4 years ago
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|