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.
138 lines
3.7 KiB
138 lines
3.7 KiB
4 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-toolbar>
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
Create New Project
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
</v-toolbar>
|
||
|
<v-container>
|
||
3 years ago
|
<v-form ref="form" v-model="valid">
|
||
2 years ago
|
<div style="width: 500px" class="mx-auto mt-10">
|
||
4 years ago
|
<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"
|
||
|
/>
|
||
3 years ago
|
<!--
|
||
4 years ago
|
<v-select
|
||
3 years ago
|
v-model="projectType"
|
||
4 years ago
|
outlined
|
||
|
label="API type"
|
||
3 years ago
|
persistent-hint
|
||
|
dense
|
||
4 years ago
|
class="caption mt-3"
|
||
3 years ago
|
:items="projectTypes"
|
||
|
>
|
||
|
<template #prepend-inner>
|
||
4 years ago
|
<img v-if="typeIcon.type === 'img'" :src="typeIcon.icon" style="width: 25px">
|
||
3 years ago
|
<v-icon v-else :color="typeIcon.iconColor" size="25">
|
||
|
{{ typeIcon.icon }}
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<template #item="{item}">
|
||
|
<span class="caption d-flex align-center">
|
||
|
<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>
|
||
3 years ago
|
</v-select>-->
|
||
4 years ago
|
|
||
3 years ago
|
<!-- Create Project -->
|
||
4 years ago
|
<div class="text-center">
|
||
2 years ago
|
<v-btn :loading="loading" :disabled="!valid" small color="primary" @click="createProject">
|
||
3 years ago
|
{{ $t('activity.createProject') }}
|
||
4 years ago
|
</v-btn>
|
||
|
</div>
|
||
|
</div>
|
||
|
</v-form>
|
||
|
</v-container>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
3 years ago
|
name: 'Name',
|
||
4 years ago
|
data: () => ({
|
||
|
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'),
|
||
2 years ago
|
type: 'img',
|
||
|
},
|
||
|
],
|
||
4 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
3 years ago
|
typeIcon() {
|
||
3 years ago
|
if (this.projectType) {
|
||
2 years ago
|
return this.projectTypes.find(({ value }) => value === this.projectType);
|
||
3 years ago
|
} else {
|
||
2 years ago
|
return { icon: 'mdi-server', iconColor: 'primary' };
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
setTimeout(() => {
|
||
2 years ago
|
this.$refs.input.$el.querySelector('input').focus();
|
||
|
}, 100);
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async createProject() {
|
||
4 years ago
|
if (this.$refs.form.validate()) {
|
||
2 years ago
|
this.loading = true;
|
||
4 years ago
|
try {
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
null,
|
||
|
'projectCreateByOneClick',
|
||
|
{
|
||
|
title: this.name,
|
||
|
projectType: this.projectType,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
2 years ago
|
await this.$store.dispatch('project/ActLoadProjectInfo');
|
||
4 years ago
|
|
||
2 years ago
|
this.projectReloading = false;
|
||
4 years ago
|
|
||
2 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({
|
||
|
path: `/nc/${result.id}`,
|
||
|
query: {
|
||
2 years ago
|
new: 1,
|
||
|
},
|
||
|
});
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.loading = false;
|
||
4 years ago
|
}
|
||
2 years ago
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ label {
|
||
2 years ago
|
font-size: 0.75rem;
|
||
4 years ago
|
}
|
||
|
</style>
|