forked from jiepengwong/ESDT4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyprofile.html
194 lines (170 loc) · 7.67 KB
/
myprofile.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Profile</title>
<!-- External CSS for navbar -->
<link rel="stylesheet" href="style.css">
<!-- External CSS for navbar -->
<link rel="stylesheet" href="style.css">
<!--bootstrap css-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<!--axios-->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<!--Vue-->
<script src="https://unpkg.com/vue@next"></script>
<!-- Google Auth0 -->
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
<meta name="google-signin-client_id" content="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com">
<link rel="icon" href="./asset/HenesysSmallLogo.png">
<style>
body {
background-color: lightgreen;
}
.labels {
font-size: 11px
}
</style>
</head>
<body>
<div id="app">
<!-- This is where the NAVBAR IS!! ############## -->
<navbar></navbar>
<!-- This is where the NAVBAR ENDS!! ############## -->
<!--THIS IS WHERE ThE PROFILE IS..################ -->
<div class="container rounded bg-white mt-5 mb-5">
<div class="row">
<div class="col-md-5 border-right">
<div class="d-flex flex-column align-items-center text-center p-3 py-5">
<img class="rounded-circle img-fluid mt-5" src="./asset/profile.jpg">
<span class="font-weight-bold">{{name}}</span><span class="text-black-50">{{email}}</span><span> </span></div>
</div>
<div class="col-md-7 border-right">
<div class="p-3 py-5">
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="text-right">Profile Information</h4>
</div>
<div class="row mt-3">
<div class="col-md-12"><label class="labels">Id Number</label><input type="text" class="form-control" v-bind:value="id" disabled></div>
<div class="col-md-12"><label class="labels">Your Name</label><input type="text" class="form-control" v-bind:value="name" disabled></div>
<div class="col-md-12"><label class="labels">Email</label><input type="text" class="form-control" v-bind:value="email" disabled></div>
<div class="col-md-12"><label class="labels">Ratings</label><input type="text" class="form-control" v-bind:value="ratings" disabled></div>
<div class="col-md-12"><label class="labels">Mobile Number</label><input type="text" class="form-control" v-bind:value="mobile" disabled></div>
<div class="col-md-12"><a href="./Insertmobile.php">Update my Mobile Number</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="./narbar.js"></script>
<script>
// VUE PORTION GOES IN HERE #################################################################################
const app = Vue.createApp({
data() {
return {
// THE JSON DATA IS TAKEN FROM THE Google Chrome
jsondata: localStorage.login,
id: localStorage.id,
name: "",
mobile: "",
email: "",
ratings: "",
}
},
async mounted() {
this.checkLogin()
try{
var getItemUrl = "http://localhost:5000/profile/" + localStorage.id
console.log(getItemUrl)
var databaseitems = await fetch(getItemUrl)
const profile_json = await databaseitems.json()
if (databaseitems.status === 200){
console.log(profile_json)
// Get all the databases
localStorage.login = JSON.stringify(profile_json.data)
jsondata_obj = JSON.parse(localStorage.login)
this.name = jsondata_obj['name'];
this.mobile = jsondata_obj['mobile'];
this.email = jsondata_obj['email'];
this.ratings = jsondata_obj['ratings'];
console.log(this.mobile)
if (this.ratings == null){
this.ratings = "There is no ratings yet";
}
if (this.mobile == '' || this.mobile == null) {
this.mobile = "There is no mobile input yet";
}
}
else{
console.log("Database not connected")
}
}
catch(error) {
console.log(error)
}
},
methods: {
checkLogin() {
// If the login variable is initalised, then we will redirect them to
if (localStorage.getItem("id")){
// redirect them to login page
// window.location.replace("./catalogue.php");
}
else {
console.log("i need to route")
window.location.replace("./");
}
},
},
computed: {
},
},
)
app.component("navbar",{
template: template1,
data() {
return{
links: links1,
isSignedIn: localStorage.getItem("id"),
}
},
methods:{
signOut() {
let gapi = window.gapi;
let clientId ="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com";
let apiKey ="AIzaSyC0WtHoYqLnGKgaqLWX6RGkiL0X2C7dll8";
let secretClientId = "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";
let discoveryDocs =["https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest"];
let scope ="https://www.googleapis.com/auth/userinfo.profile";
gapi.load("client:auth2", () => {
gapi.client.init({
apiKey,
clientId,
discoveryDocs,
scope,
secretClientId,})
.then(() => {
var GoogleAuthObj = gapi.auth2.getAuthInstance();
this.GoogleAuth = GoogleAuthObj.signOut();
this.isSignedIn = false;
})
})
localStorage.removeItem("login")
localStorage.removeItem("id")
alert("You have been logged out!")
location.reload()
},
}
})
const vm = app.mount('#app');
</script>
</html>