Skip to content

Commit

Permalink
fix: status section
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Mar 14, 2024
1 parent 160e4ca commit fb54007
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
7 changes: 2 additions & 5 deletions web/sub-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@

<div class="flex">
<label for="expires" class="pt-2 w-20 flex" style="margin-top: 0.125rem">Expires</label>
<div class="mt-2 mr-2">
<input type="datetime-local" id="expires" class="border outline-none border-slate-400 dark:border-slate-700 dark:background-gray-800"/>
<div class="w-20" id="expires-never" style="margin-top: 0.125rem; display: none">Never</div>
</div>
<input type="datetime-local" id="expires" class="mt-2 h-5 border outline-none border-slate-400 dark:border-slate-700 dark:background-gray-800"/>
</div>

<div class="flex">
<div class="flex" style="display: none">
<label for="enabled" class="pt-2 w-20" style="margin-top: 0.125rem">Enabled</label>
<input type="checkbox" id="enabled" class="je-checkbox mt-2"/>
</div>
Expand Down
13 changes: 6 additions & 7 deletions web/sub-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ function loadSubscription() {
document.getElementById("enabled").checked = data.enabled;
const expires = new Date(data.expires);
if (!isNaN(expires) && expires > 0) {
document.getElementById("expires").value = data.expires;
document.getElementById("expires").style.display = "block";
document.getElementById("expires-never").style.display = "none";
} else {
document.getElementById("expires").style.display = "none";
document.getElementById("expires-never").style.display = "block";
document.getElementById("expires").value = data.expires.substring(0, 16);
}
editor.setValue(data.cond);
}
Expand All @@ -78,9 +73,13 @@ function updateSubscription() {
let payload = {
id: id,
description: document.getElementById("description").value,
enabled: true,
enabled: document.getElementById("enabled").checked,
cond: editor.getValue(0),
}
const expires = document.getElementById("expires").value;
if (expires && expires !== "") {
payload.expires = expires;
}
let optsReq = {
method: "PUT",
headers: {
Expand Down
15 changes: 12 additions & 3 deletions web/sub-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@
<div class="flex justify-center m-1">
<form class="space-y-2 max-w-[800px] grow">

<div class="grid grid-cols-3">
<label for="description" class="pt-2">Description</label>
<input type="text" id="description" class="col-span-2 mt-1" placeholder="e.g. Mentions"/>
<div class="flex flex-col">

<div class="flex">
<label for="description" class="w-20" style="margin-top: 0.125rem">Description</label>
<input type="text" id="description">
</div>

<div class="flex">
<label for="expires" class="pt-2 w-20 flex" style="margin-top: 0.125rem">Expires</label>
<input type="datetime-local" id="expires" class="mt-2 h-5 border outline-none border-slate-400 dark:border-slate-700 dark:background-gray-800"/>
</div>

</div>

<div class="container">
Expand Down
4 changes: 4 additions & 0 deletions web/sub-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function createSubscription() {
}
},
}
const expires = document.getElementById("expires").value;
if (expires && expires !== "") {
payload.expires = expires;
}
if (payload.description === "") {
validationErr = "empty description";
} else {
Expand Down

0 comments on commit fb54007

Please sign in to comment.