antares/src/renderer/components/TheSettingBar.vue

274 lines
7.8 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">
<Draggable
v-model="connections"
:item-key="'uid'"
@start="isDragging = true"
@end="dragStop"
>
2022-04-21 14:39:24 +02:00
<template #item="{element}">
<li
:draggable="true"
class="settingbar-element btn btn-link ex-tooltip"
:class="{'selected': element.uid === selectedWorkspace}"
@click.stop="selectWorkspace(element.uid)"
@contextmenu.prevent="contextMenu($event, element)"
@mouseover.self="tooltipPosition"
>
<i class="settingbar-element-icon dbi" :class="`dbi-${element.client} ${getStatusBadge(element.uid)}`" />
<span v-if="!isDragging" class="ex-tooltip-content">{{ getConnectionName(element.uid) }}</span>
</li>
</template>
2021-07-14 20:30:54 +02:00
</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"
2021-07-08 17:43:33 +02:00
:class="{'selected': 'NEW' === selectedWorkspace}"
@click="selectWorkspace('NEW')"
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">
<li class="settingbar-element btn btn-link ex-tooltip" @click="showScratchpad">
2021-04-03 11:21:58 +02:00
<i class="settingbar-element-icon mdi mdi-24px mdi-notebook-edit-outline text-light" />
<span class="ex-tooltip-content">{{ $t('word.scratchpad') }}</span>
</li>
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';
2022-04-27 18:23:48 +02:00
import { storeToRefs } from 'pinia';
import { useApplicationStore } from '@/stores/application';
2021-07-14 20:30:54 +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: {
2021-07-14 20:30:54 +02:00
Draggable,
2020-05-23 13:32:14 +02:00
SettingBarContext
2020-05-22 19:32:55 +02:00
},
2022-04-27 18:23:48 +02:00
setup () {
const applicationStore = useApplicationStore();
const { updateStatus } = storeToRefs(applicationStore);
const { showSettingModal, showScratchpad } = applicationStore;
return {
applicationStore,
updateStatus,
showSettingModal,
showScratchpad
};
},
2020-05-22 19:32:55 +02:00
data () {
return {
dragElement: null,
isContext: false,
isDragging: 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',
getWorkspace: 'workspaces/getWorkspace',
2022-04-27 18:23:48 +02:00
selectedWorkspace: 'workspaces/getSelected'
2020-05-22 19:32:55 +02:00
}),
connections: {
get () {
return this.getConnections;
},
set (value) {
this.updateConnections(value);
}
},
hasUpdates () {
return ['available', 'downloading', 'downloaded', 'link'].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',
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 ? e.target : e;
2020-06-05 21:00:15 +02:00
const fromTop = window.pageYOffset + el.getBoundingClientRect().top - (el.offsetHeight / 4);
el.querySelector('.ex-tooltip-content').style.top = `${fromTop}px`;
},
getStatusBadge (uid) {
if (this.getWorkspace(uid)) {
const status = this.getWorkspace(uid).connectionStatus;
switch (status) {
case 'connected':
return 'badge badge-connected';
case 'connecting':
return 'badge badge-connecting';
case 'failed':
return 'badge badge-failed';
default:
return '';
}
}
},
dragStop (e) {
this.isDragging = false;
setTimeout(() => {
this.tooltipPosition(e.originalEvent.target.parentNode);
}, 200);
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;
padding: 0;
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;
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;
opacity: 0.5;
transition: opacity 0.2s;
display: flex;
align-items: center;
justify-content: flex-start;
border-radius: 0;
padding: 0;
2020-07-31 18:16:28 +02:00
&:hover {
opacity: 1;
}
&.selected {
opacity: 1;
2021-06-28 18:34:39 +02:00
&::before {
height: $settingbar-width;
}
}
&::before {
content: "";
2021-06-28 18:34:39 +02:00
height: 0;
width: 3px;
transition: height 0.2s;
background-color: $primary-color;
border-radius: $border-radius;
2020-07-31 18:16:28 +02:00
}
.settingbar-element-icon {
margin: 0 auto;
2020-07-31 18:16:28 +02:00
&.badge::after {
bottom: -10px;
right: 0;
position: absolute;
}
&.badge-update::after {
bottom: initial;
}
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: $border-radius;
2020-07-31 18:16:28 +02:00
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;
}
&.sortable-chosen {
.ex-tooltip-content {
opacity: 0 !important;
}
}
&:hover:not(.selected) .ex-tooltip-content {
2020-07-31 18:16:28 +02:00
visibility: visible;
opacity: 1;
}
}
2020-05-08 18:02:18 +02:00
</style>