Fix the logic on database modals
This commit is contained in:
parent
7e89e1bc00
commit
d284083d20
6 changed files with 64 additions and 61 deletions
|
@ -1,10 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<Modal :isVisible="isVisible" :dismissable="!showSpinner" v-on:close="closeModal">
|
||||||
<MessageBox class="alert error mb-6" :message="errorMessage" v-show="errorMessage.length"/>
|
<MessageBox class="alert error mb-6" :message="errorMessage" v-show="errorMessage.length"/>
|
||||||
<h2 class="font-medium text-neutral-900 mb-6">Create a new database</h2>
|
<h2 class="font-medium text-neutral-900 mb-6">Create a new database</h2>
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label class="input-label" for="grid-database-name">Database name</label>
|
<label class="input-label" for="grid-database-name">Database name</label>
|
||||||
<input id="grid-database-name" type="text" class="input" name="database_name" required
|
<input
|
||||||
|
id="grid-database-name" type="text" class="input" name="database_name" required
|
||||||
v-model="database"
|
v-model="database"
|
||||||
v-validate="{ alpha_dash: true, max: 100 }"
|
v-validate="{ alpha_dash: true, max: 100 }"
|
||||||
:class="{ error: errors.has('database_name') }"
|
:class="{ error: errors.has('database_name') }"
|
||||||
|
@ -13,7 +14,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label class="input-label" for="grid-database-remote">Allow connections from</label>
|
<label class="input-label" for="grid-database-remote">Allow connections from</label>
|
||||||
<input id="grid-database-remote" type="text" class="input" name="remote" required
|
<input
|
||||||
|
id="grid-database-remote" type="text" class="input" name="remote" required
|
||||||
v-model="remote"
|
v-model="remote"
|
||||||
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
|
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
|
||||||
:class="{ error: errors.has('remote') }"
|
:class="{ error: errors.has('remote') }"
|
||||||
|
@ -21,8 +23,9 @@
|
||||||
<p class="input-help error" v-show="errors.has('remote')">{{ errors.first('remote') }}</p>
|
<p class="input-help error" v-show="errors.has('remote')">{{ errors.first('remote') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="$emit('close')">Cancel</button>
|
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="closeModal">Cancel</button>
|
||||||
<button class="btn btn-primary btn-sm"
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
:disabled="errors.any() || !canSubmit || showSpinner"
|
:disabled="errors.any() || !canSubmit || showSpinner"
|
||||||
v-on:click="submit"
|
v-on:click="submit"
|
||||||
>
|
>
|
||||||
|
@ -32,17 +35,22 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import MessageBox from "@/components/MessageBox.vue";
|
import MessageBox from "@/components/MessageBox.vue";
|
||||||
import {createDatabase} from "@/api/server/createDatabase";
|
import {createDatabase} from "@/api/server/createDatabase";
|
||||||
|
import Modal from "@/components/core/Modal.vue";
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'CreateDatabaseModal',
|
name: 'CreateDatabaseModal',
|
||||||
components: {MessageBox},
|
components: {Modal, MessageBox},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
isVisible: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
@ -83,6 +91,14 @@
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.showSpinner = false;
|
this.showSpinner = false;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the modal and resets the entry field.
|
||||||
|
*/
|
||||||
|
closeModal: function () {
|
||||||
|
this.showSpinner = false;
|
||||||
|
this.$emit('close');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
<DeleteDatabaseModal
|
<DeleteDatabaseModal
|
||||||
:database="database"
|
:database="database"
|
||||||
:show="showDeleteModal"
|
:isVisible="showDeleteModal"
|
||||||
v-on:close="showDeleteModal = false"
|
v-on:close="showDeleteModal = false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal v-on:close="closeModal" :show="show" :dismissable="!showSpinner">
|
<Modal v-on:close="closeModal" :isVisible="isVisible" :dismissable="!showSpinner">
|
||||||
<transition name="modal">
|
|
||||||
<div>
|
|
||||||
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
|
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
|
||||||
<p class="text-neutral-900 text-sm">This action
|
<p class="text-neutral-900 text-sm">This action
|
||||||
<strong>cannot</strong> be undone. This will permanetly delete the
|
<strong>cannot</strong> be undone. This will permanetly delete the
|
||||||
|
@ -19,8 +17,6 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</transition>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -33,14 +29,8 @@
|
||||||
name: 'DeleteDatabaseModal',
|
name: 'DeleteDatabaseModal',
|
||||||
components: {Modal},
|
components: {Modal},
|
||||||
props: {
|
props: {
|
||||||
show: {
|
isVisible: {type: Boolean, default: false },
|
||||||
type: Boolean,
|
database: { type: Object as () => ServerDatabase, required: true },
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
database: {
|
|
||||||
type: Object as () => ServerDatabase,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal :isVisible="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
|
<Modal :isVisible="visible" v-on:close="onModalClose" :isVisibleCloseIcon="false" :dismissable="!isLoading">
|
||||||
<div>
|
<div>
|
||||||
<label class="input-label">
|
<label class="input-label">
|
||||||
Directory Name
|
Directory Name
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal :isVisible="isVisible" v-on:close="closeModal" :showCloseIcon="false" :dismissable="!isLoading">
|
<Modal :isVisible="isVisible" v-on:close="closeModal" :isVisibleCloseIcon="false" :dismissable="!isLoading">
|
||||||
<MessageBox
|
<MessageBox
|
||||||
class="alert error mb-8"
|
class="alert error mb-8"
|
||||||
title="Error"
|
title="Error"
|
||||||
|
|
|
@ -18,13 +18,11 @@
|
||||||
<div>
|
<div>
|
||||||
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
|
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
|
||||||
</div>
|
</div>
|
||||||
<Modal :isVisible="showCreateModal" v-on:close="showCreateModal = false">
|
|
||||||
<CreateDatabaseModal
|
<CreateDatabaseModal
|
||||||
v-on:close="showCreateModal = false"
|
:isVisible="showCreateModal"
|
||||||
v-on:database="handleModalCallback"
|
v-on:database="handleModalCallback"
|
||||||
v-if="showCreateModal"
|
v-on:close="showCreateModal = false"
|
||||||
/>
|
/>
|
||||||
</modal>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -32,7 +30,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import {filter, map} from 'lodash';
|
import {filter, map} from 'lodash';
|
||||||
import Modal from '@/components/core/Modal.vue';
|
|
||||||
import CreateDatabaseModal from './../components/database/CreateDatabaseModal.vue';
|
import CreateDatabaseModal from './../components/database/CreateDatabaseModal.vue';
|
||||||
import Icon from "@/components/core/Icon.vue";
|
import Icon from "@/components/core/Icon.vue";
|
||||||
import {ServerDatabase} from "@/api/server/types";
|
import {ServerDatabase} from "@/api/server/types";
|
||||||
|
@ -46,7 +43,7 @@
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'ServerDatabases',
|
name: 'ServerDatabases',
|
||||||
components: {DatabaseRow, CreateDatabaseModal, Modal, Icon},
|
components: {DatabaseRow, CreateDatabaseModal, Icon},
|
||||||
|
|
||||||
data: function (): DataStructure {
|
data: function (): DataStructure {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue