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.
68 lines
2.9 KiB
68 lines
2.9 KiB
{% extends "base.html" %}
|
|
{% block content %}
|
|
<link rel="stylesheet"
|
|
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
|
<script>hljs.highlightAll();</script>
|
|
<h1>Admin Dashboard</h1>
|
|
<article>
|
|
<p>Logged in as {{user}}</p>
|
|
<a href="{{url_for('chemical_create')}}">
|
|
<button>
|
|
Add a Chemical
|
|
</button>
|
|
</a>
|
|
<h2>Admin Authentication</h2>
|
|
<p>
|
|
Since there is now an admin, only admins can create new admin accounts. You can do so through the <code>/admin/create</code>
|
|
route.
|
|
</p>
|
|
<h2>API Routes</h2>
|
|
<ul>
|
|
<li><code>/chemical/all</code> - returns all chemicals in the database as JSON</li>
|
|
<li><code>/chemical/search</code> - returns JSON for search queries. This endpoint takes GET parameters as follows:
|
|
<ul>
|
|
<li>mz_min: Minimum M/Z Ratio</li>
|
|
<li>mz_max: Maximum M/Z Ratio</li>
|
|
<li>rt_min: Minimum Retention Time</li>
|
|
<li>rt_max: Maximum Retention Time</li>
|
|
</ul>
|
|
</li>
|
|
<li><code>/chemical/<chemical id>/{view,update,delete}</code> - CRUD endpoints for chemicals.</li>
|
|
</ul>
|
|
<h2>Programmatically adding Chemicals</h2>
|
|
<p>
|
|
You need admin credentials to access the <code>/chemical/create</code> endpoint, so using an HTTP library
|
|
like python's requests library is highly recommended for keeping track of session cookies.
|
|
</p>
|
|
<pre><code class="language-python">
|
|
import requests
|
|
session = requests.session()
|
|
baseurl = "chemicaldb.teidkim.me"
|
|
session.post(baseurl + "/admin/login", {"username": <username>, "password": <password>})
|
|
fields = {
|
|
"chemical_db_id": <db id from another database>,
|
|
"library": (library),
|
|
# name, formula, and mass are required fields!
|
|
"name": (name of the chemical),
|
|
"formula": (molecular formula),
|
|
"mass": (monoisotopic mass, float),
|
|
"pubchem_cid": <string>,
|
|
"pubmed_refcount": <integer>
|
|
"standard_class": <string>
|
|
"inchikey": <inchikey>,
|
|
"inchikey14": <inchikey14>,
|
|
# final_mz and final_rt are required fields!
|
|
"final_mz": (m/z ratio after experiment, float),
|
|
"final_rt": (retention time after experiment, float),
|
|
"final_adduct": <string>,
|
|
"final_adduct": <string>,
|
|
"detected_adducts": <string>,
|
|
"adduct_calc_mz": <string>,
|
|
"msms_detected": <string if yes, do not include this field otherwise>
|
|
"msms_purity": <float>
|
|
}
|
|
session.post(baseurl + "/chemical/create", fields)
|
|
</code></pre>
|
|
</article>
|
|
{% endblock %}
|