mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Edit connection
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
<TheFooter />
|
<TheFooter />
|
||||||
<TheNotificationsBoard />
|
<TheNotificationsBoard />
|
||||||
<ModalNewConnection v-if="isNewConnModal" />
|
<ModalNewConnection v-if="isNewConnModal" />
|
||||||
|
<ModalEditConnection v-if="isEditModal" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ import TheNotificationsBoard from '@/components/TheNotificationsBoard';
|
|||||||
import TheAppWelcome from '@/components/TheAppWelcome';
|
import TheAppWelcome from '@/components/TheAppWelcome';
|
||||||
import DatabaseWorkspace from '@/components/DatabaseWorkspace';
|
import DatabaseWorkspace from '@/components/DatabaseWorkspace';
|
||||||
import ModalNewConnection from '@/components/ModalNewConnection';
|
import ModalNewConnection from '@/components/ModalNewConnection';
|
||||||
|
import ModalEditConnection from '@/components/ModalEditConnection';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
@ -34,7 +36,8 @@ export default {
|
|||||||
TheNotificationsBoard,
|
TheNotificationsBoard,
|
||||||
TheAppWelcome,
|
TheAppWelcome,
|
||||||
DatabaseWorkspace,
|
DatabaseWorkspace,
|
||||||
ModalNewConnection
|
ModalNewConnection,
|
||||||
|
ModalEditConnection
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -44,6 +47,7 @@ export default {
|
|||||||
...mapGetters({
|
...mapGetters({
|
||||||
isLoading: 'application/isLoading',
|
isLoading: 'application/isLoading',
|
||||||
isNewConnModal: 'connections/isNewModal',
|
isNewConnModal: 'connections/isNewModal',
|
||||||
|
isEditModal: 'connections/isEditModal',
|
||||||
connections: 'connections/getConnections'
|
connections: 'connections/getConnections'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="modal-container">
|
<div class="modal-container">
|
||||||
<div class="modal-header text-light">
|
<div class="modal-header text-light">
|
||||||
<div class="modal-title h6">
|
<div class="modal-title h6">
|
||||||
Create a new connection
|
Edit connection
|
||||||
</div>
|
</div>
|
||||||
<a class="btn btn-clear c-hand" @click="closeModal" />
|
<a class="btn btn-clear c-hand" @click="closeModal" />
|
||||||
</div>
|
</div>
|
||||||
@ -127,7 +127,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
import Connection from '@/ipc-api/Connection';
|
import Connection from '@/ipc-api/Connection';
|
||||||
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
import ModalAskCredentials from '@/components/ModalAskCredentials';
|
||||||
import BaseToast from '@/components/BaseToast';
|
import BaseToast from '@/components/BaseToast';
|
||||||
@ -138,13 +138,6 @@ export default {
|
|||||||
ModalAskCredentials,
|
ModalAskCredentials,
|
||||||
BaseToast
|
BaseToast
|
||||||
},
|
},
|
||||||
props: {
|
|
||||||
isOpened: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
connection: Object
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
toast: {
|
toast: {
|
||||||
@ -157,10 +150,13 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
connection: 'connections/getSelectedConnection'
|
||||||
|
}),
|
||||||
localConnection: {
|
localConnection: {
|
||||||
get () {
|
get () {
|
||||||
if (this.connectionProxy === null)
|
if (this.connectionProxy === null)
|
||||||
return this.connection;
|
return Object.assign({}, this.connection);
|
||||||
else
|
else
|
||||||
return this.connectionProxy;
|
return this.connectionProxy;
|
||||||
},
|
},
|
||||||
@ -171,6 +167,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
|
closeModal: 'connections/hideEditConnModal',
|
||||||
editConnection: 'connections/editConnection'
|
editConnection: 'connections/editConnection'
|
||||||
}),
|
}),
|
||||||
async startTest () {
|
async startTest () {
|
||||||
@ -180,11 +177,11 @@ export default {
|
|||||||
message: ''
|
message: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.connection.ask)
|
if (this.localConnection.ask)
|
||||||
this.isAsking = true;
|
this.isAsking = true;
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
const res = await Connection.makeTest(this.connection);
|
const res = await Connection.makeTest(this.localConnection);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
this.toast = { status: 'error', message: res.response.message };
|
this.toast = { status: 'error', message: res.response.message };
|
||||||
else
|
else
|
||||||
@ -199,7 +196,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async continueTest (credentials) { // if "Ask for credentials" is true
|
async continueTest (credentials) { // if "Ask for credentials" is true
|
||||||
this.isAsking = false;
|
this.isAsking = false;
|
||||||
const params = Object.assign({}, this.connection, credentials);
|
const params = Object.assign({}, this.localConnection, credentials);
|
||||||
try {
|
try {
|
||||||
const res = await Connection.makeTest(params);
|
const res = await Connection.makeTest(params);
|
||||||
if (res.status === 'error')
|
if (res.status === 'error')
|
||||||
@ -214,12 +211,9 @@ export default {
|
|||||||
this.isTesting = false;
|
this.isTesting = false;
|
||||||
},
|
},
|
||||||
saveEditConnection () {
|
saveEditConnection () {
|
||||||
this.editConnection(this.connection);
|
this.editConnection(this.localConnection);
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
},
|
},
|
||||||
closeModal () {
|
|
||||||
this.$emit('close');
|
|
||||||
},
|
|
||||||
closeAsking () {
|
closeAsking () {
|
||||||
this.isTesting = false;
|
this.isTesting = false;
|
||||||
this.isAsking = false;
|
this.isAsking = false;
|
||||||
|
@ -143,12 +143,6 @@ export default {
|
|||||||
ModalAskCredentials,
|
ModalAskCredentials,
|
||||||
BaseToast
|
BaseToast
|
||||||
},
|
},
|
||||||
props: {
|
|
||||||
isOpened: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
connection: {
|
connection: {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
:context-event="contextEvent"
|
:context-event="contextEvent"
|
||||||
@closeContext="$emit('closeContext')"
|
@closeContext="$emit('closeContext')"
|
||||||
>
|
>
|
||||||
<div class="context-element" @click="showEditModal">
|
<div class="context-element" @click="showEditModal(contextConnection)">
|
||||||
<i class="material-icons md-18 text-light pr-1">edit</i> Edit
|
<i class="material-icons md-18 text-light pr-1">edit</i> Edit
|
||||||
</div>
|
</div>
|
||||||
<div class="context-element" @click="showConfirmModal">
|
<div class="context-element" @click="showConfirmModal">
|
||||||
@ -24,12 +24,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ConfirmModal>
|
</ConfirmModal>
|
||||||
<!-- TODO: move to vuex -->
|
|
||||||
<ModalEditConnection
|
|
||||||
v-if="isEditModal"
|
|
||||||
:connection="contextConnection"
|
|
||||||
@close="isEditModal = false"
|
|
||||||
/>
|
|
||||||
</BaseContextMenu>
|
</BaseContextMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -37,14 +31,12 @@
|
|||||||
import { mapActions } from 'vuex';
|
import { mapActions } from 'vuex';
|
||||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import ModalEditConnection from '@/components/ModalEditConnection';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SettingBarContext',
|
name: 'SettingBarContext',
|
||||||
components: {
|
components: {
|
||||||
BaseContextMenu,
|
BaseContextMenu,
|
||||||
ConfirmModal,
|
ConfirmModal
|
||||||
ModalEditConnection
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
contextEvent: MouseEvent,
|
contextEvent: MouseEvent,
|
||||||
@ -52,25 +44,19 @@ export default {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
isConfirmModal: false,
|
isConfirmModal: false
|
||||||
isEditModal: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
deleteConnection: 'connections/deleteConnection'
|
deleteConnection: 'connections/deleteConnection',
|
||||||
|
showEditModal: 'connections/showEditConnModal'
|
||||||
}),
|
}),
|
||||||
showConfirmModal () {
|
showConfirmModal () {
|
||||||
this.isConfirmModal = true;
|
this.isConfirmModal = true;
|
||||||
},
|
},
|
||||||
hideConfirmModal () {
|
hideConfirmModal () {
|
||||||
this.isConfirmModal = false;
|
this.isConfirmModal = false;
|
||||||
},
|
|
||||||
showEditModal () {
|
|
||||||
this.isEditModal = true;
|
|
||||||
},
|
|
||||||
hideEditModal () {
|
|
||||||
this.isEditModal = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,11 +6,14 @@ export default {
|
|||||||
state: {
|
state: {
|
||||||
connections: [],
|
connections: [],
|
||||||
is_new_modal: false,
|
is_new_modal: false,
|
||||||
is_edit_modal: false
|
is_edit_modal: false,
|
||||||
|
selected_conection: {}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getConnections: state => state.connections,
|
getConnections: state => state.connections,
|
||||||
isNewModal: state => state.is_new_modal
|
getSelectedConnection: state => state.selected_conection,
|
||||||
|
isNewModal: state => state.is_new_modal,
|
||||||
|
isEditModal: state => state.is_edit_modal
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
ADD_CONNECTION (state, connection) {
|
ADD_CONNECTION (state, connection) {
|
||||||
@ -19,6 +22,14 @@ export default {
|
|||||||
DELETE_CONNECTION (state, connection) {
|
DELETE_CONNECTION (state, connection) {
|
||||||
state.connections = state.connections.filter(el => el.uid !== connection.uid);
|
state.connections = state.connections.filter(el => el.uid !== connection.uid);
|
||||||
},
|
},
|
||||||
|
EDIT_CONNECTION (state, connection) {
|
||||||
|
const editedConnections = state.connections.map(conn => {
|
||||||
|
if (conn.uid === connection.uid) return connection;
|
||||||
|
return conn;
|
||||||
|
});
|
||||||
|
state.connections = editedConnections;
|
||||||
|
state.selected_conection = {};
|
||||||
|
},
|
||||||
UPDATE_CONNECTIONS (state, connections) {
|
UPDATE_CONNECTIONS (state, connections) {
|
||||||
state.connections = connections;
|
state.connections = connections;
|
||||||
},
|
},
|
||||||
@ -27,6 +38,13 @@ export default {
|
|||||||
},
|
},
|
||||||
HIDE_NEW_CONNECTION_MODAL (state) {
|
HIDE_NEW_CONNECTION_MODAL (state) {
|
||||||
state.is_new_modal = false;
|
state.is_new_modal = false;
|
||||||
|
},
|
||||||
|
SHOW_EDIT_CONNECTION_MODAL (state, connection) {
|
||||||
|
state.is_edit_modal = true;
|
||||||
|
state.selected_conection = connection;
|
||||||
|
},
|
||||||
|
HIDE_EDIT_CONNECTION_MODAL (state) {
|
||||||
|
state.is_edit_modal = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -48,6 +66,12 @@ export default {
|
|||||||
},
|
},
|
||||||
hideNewConnModal ({ commit }) {
|
hideNewConnModal ({ commit }) {
|
||||||
commit('HIDE_NEW_CONNECTION_MODAL');
|
commit('HIDE_NEW_CONNECTION_MODAL');
|
||||||
|
},
|
||||||
|
showEditConnModal ({ commit }, connection) {
|
||||||
|
commit('SHOW_EDIT_CONNECTION_MODAL', connection);
|
||||||
|
},
|
||||||
|
hideEditConnModal ({ commit }) {
|
||||||
|
commit('HIDE_EDIT_CONNECTION_MODAL');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user