Guest User

Untitled

a guest
Nov 22nd, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. console.log("CONNECTED TO JAVASCRIPT BABY @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  2.  
  3. /**
  4. * Register drag and drop.
  5. * Clear out all gobal variables and reset them to blank.
  6. */
  7. function loadDataUploadView() {
  8. dataUpload.clear_high_dimensional_input('divDataNode');
  9. dataUpload.register_drag_drop();
  10. };
  11.  
  12. // constructor
  13. var DataUploadView = function () {
  14. RmodulesView.call(this);
  15. this.display_patients_list();
  16. };
  17.  
  18. // inherit RmodulesView
  19. DataUploadView.prototype = new RmodulesView();
  20.  
  21. // correct the pointer
  22. DataUploadView.prototype.constructor = DataUploadView;
  23.  
  24. // list of patients to add
  25. DataUploadView.prototype.patients = [];
  26.  
  27. // submit analysis job
  28. DataUploadView.prototype.submit_job = function () {
  29. console.log("SUBMITTING JOB BABY @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  30.  
  31. // get formParams
  32. var formParams = this.get_form_params();
  33. console.log(formParams);
  34.  
  35. // if formParams are submitable
  36. if (this.parameters_are_valid(formParams)) {
  37. console.log("TRYING TO SUBMIT FORM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  38. submitJob(formParams);
  39. }
  40. };
  41.  
  42. // display the listof patients that are going to uploaded
  43. DataUploadView.prototype.display_patients_list = function () {
  44. if (this.patients.length == 0){
  45. document.getElementById("patientList").innerHTML = "No Patients to Upload";
  46. } else {
  47. document.getElementById("patientList").innerHTML = this.patients;
  48. }
  49.  
  50. };
  51.  
  52. // add patient to upload
  53. DataUploadView.prototype.add_patient = function () {
  54. var new_patient = document.getElementById("entered_patient_id").value;
  55. document.getElementById("entered_patient_id").value = "";
  56. if (new_patient != "") {
  57. this.patients.push(new_patient);
  58. }
  59. this.display_patients_list();
  60. };
  61.  
  62. // get form params
  63. DataUploadView.prototype.get_form_params = function () {
  64. console.log("GETTING FORM PARAMETERS BABY @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  65. return {
  66. studyId: document.getElementById('studyId').value,
  67. topNode: document.getElementById('topNode').value,
  68. studyName: document.getElementById('studyName').value,
  69. phenotipsAddress: document.getElementById('phenotipsAddress').value,
  70. phenoUsername: document.getElementById('phenoUsername').value,
  71. phenoPassword: document.getElementById('phenoPassword').value,
  72. patientIds: this.patients,
  73. jobType: 'DataUpload'
  74. };
  75. };
  76.  
  77. // check if paramters are valid
  78. DataUploadView.prototype.parameters_are_valid = function(form_params) {
  79. console.log("VALIDATING THE FORM DATA BABY @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  80. var keys = [
  81. 'studyId',
  82. 'topNode',
  83. 'studyName',
  84. 'phenotipsAddress',
  85. 'phenoUsername',
  86. 'phenoPassword',
  87. 'patientIds'
  88. ];
  89. console.log("keys length: " + keys.length);
  90. for (var i = 0; i < keys.length; i++){
  91. console.log("key: " + keys[i]);
  92. if (form_params.hasOwnProperty(keys[i])){
  93. if (form_params[keys[i]] == null) {
  94. console.log("missing value in for: " + keys[i]);
  95. return false;
  96. }
  97. } else {
  98. console.log("form missing parameters");
  99. return false;
  100. }
  101. }
  102. return true;
  103. };
  104.  
  105. // init heat map view instance
  106. var dataUpload = new DataUploadView();
Add Comment
Please, Sign In to add comment