Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Mar 5, 2024
2 parents 7c91a30 + e29a184 commit 227431e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 37 deletions.
10 changes: 10 additions & 0 deletions web/pub-msg-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@
<label for="msg_id" class="pt-1">Id</label>
<input type="text" id="msg_id" disabled="disabled" value="" class="border w-full focus:shadow-md outline-none text-sm text-slate-700"/>
</span>
<p class="text-stone-500 flex flex-row space-x-1">
<span class="text-xl"></span>
<span>
Any source publishing any
<a href="https://www.acm.org/publications/policies/inappropriate-content-policy" class="text-blue-500" target="_blank">
inappropriate content</a>
may be treated as inappropriate source and blocked.
Any user having added inappropriate sources multiple times will be blocked.
</span>
</p>
<div class="flex items-center justify-center pt-1">
<button id="button-submit" type="button" class="flex submit justify-center text-center" onclick="submitMsg()">
<svg width="21px" height="21px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
4 changes: 2 additions & 2 deletions web/pub-src-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<span id="last_upd" class="ml-2 col-span-2 py-1">YYYY-MM-DDThh-mm-ss.SSSZ</span>
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Updates:</span>
<span id="upd_period" class="ml-2 col-span-2 py-1"></span>
<span class="text-slate-500 dark:text-slate-400 text-right py-1" style="display: none">Accepted:</span>
<div class="ml-2 col-span-2 flex" style="display: none">
<span class="text-slate-500 dark:text-slate-400 text-right py-1">Accepted:</span>
<div class="ml-2 col-span-2 flex">
<input type="checkbox" disabled="disabled" id="accepted"/>
</div>
</div>
Expand Down
69 changes: 36 additions & 33 deletions web/pub-src-details.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function loadSource() {
async function loadSource() {
//
const urlParams = new URLSearchParams(window.location.search);
const typ = urlParams.get("type");
Expand All @@ -12,7 +12,7 @@ function loadSource() {
document.getElementById("freq-charts").style.display = "none";
document.body.classList.add('waiting-cursor');
document.getElementById("wait").style.display = "block";
fetch(`/v1/src/${typ}`, {
const counts = await fetch(`/v1/src/${typ}`, {
method: "GET",
headers: {
"Authorization": `Bearer ${authToken}`,
Expand Down Expand Up @@ -45,6 +45,7 @@ function loadSource() {
case true:
document.getElementById("type").innerText = "WebSub";
document.getElementById("upd_period").innerText = "Real-Time";
document.getElementById("accepted").checked = true;
break
default:
document.getElementById("type").innerText = "Feed";
Expand All @@ -53,13 +54,11 @@ function loadSource() {
break
}
document.getElementById("addr").innerHTML = `<a href="${data.addr}" target="_blank" class="text-blue-500">${data.addr}</a>`;
document.getElementById("accepted").checked = true;
break
case "site":
document.getElementById("type").innerText = "Site";
document.getElementById("upd_period").innerText = "Polling once a day";
document.getElementById("addr").innerHTML = `<a href="${data.addr}" target="_blank" class="text-blue-500">${data.addr}</a>`;
document.getElementById("accepted").checked = true;
break
case "tgch":
document.getElementById("type").innerText = "Telegram channel (App)";
Expand All @@ -71,7 +70,6 @@ function loadSource() {
document.getElementById("addr").innerHTML = `<a href="${data.addr}" target="_blank" class="text-blue-500">${data.addr}</a>`;
}
document.getElementById("name").innerText = data.name;
document.getElementById("accepted").checked = true;
break
case "tgbc":
document.getElementById("type").innerText = "Telegram channel (Bot)";
Expand Down Expand Up @@ -115,20 +113,18 @@ function loadSource() {
}
return null;
})
.then(counts => {
if (counts != null && Object.keys(counts).length > 0) {
document.body.classList.add('waiting-cursor');
document.getElementById("freq-charts").style.display = "block";
drawFreqChart(counts);
}
})
.catch(err => {
alert(err);
})
.finally(() => {
document.body.classList.remove('waiting-cursor');
document.getElementById("wait").style.display = "none";
return null;
});
document.body.classList.remove('waiting-cursor');
document.getElementById("wait").style.display = "none";
if (counts != null) {
const pointsCount = Object.keys(counts).length;
if (pointsCount < 720 || confirm("Draw frequency chart? This may take a while.")) {
drawFreqChart(counts);
}
}
}

const weekDays = 7;
Expand All @@ -139,24 +135,31 @@ const stepX = freqChartWidth / dayMinutes;
const freqChartOffsetTop = 22;
const freqChartOffsetLeft = 30;

function drawFreqChart(counts) {
let countMax = 0;
for(const [t, c] of Object.entries(counts)) {
if (c > countMax) {
countMax = c;
async function drawFreqChart(counts) {
if (counts != null && Object.keys(counts).length > 0) {
document.body.classList.add('waiting-cursor');
document.getElementById("wait").style.display = "block";
document.getElementById("freq-charts").style.display = "block";
let countMax = 0;
for (const [t, c] of Object.entries(counts)) {
if (c > countMax) {
countMax = c;
}
}
}
const stepY = freqChartHeight / countMax;
for(let i = 0; i < weekDays; i ++) {
let chartElement = document.getElementById(`chart-freq-${i}`);
chartElement.innerHTML += `<text x="20" y="20" class="svg-text">${countMax}</text>`;
}
for(const [t, c] of Object.entries(counts)) {
const dayNum = Math.floor(t / dayMinutes);
let chartElement = document.getElementById(`chart-freq-${dayNum}`);
const h = stepY * c;
const x = freqChartOffsetLeft + (t - dayNum * dayMinutes) * stepX;
chartElement.innerHTML += `<line x1="${x}" y1="${freqChartOffsetTop+freqChartHeight}" x2="${x}" y2="${freqChartOffsetTop+freqChartHeight-h}" class="svg-chart-line-data"></line>`
const stepY = freqChartHeight / countMax;
for (let i = 0; i < weekDays; i++) {
let chartElement = document.getElementById(`chart-freq-${i}`);
chartElement.innerHTML += `<text x="20" y="20" class="svg-text">${countMax}</text>`;
}
for (const [t, c] of Object.entries(counts)) {
const dayNum = Math.floor(t / dayMinutes);
let chartElement = document.getElementById(`chart-freq-${dayNum}`);
const h = stepY * c;
const x = freqChartOffsetLeft + (t - dayNum * dayMinutes) * stepX;
chartElement.innerHTML += `<line x1="${x}" y1="${freqChartOffsetTop + freqChartHeight}" x2="${x}" y2="${freqChartOffsetTop + freqChartHeight - h}" class="svg-chart-line-data"></line>`
}
document.body.classList.remove('waiting-cursor');
document.getElementById("wait").style.display = "none";
}
}

Expand Down
44 changes: 42 additions & 2 deletions web/pub-src-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,39 @@
The current user's <i>messages publishing quota</i> will be used to publish messages from the added source.
Ensure the quota is enough for this.
</p>
<p class="text-stone-500 flex flex-row space-x-1">
<span class="text-xl"></span>
<span>
Any source publishing any
<a href="https://www.acm.org/publications/policies/inappropriate-content-policy" class="text-blue-500" target="_blank">
inappropriate content</a>
may be treated as inappropriate source and blocked.
Any user having added inappropriate sources multiple times will be blocked.
</span>
</p>
</div>
<div id="tgch" hidden="hidden" class="mt-2 space-y-2">
<div class="flex">
<label for="chan_name" class="mt-1 text-md w-24">Channel</label>
<input type="text" id="chan_name" placeholder="@proxymtproto" class="min-h-5"/>
</div>
<div class="text-slate-500 dark:text-slate-400 mt-1">
<div class="text-slate-500 mt-1">
It may take up to 5 minutes before the system starts to receive new messages from the added channel.
</div>
<p class="text-slate-500 dark:text-slate-400">
<p class="text-slate-500">
The current user's <i>messages publishing quota</i> will be used to publish messages from the added source.
Ensure the quota is enough for this.
</p>
<p class="text-stone-500 flex flex-row space-x-1">
<span class="text-xl"></span>
<span>
Any source publishing any
<a href="https://www.acm.org/publications/policies/inappropriate-content-policy" class="text-blue-500" target="_blank">
inappropriate content</a>
may be treated as inappropriate source and blocked.
Any user having added inappropriate sources multiple times will be blocked.
</span>
</p>
</div>
<div id="tgbc" hidden="hidden" class="mt-2 space-y-2">
<div class="mt-1 space-y-1">
Expand Down Expand Up @@ -111,6 +131,16 @@
The current user's <i>messages publishing quota</i> will be used to publish messages from the added source.
Ensure the quota is enough for this.
</p>
<p class="text-stone-500 flex flex-row space-x-1">
<span class="text-xl"></span>
<span>
Any source publishing any
<a href="https://www.acm.org/publications/policies/inappropriate-content-policy" class="text-blue-500" target="_blank">
inappropriate content</a>
may be treated as inappropriate source and blocked.
Any user having added inappropriate sources multiple times will be blocked.
</span>
</p>
</div>
<div id="site" hidden="hidden" class="mt-2 space-y-2">
<div class="flex">
Expand All @@ -124,6 +154,16 @@
The current user's <i>messages publishing quota</i> will be used to publish messages from the added source.
Ensure the quota is enough for this.
</p>
<p class="text-stone-500 flex flex-row space-x-1">
<span class="text-xl"></span>
<span>
Any source publishing any
<a href="https://www.acm.org/publications/policies/inappropriate-content-policy" class="text-blue-500" target="_blank">
inappropriate content</a>
may be treated as inappropriate source and blocked.
Any user having added inappropriate sources multiple times will be blocked.
</span>
</p>
</div>
</div>
<div class="flex justify-center pt-1">
Expand Down

0 comments on commit 227431e

Please sign in to comment.