Skip to content

Commit

Permalink
Working on frontend. Need a way to get logged in user id. #60
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdellomes committed Jan 17, 2017
1 parent eada07c commit bb95ef2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion routes/view_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var viewRoutes = [
},

{
path: '/userprofile',
path: '/profile',
method: 'GET',
config: {
auth: false
Expand Down
48 changes: 48 additions & 0 deletions static/js/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$(function (event) {

var table = $('#followups');
var tableBody = $('#followups > tbody');

var getCaseManagerFollowUps = function (casemanagerID) {
$.ajax({
xhrFields: {
withCredentials: true
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', localStorage.getItem("authorization"));
},
url: 'api/followups/' + casemanagerID,
data: casemanagerID,
method: 'GET',
success: function (data) {
console.log(data);
tableBody.empty();

var followups = data.result.rows;

table = table.DataTable();

followups.forEach(function (followup) {
tableBody.append('<tr>
<td>' + followup.id + '</td>
<td>' + followup.timestamp + '</td>
<td>' + followup.note + '</td>
<td>' + followup.client_id + '</td>
<td>' + followup.location + '</td>
</tr>')
});

},
error: function (xhr) {
console.log(xhr);

if (xhr.status === 401) {
localStorage.removeItem("authorization");
}
}
}).done(function (data) {

});
};

});
23 changes: 17 additions & 6 deletions templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
{% include "components/_navbar.html" %}
<div class="row">
<div class="col-lg-12">
<table id="followups">
<table id="followups" class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Timestamp</th>
<th>Note</th>
<th>Client</th>
<th>Location</th>
<th>ID</th>
<th>Timestamp</th>
<th>Note</th>
<th>Client</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>7/20/2017</td>
<td>Test</td>
<td>John Doe</td>
<td>Office</td>
</tr>
</tbody>
</table>
</div>
</div>
Expand Down

0 comments on commit bb95ef2

Please sign in to comment.