antares/src/renderer/components/DatabaseWorkspace.vue

67 lines
1.7 KiB
Vue
Raw Normal View History

2020-05-14 15:21:57 +02:00
<template>
<div v-show="selectedWorkspace === connection.uid" class="workspace column columns">
2020-05-15 17:52:59 +02:00
<DatabaseExploreBar :connection="connection" />
2020-05-14 15:21:57 +02:00
<div class="workspace-tabs column">
2020-05-15 17:52:59 +02:00
<p>{{ connection }}</p>
2020-05-14 15:21:57 +02:00
</div>
</div>
</template>
<script>
2020-05-15 17:52:59 +02:00
import { mapGetters, mapActions } from 'vuex';
2020-05-14 15:21:57 +02:00
import Connection from '@/ipc-api/Connection';
import DatabaseExploreBar from '@/components/DatabaseExploreBar';
export default {
name: 'DatabaseWorkspace',
components: {
DatabaseExploreBar
},
props: {
connection: Object
},
data () {
return {
structure: null
};
},
computed: {
...mapGetters({
selectedWorkspace: 'workspaces/getSelected',
getConnected: 'workspaces/getConnected'
2020-05-14 15:21:57 +02:00
})
},
async created () {
const isInitiated = await Connection.checkConnection(this.connection.uid);
if (isInitiated) {
2020-05-15 17:52:59 +02:00
try {
const { status, response } = await Connection.connect(this.connection);
if (status === 'success') {
this.structure = response;
this.addConnected(this.connection.uid);
}
else
this.addNotification({ status, message: response });
2020-05-15 17:52:59 +02:00
}
catch (err) {
this.addNotification({ status: 'error', message: err.toString() });
2020-05-15 17:52:59 +02:00
}
}
2020-05-14 15:21:57 +02:00
},
methods: {
2020-05-15 17:52:59 +02:00
...mapActions({
addNotification: 'notifications/addNotification',
addConnected: 'workspaces/addConnected',
removeConnected: 'workspaces/removeConnected'
2020-05-15 17:52:59 +02:00
})
2020-05-14 15:21:57 +02:00
}
};
</script>
<style lang="scss">
.workspace{
padding: 0;
margin: 0;
}
</style>