You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.9 KiB

2 years ago
2 years ago
2 years ago
  1. {% extends "base.html" %}
  2. {% block content %}
  3. <link rel="stylesheet"
  4. href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
  5. <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
  6. <script>hljs.highlightAll();</script>
  7. <h1>Admin Dashboard</h1>
  8. <article>
  9. <p>Logged in as {{user}}</p>
  10. <a href="{{url_for('chemical_create')}}">
  11. <button>
  12. Add a Chemical
  13. </button>
  14. </a>
  15. <h2>Admin Authentication</h2>
  16. <p>
  17. Since there is now an admin, only admins can create new admin accounts. You can do so through the <code>/admin/create</code>
  18. route.
  19. </p>
  20. <h2>API Routes</h2>
  21. <ul>
  22. <li><code>/chemical/all</code> - returns all chemicals in the database as JSON</li>
  23. <li><code>/chemical/search</code> - returns JSON for search queries. This endpoint takes GET parameters as follows:
  24. <ul>
  25. <li>mz_min: Minimum M/Z Ratio</li>
  26. <li>mz_max: Maximum M/Z Ratio</li>
  27. <li>rt_min: Minimum Retention Time</li>
  28. <li>rt_max: Maximum Retention Time</li>
  29. </ul>
  30. </li>
  31. <li><code>/chemical/&lt;chemical id&gt;/{view,update,delete}</code> - CRUD endpoints for chemicals.</li>
  32. </ul>
  33. <h2>Programmatically adding Chemicals</h2>
  34. <p>
  35. You need admin credentials to access the <code>/chemical/create</code> endpoint, so using an HTTP library
  36. like python's requests library is highly recommended for keeping track of session cookies.
  37. </p>
  38. <pre><code class="language-python">
  39. import requests
  40. session = requests.session()
  41. baseurl = "chemicaldb.teidkim.me"
  42. session.post(baseurl + "/admin/login", {"username": (username), "password": (password)})
  43. fields = {
  44. "chemical_db_id": &lt;db id from another database&gt;,
  45. "library": (library, is a string),
  46. # name, formula, and mass are required fields!
  47. "name": (name of the chemical, is a string),
  48. "formula": (molecular formula, is a string),
  49. "mass": (monoisotopic mass, is a float),
  50. "pubchem_cid": &lt;string&gt;,
  51. "pubmed_refcount": &lt;integer&gt;
  52. "standard_class": &lt;string&gt;
  53. "inchikey": &lt;string&gt;,
  54. "inchikey14": &lt;string&gt;,
  55. # final_mz and final_rt are required fields!
  56. "final_mz": (m/z ratio after experiment, is a float),
  57. "final_rt": (retention time after experiment, is a float),
  58. "final_adduct": &lt;string&gt;,
  59. "final_adduct": &lt;string&gt;,
  60. "detected_adducts": &lt;string&gt;,
  61. "adduct_calc_mz": &lt;string&gt;,
  62. "msms_detected": &lt;string if yes, do not include this field otherwise&gt;
  63. "msms_purity": &lt;float&gt;
  64. }
  65. session.post(baseurl + "/chemical/create", fields)
  66. </code></pre>
  67. </article>
  68. {% endblock %}