notification.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function showUnfinishedUploadDialog(projectId, projectName, dateTime, count) {
  2. var alertDiv = document.createElement('div');
  3. alertDiv.classList.add('alert-notification');
  4. var message = document.createTextNode("You have an incomplete data upload for "+projectName+" ("+count+" files remaining) that was started at "+dateTime+". Would you like to continue it?");
  5. var continueButton = document.createElement('button');
  6. continueButton.classList.add('button');
  7. continueButton.classList.add('continue');
  8. continueButton.appendChild(document.createTextNode("Continue"));
  9. var forgetButton = document.createElement('button');
  10. forgetButton.classList.add('button');
  11. forgetButton.classList.add('cancel');
  12. forgetButton.appendChild(document.createTextNode("Forget Upload"));
  13. var closeButton = document.createElement('button');
  14. closeButton.classList.add('alert-close');
  15. closeButton.appendChild(document.createTextNode("X"));
  16. alertDiv.appendChild(message);
  17. alertDiv.appendChild(document.createTextNode(" "));
  18. alertDiv.appendChild(continueButton);
  19. alertDiv.appendChild(document.createTextNode(" "));
  20. alertDiv.appendChild(forgetButton);
  21. alertDiv.appendChild(document.createTextNode(" "));
  22. alertDiv.appendChild(closeButton);
  23. continueButton.addEventListener("click", function() {
  24. window.location = "/dashboard/data/?resume="+projectId;
  25. });
  26. forgetButton.addEventListener("click", function() {
  27. var data = {
  28. "project_id": projectId
  29. };
  30. var doForget = confirm("Are you sure you want to abandon this upload?");
  31. if(doForget) {
  32. var promise = ajaxPost("/api/forgetupload", data);
  33. promise.success = function() {
  34. document.getElementById("message-center").removeChild(alertDiv);
  35. };
  36. }
  37. });
  38. closeButton.addEventListener("click", function() {
  39. document.getElementById("message-center").removeChild(alertDiv);
  40. });
  41. document.getElementById("message-center").appendChild(alertDiv);
  42. }
  43. function errorMessage(message) {
  44. var alertDiv = document.createElement('div');
  45. alertDiv.classList.add('alert-notification');
  46. var messageNode = document.createTextNode(message);
  47. alertDiv.appendChild(messageNode);
  48. document.getElementById("message-center").appendChild(alertDiv);
  49. }
  50. function superadminNotice() {
  51. var alertDiv = document.createElement('div');
  52. alertDiv.classList.add('alert-notification');
  53. var messageNode = document.createTextNode("Super User Account");
  54. alertDiv.appendChild(messageNode);
  55. document.getElementById("message-center").appendChild(alertDiv);
  56. }