outposts: load token async
This commit is contained in:
parent
189b0ec324
commit
d3a96ac7aa
|
@ -24,7 +24,7 @@
|
|||
<label class="pf-c-form__label" for="help-text-simple-form-name">
|
||||
<span class="pf-c-form__label-text">PASSBOOK_TOKEN</span>
|
||||
</label>
|
||||
<input class="pf-c-form-control" readonly type="text" value="{{ outpost.token.token_uuid.hex }}" />
|
||||
<input class="pf-c-form-control" data-pb-fetch-key="pk" data-pb-fetch-fill="{% url 'passbook_api:token-detail' identifier=outpost.token_identifier %}" readonly type="text" value="" />
|
||||
</div>
|
||||
<h3>{% trans 'If your passbook Instance is using a self-signed certificate, set this value.' %}</h3>
|
||||
<div class="pf-c-form__group">
|
||||
|
|
|
@ -7,6 +7,7 @@ document.querySelectorAll("button.pf-c-dropdown__toggle").forEach((b) => {
|
|||
});
|
||||
});
|
||||
|
||||
// Search clearing
|
||||
document.querySelectorAll("input[type=search]").forEach((si) => {
|
||||
si.addEventListener("search", (e) => {
|
||||
if (si.value === "") {
|
||||
|
@ -15,6 +16,16 @@ document.querySelectorAll("input[type=search]").forEach((si) => {
|
|||
});
|
||||
});
|
||||
|
||||
// Fetch from data-attributes
|
||||
document.querySelectorAll("[data-pb-fetch-fill]").forEach((el) => {
|
||||
const url = el.dataset.pbFetchFill;
|
||||
const key = el.dataset.pbFetchKey;
|
||||
fetch(url).then(r => r.json()).then(r => {
|
||||
el.textContent = r[key];
|
||||
el.value = r[key];
|
||||
});
|
||||
});
|
||||
|
||||
// Modal
|
||||
document.querySelectorAll("[data-target='modal']").forEach((m) => {
|
||||
m.addEventListener("click", (e) => {
|
||||
|
|
Reference in New Issue