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.
126 lines
3.4 KiB
126 lines
3.4 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<v-dialog :value="value" width="600px">
|
||
4 years ago
|
<v-card>
|
||
|
<v-container fluid>
|
||
3 years ago
|
<v-form ref="form" v-model="valid">
|
||
4 years ago
|
<div style="width:500px" class="mx-auto mt-10">
|
||
|
<v-text-field
|
||
|
ref="input"
|
||
3 years ago
|
v-model="name"
|
||
4 years ago
|
outlined
|
||
|
:full-width="false"
|
||
|
class="caption"
|
||
|
dense
|
||
|
label="Project name"
|
||
|
:rules="[v => !!v || 'Project name required']"
|
||
3 years ago
|
@keyup.enter="createProject"
|
||
|
/>
|
||
4 years ago
|
|
||
3 years ago
|
<div v-for="type in projectTypes" :key="type.text">
|
||
|
<v-radio-group v-model="projectType" hide-details dense>
|
||
4 years ago
|
<v-radio :value="type.value">
|
||
3 years ago
|
<template #label>
|
||
|
<v-icon small :color="type.iconColor">
|
||
|
{{ type.icon }}
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption">{{ type.text }}</span>
|
||
|
</template>
|
||
|
</v-radio>
|
||
|
</v-radio-group>
|
||
|
</div>
|
||
|
|
||
3 years ago
|
<!-- Create Project -->
|
||
4 years ago
|
<div class="text-center">
|
||
|
<v-btn
|
||
|
:loading="loading"
|
||
|
:disabled="!valid"
|
||
3 years ago
|
color="primary"
|
||
4 years ago
|
@click="createProject"
|
||
3 years ago
|
>
|
||
3 years ago
|
{{ $t('activity.createProject') }}
|
||
4 years ago
|
</v-btn>
|
||
|
</div>
|
||
|
</div>
|
||
|
</v-form>
|
||
|
</v-container>
|
||
|
</v-card>
|
||
|
</v-dialog>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
3 years ago
|
name: 'DlgProjectCreate',
|
||
4 years ago
|
props: {
|
||
|
value: Boolean
|
||
3 years ago
|
},
|
||
|
data: () => ({
|
||
4 years ago
|
valid: null,
|
||
|
name: '',
|
||
|
loading: false,
|
||
|
projectType: 'rest',
|
||
|
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' }
|
||
4 years ago
|
/* {
|
||
|
text: 'Automatic gRPC APIs on database',
|
||
|
value: 'grpc',
|
||
|
icon: require('@/assets/img/grpc-icon-color.png'),
|
||
|
type: 'img'
|
||
3 years ago
|
}, */
|
||
|
]
|
||
4 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
3 years ago
|
typeIcon() {
|
||
3 years ago
|
if (this.projectType) {
|
||
|
return this.projectTypes.find(({ value }) => value === this.projectType)
|
||
|
} else {
|
||
|
return { icon: 'mdi-server', iconColor: 'primary' }
|
||
|
}
|
||
|
}
|
||
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
setTimeout(() => {
|
||
|
this.$refs.input.$el.querySelector('input').focus()
|
||
3 years ago
|
}, 100)
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async createProject() {
|
||
4 years ago
|
if (this.$refs.form.validate()) {
|
||
3 years ago
|
this.loading = true
|
||
4 years ago
|
try {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectCreateByWebWithXCDB', {
|
||
4 years ago
|
title: this.name,
|
||
3 years ago
|
projectType: this.projectType
|
||
|
}])
|
||
4 years ago
|
|
||
3 years ago
|
await this.$store.dispatch('project/ActLoadProjectInfo')
|
||
4 years ago
|
|
||
3 years ago
|
this.projectReloading = false
|
||
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({
|
||
3 years ago
|
path: '/user/authentication/signup'
|
||
|
})
|
||
4 years ago
|
}
|
||
|
|
||
|
this.$router.push({
|
||
|
path: `/nc/${result.id}`,
|
||
|
query: {
|
||
|
new: 1
|
||
|
}
|
||
3 years ago
|
})
|
||
4 years ago
|
this.$emit('change', false)
|
||
|
} catch (e) {
|
||
|
this.$toast.error(e.message).goAway(3000)
|
||
|
}
|
||
3 years ago
|
this.loading = false
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
|
||
|
</style>
|