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.
2185 lines
81 KiB
2185 lines
81 KiB
4 years ago
|
<template>
|
||
|
<v-container fluid>
|
||
|
<v-col
|
||
4 years ago
|
:class="{ 'col-md-8 offset-md-2 col-sm-10 offset-sm-1 col-12': !edit }"
|
||
|
style="position: relative"
|
||
|
>
|
||
3 years ago
|
<v-form ref="form" v-model="valid" :class="{ 'mt-8 pt-8': !edit }">
|
||
|
<v-card ref="mainCard" class="elevation-5">
|
||
4 years ago
|
<div
|
||
|
v-if="!edit"
|
||
4 years ago
|
style="
|
||
|
position: absolute;
|
||
|
top: -30px;
|
||
|
left: -moz-calc(50% - 30px);
|
||
|
left: -webkit-calc(50% - 30px);
|
||
|
left: calc(50% - 30px);
|
||
|
z-index: 999;
|
||
|
border-radius: 10px;
|
||
|
"
|
||
4 years ago
|
class="primary"
|
||
|
>
|
||
|
<v-img
|
||
|
class="mx-auto"
|
||
|
width="60"
|
||
|
height="60"
|
||
|
:src="require('@/assets/img/icons/512x512-trans.png')"
|
||
3 years ago
|
@dblclick="enableAllSchemas()"
|
||
|
/>
|
||
4 years ago
|
</div>
|
||
4 years ago
|
<v-toolbar
|
||
|
flat
|
||
|
color=""
|
||
|
class="mb-3"
|
||
3 years ago
|
style="
|
||
|
width: 100%;
|
||
|
border-bottom: 1px solid var(--v-backgroundColor-base);
|
||
|
"
|
||
4 years ago
|
>
|
||
|
<v-toolbar-title class="title">
|
||
|
<!-- Edit Project -->
|
||
3 years ago
|
<span v-if="edit">{{ $t("activity.editProject") }}</span>
|
||
4 years ago
|
<!-- Create Project -->
|
||
3 years ago
|
<span v-else>{{ $t("activity.createProject") }}</span>
|
||
4 years ago
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
<!-- Cancel and Return -->
|
||
|
<x-btn
|
||
|
v-ge="['project', 'cancel']"
|
||
3 years ago
|
:tooltip="$t('tooltip.cancelReturn')"
|
||
3 years ago
|
to="/"
|
||
4 years ago
|
class="elevation-20"
|
||
|
>
|
||
|
<!-- Cancel -->
|
||
3 years ago
|
{{ $t("general.cancel") }}
|
||
4 years ago
|
</x-btn>
|
||
|
<x-btn
|
||
3 years ago
|
v-ge="['project', 'save']"
|
||
4 years ago
|
:disabled="!valid || !envStatusValid"
|
||
|
class="primary"
|
||
4 years ago
|
@click="createOrUpdateProject()"
|
||
|
>
|
||
|
<!-- Update & Restart -->
|
||
3 years ago
|
<span v-if="edit">{{ $t("tooltip.updateRestart") }}</span>
|
||
4 years ago
|
<!-- Save Project -->
|
||
3 years ago
|
<span v-else>{{ $t("activity.saveProject") }}</span>
|
||
4 years ago
|
</x-btn>
|
||
|
<v-progress-linear
|
||
|
v-if="projectReloading"
|
||
|
top
|
||
|
absolute
|
||
|
color="success"
|
||
|
indeterminate
|
||
|
height="3"
|
||
4 years ago
|
style="top: -3px"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-toolbar>
|
||
|
|
||
|
<div ref="panelContainer" style="">
|
||
3 years ago
|
<api-overlay
|
||
|
v-show="projectReloading"
|
||
|
:project-created="projectCreated"
|
||
|
/>
|
||
4 years ago
|
<v-container fluid>
|
||
|
<v-row>
|
||
|
<v-col cols="12" class="mb-0 pb-0">
|
||
|
<div style="max-width: 360px" class="mx-auto mb-3">
|
||
4 years ago
|
<!-- Enter Project Name -->
|
||
4 years ago
|
<v-text-field
|
||
|
ref="name"
|
||
3 years ago
|
v-model="project.title"
|
||
4 years ago
|
v-ge="['project', 'name']"
|
||
|
:rules="form.titleRequiredRule"
|
||
|
:height="20"
|
||
3 years ago
|
:label="$t('placeholder.projName')"
|
||
4 years ago
|
autofocus
|
||
3 years ago
|
/>
|
||
4 years ago
|
</div>
|
||
|
</v-col>
|
||
|
|
||
4 years ago
|
<v-col
|
||
3 years ago
|
v-show="isTitle"
|
||
4 years ago
|
cols="10"
|
||
|
offset="1"
|
||
|
:class="{ 'mt-0 pt-0': !edit, 'mt-3 pt-3': edit }"
|
||
|
>
|
||
|
<p
|
||
|
:class="{
|
||
|
'text-center mb-2 mt-3': !edit,
|
||
|
'text-center mb-2 mt-3 grey--text': edit,
|
||
|
}"
|
||
|
>
|
||
3 years ago
|
{{ $t("title.dbCredentials") }}
|
||
4 years ago
|
</p>
|
||
|
<v-expansion-panels
|
||
|
v-model="panel"
|
||
|
focusable
|
||
|
accordion=""
|
||
|
class="elevation-20"
|
||
|
style="border: 1px solid white"
|
||
|
>
|
||
4 years ago
|
<v-expansion-panel
|
||
4 years ago
|
v-for="(envData, envKey, panelIndex) in project.envs"
|
||
|
:key="panelIndex"
|
||
4 years ago
|
:ref="`panel${envKey}`"
|
||
3 years ago
|
@change="onPanelToggle(panelIndex, envKey)"
|
||
4 years ago
|
>
|
||
|
<v-expansion-panel-header disable-icon-rotate>
|
||
|
<p class="pa-0 ma-0">
|
||
3 years ago
|
<v-tooltip
|
||
|
v-for="(db, tabIndex) in envData.db"
|
||
|
:key="tabIndex"
|
||
|
bottom
|
||
|
>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
4 years ago
|
<v-icon
|
||
|
small
|
||
3 years ago
|
:color="getDbStatusColor(db)"
|
||
3 years ago
|
@click.native.stop="
|
||
|
showDBTabInEnvPanel(panelIndex, tabIndex)
|
||
|
"
|
||
4 years ago
|
v-on="on"
|
||
3 years ago
|
>
|
||
|
mdi-database
|
||
4 years ago
|
</v-icon>
|
||
|
</template>
|
||
|
{{ getDbStatusTooltip(db) }}
|
||
|
</v-tooltip>
|
||
|
|
||
4 years ago
|
<span
|
||
|
v-if="project.ui[envKey]"
|
||
3 years ago
|
class="caption"
|
||
4 years ago
|
:class="project.ui[envKey].color + '--text'"
|
||
|
>
|
||
|
<i>{{ project.ui[envKey].msg }}</i>
|
||
|
</span>
|
||
|
|
||
|
<x-btn
|
||
3 years ago
|
v-if="panelIndex"
|
||
|
v-ge="['project', 'env-delete']"
|
||
4 years ago
|
small
|
||
|
text
|
||
|
btn.class="float-right"
|
||
|
tooltip="Click here to remove environment"
|
||
|
@click.native.stop="removeEnv(envKey)"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-hover v-slot="{ hover }">
|
||
4 years ago
|
<v-icon
|
||
|
:color="hover ? 'error' : 'grey'"
|
||
|
@click.native.stop="removeEnv(envKey)"
|
||
|
>
|
||
4 years ago
|
mdi-delete
|
||
|
</v-icon>
|
||
|
</v-hover>
|
||
|
</x-btn>
|
||
|
</p>
|
||
3 years ago
|
<template #actions>
|
||
3 years ago
|
<v-tooltip
|
||
|
v-if="getEnvironmentStatusAggregated(envData.db)"
|
||
|
bottom
|
||
|
>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<v-icon color="green" v-on="on">
|
||
|
mdi-check-circle
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
|
<span>Environment setup complete</span>
|
||
|
</v-tooltip>
|
||
3 years ago
|
<v-tooltip v-else-if="edit" bottom>
|
||
|
<template #activator="{ on }">
|
||
|
<v-icon color="orange" v-on="on">
|
||
|
mdi-alert-circle
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
|
<span>Environment setup pending</span>
|
||
|
</v-tooltip>
|
||
|
</template>
|
||
|
</v-expansion-panel-header>
|
||
|
<v-expansion-panel-content eager>
|
||
|
<v-col>
|
||
|
<v-card flat="">
|
||
3 years ago
|
<v-tabs
|
||
|
v-model="databases[panelIndex]"
|
||
|
height="34"
|
||
|
background-color=""
|
||
|
>
|
||
4 years ago
|
<v-tab
|
||
|
v-for="(db, dbIndex) in project.envs[envKey].db"
|
||
|
:key="dbIndex"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small>
|
||
|
mdi-database
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="text-capitalize caption">{{
|
||
4 years ago
|
db.connection.database
|
||
|
}}</span>
|
||
|
</v-tab>
|
||
|
<v-tabs-items v-model="databases[panelIndex]">
|
||
4 years ago
|
<v-tab-item
|
||
3 years ago
|
v-for="(db, dbIndex) in project.envs[envKey]
|
||
|
.db"
|
||
4 years ago
|
:key="dbIndex"
|
||
|
>
|
||
4 years ago
|
<v-card flat>
|
||
|
<!-- <form ref="form" class="pa-3">-->
|
||
|
<v-container class="justify-center">
|
||
4 years ago
|
<v-row style="position: relative">
|
||
|
<v-overlay
|
||
|
v-if="showMonaco[dbIndex]"
|
||
|
absolute
|
||
|
class="monaco-overlay"
|
||
|
>
|
||
4 years ago
|
<v-container fluid class="h-100">
|
||
3 years ago
|
<v-card
|
||
|
style="position: relative"
|
||
|
class="h-100"
|
||
|
>
|
||
4 years ago
|
<v-icon
|
||
|
class="monaco-overlay-close pointer"
|
||
|
color="error"
|
||
3 years ago
|
@click="
|
||
|
$set(
|
||
|
showMonaco,
|
||
|
dbIndex,
|
||
|
false
|
||
|
)
|
||
|
"
|
||
4 years ago
|
>
|
||
4 years ago
|
mdi-close-circle
|
||
|
</v-icon>
|
||
|
|
||
3 years ago
|
<span
|
||
|
class="ml-2 caption grey--text"
|
||
3 years ago
|
>Refer knex documentation
|
||
4 years ago
|
<a
|
||
|
href="https://knexjs.org/#Installation-client"
|
||
|
target="_blank"
|
||
|
class="grey--text"
|
||
3 years ago
|
>here</a>
|
||
|
.</span>
|
||
4 years ago
|
|
||
|
<monaco-json-object-editor
|
||
3 years ago
|
v-model="
|
||
|
project.envs[envKey].db[
|
||
|
dbIndex
|
||
|
]
|
||
|
"
|
||
|
style="
|
||
|
height: calc(100% - 20px);
|
||
|
width: 100%;
|
||
|
"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-card>
|
||
|
</v-container>
|
||
|
</v-overlay>
|
||
|
|
||
|
<v-col cols="4" class="py-0">
|
||
4 years ago
|
<!-- Database Type -->
|
||
4 years ago
|
<v-select
|
||
3 years ago
|
v-model="client[dbIndex]"
|
||
4 years ago
|
v-ge="['project', 'env-db-change']"
|
||
4 years ago
|
class="body-2 db-select"
|
||
|
:items="Object.keys(databaseNames)"
|
||
3 years ago
|
:label="$t('labels.dbType')"
|
||
4 years ago
|
@change="
|
||
|
onDatabaseTypeChanged(
|
||
|
client[dbIndex],
|
||
|
db,
|
||
|
dbIndex,
|
||
|
envKey
|
||
|
)
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template #selection="{ item }">
|
||
4 years ago
|
<v-chip
|
||
|
small
|
||
4 years ago
|
:color="
|
||
|
colors[
|
||
3 years ago
|
Object.keys(
|
||
|
databaseNames
|
||
|
).indexOf(item) %
|
||
3 years ago
|
colors.length
|
||
4 years ago
|
]
|
||
|
"
|
||
|
class=""
|
||
3 years ago
|
>
|
||
|
{{ item }}
|
||
4 years ago
|
</v-chip>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<template
|
||
|
slot="item"
|
||
|
slot-scope="data"
|
||
|
>
|
||
4 years ago
|
<v-chip
|
||
4 years ago
|
:color="
|
||
|
colors[
|
||
3 years ago
|
Object.keys(
|
||
|
databaseNames
|
||
|
).indexOf(data.item) %
|
||
3 years ago
|
colors.length
|
||
4 years ago
|
]
|
||
|
"
|
||
|
class="caption"
|
||
3 years ago
|
>
|
||
|
{{ data.item }}
|
||
4 years ago
|
</v-chip>
|
||
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
4 years ago
|
<!-- SQLite File -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client === 'sqlite3'"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="
|
||
|
db.connection.connection.filename
|
||
|
"
|
||
4 years ago
|
v-ge="['project', 'env-db-file']"
|
||
3 years ago
|
:rules="form.folderRequiredRule"
|
||
3 years ago
|
:label="$t('labels.sqliteFile')"
|
||
4 years ago
|
@click="selectSqliteFile(db)"
|
||
|
>
|
||
3 years ago
|
<v-icon slot="prepend" color="info">
|
||
4 years ago
|
mdi-file-outline
|
||
|
</v-icon>
|
||
|
</v-text-field>
|
||
|
</v-col>
|
||
4 years ago
|
<!-- Host Address -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="db.connection.host"
|
||
4 years ago
|
v-ge="['project', 'env-db-host']"
|
||
4 years ago
|
class="body-2"
|
||
|
:rules="form.requiredRule"
|
||
3 years ago
|
:label="$t('labels.hostAddress')"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
4 years ago
|
<!-- Port Number -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
|
v-model="db.connection.port"
|
||
3 years ago
|
v-ge="['project', 'env-db-port']"
|
||
|
class="body-2"
|
||
3 years ago
|
:label="$t('labels.port')"
|
||
4 years ago
|
:rules="form.portValidationRule"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
4 years ago
|
<!-- Username -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="db.connection.user"
|
||
4 years ago
|
v-ge="['project', 'env-db-user']"
|
||
3 years ago
|
class="body-2"
|
||
4 years ago
|
:rules="form.requiredRule"
|
||
3 years ago
|
:label="$t('labels.username')"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
4 years ago
|
<!-- Password -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
:ref="`password${envKey}`"
|
||
|
v-model="db.connection.password"
|
||
3 years ago
|
v-ge="[
|
||
|
'project',
|
||
|
'env-db-password',
|
||
|
]"
|
||
4 years ago
|
class="body-2 db-password"
|
||
4 years ago
|
:type="
|
||
3 years ago
|
showPass[
|
||
|
`${panelIndex}_${dbIndex}`
|
||
|
]
|
||
4 years ago
|
? 'text'
|
||
|
: 'password'
|
||
|
"
|
||
3 years ago
|
:label="$t('labels.password')"
|
||
3 years ago
|
@dblclick="enableDbEdit++"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template #append>
|
||
4 years ago
|
<v-icon
|
||
|
small
|
||
|
@click="
|
||
|
$set(
|
||
|
showPass,
|
||
|
`${panelIndex}_${dbIndex}`,
|
||
3 years ago
|
!showPass[
|
||
|
`${panelIndex}_${dbIndex}`
|
||
|
]
|
||
4 years ago
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
|
{{
|
||
3 years ago
|
showPass[
|
||
|
`${panelIndex}_${dbIndex}`
|
||
|
]
|
||
|
? "visibility_off"
|
||
|
: "visibility"
|
||
4 years ago
|
}}
|
||
|
</v-icon>
|
||
|
</template>
|
||
|
</v-text-field>
|
||
|
</v-col>
|
||
4 years ago
|
<!-- Database : create if not exists -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
4 years ago
|
<v-text-field
|
||
|
v-model="db.connection.database"
|
||
4 years ago
|
v-ge="['project', 'env-db-name']"
|
||
3 years ago
|
:disabled="edit && enableDbEdit < 2"
|
||
3 years ago
|
class="body-2 database-field"
|
||
|
:rules="form.requiredRule"
|
||
3 years ago
|
:label="
|
||
|
$t('labels.dbCreateIfNotExists')
|
||
|
"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
3 years ago
|
<!-- todo : Schema name -->
|
||
|
<v-col
|
||
|
v-if="db.client === 'mssql' || db.client === 'pg'"
|
||
|
cols="4"
|
||
|
class="py-0"
|
||
|
>
|
||
|
<v-text-field
|
||
|
v-model="schema"
|
||
|
:disabled="edit && enableDbEdit < 2"
|
||
|
class="body-2 database-field"
|
||
|
:rules="form.requiredRule"
|
||
|
:label="
|
||
|
$t('labels.schemaName')
|
||
|
"
|
||
|
/>
|
||
|
</v-col>
|
||
3 years ago
|
<!-- todo : ssl & inflection -->
|
||
3 years ago
|
<v-col
|
||
|
v-if="db.client !== 'sqlite3'"
|
||
3 years ago
|
cols="12"
|
||
3 years ago
|
class=""
|
||
|
>
|
||
4 years ago
|
<v-expansion-panels>
|
||
3 years ago
|
<v-expansion-panel
|
||
|
style="border: 1px solid wheat"
|
||
|
>
|
||
4 years ago
|
<v-expansion-panel-header>
|
||
4 years ago
|
<!-- SSL & Advanced parameters -->
|
||
3 years ago
|
<span
|
||
|
class="grey--text caption"
|
||
3 years ago
|
>{{
|
||
|
$t(
|
||
|
"title.advancedParameters"
|
||
|
)
|
||
|
}}</span>
|
||
4 years ago
|
</v-expansion-panel-header>
|
||
|
<v-expansion-panel-content>
|
||
|
<v-card class="elevation-0">
|
||
|
<v-card-text>
|
||
|
<v-select
|
||
3 years ago
|
v-model="db.ui.sslUse"
|
||
4 years ago
|
class="caption"
|
||
3 years ago
|
:items="
|
||
|
Object.keys(sslUsage)
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template
|
||
|
#item="{ item }"
|
||
|
>
|
||
|
<span class="caption">{{
|
||
|
item
|
||
|
}}</span>
|
||
4 years ago
|
</template>
|
||
|
</v-select>
|
||
|
|
||
|
<v-row class="pa-0 ma-0">
|
||
4 years ago
|
<input
|
||
|
ref="certFilePath"
|
||
3 years ago
|
type="file"
|
||
4 years ago
|
class="d-none"
|
||
|
@change="
|
||
|
readFileContent(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'cert',
|
||
|
dbIndex
|
||
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
4 years ago
|
<!-- Select .cert file -->
|
||
|
<x-btn
|
||
3 years ago
|
v-ge="[
|
||
|
'project',
|
||
|
'env-db-cert',
|
||
|
]"
|
||
3 years ago
|
:tooltip="
|
||
4 years ago
|
$t(
|
||
3 years ago
|
'tooltip.clientCert'
|
||
4 years ago
|
)
|
||
|
"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
3 years ago
|
class="elevation-5"
|
||
4 years ago
|
@click="
|
||
|
selectFile(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'certFilePath',
|
||
|
dbIndex
|
||
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.cert }}
|
||
4 years ago
|
</x-btn>
|
||
4 years ago
|
<!-- Select .key file -->
|
||
|
<input
|
||
|
ref="keyFilePath"
|
||
3 years ago
|
type="file"
|
||
4 years ago
|
class="d-none"
|
||
|
@change="
|
||
3 years ago
|
readFileContent(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'key',
|
||
|
dbIndex
|
||
|
)
|
||
4 years ago
|
"
|
||
3 years ago
|
>
|
||
4 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="[
|
||
|
'project',
|
||
|
'env-db-key',
|
||
|
]"
|
||
3 years ago
|
:tooltip="
|
||
4 years ago
|
$t(
|
||
3 years ago
|
'tooltip.clientKey'
|
||
4 years ago
|
)
|
||
|
"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
3 years ago
|
class="elevation-5"
|
||
4 years ago
|
@click="
|
||
|
selectFile(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'keyFilePath',
|
||
|
dbIndex
|
||
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.key }}
|
||
4 years ago
|
</x-btn>
|
||
4 years ago
|
<!-- Select CA file -->
|
||
|
<input
|
||
|
ref="caFilePath"
|
||
3 years ago
|
type="file"
|
||
4 years ago
|
class="d-none"
|
||
|
@change="
|
||
3 years ago
|
readFileContent(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'ca',
|
||
|
dbIndex
|
||
|
)
|
||
4 years ago
|
"
|
||
3 years ago
|
>
|
||
4 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="[
|
||
|
'project',
|
||
|
'env-db-ca',
|
||
|
]"
|
||
3 years ago
|
:tooltip="
|
||
3 years ago
|
$t('tooltip.clientCA')
|
||
4 years ago
|
"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
|
@click="
|
||
|
selectFile(
|
||
|
db,
|
||
|
'ssl',
|
||
|
'caFilePath',
|
||
|
dbIndex
|
||
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.ca }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-row>
|
||
|
|
||
|
<v-row>
|
||
|
<v-col>
|
||
4 years ago
|
<!-- Inflection - Table name -->
|
||
4 years ago
|
<v-select
|
||
3 years ago
|
v-model="
|
||
|
db.meta.inflection
|
||
|
.table_name
|
||
|
"
|
||
3 years ago
|
:disabled="edit"
|
||
4 years ago
|
class="caption"
|
||
3 years ago
|
:label="
|
||
4 years ago
|
$t(
|
||
3 years ago
|
'labels.inflection.tableName'
|
||
4 years ago
|
)
|
||
|
"
|
||
3 years ago
|
:items="
|
||
|
project.projectType ===
|
||
3 years ago
|
'rest'
|
||
3 years ago
|
? [
|
||
3 years ago
|
'camelize',
|
||
|
'none',
|
||
|
]
|
||
3 years ago
|
: ['camelize']
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template
|
||
|
#item="{ item }"
|
||
|
>
|
||
|
<span
|
||
|
class="caption"
|
||
3 years ago
|
>{{ item }}</span>
|
||
4 years ago
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
4 years ago
|
<!-- Inflection - Column name -->
|
||
4 years ago
|
<v-select
|
||
3 years ago
|
v-model="
|
||
|
db.meta.inflection
|
||
|
.column_name
|
||
|
"
|
||
3 years ago
|
:disabled="edit"
|
||
4 years ago
|
class="caption"
|
||
3 years ago
|
:label="
|
||
4 years ago
|
$t(
|
||
3 years ago
|
'labels.inflection.columnName'
|
||
4 years ago
|
)
|
||
|
"
|
||
3 years ago
|
:items="
|
||
|
project.projectType ===
|
||
3 years ago
|
'rest'
|
||
3 years ago
|
? [
|
||
3 years ago
|
'camelize',
|
||
|
'none',
|
||
|
]
|
||
3 years ago
|
: ['camelize']
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template
|
||
|
#item="{ item }"
|
||
|
>
|
||
|
<span
|
||
|
class="caption"
|
||
3 years ago
|
>{{ item }}</span>
|
||
4 years ago
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
4 years ago
|
<v-col
|
||
3 years ago
|
class="d-flex align-center flex-shrink-1 flex-grow-0"
|
||
4 years ago
|
>
|
||
|
<x-btn
|
||
|
small
|
||
|
btn.class="text-capitalize"
|
||
3 years ago
|
:tooltip="
|
||
4 years ago
|
$t(
|
||
3 years ago
|
'activity.editConnJson'
|
||
4 years ago
|
)
|
||
|
"
|
||
|
outlined
|
||
|
@click="
|
||
|
$set(
|
||
|
showMonaco,
|
||
|
dbIndex,
|
||
3 years ago
|
!showMonaco[
|
||
|
dbIndex
|
||
|
]
|
||
4 years ago
|
)
|
||
|
"
|
||
|
>
|
||
3 years ago
|
<v-icon
|
||
|
small
|
||
|
class="mr-1"
|
||
4 years ago
|
>
|
||
3 years ago
|
mdi-database-edit
|
||
|
</v-icon>
|
||
4 years ago
|
<!-- Edit connection JSON -->
|
||
4 years ago
|
{{
|
||
|
$t(
|
||
3 years ago
|
"activity.editConnJson"
|
||
4 years ago
|
)
|
||
|
}}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-expansion-panel-content>
|
||
|
</v-expansion-panel>
|
||
|
</v-expansion-panels>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
|
||
|
<v-row class="text-right justify-end">
|
||
4 years ago
|
<!-- Test Database Connection -->
|
||
|
<x-btn
|
||
3 years ago
|
v-ge="[
|
||
|
'project',
|
||
|
'env-db-test-connection',
|
||
|
]"
|
||
|
:tooltip="$t('activity.testDbConn')"
|
||
4 years ago
|
outlined
|
||
|
small
|
||
3 years ago
|
@click="
|
||
|
testConnection(
|
||
|
db,
|
||
|
envKey,
|
||
|
panelIndex
|
||
|
)
|
||
|
"
|
||
4 years ago
|
>
|
||
4 years ago
|
<!-- Test Database Connection -->
|
||
3 years ago
|
{{ $t("activity.testDbConn") }}
|
||
4 years ago
|
</x-btn>
|
||
4 years ago
|
<!-- Remove Database from environment -->
|
||
4 years ago
|
<x-btn
|
||
3 years ago
|
v-if="dbIndex"
|
||
|
v-ge="['project', 'env-db-delete']"
|
||
|
:tooltip="
|
||
3 years ago
|
$t('activity.removeDbFromEnv')
|
||
4 years ago
|
"
|
||
|
text
|
||
|
small
|
||
3 years ago
|
@click="
|
||
|
removeDBFromEnv(
|
||
|
db,
|
||
|
envKey,
|
||
|
panelIndex,
|
||
|
dbIndex
|
||
|
)
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-hover v-slot="{ hover }">
|
||
|
<v-icon
|
||
|
:color="hover ? 'error' : 'grey'"
|
||
|
>
|
||
|
mdi-database-remove
|
||
4 years ago
|
</v-icon>
|
||
|
</v-hover>
|
||
|
</x-btn>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
<!-- </form>-->
|
||
|
</v-card>
|
||
|
</v-tab-item>
|
||
|
</v-tabs-items>
|
||
|
</v-tabs>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
</v-expansion-panel-content>
|
||
|
</v-expansion-panel>
|
||
|
</v-expansion-panels>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</div>
|
||
|
</v-card>
|
||
|
</v-form>
|
||
|
</v-col>
|
||
|
<dlgOk
|
||
|
v-if="dialog.show"
|
||
3 years ago
|
:dialog-show="dialog.show"
|
||
|
:mtd-ok="dialog.mtdOk"
|
||
4 years ago
|
:heading="dialog.heading"
|
||
|
:type="dialog.type"
|
||
|
/>
|
||
|
|
||
3 years ago
|
<!-- heading="Connection was successful" -->
|
||
|
<!-- ok-label="Ok & Save Project" -->
|
||
4 years ago
|
<dlg-ok-new
|
||
|
v-model="testSuccess"
|
||
3 years ago
|
:heading="$t('msg.info.dbConnected')"
|
||
|
:ok-label="$t('activity.OkSaveProject')"
|
||
4 years ago
|
type="success"
|
||
3 years ago
|
:btn-attr="{ small: false }"
|
||
|
@ok="createOrUpdateProject"
|
||
4 years ago
|
/>
|
||
|
|
||
|
<textDlgSubmitCancel
|
||
|
v-if="dialogGetEnvName.dialogShow"
|
||
3 years ago
|
:dialog-show="dialogGetEnvName.dialogShow"
|
||
4 years ago
|
:heading="dialogGetEnvName.heading"
|
||
3 years ago
|
:mtd-dialog-submit="mtdDialogGetEnvNameSubmit"
|
||
|
:mtd-dialog-cancel="mtdDialogGetEnvNameCancel"
|
||
4 years ago
|
/>
|
||
|
|
||
3 years ago
|
<div v-if="isTitle && !edit" class="floating-button">
|
||
4 years ago
|
<v-tooltip top>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
4 years ago
|
<v-btn
|
||
3 years ago
|
v-ge="['project', 'save']"
|
||
4 years ago
|
fab
|
||
|
dark
|
||
|
large
|
||
|
tooltip="Scroll to top"
|
||
|
:disabled="!valid || !envStatusValid"
|
||
|
class="primary"
|
||
3 years ago
|
v-on="on"
|
||
4 years ago
|
@click="createOrUpdateProject()"
|
||
|
>
|
||
4 years ago
|
<v-icon>save</v-icon>
|
||
|
</v-btn>
|
||
|
</template>
|
||
4 years ago
|
<span> Save Project </span>
|
||
4 years ago
|
</v-tooltip>
|
||
|
</div>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
<script>
|
||
3 years ago
|
import JSON5 from 'json5'
|
||
4 years ago
|
|
||
3 years ago
|
import { mapGetters, mapActions } from 'vuex'
|
||
|
import Vue from 'vue'
|
||
4 years ago
|
|
||
3 years ago
|
import { v4 as uuidv4 } from 'uuid'
|
||
4 years ago
|
|
||
3 years ago
|
import XBtn from './global/XBtn'
|
||
|
import dlgOk from './utils/DlgOk.vue'
|
||
|
import textDlgSubmitCancel from './utils/DlgTextSubmitCancel'
|
||
3 years ago
|
import MonacoJsonObjectEditor from '@/components/monaco/MonacoJsonObjectEditor'
|
||
3 years ago
|
import ApiOverlay from '~/components/ApiOverlay'
|
||
3 years ago
|
import colors from '@/mixins/colors'
|
||
3 years ago
|
import DlgOkNew from '~/components/utils/DlgOkNew'
|
||
3 years ago
|
import readFile from '@/helpers/fileReader'
|
||
4 years ago
|
|
||
3 years ago
|
const {
|
||
|
uniqueNamesGenerator,
|
||
|
starWars,
|
||
|
adjectives,
|
||
3 years ago
|
animals
|
||
|
} = require('unique-names-generator')
|
||
4 years ago
|
|
||
3 years ago
|
const homeDir = ''
|
||
4 years ago
|
|
||
|
export default {
|
||
|
components: {
|
||
|
DlgOkNew,
|
||
|
ApiOverlay,
|
||
|
MonacoJsonObjectEditor,
|
||
|
XBtn,
|
||
|
dlgOk,
|
||
3 years ago
|
textDlgSubmitCancel
|
||
4 years ago
|
},
|
||
|
mixins: [colors],
|
||
3 years ago
|
layout: 'empty',
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
3 years ago
|
schema: 'public',
|
||
4 years ago
|
testSuccess: false,
|
||
|
projectCreated: false,
|
||
|
allSchemas: false,
|
||
|
showMonaco: [],
|
||
|
smtpConfiguration: {
|
||
3 years ago
|
from: '',
|
||
|
options: ''
|
||
4 years ago
|
},
|
||
|
showSecret: false,
|
||
|
loaderMessages: [
|
||
3 years ago
|
'Setting up new database configs',
|
||
|
'Inferring database schema',
|
||
|
'Generating APIs.',
|
||
|
'Generating APIs..',
|
||
|
'Generating APIs...',
|
||
|
'Generating APIs....',
|
||
|
'Please wait',
|
||
|
'Please wait.',
|
||
|
'Please wait..',
|
||
|
'Please wait...',
|
||
|
'Please wait..',
|
||
|
'Please wait.',
|
||
|
'Please wait',
|
||
|
'Please wait.',
|
||
|
'Please wait..',
|
||
|
'Please wait...',
|
||
|
'Please wait..',
|
||
|
'Please wait.',
|
||
|
'Please wait..',
|
||
|
'Please wait...'
|
||
4 years ago
|
],
|
||
3 years ago
|
loaderMessage: '',
|
||
4 years ago
|
projectReloading: false,
|
||
3 years ago
|
enableDbEdit: 0,
|
||
4 years ago
|
authTypes: [
|
||
3 years ago
|
{
|
||
3 years ago
|
text: 'JWT',
|
||
|
value: 'jwt'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
text: 'Master Key',
|
||
|
value: 'masterKey'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
text: 'Middleware',
|
||
|
value: 'middleware'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
text: 'Disabled',
|
||
|
value: 'none'
|
||
|
}
|
||
4 years ago
|
],
|
||
|
projectTypes: [
|
||
3 years ago
|
{
|
||
3 years ago
|
text: 'REST APIs',
|
||
|
value: 'rest',
|
||
|
icon: 'mdi-code-json',
|
||
|
iconColor: 'green'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
text: 'GRAPHQL APIs',
|
||
|
value: 'graphql',
|
||
|
icon: 'mdi-graphql',
|
||
|
iconColor: 'pink'
|
||
|
}
|
||
4 years ago
|
],
|
||
|
|
||
|
showPass: {},
|
||
3 years ago
|
/** ************** START : form related ****************/
|
||
4 years ago
|
form: {
|
||
3 years ago
|
portValidationRule: [v => /^\d+$/.test(v) || 'Not a valid port'],
|
||
|
titleRequiredRule: [v => !!v || 'Title is required'],
|
||
|
requiredRule: [v => !!v || 'Field is required'],
|
||
|
folderRequiredRule: [v => !!v || 'Folder path is required']
|
||
4 years ago
|
},
|
||
|
valid: null,
|
||
|
panel: 0,
|
||
3 years ago
|
client: ['Sqlite'],
|
||
4 years ago
|
baseFolder: homeDir,
|
||
|
|
||
|
tab: null,
|
||
|
env: null,
|
||
|
databases: [],
|
||
3 years ago
|
/** ************** END : form related ****************/
|
||
4 years ago
|
auth: {
|
||
|
authSecret: uuidv4(),
|
||
3 years ago
|
authType: 'jwt',
|
||
|
webhook: null
|
||
4 years ago
|
},
|
||
|
project: {},
|
||
|
defaultProject: {
|
||
3 years ago
|
title: '',
|
||
|
version: '0.6',
|
||
4 years ago
|
folder: homeDir,
|
||
|
envs: {
|
||
3 years ago
|
_noco: {
|
||
4 years ago
|
db: [
|
||
|
{
|
||
3 years ago
|
client: 'pg',
|
||
4 years ago
|
connection: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: 'password',
|
||
|
database: '_dev',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
searchPath: ['public'],
|
||
4 years ago
|
meta: {
|
||
3 years ago
|
tn: 'nc_evolutions',
|
||
|
dbAlias: 'db',
|
||
4 years ago
|
api: {
|
||
3 years ago
|
type: 'rest',
|
||
|
prefix: '',
|
||
|
graphqlDepthLimit: 10
|
||
4 years ago
|
},
|
||
|
inflection: {
|
||
3 years ago
|
table_name: 'camelize',
|
||
|
column_name: 'camelize'
|
||
|
}
|
||
4 years ago
|
},
|
||
|
ui: {
|
||
|
setup: -1,
|
||
|
ssl: {
|
||
3 years ago
|
key: this.$t('labels.clientKey'), // Client Key
|
||
|
cert: this.$t('labels.clientCert'), // Client Cert
|
||
|
ca: this.$t('labels.serverCA') // Server CA
|
||
4 years ago
|
},
|
||
3 years ago
|
sslUse: 'Preferred'
|
||
|
}
|
||
|
}
|
||
4 years ago
|
],
|
||
|
apiClient: {
|
||
3 years ago
|
data: []
|
||
|
}
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
workingEnv: '_noco',
|
||
4 years ago
|
ui: {
|
||
|
envs: {
|
||
3 years ago
|
_noco: {}
|
||
|
}
|
||
4 years ago
|
},
|
||
|
meta: {
|
||
3 years ago
|
version: '0.6',
|
||
|
seedsFolder: 'seeds',
|
||
|
queriesFolder: 'queries',
|
||
|
apisFolder: 'apis',
|
||
|
projectType: 'rest',
|
||
|
type: 'mvc',
|
||
|
language: 'ts'
|
||
4 years ago
|
},
|
||
3 years ago
|
seedsFolder: 'seeds',
|
||
|
queriesFolder: 'queries',
|
||
|
apisFolder: 'apis',
|
||
|
projectType: 'rest',
|
||
|
type: 'mvc',
|
||
|
language: 'ts',
|
||
4 years ago
|
apiClient: {
|
||
3 years ago
|
data: []
|
||
|
}
|
||
4 years ago
|
},
|
||
|
|
||
|
sampleConnectionData: {
|
||
|
Postgres: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: 'password',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
MySQL: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '3306',
|
||
|
user: 'root',
|
||
|
password: 'password',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
Vitess: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '15306',
|
||
|
user: 'root',
|
||
|
password: 'password',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
TiDB: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '4000',
|
||
|
user: 'root',
|
||
|
password: '',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
Yugabyte: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: '',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
CitusDB: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: '',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
CockroachDB: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: '',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
Greenplum: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: '',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
MsSQL: {
|
||
3 years ago
|
host: 'localhost',
|
||
4 years ago
|
port: 1433,
|
||
3 years ago
|
user: 'sa',
|
||
|
password: 'Password123.',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
Oracle: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '1521',
|
||
|
user: 'system',
|
||
|
password: 'Oracle18',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
|
cert: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
Sqlite: {
|
||
3 years ago
|
client: 'sqlite3',
|
||
4 years ago
|
database: homeDir,
|
||
|
connection: {
|
||
3 years ago
|
filename: homeDir
|
||
4 years ago
|
},
|
||
3 years ago
|
useNullAsDefault: true
|
||
|
}
|
||
4 years ago
|
},
|
||
|
dialog: {
|
||
|
show: false,
|
||
3 years ago
|
title: '',
|
||
|
heading: '',
|
||
4 years ago
|
mtdOk: this.testConnectionMethodSubmit,
|
||
3 years ago
|
type: 'primary'
|
||
4 years ago
|
},
|
||
4 years ago
|
// TODO: apply i18n for sslUsage
|
||
3 years ago
|
// See general.no - 5 in en.json
|
||
4 years ago
|
sslUsage: {
|
||
3 years ago
|
No: 'No',
|
||
|
Preferred: 'Preferred',
|
||
|
Required: 'pg',
|
||
|
'Required-CA': 'Required-CA',
|
||
|
'Required-IDENTITY': 'Required-IDENTITY'
|
||
4 years ago
|
},
|
||
3 years ago
|
sslUse: this.$t('general.preferred'), // Preferred
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
key: this.$t('labels.clientKey'), // Client Key
|
||
|
cert: this.$t('labels.clientCert'), // Client Cert
|
||
|
ca: this.$t('labels.serverCA') // Server CA
|
||
4 years ago
|
},
|
||
|
databaseNames: {
|
||
3 years ago
|
MySQL: 'mysql2',
|
||
|
Postgres: 'pg',
|
||
4 years ago
|
// Oracle: "oracledb",
|
||
3 years ago
|
MsSQL: 'mssql',
|
||
|
Sqlite: 'sqlite3'
|
||
4 years ago
|
// Vitess: "mysql2",
|
||
|
// TiDB: "mysql2",
|
||
|
// Yugabyte: "pg",
|
||
|
// CitusDB: "pg",
|
||
|
// CockroachDB: "pg",
|
||
|
// Greenplum: "pg"
|
||
|
},
|
||
|
testDatabaseNames: {
|
||
|
mysql2: null,
|
||
|
mysql: null,
|
||
3 years ago
|
pg: 'postgres',
|
||
|
oracledb: 'xe',
|
||
4 years ago
|
mssql: undefined,
|
||
3 years ago
|
sqlite3: 'a.sqlite'
|
||
4 years ago
|
},
|
||
|
dbIcons: {
|
||
3 years ago
|
Oracle: 'temp/db/oracle.png',
|
||
|
Postgres: 'temp/db/postgre.png',
|
||
|
MySQL: 'temp/db/mysql.png',
|
||
|
MsSQL: 'temp/db/mssql.png',
|
||
|
Sqlite: 'temp/db/sqlite.svg',
|
||
|
Salesforce: 'temp/salesforce-3-569548.webp',
|
||
|
SAP: 'temp/sap.png',
|
||
|
Stripe: 'temp/stripe.svg'
|
||
4 years ago
|
},
|
||
|
dialogGetEnvName: {
|
||
|
dialogShow: false,
|
||
3 years ago
|
heading: 'Enter New Environment Name',
|
||
|
field: 'Environment Name'
|
||
4 years ago
|
},
|
||
|
|
||
|
compErrorMessages: [
|
||
3 years ago
|
this.$t('msg.error.invalidChar'), // Invalid character in folder path
|
||
|
this.$t('msg.error.invalidDbCredentials'), // Invalid database credentials
|
||
|
this.$t('msg.error.unableToConnectToDb'), // Unable to connect to database, please check your database is up
|
||
|
this.$t('msg.error.userDoesntHaveSufficientPermission') // User does not exist or have sufficient permission to create schema
|
||
4 years ago
|
],
|
||
3 years ago
|
compErrorMessage: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
3 years ago
|
isTitle() {
|
||
3 years ago
|
return this.project.title && this.project.title.trim().length
|
||
4 years ago
|
},
|
||
3 years ago
|
envStatusValid() {
|
||
4 years ago
|
return (
|
||
|
this.project.envs &&
|
||
3 years ago
|
Object.values(this.project.envs).every(
|
||
|
this.getEnvironmentStatusAggregatedNew
|
||
|
)
|
||
3 years ago
|
)
|
||
4 years ago
|
},
|
||
3 years ago
|
typeIcon() {
|
||
4 years ago
|
if (this.project.projectType) {
|
||
3 years ago
|
return this.projectTypes.find(
|
||
|
({ value }) => value === this.project.projectType
|
||
3 years ago
|
)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
return {
|
||
3 years ago
|
icon: 'mdi-server',
|
||
|
iconColor: 'primary'
|
||
|
}
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
databaseNamesReverse() {
|
||
3 years ago
|
return Object.entries(this.databaseNames).reduce(
|
||
|
(newObj, [value, key]) => {
|
||
3 years ago
|
newObj[key] = value
|
||
|
return newObj
|
||
3 years ago
|
},
|
||
|
{}
|
||
3 years ago
|
)
|
||
|
}
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async enableAllSchemas() {
|
||
3 years ago
|
this.$toast.info('Enabled all schemas').goAway(3000)
|
||
|
this.allSchemas = true
|
||
4 years ago
|
await this.$axios({
|
||
3 years ago
|
url: 'demo',
|
||
|
baseURL: `${this.$axios.defaults.baseURL}/dashboard`
|
||
|
})
|
||
4 years ago
|
},
|
||
|
|
||
|
...mapActions({
|
||
3 years ago
|
loadProjects: 'project/loadProjects'
|
||
4 years ago
|
}),
|
||
3 years ago
|
onAdvancePanelToggle() {
|
||
4 years ago
|
if (this.$refs.monacoEditor) {
|
||
3 years ago
|
setTimeout(() => this.$refs.monacoEditor.resizeLayout(), 400)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
getProjectEditTooltip() {
|
||
4 years ago
|
// return `Opens ${path.join(this.project.folder, 'config.xc.json')} and edit - its really simple`;
|
||
|
},
|
||
3 years ago
|
openJsonInSystemEditor() {
|
||
4 years ago
|
// shell.openItem(path.join(this.project.folder, 'config.xc.json'));
|
||
|
},
|
||
3 years ago
|
readFileContent(db, obj, key, index) {
|
||
3 years ago
|
readFile(this.$refs[`${key}FilePath`][index], (data) => {
|
||
3 years ago
|
Vue.set(db.connection[obj], key, data)
|
||
|
})
|
||
4 years ago
|
},
|
||
3 years ago
|
selectFile(db, obj, key, index) {
|
||
3 years ago
|
this.$refs[key][index].click()
|
||
4 years ago
|
},
|
||
3 years ago
|
onPanelToggle(panelIndex, envKey) {
|
||
4 years ago
|
this.$nextTick(() => {
|
||
|
if (this.panel !== undefined) {
|
||
3 years ago
|
const panelContainer = this.$refs.panelContainer
|
||
|
const panel = this.$refs[`panel${envKey}`][0].$el
|
||
4 years ago
|
setTimeout(
|
||
|
() =>
|
||
|
(panelContainer.scrollTop =
|
||
|
panel.getBoundingClientRect().top +
|
||
|
panelContainer.scrollTop -
|
||
|
panelContainer.getBoundingClientRect().top -
|
||
|
50),
|
||
|
500
|
||
3 years ago
|
)
|
||
|
setTimeout(() => this.$refs[`password${envKey}`][0].focus())
|
||
4 years ago
|
}
|
||
3 years ago
|
})
|
||
4 years ago
|
},
|
||
3 years ago
|
scrollToTop() {
|
||
3 years ago
|
document.querySelector('html').scrollTop = 0
|
||
4 years ago
|
},
|
||
3 years ago
|
showDBTabInEnvPanel(panelIndex, tabIndex) {
|
||
3 years ago
|
this.panel = panelIndex
|
||
|
Vue.set(this.databases, panelIndex, tabIndex)
|
||
4 years ago
|
},
|
||
3 years ago
|
getProjectJson() {
|
||
4 years ago
|
/**
|
||
|
* remove UI keys within project
|
||
|
*/
|
||
3 years ago
|
const xcConfig = JSON.parse(JSON.stringify(this.project))
|
||
|
delete xcConfig.ui
|
||
4 years ago
|
|
||
3 years ago
|
for (const env in xcConfig.envs) {
|
||
4 years ago
|
for (let i = 0; i < xcConfig.envs[env].db.length; ++i) {
|
||
3 years ago
|
xcConfig.envs[env].db[i].meta.api.type = this.project.projectType
|
||
4 years ago
|
if (
|
||
3 years ago
|
xcConfig.envs[env].db[i].client === 'mysql' ||
|
||
|
xcConfig.envs[env].db[i].client === 'mysql2'
|
||
4 years ago
|
) {
|
||
3 years ago
|
xcConfig.envs[env].db[i].connection.multipleStatements = true
|
||
4 years ago
|
}
|
||
3 years ago
|
this.handleSSL(xcConfig.envs[env].db[i], false)
|
||
|
delete xcConfig.envs[env].db[i].ui
|
||
|
if (this.client[i] === 'Vitess') {
|
||
|
xcConfig.envs[env].db[i].meta.dbtype = 'vitess'
|
||
4 years ago
|
}
|
||
3 years ago
|
if (this.client[i] === 'TiDB') {
|
||
|
xcConfig.envs[env].db[i].meta.dbtype = 'tidb'
|
||
4 years ago
|
}
|
||
3 years ago
|
if (xcConfig.envs[env].db[i].client === 'oracledb') {
|
||
4 years ago
|
xcConfig.envs[env].db[i].pool = {
|
||
4 years ago
|
min: 0,
|
||
3 years ago
|
max: 50
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
xcConfig.envs[env].db[i].acquireConnectionTimeout = 60000
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
const inflectionObj = xcConfig.envs[env].db[i].meta.inflection
|
||
4 years ago
|
|
||
|
if (inflectionObj) {
|
||
3 years ago
|
if (Array.isArray(inflectionObj.table_name)) {
|
||
3 years ago
|
inflectionObj.table_name = inflectionObj.table_name.join(',')
|
||
4 years ago
|
}
|
||
3 years ago
|
if (Array.isArray(inflectionObj.column_name)) {
|
||
3 years ago
|
inflectionObj.column_name = inflectionObj.column_name.join(',')
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
inflectionObj.table_name = inflectionObj.table_name || 'none'
|
||
|
inflectionObj.column_name = inflectionObj.column_name || 'none'
|
||
4 years ago
|
}
|
||
|
|
||
|
if (this.allSchemas) {
|
||
3 years ago
|
delete xcConfig.envs[env].db[i].connection.database
|
||
|
xcConfig.envs[env].db[i].meta.allSchemas = true
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
xcConfig.auth = {}
|
||
4 years ago
|
switch (this.auth.authType) {
|
||
3 years ago
|
case 'jwt':
|
||
4 years ago
|
xcConfig.auth.jwt = {
|
||
|
secret: this.auth.authSecret,
|
||
3 years ago
|
dbAlias:
|
||
3 years ago
|
xcConfig.envs[Object.keys(xcConfig.envs)[0]].db[0].meta.dbAlias
|
||
|
}
|
||
|
break
|
||
|
case 'masterKey':
|
||
4 years ago
|
xcConfig.auth.masterKey = {
|
||
3 years ago
|
secret: this.auth.authSecret
|
||
|
}
|
||
|
sessionStorage.setItem('masterKey', this.auth.authSecret)
|
||
|
break
|
||
|
case 'middleware':
|
||
4 years ago
|
xcConfig.auth.masterKey = {
|
||
3 years ago
|
url: this.auth.webhook
|
||
|
}
|
||
|
break
|
||
4 years ago
|
default:
|
||
3 years ago
|
this.auth.disabled = true
|
||
|
break
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
xcConfig.type = this.$store.state.project.appInfo
|
||
|
? this.$store.state.project.appInfo.type
|
||
3 years ago
|
: 'docker'
|
||
4 years ago
|
|
||
4 years ago
|
if (
|
||
|
this.smtpConfiguration &&
|
||
|
this.smtpConfiguration.from &&
|
||
|
this.smtpConfiguration.options.trim()
|
||
|
) {
|
||
4 years ago
|
try {
|
||
|
xcConfig.mailer = {
|
||
|
options: JSON5.parse(this.smtpConfiguration.options),
|
||
3 years ago
|
from: this.smtpConfiguration.from
|
||
|
}
|
||
|
} catch (e) {
|
||
|
}
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
xcConfig.meta = xcConfig.meta || {}
|
||
4 years ago
|
xcConfig.meta.db = {
|
||
3 years ago
|
client: 'sqlite3',
|
||
4 years ago
|
connection: {
|
||
3 years ago
|
filename: 'xc.db'
|
||
|
}
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
return xcConfig
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
constructProjectJsonFromProject(project) {
|
||
3 years ago
|
const p = project // JSON.parse(JSON.stringify(project.projectJson));
|
||
4 years ago
|
|
||
|
p.ui = {
|
||
|
envs: {
|
||
3 years ago
|
_noco: {}
|
||
|
}
|
||
|
}
|
||
3 years ago
|
for (const env in p.envs) {
|
||
3 years ago
|
let i = 0
|
||
3 years ago
|
for (const db of p.envs[env].db) {
|
||
3 years ago
|
Vue.set(this.client, i++, this.databaseNamesReverse[db.client])
|
||
4 years ago
|
|
||
3 years ago
|
Vue.set(db, 'ui', {
|
||
4 years ago
|
setup: 0,
|
||
|
ssl: {
|
||
3 years ago
|
key: this.$t('labels.clientKey'), // Client Key
|
||
|
cert: this.$t('labels.clientCert'), // Client Cert
|
||
|
ca: this.$t('labels.serverCA') // Server CA
|
||
4 years ago
|
},
|
||
3 years ago
|
sslUse: this.$t('general.preferred') // Preferred
|
||
|
})
|
||
4 years ago
|
}
|
||
|
}
|
||
|
// delete p.projectJson;
|
||
|
|
||
|
if (p.auth) {
|
||
|
if (p.auth.jwt) {
|
||
3 years ago
|
this.auth.authType = 'jwt'
|
||
|
this.auth.authSecret = p.auth.jwt.secret
|
||
4 years ago
|
} else if (p.auth.masterKey) {
|
||
|
if (p.auth.masterKey.secret) {
|
||
3 years ago
|
this.auth.authSecret = p.auth.masterKey.secret
|
||
|
this.auth.authType = 'masterKey'
|
||
4 years ago
|
} else if (p.auth.masterKey.url) {
|
||
3 years ago
|
this.auth.webhook = p.auth.masterKey.url
|
||
|
this.auth.authType = 'middleware'
|
||
4 years ago
|
} else {
|
||
3 years ago
|
this.auth.authType = 'none'
|
||
4 years ago
|
}
|
||
|
} else {
|
||
3 years ago
|
this.auth.authType = 'none'
|
||
4 years ago
|
}
|
||
|
} else {
|
||
3 years ago
|
this.auth.authType = 'none'
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.project = p
|
||
4 years ago
|
if (p.mailer) {
|
||
|
this.smtpConfiguration = {
|
||
|
from: p.mailer.from,
|
||
3 years ago
|
options: JSON.stringify(p.mailer.options, 0, 2)
|
||
|
}
|
||
4 years ago
|
}
|
||
3 years ago
|
delete p.mailer
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
async createOrUpdateProject() {
|
||
3 years ago
|
const projectJson = this.getProjectJson()
|
||
|
delete projectJson.folder
|
||
4 years ago
|
|
||
3 years ago
|
let i = 0
|
||
|
const toast = this.$toast.info(this.loaderMessages[0])
|
||
4 years ago
|
const interv = setInterval(() => {
|
||
3 years ago
|
if (this.edit) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
|
if (i < this.loaderMessages.length - 1) {
|
||
3 years ago
|
i++
|
||
3 years ago
|
}
|
||
4 years ago
|
if (toast) {
|
||
|
if (!this.allSchemas) {
|
||
3 years ago
|
toast.text(this.loaderMessages[i])
|
||
4 years ago
|
} else {
|
||
3 years ago
|
toast.goAway(100)
|
||
4 years ago
|
}
|
||
|
}
|
||
3 years ago
|
}, 1000)
|
||
4 years ago
|
|
||
3 years ago
|
this.projectReloading = true
|
||
4 years ago
|
|
||
3 years ago
|
const con = projectJson.envs._noco.db[0]
|
||
|
if (con.client === 'pg' || con.client === 'mssql') {
|
||
|
con.searchPath = [this.schema]
|
||
3 years ago
|
} else if ('searchPath' in con) {
|
||
|
delete con.searchPath
|
||
3 years ago
|
}
|
||
|
|
||
|
const inflection = (con.meta && con.meta.inflection) || {}
|
||
3 years ago
|
try {
|
||
3 years ago
|
const result = await this.$api.project.create({
|
||
3 years ago
|
title: projectJson.title,
|
||
3 years ago
|
bases: [
|
||
|
{
|
||
|
type: con.client,
|
||
|
config: con,
|
||
|
inflection_column: inflection.column_name,
|
||
3 years ago
|
inflection_table: inflection.table_name
|
||
|
}
|
||
3 years ago
|
],
|
||
3 years ago
|
external: true
|
||
|
})
|
||
3 years ago
|
|
||
3 years ago
|
clearInterval(interv)
|
||
|
toast.goAway(100)
|
||
3 years ago
|
|
||
3 years ago
|
await this.$store.dispatch('project/ActLoadProjectInfo')
|
||
3 years ago
|
|
||
3 years ago
|
this.projectReloading = false
|
||
3 years ago
|
|
||
|
if (!this.edit && !this.allSchemas) {
|
||
|
this.$router.push({
|
||
|
path: `/nc/${result.id}`,
|
||
|
query: {
|
||
3 years ago
|
new: 1
|
||
|
}
|
||
|
})
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
this.projectCreated = true
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast
|
||
|
.error(await this._extractSdkResponseErrorMsg(e))
|
||
3 years ago
|
.goAway(3000)
|
||
|
toast.goAway(0)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.projectReloading = false
|
||
|
this.$e('a:project:create:extdb')
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
mtdDialogGetEnvNameSubmit(envName, cookie) {
|
||
3 years ago
|
this.dialogGetEnvName.dialogShow = false
|
||
4 years ago
|
if (envName in this.project.envs) {
|
||
|
} else {
|
||
4 years ago
|
Vue.set(this.project.envs, envName, {
|
||
|
db: [
|
||
|
{
|
||
3 years ago
|
client: 'pg',
|
||
4 years ago
|
connection: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: 'password',
|
||
|
database: 'new_database'
|
||
4 years ago
|
},
|
||
|
meta: {
|
||
3 years ago
|
tn: 'nc_evolutions',
|
||
|
dbAlias: 'db',
|
||
4 years ago
|
inflection: {
|
||
3 years ago
|
table_name: 'camelize',
|
||
|
column_name: 'camelize'
|
||
4 years ago
|
},
|
||
4 years ago
|
api: {
|
||
3 years ago
|
type: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
4 years ago
|
ui: {
|
||
|
setup: 0,
|
||
|
ssl: {
|
||
3 years ago
|
key: this.$t('labels.clientKey'), // Client Key
|
||
|
cert: this.$t('labels.clientCert'), // Client Cert
|
||
|
ca: this.$t('labels.serverCA') // Server CA
|
||
4 years ago
|
},
|
||
3 years ago
|
sslUse: this.$t('general.preferred') // Preferred
|
||
|
}
|
||
|
}
|
||
4 years ago
|
],
|
||
3 years ago
|
apiClient: { data: [] }
|
||
|
})
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
mtdDialogGetEnvNameCancel() {
|
||
3 years ago
|
this.dialogGetEnvName.dialogShow = false
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
addNewEnvironment() {
|
||
3 years ago
|
this.dialogGetEnvName.dialogShow = true
|
||
4 years ago
|
},
|
||
3 years ago
|
addNewDB(envKey, panelIndex) {
|
||
3 years ago
|
const len = this.project.envs[envKey].db.length
|
||
3 years ago
|
// eslint-disable-next-line no-unused-vars
|
||
3 years ago
|
const lastDbName = `${this.project.title}_${envKey}_${len}`
|
||
3 years ago
|
const dbType = (this.client[len] =
|
||
3 years ago
|
this.client[len] || this.client[len - 1])
|
||
|
const newlyCreatedIndex = this.project.envs[envKey].db.length
|
||
4 years ago
|
const dbAlias =
|
||
|
this.project.envs[envKey].db.length <= 0
|
||
3 years ago
|
? 'db'
|
||
|
: `db${this.project.envs[envKey].db.length + 1}`
|
||
4 years ago
|
this.project.envs[envKey].db.push({
|
||
4 years ago
|
client: this.databaseNames[dbType],
|
||
|
connection: {
|
||
4 years ago
|
...this.sampleConnectionData[dbType],
|
||
3 years ago
|
database: `${this.project.title}_${envKey}_${newlyCreatedIndex + 1}`
|
||
4 years ago
|
},
|
||
4 years ago
|
meta: {
|
||
3 years ago
|
tn: 'nc_evolutions',
|
||
3 years ago
|
dbAlias,
|
||
4 years ago
|
inflection: {
|
||
3 years ago
|
table_name: 'camelize',
|
||
|
column_name: 'camelize'
|
||
4 years ago
|
},
|
||
|
api: {
|
||
3 years ago
|
type: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
ui: {
|
||
|
setup: 0,
|
||
3 years ago
|
sslUse: this.$t('general.preferred'), // Preferred
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
key: this.$t('labels.clientKey'), // Client Key
|
||
|
cert: this.$t('labels.clientCert'), // Client Cert
|
||
|
ca: this.$t('labels.serverCA') // Server CA
|
||
|
}
|
||
|
}
|
||
|
})
|
||
4 years ago
|
// set active tab as newly created
|
||
3 years ago
|
this.databases[panelIndex] = newlyCreatedIndex
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
testConnectionMethodSubmit() {
|
||
3 years ago
|
this.dialog.show = false
|
||
|
},
|
||
|
selectDir(ev) {
|
||
|
},
|
||
|
selectSqliteFile(db) {
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
getDbStatusColor(db) {
|
||
4 years ago
|
switch (db.ui.setup) {
|
||
|
case -1:
|
||
3 years ago
|
return 'red'
|
||
3 years ago
|
|
||
4 years ago
|
case 0:
|
||
3 years ago
|
return 'orange'
|
||
3 years ago
|
|
||
4 years ago
|
case 1:
|
||
3 years ago
|
return 'green'
|
||
3 years ago
|
|
||
4 years ago
|
default:
|
||
3 years ago
|
break
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
getDbStatusTooltip(db) {
|
||
4 years ago
|
switch (db.ui.setup) {
|
||
|
case -1:
|
||
3 years ago
|
return 'DB Connection NOT successful'
|
||
3 years ago
|
|
||
4 years ago
|
case 0:
|
||
3 years ago
|
return 'MySql Database Detected - Test your connection'
|
||
3 years ago
|
|
||
4 years ago
|
case 1:
|
||
3 years ago
|
return 'DB Connection successful'
|
||
3 years ago
|
|
||
4 years ago
|
default:
|
||
3 years ago
|
break
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async newTestConnection(db, env, panelIndex) {
|
||
4 years ago
|
if (
|
||
3 years ago
|
db.connection.host === 'localhost' &&
|
||
4 years ago
|
!this.edit &&
|
||
3 years ago
|
env === '_noco' &&
|
||
4 years ago
|
this.project.envs[env].db.length === 1 &&
|
||
3 years ago
|
this.project.envs[env].db[0].connection.user === 'postgres' &&
|
||
4 years ago
|
this.project.envs[env].db[0].connection.database ===
|
||
3 years ago
|
`${this.project.title}_${env}_${this.project.envs[env].length}`
|
||
4 years ago
|
) {
|
||
3 years ago
|
this.handleSSL(db)
|
||
|
if (db.client === 'sqlite3') {
|
||
|
db.ui.setup = 1
|
||
4 years ago
|
} else {
|
||
|
const c1 = {
|
||
4 years ago
|
connection: {
|
||
|
...db.connection,
|
||
3 years ago
|
...(db.client !== 'pg'
|
||
3 years ago
|
? { database: this.testDatabaseNames[db.client] }
|
||
3 years ago
|
: {})
|
||
4 years ago
|
},
|
||
3 years ago
|
client: db.client
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
|
query: {
|
||
3 years ago
|
skipProjectHasDb: 1
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
'testConnection',
|
||
|
c1
|
||
|
])
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
3 years ago
|
db.ui.setup = 1
|
||
|
let passed = true
|
||
4 years ago
|
/**
|
||
|
* get other environments
|
||
|
* and if host is localhost - test and update connection status
|
||
|
* UI panel close
|
||
|
*/
|
||
|
|
||
3 years ago
|
for (const e in this.project.envs) {
|
||
4 years ago
|
if (e === env) {
|
||
3 years ago
|
// ignore
|
||
4 years ago
|
} else {
|
||
|
const c2 = {
|
||
3 years ago
|
connection: {
|
||
|
...this.project.envs[e].db[0].connection,
|
||
3 years ago
|
database: undefined
|
||
3 years ago
|
},
|
||
3 years ago
|
client: this.project.envs[e].db[0].client
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
this.handleSSL(c2)
|
||
4 years ago
|
|
||
3 years ago
|
const result = await this.sqlMgr.testConnection(c2)
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
3 years ago
|
this.project.envs[e][0].ui.setup = 1
|
||
4 years ago
|
} else {
|
||
3 years ago
|
this.project.envs[e][0].ui.setup = -1
|
||
|
passed = false
|
||
|
break
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (passed) {
|
||
3 years ago
|
this.panel = null
|
||
4 years ago
|
} else {
|
||
4 years ago
|
// Connection was successful
|
||
3 years ago
|
this.dialog.heading = this.$t('msg.info.dbConnected')
|
||
|
this.dialog.type = 'success'
|
||
|
this.dialog.show = true
|
||
4 years ago
|
}
|
||
|
} else {
|
||
3 years ago
|
db.ui.setup = -1
|
||
4 years ago
|
// Connection Failure:
|
||
3 years ago
|
this.dialog.heading =
|
||
3 years ago
|
this.$t('msg.error.dbConnectionFailed') + result.message
|
||
|
this.dialog.type = 'error'
|
||
|
this.dialog.show = true
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
return true
|
||
4 years ago
|
} else {
|
||
3 years ago
|
return false
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
sendAdvancedConfig(connection) {
|
||
3 years ago
|
if (!connection.ssl) {
|
||
3 years ago
|
return false
|
||
3 years ago
|
}
|
||
3 years ago
|
let sendAdvancedConfig = false
|
||
|
const sslOptions = Object.values(connection.ssl).filter(el => !!el)
|
||
4 years ago
|
if (sslOptions[0]) {
|
||
3 years ago
|
sendAdvancedConfig = true
|
||
4 years ago
|
} else {
|
||
|
}
|
||
3 years ago
|
return sendAdvancedConfig
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
handleSSL(db, creating = true) {
|
||
3 years ago
|
const sendAdvancedConfig = this.sendAdvancedConfig(db.connection)
|
||
4 years ago
|
if (!sendAdvancedConfig) {
|
||
3 years ago
|
db.connection.ssl = undefined
|
||
4 years ago
|
}
|
||
|
|
||
|
if (db.connection.ssl) {
|
||
|
}
|
||
|
},
|
||
3 years ago
|
getDatabaseForTestConnection(dbType) {
|
||
|
},
|
||
3 years ago
|
async testConnection(db, env, panelIndex) {
|
||
3 years ago
|
this.$e('a:project:create:extdb:test-connection')
|
||
|
this.$store.commit('notification/MutToggleProgressBar', true)
|
||
4 years ago
|
try {
|
||
4 years ago
|
if (!(await this.newTestConnection(db, env, panelIndex))) {
|
||
3 years ago
|
this.handleSSL(db)
|
||
4 years ago
|
|
||
3 years ago
|
if (db.client === 'sqlite3') {
|
||
|
db.ui.setup = 1
|
||
4 years ago
|
} else {
|
||
|
const c1 = {
|
||
|
connection: {
|
||
4 years ago
|
...db.connection,
|
||
3 years ago
|
...(db.client !== 'pg'
|
||
3 years ago
|
? { database: this.testDatabaseNames[db.client] }
|
||
3 years ago
|
: {})
|
||
4 years ago
|
},
|
||
3 years ago
|
client: db.client
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const result = await this.$api.utils.testConnection(c1)
|
||
4 years ago
|
|
||
4 years ago
|
if (result.code === 0) {
|
||
3 years ago
|
db.ui.setup = 1
|
||
4 years ago
|
// this.dialog.heading = "Connection was successful"
|
||
|
// this.dialog.type = 'success';
|
||
|
// this.dialog.show = true;
|
||
3 years ago
|
this.testSuccess = true
|
||
4 years ago
|
} else {
|
||
3 years ago
|
db.ui.setup = -1
|
||
4 years ago
|
// this.activeDbNode.testConnectionStatus = false;
|
||
3 years ago
|
this.dialog.heading =
|
||
3 years ago
|
this.$t('msg.error.dbConnectionFailed') + result.message
|
||
|
this.dialog.type = 'error'
|
||
|
this.dialog.show = true
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
} finally {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false)
|
||
4 years ago
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
getEnvironmentStatusAggregated(dbs) {
|
||
3 years ago
|
return dbs.every(db => db.ui.setup === 1)
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
getEnvironmentStatusAggregatedNew(dbs) {
|
||
3 years ago
|
return dbs.db.every(db => db.ui.setup === 1)
|
||
4 years ago
|
},
|
||
3 years ago
|
openFirstPanel() {
|
||
3 years ago
|
if (!this.edit) {
|
||
3 years ago
|
this.panel = 0
|
||
3 years ago
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
onDatabaseTypeChanged(client, db1, index, env) {
|
||
3 years ago
|
if (this.databaseNames[client] === 'mssql') {
|
||
|
this.schema = 'dbo'
|
||
|
} else if (this.databaseNames[client] === 'pg') {
|
||
|
this.schema = 'public'
|
||
|
}
|
||
|
|
||
3 years ago
|
for (const env in this.project.envs) {
|
||
4 years ago
|
if (this.project.envs[env].db.length > index) {
|
||
3 years ago
|
const db = this.project.envs[env].db[index]
|
||
|
Vue.set(db, 'client', this.databaseNames[client])
|
||
3 years ago
|
|
||
3 years ago
|
if (client !== 'Sqlite') {
|
||
|
const { ssl, ...connectionDet } = this.sampleConnectionData[client]
|
||
|
|
||
|
Vue.set(db, 'connection', {
|
||
4 years ago
|
...connectionDet,
|
||
|
database: `${this.project.title}_${env}_${index + 1}`,
|
||
3 years ago
|
ssl: { ...ssl }
|
||
|
})
|
||
4 years ago
|
|
||
3 years ago
|
for (const env in this.project.envs) {
|
||
4 years ago
|
if (this.project.envs[env].length > index) {
|
||
3 years ago
|
this.setDBStatus(this.project.envs[env][index], 0)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
} else {
|
||
3 years ago
|
db.connection = {}
|
||
|
Vue.set(db, 'connection', {
|
||
|
client: 'sqlite3',
|
||
4 years ago
|
// connection: {filename: path.join(this.project.folder, `${this.project.title}_${env}_${index + 1}`)},
|
||
4 years ago
|
connection: {
|
||
3 years ago
|
filename: [
|
||
|
this.project.folder,
|
||
3 years ago
|
`${this.project.title}_${env}_${index + 1}`
|
||
|
].join('/')
|
||
4 years ago
|
},
|
||
3 years ago
|
database: [
|
||
|
this.project.folder,
|
||
3 years ago
|
`${this.project.title}_${env}_${index + 1}`
|
||
|
].join('/'),
|
||
|
useNullAsDefault: true
|
||
|
})
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
selectDatabaseClient(database, index = 0) {
|
||
3 years ago
|
if (this.client) {
|
||
3 years ago
|
this.client[index] = database
|
||
3 years ago
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
setDBStatus(db, status) {
|
||
3 years ago
|
db.ui.setup = status
|
||
4 years ago
|
},
|
||
3 years ago
|
removeDBFromEnv(db, env, panelIndex, dbIndex) {
|
||
3 years ago
|
for (const env in this.project.envs) {
|
||
4 years ago
|
if (this.project.envs[env].db.length > dbIndex) {
|
||
3 years ago
|
this.project.envs[env].db.splice(dbIndex, 1)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
},
|
||
3 years ago
|
removeEnv(envKey) {
|
||
3 years ago
|
delete this.project.envs[envKey]
|
||
|
Vue.set(this.project, 'envs', { ...this.project.envs })
|
||
|
}
|
||
|
},
|
||
|
fetch({ store, params }) {
|
||
|
},
|
||
|
beforeCreated() {
|
||
3 years ago
|
},
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
'project.title'(newValue, oldValue) {
|
||
3 years ago
|
if (!newValue) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
if (!this.edit) {
|
||
|
// Vue.set(this.project, 'folder', slash(path.join(this.baseFolder, newValue)))
|
||
3 years ago
|
Vue.set(this.project, 'folder', [this.baseFolder, newValue].join('/'))
|
||
3 years ago
|
// }//this.project.folder = `${this.baseFolder}/${newValue}`;
|
||
|
|
||
|
for (const env in this.project.envs) {
|
||
|
for (const [index, db] of this.project.envs[env].db.entries()) {
|
||
|
// db.connection.database = `${this.project.title}_${env}_${index}`
|
||
3 years ago
|
if (db.client !== 'sqlite3') {
|
||
3 years ago
|
Vue.set(
|
||
|
db.connection,
|
||
3 years ago
|
'database',
|
||
3 years ago
|
`${this.project.title}_${env}_${index + 1}`
|
||
3 years ago
|
)
|
||
3 years ago
|
} else {
|
||
3 years ago
|
Vue.set(
|
||
|
db.connection,
|
||
3 years ago
|
'database',
|
||
3 years ago
|
`${this.project.title}_${env}_${index + 1}`
|
||
3 years ago
|
)
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
'project.envs': {
|
||
3 years ago
|
deep: true,
|
||
3 years ago
|
handler(envs) {
|
||
3 years ago
|
if (typeof envs === 'object' && envs) {
|
||
3 years ago
|
Object.entries(envs).forEach(([key, env]) => {
|
||
3 years ago
|
let res = 1
|
||
|
const msg = {}
|
||
3 years ago
|
for (const db of env.db) {
|
||
3 years ago
|
res = db.ui.setup < res ? db.ui.setup : res
|
||
3 years ago
|
}
|
||
|
if (this.edit) {
|
||
3 years ago
|
Vue.set(this.project.ui, key, '')
|
||
3 years ago
|
} else {
|
||
|
switch (res) {
|
||
|
case -1:
|
||
3 years ago
|
msg.color = 'red'
|
||
3 years ago
|
// msg.msg = ' ( Invalid database parameters )'
|
||
3 years ago
|
msg.msg = `( ${this.$t('msg.error.dbConnectionStatus')} )`
|
||
|
break
|
||
3 years ago
|
case 0:
|
||
3 years ago
|
msg.color = 'warning'
|
||
|
msg.msg = ' ( Click to validate database credentials )'
|
||
|
break
|
||
3 years ago
|
case 1:
|
||
3 years ago
|
msg.color = 'green'
|
||
3 years ago
|
// msg.msg = ' ( Environment Validated )'
|
||
3 years ago
|
msg.msg = `( ${this.$t('msg.info.dbConnectionStatus')} )`
|
||
|
break
|
||
3 years ago
|
}
|
||
3 years ago
|
Vue.set(this.project.ui, key, msg)
|
||
3 years ago
|
}
|
||
3 years ago
|
})
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
async created() {
|
||
4 years ago
|
this.compErrorMessage =
|
||
3 years ago
|
this.compErrorMessages[
|
||
|
Math.floor(Math.random() * this.compErrorMessages.length)
|
||
3 years ago
|
]
|
||
4 years ago
|
|
||
|
if (this.edit) {
|
||
|
try {
|
||
3 years ago
|
let data = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
3 years ago
|
null,
|
||
3 years ago
|
'xcProjectGetConfig'
|
||
|
])
|
||
|
data = JSON.parse(data.config)
|
||
|
this.constructProjectJsonFromProject(data)
|
||
|
this.$set(this.project, 'folder', data.folder)
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000)
|
||
4 years ago
|
}
|
||
|
} else {
|
||
3 years ago
|
this.project = JSON.parse(JSON.stringify(this.defaultProject))
|
||
4 years ago
|
// this.edit = false;
|
||
|
|
||
|
/**
|
||
|
* Figure out which databases users has by scanning port numbers
|
||
|
* preference can be - pg | mysql | mssql | oracledb | sqlite
|
||
|
* create this.project based on the database
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
3 years ago
|
let dbsAvailable = [] // await PortScanner.getOpenDbPortsAsList();
|
||
4 years ago
|
// // setting MySQL as default value if no databases are available
|
||
|
// if (!dbsAvailable || !dbsAvailable.length) {
|
||
3 years ago
|
dbsAvailable = ['MySQL']
|
||
4 years ago
|
// }
|
||
|
|
||
3 years ago
|
this.selectDatabaseClient(dbsAvailable[0], 0)
|
||
4 years ago
|
|
||
|
// iterating over environment and setting default connection details based
|
||
|
// on first available database
|
||
3 years ago
|
for (const env in this.project.envs) {
|
||
|
for (const db of this.project.envs[env].db) {
|
||
3 years ago
|
db.client = this.databaseNames[dbsAvailable[0]]
|
||
4 years ago
|
|
||
3 years ago
|
if (db.client === 'sqlite3') {
|
||
4 years ago
|
db.connection = {
|
||
3 years ago
|
...this.sampleConnectionData[dbsAvailable[0]]
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
db.ui.setup = 0
|
||
4 years ago
|
} else {
|
||
|
db.connection = {
|
||
|
...this.sampleConnectionData[dbsAvailable[0]],
|
||
3 years ago
|
ssl: { ...this.sampleConnectionData[dbsAvailable[0]].ssl }
|
||
|
}
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
3 years ago
|
beforeMount() {
|
||
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
this.$set(
|
||
|
this.project,
|
||
3 years ago
|
'title',
|
||
4 years ago
|
uniqueNamesGenerator({
|
||
3 years ago
|
dictionaries: [[starWars], [adjectives, animals]][
|
||
|
Math.floor(Math.random() * 2)
|
||
3 years ago
|
]
|
||
4 years ago
|
})
|
||
|
.toLowerCase()
|
||
3 years ago
|
.replace(/[ -]/g, '_')
|
||
|
)
|
||
4 years ago
|
|
||
|
this.$nextTick(() => {
|
||
3 years ago
|
const input = this.$refs.name.$el.querySelector('input')
|
||
|
input.setSelectionRange(0, this.project.title.length)
|
||
|
input.focus()
|
||
|
})
|
||
|
},
|
||
|
beforeDestroy() {
|
||
|
},
|
||
|
destroy() {
|
||
3 years ago
|
},
|
||
3 years ago
|
validate({ params }) {
|
||
3 years ago
|
return true
|
||
4 years ago
|
},
|
||
3 years ago
|
head() {
|
||
4 years ago
|
return {
|
||
3 years ago
|
title: this.$t('title.headCreateProject')
|
||
|
}
|
||
4 years ago
|
},
|
||
|
props: {
|
||
|
edit: {
|
||
|
type: Boolean,
|
||
3 years ago
|
default: false
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
directives: {}
|
||
|
}
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
.floating-button {
|
||
|
position: fixed;
|
||
|
right: 7%;
|
||
4 years ago
|
bottom: 100px;
|
||
4 years ago
|
}
|
||
|
|
||
|
/deep/ .v-expansion-panel-header {
|
||
|
padding: 0 6px;
|
||
|
min-height: 50px !important;
|
||
|
}
|
||
|
|
||
|
/deep/ .monaco-overlay {
|
||
|
align-items: stretch;
|
||
|
}
|
||
|
|
||
|
/deep/ .monaco-overlay .v-overlay__content {
|
||
|
flex-grow: 1;
|
||
|
}
|
||
|
|
||
|
.monaco-overlay-close {
|
||
|
position: absolute;
|
||
|
right: 10px;
|
||
|
top: 10px;
|
||
|
z-index: 999;
|
||
|
cursor: pointer !important;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
4 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/>.
|
||
|
*
|
||
|
*/
|
||
4 years ago
|
-->
|