antares/src/renderer/components/Workspace.vue

92 lines
2.3 KiB
Vue
Raw Normal View History

2020-05-14 15:21:57 +02:00
<template>
2020-06-02 19:13:57 +02:00
<div v-show="isSelected" class="workspace column columns">
2020-06-03 20:56:44 +02:00
<WorkspaceExploreBar :connection="connection" :is-selected="isSelected" />
2020-06-05 21:00:15 +02:00
<div class="workspace-tabs column p-0">
<ul class="tab tab-block">
<li
v-for="(tab, key) of workspace.tabs"
:key="tab.uid"
class="tab-item"
:class="{'active': selectedTab === tab.uid}"
>
<a href="#">Query #{{ key }} <span class="btn btn-clear" /></a>
</li>
</ul>
<QueryEditor v-model="query" />
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';
2020-06-03 20:56:44 +02:00
import WorkspaceExploreBar from '@/components/WorkspaceExploreBar';
2020-06-05 21:00:15 +02:00
import QueryEditor from '@/components/QueryEditor';
2020-05-14 15:21:57 +02:00
export default {
2020-06-03 20:56:44 +02:00
name: 'Workspace',
2020-05-14 15:21:57 +02:00
components: {
2020-06-05 21:00:15 +02:00
WorkspaceExploreBar,
QueryEditor
2020-05-14 15:21:57 +02:00
},
props: {
connection: Object
},
2020-06-05 21:00:15 +02:00
data () {
return {
query: ''
};
},
2020-05-14 15:21:57 +02:00
computed: {
...mapGetters({
selectedWorkspace: 'workspaces/getSelected',
2020-05-20 18:00:14 +02:00
getWorkspace: 'workspaces/getWorkspace'
}),
workspace () {
return this.getWorkspace(this.connection.uid);
2020-06-02 19:13:57 +02:00
},
isSelected () {
return this.selectedWorkspace === this.connection.uid;
2020-06-05 21:00:15 +02:00
},
selectedTab () {
return this.workspace.tabs.filter(tab => tab.selected).uid || this.workspace.tabs[0].uid;
2020-05-20 18:00:14 +02:00
}
2020-05-14 15:21:57 +02:00
},
async created () {
2020-06-05 21:00:15 +02:00
await this.addWorkspace(this.connection.uid);
const isInitiated = await Connection.checkConnection(this.connection.uid);
2020-05-19 18:06:05 +02:00
if (isInitiated)
this.connectWorkspace(this.connection);
2020-05-14 15:21:57 +02:00
},
methods: {
2020-05-15 17:52:59 +02:00
...mapActions({
addNotification: 'notifications/addNotification',
2020-05-18 18:06:32 +02:00
addWorkspace: 'workspaces/addWorkspace',
2020-05-19 18:06:05 +02:00
connectWorkspace: 'workspaces/connectWorkspace',
removeConnected: 'workspaces/removeConnected'
2020-05-15 17:52:59 +02:00
})
2020-05-14 15:21:57 +02:00
}
};
</script>
<style lang="scss">
2020-06-05 21:00:15 +02:00
.workspace{
padding: 0;
margin: 0;
.workspace-tabs{
overflow: auto;
height: calc(100vh - #{$excluding-size});
.tab-block{
background: $bg-color-light;
margin-top: 0;
2020-05-20 18:00:14 +02:00
2020-06-05 21:00:15 +02:00
.tab-item{
max-width: 6rem;
}
2020-05-20 18:00:14 +02:00
}
2020-05-14 15:21:57 +02:00
}
2020-06-05 21:00:15 +02:00
}
2020-05-14 15:21:57 +02:00
</style>