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.
1662 lines
62 KiB
1662 lines
62 KiB
4 years ago
|
<template>
|
||
|
<v-container fluid>
|
||
|
<v-col class="col-md-8 offset-md-2 col-sm-10 offset-sm-1 col-12" style="position: relative">
|
||
2 years ago
|
<v-form ref="form" v-model="valid" class="mt-8 pt-8">
|
||
|
<v-card ref="mainCard" class="elevation-5">
|
||
4 years ago
|
<div
|
||
2 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"
|
||
|
>
|
||
2 years ago
|
<v-img class="mx-auto" width="60" height="60" :src="require('~/assets/img/icons/512x512-trans.png')" />
|
||
4 years ago
|
</div>
|
||
3 years ago
|
<!-- Create Project -->
|
||
4 years ago
|
<v-toolbar flat color="" class="mb-3" style="width: 100%; border-bottom: 1px solid grey">
|
||
2 years ago
|
<v-toolbar-title class="display-1">
|
||
3 years ago
|
{{ $t('activity.createProject') }}
|
||
4 years ago
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
2 years ago
|
<x-btn v-ge="['project', 'cancel']" tooltip="Cancel and Return" to="/" class="elevation-20">
|
||
3 years ago
|
<!-- Cancel -->
|
||
|
{{ $t('general.cancel') }}
|
||
4 years ago
|
</x-btn>
|
||
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'save']"
|
||
4 years ago
|
:disabled="!valid || !envStatusValid"
|
||
|
class="primary"
|
||
3 years ago
|
@click="createOrUpdateProject()"
|
||
|
>
|
||
4 years ago
|
Save Project
|
||
|
</x-btn>
|
||
|
<v-progress-linear
|
||
|
v-if="projectReloading"
|
||
|
top
|
||
|
absolute
|
||
|
color="success"
|
||
|
indeterminate
|
||
|
height="3"
|
||
2 years ago
|
style="top: -3px"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-toolbar>
|
||
|
|
||
|
<div ref="panelContainer" style="">
|
||
|
<v-overlay v-if="projectReloading" absolute color="grey" opacity="0.4">
|
||
3 years ago
|
<div class="d-flex flex-column justify-center align-center" />
|
||
4 years ago
|
</v-overlay>
|
||
|
<v-container fluid>
|
||
|
<v-row>
|
||
|
<v-col cols="6" offset="3 " class="mb-0 pb-0">
|
||
|
<!-- <div class="ml-7 pb-5" v-if="edit">-->
|
||
|
<!-- <x-btn-->
|
||
|
<!-- :tooltip="getProjectEditTooltip()"-->
|
||
|
<!-- :disabled="!this.edit"-->
|
||
|
<!-- btn.class="primary"-->
|
||
|
<!-- icon="mdi-circle-edit-outline"-->
|
||
|
<!-- @click="openJsonInSystemEditor()">-->
|
||
|
<!-- <p class="pa-0 ma-0"><b>Open Editor</b> <span-->
|
||
|
<!-- class="caption">(to edit Project Json)</span>-->
|
||
|
<!-- </p>-->
|
||
|
<!-- </x-btn>-->
|
||
|
|
||
|
<!-- </div>-->
|
||
|
<v-text-field
|
||
3 years ago
|
v-model="project.title"
|
||
2 years ago
|
v-ge="['project', 'name']"
|
||
3 years ago
|
:rules="form.titleValidationRule"
|
||
3 years ago
|
:height="20"
|
||
|
label="Enter Project Name"
|
||
|
autofocus
|
||
|
>
|
||
2 years ago
|
<v-icon slot="prepend" color="info" class="blink_me"> mdi-lightbulb-on </v-icon>
|
||
4 years ago
|
</v-text-field>
|
||
|
|
||
|
<v-select
|
||
3 years ago
|
v-model="project.projectType"
|
||
|
hint="Choose Project type"
|
||
|
persistent-hint
|
||
|
dense
|
||
|
:items="projectTypes"
|
||
|
>
|
||
|
<template #prepend>
|
||
2 years ago
|
<img v-if="typeIcon.type === 'img'" :src="typeIcon.icon" style="width: 32px" />
|
||
3 years ago
|
<v-icon v-else :color="typeIcon.iconColor">
|
||
|
{{ typeIcon.icon }}
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
2 years ago
|
<template #item="{ item }">
|
||
4 years ago
|
<span class="caption d-flex align-center">
|
||
2 years ago
|
<img v-if="item.type === 'img'" :src="item.icon" style="width: 30px" />
|
||
|
<v-icon v-else :color="item.iconColor">{{ item.icon }}</v-icon> {{ item.text }}</span
|
||
|
>
|
||
4 years ago
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
|
|
||
3 years ago
|
<v-col
|
||
|
v-show="project.title.trim().length"
|
||
|
cols="10"
|
||
|
offset="1"
|
||
2 years ago
|
:class="{ 'mt-0 pt-0': !edit, 'mt-3 pt-3': edit }"
|
||
3 years ago
|
>
|
||
2 years ago
|
<h2 :class="{ 'text-center mb-2': !edit, 'text-center mb-2 grey--text': edit }">
|
||
|
{{ project.title.toUpperCase() }}'s Environments
|
||
3 years ago
|
</h2>
|
||
|
<v-expansion-panels
|
||
|
v-model="panel"
|
||
|
focusable
|
||
|
accordion=""
|
||
|
class="elevation-20"
|
||
|
style="border: 1px solid white"
|
||
|
>
|
||
4 years ago
|
<v-expansion-panel
|
||
2 years ago
|
v-for="(envData, envKey, panelIndex) in project.envs"
|
||
3 years ago
|
:key="panelIndex"
|
||
4 years ago
|
:ref="`panel${envKey}`"
|
||
2 years ago
|
@change="onPanelToggle(panelIndex, envKey)"
|
||
4 years ago
|
>
|
||
|
<v-expansion-panel-header disable-icon-rotate>
|
||
|
<p class="pa-0 ma-0">
|
||
|
<v-icon>mdi-test-tube</v-icon>
|
||
2 years ago
|
<span class="title"
|
||
|
> <b>'{{ envKey }}'</b> environment :
|
||
|
</span>
|
||
|
<v-tooltip v-for="(db, tabIndex) in envData.db" :key="tabIndex" bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<v-icon
|
||
|
small
|
||
|
:color="getDbStatusColor(db)"
|
||
2 years ago
|
@click.native.stop="showDBTabInEnvPanel(panelIndex, tabIndex)"
|
||
3 years ago
|
v-on="on"
|
||
|
>
|
||
|
mdi-database
|
||
4 years ago
|
</v-icon>
|
||
|
</template>
|
||
|
<span>{{ getDbStatusTooltip(db) }}</span>
|
||
|
</v-tooltip>
|
||
|
|
||
3 years ago
|
<span v-if="project.ui[envKey]" class="caption" :class="project.ui[envKey].color + '--text'">
|
||
|
<i>{{ project.ui[envKey].msg }}</i>
|
||
|
</span>
|
||
|
|
||
|
<x-btn
|
||
|
v-if="panelIndex"
|
||
2 years ago
|
v-ge="['project', 'env-delete']"
|
||
3 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)">
|
||
|
mdi-delete
|
||
|
</v-icon>
|
||
|
</v-hover>
|
||
|
</x-btn>
|
||
|
</p>
|
||
3 years ago
|
<template #actions>
|
||
|
<v-tooltip v-if="getEnvironmentStatusAggregated(envData.db)" bottom>
|
||
|
<template #activator="{ on }">
|
||
2 years ago
|
<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 }">
|
||
2 years ago
|
<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="">
|
||
|
<v-tabs v-model="databases[panelIndex]" background-color="">
|
||
2 years ago
|
<v-tab v-for="(db, dbIndex) in project.envs[envKey].db" :key="dbIndex">
|
||
4 years ago
|
<v-icon>mdi-database</v-icon> {{ db.connection.database }}
|
||
|
</v-tab>
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-db-add']"
|
||
3 years ago
|
tooltip="Add New Database to Environment"
|
||
|
text
|
||
|
small
|
||
|
class="ma-2"
|
||
|
v-on="on"
|
||
2 years ago
|
@click.prevent.stop="addNewDB(envKey, panelIndex)"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-hover v-slot="{ hover }">
|
||
2 years ago
|
<v-icon :color="hover ? 'primary' : 'grey'"> mdi-database-plus </v-icon>
|
||
4 years ago
|
</v-hover>
|
||
|
</x-btn>
|
||
|
</template>
|
||
|
<span>Add new database to '{{ envKey }}' environment</span>
|
||
|
</v-tooltip>
|
||
|
|
||
|
<v-tabs-items v-model="databases[panelIndex]">
|
||
2 years ago
|
<v-tab-item v-for="(db, dbIndex) in project.envs[envKey].db" :key="dbIndex">
|
||
4 years ago
|
<v-card flat>
|
||
|
<!-- <form ref="form" class="pa-3">-->
|
||
|
<v-container class="justify-center">
|
||
|
<v-row>
|
||
|
<v-col cols="4" class="py-0">
|
||
|
<v-select
|
||
3 years ago
|
v-model="client[dbIndex]"
|
||
2 years ago
|
v-ge="['project', 'env-db-change']"
|
||
4 years ago
|
class="body-2 db-select"
|
||
|
:items="Object.keys(databaseNames)"
|
||
|
label="Database Type"
|
||
2 years ago
|
@change="onDatabaseTypeChanged(client[dbIndex], db, dbIndex, envKey)"
|
||
4 years ago
|
>
|
||
|
<template slot="item" slot-scope="data">
|
||
|
{{ data.item }}
|
||
|
<!-- <div class="d-flex flex-column mx-auto "-->
|
||
|
<!-- style="width:100%;border-bottom: 1px solid #ddd">-->
|
||
|
<!-- <img class="mx-auto py-3" width="80" :src="dbIcons[data.item]"/>-->
|
||
|
<!-- <!– {{ data.item }}–>-->
|
||
|
|
||
|
<!-- <p v-if="!databaseNames[data.item]" class="text-center grey--text">-->
|
||
|
<!-- Coming soon</p>-->
|
||
|
<!-- </div>-->
|
||
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
|
|
||
3 years ago
|
<v-col v-if="db.client === 'sqlite3'" class="py-0">
|
||
4 years ago
|
<v-text-field
|
||
|
v-model="db.connection.connection.filename"
|
||
2 years ago
|
v-ge="['project', 'env-db-file']"
|
||
3 years ago
|
:rules="form.folderRequiredRule"
|
||
|
label="SQLite File"
|
||
|
@click="selectSqliteFile(db)"
|
||
|
>
|
||
2 years ago
|
<v-icon slot="prepend" color="info"> mdi-file-outline </v-icon>
|
||
4 years ago
|
</v-text-field>
|
||
|
</v-col>
|
||
|
|
||
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"
|
||
2 years ago
|
v-ge="['project', 'env-db-host']"
|
||
4 years ago
|
class="body-2"
|
||
|
:rules="form.requiredRule"
|
||
|
label="Host address"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
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"
|
||
2 years ago
|
v-ge="['project', 'env-db-port']"
|
||
3 years ago
|
class="body-2"
|
||
4 years ago
|
label="Port number"
|
||
|
:rules="form.portValidationRule"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
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"
|
||
2 years ago
|
v-ge="['project', 'env-db-user']"
|
||
3 years ago
|
class="body-2"
|
||
4 years ago
|
:rules="form.requiredRule"
|
||
|
label="Username"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
3 years ago
|
<v-col v-if="db.client !== 'sqlite3'" cols="4" class="py-0">
|
||
4 years ago
|
<v-text-field
|
||
|
:ref="`password${envKey}`"
|
||
|
v-model="db.connection.password"
|
||
2 years ago
|
v-ge="['project', 'env-db-password']"
|
||
3 years ago
|
class="body-2 db-password"
|
||
|
:type="showPass[`${panelIndex}_${dbIndex}`] ? 'text' : 'password'"
|
||
4 years ago
|
label="Password"
|
||
|
>
|
||
3 years ago
|
<template #append>
|
||
|
<v-icon
|
||
|
small
|
||
2 years ago
|
@click="
|
||
|
$set(
|
||
|
showPass,
|
||
|
`${panelIndex}_${dbIndex}`,
|
||
|
!showPass[`${panelIndex}_${dbIndex}`]
|
||
|
)
|
||
|
"
|
||
3 years ago
|
>
|
||
|
{{
|
||
2 years ago
|
showPass[`${panelIndex}_${dbIndex}`] ? 'visibility_off' : 'visibility'
|
||
4 years ago
|
}}
|
||
|
</v-icon>
|
||
|
</template>
|
||
|
</v-text-field>
|
||
|
</v-col>
|
||
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"
|
||
2 years ago
|
v-ge="['project', 'env-db-name']"
|
||
3 years ago
|
class="body-2"
|
||
|
:rules="form.requiredRule"
|
||
4 years ago
|
label="Database : create if not exists"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
3 years ago
|
<v-col v-if="db.client !== 'sqlite3'" class="">
|
||
4 years ago
|
<v-expansion-panels>
|
||
2 years ago
|
<v-expansion-panel style="border: 1px solid wheat">
|
||
4 years ago
|
<v-expansion-panel-header>
|
||
|
<span class="grey--text">SSL / Advanced parameters</span>
|
||
|
</v-expansion-panel-header>
|
||
|
<v-expansion-panel-content>
|
||
|
<v-card class="elevation-0">
|
||
|
<v-card-text>
|
||
2 years ago
|
<v-select v-model="db.ui.sslUse" :items="Object.keys(sslUsage)" />
|
||
4 years ago
|
|
||
|
<v-row class="pa-0 ma-0">
|
||
3 years ago
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-db-cert']"
|
||
3 years ago
|
tooltip="Select .cert file"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
|
class="elevation-5"
|
||
2 years ago
|
@click="selectFile(db, 'ssl', 'certFilePath')"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.cert }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-db-key']"
|
||
3 years ago
|
tooltip="Select .key file"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
|
class="elevation-5"
|
||
2 years ago
|
@click="selectFile(db, 'ssl', 'keyFilePath')"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.key }}
|
||
4 years ago
|
</x-btn>
|
||
|
|
||
3 years ago
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-db-ca']"
|
||
3 years ago
|
tooltip="Select CA file"
|
||
|
small
|
||
|
color="primary"
|
||
|
outlined
|
||
2 years ago
|
@click="selectFile(db, 'ssl', 'caFilePath')"
|
||
3 years ago
|
>
|
||
|
{{ db.ui.ssl.ca }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-row>
|
||
|
|
||
|
<v-row>
|
||
|
<v-col>
|
||
|
<v-select
|
||
3 years ago
|
v-model="db.meta.inflection.table_name"
|
||
4 years ago
|
label="Inflection - Table name"
|
||
|
multiple
|
||
2 years ago
|
:items="['camelize', 'pluralize']"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-col>
|
||
|
<v-col>
|
||
|
<v-select
|
||
3 years ago
|
v-model="db.meta.inflection.column_name"
|
||
4 years ago
|
label="Inflection - Column name"
|
||
|
multiple
|
||
|
:items="['camelize']"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</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">
|
||
3 years ago
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-db-test-connection']"
|
||
3 years ago
|
tooltip="Test Database Connection"
|
||
|
outlined
|
||
|
small
|
||
2 years ago
|
@click="testConnection(db, envKey, panelIndex)"
|
||
3 years ago
|
>
|
||
4 years ago
|
Test Database Connection
|
||
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
|
v-if="dbIndex"
|
||
2 years ago
|
v-ge="['project', 'env-db-delete']"
|
||
3 years ago
|
tooltip="Remove Database from environment"
|
||
|
text
|
||
|
small
|
||
2 years ago
|
@click="removeDBFromEnv(db, envKey, panelIndex, dbIndex)"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-hover v-slot="{ hover }">
|
||
2 years ago
|
<v-icon :color="hover ? 'error' : 'grey'"> mdi-database-remove </v-icon>
|
||
4 years ago
|
</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-panel>
|
||
|
<v-expansion-panel-header disable-icon-rotate>
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<x-btn
|
||
2 years ago
|
v-ge="['project', 'env-add']"
|
||
3 years ago
|
tooltip="Add New Environment to Project"
|
||
|
color="grey"
|
||
|
block
|
||
|
outlined
|
||
|
v-on="on"
|
||
|
@click.stop="addNewEnvironment"
|
||
|
>
|
||
4 years ago
|
<v-icon>mdi-plus</v-icon>
|
||
|
Add Another Environment
|
||
|
</x-btn>
|
||
|
</template>
|
||
|
<span>Add new environment to {{ project.title }} project</span>
|
||
|
</v-tooltip>
|
||
3 years ago
|
<template #actions>
|
||
|
<i />
|
||
4 years ago
|
</template>
|
||
|
</v-expansion-panel-header>
|
||
|
</v-expansion-panel>
|
||
|
</v-expansion-panels>
|
||
|
</v-col>
|
||
|
|
||
3 years ago
|
<v-col
|
||
|
v-show="project.title.trim().length"
|
||
|
cols="10"
|
||
|
offset="1"
|
||
2 years ago
|
:class="{ 'mt-0 pt-0': !edit, 'mt-3 pt-3': edit }"
|
||
3 years ago
|
>
|
||
4 years ago
|
<!-- <h2 :class="{'text-center mb-2':!edit,'text-center mb-2 grey--text':edit}">-->
|
||
|
<!-- Advanced Configuration</h2>-->
|
||
2 years ago
|
<v-expansion-panels focusable accordion="" class="elevation-20" style="border: 1px solid grey">
|
||
3 years ago
|
<v-expansion-panel>
|
||
4 years ago
|
<v-expansion-panel-header disable-icon-rotate>
|
||
|
<p class="pa-0 ma-0">
|
||
2 years ago
|
<v-icon class="mt-n2" color="grey darken-1"> mdi-cog </v-icon>
|
||
4 years ago
|
<span class="grey--text text--darken-1"> Advanced Configuration </span>
|
||
|
</p>
|
||
|
</v-expansion-panel-header>
|
||
|
<v-expansion-panel-content eager>
|
||
|
<v-container class="justify-center">
|
||
|
<v-row>
|
||
|
<v-col cols="12" class="py-0">
|
||
|
<v-select
|
||
3 years ago
|
v-model="auth.authType"
|
||
|
hint="Choose Authentication type"
|
||
|
persistent-hint
|
||
|
dense
|
||
|
:items="authTypes"
|
||
|
>
|
||
2 years ago
|
<template #item="{ item }">
|
||
|
<span class="caption"> {{ item.text }}</span>
|
||
4 years ago
|
</template>
|
||
|
</v-select>
|
||
|
</v-col>
|
||
3 years ago
|
<v-col v-if="auth.authType && auth.authType !== 'none'" cols="12" class="py-0">
|
||
4 years ago
|
<v-text-field
|
||
|
v-if="auth.authType !== 'middleware'"
|
||
|
v-model="auth.authSecret"
|
||
|
label="Enter Auth Secret (Randomly generated)"
|
||
3 years ago
|
:type="showSecret ? 'text' : 'password'"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template #append>
|
||
2 years ago
|
<v-icon small @click="showSecret = !showSecret">
|
||
|
{{ showSecret ? 'visibility_off' : 'visibility' }}
|
||
4 years ago
|
</v-icon>
|
||
|
</template>
|
||
|
</v-text-field>
|
||
2 years ago
|
<v-text-field v-else v-model="auth.webhook" label="Webhook url" />
|
||
4 years ago
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</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"
|
||
|
/>
|
||
|
|
||
|
<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="project.title.trim().length" class="floating-button">
|
||
4 years ago
|
<v-tooltip top>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<v-btn
|
||
2 years ago
|
v-ge="['project', 'save']"
|
||
3 years ago
|
fab
|
||
|
dark
|
||
|
large
|
||
|
tooltip="Scroll to top"
|
||
|
:disabled="!valid || !envStatusValid"
|
||
|
class="primary"
|
||
|
v-on="on"
|
||
|
@click="createOrUpdateProject()"
|
||
|
>
|
||
4 years ago
|
<v-icon>save</v-icon>
|
||
|
</v-btn>
|
||
|
</template>
|
||
2 years ago
|
<span> Save Project </span>
|
||
4 years ago
|
</v-tooltip>
|
||
|
</div>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
<script>
|
||
3 years ago
|
/* eslint-disable */
|
||
4 years ago
|
|
||
2 years ago
|
import { mapGetters, mapActions } from 'vuex';
|
||
|
import Vue from 'vue';
|
||
|
import { v4 as uuidv4 } from 'uuid';
|
||
|
import axios from 'axios';
|
||
|
import textDlgSubmitCancel from '../../components/utils/DlgTextSubmitCancel';
|
||
4 years ago
|
|
||
2 years ago
|
import dlgOk from '../../components/utils/DlgOk.vue';
|
||
|
import XBtn from '../../components/global/XBtn';
|
||
4 years ago
|
|
||
2 years ago
|
const { uniqueNamesGenerator, starWars, adjectives, animals } = require('unique-names-generator');
|
||
4 years ago
|
|
||
2 years ago
|
const homeDir = '';
|
||
4 years ago
|
|
||
|
export default {
|
||
|
components: {
|
||
|
XBtn,
|
||
|
dlgOk,
|
||
2 years ago
|
textDlgSubmitCancel,
|
||
4 years ago
|
},
|
||
3 years ago
|
layout: 'empty',
|
||
2 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
showSecret: false,
|
||
|
loaderMessages: [
|
||
|
'Setting up new database configs',
|
||
|
'Inferring database schema',
|
||
|
'Generating APIs.',
|
||
|
'Generating APIs..',
|
||
|
'Generating APIs...',
|
||
|
'Generating APIs....',
|
||
2 years ago
|
'Please wait...',
|
||
4 years ago
|
],
|
||
|
loaderMessage: '',
|
||
|
projectReloading: false,
|
||
|
authTypes: [
|
||
3 years ago
|
{ text: 'JWT', value: 'jwt' },
|
||
|
{ text: 'Master Key', value: 'masterKey' },
|
||
|
{ text: 'Middleware', value: 'middleware' },
|
||
2 years ago
|
{ text: 'Disabled', value: 'none' },
|
||
4 years ago
|
],
|
||
|
projectTypes: [
|
||
3 years ago
|
{ text: 'Automatic REST APIs on database', value: 'rest', icon: 'mdi-code-json', iconColor: 'green' },
|
||
|
{ text: 'Automatic GRAPHQL APIs on database', value: 'graphql', icon: 'mdi-graphql', iconColor: 'pink' },
|
||
2 years ago
|
{ text: 'Automatic gRPC APIs on database', value: 'grpc', icon: 'grpc-icon-color.png', type: 'img' },
|
||
4 years ago
|
// {
|
||
|
// text: 'Automatic SQL Schema Migrations',
|
||
|
// value: 'migrations',
|
||
|
// icon: 'mdi-database-sync',
|
||
|
// iconColor: 'indigo'
|
||
|
// },
|
||
|
// {text: 'Simple Database Connection', value: 'dbConnection', icon: 'mdi-database', iconColor: 'primary'},
|
||
|
],
|
||
|
|
||
|
showPass: {},
|
||
3 years ago
|
/** ************** START : form related ****************/
|
||
4 years ago
|
form: {
|
||
3 years ago
|
portValidationRule: [v => /^\d+$/.test(v) || 'Not a valid port'],
|
||
3 years ago
|
titleValidationRule: [
|
||
|
v => !!v || 'Title is required',
|
||
|
v => v.length <= 50 || 'Project name exceeds 50 characters',
|
||
|
],
|
||
3 years ago
|
requiredRule: [v => !!v || 'Field is required'],
|
||
2 years ago
|
folderRequiredRule: [v => !!v || 'Folder path is required'],
|
||
4 years ago
|
},
|
||
|
valid: null,
|
||
|
panel: null,
|
||
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(),
|
||
|
authType: 'jwt',
|
||
2 years ago
|
webhook: null,
|
||
4 years ago
|
},
|
||
|
project: {},
|
||
|
defaultProject: {
|
||
|
title: '',
|
||
|
folder: homeDir,
|
||
|
envs: {
|
||
3 years ago
|
_noco: {
|
||
4 years ago
|
db: [
|
||
|
{
|
||
3 years ago
|
client: 'pg',
|
||
|
connection: {
|
||
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: 'password',
|
||
|
database: '_dev',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
2 years ago
|
cert: '',
|
||
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
meta: {
|
||
|
tn: 'nc_evolutions',
|
||
|
dbAlias: 'db',
|
||
4 years ago
|
api: {
|
||
3 years ago
|
type: 'rest',
|
||
|
prefix: '',
|
||
2 years ago
|
graphqlDepthLimit: 10,
|
||
4 years ago
|
},
|
||
|
inflection: {
|
||
2 years ago
|
tn: [],
|
||
|
},
|
||
4 years ago
|
},
|
||
|
ui: {
|
||
|
setup: -1,
|
||
|
ssl: {
|
||
3 years ago
|
key: 'Client Key',
|
||
|
cert: 'Client Cert',
|
||
2 years ago
|
ca: 'Server CA',
|
||
4 years ago
|
},
|
||
2 years ago
|
sslUse: 'Preferred',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
],
|
||
|
apiClient: {
|
||
2 years ago
|
data: [],
|
||
|
},
|
||
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
workingEnv: '_noco',
|
||
4 years ago
|
ui: {
|
||
|
envs: {
|
||
2 years ago
|
_noco: {},
|
||
|
},
|
||
4 years ago
|
},
|
||
|
meta: {
|
||
|
version: '0.5',
|
||
|
seedsFolder: 'seeds',
|
||
|
queriesFolder: 'queries',
|
||
|
apisFolder: 'apis',
|
||
3 years ago
|
projectType: 'rest',
|
||
4 years ago
|
type: 'mvc',
|
||
2 years ago
|
language: 'ts',
|
||
4 years ago
|
},
|
||
|
version: '0.5',
|
||
|
seedsFolder: 'seeds',
|
||
|
queriesFolder: 'queries',
|
||
|
apisFolder: 'apis',
|
||
3 years ago
|
projectType: 'rest',
|
||
4 years ago
|
type: 'mvc',
|
||
|
language: 'ts',
|
||
|
apiClient: {
|
||
2 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: '',
|
||
2 years ago
|
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: '',
|
||
2 years ago
|
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: '',
|
||
2 years ago
|
cert: '',
|
||
|
},
|
||
4 years ago
|
},
|
||
|
MsSQL: {
|
||
3 years ago
|
host: 'localhost',
|
||
|
port: 1433,
|
||
|
user: 'sa',
|
||
|
password: 'Password123.',
|
||
|
database: '_test',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
ca: '',
|
||
|
key: '',
|
||
2 years ago
|
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: '',
|
||
2 years ago
|
cert: '',
|
||
|
},
|
||
4 years ago
|
},
|
||
|
Sqlite: {
|
||
3 years ago
|
client: 'sqlite3',
|
||
4 years ago
|
database: homeDir,
|
||
|
connection: {
|
||
2 years ago
|
filename: homeDir,
|
||
4 years ago
|
},
|
||
2 years ago
|
useNullAsDefault: true,
|
||
|
},
|
||
4 years ago
|
},
|
||
|
|
||
|
edit: false,
|
||
|
dialog: {
|
||
|
show: false,
|
||
|
title: '',
|
||
|
heading: '',
|
||
|
mtdOk: this.testConnectionMethodSubmit,
|
||
2 years ago
|
type: 'primary',
|
||
4 years ago
|
},
|
||
|
sslUsage: {
|
||
3 years ago
|
No: 'No',
|
||
|
Preferred: 'Preferred',
|
||
|
Required: 'pg',
|
||
|
'Required-CA': 'Required-CA',
|
||
2 years ago
|
'Required-IDENTITY': 'Required-IDENTITY',
|
||
4 years ago
|
},
|
||
3 years ago
|
sslUse: 'Preferred',
|
||
4 years ago
|
ssl: {
|
||
3 years ago
|
key: 'Client Key',
|
||
|
cert: 'Client Cert',
|
||
2 years ago
|
ca: 'Server CA',
|
||
4 years ago
|
},
|
||
|
databaseNames: {
|
||
3 years ago
|
MySQL: 'mysql2',
|
||
|
Postgres: 'pg',
|
||
|
Oracle: 'oracledb',
|
||
|
MsSQL: 'mssql',
|
||
2 years ago
|
Sqlite: 'sqlite3',
|
||
4 years ago
|
// 'Google Analytics': '',
|
||
|
// Vitess: "mysql",
|
||
|
// 'Salesforce': '',
|
||
|
// 'SAP': '',
|
||
|
// 'Stripe': '',
|
||
|
},
|
||
|
testDatabaseNames: {
|
||
|
mysql2: null,
|
||
|
mysql: null,
|
||
|
pg: 'postgres',
|
||
|
oracledb: 'xe',
|
||
|
mssql: undefined,
|
||
2 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',
|
||
2 years ago
|
Stripe: 'temp/stripe.svg',
|
||
4 years ago
|
},
|
||
|
dialogGetEnvName: {
|
||
|
dialogShow: false,
|
||
3 years ago
|
heading: 'Enter New Environment Name',
|
||
2 years ago
|
field: 'Environment Name',
|
||
4 years ago
|
},
|
||
|
|
||
|
compErrorMessages: [
|
||
|
'Invalid character in folder path.',
|
||
|
'Invalid database credentials.',
|
||
|
'Unable to connect to database, please check your database is up.',
|
||
2 years ago
|
'User does not exist or have sufficient permission to create schema.',
|
||
4 years ago
|
],
|
||
2 years ago
|
compErrorMessage: '',
|
||
|
};
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
2 years ago
|
envStatusValid() {
|
||
|
return Object.values(this.project.envs).every(this.getEnvironmentStatusAggregatedNew);
|
||
4 years ago
|
},
|
||
2 years ago
|
typeIcon() {
|
||
4 years ago
|
if (this.project.projectType) {
|
||
2 years ago
|
return this.projectTypes.find(({ value }) => value === this.project.projectType);
|
||
4 years ago
|
} else {
|
||
2 years ago
|
return { icon: 'mdi-server', iconColor: 'primary' };
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
databaseNamesReverse() {
|
||
4 years ago
|
return Object.entries(this.databaseNames).reduce((newObj, [value, key]) => {
|
||
2 years ago
|
newObj[key] = value;
|
||
|
return newObj;
|
||
|
}, {});
|
||
|
},
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
|
...mapActions({
|
||
2 years ago
|
loadProjects: 'project/loadProjects',
|
||
4 years ago
|
}),
|
||
|
|
||
2 years ago
|
getProjectEditTooltip() {
|
||
4 years ago
|
// return `Opens ${path.join(this.project.folder, 'config.xc.json')} and edit - its really simple`;
|
||
|
},
|
||
2 years ago
|
openJsonInSystemEditor() {
|
||
4 years ago
|
// shell.openItem(path.join(this.project.folder, 'config.xc.json'));
|
||
|
},
|
||
|
|
||
2 years ago
|
selectFile(db, obj, key) {
|
||
4 years ago
|
// console.log(obj, key);
|
||
3 years ago
|
// const file = dialog.showOpenDialog({
|
||
|
// properties: ['openFile']
|
||
|
// })
|
||
|
// console.log(typeof file, file, typeof file[0])
|
||
|
// if (file && file[0]) {
|
||
|
// const fileName = path.basename(file[0])
|
||
|
// db.ui[obj][key] = fileName
|
||
|
// Vue.set(db.ui[obj], key, fileName)
|
||
|
// // db.connection[obj][key] = file[0].toString();
|
||
|
// Vue.set(db.connection[obj], key, file[0].toString())
|
||
|
// }
|
||
4 years ago
|
},
|
||
2 years ago
|
onPanelToggle(panelIndex, envKey) {
|
||
4 years ago
|
this.$nextTick(() => {
|
||
|
if (this.panel !== undefined) {
|
||
2 years ago
|
const panelContainer = this.$refs.panelContainer;
|
||
|
const panel = this.$refs[`panel${envKey}`][0].$el;
|
||
|
setTimeout(
|
||
|
() =>
|
||
|
(panelContainer.scrollTop =
|
||
|
panel.getBoundingClientRect().top +
|
||
|
panelContainer.scrollTop -
|
||
|
panelContainer.getBoundingClientRect().top -
|
||
|
50),
|
||
|
500
|
||
|
);
|
||
|
setTimeout(() => this.$refs[`password${envKey}`][0].focus());
|
||
4 years ago
|
}
|
||
2 years ago
|
});
|
||
4 years ago
|
},
|
||
2 years ago
|
scrollToTop() {
|
||
|
document.querySelector('html').scrollTop = 0;
|
||
4 years ago
|
},
|
||
2 years ago
|
showDBTabInEnvPanel(panelIndex, tabIndex) {
|
||
|
this.panel = panelIndex;
|
||
|
Vue.set(this.databases, panelIndex, tabIndex);
|
||
4 years ago
|
},
|
||
2 years ago
|
getProjectJson() {
|
||
4 years ago
|
/**
|
||
|
* remove UI keys within project
|
||
|
*/
|
||
2 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) {
|
||
2 years ago
|
xcConfig.envs[env].db[i].meta.api.type = this.project.projectType;
|
||
4 years ago
|
if (xcConfig.envs[env].db[i].client === 'mysql' || xcConfig.envs[env].db[i].client === 'mysql2') {
|
||
2 years ago
|
xcConfig.envs[env].db[i].connection.multipleStatements = true;
|
||
4 years ago
|
}
|
||
2 years ago
|
this.handleSSL(xcConfig.envs[env].db[i], false);
|
||
|
delete xcConfig.envs[env].db[i].ui;
|
||
4 years ago
|
if (this.client[i] === 'Vitess') {
|
||
2 years ago
|
xcConfig.envs[env].db[i].meta.dbtype = 'vitess';
|
||
4 years ago
|
}
|
||
|
if (xcConfig.envs[env].db[i].client === 'oracledb') {
|
||
|
xcConfig.envs[env].db[i].pool = {
|
||
2 years ago
|
min: 0,
|
||
|
max: 50,
|
||
|
};
|
||
4 years ago
|
|
||
2 years ago
|
xcConfig.envs[env].db[i].acquireConnectionTimeout = 60000;
|
||
4 years ago
|
}
|
||
|
|
||
2 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)) {
|
||
2 years ago
|
inflectionObj.table_name = inflectionObj.table_name.join(',');
|
||
4 years ago
|
}
|
||
3 years ago
|
if (Array.isArray(inflectionObj.column_name)) {
|
||
2 years ago
|
inflectionObj.column_name = inflectionObj.column_name.join(',');
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
inflectionObj.table_name = inflectionObj.table_name || 'none';
|
||
|
inflectionObj.column_name = inflectionObj.column_name || 'none';
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
2 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,
|
||
2 years ago
|
dbAlias: xcConfig.envs[Object.keys(xcConfig.envs)[0]].db[0].meta.dbAlias,
|
||
|
};
|
||
|
break;
|
||
3 years ago
|
case 'masterKey':
|
||
4 years ago
|
xcConfig.auth.masterKey = {
|
||
2 years ago
|
secret: this.auth.authSecret,
|
||
|
};
|
||
|
sessionStorage.setItem('admin-secret', this.auth.authSecret);
|
||
|
break;
|
||
3 years ago
|
case 'middleware':
|
||
4 years ago
|
xcConfig.auth.masterKey = {
|
||
2 years ago
|
url: this.auth.webhook,
|
||
|
};
|
||
|
break;
|
||
4 years ago
|
default:
|
||
2 years ago
|
this.auth.disabled = true;
|
||
|
break;
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
xcConfig.type = this.$store.state.project.appInfo ? this.$store.state.project.appInfo.type : 'docker';
|
||
4 years ago
|
|
||
2 years ago
|
return xcConfig;
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
constructProjectJsonFromProject(project) {
|
||
4 years ago
|
// const {projectJson: envs, ...rest} = project;
|
||
|
|
||
|
// let p = {...rest, ...envs};
|
||
2 years ago
|
const p = JSON.parse(JSON.stringify(project.projectJson));
|
||
4 years ago
|
|
||
|
p.ui = {
|
||
|
envs: {
|
||
2 years ago
|
_noco: {},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
for (const env in p.envs) {
|
||
2 years ago
|
let i = 0;
|
||
3 years ago
|
for (const db of p.envs[env].db) {
|
||
2 years ago
|
Vue.set(this.client, i++, this.databaseNamesReverse[db.client]);
|
||
4 years ago
|
|
||
|
Vue.set(db, 'ui', {
|
||
|
setup: 0,
|
||
|
ssl: {
|
||
3 years ago
|
key: 'Client Key',
|
||
|
cert: 'Client Cert',
|
||
2 years ago
|
ca: 'Server CA',
|
||
4 years ago
|
},
|
||
2 years ago
|
sslUse: 'Preferred',
|
||
|
});
|
||
4 years ago
|
}
|
||
|
}
|
||
2 years ago
|
delete p.projectJson;
|
||
4 years ago
|
|
||
|
if (p.auth) {
|
||
|
if (p.auth.jwt) {
|
||
2 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) {
|
||
2 years ago
|
this.auth.authSecret = p.auth.masterKey.secret;
|
||
|
this.auth.authType = 'masterKey';
|
||
4 years ago
|
} else if (p.auth.masterKey.url) {
|
||
2 years ago
|
this.auth.webhook = p.auth.masterKey.url;
|
||
|
this.auth.authType = 'middleware';
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.auth.authType = 'none';
|
||
4 years ago
|
}
|
||
|
} else {
|
||
2 years ago
|
this.auth.authType = 'none';
|
||
4 years ago
|
}
|
||
|
} else {
|
||
2 years ago
|
this.auth.authType = 'none';
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
this.project = p;
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
async createOrUpdateProject() {
|
||
3 years ago
|
// if (this.$store.state.settings.isComp) {
|
||
4 years ago
|
// try {
|
||
3 years ago
|
// ga('send', 'event', 'NewProject.', 'Action failed', this.$store.state.settings.isComp);
|
||
4 years ago
|
// } catch (e) {
|
||
|
// }
|
||
|
// this.$toast.info(this.compErrorMessage).goAway(800);
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
2 years ago
|
const projectJson = this.getProjectJson();
|
||
3 years ago
|
// electron error from this.sqlMgr.projectCreate1 this fn
|
||
4 years ago
|
// Attempting to call a function in a renderer window that has been closed or released.
|
||
|
// const result = await this.sqlMgr.projectCreate1({
|
||
|
// project: {
|
||
|
// title: this.project.title,
|
||
|
// folder: this.project.folder,
|
||
|
// type: 'mysql'
|
||
|
// },
|
||
|
// projectJson
|
||
|
// });
|
||
|
|
||
2 years ago
|
const folder = projectJson.folder;
|
||
|
delete projectJson.folder;
|
||
4 years ago
|
|
||
|
// let result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
|
query: {
|
||
2 years ago
|
skipProjectHasDb: 1,
|
||
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
this.edit ? 'projectUpdateByWeb' : 'projectCreateByWeb',
|
||
4 years ago
|
// "projectCreate1",
|
||
|
{
|
||
|
project: {
|
||
|
title: projectJson.title,
|
||
3 years ago
|
folder: 'config.xc.json', // slash(path.join(folder, 'config.xc.json')),
|
||
2 years ago
|
type: 'pg',
|
||
4 years ago
|
},
|
||
2 years ago
|
projectJson,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
2 years ago
|
this.projectReloading = true;
|
||
4 years ago
|
|
||
2 years ago
|
let i = 0;
|
||
|
const toast = this.$toast.info(this.loaderMessages[0]);
|
||
|
await new Promise(resolve => {
|
||
4 years ago
|
const interv = setInterval(() => {
|
||
2 years ago
|
if (i < this.loaderMessages.length - 1) {
|
||
|
i++;
|
||
|
}
|
||
4 years ago
|
if (toast) {
|
||
2 years ago
|
toast.text(this.loaderMessages[i]);
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
axios
|
||
|
.create({
|
||
|
baseURL: `${this.$axios.defaults.baseURL}/dashboard`,
|
||
|
})
|
||
|
.get('')
|
||
|
.then(() => {
|
||
|
toast.goAway(100);
|
||
|
this.projectReloading = false;
|
||
|
clearInterval(interv);
|
||
|
resolve();
|
||
|
})
|
||
|
.catch(err => {});
|
||
|
}, 1000);
|
||
|
});
|
||
4 years ago
|
|
||
2 years ago
|
await this.$store.dispatch('project/ActLoadProjectInfo');
|
||
4 years ago
|
|
||
3 years ago
|
if (this.$store.state.project.appInfo.firstUser || this.$store.state.project.appInfo.authType === 'masterKey') {
|
||
4 years ago
|
return this.$router.push({
|
||
2 years ago
|
path: '/user/authentication/signup',
|
||
|
});
|
||
4 years ago
|
}
|
||
|
|
||
|
this.$router.push({
|
||
2 years ago
|
path: '/',
|
||
|
});
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
mtdDialogGetEnvNameSubmit(envName, cookie) {
|
||
|
this.dialogGetEnvName.dialogShow = false;
|
||
4 years ago
|
if (envName in this.project.envs) {
|
||
|
} else {
|
||
2 years ago
|
Vue.set(this.project.envs, envName, {
|
||
|
db: [
|
||
|
{
|
||
|
client: 'pg',
|
||
|
connection: {
|
||
|
host: 'localhost',
|
||
|
port: '5432',
|
||
|
user: 'postgres',
|
||
|
password: 'password',
|
||
|
database: 'new_database',
|
||
|
},
|
||
|
meta: {
|
||
|
tn: 'xc_evolutions',
|
||
|
dbAlias: 'db',
|
||
|
inflection: {
|
||
|
tn: [],
|
||
4 years ago
|
},
|
||
2 years ago
|
},
|
||
|
ui: {
|
||
|
setup: 0,
|
||
|
ssl: {
|
||
|
key: 'Client Key',
|
||
|
cert: 'Client Cert',
|
||
|
ca: 'Server CA',
|
||
4 years ago
|
},
|
||
2 years ago
|
sslUse: 'Preferred',
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
apiClient: { data: [] },
|
||
|
});
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
mtdDialogGetEnvNameCancel() {
|
||
|
this.dialogGetEnvName.dialogShow = false;
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
addNewEnvironment() {
|
||
|
this.dialogGetEnvName.dialogShow = true;
|
||
4 years ago
|
},
|
||
2 years ago
|
addNewDB(envKey, panelIndex) {
|
||
|
const len = this.project.envs[envKey].db.length;
|
||
|
const lastDbName = `${this.project.title}_${envKey}_${len}`;
|
||
|
const dbType = (this.client[len] = this.client[len] || this.client[len - 1]);
|
||
|
const newlyCreatedIndex = this.project.envs[envKey].db.length;
|
||
|
const dbAlias = this.project.envs[envKey].db.length <= 0 ? 'db' : `db${this.project.envs[envKey].db.length + 1}`;
|
||
4 years ago
|
this.project.envs[envKey].db.push({
|
||
3 years ago
|
client: this.databaseNames[dbType],
|
||
|
connection: {
|
||
4 years ago
|
...this.sampleConnectionData[dbType],
|
||
2 years ago
|
database: `${this.project.title}_${envKey}_${newlyCreatedIndex + 1}`,
|
||
4 years ago
|
},
|
||
3 years ago
|
meta: {
|
||
|
tn: 'xc_evolutions',
|
||
|
dbAlias,
|
||
4 years ago
|
inflection: {
|
||
2 years ago
|
tn: [],
|
||
4 years ago
|
},
|
||
|
api: {
|
||
2 years ago
|
type: '',
|
||
|
},
|
||
4 years ago
|
},
|
||
|
ui: {
|
||
|
setup: 0,
|
||
|
sslUse: 'Preferred',
|
||
|
ssl: {
|
||
3 years ago
|
key: 'Client Key',
|
||
|
cert: 'Client Cert',
|
||
2 years ago
|
ca: 'Server CA',
|
||
|
},
|
||
|
},
|
||
|
});
|
||
4 years ago
|
// set active tab as newly created
|
||
2 years ago
|
this.databases[panelIndex] = newlyCreatedIndex;
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
testConnectionMethodSubmit() {
|
||
|
this.dialog.show = false;
|
||
4 years ago
|
},
|
||
2 years ago
|
selectDir(ev) {
|
||
4 years ago
|
// console.log(ev)
|
||
|
const file = dialog.showOpenDialog({
|
||
2 years ago
|
properties: ['openDirectory'],
|
||
|
});
|
||
4 years ago
|
if (file && file[0]) {
|
||
2 years ago
|
this.baseFolder = file[0];
|
||
|
this.project.folder = file[0];
|
||
|
this.userSelectedDir = true;
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
selectSqliteFile(db) {
|
||
4 years ago
|
// console.log(ev)
|
||
|
const file = dialog.showOpenDialog({
|
||
2 years ago
|
properties: ['openFile'],
|
||
|
});
|
||
4 years ago
|
if (file && file[0]) {
|
||
2 years ago
|
db.connection.connection.filename = file[0];
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
2 years ago
|
getDbStatusColor(db) {
|
||
4 years ago
|
switch (db.ui.setup) {
|
||
|
case -1:
|
||
2 years ago
|
return 'red';
|
||
|
break;
|
||
4 years ago
|
case 0:
|
||
2 years ago
|
return 'orange';
|
||
|
break;
|
||
4 years ago
|
case 1:
|
||
2 years ago
|
return 'green';
|
||
|
break;
|
||
4 years ago
|
default:
|
||
2 years ago
|
break;
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
2 years ago
|
getDbStatusTooltip(db) {
|
||
4 years ago
|
switch (db.ui.setup) {
|
||
|
case -1:
|
||
2 years ago
|
return 'DB Connection NOT successful';
|
||
|
break;
|
||
4 years ago
|
case 0:
|
||
2 years ago
|
return 'MySql Database Detected - Test your connection';
|
||
|
break;
|
||
4 years ago
|
case 1:
|
||
2 years ago
|
return 'DB Connection successful';
|
||
|
break;
|
||
4 years ago
|
default:
|
||
2 years ago
|
break;
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
async newTestConnection(db, env, panelIndex) {
|
||
|
if (
|
||
|
db.connection.host === 'localhost' &&
|
||
3 years ago
|
!this.edit &&
|
||
3 years ago
|
env === '_noco' &&
|
||
3 years ago
|
this.project.envs[env].db.length === 1 &&
|
||
|
this.project.envs[env].db[0].connection.user === 'postgres' &&
|
||
2 years ago
|
this.project.envs[env].db[0].connection.database ===
|
||
|
`${this.project.title}_${env}_${this.project.envs[env].length}`
|
||
|
) {
|
||
|
this.handleSSL(db);
|
||
4 years ago
|
if (db.client === 'sqlite3') {
|
||
2 years ago
|
db.ui.setup = 1;
|
||
4 years ago
|
} else {
|
||
|
const c1 = {
|
||
3 years ago
|
connection: { ...db.connection, database: this.testDatabaseNames[db.client] },
|
||
2 years ago
|
client: db.client,
|
||
|
};
|
||
4 years ago
|
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
query: {
|
||
|
skipProjectHasDb: 1,
|
||
|
},
|
||
|
},
|
||
|
'testConnection',
|
||
|
c1,
|
||
|
]);
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
2 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) {
|
||
|
} else {
|
||
|
const c2 = {
|
||
3 years ago
|
connection: { ...this.project.envs[e].db[0].connection, database: undefined },
|
||
2 years ago
|
client: this.project.envs[e].db[0].client,
|
||
|
};
|
||
4 years ago
|
|
||
2 years ago
|
this.handleSSL(c2);
|
||
4 years ago
|
|
||
2 years ago
|
const result = await this.sqlMgr.testConnection(c2);
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
2 years ago
|
this.project.envs[e][0].ui.setup = 1;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.project.envs[e][0].ui.setup = -1;
|
||
|
passed = false;
|
||
|
break;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (passed) {
|
||
2 years ago
|
this.panel = null;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.dialog.heading = 'Connection was successful';
|
||
|
this.dialog.type = 'success';
|
||
|
this.dialog.show = true;
|
||
4 years ago
|
}
|
||
|
} else {
|
||
2 years ago
|
db.ui.setup = -1;
|
||
|
this.dialog.heading = 'Connection Failure: \n\n' + result.message;
|
||
|
this.dialog.type = 'error';
|
||
|
this.dialog.show = true;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
return true;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
return false;
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
2 years ago
|
sendAdvancedConfig(connection) {
|
||
|
if (!connection.ssl) {
|
||
|
return false;
|
||
|
}
|
||
|
let sendAdvancedConfig = false;
|
||
|
const sslOptions = Object.values(connection.ssl).filter(el => !!el);
|
||
4 years ago
|
if (sslOptions[0]) {
|
||
2 years ago
|
sendAdvancedConfig = true;
|
||
4 years ago
|
} else {
|
||
|
}
|
||
2 years ago
|
return sendAdvancedConfig;
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
handleSSL(db, creating = true) {
|
||
|
const sendAdvancedConfig = this.sendAdvancedConfig(db.connection);
|
||
4 years ago
|
if (!sendAdvancedConfig) {
|
||
3 years ago
|
// args.ssl = undefined;
|
||
2 years ago
|
db.connection.ssl = undefined;
|
||
4 years ago
|
}
|
||
|
|
||
|
if (db.connection.ssl) {
|
||
|
// db.connection.ssl.caFilePath = db.connection.ssl.ca;
|
||
|
// db.connection.ssl.keyFilePath = db.connection.ssl.key;
|
||
|
// db.connection.ssl.certFilePath = db.connection.ssl.cert;
|
||
|
// if(creating) {
|
||
|
// delete db.connection.ssl.ca;
|
||
|
// delete db.connection.ssl.key;
|
||
|
// delete db.connection.ssl.cert;
|
||
|
// }
|
||
|
}
|
||
|
},
|
||
2 years ago
|
getDatabaseForTestConnection(dbType) {},
|
||
|
async testConnection(db, env, panelIndex) {
|
||
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
4 years ago
|
try {
|
||
2 years ago
|
if (!(await this.newTestConnection(db, env, panelIndex))) {
|
||
4 years ago
|
// this.activeDbNode.testConnectionStatus = false;
|
||
|
//
|
||
|
|
||
2 years ago
|
this.handleSSL(db);
|
||
4 years ago
|
|
||
|
if (db.client === 'sqlite3') {
|
||
2 years ago
|
db.ui.setup = 1;
|
||
4 years ago
|
} else {
|
||
|
const c1 = {
|
||
3 years ago
|
connection: { ...db.connection, database: this.testDatabaseNames[db.client] },
|
||
2 years ago
|
client: db.client,
|
||
|
};
|
||
4 years ago
|
|
||
|
// const result = await this.sqlMgr.testConnection(c1);
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
query: {
|
||
|
skipProjectHasDb: 1,
|
||
|
},
|
||
|
},
|
||
|
'testConnection',
|
||
|
c1,
|
||
|
]);
|
||
4 years ago
|
|
||
|
if (result.code === 0) {
|
||
2 years ago
|
db.ui.setup = 1;
|
||
|
this.dialog.heading = 'Connection was successful';
|
||
|
this.dialog.type = 'success';
|
||
|
this.dialog.show = true;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
db.ui.setup = -1;
|
||
4 years ago
|
// this.activeDbNode.testConnectionStatus = false;
|
||
2 years ago
|
this.dialog.heading = 'Connection Failure: \n\n' + result.message;
|
||
|
this.dialog.type = 'error';
|
||
|
this.dialog.show = true;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
4 years ago
|
} finally {
|
||
2 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
getEnvironmentStatusAggregated(dbs) {
|
||
|
return dbs.every(db => db.ui.setup === 1);
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
getEnvironmentStatusAggregatedNew(dbs) {
|
||
|
return dbs.db.every(db => db.ui.setup === 1);
|
||
4 years ago
|
},
|
||
2 years ago
|
openFirstPanel() {
|
||
|
if (!this.edit) {
|
||
|
this.panel = 0;
|
||
|
}
|
||
4 years ago
|
},
|
||
2 years ago
|
onDatabaseTypeChanged(client, db1, index, env) {
|
||
3 years ago
|
for (const env in this.project.envs) {
|
||
4 years ago
|
if (this.project.envs[env].db.length > index) {
|
||
2 years ago
|
const db = this.project.envs[env].db[index];
|
||
|
Vue.set(db, 'client', this.databaseNames[client]);
|
||
4 years ago
|
if (client !== 'Sqlite') {
|
||
2 years ago
|
const { ssl, ...connectionDet } = this.sampleConnectionData[client];
|
||
4 years ago
|
|
||
|
Vue.set(db, 'connection', {
|
||
|
...connectionDet,
|
||
|
database: `${this.project.title}_${env}_${index + 1}`,
|
||
2 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) {
|
||
2 years ago
|
this.setDBStatus(this.project.envs[env][index], 0);
|
||
4 years ago
|
}
|
||
|
}
|
||
|
} else {
|
||
2 years ago
|
db.connection = {};
|
||
4 years ago
|
Vue.set(db, 'connection', {
|
||
|
client: 'sqlite3',
|
||
|
// connection: {filename: path.join(this.project.folder, `${this.project.title}_${env}_${index + 1}`)},
|
||
3 years ago
|
connection: { filename: [this.project.folder, `${this.project.title}_${env}_${index + 1}`].join('/') },
|
||
4 years ago
|
database: [this.project.folder, `${this.project.title}_${env}_${index + 1}`].join('/'),
|
||
|
// database: path.join(this.project.folder, `${this.project.title}_${env}_${index + 1}`),
|
||
2 years ago
|
useNullAsDefault: true,
|
||
|
});
|
||
4 years ago
|
// Vue.set(db.connection, 'connection', {filename: `${this.project.folder}/${this.project.title}_${env}_${index + 1}`})
|
||
|
// Vue.set(db.connection, 'database', `${this.project.folder}/${this.project.title}_${env}_${index + 1}`)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
2 years ago
|
selectDatabaseClient(database, index = 0) {
|
||
|
if (this.client) {
|
||
|
this.client[index] = database;
|
||
|
}
|
||
4 years ago
|
},
|
||
2 years ago
|
setDBStatus(db, status) {
|
||
|
db.ui.setup = status;
|
||
4 years ago
|
},
|
||
2 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) {
|
||
2 years ago
|
this.project.envs[env].db.splice(dbIndex, 1);
|
||
4 years ago
|
}
|
||
|
}
|
||
|
},
|
||
2 years ago
|
removeEnv(envKey) {
|
||
|
delete this.project.envs[envKey];
|
||
|
Vue.set(this.project, 'envs', { ...this.project.envs });
|
||
|
},
|
||
4 years ago
|
},
|
||
2 years ago
|
fetch({ store, params }) {},
|
||
|
beforeCreated() {},
|
||
3 years ago
|
watch: {
|
||
2 years ago
|
'project.title'(newValue, oldValue) {
|
||
|
if (!newValue) {
|
||
|
return;
|
||
|
}
|
||
3 years ago
|
if (!this.edit) {
|
||
|
// Vue.set(this.project, 'folder', slash(path.join(this.baseFolder, newValue)))
|
||
2 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}`
|
||
|
if (db.client !== 'sqlite3') {
|
||
2 years ago
|
Vue.set(db.connection, 'database', `${this.project.title}_${env}_${index + 1}`);
|
||
3 years ago
|
} else {
|
||
2 years ago
|
Vue.set(db.connection, 'connection', {
|
||
|
filename: path.join(this.project.folder, `${this.project.title}_${env}_${index + 1}`),
|
||
|
});
|
||
|
Vue.set(db.connection, 'database', `${this.project.title}_${env}_${index + 1}`);
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
'project.envs': {
|
||
|
deep: true,
|
||
2 years ago
|
handler(envs) {
|
||
3 years ago
|
Object.entries(envs).forEach(([key, env]) => {
|
||
2 years ago
|
let res = 1;
|
||
|
const msg = {};
|
||
3 years ago
|
for (const db of env.db) {
|
||
2 years ago
|
res = db.ui.setup < res ? db.ui.setup : res;
|
||
3 years ago
|
}
|
||
|
if (this.edit) {
|
||
2 years ago
|
Vue.set(this.project.ui, key, '');
|
||
3 years ago
|
} else {
|
||
|
switch (res) {
|
||
|
case -1:
|
||
2 years ago
|
msg.color = 'red';
|
||
|
msg.msg = ' ( Invalid database parameters )';
|
||
|
break;
|
||
3 years ago
|
case 0:
|
||
2 years ago
|
msg.color = 'warning';
|
||
|
msg.msg = ' ( Click to validate database credentials )';
|
||
|
break;
|
||
3 years ago
|
case 1:
|
||
2 years ago
|
msg.color = 'green';
|
||
|
msg.msg = ' ( Environment Validated )';
|
||
|
break;
|
||
3 years ago
|
}
|
||
2 years ago
|
Vue.set(this.project.ui, key, msg);
|
||
3 years ago
|
}
|
||
2 years ago
|
});
|
||
|
},
|
||
|
},
|
||
3 years ago
|
},
|
||
2 years ago
|
async created() {
|
||
|
this.compErrorMessage = this.compErrorMessages[Math.floor(Math.random() * this.compErrorMessages.length)];
|
||
4 years ago
|
|
||
|
if (this.$route.query && this.$route.query.edit) {
|
||
2 years ago
|
this.edit = true;
|
||
4 years ago
|
// await this.$store.dispatch('sqlMgr/instantiateSqlMgr');
|
||
2 years ago
|
let data = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{ id: this.$route.query.projectId },
|
||
|
'PROJECT_READ_BY_WEB',
|
||
|
]);
|
||
|
data = data.data.list[0];
|
||
|
this.constructProjectJsonFromProject(data);
|
||
|
this.$set(this.project, 'folder', data.folder);
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.project = JSON.parse(JSON.stringify(this.defaultProject));
|
||
|
this.edit = false;
|
||
4 years ago
|
|
||
|
/**
|
||
|
* 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
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
2 years ago
|
let dbsAvailable = []; // await PortScanner.getOpenDbPortsAsList();
|
||
4 years ago
|
// // setting MySQL as default value if no databases are available
|
||
|
// if (!dbsAvailable || !dbsAvailable.length) {
|
||
2 years ago
|
dbsAvailable = ['MySQL'];
|
||
4 years ago
|
// }
|
||
|
|
||
2 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) {
|
||
2 years ago
|
db.client = this.databaseNames[dbsAvailable[0]];
|
||
4 years ago
|
|
||
|
if (db.client === 'sqlite3') {
|
||
|
db.connection = {
|
||
2 years ago
|
...this.sampleConnectionData[dbsAvailable[0]],
|
||
|
};
|
||
4 years ago
|
|
||
2 years ago
|
db.ui.setup = 0;
|
||
4 years ago
|
} else {
|
||
|
db.connection = {
|
||
|
...this.sampleConnectionData[dbsAvailable[0]],
|
||
2 years ago
|
ssl: { ...this.sampleConnectionData[dbsAvailable[0]].ssl },
|
||
|
};
|
||
4 years ago
|
// db.ui.setup = await PortScanner.isAlive(db.connection.host, parseInt(db.connection.port)) ? 0 : -1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// for (let env in this.project.envs) {
|
||
|
// for (let db of this.project.envs[env]) {
|
||
|
// db.ui.setup = await PortScanner.isAlive(db.connection.host, parseInt(db.connection.port)) ? 0 : -1;
|
||
|
// console.log('testing port', env, db.connection.database, db.ui.setup);
|
||
|
// }
|
||
|
// }
|
||
|
}
|
||
|
},
|
||
2 years ago
|
beforeMount() {},
|
||
|
mounted() {
|
||
|
this.$set(
|
||
|
this.project,
|
||
|
'title',
|
||
|
uniqueNamesGenerator({
|
||
|
dictionaries: [[starWars], [adjectives, animals]][Math.floor(Math.random() * 2)],
|
||
|
})
|
||
|
.toLowerCase()
|
||
|
.replace(/[ -]/g, '_')
|
||
|
);
|
||
4 years ago
|
},
|
||
2 years ago
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
|
validate({ params }) {
|
||
|
return true;
|
||
4 years ago
|
},
|
||
2 years ago
|
head() {
|
||
4 years ago
|
return {
|
||
2 years ago
|
title: 'Create Project | XC',
|
||
|
};
|
||
4 years ago
|
},
|
||
|
props: {},
|
||
2 years ago
|
directives: {},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
.floating-button {
|
||
|
position: fixed;
|
||
|
right: 7%;
|
||
2 years ago
|
bottom: 100px;
|
||
4 years ago
|
}
|
||
|
|
||
|
/deep/ .v-expansion-panel-header {
|
||
|
padding: 0 6px;
|
||
|
min-height: 50px !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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|