index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div>
  3. <metadata title="Settings" />
  4. <main-header />
  5. <div class="container">
  6. <h1 id="page-title">Settings</h1>
  7. <div id="sidebar-with-content">
  8. <div class="nav-links">
  9. <a
  10. :class="{ active: tab === 'profile' }"
  11. @click="showTab('profile')"
  12. >
  13. Profile
  14. </a>
  15. <a
  16. :class="{ active: tab === 'account' }"
  17. @click="showTab('account')"
  18. >
  19. Account
  20. </a>
  21. <a
  22. :class="{ active: tab === 'security' }"
  23. @click="showTab('security')"
  24. >
  25. Security
  26. </a>
  27. <a
  28. :class="{ active: tab === 'preferences' }"
  29. @click="showTab('preferences')"
  30. >
  31. Preferences
  32. </a>
  33. </div>
  34. <profile-settings v-if="tab === 'profile'"></profile-settings>
  35. <account-settings v-if="tab === 'account'"></account-settings>
  36. <security-settings
  37. v-if="tab === 'security'"
  38. ></security-settings>
  39. <preferences-settings
  40. v-if="tab === 'preferences'"
  41. ></preferences-settings>
  42. </div>
  43. </div>
  44. <main-footer />
  45. </div>
  46. </template>
  47. <script>
  48. import { mapActions, mapGetters } from "vuex";
  49. import Toast from "toasters";
  50. import MainHeader from "@/components/layout/MainHeader.vue";
  51. import MainFooter from "@/components/layout/MainFooter.vue";
  52. import TabQueryHandler from "@/mixins/TabQueryHandler.vue";
  53. export default {
  54. components: {
  55. MainHeader,
  56. MainFooter,
  57. SecuritySettings: () => import("./tabs/Security.vue"),
  58. AccountSettings: () => import("./tabs/Account.vue"),
  59. ProfileSettings: () => import("./tabs/Profile.vue"),
  60. PreferencesSettings: () => import("./tabs/Preferences.vue")
  61. },
  62. mixins: [TabQueryHandler],
  63. data() {
  64. return {
  65. tab: ""
  66. };
  67. },
  68. computed: mapGetters({
  69. socket: "websockets/getSocket"
  70. }),
  71. mounted() {
  72. if (
  73. this.$route.query.tab === "profile" ||
  74. this.$route.query.tab === "security" ||
  75. this.$route.query.tab === "account" ||
  76. this.$route.query.tab === "preferences"
  77. )
  78. this.tab = this.$route.query.tab;
  79. else this.tab = "profile";
  80. this.localNightmode = this.nightmode;
  81. this.socket.dispatch("users.findBySession", res => {
  82. if (res.status === "success") this.setUser(res.data.user);
  83. else new Toast("You're not currently signed in.");
  84. });
  85. this.socket.on("event:user.linkPassword", () =>
  86. this.updateOriginalUser({
  87. property: "password",
  88. value: true
  89. })
  90. );
  91. this.socket.on("event:user.unlinkPassword", () =>
  92. this.updateOriginalUser({
  93. property: "password",
  94. value: false
  95. })
  96. );
  97. this.socket.on("event:user.linkGithub", () =>
  98. this.updateOriginalUser({
  99. property: "github",
  100. value: true
  101. })
  102. );
  103. this.socket.on("event:user.unlinkGithub", () =>
  104. this.updateOriginalUser({
  105. property: "github",
  106. value: false
  107. })
  108. );
  109. },
  110. methods: mapActions("settings", ["updateOriginalUser", "setUser"])
  111. };
  112. </script>
  113. <style lang="scss" scoped>
  114. /deep/ .character-counter {
  115. display: flex;
  116. justify-content: flex-end;
  117. height: 0;
  118. }
  119. .container {
  120. margin-top: 32px;
  121. padding: 24px;
  122. .content {
  123. background-color: var(--white);
  124. padding: 30px 50px;
  125. border-radius: 3px;
  126. }
  127. #page-title {
  128. margin-top: 0;
  129. font-size: 35px;
  130. }
  131. #sidebar-with-content {
  132. display: flex;
  133. flex-direction: column;
  134. }
  135. @media only screen and (min-width: 900px) {
  136. #page-title {
  137. margin: 0;
  138. font-size: 40px;
  139. }
  140. #sidebar-with-content {
  141. width: 962px;
  142. margin: 0 auto;
  143. margin-top: 30px;
  144. flex-direction: row;
  145. .content {
  146. width: 600px;
  147. margin-top: 0px !important;
  148. }
  149. }
  150. }
  151. .nav-links {
  152. width: 250px;
  153. margin-right: 64px;
  154. a {
  155. outline: none;
  156. border: none;
  157. box-shadow: none;
  158. color: var(--primary-color);
  159. font-size: 22px;
  160. line-height: 26px;
  161. padding: 7px 0 7px 12px;
  162. width: 100%;
  163. text-align: left;
  164. cursor: pointer;
  165. border-radius: 5px;
  166. background-color: transparent;
  167. display: inline-block;
  168. &.active {
  169. color: var(--white);
  170. background-color: var(--primary-color);
  171. }
  172. }
  173. }
  174. /deep/ .content {
  175. margin: 24px 0;
  176. height: fit-content;
  177. .control:not(:first-of-type) {
  178. margin: 10px 0;
  179. }
  180. label {
  181. font-size: 14px;
  182. color: var(--dark-grey-2);
  183. }
  184. textarea {
  185. height: 96px;
  186. }
  187. button {
  188. width: 100%;
  189. margin-top: 30px;
  190. }
  191. }
  192. }
  193. </style>