Users.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div id="users">
  3. <h5 class="has-text-centered">Total users: {{ userCount }}</h5>
  4. <transition-group name="notification-box">
  5. <h6
  6. class="has-text-centered"
  7. v-if="
  8. users &&
  9. ((users.loggedIn.length === 1 &&
  10. users.loggedOut.length === 0) ||
  11. (users.loggedIn.length === 0 &&
  12. users.loggedOut.length === 1))
  13. "
  14. key="only-me"
  15. >
  16. It's just you in the station!
  17. </h6>
  18. <h6
  19. class="has-text-centered"
  20. v-else-if="users && users.loggedOut.length > 0"
  21. key="logged-out-users"
  22. >
  23. {{ users.loggedOut.length }}
  24. {{ users.loggedOut.length > 1 ? "users are" : "user is" }}
  25. logged-out.
  26. </h6>
  27. </transition-group>
  28. <aside class="menu">
  29. <ul class="menu-list scrollable-list">
  30. <li v-for="(user, index) in users.loggedIn" :key="index">
  31. <router-link
  32. :to="{
  33. name: 'profile',
  34. params: { username: user.username }
  35. }"
  36. target="_blank"
  37. >
  38. <profile-picture
  39. :avatar="user.avatar"
  40. :name="user.name"
  41. />
  42. {{ user.username }}
  43. </router-link>
  44. </li>
  45. </ul>
  46. </aside>
  47. <button
  48. class="button is-primary tab-actionable-button"
  49. @click="copyToClipboard()"
  50. >
  51. <i class="material-icons icon-with-button">share</i>
  52. <span class="optional-desktop-only-text">
  53. Share (copy to clipboard)
  54. </span>
  55. </button>
  56. </div>
  57. </template>
  58. <script>
  59. import { mapState } from "vuex";
  60. import Toast from "toasters";
  61. import ProfilePicture from "../../../../components/ui/ProfilePicture.vue";
  62. export default {
  63. components: { ProfilePicture },
  64. data() {
  65. return {
  66. notesUri: "",
  67. frontendDomain: ""
  68. };
  69. },
  70. computed: mapState({
  71. users: state => state.station.users,
  72. userCount: state => state.station.userCount
  73. }),
  74. mounted() {
  75. lofig.get("frontendDomain").then(frontendDomain => {
  76. this.notesUri = encodeURI(`${frontendDomain}/assets/notes.png`);
  77. this.frontendDomain = frontendDomain;
  78. });
  79. },
  80. methods: {
  81. async copyToClipboard() {
  82. try {
  83. await navigator.clipboard.writeText(
  84. this.frontendDomain + this.$route.fullPath
  85. );
  86. } catch (err) {
  87. new Toast({
  88. content: "Failed to copy to clipboard.",
  89. timeout: 8000
  90. });
  91. }
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. @import "../../../../styles/global.scss";
  98. .night-mode {
  99. #users {
  100. background-color: $night-mode-bg-secondary !important;
  101. border: 0 !important;
  102. }
  103. a {
  104. color: $night-mode-text;
  105. background-color: $dark-grey-2 !important;
  106. border: 0 !important;
  107. &:hover {
  108. color: lighten($night-mode-text, 10%) !important;
  109. }
  110. }
  111. }
  112. .notification-box-enter-active,
  113. .fade-leave-active {
  114. transition: opacity 0.5s;
  115. }
  116. .notification-box-enter,
  117. .notification-box-leave-to {
  118. opacity: 0;
  119. }
  120. #users {
  121. background-color: #fff;
  122. margin-bottom: 20px;
  123. border-radius: 0 0 5px 5px;
  124. max-height: 100%;
  125. .menu {
  126. padding: 0 10px;
  127. margin-top: 20px;
  128. width: 100%;
  129. overflow: auto;
  130. height: calc(100% - 20px - 40px);
  131. .menu-list {
  132. padding: 0 10px;
  133. }
  134. li {
  135. &:not(:first-of-type) {
  136. margin-top: 10px;
  137. }
  138. a {
  139. display: flex;
  140. align-items: center;
  141. padding: 5px 10px;
  142. border: 0.5px $light-grey-2 solid;
  143. border-radius: 3px;
  144. cursor: pointer;
  145. &:hover {
  146. background-color: #eee;
  147. color: #000;
  148. }
  149. .profile-picture {
  150. margin-right: 10px;
  151. width: 35px;
  152. height: 35px;
  153. font-size: 15px;
  154. }
  155. }
  156. }
  157. }
  158. h5 {
  159. font-size: 20px;
  160. margin-top: 20px;
  161. }
  162. }
  163. </style>