index.vue 4.3 KB

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