Skip to content

Commit

Permalink
feat: internal comm
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Mar 8, 2024
1 parent f57fd9c commit 2238819
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
37 changes: 37 additions & 0 deletions web/intcomm.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,43 @@ async function requestIncreasePublishingDailyLimit(objId) {
}
}

async function requestPublishingSourceDedicated(addr){
const userIdCurrent = localStorage.getItem(keyUserId);
const msg = "Request to make the source dedicated.\nPlease justify how it is useful for others:"
const reason = prompt(msg);
if (reason) {
const payload = {
id: uuidv4(),
specVersion: "1.0",
source: "awakari.com",
type: "com.github.awakari.webapp",
attributes: {
reason: {
ce_string: reason,
},
limit: {
ce_integer: parseInt(document.getElementById("limit").value),
},
action: {
ce_string: "request",
},
object: {
ce_string: `make dedicated ${addr}`,
},
subject: {
ce_string: userIdCurrent,
},
},
text_data: `User ${userIdCurrent} requests to make the source ${addr} dedicated`,
}
if (await submitMessageInternal(payload, userIdCurrent)) {
document.getElementById("request-increase-success-dialog").style.display = "block";
document.getElementById("request-id").innerText = payload.id;
document.getElementById("pub-src-nominate").disable();
}
}
}

async function requestIncreaseSubscriptionsLimit(userId) {
const msg = "Request to increase the subscriptions limit\nPlease enter the number to add:"
const input = prompt(msg, "1");
Expand Down
15 changes: 13 additions & 2 deletions web/pub-src-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<img src="wait.gif"/>
</div>
<form class="space-y-2">
<div class="grid grid-cols-3">
<div class="grid grid-cols-3 space-y-1">
<span class="text-slate-500 dark:text-slate-400 py-1 text-right">Type:</span>
<span id="type" class="ml-2 col-span-2 py-1"></span>
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Address:</span>
Expand Down Expand Up @@ -87,7 +87,18 @@

</div>
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Limit Owner:</span>
<span id="owner" class="ml-2 col-span-2 py-1"></span>
<div class="col-span-2 space-x-2 flex">

<span id="owner" class="ml-2 col-span-2 py-1"></span>

<button id="pub-src-nominate"
style="display: none"
type="button"
class="text-blue-500 border border-blue-500 h-6 hover:bg-blue-200 dark:hover:bg-blue-900 static w-[100px]">
★ Nominate
</button>

</div>
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Published Today:</span>
<span id="count" class="ml-2 col-span-2 py-1"></span>
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Published Total:</span>
Expand Down
4 changes: 4 additions & 0 deletions web/pub-src-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ async function loadSource() {
document.getElementById("pub-src-lim-incr-btn").onclick = () => {
requestIncreasePublishingDailyLimit(data.userId);
};
document.getElementById("pub-src-nominate").style.display = "block";
document.getElementById("pub-src-nominate").onclick = () => {
requestPublishingSourceDedicated(data.addr);
}
break;
}
document.getElementById("limit").innerText = data.usage.limit;
Expand Down

0 comments on commit 2238819

Please sign in to comment.