diff --git a/BadgerProgram/samplesserver/static/scripts.js b/BadgerProgram/samplesserver/static/scripts.js index 000b382..d0bd31d 100644 --- a/BadgerProgram/samplesserver/static/scripts.js +++ b/BadgerProgram/samplesserver/static/scripts.js @@ -56,7 +56,7 @@ function populatePatientsTable(patients) { }); if (patients[0]) { var table = $("
| Patient ID | ")); @@ -361,28 +361,36 @@ function populateSessionsTable(sessions) { $("#page-specific").append(table); $.each(sessions, function(index, session) { var row = $("|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ").text(session.start_time)); - row.append($(" | ").text(session.end_time)); - row.append($(" | ").text(session.course_id)); - row.append($(" | ").text(session.patient_id)); - row.append($(" | ").text(session.instructor_id)); - row.append($(" | ").text(session.sample_rate + " Hz")); - row.append($(" | ").text(session.resolution)); - var editButton = $("") + $.get("/api/courses/"+session.course_id).done(function(course) + { + $.get("/api/patients/"+session.patient_id).done(function(patient){ + $.get("/api/instructors/"+session.instructor_id).done(function(instructor){ + row.append($(" | ").text(session.start_time)); + row.append($(" | ").text(session.end_time)); + row.append($(" | ").text(course.name)); + row.append($(" | ").text(patient.code)); + row.append($(" | ").text(instructor.name)); + row.append($(" | ").text(session.sample_rate + " Hz")); + row.append($(" | ").text(session.resolution)); + var editButton = $("") .addClass("btn btn-default") .attr("id","edit" + session.id); row.append($(" | ").append(editButton)); editButton.click(function() { - editSessionForm(session.id); - }); + editSessionForm(session.id); + }); var sampleButton = $(" | ") .addClass("btn btn-default") .attr("id", "samples" + session.id); sampleButton.click(function() { page("/sessions/" + session.id); - }); + }); row.append($("").append(sampleButton));
$("#sessions-table tbody").append(row);
+
+ });
+ });
+ });
});
}
@@ -394,16 +402,16 @@ function editSessionForm(id) {
$.get("/api/courses")
)
.done(function(session, instructors, patients, courses) {
- $("#page-specific").empty();
+ $("#page-specific").empty();
showNavLinks();
$("#page-specific").append("Edit session"); var source = $("#session-form-template").html(); var template = Handlebars.compile(source); var data = { session: session, - instructors: instructors.instructors, - courses: courses.courses, - patients: patients.patients + instructors: instructors[0].instructors, + courses: courses[0].courses, + patients: patients[0].patients }; $.each(instructors, function(index, instructor) { if (instructor.id === session.instructor_id) { |