index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <page-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 { defineAsyncComponent } from "vue";
  50. import Toast from "toasters";
  51. import ws from "@/ws";
  52. import TabQueryHandler from "@/mixins/TabQueryHandler.vue";
  53. export default {
  54. components: {
  55. SecuritySettings: defineAsyncComponent(() =>
  56. import("./Tabs/Security.vue")
  57. ),
  58. AccountSettings: defineAsyncComponent(() =>
  59. import("./Tabs/Account.vue")
  60. ),
  61. ProfileSettings: defineAsyncComponent(() =>
  62. import("./Tabs/Profile.vue")
  63. ),
  64. PreferencesSettings: defineAsyncComponent(() =>
  65. import("./Tabs/Preferences.vue")
  66. )
  67. },
  68. mixins: [TabQueryHandler],
  69. data() {
  70. return {
  71. tab: ""
  72. };
  73. },
  74. computed: {
  75. ...mapGetters({
  76. socket: "websockets/getSocket"
  77. })
  78. },
  79. mounted() {
  80. if (
  81. this.$route.query.tab === "profile" ||
  82. this.$route.query.tab === "security" ||
  83. this.$route.query.tab === "account" ||
  84. this.$route.query.tab === "preferences"
  85. )
  86. this.tab = this.$route.query.tab;
  87. else this.tab = "profile";
  88. this.localNightmode = this.nightmode;
  89. ws.onConnect(this.init);
  90. this.socket.on("event:user.password.linked", () =>
  91. this.updateOriginalUser({
  92. property: "password",
  93. value: true
  94. })
  95. );
  96. this.socket.on("event:user.password.unlinked", () =>
  97. this.updateOriginalUser({
  98. property: "password",
  99. value: false
  100. })
  101. );
  102. this.socket.on("event:user.github.linked", () =>
  103. this.updateOriginalUser({
  104. property: "github",
  105. value: true
  106. })
  107. );
  108. this.socket.on("event:user.github.unlinked", () =>
  109. this.updateOriginalUser({
  110. property: "github",
  111. value: false
  112. })
  113. );
  114. },
  115. methods: {
  116. init() {
  117. this.socket.dispatch("users.findBySession", res => {
  118. if (res.status === "success") this.setUser(res.data.user);
  119. else new Toast("You're not currently signed in.");
  120. });
  121. },
  122. ...mapActions("settings", ["updateOriginalUser", "setUser"])
  123. }
  124. };
  125. </script>
  126. <style lang="less" scoped>
  127. .night-mode {
  128. .container .content {
  129. box-shadow: 0 !important;
  130. }
  131. }
  132. :deep(.character-counter) {
  133. display: flex;
  134. justify-content: flex-end;
  135. height: 0;
  136. }
  137. .container {
  138. margin-top: 32px;
  139. padding: 24px;
  140. :deep(.row) {
  141. *:not(:last-child) {
  142. margin-right: 5px;
  143. }
  144. }
  145. .content {
  146. background-color: var(--white);
  147. padding: 30px 50px;
  148. border-radius: @border-radius;
  149. box-shadow: @box-shadow;
  150. }
  151. #sidebar-with-content {
  152. display: flex;
  153. flex-direction: column;
  154. }
  155. @media only screen and (min-width: 700px) {
  156. #sidebar-with-content {
  157. width: 962px;
  158. max-width: 100%;
  159. margin: 0 auto;
  160. flex-direction: row;
  161. .nav-links {
  162. margin-left: 0;
  163. margin-right: 64px;
  164. }
  165. .content {
  166. width: 600px;
  167. margin-top: 0px !important;
  168. }
  169. }
  170. }
  171. .nav-links {
  172. width: 250px;
  173. margin-left: auto;
  174. margin-right: auto;
  175. a {
  176. outline: none;
  177. border: none;
  178. box-shadow: 0;
  179. color: var(--primary-color);
  180. font-size: 22px;
  181. line-height: 26px;
  182. padding: 7px 0 7px 12px;
  183. width: 100%;
  184. text-align: left;
  185. cursor: pointer;
  186. border-radius: @border-radius;
  187. background-color: transparent;
  188. display: inline-block;
  189. &.active {
  190. color: var(--white);
  191. background-color: var(--primary-color);
  192. }
  193. }
  194. }
  195. :deep(.content) {
  196. margin: 24px 0;
  197. height: fit-content;
  198. .control:not(:first-of-type) {
  199. margin: 10px 0;
  200. }
  201. label {
  202. font-size: 14px;
  203. color: var(--dark-grey-2);
  204. }
  205. textarea {
  206. height: 96px;
  207. }
  208. button {
  209. width: 100%;
  210. margin-top: 30px;
  211. }
  212. }
  213. }
  214. </style>