neko/client/src/components/header.vue

212 lines
5.0 KiB
Vue
Raw Normal View History

2020-01-23 15:23:26 +00:00
<template>
<div class="header">
2021-07-22 20:13:58 +02:00
<a href="https://github.com/m1k1o/neko" title="Github repository" target="_blank" class="neko">
2020-02-01 20:35:48 +00:00
<img src="@/assets/images/logo.svg" alt="n.eko" />
2020-01-23 15:23:26 +00:00
<span><b>n</b>.eko</span>
2021-07-22 20:13:58 +02:00
</a>
2020-01-23 15:23:26 +00:00
<ul class="menu">
<li>
<i
2021-11-16 22:50:11 +01:00
:class="[{ disabled: !admin }, { locked: isLocked('control') }, 'fas', 'fa-mouse']"
@click="toggleLock('control')"
2020-02-12 00:02:51 +00:00
v-tooltip="{
2021-11-16 22:50:11 +01:00
content: lockedTooltip('control'),
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
/>
</li>
<li>
<i
:class="[{ disabled: !admin }, { locked: isLocked('login') }, locked ? 'fa-lock' : 'fa-lock-open', 'fas']"
@click="toggleLock('login')"
v-tooltip="{
content: lockedTooltip('login'),
2020-02-12 00:02:51 +00:00
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
2020-01-23 15:23:26 +00:00
/>
</li>
2022-11-19 20:26:45 +01:00
<li v-if="fileTransfer">
<i
:class="[{ disabled: !admin }, { locked: isLocked('file_transfer') }, 'fas', 'fa-file']"
@click="toggleLock('file_transfer')"
v-tooltip="{
content: lockedTooltip('file_transfer'),
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
/>
</li>
2020-01-23 15:23:26 +00:00
<li>
2021-07-17 12:38:12 +02:00
<span v-if="showBadge" class="badge">&bull;</span>
2020-01-23 15:23:26 +00:00
<i class="fas fa-bars toggle" @click="toggleMenu" />
</li>
</ul>
</div>
</template>
<style lang="scss" scoped>
.header {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
.neko {
flex: 1;
display: flex;
justify-content: flex-start;
align-items: center;
width: 150px;
margin-left: 20px;
2021-07-22 20:13:58 +02:00
color: $text-normal;
text-decoration: none;
2020-01-23 15:23:26 +00:00
img {
display: block;
float: left;
height: 30px;
margin-right: 10px;
}
span {
font-size: 30px;
line-height: 30px;
b {
font-weight: 900;
}
}
}
.menu {
justify-self: flex-end;
margin-right: 10px;
white-space: nowrap;
li {
display: inline-block;
margin-right: 10px;
i {
display: block;
width: 30px;
height: 30px;
text-align: center;
line-height: 32px;
border-radius: 3px;
cursor: pointer;
}
.disabled {
cursor: default;
opacity: 0.8;
}
2021-11-16 22:50:11 +01:00
.locked {
2020-01-23 15:23:26 +00:00
color: rgba($color: $style-error, $alpha: 0.5);
}
.toggle {
background: $background-primary;
}
2021-07-17 12:38:12 +02:00
.badge {
position: absolute;
background: red;
font-weight: bold;
font-size: 1.25em;
border-radius: 50%;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
pointer-events: none;
transform: translate(-50%, -25%) scale(1);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 1);
animation: badger-pulse 2s infinite;
}
@keyframes badger-pulse {
0% {
transform: translate(-50%, -25%) scale(0.85);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
}
70% {
transform: translate(-50%, -25%) scale(1);
box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
}
100% {
transform: translate(-50%, -25%) scale(0.85);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
}
2020-01-23 15:23:26 +00:00
}
}
}
</style>
<script lang="ts">
import { Component, Ref, Watch, Vue } from 'vue-property-decorator'
2021-11-16 22:50:11 +01:00
import { AdminLockResource } from '~/neko/messages'
2020-01-23 15:23:26 +00:00
@Component({ name: 'neko-settings' })
export default class extends Vue {
get admin() {
return this.$accessor.user.admin
}
get locked() {
return this.$accessor.locked
}
2021-07-17 12:38:12 +02:00
get side() {
return this.$accessor.client.side
}
get texts() {
return this.$accessor.chat.texts
}
get showBadge() {
return !this.side && this.readTexts != this.texts
}
2022-11-19 20:26:45 +01:00
get fileTransfer() {
return this.$accessor.remote.fileTransfer
2020-01-23 15:23:26 +00:00
}
2021-11-16 22:50:11 +01:00
toggleLock(resource: AdminLockResource) {
2022-11-19 20:26:45 +01:00
this.$accessor.toggleLock(resource)
2021-11-16 22:50:11 +01:00
}
isLocked(resource: AdminLockResource): boolean {
2022-11-19 20:26:45 +01:00
return this.$accessor.isLocked(resource)
}
readTexts: number = 0
toggleMenu() {
this.$accessor.client.toggleSide()
this.readTexts = this.texts
2021-11-16 22:50:11 +01:00
}
lockedTooltip(resource: AdminLockResource) {
2020-01-23 15:23:26 +00:00
if (this.admin) {
2021-11-16 22:50:11 +01:00
return this.$t(`locks.${resource}.` + (this.isLocked(resource) ? `unlock` : `lock`))
2020-01-23 15:23:26 +00:00
}
2021-11-16 22:50:11 +01:00
return this.$t(`locks.${resource}.` + (this.isLocked(resource) ? `locked` : `unlocked`))
2020-01-23 15:23:26 +00:00
}
}
</script>