index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 } 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. import io from "../../io";
  58. export default {
  59. components: {
  60. MainHeader,
  61. MainFooter,
  62. SecuritySettings,
  63. AccountSettings,
  64. ProfileSettings,
  65. PreferencesSettings
  66. },
  67. mixins: [TabQueryHandler],
  68. data() {
  69. return {
  70. tab: "profile"
  71. };
  72. },
  73. mounted() {
  74. if (
  75. this.$route.query.tab === "profile" ||
  76. this.$route.query.tab === "security" ||
  77. this.$route.query.tab === "account" ||
  78. this.$route.query.tab === "preferences"
  79. )
  80. this.tab = this.$route.query.tab;
  81. this.localNightmode = this.nightmode;
  82. io.getSocket(socket => {
  83. this.socket = socket;
  84. this.socket.emit("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. },
  120. methods: mapActions("settings", ["updateOriginalUser", "setUser"])
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. @import "../../styles/global.scss";
  125. /deep/ .character-counter {
  126. display: flex;
  127. justify-content: flex-end;
  128. height: 0;
  129. }
  130. .container {
  131. margin-top: 32px;
  132. padding: 24px;
  133. .content {
  134. background-color: #fff;
  135. padding: 30px 50px;
  136. border-radius: 3px;
  137. }
  138. #page-title {
  139. margin-top: 0;
  140. font-size: 35px;
  141. }
  142. #sidebar-with-content {
  143. display: flex;
  144. flex-direction: column;
  145. }
  146. @media only screen and (min-width: 900px) {
  147. #page-title {
  148. margin: 0;
  149. font-size: 40px;
  150. }
  151. #sidebar-with-content {
  152. width: 962px;
  153. margin: 0 auto;
  154. margin-top: 30px;
  155. flex-direction: row;
  156. .content {
  157. width: 600px;
  158. margin-top: 0px !important;
  159. }
  160. }
  161. }
  162. .nav-links {
  163. width: 250px;
  164. margin-right: 64px;
  165. a {
  166. outline: none;
  167. border: none;
  168. box-shadow: none;
  169. color: $musare-blue;
  170. font-size: 22px;
  171. line-height: 26px;
  172. padding: 7px 0 7px 12px;
  173. width: 100%;
  174. text-align: left;
  175. cursor: pointer;
  176. border-radius: 5px;
  177. background-color: transparent;
  178. display: inline-block;
  179. &.active {
  180. color: $white;
  181. background-color: $musare-blue;
  182. }
  183. }
  184. }
  185. /deep/ .content {
  186. margin: 24px 0;
  187. height: fit-content;
  188. .save-changes {
  189. margin-top: 30px;
  190. &:disabled {
  191. background-color: $light-grey !important;
  192. color: #000;
  193. }
  194. }
  195. .control:not(:first-of-type) {
  196. margin: 10px 0;
  197. }
  198. label {
  199. font-size: 14px;
  200. color: $dark-grey-2;
  201. }
  202. textarea {
  203. height: 96px;
  204. }
  205. button {
  206. width: 100%;
  207. }
  208. }
  209. }
  210. /deep/ .saving-changes-transition-enter-active {
  211. transition: all 0.1s ease;
  212. }
  213. /deep/ .saving-changes-transition-enter {
  214. transform: translateX(20px);
  215. opacity: 0;
  216. }
  217. </style>