123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <div id="users">
- <h5 class="has-text-centered">Total users: {{ userCount }}</h5>
- <transition-group name="notification-box">
- <h6
- class="has-text-centered"
- v-if="
- users &&
- ((users.loggedIn.length === 1 &&
- users.loggedOut.length === 0) ||
- (users.loggedIn.length === 0 &&
- users.loggedOut.length === 1))
- "
- key="only-me"
- >
- It's just you in the station!
- </h6>
- <h6
- class="has-text-centered"
- v-else-if="users && users.loggedOut.length > 0"
- key="logged-out-users"
- >
- {{ users.loggedOut.length }}
- {{ users.loggedOut.length > 1 ? "users are" : "user is" }}
- logged-out.
- </h6>
- </transition-group>
- <aside class="menu">
- <ul class="menu-list scrollable-list">
- <li v-for="(user, index) in users.loggedIn" :key="index">
- <router-link
- :to="{
- name: 'profile',
- params: { username: user.username }
- }"
- target="_blank"
- >
- <profile-picture
- :avatar="user.avatar"
- :name="user.name"
- />
- {{ user.username }}
- </router-link>
- </li>
- </ul>
- </aside>
- <button
- class="button is-primary tab-actionable-button"
- @click="copyToClipboard()"
- >
- <i class="material-icons icon-with-button">share</i>
- <span class="optional-desktop-only-text">
- Share (copy to clipboard)
- </span>
- </button>
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- import Toast from "toasters";
- import ProfilePicture from "../../../../components/ui/ProfilePicture.vue";
- export default {
- components: { ProfilePicture },
- data() {
- return {
- notesUri: "",
- frontendDomain: ""
- };
- },
- computed: mapState({
- users: state => state.station.users,
- userCount: state => state.station.userCount
- }),
- mounted() {
- lofig.get("frontendDomain").then(frontendDomain => {
- this.notesUri = encodeURI(`${frontendDomain}/assets/notes.png`);
- this.frontendDomain = frontendDomain;
- });
- },
- methods: {
- async copyToClipboard() {
- try {
- await navigator.clipboard.writeText(
- this.frontendDomain + this.$route.fullPath
- );
- } catch (err) {
- new Toast({
- content: "Failed to copy to clipboard.",
- timeout: 8000
- });
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../../../styles/global.scss";
- .night-mode {
- #users {
- background-color: $night-mode-bg-secondary !important;
- border: 0 !important;
- }
- a {
- color: $night-mode-text;
- background-color: $dark-grey-2 !important;
- border: 0 !important;
- &:hover {
- color: lighten($night-mode-text, 10%) !important;
- }
- }
- }
- .notification-box-enter-active,
- .fade-leave-active {
- transition: opacity 0.5s;
- }
- .notification-box-enter,
- .notification-box-leave-to {
- opacity: 0;
- }
- #users {
- background-color: #fff;
- margin-bottom: 20px;
- border-radius: 0 0 5px 5px;
- max-height: 100%;
- .menu {
- padding: 0 10px;
- margin-top: 20px;
- width: 100%;
- overflow: auto;
- height: calc(100% - 20px - 40px);
- .menu-list {
- padding: 0 10px;
- }
- li {
- &:not(:first-of-type) {
- margin-top: 10px;
- }
- a {
- display: flex;
- align-items: center;
- padding: 5px 10px;
- border: 0.5px $light-grey-2 solid;
- border-radius: 3px;
- cursor: pointer;
- &:hover {
- background-color: #eee;
- color: #000;
- }
- .profile-picture {
- margin-right: 10px;
- width: 35px;
- height: 35px;
- font-size: 15px;
- }
- }
- }
- }
- h5 {
- font-size: 20px;
- margin-top: 20px;
- }
- }
- </style>
|