index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div>
  3. <metadata title="Settings" />
  4. <main-header />
  5. <div class="container">
  6. <div class="nav-links">
  7. <router-link
  8. :class="{ active: activeTab === 'profile' }"
  9. to="#profile"
  10. >
  11. Profile
  12. </router-link>
  13. <router-link
  14. :class="{ active: activeTab === 'account' }"
  15. to="#account"
  16. >
  17. Account
  18. </router-link>
  19. <router-link
  20. :class="{ active: activeTab === 'security' }"
  21. to="#security"
  22. >
  23. Security
  24. </router-link>
  25. <router-link
  26. :class="{ active: activeTab === 'preferences' }"
  27. to="#preferences"
  28. >
  29. Preferences
  30. </router-link>
  31. </div>
  32. <profile-settings v-if="activeTab === 'profile'"></profile-settings>
  33. <account-settings v-if="activeTab === 'account'"></account-settings>
  34. <security-settings
  35. v-if="activeTab === 'security'"
  36. ></security-settings>
  37. <preferences-settings
  38. v-if="activeTab === 'preferences'"
  39. ></preferences-settings>
  40. </div>
  41. <main-footer />
  42. </div>
  43. </template>
  44. <script>
  45. import { mapActions } from "vuex";
  46. import Toast from "toasters";
  47. import MainHeader from "../../components/layout/MainHeader.vue";
  48. import MainFooter from "../../components/layout/MainFooter.vue";
  49. import SecuritySettings from "./tabs/Security.vue";
  50. import AccountSettings from "./tabs/Account.vue";
  51. import ProfileSettings from "./tabs/Profile.vue";
  52. import PreferencesSettings from "./tabs/Preferences.vue";
  53. import io from "../../io";
  54. export default {
  55. components: {
  56. MainHeader,
  57. MainFooter,
  58. SecuritySettings,
  59. AccountSettings,
  60. ProfileSettings,
  61. PreferencesSettings
  62. },
  63. data() {
  64. return {
  65. activeTab: ""
  66. };
  67. },
  68. mounted() {
  69. if (this.$route.hash === "") {
  70. this.$router.push("#profile");
  71. } else {
  72. this.activeTab = this.$route.hash.replace("#", "");
  73. this.localNightmode = this.nightmode;
  74. io.getSocket(socket => {
  75. this.socket = socket;
  76. this.socket.emit("users.findBySession", res => {
  77. if (res.status === "success") {
  78. this.setUser(res.data);
  79. } else {
  80. new Toast({
  81. content: "You're not currently signed in.",
  82. timeout: 3000
  83. });
  84. }
  85. });
  86. this.socket.on("event:user.linkPassword", () =>
  87. this.updateOriginalUser("password", true)
  88. );
  89. this.socket.on("event:user.unlinkPassword", () =>
  90. this.updateOriginalUser("github", false)
  91. );
  92. this.socket.on("event:user.linkGithub", () =>
  93. this.updateOriginalUser("github", true)
  94. );
  95. this.socket.on("event:user.unlinkGithub", () =>
  96. this.updateOriginalUser("github", false)
  97. );
  98. });
  99. }
  100. },
  101. methods: {
  102. // changePassword() {
  103. // const { newPassword } = this;
  104. // if (!validation.isLength(newPassword, 6, 200))
  105. // return new Toast({
  106. // content: "Password must have between 6 and 200 characters.",
  107. // timeout: 8000
  108. // });
  109. // if (!validation.regex.password.test(newPassword))
  110. // return new Toast({
  111. // content:
  112. // "Invalid password format. Must have one lowercase letter, one uppercase letter, one number and one special character.",
  113. // timeout: 8000
  114. // });
  115. // return this.socket.emit(
  116. // "users.updatePassword",
  117. // newPassword,
  118. // res => {
  119. // if (res.status !== "success")
  120. // new Toast({ content: res.message, timeout: 8000 });
  121. // else
  122. // new Toast({
  123. // content: "Successfully changed password",
  124. // timeout: 4000
  125. // });
  126. // }
  127. // );
  128. // },
  129. ...mapActions("settings", ["updateOriginalUser", "setUser"])
  130. }
  131. };
  132. </script>
  133. <style lang="scss" scoped>
  134. @import "../../styles/global.scss";
  135. .container {
  136. @media only screen and (min-width: 900px) {
  137. width: 962px;
  138. margin: 0 auto;
  139. flex-direction: row;
  140. .content {
  141. width: 600px;
  142. margin-top: 0px;
  143. }
  144. }
  145. margin-top: 32px;
  146. padding: 24px;
  147. display: flex;
  148. flex-direction: column;
  149. .nav-links {
  150. height: 100%;
  151. width: 250px;
  152. margin-right: 64px;
  153. a {
  154. outline: none;
  155. border: none;
  156. box-shadow: none;
  157. color: $musare-blue;
  158. font-size: 22px;
  159. line-height: 26px;
  160. padding: 7px 0 7px 12px;
  161. width: 100%;
  162. text-align: left;
  163. cursor: pointer;
  164. border-radius: 5px;
  165. background-color: transparent;
  166. display: inline-block;
  167. &.active {
  168. color: $white;
  169. background-color: $musare-blue;
  170. }
  171. }
  172. }
  173. .content {
  174. margin: 24px 0;
  175. label {
  176. font-size: 14px;
  177. color: $dark-grey-2;
  178. padding-bottom: 4px;
  179. }
  180. input {
  181. height: 32px;
  182. }
  183. textarea {
  184. height: 96px;
  185. }
  186. input,
  187. textarea {
  188. border-radius: 3px;
  189. border: 1px solid $light-grey-2;
  190. }
  191. button {
  192. width: 100%;
  193. }
  194. }
  195. }
  196. .night-mode {
  197. label {
  198. color: #ddd !important;
  199. }
  200. }
  201. </style>