Skip to content

Commit

Permalink
Fix broken breakdown after history corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
starscouts committed Dec 14, 2024
1 parent 87d4214 commit cf9ead6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 40 deletions.
31 changes: 3 additions & 28 deletions .idea/deployment.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/sshConfigs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/webServers.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions client/src/breakdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function fillBreakdown() {

function buildSVG() {
let width = document.getElementById("sp-app-global-box").clientWidth;
breakdown.reverse();

document.getElementById("sp-app-breakdown-box-inner").innerHTML = `
<svg viewBox="-5 -5 ${width + 5} 155" class="chart" id="sp-app-breakdown-svg">
Expand Down Expand Up @@ -83,6 +84,7 @@ function fillBreakdown() {
</div>
`;

breakdown.reverse();
let inner = document.getElementById("sp-app-breakdown-box-inner");

inner.onmouseleave = inner.ontouchend = (event) => {
Expand All @@ -97,17 +99,21 @@ function fillBreakdown() {
}

inner.onmousemove = inner.ontouchstart = inner.ontouchmove = (event) => {
let realBreakdown = [...breakdown];

while (realBreakdown.length < 90) {
realBreakdown.unshift(null);
}

if (event.touches) {
event.preventDefault();
document.getElementById("sp-app-global").classList.add("mobile-focus");
}

document.getElementById("sp-app-breakdown-box-cursor").style.opacity = "1";

let position = event.clientX ?? event.touches[0].clientX;
let day = 90 - Math.round((((position - inner.getBoundingClientRect().left) / inner.clientWidth) * 90) - 0.7);

if (!breakdown[90 - day]) {
if (!realBreakdown[90 - day]) {
if (90 - day > 90) {
day = 0;
position = inner.getBoundingClientRect().right;
Expand All @@ -123,7 +129,13 @@ function fillBreakdown() {
document.getElementById("sp-app-breakdown-box-cursor-text").classList.remove("left");
}

document.getElementById("sp-app-breakdown-box-cursor").style.marginLeft = (position - inner.getBoundingClientRect().left) + "px";
if (realBreakdown[90 - day]) {
document.getElementById("sp-app-breakdown-box-cursor").style.marginLeft = (position - inner.getBoundingClientRect().left) + "px";
document.getElementById("sp-app-breakdown-box-cursor").style.opacity = "1";
} else {
document.getElementById("sp-app-breakdown-box-cursor").style.opacity = "0";
}

let date = document.getElementById("sp-app-breakdown-box-cursor-text-relative");

if (day === 0) {
Expand All @@ -136,7 +148,9 @@ function fillBreakdown() {
date.innerText = new Date(new Date().getTime() - (86400000 * day)).toLocaleString("en-IE", { weekday: "short", day: "numeric", month: "short" });
}

document.getElementById("sp-app-breakdown-box-cursor-text-uptime").innerText = breakdown[90 - day][0].toFixed(2) + "% uptime";
if (realBreakdown[90 - day]) {
document.getElementById("sp-app-breakdown-box-cursor-text-uptime").innerText = realBreakdown[90 - day][0].toFixed(2) + "% uptime";
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const VERSION = "4.1.4";
const VERSION = "4.1.5";
const DATA_URL = "https://d6gd1hq6b89h1s1v.public.blob.vercel-storage.com/public/status.dat";

const CATEGORIES = [
Expand Down
4 changes: 4 additions & 0 deletions client/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,7 @@
#sp-app-global-box-text-uptime, #sp-app-global-box-ping {
color: var(--fella-text-secondary);
}

#sp-app-breakdown-svg {
transform: rotateY(180deg);
}
4 changes: 2 additions & 2 deletions statusng/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions statusng/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "statusng"
version = "4.1.4"
version = "4.1.5"
edition = "2021"

[dependencies]
Expand All @@ -16,4 +16,4 @@ md5 = "0.7.0"
toml = "0.8.19"
dns-lookup = "2.0.4"
rustls = "0.23.17"
rustls-native-certs = "0.8.0"
rustls-native-certs = "0.8.0"

0 comments on commit cf9ead6

Please sign in to comment.