hide/delete buttons + confirm popup, TODO: interactivity
This commit is contained in:
parent
9ccf112daf
commit
8761a6c5ad
10
web/app.html
10
web/app.html
@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<!-- <link href='https://overpass-30e2.kxcdn.com/overpass.css' rel='stylesheet'> -->
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<title>Aliexpress price tracker</title>
|
<title>Aliexpress price tracker</title>
|
||||||
</head>
|
</head>
|
||||||
@ -19,6 +20,15 @@
|
|||||||
<button id="addbutton" type="button">Add</button>
|
<button id="addbutton" type="button">Add</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--popup confirmation window-->
|
||||||
|
<div id="confirmationPopup" class="popup">
|
||||||
|
<div class="popup-content">
|
||||||
|
<p>Are you sure?</p>
|
||||||
|
<button id="yesBtn">Yes</button>
|
||||||
|
<button id="noBtn">No</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- div where graphs will take place -->
|
<!-- div where graphs will take place -->
|
||||||
<div class="content" id="graphs"></div>
|
<div class="content" id="graphs"></div>
|
||||||
|
|
||||||
|
51
web/app.js
51
web/app.js
@ -14,6 +14,9 @@ const width = window.innerWidth - margin.right - margin.left -10;
|
|||||||
// url
|
// url
|
||||||
const currentUrl = window.location.href;
|
const currentUrl = window.location.href;
|
||||||
|
|
||||||
|
// global delete key
|
||||||
|
var del_key = null;
|
||||||
|
|
||||||
|
|
||||||
// reload page when window is resized
|
// reload page when window is resized
|
||||||
// (resizes every elements)
|
// (resizes every elements)
|
||||||
@ -57,7 +60,8 @@ async function fetch_item() {
|
|||||||
skuid: skuid,
|
skuid: skuid,
|
||||||
choice: choice,
|
choice: choice,
|
||||||
attributes: attributes,
|
attributes: attributes,
|
||||||
image: image
|
image: image,
|
||||||
|
show: true
|
||||||
};
|
};
|
||||||
|
|
||||||
item[uuid] = values;
|
item[uuid] = values;
|
||||||
@ -76,6 +80,9 @@ async function fetch_item() {
|
|||||||
fetch_history().then(async function(data) {
|
fetch_history().then(async function(data) {
|
||||||
items = await fetch_item();
|
items = await fetch_item();
|
||||||
|
|
||||||
|
// by default, do not show hidden items
|
||||||
|
var show_hidden = false;
|
||||||
|
|
||||||
// Date domain (width)
|
// Date domain (width)
|
||||||
const x = d3.scaleTime()
|
const x = d3.scaleTime()
|
||||||
.domain(d3.extent(data, d => d.date))
|
.domain(d3.extent(data, d => d.date))
|
||||||
@ -103,6 +110,7 @@ fetch_history().then(async function(data) {
|
|||||||
|
|
||||||
// plot for each graph
|
// plot for each graph
|
||||||
svgs.each(function(key) {
|
svgs.each(function(key) {
|
||||||
|
if (show_hidden || items[key].show) {
|
||||||
const dataSubset = nestedData.get(key);
|
const dataSubset = nestedData.get(key);
|
||||||
const svg = d3.select(this);
|
const svg = d3.select(this);
|
||||||
|
|
||||||
@ -119,6 +127,28 @@ fetch_history().then(async function(data) {
|
|||||||
window.open(link, '_blank', 'noopener,noreferrer');
|
window.open(link, '_blank', 'noopener,noreferrer');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// BUTTONS FOR EACH GRAPH
|
||||||
|
// buttons to hide or show item
|
||||||
|
g_div = this.parentNode.parentNode;
|
||||||
|
const hide_button = document.createElement("button");
|
||||||
|
hide_button.innerHTML = "hide";
|
||||||
|
hide_button.style.position = "relative";
|
||||||
|
hide_button.style.top = `-${height+margin.bottom}px`;
|
||||||
|
hide_button.style.left = `${margin.left+20}px`;
|
||||||
|
g_div.append(hide_button);
|
||||||
|
// button to delete item
|
||||||
|
const del_button = document.createElement("button");
|
||||||
|
del_button.innerHTML = "delete";
|
||||||
|
del_button.style.position = "relative";
|
||||||
|
del_button.style.top = `-${height+margin.bottom}px`;
|
||||||
|
del_button.style.left = `${margin.left+30}px`;
|
||||||
|
del_button.addEventListener("click", function () {
|
||||||
|
confirmationPopup.style.display = 'flex';
|
||||||
|
del_key = key;
|
||||||
|
});
|
||||||
|
g_div.append(del_button);
|
||||||
|
|
||||||
|
|
||||||
// Price domain (height)
|
// Price domain (height)
|
||||||
const y = d3.scaleLinear()
|
const y = d3.scaleLinear()
|
||||||
.domain([d3.min(dataSubset, d => d.value) - 1, d3.max(dataSubset, d => d.value) + 1])
|
.domain([d3.min(dataSubset, d => d.value) - 1, d3.max(dataSubset, d => d.value) + 1])
|
||||||
@ -279,6 +309,7 @@ fetch_history().then(async function(data) {
|
|||||||
.on("mouseover", mouseover)
|
.on("mouseover", mouseover)
|
||||||
.on("mousemove", mousemove)
|
.on("mousemove", mousemove)
|
||||||
.on("mouseleave", mouseleave);
|
.on("mouseleave", mouseleave);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -324,3 +355,21 @@ async function addItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// delete item, pop-up confirm
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const yesBtn = document.getElementById('yesBtn');
|
||||||
|
const noBtn = document.getElementById('noBtn');
|
||||||
|
yesBtn.addEventListener('click', function () {
|
||||||
|
// Add your function to execute on 'Yes' click
|
||||||
|
console.log('Yes clicked');
|
||||||
|
console.log(del_key);
|
||||||
|
confirmationPopup.style.display = 'none';
|
||||||
|
});
|
||||||
|
noBtn.addEventListener('click', function () {
|
||||||
|
// Add your function to execute on 'No' click
|
||||||
|
console.log('No clicked');
|
||||||
|
confirmationPopup.style.display = 'none';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
/* font-family: 'overpass'; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-content {
|
||||||
|
background: #3d3d3d;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner {
|
.banner {
|
||||||
@ -8,6 +28,7 @@ body {
|
|||||||
color: #fff; /* text color */
|
color: #fff; /* text color */
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
z-index: 300;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user