antares/src/renderer/components/TheSettingBar.vue

214 lines
6.1 KiB
Vue
Raw Normal View History

2020-05-08 18:02:18 +02:00
<template>
2020-05-14 15:21:57 +02:00
<div id="settingbar">
2020-05-08 18:02:18 +02:00
<div class="settingbar-top-elements">
2020-05-23 13:32:14 +02:00
<SettingBarContext
2020-05-22 19:32:55 +02:00
v-if="isContext"
:context-event="contextEvent"
2020-05-23 13:32:14 +02:00
:context-connection="contextConnection"
2020-08-12 18:11:48 +02:00
@close-context="isContext = false"
2020-05-23 13:32:14 +02:00
/>
2020-05-08 18:02:18 +02:00
<ul class="settingbar-elements">
2020-05-22 19:32:55 +02:00
<draggable v-model="connections">
<li
v-for="connection in connections"
:key="connection.uid"
draggable="true"
2020-06-05 21:00:15 +02:00
class="settingbar-element btn btn-link ex-tooltip"
2020-05-22 19:32:55 +02:00
:class="{'selected': connection.uid === selectedWorkspace}"
@click="selectWorkspace(connection.uid)"
2020-05-23 13:32:14 +02:00
@contextmenu.prevent="contextMenu($event, connection)"
2020-06-05 21:00:15 +02:00
@mouseover.self="tooltipPosition"
2020-05-22 19:32:55 +02:00
>
<i class="settingbar-element-icon dbi" :class="`dbi-${connection.client} ${connected.includes(connection.uid) ? 'badge' : ''}`" />
2020-06-05 21:00:15 +02:00
<span class="ex-tooltip-content">{{ getConnectionName(connection.uid) }}</span>
2020-05-22 19:32:55 +02:00
</li>
</draggable>
2020-05-08 18:02:18 +02:00
<li
2020-06-05 21:00:15 +02:00
class="settingbar-element btn btn-link ex-tooltip"
2020-05-08 18:02:18 +02:00
@click="showNewConnModal"
2020-06-05 21:00:15 +02:00
@mouseover.self="tooltipPosition"
2020-05-08 18:02:18 +02:00
>
<i class="settingbar-element-icon mdi mdi-24px mdi-plus text-light" />
2020-06-05 21:00:15 +02:00
<span class="ex-tooltip-content">{{ $t('message.addConnection') }}</span>
2020-05-08 18:02:18 +02:00
</li>
</ul>
</div>
<div class="settingbar-bottom-elements">
<ul class="settingbar-elements">
2020-06-05 21:00:15 +02:00
<li class="settingbar-element btn btn-link ex-tooltip" @click="showSettingModal('general')">
<i class="settingbar-element-icon mdi mdi-24px mdi-cog text-light" :class="{' badge badge-update': hasUpdates}" />
2020-06-05 21:00:15 +02:00
<span class="ex-tooltip-content">{{ $t('word.settings') }}</span>
2020-05-08 18:02:18 +02:00
</li>
</ul>
</div>
</div>
</template>
<script>
2020-05-12 18:27:31 +02:00
import { mapActions, mapGetters } from 'vuex';
2020-05-22 19:32:55 +02:00
import draggable from 'vuedraggable';
2020-05-23 13:32:14 +02:00
import SettingBarContext from '@/components/SettingBarContext';
2020-05-08 18:02:18 +02:00
export default {
name: 'TheSettingBar',
2020-05-22 19:32:55 +02:00
components: {
draggable,
2020-05-23 13:32:14 +02:00
SettingBarContext
2020-05-22 19:32:55 +02:00
},
data () {
return {
dragElement: null,
isContext: false,
2020-05-23 13:32:14 +02:00
contextEvent: null,
2020-06-05 21:00:15 +02:00
contextConnection: {},
scale: 0
2020-05-22 19:32:55 +02:00
};
},
2020-05-12 18:27:31 +02:00
computed: {
...mapGetters({
2020-05-22 19:32:55 +02:00
getConnections: 'connections/getConnections',
2020-05-31 17:56:33 +02:00
getConnectionName: 'connections/getConnectionName',
connected: 'workspaces/getConnected',
selectedWorkspace: 'workspaces/getSelected',
updateStatus: 'application/getUpdateStatus'
2020-05-22 19:32:55 +02:00
}),
connections: {
get () {
return this.getConnections;
},
set (value) {
this.updateConnections(value);
}
},
hasUpdates () {
return ['available', 'downloading', 'downloaded'].includes(this.updateStatus);
2020-05-22 19:32:55 +02:00
}
2020-05-12 18:27:31 +02:00
},
2020-05-08 18:02:18 +02:00
methods: {
...mapActions({
2020-05-22 19:32:55 +02:00
updateConnections: 'connections/updateConnections',
2020-05-30 12:54:05 +02:00
showNewConnModal: 'application/showNewConnModal',
showSettingModal: 'application/showSettingModal',
selectWorkspace: 'workspaces/selectWorkspace'
2020-05-22 19:32:55 +02:00
}),
2020-05-23 13:32:14 +02:00
contextMenu (event, connection) {
2020-05-22 19:32:55 +02:00
this.contextEvent = event;
2020-05-23 13:32:14 +02:00
this.contextConnection = connection;
2020-05-22 19:32:55 +02:00
this.isContext = true;
2020-05-31 17:56:33 +02:00
},
workspaceName (connection) {
return connection.ask ? '' : `${connection.user + '@'}${connection.host}:${connection.port}`;
2020-06-05 21:00:15 +02:00
},
tooltipPosition (e) {
const el = e.target;
const fromTop = window.pageYOffset + el.getBoundingClientRect().top - (el.offsetHeight / 4);
el.querySelector('.ex-tooltip-content').style.top = `${fromTop}px`;
2020-05-22 19:32:55 +02:00
}
2020-05-08 18:02:18 +02:00
}
};
</script>
<style lang="scss">
2020-07-31 18:16:28 +02:00
#settingbar {
width: $settingbar-width;
height: calc(100vh - #{$excluding-size});
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
background: $bg-color-light;
padding: 0;
box-shadow: 0 0 1px 0 #000;
z-index: 9;
.settingbar-top-elements {
overflow-x: hidden;
overflow-y: overlay;
max-height: calc((100vh - 3.5rem) - #{$excluding-size});
&::-webkit-scrollbar {
width: 3px;
2020-06-05 21:00:15 +02:00
}
2020-07-31 18:16:28 +02:00
}
2020-06-05 21:00:15 +02:00
2020-07-31 18:16:28 +02:00
.settingbar-bottom-elements {
padding-top: 0.5rem;
background: $bg-color-light;
z-index: 1;
}
2020-06-05 21:00:15 +02:00
2020-07-31 18:16:28 +02:00
.settingbar-elements {
list-style: none;
text-align: center;
width: $settingbar-width;
padding: 0;
margin: 0;
.settingbar-element {
height: $settingbar-width;
width: 100%;
margin: 0;
border-left: 3px solid transparent;
opacity: 0.5;
transition: opacity 0.2s;
display: flex;
align-content: center;
justify-content: center;
flex-direction: column;
&:hover {
opacity: 1;
}
&.selected {
border-left-color: $body-font-color;
opacity: 1;
}
.settingbar-element-icon {
&.badge::after {
bottom: -10px;
right: 0;
position: absolute;
background: $success-color;
}
&.badge-update::after {
bottom: initial;
background: $primary-color;
}
2020-07-31 18:16:28 +02:00
}
2020-06-05 21:00:15 +02:00
}
2020-07-31 18:16:28 +02:00
}
}
.ex-tooltip {// Because both overflow-x: visible and overflow-y:auto are evil!!!
.ex-tooltip-content {
z-index: 999;
visibility: hidden;
opacity: 0;
display: block;
position: absolute;
text-align: center;
margin: 0 0 0 calc(#{$settingbar-width} - 5px);
left: 0;
padding: 0.2rem 0.4rem;
font-size: 0.7rem;
background: rgba(48, 55, 66, 0.95);
border-radius: 0.1rem;
color: #fff;
max-width: 320px;
pointer-events: none;
text-overflow: ellipsis;
overflow: hidden;
2020-07-31 18:16:28 +02:00
transition: opacity 0.2s;
}
&:hover .ex-tooltip-content {
visibility: visible;
opacity: 1;
}
}
2020-05-08 18:02:18 +02:00
</style>