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.5 KiB
126 lines
3.5 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">
|
||
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"
|
||
|
/>
|
||
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">
|
||
2 years ago
|
<v-btn :loading="loading" :disabled="!valid" color="primary" @click="createProject">
|
||
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: {
|
||
2 years ago
|
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' },
|
||
2 years ago
|
{ 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
|
}, */
|
||
2 years ago
|
],
|
||
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,
|
||
|
'projectCreateByWebWithXCDB',
|
||
|
{
|
||
|
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,
|
||
|
},
|
||
|
});
|
||
|
this.$emit('change', false);
|
||
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>
|
||
|
|
||
2 years ago
|
<style scoped></style>
|