Blame view

src/components/Header.vue 3.19 KB
2b91d45ce   Digvijay Singh   new ui fixes
1
2
  <template>
    <nav class="navbar navbar-expand-sm spotLight-nav">
1f12ffc55   Digvijay Singh   issues fixation
3
      <a @click="goTo" class="navbar-brand" href="javasript:void(0);"
2b91d45ce   Digvijay Singh   new ui fixes
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        ><img src="../assets/images/logo.png"
      /></a>
      <button
        class="navbar-toggler"
        type="button"
        data-toggle="collapse"
        data-target="#navbarsExample03"
        aria-controls="navbarsExample03"
        aria-expanded="false"
        aria-label="Toggle navigation"
      >
        <span class="navbar-toggler-icon"></span>
        <span class="navbar-toggler-icon"></span>
        <span class="navbar-toggler-icon"></span>
      </button>
  
      <div class="collapse navbar-collapse" id="navbarsExample03">
        <!-- <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
1f12ffc55   Digvijay Singh   issues fixation
23
            <a class="nav-link" href="javasript:void(0);"avasript:void(0);"
2b91d45ce   Digvijay Singh   new ui fixes
24
25
          </li>
          <li class="nav-item">
1f12ffc55   Digvijay Singh   issues fixation
26
            <a class="nav-link" href="javasript:void(0);"avasript:void(0);"
2b91d45ce   Digvijay Singh   new ui fixes
27
28
          </li>
          <li class="nav-item">
1f12ffc55   Digvijay Singh   issues fixation
29
            <a class="nav-link" href="javasript:void(0);"avasript:void(0);"
2b91d45ce   Digvijay Singh   new ui fixes
30
31
          </li>
          <li class="nav-item">
1f12ffc55   Digvijay Singh   issues fixation
32
            <a class="nav-link" href="javasript:void(0);"avasript:void(0);"
2b91d45ce   Digvijay Singh   new ui fixes
33
34
35
36
          </li>
        </ul> -->
      </div>
      <div class="">
49055248c   Digvijay Singh   offline synching
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
        <a
          @click="goTo"
          href="javascript:void(0);"
          class="user-profile-photo common_color"
          v-if="usertoken"
        >
          <img :src="profilePictue"
        /></a>
        <a
          @click="goToLogin"
          href="javascript:void(0);"
          class="user-profile-photo insights-profile"
          v-if="!usertoken"
        >
          <img src="../assets/images/lock.svg"
2b91d45ce   Digvijay Singh   new ui fixes
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
        /></a>
        <div class="sub-menu-user" id="userprofileshow" style="display: none">
          <!-- <ul>
                <li>
                  <a href="javascript:void(0);" 
                    >Edit Profile</a
                  >
                </li>
                <li><a href="javascript:void(0);" @click="logout">Log Out</a></li>
              </ul> -->
        </div>
      </div>
    </nav>
  </template>
  
  <script>
  import $ from "jquery";
  import axios from "axios";
  export default {
    name: "Header",
    data() {
      return {
49055248c   Digvijay Singh   offline synching
74
75
        usertoken: null,
        profilePictue: null,
2b91d45ce   Digvijay Singh   new ui fixes
76
77
78
      };
    },
    mounted() {
49055248c   Digvijay Singh   offline synching
79

2b91d45ce   Digvijay Singh   new ui fixes
80
81
82
83
84
85
86
87
      var userdata = localStorage.getItem("spotlight_usertoken");
      if (userdata) {
        userdata = JSON.parse(userdata);
        this.usertoken = userdata.token;
        this.getProfile();
      }
    },
    methods: {
49055248c   Digvijay Singh   offline synching
88
      goTo() {
2b91d45ce   Digvijay Singh   new ui fixes
89
90
        this.$router.push("/profile");
      },
49055248c   Digvijay Singh   offline synching
91
92
93
94
95
96
      goToLogin() {
        localStorage.removeItem("spotlight_usertoken");
        localStorage.removeItem("spotlight_email");
        this.$router.push("/login");
      },
      getProfile() {
2b91d45ce   Digvijay Singh   new ui fixes
97
98
99
100
101
102
103
        axios
          .get("/profile", {
            headers: {
              Authorization: "Bearer " + this.usertoken,
            },
          })
          .then((response) => {
49055248c   Digvijay Singh   offline synching
104
105
            this.assignClass(response.data.data.bgColor);
            this.profilePictue = response.data.data.profilePic;
2b91d45ce   Digvijay Singh   new ui fixes
106
107
108
109
110
111
112
113
114
115
            console.log(response.data.data);
          })
          .catch((error) => console.log(error));
      },
      assignClass(bgClr) {
        var cols = document.getElementsByClassName("common_color");
        for (var i = 0; i < cols.length; i++) {
          cols[i].style.backgroundColor = bgClr;
        }
      },
49055248c   Digvijay Singh   offline synching
116
    },
2b91d45ce   Digvijay Singh   new ui fixes
117
118
  };
  </script>