-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers-sidebar.html
193 lines (149 loc) · 8.09 KB
/
users-sidebar.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
<!DOCTYPE html>
<html ng-app="pelotonApp">
<head>
<style>
</style>
<base target="_top">
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script>
angular.module('pelotonApp', [])
.controller('PelotonUserController', function($scope, $httpParamSerializer) {
var userController = this;
userController.loading=false;
userController.users=[];
userController.searchText="";
userController.batchProcessing=false;
userController.followUser=function(user_id){
var myUserId=user_id;
google.script.run.withSuccessHandler(function(result){
if(result){
userController.users.map(function(user){ if(user.id==myUserId) user.relationship=result;});
$scope.$digest();
}
}).followUser(user_id);
}
userController.unfollowUser=function(user_id){
var myUserId=user_id;
google.script.run.withSuccessHandler(function(result){
if(result){
userController.users.map(function(user){ if(user.id==myUserId) user.relationship=result;});
$scope.$digest();
}
}).unfollowUser(user_id);
}
userController.reprocessUser=function(user){
user.loading=true;
google.script.run.withSuccessHandler(function(result){
user.loading=false;
$scope.$digest();
}).reprocessUser(user.id, user.username);
}
userController.processIncremental=function(user){
var name=user.username;
user.loading=true;
google.script.run.withSuccessHandler(function(result){
user.loading=false;
alert("Total rides loaded for "+name+": " +result);
$scope.$digest();
}).populateWorkoutsIncrementally(user.id, user.username);
};
userController.processSelectedIncremental=function(){
userController.batchProcessing=true;
google.script.run.withSuccessHandler(function(result){
userController.batchProcessing=false;
alert("Loaded "+result+" workouts");
$scope.$digest();
}).incrementalProcessSelectedUsers();
}
userController.searchUsers=function(){
userController.searchText = userController.searchText.replace(/[^A-Za-z0-9_]/gi, "");
userController.users=[];
if(userController.searchText=="") return;
userController.loading=true;
google.script.run.withSuccessHandler(function(result){
console.log(JSON.stringify(result));
userController.users=result;
userController.users.map(user=>{user.loading=false;});
userController.loading=false;
$scope.$digest();
})
.searchUsers(userController.searchText);
};
userController.displayUser=function(user_id){
google.script.run.displayUser(user_id);
}
});
</script>
</head>
<body ng-controller="PelotonUserController as peloton" >
<div class="card" style="width: 18rem;">
<button class="badge badge-primary" ng-disabled="peloton.batchProcessing" ng-click="peloton.processSelectedIncremental()">
<i ng-if="peloton.batchProcessing" class="fa fa-circle-o-notch fa-spin fa-fw"></i> INCREMENTAL - Process Selected</button>
<div class="card-header">Find Users</div>
<div class="card-body">
<form id="user-filter-form">
<div>
<input type='text' placeholder='Leaderboard Name'
ng-model='peloton.searchText'
ng-model-options='{ debounce: 1500 }'
ng-change='peloton.searchUsers()'
/>
</div>
<div ng-if="peloton.loading" style="text-align:center"> <i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
</form>
</div>
<div class="card-footer">
<!--button ng-disabled="! peloton.totalRides" ng-click="peloton.loadRides()"
class="badge badge-pill badge-danger" id="load">Load <span id='total' ng-show="peloton.totalRides!=null">{{peloton.totalRides}}</span> Classes </button>
<a ng-disabled="! peloton.totalRides" target="_blank" class="text-danger" title="Search on Peloton Site" href="https://members.onepeloton.com/classes/cycling?utm_source=ios_app&utm_medium=in_app&{{peloton.getQueryParams()}}">
<span class="fa fa-share"></span>
</a>
</div-->
</div>
</div>
<ul id="users" class="list-unstyled">
<li class="media mt-1 ml-2 mb-2" ng-repeat="user in peloton.users" style="max-width: 400px">
<img style="max-width:50px; max-height:50px;" class=" rounded mr-3" src="{{user.image_url}}" alt="{{user.username}}">
<div class="media-body">
<h5 class="mt-0 mb-1">{{user.username}}</h5>
<h6 class="card-subtitle" ng-if="user.location">{{user.location}}</h6>
<small>
<span ng-if="user.is_profile_private" class="text-muted">This profile is private. <br/></span>
<span >{{user.total_followers}} Followers. {{user.total_following}} following {{user.total_workouts}} workouts</span>
<div ng-if="user.relationship">
Relationship: Me to user: {{user.relationship.me_to_user}} // User to me: {{user.relationship.user_to_me}}
<br/>
<button ng-if="user.relationship.me_to_user=='following'" ng-click="peloton.unfollowUser(user.id)" class="badge badge-pill badge-secondary">Unfollow</button>
<button ng-if="user.relationship.me_to_user=='none'" ng-click="peloton.followUser(user.id)" class="badge badge-pill badge-primary">Follow</button>
<button ng-if="user.relationship.me_to_user=='follow_pending'" disabled="true" class="badge badge-pill badge-secondary">Follow Requested</button>
<button ng-if="user.relationship.me_to_user=='following' || !user.is_profile_private"
ng-click="peloton.reprocessUser(user)" class="badge badge-pill badge-secondary" ng-disabled="user.loading">
<i ng-if="user.loading" class="fa fa-circle-o-notch fa-spin fa-fw"></i>
Reload Existing Results (If any)</button>
<button ng-if="user.relationship.me_to_user=='following' || !user.is_profile_private"
ng-click="peloton.processIncremental(user)" class="badge badge-pill badge-secondary" ng-disabled="user.loading">
<i ng-if="user.loading" class="fa fa-circle-o-notch fa-spin fa-fw"></i>
INCREMENTAL - Load new Results (If any)</button>
</div>
<!--<span ng-if="ride.user_workouts" class="badge badge-pill badge-success" title="You took this ride {{ride.user_workouts}} time(s)">Taken</span>
button ng-if="ride.is_favorite" ng-click="peloton.clearBookmark(ride)" class="badge badge-pill badge-secondary">Bookmarked</button>
<button ng-if="!ride.is_favorite" ng-click="peloton.addBookmark(ride)" class="badge badge-pill badge-info">Add Bookmark</button
<h5 class="card-title">{{ride.title}}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{ride.instructor.name}}<br>Aired on {{ride.aired | date:'MM/dd/yyyy @ h:mma'}}</h6>
<p class="card-text">{{ride.description}}</p>-->
<!--<small class="text-muted">{{user.total_workouts}} total workouts</small>-->
<button ng-click="peloton.displayUser(user.id)" data-user-id="{{user.id}}" class="ride-load-button badge-pill badge badge-danger">Show Details</button>
<a target="_blank" class="text-danger" title="Open on Peloton Site" href="https://members.onepeloton.com/members/{{user.username}}/overview">
<span class="fa fa-share"></span>
</a>
</small>
</div>
<span class="border-bottom"></span>
</li>
</ul>
</body>
</html>