mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
798 lines
21 KiB
798 lines
21 KiB
4 years ago
|
/* eslint-disable */
|
||
3 years ago
|
import Vue from 'vue'
|
||
4 years ago
|
|
||
3 years ago
|
import treeViewDataSerializer from '~/helpers/treeViewDataSerializer'
|
||
|
import deepFind from '~/helpers/deepFind'
|
||
|
import deepSet from '~/helpers/deepSet'
|
||
|
import { isMetaTable } from '@/helpers/xutils'
|
||
4 years ago
|
|
||
|
// const {path, config, jsonfile} = require('electron').remote.require('./libs')
|
||
3 years ago
|
const defaultProject = ''//jsonfile.readFileSync(config.electron.defaultProjectPath);
|
||
4 years ago
|
// import setProp from "../helpers/setProp";
|
||
|
|
||
|
export const state = () => ({
|
||
|
list: [],
|
||
|
|
||
|
/***
|
||
|
* Row of project in xc.sqlite + projectJson
|
||
|
*/
|
||
|
unserializedList: [],
|
||
|
defaultProject,
|
||
3 years ago
|
appInfo: null,
|
||
4 years ago
|
activeEnv: null,
|
||
3 years ago
|
authDbAlias: null,
|
||
3 years ago
|
projectId: null,
|
||
|
project: null,
|
||
|
tables: []
|
||
|
})
|
||
4 years ago
|
|
||
|
export const mutations = {
|
||
3 years ago
|
tables(state, tables) {
|
||
|
state.tables = tables
|
||
|
},
|
||
4 years ago
|
add(state, project) {
|
||
3 years ago
|
state.list.push(project)
|
||
4 years ago
|
},
|
||
3 years ago
|
MutProjectId(state, projectId) {
|
||
3 years ago
|
state.projectId = projectId
|
||
3 years ago
|
},
|
||
4 years ago
|
update(state, data) {
|
||
|
},
|
||
3 years ago
|
remove(state, { project }) {
|
||
|
state.list.splice(state.list.indexOf(project), 1)
|
||
4 years ago
|
},
|
||
|
list(state, projects) {
|
||
3 years ago
|
Vue.set(state, 'unserializedList', projects)
|
||
4 years ago
|
// state.unserializedList = projects;
|
||
|
// state.list = treeViewDataSerializer(projects);
|
||
|
state.authDbAlias = projects[0]
|
||
|
&& projects[0].projectJson
|
||
|
&& projects[0].projectJson.auth
|
||
|
&& projects[0].projectJson.auth.jwt
|
||
|
&& projects[0].projectJson.auth.jwt.dbAlias
|
||
3 years ago
|
Vue.set(state, 'list', treeViewDataSerializer(projects))
|
||
4 years ago
|
if (!(projects && projects[0] && projects[0].workingEnv)) {
|
||
|
return
|
||
|
}
|
||
3 years ago
|
state.activeEnv = projects[0].workingEnv
|
||
|
|
||
|
},
|
||
|
|
||
|
project(state, val) {
|
||
|
|
||
|
const formattedProj = {
|
||
|
...val,
|
||
|
projectJson: {
|
||
|
...val,
|
||
|
envs: {
|
||
|
_noco: {
|
||
|
db: [{
|
||
|
...val.bases[0],
|
||
|
client: val.bases[0].type,
|
||
|
connection: {
|
||
|
database: val.bases[0].database
|
||
|
},
|
||
|
meta: {}
|
||
|
}]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const projects = [formattedProj]
|
||
|
|
||
|
Vue.set(state, 'unserializedList', projects)
|
||
4 years ago
|
|
||
3 years ago
|
Vue.set(state, 'list', treeViewDataSerializer(projects))
|
||
|
|
||
|
state.project = val
|
||
4 years ago
|
},
|
||
3 years ago
|
|
||
4 years ago
|
setProjectJson(state, projJson) {
|
||
|
// setProp(state, ['unserializedList', 0, 'projectJson'], projJson)
|
||
3 years ago
|
Vue.set(state.unserializedList, '0', {
|
||
|
...state.unserializedList[0],
|
||
|
projectJson: projJson
|
||
|
})
|
||
4 years ago
|
// state.unserializedList = JSON.parse(JSON.stringify(state.unserializedList))
|
||
|
},
|
||
|
setDefaultProjectJson(state, projJson) {
|
||
|
// setProp(state, ['unserializedList', 0, 'projectJson'], projJson)
|
||
3 years ago
|
Vue.set(state, 'defaultProject', { ...projJson })
|
||
4 years ago
|
},
|
||
3 years ago
|
MutAppInfo(state, appInfo) {
|
||
|
state.appInfo = appInfo
|
||
2 years ago
|
},
|
||
|
MutProjectCost(state, cost) {
|
||
|
state.project.cost = cost
|
||
|
},
|
||
|
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
|
function getSerializedEnvObj(data) {
|
||
3 years ago
|
return data.reduce((obj, {
|
||
|
key,
|
||
|
value,
|
||
|
enabled
|
||
|
}) => {
|
||
4 years ago
|
if (enabled) {
|
||
3 years ago
|
obj[key] = value
|
||
4 years ago
|
}
|
||
3 years ago
|
return obj
|
||
|
}, {})
|
||
4 years ago
|
}
|
||
|
|
||
|
export const getters = {
|
||
|
|
||
|
GtrEnv(state) {
|
||
3 years ago
|
return state.appInfo && state.appInfo.env
|
||
4 years ago
|
},
|
||
|
GtrFirstDbAlias(state, getters) {
|
||
|
return (state.unserializedList
|
||
3 years ago
|
&& state.unserializedList[0]
|
||
|
&& state.unserializedList[0].projectJson
|
||
|
&& state.unserializedList[0].projectJson.envs
|
||
|
&& getters.GtrEnv
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv]
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv].db
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv].db[0]
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv].db[0].meta
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv].db[0].meta.dbAlias)
|
||
3 years ago
|
|| 'db'
|
||
4 years ago
|
},
|
||
|
|
||
|
GtrDbAliasList(state, getters) {
|
||
|
return (state.unserializedList
|
||
3 years ago
|
&& state.unserializedList[0]
|
||
|
&& state.unserializedList[0].projectJson
|
||
|
&& state.unserializedList[0].projectJson.envs
|
||
|
&& getters.GtrEnv
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv]
|
||
|
&& state.unserializedList[0].projectJson.envs[getters.GtrEnv].db)
|
||
4 years ago
|
// && state.unserializedList[0].projectJson.envs[gettersGtrEnv].db.map(db => db.meta.dbAlias))
|
||
3 years ago
|
|| []
|
||
4 years ago
|
},
|
||
|
|
||
|
list(state) {
|
||
3 years ago
|
return state.list
|
||
4 years ago
|
},
|
||
|
currentProjectFolder(state) {
|
||
|
// unserializedList.o.folder
|
||
3 years ago
|
return state.unserializedList && state.unserializedList[0] && state.unserializedList[0].folder
|
||
4 years ago
|
},
|
||
|
projectQueriesFolder(state) {
|
||
|
// unserializedList.o.folder
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.queriesFolder
|
||
4 years ago
|
},
|
||
|
projectApisFolder(state) {
|
||
|
// unserializedList.o.folder
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.apisFolder
|
||
4 years ago
|
},
|
||
|
projectApisFolderPath(state) {
|
||
|
return ''
|
||
|
// unserializedList.o.folder
|
||
|
// console.log(state.unserializedList[0]);
|
||
|
// return path.join(state.unserializedList && state.unserializedList[0] && state.unserializedList[0].folder,
|
||
|
// 'server', 'tool', state.unserializedList[0].projectJson.apisFolder);
|
||
|
},
|
||
|
GtrProjectJson(state) {
|
||
3 years ago
|
// return state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null;
|
||
|
return state.project
|
||
4 years ago
|
},
|
||
|
GtrProjectJsonUnserialized(state) {
|
||
3 years ago
|
let data = JSON.parse(JSON.stringify(state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null))
|
||
|
if (!data) {
|
||
|
return {}
|
||
|
}
|
||
4 years ago
|
for (let env of Object.values(data.envs)) {
|
||
|
for (let db of env.db) {
|
||
3 years ago
|
delete db.tables
|
||
|
delete db.functions
|
||
|
delete db.procedures
|
||
|
delete db.sequences
|
||
|
delete db.views
|
||
4 years ago
|
}
|
||
|
}
|
||
3 years ago
|
return data
|
||
4 years ago
|
},
|
||
|
GtrProjectName(state) {
|
||
3 years ago
|
return state.project && state.project.title
|
||
|
},
|
||
|
GtrProjectId(state) {
|
||
|
return state.project && state.project.id
|
||
4 years ago
|
},
|
||
|
GtrProjectPrefix(state) {
|
||
3 years ago
|
return state.project && state.project.prefix
|
||
4 years ago
|
},
|
||
3 years ago
|
GtrClientType(state) {
|
||
|
return state.project && state.project.bases && state.project.bases[0]&& state.project.bases[0].type
|
||
|
},
|
||
4 years ago
|
|
||
|
GtrApiEnvironment(state) {
|
||
3 years ago
|
const projJson = state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null
|
||
|
if (!projJson || !projJson.apiClient) {
|
||
|
return {}
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const serializedGlobEnv = getSerializedEnvObj(projJson.apiClient.data)
|
||
4 years ago
|
|
||
|
return Object.entries(projJson.envs || {})
|
||
|
.reduce((obj, [name, env]) => {
|
||
3 years ago
|
const serializedEnvObj = getSerializedEnvObj(env.apiClient.data)
|
||
|
obj[name] = { ...serializedGlobEnv, ...serializedEnvObj }
|
||
|
return obj
|
||
|
}, {})
|
||
4 years ago
|
},
|
||
|
GtrDefaultApiEnvironment(state) {
|
||
3 years ago
|
if (!state.defaultProject || !state.defaultProject.apiClient) {
|
||
|
return {}
|
||
|
}
|
||
|
const serializedGlobEnv = getSerializedEnvObj(state.defaultProject.apiClient.data)
|
||
|
if (!state.defaultProject || !state.defaultProject.envs) {
|
||
|
return {}
|
||
|
}
|
||
4 years ago
|
return Object.entries(state.defaultProject.envs)
|
||
|
.reduce((obj, [name, env]) => {
|
||
3 years ago
|
const serializedEnvObj = getSerializedEnvObj(env.apiClient.data)
|
||
|
obj[name] = { ...serializedGlobEnv, ...serializedEnvObj }
|
||
|
return obj
|
||
4 years ago
|
}, {})
|
||
|
},
|
||
|
|
||
|
GtrApiClientEnvironment(state) {
|
||
3 years ago
|
const projJson = state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null
|
||
4 years ago
|
return projJson && projJson.envs ?
|
||
|
Object.entries(projJson.envs)
|
||
3 years ago
|
.reduce((obj, [name, env]) => ({ [name]: { ...projJson.api, ...env.api }, ...obj }), {}) : {}
|
||
4 years ago
|
},
|
||
|
|
||
|
GtrProjectIsGraphql(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'graphql'
|
||
4 years ago
|
},
|
||
|
|
||
|
GtrProjectIsMvc(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.type === 'mvc'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsDocker(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.type === 'docker'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsPackage(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.type === 'package'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsTs(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.language === 'ts'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsRest(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'rest'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsGrpc(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'grpc'
|
||
4 years ago
|
},
|
||
|
GtrProjectType(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType
|
||
4 years ago
|
},
|
||
|
GtrProjectIsNoApis(state) {
|
||
|
return (state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'migrations')
|
||
3 years ago
|
|| (state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'dbConnection')
|
||
4 years ago
|
},
|
||
|
GtrProjectIsMigration(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'migrations'
|
||
4 years ago
|
},
|
||
|
GtrProjectIsDbConnection(state) {
|
||
3 years ago
|
return state.unserializedList[0] && state.unserializedList[0].projectJson.projectType === 'dbConnection'
|
||
4 years ago
|
},
|
||
|
|
||
|
GtrIsFirstLoad(state) {
|
||
3 years ago
|
return !state.appInfo || !state.appInfo.projectHasDb || state.appInfo.firstUser
|
||
4 years ago
|
},
|
||
|
|
||
|
GtrIsDocker(state) {
|
||
3 years ago
|
return state.appInfo && state.appInfo.type === 'docker'
|
||
4 years ago
|
},
|
||
|
GtrIsMvc(state) {
|
||
3 years ago
|
return state.appInfo && state.appInfo.type === 'mvc'
|
||
4 years ago
|
},
|
||
|
GtrEnvList(state) {
|
||
|
return state.unserializedList[0]
|
||
|
&& state.unserializedList[0].projectJson
|
||
3 years ago
|
&& state.unserializedList[0].projectJson.envs ? Object.keys(state.unserializedList[0].projectJson.envs) : []
|
||
4 years ago
|
},
|
||
2 years ago
|
GtrProjectCost(state) {
|
||
|
return state.project.cost || 0
|
||
|
},
|
||
4 years ago
|
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
|
// let sqlMgr;
|
||
|
export const actions = {
|
||
3 years ago
|
async clearProjects({
|
||
|
commit,
|
||
|
state,
|
||
|
rootGetters,
|
||
|
dispatch
|
||
|
}) {
|
||
|
await commit('list', [])
|
||
|
},
|
||
|
async loadProjects({
|
||
|
commit,
|
||
|
state,
|
||
|
rootGetters,
|
||
|
dispatch,
|
||
|
...rest
|
||
|
}, id = null) {
|
||
4 years ago
|
// dispatch("sqlMgr/instantiateSqlMgr", null, {root: true});
|
||
|
// sqlMgr = rootGetters["sqlMgr/sqlMgr"];
|
||
|
// const data = await sqlMgr.projectOpen({id}); // unsearialized data
|
||
|
await new Promise(resolve => {
|
||
|
const int = setInterval(() => {
|
||
|
if (window.rehydrated) {
|
||
3 years ago
|
clearTimeout(tm)
|
||
|
resolve()
|
||
4 years ago
|
}
|
||
|
}, 100)
|
||
|
const tm = setTimeout(() => {
|
||
3 years ago
|
clearInterval(int)
|
||
|
resolve()
|
||
4 years ago
|
}, 5000)
|
||
3 years ago
|
})
|
||
4 years ago
|
try {
|
||
3 years ago
|
let data, projectId
|
||
4 years ago
|
if (this.$router.currentRoute && this.$router.currentRoute.params && this.$router.currentRoute.params.project_id) {
|
||
3 years ago
|
commit('MutProjectId', projectId = this.$router.currentRoute.params.project_id)
|
||
3 years ago
|
await dispatch('users/ActGetProjectUserDetails', this.$router.currentRoute.params.project_id, { root: true })
|
||
|
// data = await this.dispatch('sqlMgr/ActSqlOp', [null, 'PROJECT_READ_BY_WEB']); // unsearialized data
|
||
3 years ago
|
} else if (this.$router.currentRoute && this.$router.currentRoute.params && this.$router.currentRoute.params.shared_base_id) {
|
||
3 years ago
|
const baseData = (await this.$api.public.sharedBaseGet(this.$router.currentRoute.params.shared_base_id))// await this.dispatch('sqlMgr/ActSqlOp', [null, 'sharedBaseGet', {shared_base_id: this.$router.currentRoute.params.shared_base_id}]); // unsearialized data
|
||
3 years ago
|
commit('MutProjectId', projectId = baseData.project_id)
|
||
3 years ago
|
// data = await this.dispatch('sqlMgr/ActSqlOp', [{project_id: baseData.project_id}, 'PROJECT_READ_BY_WEB']); // unsearialized data
|
||
|
await dispatch('users/ActGetBaseUserDetails', this.$router.currentRoute.params.shared_base_id, { root: true })
|
||
3 years ago
|
} else {
|
||
3 years ago
|
commit('MutProjectId', null)
|
||
3 years ago
|
return
|
||
4 years ago
|
}
|
||
3 years ago
|
data = (await this.$api.project.read(projectId))
|
||
|
commit('project', data)
|
||
|
commit('meta/MutClear', null, { root: true })
|
||
|
commit('tabs/MutClearTabState', null, { root: true })
|
||
3 years ago
|
if (this.$ncApis) {
|
||
3 years ago
|
this.$ncApis.clear()
|
||
|
this.$ncApis.setProjectId(projectId)
|
||
3 years ago
|
}
|
||
2 years ago
|
|
||
|
this.$api.project.cost(projectId).then(res => {
|
||
|
if (res.cost) commit('MutProjectCost', res.cost)
|
||
|
})
|
||
|
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
|
this.$toast.error(e).goAway(3000)
|
||
4 years ago
|
this.$router.push('/projects')
|
||
|
}
|
||
|
},
|
||
3 years ago
|
async _loadTables({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch,
|
||
|
rootState
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data
|
||
4 years ago
|
|
||
3 years ago
|
const db = deepFind(state.unserializedList, dbKey)
|
||
4 years ago
|
|
||
|
if (db) {
|
||
|
|
||
3 years ago
|
const tables = (await this.$api.dbTable.list(
|
||
|
state.projectId,
|
||
|
{
|
||
3 years ago
|
includeM2M: rootState.settings.includeM2M || ''
|
||
3 years ago
|
})).list
|
||
4 years ago
|
|
||
3 years ago
|
commit('tables', tables)
|
||
4 years ago
|
|
||
3 years ago
|
deepSet(state.unserializedList, tables, `${key}`)
|
||
|
commit('list', state.unserializedList)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
console.error('DB Not found for tables load fn')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadTables({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
4 years ago
|
// type should tableDir and key should be for that table and dbkey
|
||
3 years ago
|
const dbKey = data._nodes.dbKey || null
|
||
|
const { key } = data._nodes
|
||
|
|
||
|
await dispatch('_loadTables', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadTablesFromParentTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
let dbKey = data._nodes.dbKey || ''
|
||
|
let {
|
||
|
key,
|
||
|
newTable
|
||
|
} = data._nodes
|
||
|
|
||
|
dbKey = (newTable ? key : data._nodes.tableDirKey).replace('.tables', '')
|
||
|
key = (newTable ? key : data._nodes.tableDirKey)
|
||
|
data._nodes.type = 'tableDir'
|
||
|
|
||
|
await dispatch('_loadTables', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadTablesFromChildTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const dbKey = data._nodes.dbKey
|
||
|
const key = data._nodes.key
|
||
|
|
||
|
data._nodes.type = 'tableDir'
|
||
|
|
||
|
await dispatch('_loadTables', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async _loadViews({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data
|
||
|
const db = deepFind(state.unserializedList, dbKey)
|
||
4 years ago
|
|
||
|
if (db) {
|
||
|
|
||
|
const result = await this.dispatch('sqlMgr/ActSqlOp', [{
|
||
|
env: data._nodes.env,
|
||
|
dbAlias: data._nodes.dbAlias
|
||
|
}, 'viewList'])
|
||
|
if (!result.data.list.length) {
|
||
3 years ago
|
this.$toast.info('No views in this schema').goAway(2000)
|
||
4 years ago
|
}
|
||
3 years ago
|
deepSet(state.unserializedList, result.data.list, `${key}`)
|
||
|
commit('list', state.unserializedList)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
console.error('DB Not found for tables load fn')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadViews({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const dbKey = data._nodes.dbKey || null
|
||
|
const { key } = data._nodes
|
||
|
|
||
|
await dispatch('_loadViews', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadViewsFromParentTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
|
||
|
let dbKey = data._nodes.dbKey || ''
|
||
|
let {
|
||
|
key,
|
||
|
newView
|
||
|
} = data._nodes
|
||
|
|
||
|
dbKey = (newView ? key : data._nodes.viewDirKey).replace('.views', '')
|
||
|
key = (newView ? key : data._nodes.viewDirKey)
|
||
|
data._nodes.type = 'viewDir'
|
||
|
|
||
|
await dispatch('_loadViews', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadViewsFromChildTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const dbKey = data._nodes.dbKey || null
|
||
|
const { key } = data._nodes
|
||
|
|
||
|
data._nodes.type = 'viewDir'
|
||
|
|
||
|
await dispatch('_loadViews', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async _loadFunctions({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data
|
||
4 years ago
|
|
||
|
// console.log("project data from actions", state, data);
|
||
3 years ago
|
const db = deepFind(state.unserializedList, dbKey)
|
||
4 years ago
|
|
||
|
if (db) {
|
||
|
const result = await this.dispatch('sqlMgr/ActSqlOp', [{
|
||
|
env: data._nodes.env,
|
||
|
dbAlias: data._nodes.dbAlias
|
||
|
}, 'functionList'])
|
||
|
|
||
|
if (!result.data.list.length) {
|
||
3 years ago
|
this.$toast.info('No functions in this schema').goAway(2000)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
deepSet(state.unserializedList, result.data.list, `${key}`)
|
||
|
commit('list', state.unserializedList)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
console.error('DB Not found for tables load fn')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadFunctions({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data._nodes
|
||
|
|
||
|
await dispatch('_loadFunctions', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadFunctionsFromParentTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
let dbKey = data._nodes.dbKey || ''
|
||
|
let {
|
||
|
key,
|
||
|
newFunction
|
||
|
} = data._nodes
|
||
|
|
||
|
dbKey = (newFunction ? key : data._nodes.functionDirKey).replace('.functions', '')
|
||
|
key = (newFunction ? key : data._nodes.functionDirKey)
|
||
|
data._nodes.type = 'functionDir'
|
||
|
|
||
|
await dispatch('_loadFunctions', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
async loadFunctionsFromChildTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const dbKey = data._nodes.dbKey || null
|
||
|
const { key } = data._nodes
|
||
|
|
||
|
data._nodes.type = 'functionDir'
|
||
|
|
||
|
await dispatch('_loadFunctions', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async _loadProcedures({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data
|
||
4 years ago
|
|
||
|
// console.log("project data from actions", state, data);
|
||
3 years ago
|
const db = deepFind(state.unserializedList, dbKey)
|
||
4 years ago
|
|
||
|
if (db) {
|
||
|
const result = await this.dispatch('sqlMgr/ActSqlOp', [{
|
||
|
env: data._nodes.env,
|
||
|
dbAlias: data._nodes.dbAlias
|
||
|
}, 'procedureList'])
|
||
|
|
||
|
if (!result.data.list.length) {
|
||
3 years ago
|
this.$toast.info('No procedures in this schema').goAway(2000)
|
||
4 years ago
|
}
|
||
3 years ago
|
deepSet(state.unserializedList, result.data.list, `${key}`)
|
||
|
commit('list', state.unserializedList)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
console.error('DB Not found for tables load fn')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadProcedures({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data._nodes
|
||
|
|
||
|
await dispatch('_loadProcedures', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async _loadSequences({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data
|
||
|
const db = deepFind(state.unserializedList, dbKey)
|
||
4 years ago
|
|
||
|
if (db) {
|
||
3 years ago
|
let result = {}
|
||
4 years ago
|
if (0) {
|
||
3 years ago
|
result.data = {}
|
||
|
result.data.list = []
|
||
4 years ago
|
} else {
|
||
|
// result = await client.sequenceList();
|
||
|
const result = await this.sqlMgr.sqlOp({
|
||
|
env: data._nodes.env,
|
||
|
dbAlias: data._nodes.dbAlias
|
||
3 years ago
|
}, 'sequenceList')
|
||
4 years ago
|
if (!result.data.list.length) {
|
||
3 years ago
|
this.$toast.info('No sequences in this schema').goAway(2000)
|
||
4 years ago
|
}
|
||
|
|
||
|
}
|
||
3 years ago
|
deepSet(state.unserializedList, result.data.list, `${key}`)
|
||
|
commit('list', state.unserializedList)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
console.error('DB Not found for tables load fn')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadSequences({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const {
|
||
|
key,
|
||
|
dbKey
|
||
|
} = data._nodes
|
||
|
await dispatch('_loadSequences', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async loadProceduresFromParentTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
let dbKey = data._nodes.dbKey || ''
|
||
|
let {
|
||
|
key,
|
||
|
newProcedure
|
||
|
} = data._nodes
|
||
|
|
||
|
dbKey = (newProcedure ? key : data._nodes.procedureDirKey).replace('.procedures', '')
|
||
|
key = newProcedure ? key : data._nodes.procedureDirKey
|
||
|
data._nodes.type = 'procedureDir'
|
||
|
|
||
|
await dispatch('_loadProcedures', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async loadSequencesFromParentTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
let dbKey = data._nodes.dbKey || ''
|
||
|
let {
|
||
|
key,
|
||
|
newSequence
|
||
|
} = data._nodes
|
||
|
|
||
|
dbKey = (newSequence ? key : data._nodes.sequenceDirKey).replace('.sequences', '')
|
||
|
key = newSequence ? key : data._nodes.sequenceDirKey
|
||
|
data._nodes.type = 'sequenceDir'
|
||
|
|
||
|
await dispatch('_loadSequences', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async loadProceduresFromChildTreeNode({
|
||
|
commit,
|
||
|
state,
|
||
|
dispatch
|
||
|
}, data) {
|
||
|
const dbKey = data._nodes.dbKey || null
|
||
|
const { key } = data._nodes
|
||
|
|
||
|
data._nodes.type = 'procedureDir'
|
||
|
|
||
|
await dispatch('_loadProcedures', {
|
||
|
...data,
|
||
|
dbKey,
|
||
|
key
|
||
|
})
|
||
|
},
|
||
|
|
||
|
async ActLoadProjectInfo({ commit }) {
|
||
3 years ago
|
const appInfo = (await this.$api.utils.appInfo())
|
||
|
commit('MutAppInfo', appInfo)
|
||
4 years ago
|
}
|
||
3 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>
|
||
3 years ago
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|