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.
99 lines
2.9 KiB
99 lines
2.9 KiB
3 years ago
|
<script lang="ts" setup>
|
||
|
import { ref } from 'vue'
|
||
3 years ago
|
import { navigateTo, useNuxtApp } from '#app'
|
||
3 years ago
|
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
|
||
3 years ago
|
import MaterialSymbolsRocketLaunchOutline from '~icons/material-symbols/rocket-launch-outline'
|
||
3 years ago
|
|
||
|
const name = ref('')
|
||
|
const loading = ref(false)
|
||
|
const valid = ref(false)
|
||
|
|
||
3 years ago
|
const { $api, $toast } = useNuxtApp()
|
||
3 years ago
|
|
||
3 years ago
|
const nameValidationRules = [
|
||
3 years ago
|
(v: string) => !!v || 'Title is required',
|
||
|
(v: string) => v.length <= 50 || 'Project name exceeds 50 characters',
|
||
|
]
|
||
3 years ago
|
|
||
|
const createProject = async () => {
|
||
|
loading.value = true
|
||
|
try {
|
||
3 years ago
|
const result = await $api.project.create({
|
||
3 years ago
|
title: name.value,
|
||
3 years ago
|
})
|
||
3 years ago
|
|
||
3 years ago
|
await navigateTo(`/nc/${result.id}`)
|
||
3 years ago
|
} catch (e: any) {
|
||
3 years ago
|
$toast.error(await extractSdkResponseErrorMsg(e)).goAway(3000)
|
||
3 years ago
|
}
|
||
|
loading.value = false
|
||
|
}
|
||
3 years ago
|
|
||
|
const formState = reactive({
|
||
|
username: '',
|
||
|
password: '',
|
||
|
remember: true,
|
||
|
})
|
||
|
const onFinish = (values: any) => {
|
||
|
console.log('Success:', values)
|
||
|
}
|
||
|
|
||
|
const onFinishFailed = (errorInfo: any) => {
|
||
|
console.log('Failed:', errorInfo)
|
||
|
}
|
||
3 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<template>
|
||
3 years ago
|
<a-card class="w-[500px] mx-auto mt-10">
|
||
|
|
||
|
<h3 class="text-3xl text-center"> {{ $t('activity.createProject') }}</h3>
|
||
|
|
||
|
<a-form
|
||
|
:model="formState"
|
||
|
name="basic"
|
||
|
layout="vertical"
|
||
|
autocomplete="off"
|
||
|
@finish="onFinish"
|
||
|
@finishFailed="onFinishFailed"
|
||
|
>
|
||
|
<a-form-item
|
||
|
:label="$t('labels.projName')"
|
||
|
name="title"
|
||
|
:rules="[{ required: true, message: 'Please input your username!' }]"
|
||
|
>
|
||
|
<a-input class="nc-metadb-project-name" v-model:value="formState.username" />
|
||
|
</a-form-item>
|
||
|
|
||
|
<a-form-item style="text-align: center">
|
||
|
<a-button type="primary" html-type="submit" class="mx-auto flex justify-self-center">
|
||
|
<MaterialSymbolsRocketLaunchOutline class="mr-1" /> <span> {{ $t('general.create') }} </span></a-button
|
||
|
>
|
||
|
</a-form-item>
|
||
|
</a-form>
|
||
|
</a-card>
|
||
|
<!-- <v-form ref="formValidator" v-model="valid" class="h-full" @submit.prevent="createProject">
|
||
3 years ago
|
<v-container fluid class="flex justify-center items-center h-3/4">
|
||
3 years ago
|
<v-card max-width="500">
|
||
|
<v-container class="pb-10 px-12">
|
||
3 years ago
|
<h1 class="my-4 prose-lg text-center">
|
||
3 years ago
|
{{ $t('activity.createProject') }}
|
||
|
</h1>
|
||
|
<div class="mx-auto" style="width: 350px">
|
||
3 years ago
|
<v-text-field
|
||
|
v-model="name"
|
||
|
class="nc-metadb-project-name"
|
||
|
:rules="nameValidationRules"
|
||
|
:label="$t('labels.projName')"
|
||
|
/>
|
||
3 years ago
|
</div>
|
||
|
<v-btn class="mx-auto" large :loading="loading" color="primary" @click="createProject">
|
||
|
<MaterialSymbolsRocketLaunchOutline class="mr-1" />
|
||
|
<span> {{ $t('general.create') }} </span>
|
||
3 years ago
|
</v-btn>
|
||
3 years ago
|
</v-container>
|
||
|
</v-card>
|
||
3 years ago
|
</v-container>
|
||
|
</v-form>
|
||
3 years ago
|
</NuxtLayout> -->
|
||
3 years ago
|
</template>
|