-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserActivity.php
256 lines (251 loc) · 9.11 KB
/
UserActivity.php
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
include ("DBconnect.php");
include ("functions.php");
session_start();
if(!isset($_SESSION['username'])){
redirect('Login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<style>
.navbar.navTop{
font-weight: lighter;
padding-top: 15px;
}
.navbar.navBottom{
font-weight: lighter;
padding-bottom: 2px;
}
.navBottom .navbar-nav{
width: 100%;
margin: 0 auto;
}
.navBottom .navbar-nav .nav-item{
width: 20%;
}
.navBottom .navbar-nav .nav-item .nav-link{
text-align: center;
}
.navbar-toggler{
float: right;
}
.navbar-brand{
float: left;
}
.container-fluid{
background-color: #f8f9fa !important;
height: 91vh;
padding-bottom: 56px;
}
.row{
background-color: #f8f9fa !important;
}
.maincontainer{
padding: 0;
}
#chartContainer{
position: relative;
top: 20%;
height: 300px;
}
.card{
width: 100%;
}
.profilepic{
width: 35px;
height: 35px;
float: left;
display: block;
border-radius: 15px;
}
.list-group>li.list-group-item{
width: 100%;
text-align: left;
padding: 0px 20px;
}
.list-group>li.list-group-item>img{
margin: 12px 0px;
}
.list-group>li.list-group-item>a{
width: 87%;
text-decoration: none;
color: black;
padding: 12px 20px;
display: block;
float: left;
font-size: 20px;
font-weight: 500;
}
</style>
<script>
window.onload = function () {
$.ajax({
url: 'UserActivityAPI.php',
method: 'POST',
data: {
getActivity: 1,
limit: 5
},
success: function(response) {
plotGraph(JSON.parse(response));
}
});
function plotGraph(data){
console.log(data);
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
exportEnabled: true,
title:{
text: "Picturesque Top Users"
},
axisY:{
title: "Number"
},
toolTip: {
shared: true
},
legend:{
cursor:"pointer",
itemclick: toggleDataSeries
},
data: [{
type: "spline",
name: data[0].username,
showInLegend: true,
dataPoints: [
{ label: "Posts" , y: parseInt(data[0].posts_published) },
{ label: "Comments", y: parseInt(data[0].comments_made) },
{ label: "Post Likes", y: parseInt(data[0].posts_liked) },
{ label: "Comment Likes", y: parseInt(data[0].comments_liked) }
]
},
{
type: "spline",
name: data[1].username,
showInLegend: true,
dataPoints: [
{ label: "Posts" , y: parseInt(data[1].posts_published) },
{ label: "Comments", y: parseInt(data[1].comments_made) },
{ label: "Post Likes", y: parseInt(data[1].posts_liked) },
{ label: "Comment Likes", y: parseInt(data[1].comments_liked) }
]
},
{
type: "spline",
name: data[2].username,
showInLegend: true,
dataPoints: [
{ label: "Posts" , y: parseInt(data[2].posts_published) },
{ label: "Comments", y: parseInt(data[2].comments_made) },
{ label: "Post Likes", y: parseInt(data[2].posts_liked) },
{ label: "Comment Likes", y: parseInt(data[2].comments_liked) }
]
},
{
type: "spline",
name: data[3].username,
showInLegend: true,
dataPoints: [
{ label: "Posts" , y: parseInt(data[3].posts_published) },
{ label: "Comments", y: parseInt(data[3].comments_made) },
{ label: "Post Likes", y: parseInt(data[3].posts_liked) },
{ label: "Comment Likes", y: parseInt(data[3].comments_liked) }
]
},
{
type: "spline",
name: data[4].username,
showInLegend: true,
dataPoints: [
{ label: "Posts" , y: parseInt(data[4].posts_published) },
{ label: "Comments", y: parseInt(data[4].comments_made) },
{ label: "Post Likes", y: parseInt(data[4].posts_liked) },
{ label: "Comment Likes", y: parseInt(data[4].comments_liked) }
]
}]
});
chart.render();
function toggleDataSeries(e) {
if(typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
chart.render();
}
}
}
</script>
<title>User Activity</title>
<link rel="shortcut icon" href="assets/images/PicturesqueLogo.png" type="image/png">
</head>
<body>
<nav class="navbar navTop sticky-top navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="./Home.php">
<img src="assets/images/PicturesqueLogo.png" width="30" height="30" class="d-inline-block align-top" alt="">
Picturesque
</a>
<form class="form-inline my-lg-0" action="Logout.php">
<?php
if(!isset($_SESSION['username'])){
echo '<button class="btn btn-outline-success my-sm-0" type="submit" style="width: 100%">Login</button>';
}
else{
echo '<button class="btn btn-outline-info my-sm-0" type="submit" style="width: 100%">Logout</button>';
}
?>
</form>
</nav>
<div class="container-fluid">
<div class = "row">
<div class="maincontainer col-xs-12 offset-md-3 col-md-6">
<br>
<div id="chartContainer">
</div>
</div>
</div>
</div>
<nav class="navbar navBottom fixed-bottom navbar-dark bg-dark navbar-expand">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="Home.php">
<i class="material-icons md-light">home</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Search.php">
<i class="material-icons md-light">search</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Upload.php">
<i class="material-icons md-light">add_box</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Requests.php">
<i class="material-icons md-light">supervisor_account</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Profile.php">
<i class="material-icons md-light">account_circle</i>
</a>
</li>
</ul>
</nav>
<script type="text/javascript">
</script>
</body>
</html>